hw_x86_64: Add Genode::Gdt class

The class provides the load() function which reloads the GDTR with the
GDT address in the mtc region. This is needed to make the segments
accessible to non-core threads.

Make the _gdt_start label global to use it in the call to
_virt_mtc_addr().
This commit is contained in:
Reto Buerki 2015-02-27 10:40:34 +01:00 committed by Christian Helmuth
parent 251b270e4b
commit 968ab15bbb
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#ifndef _GDT_H_
#define _GDT_H_
#include <pseudo_descriptor.h>
#include <mtc_util.h>
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_ */

View File

@ -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 */