-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdescriptor_tables.h
92 lines (85 loc) · 2.46 KB
/
descriptor_tables.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include "types.h"
// Describes one GDT entry
typedef struct
{
uint16_t limit_low; // the lower 16 bits of the limit
uint16_t base_low; // the lower 16 bits of the base
uint8_t base_middle; // the next 8 bits of the base
uint8_t access; // access flags, determines the segment's ring
uint8_t granularity;
uint8_t base_high; // the last 8 bits of the base
} __attribute__((packed)) gdt_entry_t;
// Describes a pointer to the GDT
typedef struct
{
uint16_t limit; // the upper 16 bits of all selector limits
uint32_t base; // the address of the first GDT entry
} __attribute__((packed)) gdt_ptr_t;
// Describes one IDT entry
typedef struct
{
uint16_t base_low; // the lower 16 bits of the address to jump on interrupt
uint16_t selector; // kernel segment selector
uint8_t zero; // always zero
uint8_t flags; // more flags
uint16_t base_high; // the upper 16 bits of the address to jump on interrupt
} __attribute__((packed)) idt_entry_t;
// Describes a pointer to the IDT
typedef struct
{
uint16_t limit;
uint32_t base; // the address of the first IDT entry
} __attribute__((packed)) idt_ptr_t;
void gdt_init(void);
void idt_init(void);
// ISR handlers
extern void isr0 (void);
extern void isr1 (void);
extern void isr2 (void);
extern void isr3 (void);
extern void isr4 (void);
extern void isr5 (void);
extern void isr6 (void);
extern void isr7 (void);
extern void isr8 (void);
extern void isr9 (void);
extern void isr10(void);
extern void isr11(void);
extern void isr12(void);
extern void isr13(void);
extern void isr14(void);
extern void isr15(void);
extern void isr16(void);
extern void isr17(void);
extern void isr18(void);
extern void isr19(void);
extern void isr20(void);
extern void isr21(void);
extern void isr22(void);
extern void isr23(void);
extern void isr24(void);
extern void isr25(void);
extern void isr26(void);
extern void isr27(void);
extern void isr28(void);
extern void isr29(void);
extern void isr30(void);
extern void isr31(void);
// IRQ handlers (ISR 32-47)
extern void irq0 (void);
extern void irq1 (void);
extern void irq2 (void);
extern void irq3 (void);
extern void irq4 (void);
extern void irq5 (void);
extern void irq6 (void);
extern void irq7 (void);
extern void irq8 (void);
extern void irq9 (void);
extern void irq10(void);
extern void irq11(void);
extern void irq12(void);
extern void irq13(void);
extern void irq14(void);
extern void irq15(void);