The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
idt.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
common/stdint.h
"
4
5
/**
6
* IDT gate type and attribute flags.
7
* combine these with bitwise OR to build the flags byte for an IDT entry.
8
*/
9
enum
idt_flags
10
{
11
IDT_FLAG_GATE_TASK
= 0x05,
// task gate.
12
IDT_FLAG_GATE_16BIT_INT
= 0x06,
// 16-bit interrupt gate.
13
IDT_FLAG_GATE_16BIT_TRAP
= 0x07,
// 16-bit trap gate.
14
IDT_FLAG_GATE_32BIT_INT
= 0x0E,
// 32-bit interrupt gate.
15
IDT_FLAG_GATE_32BIT_TRAP
= 0x0F,
// 32-bit trap gate.
16
17
IDT_FLAG_RING0
= (0 << 5),
// descriptor privilege level 0 (kernel).
18
IDT_FLAG_RING1
= (1 << 5),
// descriptor privilege level 1.
19
IDT_FLAG_RING2
= (2 << 5),
// descriptor privilege level 2.
20
IDT_FLAG_RING3
= (3 << 5),
// descriptor privilege level 3 (user).
21
22
IDT_FLAG_PRESENT
= 0x80
// segment present flag.
23
};
24
25
/**
26
* initialize the Interrupt Descriptor Table (IDT) and load it into the IDTR register.
27
*/
28
void
idt_initialize
(
void
);
29
30
/**
31
* load the IDT into the IDTR of the core that runs the call. idt_initialize()
32
* does it for the boot core; each other core calls this when it starts.
33
*/
34
void
idt_load_core
(
void
);
35
36
/**
37
* configure a single IDT gate entry.
38
* @param vector interrupt vector number (0–255).
39
* @param base pointer to the interrupt service routine.
40
* @param segment code segment selector for the ISR.
41
* @param flags gate type and attribute flags (see idt_flags).
42
*/
43
void
idt_set_gate
(
int
vector,
void
*
base
,
uint16_t
segment,
uint8_t
flags
);
44
45
/**
46
* enable an IDT gate by setting its present bit.
47
* @param vector interrupt vector number (0–255).
48
*/
49
void
idt_enable_gate
(
int
vector);
50
51
/**
52
* disable an IDT gate by clearing its present bit.
53
* @param vector interrupt vector number (0–255).
54
*/
55
void
idt_disable_gate
(
int
vector);
56
57
#ifdef __x86_64__
58
/**
59
* make a gate switch to an interrupt stack table stack (gdt.h, tss_set_ist).
60
* @param vector interrupt vector, 0 to 255.
61
* @param ist the IST index, 1 to 7 (0: no stack switch).
62
*/
63
void
idt_set_ist(
int
vector,
uint8_t
ist);
64
#endif
stdint.h
base
uint32_t base
Definition
gdt.c:1
idt_disable_gate
void idt_disable_gate(int vector)
disable an IDT gate by clearing its present bit.
Definition
idt.c:99
idt_load_core
void idt_load_core(void)
load the IDT into the IDTR of the core that runs the call.
Definition
idt.c:111
idt_set_gate
void idt_set_gate(int vector, void *base, uint16_t segment, uint8_t flags)
configure a single IDT gate entry.
Definition
idt.c:66
idt_enable_gate
void idt_enable_gate(int vector)
enable an IDT gate by setting its present bit.
Definition
idt.c:94
flags
uint8_t flags
Definition
idt.c:3
idt_initialize
void idt_initialize(void)
initialize the Interrupt Descriptor Table (IDT) and load it into the IDTR register.
Definition
idt.c:104
idt_flags
idt_flags
IDT gate type and attribute flags.
Definition
idt.h:10
IDT_FLAG_RING3
@ IDT_FLAG_RING3
Definition
idt.h:20
IDT_FLAG_RING0
@ IDT_FLAG_RING0
Definition
idt.h:17
IDT_FLAG_GATE_TASK
@ IDT_FLAG_GATE_TASK
Definition
idt.h:11
IDT_FLAG_GATE_32BIT_TRAP
@ IDT_FLAG_GATE_32BIT_TRAP
Definition
idt.h:15
IDT_FLAG_GATE_16BIT_INT
@ IDT_FLAG_GATE_16BIT_INT
Definition
idt.h:12
IDT_FLAG_PRESENT
@ IDT_FLAG_PRESENT
Definition
idt.h:22
IDT_FLAG_GATE_32BIT_INT
@ IDT_FLAG_GATE_32BIT_INT
Definition
idt.h:14
IDT_FLAG_RING2
@ IDT_FLAG_RING2
Definition
idt.h:19
IDT_FLAG_GATE_16BIT_TRAP
@ IDT_FLAG_GATE_16BIT_TRAP
Definition
idt.h:13
IDT_FLAG_RING1
@ IDT_FLAG_RING1
Definition
idt.h:18
uint8_t
unsigned char uint8_t
Definition
fb.h:18
uint16_t
unsigned short uint16_t
Definition
stdint.h:13
src
arch
x86
cpu
idt.h
Generated by
1.18.0