feat(adapter-riscv): add Sv39 page tables with identity mapping and MMU activation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
mod page_table;
|
||||
mod uart;
|
||||
|
||||
use core::arch::global_asm;
|
||||
@@ -22,6 +23,7 @@ spin:
|
||||
unsafe extern "C" {
|
||||
static _bss_start: u8;
|
||||
static _bss_end: u8;
|
||||
static _heap_start: u8;
|
||||
}
|
||||
|
||||
fn zero_bss() {
|
||||
@@ -40,6 +42,12 @@ extern "C" fn kmain() -> ! {
|
||||
let uart = Uart::new();
|
||||
uart.write_str("k-os: booted on RISC-V\n");
|
||||
|
||||
let heap_start = unsafe { &_heap_start as *const u8 as usize };
|
||||
page_table::init_page_allocator(heap_start);
|
||||
let kernel_pt = page_table::init_kernel_page_table();
|
||||
page_table::activate(kernel_pt);
|
||||
uart.write_str("k-os: MMU enabled (Sv39)\n");
|
||||
|
||||
loop {
|
||||
unsafe { core::arch::asm!("wfi") };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user