feat: devices via caps (BootInfo, init assigns devices, drivers map MMIO/DMA themselves, IRQ-driven input); drop boot device wiring and info pages; headless display fallback
This commit is contained in:
54
crates/types/src/bootinfo.rs
Normal file
54
crates/types/src/bootinfo.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
//! What boot tells init: a read-only page at `BOOT_INFO_VA` saying which
|
||||
//! of init's capability slots hold which board device (seL4's BootInfo,
|
||||
//! reduced to what this system needs). Everything else init learns by
|
||||
//! asking the devices themselves.
|
||||
|
||||
/// Where the page is mapped in init.
|
||||
pub const BOOT_INFO_VA: usize = 0x2F000;
|
||||
/// "kosboot1", so init can tell the page is really there.
|
||||
pub const MAGIC: u64 = 0x6b6f_7362_6f6f_7431;
|
||||
pub const MAX_BOOT_DEVICES: usize = 16;
|
||||
/// A slot field with no capability in it.
|
||||
pub const NO_SLOT: u64 = u64::MAX;
|
||||
|
||||
/// What kind of device a board entry is. Board code knows; init asks the
|
||||
/// device itself only where a kind has several possibilities (which
|
||||
/// virtio device sits in a slot).
|
||||
pub const KIND_VIRTIO: u64 = 1;
|
||||
pub const KIND_UART_16550: u64 = 2;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct BootDevice {
|
||||
/// One of the `KIND_` constants.
|
||||
pub kind: u64,
|
||||
/// Physical base of the device's MMIO window.
|
||||
pub phys_base: u64,
|
||||
pub pages: u64,
|
||||
/// The device's IRQ line, 0 if it has none.
|
||||
pub irq: u64,
|
||||
/// init's slot holding the MMIO region capability.
|
||||
pub region_slot: u64,
|
||||
/// init's slot holding the IRQ capability, or `NO_SLOT`.
|
||||
pub irq_slot: u64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct BootInfo {
|
||||
pub magic: u64,
|
||||
pub device_count: u64,
|
||||
pub system_control_slot: u64,
|
||||
pub devices: [BootDevice; MAX_BOOT_DEVICES],
|
||||
}
|
||||
|
||||
impl BootInfo {
|
||||
/// The devices actually listed; empty if the page is not a BootInfo.
|
||||
pub fn devices(&self) -> &[BootDevice] {
|
||||
if self.magic != MAGIC {
|
||||
return &[];
|
||||
}
|
||||
let n = (self.device_count as usize).min(MAX_BOOT_DEVICES);
|
||||
self.devices.get(..n).unwrap_or(&[])
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
pub mod address;
|
||||
pub mod badge;
|
||||
pub mod bootinfo;
|
||||
pub mod bounded;
|
||||
pub mod display;
|
||||
pub mod generation;
|
||||
|
||||
Reference in New Issue
Block a user