Xyris  0.5
GDT Namespace Reference

Data Structures

union  Base
 
struct  Entry
 
union  Limit
 

Functions

void init ()
 

Variables

struct Entry gdt [ARCH_GDT_MAX_ENTRIES]
 
struct Registers::GDTR gdtr
 

Function Documentation

◆ init()

void GDT::init ( )

Setup and install the GDT onto the system.

Definition at line 22 of file gdt.cpp.

23 {
24  uint8_t gdtIndex = 0;
25  const union Base nullSegmentBase = { .value = 0 };
26  const union Limit nullSegmentLimit = { .value = 0 };
27  gdt[gdtIndex++] = {
28  .limit_low = nullSegmentLimit.section.low,
29  .base_low = nullSegmentBase.section.low,
30  .accessed = 0,
31  .rw = 0,
32  .dc = 0,
33  .executable = 0,
34  .system = 0,
35  .privilege = 0,
36  .present = 0,
37  .limit_high = nullSegmentLimit.section.high,
38  .reserved = 0,
39  .longMode = 0,
40  .size = 0,
41  .granulatity = 0,
42  .base_high = nullSegmentBase.section.high,
43  };
44 
45  const union Base kernelCodeBase = { .value = 0 };
46  const union Limit kernelCodeLimit = { .value = 0x000FFFFF };
47  gdt[gdtIndex++] = {
48  .limit_low = kernelCodeLimit.section.low,
49  .base_low = kernelCodeBase.section.low,
50  .accessed = 0,
51  .rw = 1,
52  .dc = 0,
53  .executable = 1,
54  .system = 1,
55  .privilege = 0,
56  .present = 1,
57  .limit_high = kernelCodeLimit.section.high,
58  .reserved = 0,
59  .longMode = 0,
60  .size = 1,
61  .granulatity = 1,
62  .base_high = kernelCodeBase.section.high,
63  };
64 
65  const union Base kernelDataBase = { .value = 0 };
66  const union Limit kernelDataLimit = { .value = 0x000FFFFF };
67  gdt[gdtIndex++] = {
68  .limit_low = kernelDataLimit.section.low,
69  .base_low = kernelDataBase.section.low,
70  .accessed = 0,
71  .rw = 1,
72  .dc = 0,
73  .executable = 0,
74  .system = 1,
75  .privilege = 0,
76  .present = 1,
77  .limit_high = kernelDataLimit.section.high,
78  .reserved = 0,
79  .longMode = 0,
80  .size = 1,
81  .granulatity = 1,
82  .base_high = kernelDataBase.section.high,
83  };
84 
85  const union Base userCodeBase = { .value = 0 };
86  const union Limit userCodeLimit = { .value = 0x000FFFFF };
87  gdt[gdtIndex++] = {
88  .limit_low = userCodeLimit.section.low,
89  .base_low = userCodeBase.section.low,
90  .accessed = 0,
91  .rw = 1,
92  .dc = 0,
93  .executable = 1,
94  .system = 1,
95  .privilege = 3,
96  .present = 1,
97  .limit_high = userCodeLimit.section.high,
98  .reserved = 0,
99  .longMode = 0,
100  .size = 1,
101  .granulatity = 1,
102  .base_high = userCodeBase.section.high,
103  };
104 
105  const union Base userDataBase = { .value = 0 };
106  const union Limit userDataLimit = { .value = 0x000FFFFF };
107  gdt[gdtIndex++] = {
108  .limit_low = userDataLimit.section.low,
109  .base_low = userDataBase.section.low,
110  .accessed = 0,
111  .rw = 1,
112  .dc = 0,
113  .executable = 0,
114  .system = 1,
115  .privilege = 3,
116  .present = 1,
117  .limit_high = userDataLimit.section.high,
118  .reserved = 0,
119  .longMode = 0,
120  .size = 1,
121  .granulatity = 1,
122  .base_high = userDataBase.section.high,
123  };
124 
125  // Update GDT register and flush
126  gdtr.size = sizeof(gdt) - 1;
127  gdtr.base = (uint32_t)&gdt;
128 
129  gdt_flush((uint32_t)&gdtr);
130 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ gdt

struct Entry GDT::gdt[ARCH_GDT_MAX_ENTRIES]

Definition at line 19 of file gdt.cpp.

◆ gdtr

struct Registers::GDTR GDT::gdtr

Definition at line 20 of file gdt.cpp.

GDT::Entry::limit_low
uint16_t limit_low
Definition: gdt.hpp:43
GDT::gdtr
struct Registers::GDTR gdtr
Definition: gdt.cpp:20
GDT::gdt
struct Entry gdt[ARCH_GDT_MAX_ENTRIES]
Definition: gdt.cpp:19
gdt_flush
void gdt_flush(uintptr_t gdt)
Flush the global descriptor table and use the one provided.