blob: 1080f920cd771b855f30a6d0b5fb789115b84bdd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "arch/x86_64/tables.h"
#include "arch/x86_64/idt.h"
__attribute__((aligned(0x10)))
interrupt_gate_t s_idtd[256];
void
isr_handle(ivt_state_t* state)
{
kpanic_state(state, "Unhandled interrupt %i", state->num);
}
void
ivt_setup(void)
{
extern uintptr_t __ivt[256];
for(int i = 0; i < 256; i++) {
uintptr_t base = __ivt[i];
s_idtd[i] = (interrupt_gate_t) {
.base_0_15 = (base & 0xFFFF),
.cs = GDT_OFFSET_KERNEL_CODE,
.ist = 0,
.type_flags = IDT_TYPE_INT_GATE | IDT_FLAG_DPL(0) | IDT_FLAG_P,
.base_16_31 = (base >> 16) & 0xFFFF,
.base_32_63 = (base >> 32) & 0xFFFFFFFF,
.resv = 0
};
}
}
void
idt_setup(processor_t *processor)
{
processor->idtr.base = (uintptr_t)&s_idtd;
processor->idtr.length = sizeof(s_idtd) - 1;
extern void idt_load(void* idtr);
idt_load(&processor->idtr);
}
|