feat: SMP stage 1 (4 harts, per-hart guarded stacks, home-core affinity, IPIs, TLB shootdown, one temporary kernel lock), 4-core storm
This commit is contained in:
@@ -8,12 +8,21 @@ unsafe extern "C" {
|
||||
static _heap_start: u8;
|
||||
}
|
||||
|
||||
pub fn init(uart: &Uart) -> &'static mut mmu::PageTable {
|
||||
pub fn init(uart: &Uart, boot_hart: usize) -> &'static mut mmu::PageTable {
|
||||
zero_bss();
|
||||
|
||||
let heap_start = unsafe { &_heap_start as *const u8 as usize };
|
||||
mmu::init_allocator(heap_start);
|
||||
let kernel_pt = mmu::init_kernel_page_table();
|
||||
let harts = crate::smp::probe_harts();
|
||||
if boot_hart >= harts {
|
||||
crate::halt(uart, "boot hart outside the hart range");
|
||||
}
|
||||
crate::smp::init(
|
||||
boot_hart,
|
||||
harts,
|
||||
mmu::virt_to_phys(kernel_pt as *const mmu::PageTable as usize),
|
||||
);
|
||||
mmu::activate(kernel_pt);
|
||||
uart.write_str("k-os: MMU enabled (Sv39)\n");
|
||||
match mmu::check_wx(kernel_pt) {
|
||||
@@ -46,7 +55,8 @@ pub fn init(uart: &Uart) -> &'static mut mmu::PageTable {
|
||||
if board::USER_POOL_PAGES > domain::memory::frame::MAX_FRAMES {
|
||||
crate::halt(uart, "user pool larger than the frame table");
|
||||
}
|
||||
let riscv_platform = platform::RiscVPlatform::new(kernel_pt as *const mmu::PageTable as usize);
|
||||
let riscv_platform =
|
||||
platform::RiscVPlatform::new(kernel_pt as *const mmu::PageTable as usize, harts as u8);
|
||||
// SAFETY: `init_in_place` writes every field of the kernel.
|
||||
unsafe {
|
||||
KERNEL.init_with(|slot| {
|
||||
|
||||
Reference in New Issue
Block a user