blob: bc71f05e5f4a343c809ef6bc579d36221443b4bf (
plain)
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
|
#pragma once
#include <types.h>
class IDT {
public:
struct Pointer {
uint16_t limit;
uint32_t base;
} __attribute__((packed));
enum InterruptType : uint8_t {
Null = 0,
Task = 0b10000101, // 32-bit task gate selector points to TSS rather than a code segment
Intr = 0b10001110, // 32-bit interrupt hardware interrupts are disabled while the handler runs
Trap = 0b10001111, // 32-bit trap gate hardware interrupts remain active while the handler runs
};
class Entry {
public:
constexpr Entry() = default;
Entry(void (*handler)(), uint16_t select, InterruptType t) {
offset_0_15 = reinterpret_cast<uint32_t>(handler) & 0xffff;
offset_16_31 = (reinterpret_cast<uint32_t>(handler) >> 16) & 0xffff;
selector = select;
type = t;
}
private:
uint16_t offset_0_15 = 0; // 0-15 offset in the segment
uint16_t selector = 0; // 16-31 selector of the code segment
[[maybe_unused]] uint8_t null = 0; // 32-39 unused in protected mode
InterruptType type = Null; // 40-43 type
uint16_t offset_16_31 = 0; // 48-63 offset high
} __attribute__((packed));
IDT(const uint16_t selector);
private:
Entry table[256];
};
|