Files
bsb2/kernel/arch/gdt.cc
2025-11-10 11:46:58 +01:00

43 lines
1.1 KiB
C++

#include "gdt.h"
#include "core.h"
#include "tss.h"
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) constinit 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(),
//SegmentDescriptor::TSSHigh(),
};
extern "C" constexpr Pointer gdt_long_mode_pointer(long_mode);
} // namespace GDT