-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidt.h
More file actions
33 lines (26 loc) · 941 Bytes
/
idt.h
File metadata and controls
33 lines (26 loc) · 941 Bytes
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
#pragma once
#include <stdint.h>
/* Segment selectors */
#define KERNEL_CS 0x08
/* How every interrupt gate (handler) is defined */
typedef struct {
uint16_t low_offset; /* Lower 16 bits of handler function address */
uint16_t sel; /* Kernel segment selector */
uint8_t always0;
/* First byte
* Bit 7: "Interrupt is present"
* Bits 6-5: Privilege level of caller (0=kernel..3=user)
* Bit 4: Set to 0 for interrupt gates
* Bits 3-0: bits 1110 = decimal 14 = "32 bit interrupt gate" */
uint8_t flags;
uint16_t high_offset; /* Higher 16 bits of handler function address */
} __attribute__((packed)) idt_gate_t;
/* A pointer to the array of interrupt handlers.
* Assembly instruction 'lidt' will read it */
typedef struct {
uint16_t limit;
uint32_t base;
} __attribute__((packed)) idt_register_t;
#define IDT_ENTRIES 256
void set_idt_gate(int n, uint32_t handler);
void load_idt();