feat(kernel): SystemControl cap for halt, board device table + boot caps to init, RegionAddress syscall, idle loop services irqs
This commit is contained in:
@@ -17,6 +17,12 @@ use kernel_cell::KernelCell;
|
||||
|
||||
static KERNEL: KernelCell<kernel::Kernel<platform::RiscVPlatform>> = KernelCell::uninit();
|
||||
|
||||
fn kern_mut() -> &'static mut kernel::Kernel<platform::RiscVPlatform> {
|
||||
// SAFETY: single core; boot code runs before any trap can touch the
|
||||
// kernel.
|
||||
unsafe { &mut *kernel_ptr() }
|
||||
}
|
||||
|
||||
pub fn kernel_ptr() -> *mut kernel::Kernel<platform::RiscVPlatform> {
|
||||
KERNEL.as_ptr()
|
||||
}
|
||||
@@ -51,10 +57,18 @@ extern "C" fn kmain() -> ! {
|
||||
let input = boot::loader::load_server(&uart, &mut blk, b"input.elf", "input");
|
||||
let virtio_base = blk.base();
|
||||
|
||||
let board = board::devices().unwrap_or_else(|| halt(&uart, "bad board table"));
|
||||
kern_mut()
|
||||
.register_board(init.pid, &board)
|
||||
.unwrap_or_else(|_| halt(&uart, "board registration failed"));
|
||||
devices::storage_setup::configure(&uart, init.pid, storage.pid, virtio_base);
|
||||
devices::gpu_setup::configure(&uart, display.pid);
|
||||
devices::input_setup::configure(&uart, input.pid);
|
||||
boot::caps::grant_all(&uart, init.pid, storage.pid, display.pid, input.pid);
|
||||
// After grant_all, so the slots init already relies on stay put.
|
||||
kern_mut()
|
||||
.grant_boot_authority(init.pid, &board)
|
||||
.unwrap_or_else(|_| halt(&uart, "boot authority failed"));
|
||||
|
||||
uart.write_str("k-os: entering userspace\n");
|
||||
boot::loader::enter_userspace(init.pid, init.entry, SHARED_BUF_VA);
|
||||
|
||||
Reference in New Issue
Block a user