summaryrefslogtreecommitdiff
path: root/kernel/cpu.c
diff options
context:
space:
mode:
authorAda Christine <adachristine18@gmail.com>2021-04-11 09:05:25 +0000
committerAda Christine <adachristine18@gmail.com>2021-04-11 09:05:25 +0000
commit19a91071908c49365290fb1a49a5da8e354989e2 (patch)
tree59667272fc339fec1095d9ce8ad383be13bd0b78 /kernel/cpu.c
parent922e6ca1bc48cf62ad599ef1a2d63bf338a0e8c3 (diff)
added rule to compile .S files; page fault ISR and skeleton handler are present
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index db4108f..ed1a04e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1,4 +1,5 @@
#include "cpu.h"
+#include "exceptions.h"
#include <stdint.h>
@@ -140,6 +141,7 @@ static void gdt_init(void)
"mov %w2, %%es\n"
"mov %w2, %%fs\n"
"mov %w2, %%gs\n"
+ "mov %w2, %%ss\n"
// make a far return frame on the stack
// [ss] @rsp+8
// [rip] @rsp
@@ -183,11 +185,24 @@ void cpu_init(void)
{
gdt_init();
idt_init();
+ exceptions_init();
}
-void isr_install(int vec, void *isr, int ist)
+void exceptions_init(void)
{
- set_idt(vec, CODE_SEG_INDEX << 3, (uint64_t)isr, INT64_GATE);
+ isr_install(PAGE_FAULT_VECTOR, &page_fault_isr, 0, 0);
+}
+
+void isr_install(int vec, void (*isr)(void), int trap, int ist)
+{
+ enum gate_descriptor_type type = INT64_GATE;
+
+ if (trap)
+ {
+ type = TRAP64_GATE;
+ }
+
+ set_idt(vec, CODE_SEG_INDEX << 3, (uint64_t)isr, type);
if (ist)
{
set_ist(vec, ist);