diff --git a/awkernel_drivers/src/hal/raspi/uart.rs b/awkernel_drivers/src/hal/raspi/uart.rs index a113c7a95..2d8dd9b06 100644 --- a/awkernel_drivers/src/hal/raspi/uart.rs +++ b/awkernel_drivers/src/hal/raspi/uart.rs @@ -243,6 +243,14 @@ impl Drop for Uart { } } +impl core::fmt::Display for UartError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for UartError {} + impl embedded_hal_nb::serial::Error for UartError { fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { match self { diff --git a/awkernel_drivers/src/mii.rs b/awkernel_drivers/src/mii.rs index b83984056..517335ed0 100644 --- a/awkernel_drivers/src/mii.rs +++ b/awkernel_drivers/src/mii.rs @@ -157,6 +157,14 @@ pub enum MiiError { Media, } +impl core::fmt::Display for MiiError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for MiiError {} + pub struct MiiDev { mii_data: MiiData, phys: BTreeMap>, diff --git a/awkernel_drivers/src/pcie.rs b/awkernel_drivers/src/pcie.rs index 35600f2e3..84f2c8d6a 100644 --- a/awkernel_drivers/src/pcie.rs +++ b/awkernel_drivers/src/pcie.rs @@ -102,6 +102,8 @@ impl fmt::Display for PCIeDeviceErr { } } +impl core::error::Error for PCIeDeviceErr {} + pub(crate) mod registers { use alloc::vec::Vec; use core::fmt; diff --git a/awkernel_drivers/src/pcie/intel/igb.rs b/awkernel_drivers/src/pcie/intel/igb.rs index 2f0902667..3f8239960 100644 --- a/awkernel_drivers/src/pcie/intel/igb.rs +++ b/awkernel_drivers/src/pcie/intel/igb.rs @@ -395,6 +395,8 @@ impl fmt::Display for IgbDriverErr { } } +impl core::error::Error for IgbDriverErr {} + impl IgbInner { fn new(mut info: PCIeInfo) -> Result { let mut hw = igb_hw::IgbHw::new(&mut info)?; diff --git a/awkernel_drivers/src/pcie/intel/ixgbe.rs b/awkernel_drivers/src/pcie/intel/ixgbe.rs index 3287bf5a0..b7e944748 100644 --- a/awkernel_drivers/src/pcie/intel/ixgbe.rs +++ b/awkernel_drivers/src/pcie/intel/ixgbe.rs @@ -290,6 +290,8 @@ impl fmt::Display for IxgbeDriverErr { } } +impl core::error::Error for IxgbeDriverErr {} + impl IxgbeInner { fn new(mut info: PCIeInfo) -> Result { let (mut hw, ops) = ixgbe_hw::IxgbeHw::new(&mut info)?; diff --git a/awkernel_drivers/src/pcie/nvme.rs b/awkernel_drivers/src/pcie/nvme.rs index 97c8691a2..1d73c4e54 100644 --- a/awkernel_drivers/src/pcie/nvme.rs +++ b/awkernel_drivers/src/pcie/nvme.rs @@ -1042,6 +1042,14 @@ impl From for PCIeDeviceErr { } } +impl core::fmt::Display for NvmeDriverErr { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for NvmeDriverErr {} + #[inline(always)] pub fn write_reg(info: &PCIeInfo, offset: usize, value: u32) -> Result<(), NvmeDriverErr> { let mut bar0 = info.get_bar(0).ok_or(NvmeDriverErr::NoBar0)?; diff --git a/awkernel_drivers/src/pcie/virtio.rs b/awkernel_drivers/src/pcie/virtio.rs index eb6a3daec..84a6fa797 100644 --- a/awkernel_drivers/src/pcie/virtio.rs +++ b/awkernel_drivers/src/pcie/virtio.rs @@ -1,4 +1,5 @@ use alloc::sync::Arc; +use core::fmt; use super::{PCIeDevice, PCIeDeviceErr, PCIeInfo}; @@ -36,6 +37,14 @@ pub enum VirtioDriverErr { NoSlot, } +impl fmt::Display for VirtioDriverErr { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for VirtioDriverErr {} + impl From for PCIeDeviceErr { fn from(value: VirtioDriverErr) -> Self { log::error!("virtio: {value:?}"); diff --git a/awkernel_drivers/src/rtc.rs b/awkernel_drivers/src/rtc.rs index c1a52283e..d7ff25684 100644 --- a/awkernel_drivers/src/rtc.rs +++ b/awkernel_drivers/src/rtc.rs @@ -34,3 +34,11 @@ pub enum RtcError { HardwareError, NotSupported, } + +impl core::fmt::Display for RtcError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for RtcError {} diff --git a/awkernel_lib/src/device_tree/error.rs b/awkernel_lib/src/device_tree/error.rs index 0f8182601..901484999 100644 --- a/awkernel_lib/src/device_tree/error.rs +++ b/awkernel_lib/src/device_tree/error.rs @@ -11,3 +11,11 @@ pub enum DeviceTreeError { InvalidSemantics, NotFound, } + +impl core::fmt::Display for DeviceTreeError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for DeviceTreeError {} diff --git a/awkernel_lib/src/file/vfs/error.rs b/awkernel_lib/src/file/vfs/error.rs index 377110b7f..9879aecbc 100644 --- a/awkernel_lib/src/file/vfs/error.rs +++ b/awkernel_lib/src/file/vfs/error.rs @@ -168,5 +168,7 @@ impl fmt::Display for VfsIoError { } } +impl core::error::Error for VfsIoError {} + /// The result type of this crate pub type VfsResult = core::result::Result; diff --git a/awkernel_lib/src/graphics.rs b/awkernel_lib/src/graphics.rs index f2b13a262..e17825977 100644 --- a/awkernel_lib/src/graphics.rs +++ b/awkernel_lib/src/graphics.rs @@ -6,10 +6,19 @@ use embedded_graphics::{ }; use embedded_graphics_core::pixelcolor::Rgb888; +#[derive(Debug)] pub enum FrameBufferError { NoFrameBuffer, } +impl core::fmt::Display for FrameBufferError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for FrameBufferError {} + static mut FRAME_BUFFER: Option<&'static mut dyn FrameBuffer> = None; pub trait FrameBuffer { diff --git a/awkernel_lib/src/net.rs b/awkernel_lib/src/net.rs index eb96e942d..b8446a086 100644 --- a/awkernel_lib/src/net.rs +++ b/awkernel_lib/src/net.rs @@ -71,6 +71,14 @@ pub enum NetManagerError { DeviceError(NetDevError), } +impl core::fmt::Display for NetManagerError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for NetManagerError {} + #[derive(Debug)] pub struct IfStatus { pub interface_id: u64, diff --git a/awkernel_lib/src/net/net_device.rs b/awkernel_lib/src/net/net_device.rs index 318950f10..17e2a9efa 100644 --- a/awkernel_lib/src/net/net_device.rs +++ b/awkernel_lib/src/net/net_device.rs @@ -132,6 +132,14 @@ pub enum NetDevError { MulticastAddrError, } +impl core::fmt::Display for NetDevError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for NetDevError {} + #[derive(Debug, Clone)] pub struct EtherFrameRef<'a> { pub data: &'a [u8], diff --git a/awkernel_lib/src/storage/storage_device.rs b/awkernel_lib/src/storage/storage_device.rs index 182794164..435763be8 100644 --- a/awkernel_lib/src/storage/storage_device.rs +++ b/awkernel_lib/src/storage/storage_device.rs @@ -19,6 +19,14 @@ pub enum StorageDevError { NotSupported, } +impl core::fmt::Display for StorageDevError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{self:?}") + } +} + +impl core::error::Error for StorageDevError {} + pub trait StorageDevice: Send + Sync { fn device_id(&self) -> u64;