forked from koniifer/ableos
37 lines
840 B
Rust
37 lines
840 B
Rust
|
use alloc::{
|
||
|
boxed::Box,
|
||
|
string::{String, ToString},
|
||
|
};
|
||
|
use hashbrown::HashMap;
|
||
|
|
||
|
use crate::character_device::CharacterDevice;
|
||
|
|
||
|
pub mod dev_null;
|
||
|
pub mod dev_unicode;
|
||
|
pub mod dev_zero;
|
||
|
|
||
|
// FIXME: This is a hack to hold a device.
|
||
|
pub enum Device {
|
||
|
CharacterDevice(Box<dyn CharacterDevice>),
|
||
|
// BlockDevice,
|
||
|
}
|
||
|
unsafe impl Sync for Device {}
|
||
|
unsafe impl Send for Device {}
|
||
|
|
||
|
pub struct DeviceTable {
|
||
|
pub devices: HashMap<String, Device>,
|
||
|
}
|
||
|
use self::dev_null::DevNull;
|
||
|
pub use self::Device::*;
|
||
|
impl DeviceTable {
|
||
|
pub fn new() -> Self {
|
||
|
let mut table: HashMap<String, Device> = HashMap::new();
|
||
|
table.insert("null".to_string(), CharacterDevice(Box::new(DevNull)));
|
||
|
DeviceTable { devices: table }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
lazy_static::lazy_static!(
|
||
|
static ref DEVICE_TABLE: DeviceTable = DeviceTable::new();
|
||
|
);
|