blob: 5ddda505a720c63b9854c1245f840327d139bc6e (
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
40
41
42
43
44
45
|
#include <stddef.h>
#include "arch/x86_64/tables.h"
#include "arch/x86_64/idt.h"
#include "arch/processor.h"
#include "print.h"
#include "jove.h"
PAGEALIGN
static interrupt_gate_t s_idtd[48];
uint64_t __isr_err;
uint64_t __isr_num;
extern void x86_64_lidt(struct XDTR *idtr);
void
idt_init(void)
{
extern uintptr_t __isr_stubs[22];
for(int i = 0; i < 22; i++)
{
uintptr_t base = __isr_stubs[i];
s_idtd[i] = (interrupt_gate_t){
.base_0_15 = (base & 0xFFFF),
.segment_selector = 0x8,
.ist = 0,
.zero_0 = 0,
.type = 0xE,
.zero_1 = 0,
.dpl = 0,
.p = 1,
.base_16_31 = (base >> 16) & 0xFFFF,
.base_32_63 = (base >> 32) & 0xFFFFFFFF,
.resv = 0
};
}
}
void
idt_setup(processor_t *proc)
{
proc->_idtr = (struct XDTR){
.length = sizeof(s_idtd) - 1,
.address = (uintptr_t)s_idtd
};
}
|