Abstracts the GDT that, primarily, contains descriptors to memory segments.The GDT is a table that primarily contains segment descriptors. Segment descriptors has a size of 8 Bytes and contains the size, position, access rights, and purpose of such a segment. Unlike the LDT, the GDT is shared between all processes and may contain TSS and LDT descriptors. For the kernel, the first entry is required to be a null descriptor and the code and data segments. To support user-mode processes, additional TSS, code, and data segments for ring 3 must be added.
More...
|
enum | Segments { SEGMENT_NULL = 0,
SEGMENT_KERNEL_CODE,
SEGMENT_KERNEL_DATA
} |
|
enum | Granularity { GRANULARITY_BYTES = 0,
GRANULARITY_4KBLOCK = 1
} |
| Unit of the segment limit. More...
|
|
enum | Type { TYPE_SYSTEM16 = 0,
TYPE_SYSTEM32 = 1,
TYPE_DATA = 2,
TYPE_CODE = 3
} |
| Segment type. More...
|
|
enum | Size { SIZE_16BIT = 0,
SIZE_32BIT = 1
} |
| Address width in code segment. More...
|
|
enum | Gate {
GATE_TSS = 0x1,
GATE_LDT = 0x2,
GATE_TSS_BUSY = 0x3,
GATE_CALL = 0x4,
GATE_TASK = 0x5,
GATE_INTERRUPT = 0x6,
GATE_TRAP = 0x7
} |
| gate type More...
|
|
enum | Mode { REAL_MODE,
PROTECTED_MODE,
LONG_MODE
} |
| Modus.
|
|
|
constexpr Pointer | gdt_protected_mode_pointer (protected_mode) |
|
constexpr Pointer | gdt_long_mode_pointer (long_mode) |
|
Abstracts the GDT that, primarily, contains descriptors to memory segments.
The GDT is a table that primarily contains segment descriptors. Segment descriptors has a size of 8 Bytes and contains the size, position, access rights, and purpose of such a segment. Unlike the LDT, the GDT is shared between all processes and may contain TSS and LDT descriptors. For the kernel, the first entry is required to be a null descriptor and the code and data segments. To support user-mode processes, additional TSS, code, and data segments for ring 3 must be added.
The base address and size of the GDT are written to the GDTR register during boot (via. lgdt
).
- See also
- ISDMv3, 2.4.1; Global Descriptor Table Register (GDTR)
-
ISDMv3, 3.5.1; Segment Descriptor Tables
◆ GDT::SegmentDescriptor.__unnamed__
struct GDT::SegmentDescriptor.__unnamed__ |
Class Members |
uint64_t |
limit_low: 16 |
Least-significant bits of segment size (influenced by granularity!) |
uint64_t |
base_low: 24 |
Least-significant bits of base address. |
uint64_t |
type: 3 |
Meaning of those 3 bits depends on segment_type below. |
enum Type |
segment_type: 2 |
Segment type (influences the meaning of the 3 bits above) |
uint64_t |
privilege_level: 2 |
Ring for this segment. |
bool |
present: 1 |
Entry is valid iff set to 1. |
uint64_t |
limit_high: 4 |
Most-significant bits of segment size. |
bool |
available: 1 |
One bit to use for other purposes. |
uint64_t |
custom: 2 |
Meaning of those 2 bits depends on segment_type below. |
Granularity |
granularity: 1 |
Unit used as granularity for the segment limit. |
uint64_t |
base_high: 8 |
most-significant bits of base address |
◆ Granularity
Unit of the segment limit.
Enumerator |
---|
GRANULARITY_BYTES | Segment limit in Bytes.
|
GRANULARITY_4KBLOCK | Segment limit in blocks of 4 Kilobytes.
|
◆ Type
Segment type.
Enumerator |
---|
TYPE_SYSTEM16 | entry is a 16 bit system segment
|
TYPE_SYSTEM32 | entry is a 32 bit system segment (e.g., TSS)
|
TYPE_DATA | entry is a data segment
|
TYPE_CODE | entry is a code segment
|
◆ Size
Address width in code segment.
Enumerator |
---|
SIZE_16BIT | 16-bit addresses by default
|
SIZE_32BIT | 32-bit addresses by default
|
◆ Gate