summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/sse.s
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2025-08-10 15:40:19 -0400
committerJon Santmyer <jon@jonsantmyer.com>2025-08-10 15:40:19 -0400
commitc4f8ef91f18d854a4ede7a94e95b2eab898d6963 (patch)
treec2772c4f380a684b6fa347f03b13f9476bf9500c /arch/x86_64/sse.s
parentb905869a35f062a4e5072f10bec3a2ba3db0e365 (diff)
downloadjove-kernel-c4f8ef91f18d854a4ede7a94e95b2eab898d6963.tar.gz
jove-kernel-c4f8ef91f18d854a4ede7a94e95b2eab898d6963.tar.bz2
jove-kernel-c4f8ef91f18d854a4ede7a94e95b2eab898d6963.zip
working usermode objdir iteration
Diffstat (limited to 'arch/x86_64/sse.s')
-rw-r--r--arch/x86_64/sse.s46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/x86_64/sse.s b/arch/x86_64/sse.s
new file mode 100644
index 0000000..8065188
--- /dev/null
+++ b/arch/x86_64/sse.s
@@ -0,0 +1,46 @@
+.global enable_fpu
+.type enable_fpu @function
+enable_fpu:
+ fninit
+ fldcw [fcw_init]
+ ret
+.size enable_fpu, . - enable_fpu
+
+.global enable_sse
+.type enable_sse @function
+enable_sse:
+ movq %cr0, %rax
+ //Disable coprocessor emulation
+ and $0xFFFB, %ax
+ //Set coprocessor monitoring
+ or $0x22, %ax
+ //Save cr0
+ movq %rax, %cr0
+ movq %cr4, %rax
+ //Set CR4.OSFXR and CR4.OSXMMEXCEPT
+ or $3 << 9, %ax
+ movq %rax, %cr4
+ ret
+.size enable_sse, . - enable_sse
+
+.global enable_avx
+.type enable_avx, @function
+enable_avx:
+ pushq %rax
+ pushq %rcx
+ pushq %rdx
+
+ xorq %rcx, %rcx
+ xgetbv
+ or $7, %eax
+ xsetbv
+
+ popq %rdx
+ popq %rcx
+ popq %rax
+ ret
+.size enable_avx, . - enable_avx
+
+.data
+fcw_init:
+ .word 0x037F