aboutsummaryrefslogtreecommitdiff
path: root/src/gdt.cc
blob: 289462b609fee65b79e2e063bf968f6481e224d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include "gdt.h"

using seg = GDT::SegmentDescriptor;

GDT::GDT()
    : segments{seg::make<0>(0, {.present = false}),                                    // null segment
               seg::make<0xffffffff>(0, {.r_w = true, .exe = true, .segment = true}),  // code segment
               seg::make<0xffffffff>(0, {.r_w = true, .segment = true})}               // data segment
{
  Pointer gdtr{.limit = sizeof(segments) - 1, .base = reinterpret_cast<uint32_t>(segments)};
  asm volatile("lgdt %0" : : "p"(gdtr));
}