diff options
Diffstat (limited to 'arch/x86_64/sse.s')
-rw-r--r-- | arch/x86_64/sse.s | 46 |
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 |