aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/kernel/cpu/gdtr.cpp
blob: 2fe3a9904a72d2cc8550285717330e44741b8555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "arch/kernel/cpu/gdtr.hpp"

#include "arch/context_switching/descriptor_table/global_descriptor_table_pointer.hpp"

namespace teachos::arch::kernel::cpu
{
  auto store_global_descriptor_table() -> context_switching::descriptor_table::global_descriptor_table_pointer
  {
    context_switching::descriptor_table::global_descriptor_table_pointer current_value{};
    asm("sgdt %[output]" : [output] "=m"(current_value));
    return current_value;
  }

  auto
  load_global_descriptor_table(context_switching::descriptor_table::global_descriptor_table_pointer const & gdt_pointer)
      -> void
  {
    asm volatile("lgdt %[input]" : /* no output from call */ : [input] "m"(gdt_pointer));
  }
}  // namespace teachos::arch::kernel::cpu