diff options
author | Brett Weiland <brett_weiland@bpcspace.com> | 2021-03-24 15:36:54 -0500 |
---|---|---|
committer | Brett Weiland <brett_weiland@bpcspace.com> | 2021-03-24 15:38:09 -0500 |
commit | 14b109ea24dc5cb1db948de57a2a44c80ef4622e (patch) | |
tree | e397997d9c8d9c1b50a5a5235d38c6b0e8f24b5b /src/bootloader/cpu_check.asm | |
parent | 13000d6f44d66da795e92e4b2ddc37ce879bf275 (diff) |
modified: README.md
modified: compiler/create_crosscompiler.sh
deleted: notes
modified: src/.gdb_history
deleted: src/amd64_vol2.pdf
modified: src/bootloader/bios_functions/bios_disk.asm
modified: src/bootloader/bios_functions/print.asm
modified: src/bootloader/bootloader.asm
modified: src/bootloader/cpu_check.asm
modified: src/bootloader/enter_kernel.asm
deleted: src/bootloader/enter_kernel_backup
modified: src/bootloader/gdt.asm
deleted: src/bootloader/multicore.asm
deleted: src/bootloader/notes
new file: src/debug/gdbinit.gdb
deleted: src/indigo_os
modified: src/kernel/include/libc.h
modified: src/kernel/include/paging.h
modified: src/kernel/include/video.h
modified: src/kernel/kernel.c
modified: src/kernel/libs/acpi.c
modified: src/kernel/libs/drivers/serial.c
modified: src/kernel/libs/drivers/video.c
modified: src/kernel/libs/libc.c
modified: src/kernel/libs/page.c
modified: src/link.ld
modified: src/makefile
new file: tools/README.md
modified: tools/page/page.py
Diffstat (limited to 'src/bootloader/cpu_check.asm')
-rw-r--r-- | src/bootloader/cpu_check.asm | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/bootloader/cpu_check.asm b/src/bootloader/cpu_check.asm index ffdd908..0fa6ddf 100644 --- a/src/bootloader/cpu_check.asm +++ b/src/bootloader/cpu_check.asm @@ -1,38 +1,41 @@ -; TODO move this file to something like "system_check", now that we do ram checks here [extern _meminfo_loc] detect_arch: -; todo: figure out how to just handle invalid opcode exceptions, it would be faster and (maybe?) easier -; todo: digest this part a little better when it's _not_ 1am. -pushfd ; pushes eflags to stack -pushfd ; pushes eflags to stack a second time -xor dword [esp], 0x00200000 ; inverses the ID bit to see if cpuid is a thing -pop eax ;gets our modified cpuid back -xor eax, [esp] ; checks with the first time we pushed it; the OG eflag -popfd ; pops the flags back I guess? -and eax, 0x00200000 ; checks to see if the bit was inverted + +; detect CPUID + +pushfd +pushfd +xor dword [esp], 0x00200000 +pop eax +xor eax, [esp] +popfd +and eax, 0x00200000 jz .print_cpuid_error -;now we detect if we support long slong (aka 64 bit) -;https://www.amd.com/system/files/TechDocs/25481.pdf page 21 -;So apperently some dumbass engineers thought it would be funny to sell CPUs that have the long mode bit set without it being supported, dispite including it in their own documentation. -;there's a work around by checking other bits, and it's a low priority TODO. However, I really think us coming accross this will be extremely rare. +; detect long mode + mov eax, 0x80000001 -cpuid ;cpuid returns into edx -and edx, 0x0020000000 ; the 21st bit is cpuid. +cpuid +and edx, 0x0020000000 jz .print_long_error +; APIC mov eax, 0x00000001 cpuid -and edx, 0x00000200 +test edx, 0x00000200 jz .print_apic_error +; SSE (you might be able to remove this, I think it's a standard requirement) +test edx, 0x2000000 +jz .print_sse_error + mov bx, .no_error mov cx, 0 call bios_print -;mapping memory +; get memory mappings mov ax, 0 mov es, ax mov ax, _meminfo_loc @@ -71,7 +74,7 @@ call bios_print jmp $ .print_long_error: -mov bx, .arch_error ; lets just test for now +mov bx, .arch_error mov cx, 0 call bios_print jmp $ @@ -80,11 +83,19 @@ jmp $ mov bx, .apic_error mov cx, 0 call bios_print +jmp $ .print_mem_error: mov bx, .mem_error mov cx, 0 call bios_print +jmp $ + +.print_sse_error: +mov bx, .sse_error +mov cx, 0 +call bios_print +jmp $ .cpuid_error: @@ -95,6 +106,8 @@ call bios_print db "No apic support", 0x0 .mem_error: db "Could not get information on memory!", 0x0 +.sse_error: + db "This OS requires SSE", 0x0 .no_error: db "CPU info gathered!", 0x0 |