-
Notifications
You must be signed in to change notification settings - Fork 1
/
gdt.hpp
44 lines (40 loc) · 1.14 KB
/
gdt.hpp
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
#pragma once
#include "util/gdt.hpp"
namespace gdt {
constexpr uint64_t gdt[] = {
0, // null-selector is invalid, no matter what the entry is, so set to an invalid value
util::gdt::Entry(
/*.base = */0,
/*.limit = */0xffff'ffff,
/*.ring = */0,
/*.rw = */true,
/*.size = */util::gdt::entry::Size::bit32,
/*.type = */util::gdt::entry::Type::code,
/*.code_flags = */util::gdt::entry::CodeFlags {
/*.conforming = */false
}
).bin(),
util::gdt::Entry(
/*.base = */0,
/*.limit = */0xffff'ffff,
/*.ring = */0,
/*.rw = */true,
/*.size = */util::gdt::entry::Size::bit32,
/*.type = */util::gdt::entry::Type::data,
/*.data_flags = */util::gdt::entry::DataFlags {
/*.dir = */util::gdt::entry::Direction::up
}
).bin()
};
constexpr util::gdt::GDTR gdtr = {
/*.gdt_size = */sizeof(gdt)-1,
/*.gdt = */gdt
};
constexpr unsigned int getSelector(const unsigned int n) {
return sizeof(gdt[0])*n;
}
namespace selector {
constexpr unsigned int code = getSelector(1);
constexpr unsigned int data = getSelector(2);
}
}