mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Move setup_SSE to boot.asm
This commit is contained in:
@@ -18,8 +18,6 @@ extern rust_main
|
||||
section .text
|
||||
bits 64
|
||||
long_mode_start:
|
||||
call setup_SSE
|
||||
|
||||
; call rust main (with multiboot pointer in rdi)
|
||||
call rust_main
|
||||
.os_returned:
|
||||
@@ -31,36 +29,3 @@ long_mode_start:
|
||||
mov rax, 0x4f214f644f654f6e
|
||||
mov [0xb8010], rax
|
||||
hlt
|
||||
|
||||
; Check for SSE and enable it. If it's not supported throw error "a".
|
||||
setup_SSE:
|
||||
; check for SSE
|
||||
mov rax, 0x1
|
||||
cpuid
|
||||
test edx, 1<<25
|
||||
jz .no_SSE
|
||||
|
||||
; enable SSE
|
||||
mov rax, cr0
|
||||
and ax, 0xFFFB ; clear coprocessor emulation CR0.EM
|
||||
or ax, 0x2 ; set coprocessor monitoring CR0.MP
|
||||
mov cr0, rax
|
||||
mov rax, cr4
|
||||
or ax, 3 << 9 ; set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
|
||||
mov cr4, rax
|
||||
|
||||
ret
|
||||
.no_SSE:
|
||||
mov al, "a"
|
||||
jmp error
|
||||
|
||||
; Prints `ERROR: ` and the given error code to screen and hangs.
|
||||
; parameter: error code (in ascii) in al
|
||||
error:
|
||||
mov rbx, 0x4f4f4f524f524f45
|
||||
mov [0xb8000], rbx
|
||||
mov rbx, 0x4f204f204f3a4f52
|
||||
mov [0xb8008], rbx
|
||||
mov byte [0xb800e], al
|
||||
hlt
|
||||
jmp error
|
||||
|
||||
Reference in New Issue
Block a user