Add get_gsbase()
This commit is contained in:
@@ -8,6 +8,7 @@ extern "C" {
|
||||
uintptr_t get_rsp();
|
||||
uintptr_t get_rip();
|
||||
uintptr_t get_frame(int frame);
|
||||
uintptr_t get_gsbase();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ get_rip:
|
||||
pop rax ; do the same thing as 'ret', except with 'jmp'
|
||||
jmp rax ; with the return address still in rax
|
||||
|
||||
global get_gsbase
|
||||
get_gsbase:
|
||||
rdgsbase rax
|
||||
ret
|
||||
|
||||
global _halt
|
||||
_halt:
|
||||
hlt
|
||||
|
||||
@@ -198,9 +198,12 @@ memory_initialize(uint16_t scratch_pages, const void *memory_map, size_t map_len
|
||||
// make sure the options we want in CR4 are set
|
||||
uint64_t cr4;
|
||||
__asm__ __volatile__ ( "mov %%cr4, %0" : "=r" (cr4) );
|
||||
cr4 |= 0x00080; // Enable global pages
|
||||
cr4 |= 0x00200; // Enable FXSAVE/FXRSTOR
|
||||
cr4 |= 0x20000; // Enable PCIDs
|
||||
cr4 |=
|
||||
0x000080 | // Enable global pages
|
||||
0x000200 | // Enable FXSAVE/FXRSTOR
|
||||
0x010000 | // Enable FSGSBASE
|
||||
0x020000 | // Enable PCIDs
|
||||
0;
|
||||
__asm__ __volatile__ ( "mov %0, %%cr4" :: "r" (cr4) );
|
||||
|
||||
// The bootloader reserved "scratch_pages" pages for page tables and
|
||||
|
||||
Reference in New Issue
Block a user