Some simplification and commenting

This commit is contained in:
Thomas Lovén 2017-11-15 20:37:22 +01:00
parent 93d60294ba
commit 4f9a4292e5
2 changed files with 45 additions and 40 deletions

View File

@ -12,19 +12,32 @@ BootStack:
.code32 .code32
error: error:
// Print "ERR!" in upper left corner // Print "ERR!" in upper left corner
mov [0xb8000], dword ptr 0x4f524f45 mov [0xb8000], dword ptr 0x4f004f00
mov [0xb8004], dword ptr 0x4f214f52 mov [0xb8004], dword ptr 0x4f004f00
mov [0xb8000], byte ptr 'E'
mov [0xb8002], byte ptr 'R'
mov [0xb8004], byte ptr 'R'
mov [0xb8006], byte ptr '!'
jmp $ jmp $
check_cpuid: check_cpuid:
// Save EFLAGS
pushfd pushfd
// Try to modify EFLAGS.ID
pushfd pushfd
xor dword ptr [esp], 1<<21 xor dword ptr [esp], 1<<21
popfd popfd
//Read EFLAGS into eax
pushfd pushfd
pop eax pop eax
xor eax, [esp]
// Restore original EFLAGS
popfd popfd
// Check if EFLAGS.ID was modified
xor eax, [esp+4]
and eax, 1<<21 and eax, 1<<21
jz error jz error
ret ret
@ -72,8 +85,6 @@ mov cr0, eax
lgdt [BootGDTp] lgdt [BootGDTp]
.extern long_mode_start
jmp 0x8:long_mode_start jmp 0x8:long_mode_start
.code64 .code64

View File

@ -7,16 +7,10 @@
BootP4: BootP4:
.quad offset BootP3 + (PAGE_PRESENT | PAGE_WRITE) .quad offset BootP3 + (PAGE_PRESENT | PAGE_WRITE)
.rept ENTRIES_PER_PT - 1 .rept ENTRIES_PER_PT - 1
.quad 0x0 .quad 0
.endr .endr
BootP3: BootP3:
.quad offset BootP2 + (PAGE_PRESENT | PAGE_WRITE) .quad 0 + (PAGE_PRESENT | PAGE_WRITE | PAGE_HUGE)
.rept ENTRIES_PER_PT - 1 .rept ENTRIES_PER_PT - 1
.quad 0x0 .quad 0
.endr
BootP2:
.set i, 0
.rept ENTRIES_PER_PT
.quad (i << 21 ) + (PAGE_PRESENT | PAGE_WRITE | PAGE_HUGE)
.set i, (i+1)
.endr .endr