We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 29c249e + 154e825 commit c9e238fCopy full SHA for c9e238f
src/init/cpu.asm
@@ -87,6 +87,26 @@ init_cpu:
87
; Enable Math Co-processor
88
finit
89
90
+; Enable AVX
91
+ mov eax, 1 ; CPUID Feature information 1
92
+ cpuid ; Sets info in eax and ecx
93
+ bt ecx, 28 ; AVX is supported if bit 28 is set in ecx
94
+ jnc avx_not_supported ; Skip activating AVX if not supported
95
+
96
+avx_supported:
97
98
+ mov rax, cr4
99
+ bts rax, 18 ; Enable OSXSAVE (Bit 18)
100
+ mov cr4, rax
101
102
+ mov rcx, 0 ; Set load XCR Nr. 0
103
+ xgetbv ; Load XCR0 register
104
+ bts rax, 0 ; Set X87 enable (Bit 0)
105
+ bts rax, 1 ; Set SSE enable (Bit 1)
106
+ bts rax, 2 ; Set AVX enable (Bit 2)
107
+ xsetbv ; Save XCR0 register
108
+avx_not_supported:
109
110
; Enable and Configure Local APIC
111
mov rsi, [os_LocalAPICAddress]
112
test rsi, rsi
0 commit comments