32 lines
891 B
Rust

//! Device management and interfaces
use device_api::{manager::DeviceManager, Device, DeviceId};
use crate::sync::{IrqSafeSpinlock, IrqSafeSpinlockGuard};
#[cfg(target_arch = "aarch64")]
pub mod devtree;
// TODO bus device support on aarch64
#[cfg(not(target_arch = "aarch64"))]
pub mod bus;
pub mod display;
pub mod power;
pub mod serial;
pub mod timer;
pub mod tty;
static DEVICE_MANAGER: IrqSafeSpinlock<DeviceManager> = IrqSafeSpinlock::new(DeviceManager::new());
/// Adds a device to the kernel's device table and returns the ID assigned to it
pub fn register_device(device: &'static dyn Device) -> DeviceId {
debugln!("Register {:?}", device.display_name());
DEVICE_MANAGER.lock().register(device)
}
/// Returns a safe reference to the kernel's [DeviceManager] instance
pub fn manager_lock<'a>() -> IrqSafeSpinlockGuard<'a, DeviceManager> {
DEVICE_MANAGER.lock()
}