mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-17 06:47:49 +00:00
Setup SSE because rust needs it
This commit is contained in:
@@ -18,6 +18,7 @@ extern main
|
|||||||
section .text
|
section .text
|
||||||
bits 64
|
bits 64
|
||||||
long_mode_start:
|
long_mode_start:
|
||||||
|
call setup_SSE
|
||||||
|
|
||||||
; call rust main
|
; call rust main
|
||||||
call main
|
call main
|
||||||
@@ -26,6 +27,28 @@ long_mode_start:
|
|||||||
mov qword [0xb8000], rax
|
mov qword [0xb8000], rax
|
||||||
hlt
|
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.
|
; Prints `ERROR: ` and the given error code to screen and hangs.
|
||||||
; parameter: error code (in ascii) in al
|
; parameter: error code (in ascii) in al
|
||||||
error:
|
error:
|
||||||
@@ -35,3 +58,4 @@ error:
|
|||||||
mov [0xb8008], rbx
|
mov [0xb8008], rbx
|
||||||
mov byte [0xb800e], al
|
mov byte [0xb800e], al
|
||||||
hlt
|
hlt
|
||||||
|
jmp error
|
||||||
|
|||||||
Reference in New Issue
Block a user