Max OS 0.3
Loading...
Searching...
No Matches
gdt.h
Go to the documentation of this file.
1
9#ifndef MAX_OS_SYSTEM_GDT_H
10#define MAX_OS_SYSTEM_GDT_H
11
12#include <cstdint>
13#include <common/macros.h>
14#include <system/multiboot.h>
15
16
17namespace MaxOS::system {
18
19
24 enum class DescriptorFlags : uint64_t {
25 Write = (1ULL << 41),
26 Execute = (1ULL << 43),
27 CodeOrDataSegment = (1ULL << 44),
28 GrowDown = (1ULL << 45),
29 ConformFromLower = (1ULL << 46),
30 Present = (1ULL << 47),
31 LongMode = (1ULL << 53),
32 };
33
34
42 typedef struct PACKED GDTRegister {
43
44 uint16_t size;
45 uint64_t address;
46
47 } gdtr_t;
48
54
55 public:
58
59 uint64_t table[7];
60
61 gdtr_t gdtr = { };
62 void load();
63 };
64}
65
66
67#endif //MAX_OS_SYSTEM_GDT_H
Sets up the GDT in the CPU.
Definition gdt.h:53
void load()
Loads the GDT into the CPU.
Definition gdt.cpp:77
gdtr_t gdtr
The GDTR structure.
Definition gdt.h:61
uint64_t table[7]
The GDT entries.
Definition gdt.h:59
GlobalDescriptorTable()
Construct a new Global Descriptor Table object and set up the GDT entries and load it into the CPU,...
Definition gdt.cpp:18
struct PACKED MaxOS::system::GDTRegister gdtr_t
Alias for GDTRegister struct.
DescriptorFlags
Flags for the GDT entries.
Definition gdt.h:24
How the CPU stores the GDT.
Definition gdt.h:42
uint64_t address
The address of the GDT.
Definition gdt.h:45
uint16_t size
The size of the GDT.
Definition gdt.h:44