#include "gdt.h" GDT::SegmentDescriptor::SegmentDescriptor(uint32_t base, uint32_t limit, uint8_t type) { base_low = base & 0xffff; base_high = (base >> 16) & 0xff; base_vhigh = (base >> 24) & 0xff; } uint32_t GDT::SegmentDescriptor::base() const { uint32_t base = base_vhigh; base = (base << 8) + base_high; base = (base << 8) + base_low; return base; } uint32_t GDT::SegmentDescriptor::limit() const { return 0; } GDT::GDT() : segments{{0, 0, 0}, // null segment {0, 64 * 1024 * 1024 /* 64MB */, 0x9a}, // code segment {0, 64 * 1024 * 1024 /* 64MB */, 0x92}} // data segment { Pointer gdtr{.limit = sizeof(segments) - 1, .base = reinterpret_cast(segments)}; asm volatile("lgdt %0" : : "p"(gdtr)); }