8struct [[gnu::packed]] 
IDTR {
 
 
   13static inline void load_idt(
IDTR descriptor) {
 
   14    asm(
"lidtq %0" : : 
"m"(descriptor));
 
   17struct [[gnu::packed]] 
GDTR {
 
 
   22static inline void load_gdt(
GDTR descriptor) {
 
   23    asm(
"lgdt %0" : : 
"m"(descriptor));
 
   26static inline void load_tr(
u16 selector) {
 
   27    asm(
"ltr %0" : : 
"m"(selector));
 
   30static inline auto read_cr0() -> 
u64 {
 
   32    asm volatile(
"mov %%cr0, %0" : 
"=r"(cr0));
 
   36static inline void load_cr0(
u64 cr0) {
 
   37    asm volatile(
"mov %0, %%cr0" : : 
"r"(cr0));
 
   40static inline auto read_cr2() -> 
u64 {
 
   42    asm volatile(
"mov %%cr2, %0" : 
"=r"(cr2));
 
   46static inline auto read_cr3() -> 
u64 {
 
   48    asm volatile(
"mov %%cr3, %0" : 
"=r"(cr3));
 
   52static inline void load_cr3(
u64 cr3) {
 
   53    asm volatile(
"mov %0, %%cr3" : : 
"r"(cr3) : 
"memory");
 
   56static inline auto read_cr4() -> 
u64 {
 
   58    asm volatile(
"mov %%cr4, %0" : 
"=r"(cr4));
 
   62static inline void load_cr4(
u64 cr4) {
 
   63    asm volatile(
"mov %0, %%cr4" : : 
"r"(cr4));
 
   70    asm volatile(
"invlpg (%0)" : : 
"r"(address.raw_value()) : 
"memory");
 
   74static inline void fninit() {
 
   75    asm volatile(
"fninit");
 
   81static inline void fxsave(
byte* state) {
 
   82    ASSERT(
reinterpret_cast<uptr>(state) % 16 == 0);
 
   83    asm volatile(
"fxsave64 %0" : : 
"m"(*state));
 
   89static inline void fxrstor(
byte* state) {
 
   90    ASSERT(
reinterpret_cast<uptr>(state) % 16 == 0);
 
   91    asm volatile(
"fxrstor64 %0" : : 
"m"(*state));
 
   97static inline void xsave(
byte* state) {
 
   98    ASSERT(
reinterpret_cast<uptr>(state) % 64 == 0);
 
   99    asm volatile(
"xsave %0" ::
"m"(*state));
 
  105static inline void xrstor(
byte* state) {
 
  106    ASSERT(
reinterpret_cast<uptr>(state) % 64 == 0);
 
  107    asm volatile(
"xrstor %0" : : 
"m"(*state));
 
  113static inline void xsetbv(
u32 reg, 
u64 value) {
 
  114    auto low = 
u32(value);
 
  115    auto high = 
u32(value >> 32);
 
  116    asm volatile(
"xsetbv" : : 
"a"(low), 
"c"(reg), 
"d"(high));
 
  122static inline void write_fs_base(
u64 value) {
 
  123    asm volatile(
"wrfsbase %0" : : 
"r"(
value));
 
  129static inline void write_gs_base(
u64 value) {
 
  130    asm volatile(
"wrgsbase %0" : : 
"r"(
value));
 
  137static inline void swapgs() {
 
  138    asm volatile(
"swapgs" ::: 
"memory");
 
#define ASSERT
Definition assert_bool.h:16
 
constexpr auto value
Definition value.h:34
 
uintptr_t uptr
Definition integers.h:36
 
__UINT64_TYPE__ u64
Definition integers.h:12
 
__UINT32_TYPE__ u32
Definition integers.h:11
 
__UINT16_TYPE__ u16
Definition integers.h:10
 
di::StrongInt< VirtualAddressTag > VirtualAddress
Definition virtual_address.h:25
 
Definition system_instructions.h:17
 
u64 virtual_address
Definition system_instructions.h:19
 
u16 size
Definition system_instructions.h:18
 
Definition system_instructions.h:8
 
u16 size
Definition system_instructions.h:9
 
u64 virtual_address
Definition system_instructions.h:10