Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions awkernel_drivers/src/hal/raspi/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions awkernel_drivers/src/mii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32, Box<dyn MiiPhy + Send + Sync>>,
Expand Down
2 changes: 2 additions & 0 deletions awkernel_drivers/src/pcie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions awkernel_drivers/src/pcie/intel/igb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ impl fmt::Display for IgbDriverErr {
}
}

impl core::error::Error for IgbDriverErr {}

impl IgbInner {
fn new(mut info: PCIeInfo) -> Result<Self, PCIeDeviceErr> {
let mut hw = igb_hw::IgbHw::new(&mut info)?;
Expand Down
2 changes: 2 additions & 0 deletions awkernel_drivers/src/pcie/intel/ixgbe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ impl fmt::Display for IxgbeDriverErr {
}
}

impl core::error::Error for IxgbeDriverErr {}

impl IxgbeInner {
fn new(mut info: PCIeInfo) -> Result<Self, PCIeDeviceErr> {
let (mut hw, ops) = ixgbe_hw::IxgbeHw::new(&mut info)?;
Expand Down
8 changes: 8 additions & 0 deletions awkernel_drivers/src/pcie/nvme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,14 @@ impl From<NvmeDriverErr> 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)?;
Expand Down
9 changes: 9 additions & 0 deletions awkernel_drivers/src/pcie/virtio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::sync::Arc;
use core::fmt;

use super::{PCIeDevice, PCIeDeviceErr, PCIeInfo};

Expand Down Expand Up @@ -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<VirtioDriverErr> for PCIeDeviceErr {
fn from(value: VirtioDriverErr) -> Self {
log::error!("virtio: {value:?}");
Expand Down
8 changes: 8 additions & 0 deletions awkernel_drivers/src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
8 changes: 8 additions & 0 deletions awkernel_lib/src/device_tree/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
2 changes: 2 additions & 0 deletions awkernel_lib/src/file/vfs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,7 @@ impl fmt::Display for VfsIoError {
}
}

impl core::error::Error for VfsIoError {}

/// The result type of this crate
pub type VfsResult<T> = core::result::Result<T, VfsError>;
9 changes: 9 additions & 0 deletions awkernel_lib/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions awkernel_lib/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions awkernel_lib/src/net/net_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
8 changes: 8 additions & 0 deletions awkernel_lib/src/storage/storage_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading