Skip to content
Snippets Groups Projects
Commit a022b64a authored by Nagy Tibor's avatar Nagy Tibor
Browse files

Implement CPUID feature checks

The bootloader now shows an error message instead of hanging with
a black screen on incompatible CPUs.
parent ab060320
No related branches found
No related tags found
1 merge request!5Implement CPUID feature checks
%include "cpuid.inc"
required_features:
.edx equ features_edx.fpu | features_edx.sse | features_edx.pae | features_edx.pse | features_edx.pge | features_edx.fxsr
.ecx equ features_ecx.xsave
check_cpuid:
mov eax, 1
cpuid
and edx, required_features.edx
cmp edx, required_features.edx
jne .error
and ecx, required_features.ecx
cmp ecx, required_features.ecx
jne .error
ret
.error:
mov si, .err_features
call print
.halt:
jmp .halt
.err_features: db "Required CPU features are not present",13,10,0
features_edx:
.fpu equ 1 << 0
.vme equ 1 << 1
.de equ 1 << 2
.pse equ 1 << 3
.tsc equ 1 << 4
.msr equ 1 << 5
.pae equ 1 << 6
.mce equ 1 << 7
.cx8 equ 1 << 8
.apic equ 1 << 9
.sep equ 1 << 11
.mtrr equ 1 << 12
.pge equ 1 << 13
.mca equ 1 << 14
.cmov equ 1 << 15
.pat equ 1 << 16
.pse_36 equ 1 << 17
.psn equ 1 << 18
.clfsh equ 1 << 19
.ds equ 1 << 21
.acpi equ 1 << 22
.mmx equ 1 << 23
.fxsr equ 1 << 24
.sse equ 1 << 25
.sse2 equ 1 << 26
.ss equ 1 << 27
.htt equ 1 << 28
.tm equ 1 << 29
.ia64 equ 1 << 30
.pbe equ 1 << 31
features_ecx:
.sse3 equ 1 << 0
.pclmulqdq equ 1 << 1
.dtes64 equ 1 << 2
.monitor equ 1 << 3
.ds_cpl equ 1 << 4
.vmx equ 1 << 5
.smx equ 1 << 6
.est equ 1 << 7
.tm2 equ 1 << 8
.ssse3 equ 1 << 9
.cnxt_id equ 1 << 10
.sdbg equ 1 << 11
.fma equ 1 << 12
.cmpxchg16b equ 1 << 13
.xtpr equ 1 << 14
.pdcm equ 1 << 15
.pcid equ 1 << 17
.dca equ 1 << 18
.sse4_1 equ 1 << 19
.sse4_2 equ 1 << 20
.x2apic equ 1 << 21
.movbe equ 1 << 22
.popcnt equ 1 << 23
.tsc_deadline equ 1 << 24
.aes equ 1 << 25
.xsave equ 1 << 26
.osxsave equ 1 << 27
.avx equ 1 << 28
.f16c equ 1 << 29
.rdrand equ 1 << 30
.hypervisor equ 1 << 31
......@@ -42,6 +42,8 @@ startup:
jmp .loaded_kernel
.loaded_kernel:
call check_cpuid
call memory_map
call vesa
......@@ -139,6 +141,7 @@ load_extent:
%include "memory_map.asm"
%include "vesa.asm"
%include "initialize.asm"
%include "cpuid.asm"
%ifndef KERNEL
%include "redoxfs.asm"
%ifndef FILESYSTEM
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment