Friedrich-Alexander-Universität Erlangen-Nürnberg  /   Technische Fakultät  /   Department Informatik
gdt.h File Reference

The Global Descriptor Table (GDT). More...

#include "types.h"
Include dependency graph for gdt.h:

Classes

union  GDT::SegmentDescriptor
 Describes the structure of segment descriptors. More...
 
struct  GDT::Pointer
 Structure that describes a GDT Pointer (aka GDT Descriptor) More...
 
struct  GDT::SegmentDescriptor.__unnamed__
 
struct  GDT::SegmentDescriptor.__unnamed__
 Fields specific for Code Segment. More...
 
struct  GDT::SegmentDescriptor.__unnamed__
 Fields specific for Data Segment. More...
 
struct  GDT::SegmentDescriptor.__unnamed__
 Fields specific to the Task State Segment. More...
 
struct  GDT::SegmentDescriptor.__unnamed__
 Fields specific to the second part of the Task State Segment on x64. More...
 

Namespaces

 GDT
 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.
 

Enumerations

enum  Segments { SEGMENT_NULL = 0, SEGMENT_KERNEL_CODE, SEGMENT_KERNEL_DATA }
 
enum  GDT::Granularity { GDT::GRANULARITY_BYTES = 0, GDT::GRANULARITY_4KBLOCK = 1 }
 Unit of the segment limit. More...
 
enum  GDT::Type { GDT::TYPE_SYSTEM16 = 0, GDT::TYPE_SYSTEM32 = 1, GDT::TYPE_DATA = 2, GDT::TYPE_CODE = 3 }
 Segment type. More...
 
enum  GDT::Size { GDT::SIZE_16BIT = 0, GDT::SIZE_32BIT = 1 }
 Address width in code segment. More...
 
enum  GDT::Gate {
  GATE_TSS = 0x1, GATE_LDT = 0x2, GDT::GATE_TSS_BUSY = 0x3, GATE_CALL = 0x4,
  GDT::GATE_TASK = 0x5, GATE_INTERRUPT = 0x6, GATE_TRAP = 0x7
}
 gate type More...
 
enum  GDT::Mode { REAL_MODE, PROTECTED_MODE, LONG_MODE }
 Modus.
 

Detailed Description


Class Documentation

◆ 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

◆ GDT::SegmentDescriptor.__unnamed__

struct GDT::SegmentDescriptor.__unnamed__

Fields specific for Code Segment.

See also
ISDMv3, 3.4.5.1; Code- and Data-Segment Descriptor Types
Class Members
uint64_t __pad0__: 40 Ignored.
bool code_accessed: 1 If set, the code segment was used since the last reset of this value.
bool readable: 1 If set the code is readable (otherwise only executable)
bool conforming: 1 If set, the execution of code from this segment is only allowed when running at a privilege of numerically less than or equal to privilege_level (i.e. the executor has the same or higher privileges). However, the executor's privileges remain unchanged. For nonconforming code segments (i.e., conforming is set to 0), execution is allowed only if the privileges are equal. Execution will cause a GPF in case of privilege violation.
uint64_t __pad1__: 10 Ignored.
bool is64bit: 1 64bit code segment
Warning
If set to 1, operation_size must be 0.
Size operation_size: 1 Default address width.
uint64_t __pad2__: 0 Remainder ignored.

◆ GDT::SegmentDescriptor.__unnamed__

struct GDT::SegmentDescriptor.__unnamed__

Fields specific for Data Segment.

See also
ISDMv3, 3.4.5.1; Code- and Data-Segment Descriptor Types
Class Members
uint64_t __pad0__: 40 Ignored.
bool data_accessed: 1 If set, the data segment was used since the last reset of this value.
bool writeable: 1 If set, data is writable (otherwise read only)
bool expand_down: 1 Growing direction for dynamically growing segments.
uint64_t __pad1__: 10 Ignored.
uint64_t reserved: 1 Reserved, always set to 0!
Size big: 1 Size of the stack pointer.
Warning
Has a different meaning in case expand_down is set to 1.
uint64_t __pad2__: 0 Remainder ignored.

◆ GDT::SegmentDescriptor.__unnamed__

struct GDT::SegmentDescriptor.__unnamed__

Fields specific to the Task State Segment.

See also
ISDMv3, 7.2.2; TSS Descriptor
Class Members
uint64_t __pad0__: 40 Ignored.
enum Gate gate: 3 TSS or LDT entry.
uint64_t __pad1__: 0 Remainder ignored.

◆ GDT::SegmentDescriptor.__unnamed__

struct GDT::SegmentDescriptor.__unnamed__

Fields specific to the second part of the Task State Segment on x64.

See also
ISDMv3, 7.2.3; TSS Descriptor in 64bit mode
Class Members
uint64_t base64_high: 32 Most-significant part of 64bit TSS entries.
uint64_t __pad0__: 8 Reserved.
uint64_t zero: 5 Zero.
uint64_t __pad1__: 0 Remainder ignored.