Setup SSE because rust needs it

This commit is contained in:
Philipp Oppermann
2015-08-17 15:09:22 +02:00
parent c65797d89f
commit e09ae042a3

View File

@@ -18,6 +18,7 @@ extern main
section .text
bits 64
long_mode_start:
call setup_SSE
; call rust main
call main
@@ -26,6 +27,28 @@ long_mode_start:
mov qword [0xb8000], 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:
@@ -35,3 +58,4 @@ error:
mov [0xb8008], rbx
mov byte [0xb800e], al
hlt
jmp error