From 0c83e3787f75aca3cea90fd072eb9c3fc608f165 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Mon, 15 Aug 2016 14:34:20 -0600 Subject: [PATCH] GDT and IDT in kernel space Paging constructs completed, remap kernel before jumping to kmain Panic will do a stack trace Remove SSE from none target --- x86/startup-x86_64.asm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/x86/startup-x86_64.asm b/x86/startup-x86_64.asm index 25a6102..eec7782 100644 --- a/x86/startup-x86_64.asm +++ b/x86/startup-x86_64.asm @@ -48,12 +48,12 @@ startup_arch: mov ecx, 0xC0000080 ; Read from the EFER MSR. rdmsr - or eax, 0x00000100 ; Set the Long-Mode-Enable bit. + or eax, 1 << 11 | 1 << 8 ; Set the Long-Mode-Enable and NXE bit. wrmsr ;enabling paging and protection simultaneously mov ebx, cr0 - or ebx, 0x80000001 ;Bit 31: Paging, Bit 0: Protected Mode + or ebx, 1 << 31 | 1 << 16 | 1 ;Bit 31: Paging, Bit 16: write protect kernel, Bit 0: Protected Mode mov cr0, ebx ; far jump to enable Long Mode and load CS with 64 bit segment @@ -69,13 +69,12 @@ long_mode: mov gs, rax mov ss, rax - mov rsp, 0x800000 - 128 + mov rsp, 0x0009F000 ;rust init xor rax, rax mov eax, [kernel_base + 0x18] mov rbx, gdtr - xchg bx, bx jmp rax gdtr: -- GitLab