-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupts.h
67 lines (55 loc) · 1.54 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
#ifndef __INTERRUPTS_H
#define __INTERRUPTS_H
#include "types.h"
#include "port.h"
#include "gdt.h"
class InterruptManager;
class InterruptHandler {
protected:
uint8_t interruptNumber;
InterruptManager* interruptManager;
InterruptHandler(uint8_t interruptNumber, InterruptManager* interruptManager);
~InterruptHandler();
public:
virtual uint32_t handleInterrupt(uint32_t esp);
};
class InterruptManager {
friend class InterruptHandler;
protected:
static InterruptManager* activeInterruptManager;
InterruptHandler* handlers[0x100];
struct GateDescriptor {
uint16_t handlerAdress_lwr;
uint16_t gdt_codeSegmentSelector;
uint8_t reserved;
uint8_t access;
uint16_t handlerAdress_upr;
} __attribute__((packed));
static GateDescriptor interruptDescriptorTable[0x100];
struct InterruptDescriptorTablePointer{
uint16_t size;
uint32_t base;
}__attribute__((packed));
static void setInterruptDescriptorTableEntry(
uint8_t interrupt,
uint16_t codeSegmentSelectorOffset,
void (*handler)(),
uint8_t desciptorPrivilegeLevel,
uint8_t desciptorType
);
Port8Slow picMasterCommand;
Port8Slow picMasterData;
Port8Slow picSlaveCommand;
Port8Slow picSlaveData;
public:
InterruptManager(GlobalDescriptorTable* gdt);
~InterruptManager();
void activate();
void deactivate();
static uint32_t handleInterrupt(uint8_t interrupt, uint32_t esp);
uint32_t doHandleInterrupt(uint8_t interrupt, uint32_t esp);
static void ignoreInterruptRequest();
static void handleInterruptRequest0x00();
static void handleInterruptRequest0x01();
};
#endif