Devices: Add block devices

master
TheOddGarlic 2022-08-08 20:07:43 +03:00
parent 8c1f80b7e6
commit 272cf525af
11 changed files with 23 additions and 12 deletions

View File

@ -1,4 +1,4 @@
use kernel::device_interface::character::CharacterDevice;
use kernel::device_interface::CharacterDevice;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DevNull;

View File

@ -1,4 +1,4 @@
use kernel::device_interface::character::CharacterDevice;
use kernel::device_interface::CharacterDevice;
#[derive(Debug)]
pub struct DevUnicode {

View File

@ -1,4 +1,4 @@
use kernel::device_interface::character::CharacterDevice;
use kernel::device_interface::CharacterDevice;
#[derive(Debug)]
pub struct DevZero;

View File

@ -2,4 +2,4 @@ pub mod dev_null;
pub mod dev_unicode;
pub mod dev_zero;
pub use kernel::device_interface::character::CharacterDevice;
pub use kernel::device_interface::CharacterDevice;

View File

@ -3,7 +3,7 @@
use core::ops::Not;
use core::sync::atomic::AtomicU32;
use core::sync::atomic::Ordering;
use kernel::device_interface::character::CharacterDevice;
use kernel::device_interface::CharacterDevice;
use crate::pixel_format::Rgba64;

View File

@ -10,7 +10,7 @@ pub use self::Device::*;
use crate::devices::dev_vterm::VTerm;
use character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero};
use hashbrown::HashMap;
use kernel::device_interface::character::CharacterDevice;
use kernel::device_interface::{BlockDevice, CharacterDevice};
use spin::Lazy;
pub static DEVICE_TABLE: Lazy<spin::Mutex<DeviceTable>> =
@ -19,6 +19,7 @@ pub static DEVICE_TABLE: Lazy<spin::Mutex<DeviceTable>> =
// FIXME: This is a hack to hold a device.
// #[derive(Debug)]
pub enum Device {
Block(Box<dyn BlockDevice>),
Character(Box<dyn CharacterDevice>),
Vterm(Box<VTerm>),
}

View File

@ -1,4 +1,4 @@
use kernel::device_interface::character::CharacterDevice;
use kernel::device_interface::CharacterDevice;
pub struct Serial {
pub base: usize,

View File

@ -1,7 +1,7 @@
use {
crate::devices::Device::{Character, Vterm},
crate::devices::Device::{Block, Character, Vterm},
core::fmt::{Arguments, Error, Write},
kernel::device_interface::character::CharacterDevice,
kernel::device_interface::CharacterDevice,
};
#[derive(Debug, Clone)]
@ -35,6 +35,7 @@ impl StdIo {
}
Ok(())
}
Block(_) => todo!(),
}
}
@ -54,6 +55,7 @@ impl StdIo {
vterm.read_char().map(|c| buf.push(c));
println!("{}", buf);
}
Block(_) => todo!(),
}
}
}

View File

@ -0,0 +1,6 @@
//! Block device interface
/// Block device interface
pub trait BlockDevice {
// TODO
}

View File

@ -1 +0,0 @@
//!

View File

@ -1,4 +1,7 @@
//! Platform Agnostic Device
pub mod block;
pub mod character;
mod block;
mod character;
pub use block::BlockDevice;
pub use character::CharacterDevice;