From c4f8ef91f18d854a4ede7a94e95b2eab898d6963 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Sun, 10 Aug 2025 15:40:19 -0400 Subject: working usermode objdir iteration --- arch/x86_64/sse.s | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 arch/x86_64/sse.s (limited to 'arch/x86_64/sse.s') 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 -- cgit v1.2.1