Rename some things, and fix a map insertion.

This commit is contained in:
4lDO2
2020-04-21 19:32:51 +02:00
parent f4246deabf
commit 9232736bf1
2 changed files with 10 additions and 5 deletions

View File

@@ -129,21 +129,26 @@ const fn new_idt_reservations() -> [AtomicU64; 4] {
[AtomicU64::new(0), AtomicU64::new(0), AtomicU64::new(0), AtomicU64::new(0)]
}
/// Initialize the IDT for a
pub unsafe fn init_paging_post_heap(is_bsp: bool, cpu_id: usize) {
let mut idts_guard = IDTS.write();
let idts_btree = idts_guard.get_or_insert_with(|| BTreeMap::new());
let idt = idts_btree.entry(cpu_id).or_insert_with(|| Box::leak(Box::new(Idt::new())));
if is_bsp {
*idt = &mut INIT_BSP_IDT;
idts_btree.insert(cpu_id, &mut INIT_BSP_IDT);
} else {
init_generic(is_bsp, idt)
let idt = idts_btree.entry(cpu_id).or_insert_with(|| Box::leak(Box::new(Idt::new())));
init_generic(is_bsp, idt);
}
}
pub unsafe fn init_paging() {
/// Initializes a fully functional IDT for use before it be moved into the map. This is ONLY called
/// on the BSP, since the kernel heap is ready for the APs.
pub unsafe fn init_paging_bsp() {
init_generic(true, &mut INIT_BSP_IDT);
}
/// Initializes an IDT for any type of processor.
pub unsafe fn init_generic(is_bsp: bool, idt: &mut Idt) {
let (current_idt, current_reservations) = (&mut idt.entries, &mut idt.reservations);

View File

@@ -109,7 +109,7 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
gdt::init_paging(tcb_offset, stack_base + stack_size);
// Set up IDT
idt::init_paging();
idt::init_paging_bsp();
// Set up syscall instruction
interrupt::syscall::init();