-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterrupts.h
71 lines (57 loc) · 1.64 KB
/
interrupts.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
#ifndef INTERRUPTS_H
#define INTERRUPTS_H
#include "types.h"
#include "print.h"
#include "gdt.h"
#include "port.h"
class InterruptManager;
class InterruptHandler {
protected:
uint8_t num;
InterruptManager* manager;
InterruptHandler(int num, InterruptManager* manager);
~InterruptHandler();
public:
virtual uint32_t operator()(uint32_t esp);
};
class InterruptManager {
friend class InterruptHandler;
protected:
InterruptHandler* handlers[256];
static InterruptManager* current;
struct GateDescriptor {
uint16_t handler_low;
uint16_t gdt_code_segment;
uint8_t reserved;
uint8_t access;
uint16_t handler_high;
} __attribute__((packed));
static GateDescriptor interruptDescriptorTable[256];
static void setInterruptDescriptorTableEntry(uint8_t intnum,
uint16_t gdt_code_segment,
uint8_t privilege_level,
uint8_t type,
void (*handler)());
struct InterruptDescriptorTable {
uint16_t size;
uint32_t base;
} __attribute__((packed));
Port8slow pic_master_command;
Port8slow pic_master_data;
Port8slow pic_slave_command;
Port8slow pic_slave_data;
public:
InterruptManager(GlobalDescriptorTable* gdt);
~InterruptManager();
void activate();
void deactivate();
// calls instHandleInterrupt on the current instance
static uint32_t handleInterrupt(uint8_t num, uint32_t esp);
uint32_t instHandleInterrupt(uint8_t num, uint32_t esp);
static void ignoreInterrupt();
static void handleInterruptRequest0x00();
static void handleInterruptRequest0x01();
static void handleInterruptRequest0xCD();
static void handleException0x01();
};
#endif