Change comment style, and more commenting

This commit is contained in:
Thomas Lovén 2017-11-15 21:43:00 +01:00
parent 4f9a4292e5
commit bb25b7ea35

View File

@ -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 $