45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#include "gdt.h"
|
|
|
|
#include "core.h"
|
|
#include "tss.h"
|
|
|
|
TSS::Entry mytss;
|
|
|
|
namespace GDT {
|
|
|
|
// The static 32-bit Global Descriptor Table (GDT)
|
|
alignas(16) constinit SegmentDescriptor protected_mode[] = {
|
|
// Null descriptor
|
|
{},
|
|
|
|
// Global code segment von 0-4GB
|
|
SegmentDescriptor::Segment(0, UINT32_MAX, true, 0, Size::Bit32),
|
|
|
|
// Global data segment von 0-4GB
|
|
SegmentDescriptor::Segment(0, UINT32_MAX, false, 0, Size::Bit32),
|
|
};
|
|
extern "C" constexpr Pointer gdt_protected_mode_pointer(protected_mode);
|
|
|
|
// The static 64-bit Global Descriptor Table (GDT)
|
|
// \see [ISDMv3 3.2.4 Segmentation in IA-32e
|
|
// Mode](intel_manual_vol3.pdf#page=91)
|
|
alignas(16) SegmentDescriptor long_mode[] = {
|
|
// Null descriptor
|
|
SegmentDescriptor::Null(),
|
|
|
|
// Global code segment
|
|
SegmentDescriptor::Segment64(true, 0),
|
|
|
|
// Global data segment
|
|
SegmentDescriptor::Segment64(false, 0),
|
|
|
|
SegmentDescriptor::Segment64(true , 3),
|
|
SegmentDescriptor::Segment64(false, 3),
|
|
|
|
SegmentDescriptor::TSSLow(mytss),
|
|
SegmentDescriptor::TSSHigh(mytss),
|
|
};
|
|
extern "C" constexpr Pointer gdt_long_mode_pointer(long_mode);
|
|
|
|
} // namespace GDT
|