feat: base PM scheduller
This commit is contained in:
@@ -5,6 +5,8 @@ use crate::mem::address::VirtAddr;
|
||||
|
||||
pub static mut IDT: crate::cpu::idt::InterruptDescriptorTable = crate::cpu::idt::InterruptDescriptorTable::new();
|
||||
|
||||
pub const TLB_SHOOTDOWN_VECTOR: u8 = 0xFD;
|
||||
|
||||
global_asm!(
|
||||
".global page_fault_stub",
|
||||
"page_fault_stub:",
|
||||
@@ -24,6 +26,26 @@ global_asm!(
|
||||
"push r14",
|
||||
"push r15",
|
||||
|
||||
".global tlb_shootdown_stub",
|
||||
"tlb_shootdown_stub:",
|
||||
"push rax",
|
||||
"push rcx",
|
||||
"push rdx",
|
||||
"push rbx",
|
||||
"push rbp",
|
||||
"push rsi",
|
||||
"push rdi",
|
||||
"push r8",
|
||||
"push r9",
|
||||
"push r10",
|
||||
"push r11",
|
||||
"push r12",
|
||||
"push r13",
|
||||
"push r14",
|
||||
"push r15",
|
||||
|
||||
"call rust_tlb_shootdown_handler",
|
||||
|
||||
"mov rdi, [rsp + 15*8]",
|
||||
"call rust_page_fault_handler",
|
||||
|
||||
@@ -49,17 +71,22 @@ global_asm!(
|
||||
|
||||
unsafe extern "C" {
|
||||
fn page_fault_stub();
|
||||
fn tlb_shootdown_stub();
|
||||
}
|
||||
|
||||
pub fn init_idt() {
|
||||
unsafe {
|
||||
let idt_mut_ptr = core::ptr::addr_of_mut!(IDT);
|
||||
(*idt_mut_ptr).set_handler(14, page_fault_stub as u64);
|
||||
|
||||
(*idt_mut_ptr).set_handler(TLB_SHOOTDOWN_VECTOR, tlb_shootdown_stub as u64);
|
||||
|
||||
let idt_static_ref: &'static crate::cpu::idt::InterruptDescriptorTable = &*core::ptr::addr_of!(IDT);
|
||||
idt_static_ref.load();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn process_deferred_mmu_events() {
|
||||
let mut vmm_guard = KERNEL_SPACE.lock();
|
||||
if let Some(space) = vmm_guard.as_mut() {
|
||||
@@ -107,3 +134,9 @@ pub extern "C" fn rust_page_fault_handler(error_code: u64) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn rust_tlb_shootdown_handler() {
|
||||
crate::mem::vmm::handle_tlb_shootdown_ipi();
|
||||
crate::cpu::lapic::send_eoi();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user