diff cos/kernel/goto64.asm @ 24:d8627924d40d

Split up in more files and reboot command
author windel
date Fri, 02 Dec 2011 14:00:02 +0100
parents 5dd47d6eebac
children 3a6a9b929db0
line wrap: on
line diff
--- a/cos/kernel/goto64.asm	Thu Dec 01 21:42:59 2011 +0100
+++ b/cos/kernel/goto64.asm	Fri Dec 02 14:00:02 2011 +0100
@@ -10,12 +10,22 @@
 ; Use 2 mbyte pages. Is this more efficient?
 
 ; Intended memory map (copied from pure64), at the end of this file:
-; 0x0 : IDT, 256 entries
+; MOVED TO 0x5000!! 0x0 : IDT, 256 entries
 ; 0x1000 - 0x2000 : PML4 (Page map level 4)
 ; 0x2000 - 0x3000 : PDPT (page directory pointer table)
 ; 0x3000 - 0x4000 : PDT (page directory table)
 ; 0x4000 - 0x5000 : PT (page table)
-; 0x5000 - 0xA000 : Stack
+; 0x5000 - 0x6000 : IDT entries
+; 0x6000 - 0xA000 : Stack
+
+; panic macro to debug on real hardware
+%macro DOPANIC 1
+mov al, %1
+mov edi, 0xb8000
+stosb
+xchg bx,bx
+hlt
+%endmacro
 
 bits 32 ; Start in 32 bits mode, as loaded by GRUB
 
@@ -109,7 +119,7 @@
 ; Print long mode not supported
 mov edi, 0xb8000
 mov esi, hltmessage
-xor eax,eax
+xor eax, eax
 loop1:
 lodsb
 mov dl, al
@@ -118,7 +128,6 @@
 stosb
 cmp dl, 0
 jne loop1
-
 hlt
 
 cpu_has_long_mode:
@@ -138,7 +147,7 @@
 ; Clear the paging tables 0x1000, 0x2000, 0x3000 and 0x4000:
 mov edi, 0x1000
 xor eax, eax
-mov ecx, 4096
+mov ecx, 0x1000
 rep stosd
 
 ; Create PML4 table:
@@ -180,8 +189,7 @@
 or eax, 1 << 5 ; PAE-bit is bit 5
 mov cr4, eax
 
-; Load the GDT:
-lgdt [gdt64pointer]
+lgdt [gdt64pointer]              ; Load the GDT
 
 ; Set LM-bit (Long Mode bit):
 mov ecx, 0xC0000080
@@ -214,14 +222,6 @@
 
 mov rsp, 0xA000      ; Setup stack pointer.
 
-# XCHG BX, BX ; bochs breakpoint
-
 extern kmain
 call kmain              ; Call kernel in C-code
 
-# Should we ever return, remain in endless loop:
-cli
-hang:
-  hlt
-  jmp hang
-