summaryrefslogtreecommitdiff
path: root/kernel/cpu/idt.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-02-21 20:06:35 +0100
committerAnton Kling <anton@kling.gg>2024-02-21 20:06:35 +0100
commit9b475d3db3275d4c34f02161ae70ced5595a0fdb (patch)
tree0c50e4af3ce52017f295c44f6f4319e4a43de085 /kernel/cpu/idt.c
parent6c9cb0bd8ceb039ce387c850e25adc6f99cfcd6f (diff)
Kernel: Remove all inline assembly.
Now the kernel does not rely upon inline assembly which is often very error prone. This also means that the kernel could probably be compiled with any c99 compiler which would help future bootstrapping.
Diffstat (limited to 'kernel/cpu/idt.c')
-rw-r--r--kernel/cpu/idt.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c
index 3d866e5..ec7ca63 100644
--- a/kernel/cpu/idt.c
+++ b/kernel/cpu/idt.c
@@ -1,4 +1,6 @@
+#include <cpu/arch_inst.h>
#include <cpu/idt.h>
+#include <interrupts.h>
#include <sched/scheduler.h>
#include <stdio.h>
@@ -52,25 +54,20 @@ void general_protection_fault(reg_t *regs) {
kprintf(" Error Code: %x\n", regs->error_code);
kprintf("Instruction Pointer: %x\n", regs->eip);
dump_backtrace(12);
- asm("hlt");
- for (;;)
- ;
+ halt();
EOI(0xD - 8);
}
void double_fault(registers_t *regs) {
(void)regs;
klog("DOUBLE FAULT", LOG_ERROR);
- asm("hlt");
- for (;;)
- ;
+ halt();
}
void page_fault(reg_t *regs) {
- volatile uint32_t cr2;
- asm volatile("mov %%cr2, %0" : "=r"(cr2));
+ uint32_t cr2 = get_cr2();
if (0xDEADC0DE == cr2) {
- asm("cli");
+ disable_interrupts();
EOI(0xB);
process_pop_restore_context(NULL, regs);
return;
@@ -105,9 +102,7 @@ void page_fault(reg_t *regs) {
}
dump_backtrace(12);
- asm("hlt");
- for (;;)
- ;
+ halt();
}
static inline void io_wait(void) {