mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Merge pull request #7 from phil-opp/fix_long_mode_test
Fix long mode test
This commit is contained in:
@@ -20,9 +20,9 @@ bits 32
|
|||||||
start:
|
start:
|
||||||
mov esp, stack_top
|
mov esp, stack_top
|
||||||
|
|
||||||
call check_multiboot
|
call test_multiboot
|
||||||
call check_cpuid
|
call test_cpuid
|
||||||
call check_long_mode
|
call test_long_mode
|
||||||
|
|
||||||
call setup_page_tables
|
call setup_page_tables
|
||||||
call enable_paging
|
call enable_paging
|
||||||
@@ -83,7 +83,7 @@ error:
|
|||||||
hlt
|
hlt
|
||||||
|
|
||||||
; Throw error 0 if eax doesn't contain the Multiboot 2 magic value (0x36d76289).
|
; Throw error 0 if eax doesn't contain the Multiboot 2 magic value (0x36d76289).
|
||||||
check_multiboot:
|
test_multiboot:
|
||||||
cmp eax, 0x36d76289
|
cmp eax, 0x36d76289
|
||||||
jne .no_multiboot
|
jne .no_multiboot
|
||||||
ret
|
ret
|
||||||
@@ -92,7 +92,7 @@ check_multiboot:
|
|||||||
jmp error
|
jmp error
|
||||||
|
|
||||||
; Throw error 1 if the CPU doesn't support the CPUID command.
|
; Throw error 1 if the CPU doesn't support the CPUID command.
|
||||||
check_cpuid:
|
test_cpuid:
|
||||||
pushfd ; Store the FLAGS-register.
|
pushfd ; Store the FLAGS-register.
|
||||||
pop eax ; Restore the A-register.
|
pop eax ; Restore the A-register.
|
||||||
mov ecx, eax ; Set the C-register to the A-register.
|
mov ecx, eax ; Set the C-register to the A-register.
|
||||||
@@ -111,15 +111,15 @@ check_cpuid:
|
|||||||
jmp error
|
jmp error
|
||||||
|
|
||||||
; Throw error 2 if the CPU doesn't support Long Mode.
|
; Throw error 2 if the CPU doesn't support Long Mode.
|
||||||
check_long_mode:
|
test_long_mode:
|
||||||
mov eax, 0x80000000 ; Set the A-register to 0x80000000.
|
mov eax, 0x80000000 ; Set the A-register to 0x80000000.
|
||||||
cpuid ; CPU identification.
|
cpuid ; CPU identification.
|
||||||
cmp eax, 0x80000001 ; Compare the A-register with 0x80000001.
|
cmp eax, 0x80000001 ; Compare the A-register with 0x80000001.
|
||||||
jb .no_long_mode ; It is less, there is no long mode.
|
jb .no_long_mode ; It is less, there is no long mode.
|
||||||
mov eax, 0x80000000 ; Set the A-register to 0x80000000.
|
mov eax, 0x80000001 ; Set the A-register to 0x80000001.
|
||||||
cpuid ; CPU identification.
|
cpuid ; CPU identification.
|
||||||
cmp eax, 0x80000001 ; Compare the A-register with 0x80000001.
|
test edx, 1 << 29 ; Test if the LM-bit, which is bit 29, is set in the D-register.
|
||||||
jb .no_long_mode ; It is less, there is no long mode.
|
jz .no_long_mode ; They aren't, there is no long mode.
|
||||||
ret
|
ret
|
||||||
.no_long_mode:
|
.no_long_mode:
|
||||||
mov al, "2"
|
mov al, "2"
|
||||||
|
|||||||
Reference in New Issue
Block a user