From bb25b7ea35174175d61de546e449e84bcc273bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 15 Nov 2017 21:43:00 +0100 Subject: [PATCH] Change comment style, and more commenting --- src/kernel/boot/boot.S | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/kernel/boot/boot.S b/src/kernel/boot/boot.S index cc0383f..d359815 100644 --- a/src/kernel/boot/boot.S +++ b/src/kernel/boot/boot.S @@ -11,7 +11,7 @@ BootStack: .code32 error: - // Print "ERR!" in upper left corner + //; Print "ERR!" in upper left corner mov [0xb8000], dword ptr 0x4f004f00 mov [0xb8004], dword ptr 0x4f004f00 mov [0xb8000], byte ptr 'E' @@ -21,39 +21,39 @@ error: jmp $ check_cpuid: - // Save EFLAGS + //; Save EFLAGS pushfd - // Try to modify EFLAGS.ID + //; Try to modify EFLAGS.ID pushfd xor dword ptr [esp], 1<<21 popfd - //Read EFLAGS into eax + //;Read EFLAGS into eax pushfd pop eax - // Restore original EFLAGS + //; Restore original EFLAGS popfd - // Check if EFLAGS.ID was modified + //; Check if EFLAGS.ID was modified xor eax, [esp+4] and eax, 1<<21 jz error ret check_longmode: - // cpuid 0x8000 0000 + //; cpuid 0x8000 0000 mov eax, 0x80000000 cpuid cmp eax, 0x80000001 jb error - // cpuid 0x8000 0001 + //; cpuid 0x8000 0001 mov eax, 0x80000001 cpuid - // Test for long mode flag + //; Test for long mode flag test edx, 1<<29 jz error ret @@ -67,29 +67,39 @@ _start: call check_cpuid call check_longmode + //; Set CR4.PAE + //; enabling Page Address Extension mov eax, cr4 or eax, 1<<5 mov cr4, eax + //; Load a P4 page table mov eax, offset BootP4 mov cr3, eax + //; Set EFER.LME + //; enabling Long Mode mov ecx, 0x0C0000080 rdmsr or eax, 1<<8 wrmsr + //; Set CR0.PG + //; enabling Paging mov eax, cr0 or eax, 1<<31 mov cr0, eax + //; Load a new GDT lgdt [BootGDTp] + //; and update the code selector by a long jump jmp 0x8:long_mode_start .code64 long_mode_start: + //; Clear out all other selectors mov eax, 0x0 mov ss, eax mov ds, eax @@ -97,4 +107,5 @@ _start: mov fs, eax mov gs, eax + //; Loop infinitely jmp $