pub mod character_devs; mod dev_vterm; pub mod id; pub mod pci; pub use self::Device::*; use crate::device_interface::{BlockDevice, CharacterDevice}; use crate::devices::dev_vterm::VTerm; use character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero}; use hashbrown::HashMap; use spin::Lazy; pub static DEVICE_TABLE: Lazy> = Lazy::new(|| spin::Mutex::new(DeviceTable::new())); // FIXME: This is a hack to hold a device. // #[derive(Debug)] pub enum Device { Block(Box), Character(Box), Vterm(Box), } unsafe impl Sync for Device {} unsafe impl Send for Device {} pub struct DeviceTable { pub devices: HashMap, } impl DeviceTable { pub fn new() -> Self { DeviceTable { devices: [ ("null", Character(Box::new(DevNull))), ("zero", Character(Box::new(DevZero))), ( "unicode", Character(Box::new(DevUnicode { next_write_char: 0x00 as char, next_read_char: 0x00 as char, })), ), ("kvterm", Vterm(Box::new(VTerm::new()))), ] .into_iter() .map(|(k, v)| (k.to_string(), v)) .collect(), } } } impl Default for DeviceTable { fn default() -> Self { Self::new() } }