aboutsummaryrefslogtreecommitdiff
path: root/kernel/interrupts/idt.sats
blob: b8ee06d66c5780253ddc1e30ad390ea69d11932f (plain)
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
#define 
TRAP_GATE_FLAGS 0x8F // p=1, dpl=0b00, type=0b1111
#define
INT_GATE_FLAGS 0x8E // p=1, dpl=0b00, type=0b1110
#define
IDT_MAX_DESCRIPTORS 256


typedef idt_entry_t = @{
  isr_low = uint16,   // The lower 16 bits of the ISR's address
  kernel_cs = uint16, // The GDT segment selector that the CPU will load into CS before calling the ISR
  ist = uint8 0,        // The IST in the TSS that the CPU will load into RSP; set to zero for now 
  attributes = uint8, // Type and attributes; see the IDT page
  isr_mid = uint16,   // The higher 16 bits of the lower 32 bits of the ISR's address
  isr_high = uint32,  // The higher 32 bits of the ISR's address
  reserved = uint32 0   // Set to zero
}

typedef idtr_t = @{
  limit =  uint16 (8 * IDT_MAX_DESCRIPTORS),
  base = [l : addr] ptr l
}

// Interrupt frame to pass to ISR
typedef int_frame =  @{
  ip = [l : agz] ptr l, // instruction pointer
  cs = [l : agz] ptr l, // code segment
  rflags = uint64,
  sp = [l : agz] ptr l, // stack pointer
  ss = [l : agz] ptr l // stack segment
}

fun idt_init() : void