From f186a44f826d17786b464b2fcdc7b88b3c55876a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 27 May 2010 20:10:53 +0800 Subject: [PATCH] x86_64 starts without erroring, reaches high mem and full 64-bit --- Kernel/Makefile.BuildNum | 2 +- Kernel/arch/x86_64/start32.asm | 11 ++++------- Kernel/arch/x86_64/start64.asm | 25 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index 2e18d025..165c6a4b 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 2206 +BUILD_NUM = 2212 diff --git a/Kernel/arch/x86_64/start32.asm b/Kernel/arch/x86_64/start32.asm index 21e7c408..6f3c9a77 100644 --- a/Kernel/arch/x86_64/start32.asm +++ b/Kernel/arch/x86_64/start32.asm @@ -33,8 +33,12 @@ mboot: [global start] start: ; Check for Long Mode support + mov eax, 0x80000000 + cpuid + cmp eax, 0x80000001 ; Compare the A-register with 0x80000001. mov eax, 0x80000001 cpuid + jb .not64bitCapable test edx, 1<<29 jz .not64bitCapable @@ -60,13 +64,6 @@ start: ; Load GDT lgdt [gGDTPtr - KERNEL_BASE] - mov ax, 0x10 - mov ss, ax - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - jmp 0x08:start64 - KERNEL_BASE .not64bitCapable: diff --git a/Kernel/arch/x86_64/start64.asm b/Kernel/arch/x86_64/start64.asm index a2ffb19b..699c7931 100644 --- a/Kernel/arch/x86_64/start64.asm +++ b/Kernel/arch/x86_64/start64.asm @@ -6,9 +6,32 @@ [section .text] [global start64] start64: + ; Load Registers + mov ax, 0x10 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + + ; Go to high memory + mov rax, start64.himem + jmp rax +.himem: + + ; Clear the screen + mov rax, 0x1F201F201F201F20 ; Set the screen to White on blue, space (4 characters) + mov edi, 0xB8000 + mov ecx, 80*25*2/8 + rep stosq + ; Set kernel stack + mov rsp, gInitialKernelStack + ; Call main - jmp $ + cli +.hlt: + hlt + jmp .hlt [global GetRIP] GetRIP: -- 2.20.1