call set_APIC_reg_asm; \
sti; \
POP_REGS \
- addq 4, %rsp;\
+ addq $8, %rsp;\
iretq
#define HANDLER_NOERRCODE(n, handler) \
.globl handler_##n ;\
HANDLER_ERRCODE (0x0b, int_segment_not_present)
HANDLER_ERRCODE (0x0c, int_stack_segment_fault)
HANDLER_ERRCODE (0x0d, int_general_protection_fault)
-HANDLER_ERRCODE (0x0e, int_page_fault)
+.globl handler_0x0e
+ handler_0x0e:
+ cli
+ PUSH_REGS
+ movl 72(%rsp), %edi
+ movq %cr2, %rsi
+ call int_page_fault
+ movq $0xB0, %rdi
+ movq $0, %rsi
+ call set_APIC_reg_asm
+ sti
+ POP_REGS
+ addq $8, %rsp
+ iretq
HANDLER_NOERRCODE(0x0f, int_default)
HANDLER_NOERRCODE(0x10, int_x87_floating_point_exception)
HANDLER_ERRCODE (0x11, int_alignment_check)
#include <cpuid.h>
#include "interrupts.hpp"
+#include "paging.hpp"
void os::lidt(idtr idtr) {
asm volatile("lidt %0" : : "m"(idtr));
os::print("Err code: {}.\n", err_code);
while (true) { os::hlt(); }
}
-extern "C" void int_page_fault(std::uint32_t err_code) {
+extern "C" os::paging::PML4T PML4T;
+extern "C" void int_page_fault(std::uint32_t err_code, std::uint64_t vaddr) {
+ if (
+ (0xFFFF'C000'0000'0000 <= vaddr && vaddr < 0xFFFF'C000'0801'0000) // process/port info
+ ) { // Kernel memory
+ os::print("Alloccing: {}\n", vaddr);
+ os::paging::setup_page(PML4T, (void*)vaddr, true, false);
+ return;
+ }
os::print("Interrupt: Page Fault.\n");
os::print("Err code: {}.\n", err_code);
+ os::print("Vaddr: {}.\n", vaddr);
while (true) { os::hlt(); }
}
extern "C" void int_x87_floating_point_exception() {
os::print("Enabling syscalls.\n");
os::enable_syscalls();
- os::paging::setup_page(PML4T, (void*)0xFFFF'C000'0000'0000, true, false);
os::current_pid = 1;
os::get_process(os::current_pid) = test_module_process;