diff --git a/repos/base-hw/src/core/include/spec/x86_64/gdt.h b/repos/base-hw/src/core/include/spec/x86_64/gdt.h new file mode 100644 index 000000000..21ca6e4e4 --- /dev/null +++ b/repos/base-hw/src/core/include/spec/x86_64/gdt.h @@ -0,0 +1,34 @@ +#ifndef _GDT_H_ +#define _GDT_H_ + +#include +#include + +extern int _gdt_start; + +namespace Genode +{ + /** + * Global Descriptor Table (GDT) + * See Intel SDM Vol. 3A, section 3.5.1 + */ + class Gdt; +} + +class Genode::Gdt +{ + public: + + /** + * Load GDT from mtc region into GDTR. + * + * \param virt_base virtual base address of mode transition pages + */ + static void load(addr_t const virt_base) + { + asm volatile ("lgdt %0" : : "m" (Pseudo_descriptor (0x37, + _virt_mtc_addr(virt_base, (addr_t)&_gdt_start)))); + } +}; + +#endif /* _GDT_H_ */ diff --git a/repos/base-hw/src/core/spec/x86_64/mode_transition.s b/repos/base-hw/src/core/spec/x86_64/mode_transition.s index ae5e9426d..566b91de7 100644 --- a/repos/base-hw/src/core/spec/x86_64/mode_transition.s +++ b/repos/base-hw/src/core/spec/x86_64/mode_transition.s @@ -269,6 +269,7 @@ .space 2 .global _gdt_ptr + .global _gdt_start _gdt_ptr: .word _gdt_end - _gdt_start - 1 /* limit */ .long _gdt_start /* base address */