-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterrupt.h
66 lines (53 loc) · 1.23 KB
/
interrupt.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
#ifndef INTERRUPT_H
#define INTERRUPT_H
#include "types.h"
#define T_IRQ_BASE 0x20
#define IRQ_SYSCALL 0x60
struct gate {
uint16_t offset0; // offset 0:15
uint16_t selector;
uint8_t unused;
uint8_t type: 4, s: 1, dpl: 2, p: 1;
uint16_t offset1; // offset 16:31
} __attribute__ ((packed));
// Registers saved by `pushad`
struct regs {
uint32_t edi;
uint32_t esi;
uint32_t ebp;
uint32_t orig_esp;
uint32_t ebx;
uint32_t edx;
uint32_t ecx;
uint32_t eax;
};
struct int_regs {
struct regs saved_regs;
uint16_t gs;
uint16_t padding0;
uint16_t fs;
uint16_t padding1;
uint16_t es;
uint16_t padding2;
uint16_t ds;
uint16_t padding3;
uint32_t vector_num;
uint32_t error_code;
uint32_t eip;
uint16_t cs;
uint16_t padding4;
uint32_t eflags;
// below are only present on privilege level change
uint32_t esp;
uint16_t ss;
uint16_t padding5;
};
struct idt_desc {
uint16_t size;
uint16_t offset0;
uint16_t offset1;
} __attribute__ ((packed));
void set_interrupt_gate(struct gate *gate_p, uint32_t offset, uint8_t dpl);
void set_trap_gate(struct gate *gate_p, uint32_t offset, uint8_t dpl);
void init_interrupt(void);
#endif