86 const auto &Sel = SelectorTable[Idx];
88 GdtTable[Sel.m_Seg].
BaseLow = (Sel.m_Base & 0xFFFF);
89 GdtTable[Sel.m_Seg].
BaseMid = (Sel.m_Base >> 16) & 0xFF;
90 GdtTable[Sel.m_Seg].
BaseHigh = (Sel.m_Base >> 24) & 0xFF;
92 GdtTable[Sel.m_Seg].
LimitLow = (Sel.m_Limit & 0xFFFF);
96 GdtTable[Sel.m_Seg].
Access = Sel.m_Access;
104 inline void Load_gdt(
void *gdtAddress, uint16_t LimitUse)
106 struct [[gnu::packed]]
110 } GTR = { LimitUse, gdtAddress };
127 constexpr
struct Selector SelTable[GDT_ENTRIES] =
138 Load_gdt(gdt_table, GDT_ENTRIES * 8 - 1);
140 kassert (ReadCR0() & DWord<CR0::PE>(),
"PE bit of cr0 must be set for protected mode\n");
159 "ljmpl %0, $CS_LABEL\n\t" void SetGlobalDescriptorEntry(GdtEntry GdtTable[], const Selector SelectorTable[])
Set entries in GdtTable from array of Selector.
const uint32_t KERN_CS_BASE
Segment m_Seg
Segment enum.
uint8_t m_Offset
Segment byte position in gdt_table.
uint32_t m_Limit
Limit address of segment.
void gdt()
creates global descriptor table and loads it into CPU
const uint32_t USER_CS_LIMIT
const uint32_t USER_CS_BASE
uint32_t m_Base
Base address of segment.
const uint8_t KERN_CS_ACCESS
Kernel code segment access descriptor.
const uint8_t USER_DS_ACCESS
User data segment access descriptor.
uint8_t m_Granularity
Granularity setting.
const uint32_t KERN_CS_LIMIT
const uint8_t USER_DS_GRANULARITY
contains all kernel initialization routines
const uint32_t NULL_LIMIT
void Install_gdt()
Creates global descriptor entries in gdt_table, and loads into CPU.
const uint8_t USER_CS_GRANULARITY
uint8_t m_Access
Access right bytes.
const uint8_t NULL_GRANULARITY
const uint8_t GDT_ENTRIES
void Load_gdt(void *gdtAddress, uint16_t LimitUse)
assembly instruction to load gdt table to CPU
constexpr uint8_t SEG_OFFSET(const Segment Seg)
Translates code segment enum to code segment selector.
const uint32_t KERN_DS_BASE
const uint32_t KERN_DS_LIMIT
convenience structure used to set bits of GdtEntry
const uint8_t USER_CS_ACCESS
User code segment access descriptor.
const uint32_t USER_DS_BASE
const uint8_t KERN_DS_GRANULARITY
const uint32_t USER_DS_LIMIT
uint8_t LimitHighAndGranularity
Global descriptor table entry.
const uint8_t KERN_DS_ACCESS
Kernel data segment access descriptor.
const uint8_t NULL_ACCESS
const uint8_t KERN_CS_GRANULARITY