Check if long mode is available
This commit is contained in:
parent
a9328d6b67
commit
dd565454e3
@ -7,4 +7,9 @@ SECTIONS
|
||||
*(.multiboot)
|
||||
*(.text)
|
||||
}
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,58 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.section .data
|
||||
check_cpuid_stack_top:
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
check_cpuid_stack:
|
||||
nop
|
||||
|
||||
.section .text
|
||||
.global _start
|
||||
|
||||
.code32
|
||||
error:
|
||||
// Print "ERR!" in upper left corner
|
||||
mov [0xb8000], dword ptr 0x4f524f45
|
||||
mov [0xb8004], dword ptr 0x4f214f52
|
||||
jmp $
|
||||
|
||||
check_cpuid:
|
||||
mov check_cpuid_stack, esp
|
||||
pushfd
|
||||
pushfd
|
||||
xor dword ptr[esp], 1<<21
|
||||
popfd
|
||||
pushfd
|
||||
pop eax
|
||||
xor eax, [esp]
|
||||
popfd
|
||||
and eax, 1<<21
|
||||
jz error
|
||||
ret
|
||||
|
||||
check_longmode:
|
||||
// cpuid 0x8000 0000
|
||||
mov eax, 0x80000000
|
||||
cpuid
|
||||
cmp eax, 0x80000001
|
||||
jb error
|
||||
|
||||
// cpuid 0x8000 0001
|
||||
mov eax, 0x80000001
|
||||
cpuid
|
||||
|
||||
// Test for long mode flag
|
||||
test edx, 1<<29
|
||||
jz error
|
||||
ret
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
cli
|
||||
|
||||
call check_cpuid
|
||||
call check_longmode
|
||||
|
||||
|
||||
jmp $
|
||||
|
Loading…
x
Reference in New Issue
Block a user