refactor(adapter-riscv): restructure into hw/, mmu/, trap/ modules with board constants
Add Priority::DEFAULT and TimeSlice::DEFAULT to types crate. All QEMU virt addresses consolidated in board.rs. Structure mirrors future adapter-arm/ layout.
This commit is contained in:
19
crates/adapter-riscv/src/mmu/allocator.rs
Normal file
19
crates/adapter-riscv/src/mmu/allocator.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use super::page_table::{PageTable, PAGE_SIZE};
|
||||
|
||||
// Boot-time bump allocator for page tables.
|
||||
// Only used during init before the scheduler starts.
|
||||
static mut NEXT_FREE: usize = 0;
|
||||
|
||||
pub fn init_allocator(start: usize) {
|
||||
unsafe { NEXT_FREE = start; }
|
||||
}
|
||||
|
||||
pub fn alloc_page_table() -> &'static mut PageTable {
|
||||
unsafe {
|
||||
let addr = NEXT_FREE;
|
||||
NEXT_FREE += PAGE_SIZE;
|
||||
let table = &mut *(addr as *mut PageTable);
|
||||
table.zero();
|
||||
table
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user