MCPcopy Create free account
hub / github.com/JHRobotics/softgpu / readCPUInfo

Function readCPUInfo

softgpu.c:192–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void readCPUInfo()
193{
194 /* AVX avaibility by intel atricle:
195 http://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled/ */
196 __asm(
197 "pusha\n"
198 "pushf\n" // push eflags on the stack
199 "pop %%eax\n" // pop them into eax
200 "movl %%eax, %%ebx\n" // save to ebx for restoring afterwards
201 "xorl $0x200000, %%eax\n" // toggle bit 21
202 "push %%eax\n" // push the toggled eflags
203 "popf\n" // pop them back into eflags
204 "pushf\n" // push eflags
205 "pop %%eax\n" // pop them back into eax
206 "cmpl %%ebx, %%eax\n" // see if bit 21 was reset
207 "jz not_supported\n"
208 "movl $1, %1\n"
209 "xorl %%eax, %%eax\n"
210 "cpuid\n"
211 "cmpl $1, %%eax\n" // does CPUID support eax = 1?
212 "jb not_supported\n"
213 "movl $1, %%eax\n"
214 "cpuid\n"
215 "andl $0x18000000, %%ecx\n" // check 27 bit (OS uses XSAVE/XRSTOR)
216 "cmpl $0x18000000, %%ecx\n" // and 28 (AVX supported by CPU)
217 "jne not_supported\n"
218 "xorl %%ecx, %%ecx\n" // XFEATURE_ENABLED_MASK/XCR0 register number = 0
219 "xgetbv\n" // XFEATURE_ENABLED_MASK register is in edx:eax
220 "andl $6, %%eax\n"
221 "cmpl $6, %%eax\n" // check the AVX registers restore at context switch
222 "jne not_supported\n"
223 "movl $1, %0\n"
224 "jmp end\n"
225 "not_supported:\n"
226 "movl $0, %0\n"
227 "end:\n"
228 "popa" : "=m" (hasAVX), "=m" (hasCPUID));
229
230 if(hasCPUID)
231 {
232 __asm(
233 "pusha\n"
234 "xorl %%eax, %%eax\n"
235 "cpuid\n"
236 "cmpl $1, %%eax\n" // does CPUID support eax = 1?
237 "jb end_p2\n"
238 "movl $1, %%eax\n"
239 "cpuid\n"
240 "andl $0x01800000, %%edx\n" // check MMX and FXSR
241 "cmpl $0x01800000, %%edx\n"
242 "jne end_p2\n"
243 "mov $1, %0\n"
244 "end_p2:\n"
245 "popa" : "=m" (hasP2));
246
247 if(version_compare(&sysver, &WINVER98) >= 0) /* in 98 SSE supported if they are present */
248 {
249 __asm(

Callers 1

softgpu_sysinfoFunction · 0.85

Calls 1

version_compareFunction · 0.85

Tested by

no test coverage detected