diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-06-24 13:04:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-25 15:19:09 +0200 |
commit | 4c555684b706bb62aaf8c85d48b2b6e029654220 (patch) | |
tree | 63128d11fc95518378951a18276c872c532762cf /Kernel/Arch/x86/x86_64 | |
parent | d84abe51f569dd74637faadf5fb3f231189ff672 (diff) | |
download | serenity-4c555684b706bb62aaf8c85d48b2b6e029654220.zip |
Kernel: Set an appropriate GDT for 64-bit mode
Diffstat (limited to 'Kernel/Arch/x86/x86_64')
-rw-r--r-- | Kernel/Arch/x86/x86_64/Boot/boot.S | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Kernel/Arch/x86/x86_64/Boot/boot.S b/Kernel/Arch/x86/x86_64/Boot/boot.S index 512562c203..ba65ee00d5 100644 --- a/Kernel/Arch/x86/x86_64/Boot/boot.S +++ b/Kernel/Arch/x86/x86_64/Boot/boot.S @@ -80,13 +80,23 @@ boot_pd3 : 512 pde's 13: boot_pd3_pts[13] (3098-3100MB) (pseudo 512 4KB pages) 14: boot_pd3_pts[14] (3100-3102MB) (pseudo 512 4KB pages) 15: boot_pd3_pts[15] (3102-3104MB) (pseudo 512 4KB pages) - + 16: boot_pd3_pt1023 (4094-4096MB) (for page table mappings) the 9 page tables each contain 512 pte's that map individual 4KB pages */ +gdt64: + .quad 0 +gdt64code: + .quad (1<<43) | (1<<44) | (1<<47) | (1<<53) /* executable, code segment, present, 64-bit */ +gdt64ptr: + .short . - gdt64 - 1 + .quad gdt64 + +.set code64_sel, gdt64code - gdt64 + start: cli cld @@ -250,8 +260,13 @@ start: addl $0xc0000000, %ebx movl %ebx, multiboot_info_ptr + lgdt gdt64ptr + ljmpl $code64_sel, $1f + +.code64 +1: call init - add $4, %esp + add $4, %rsp cli loop: @@ -319,7 +334,8 @@ apic_ap_start32: movl $0x80000001, %eax cpuid testl $0x100000, %edx - je (1f - apic_ap_start + 0x8000) + // TODO: Uncomment this + //je (1f - apic_ap_start + 0x8000) /* turn on IA32_EFER.NXE */ movl $0xc0000080, %ecx rdmsr |