32 lines
891 B
Rust
Raw Normal View History

2023-07-18 18:03:45 +03:00
//! Device management and interfaces
use device_api::{manager::DeviceManager, Device, DeviceId};
use crate::sync::{IrqSafeSpinlock, IrqSafeSpinlockGuard};
#[cfg(target_arch = "aarch64")]
pub mod devtree;
2023-08-04 10:07:21 +03:00
2023-11-16 00:16:38 +02:00
// TODO bus device support on aarch64
#[cfg(not(target_arch = "aarch64"))]
2023-09-15 00:02:14 +03:00
pub mod bus;
2023-11-16 00:16:38 +02:00
pub mod display;
2023-11-16 00:16:38 +02:00
pub mod power;
pub mod serial;
2023-09-05 16:17:48 +03:00
pub mod timer;
pub mod tty;
2023-07-18 18:03:45 +03:00
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)
}
2023-08-04 10:07:21 +03:00
/// Returns a safe reference to the kernel's [DeviceManager] instance
pub fn manager_lock<'a>() -> IrqSafeSpinlockGuard<'a, DeviceManager> {
DEVICE_MANAGER.lock()
2023-08-04 10:07:21 +03:00
}