1
0
Fork 0
forked from koniifer/ableos
ableos-framebuffer/ableos/src/devices/mod.rs

37 lines
840 B
Rust
Raw Normal View History

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();
);