feat(kernel): SystemControl cap for halt, board device table + boot caps to init, RegionAddress syscall, idle loop services irqs
This commit is contained in:
@@ -8,3 +8,29 @@ pub const CLINT_BASE: usize = 0x02000000;
|
||||
pub const USER_POOL_BASE: usize = 0x84000000;
|
||||
pub const USER_POOL_PAGES: usize = 4096;
|
||||
pub const TICK_INTERVAL: u64 = 10_000_000;
|
||||
|
||||
/// QEMU virt's PLIC lines.
|
||||
const UART_IRQ: u16 = 10;
|
||||
const VIRTIO_IRQ_BASE: u16 = 1;
|
||||
const VIRTIO_SLOT_SIZE: usize = 0x1000;
|
||||
const VIRTIO_SLOTS: usize = VIRTIO_SIZE / VIRTIO_SLOT_SIZE;
|
||||
|
||||
/// Every device userspace may drive: the UART and each VirtIO MMIO slot.
|
||||
/// The PLIC, CLINT and RAM stay the kernel's.
|
||||
pub fn devices() -> Option<[kernel::BoardDevice; 1 + VIRTIO_SLOTS]> {
|
||||
use types::{address::PhysicalAddress, bounded::PageCount, id::IrqId};
|
||||
let one = PageCount::new(1)?;
|
||||
let device = |base: usize, irq: u16| kernel::BoardDevice {
|
||||
base: PhysicalAddress::from_raw(base),
|
||||
pages: one,
|
||||
irq: Some(IrqId::from_raw(irq)),
|
||||
};
|
||||
let mut all = [device(UART_BASE, UART_IRQ); 1 + VIRTIO_SLOTS];
|
||||
for (i, d) in all.iter_mut().skip(1).enumerate() {
|
||||
*d = device(
|
||||
VIRTIO_BASE + i * VIRTIO_SLOT_SIZE,
|
||||
VIRTIO_IRQ_BASE + i as u16,
|
||||
);
|
||||
}
|
||||
Some(all)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user