mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
Kill the CpuGetInfo function.
We're probably going to kill pnNetDiag at some point anyways.
This commit is contained in:
@ -58,104 +58,3 @@ const wchar_t * AppGetCommandLine () {
|
||||
return GetCommandLineW();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* System status
|
||||
*
|
||||
***/
|
||||
|
||||
//============================================================================
|
||||
// Loosely taken from MS's cpuid code sample
|
||||
void CpuGetInfo (
|
||||
uint16_t * cpuCaps,
|
||||
uint32_t * cpuVendor,
|
||||
uint16_t * cpuSignature
|
||||
) {
|
||||
uint32_t signature = 0;
|
||||
uint32_t extended = 0;
|
||||
uint32_t flags[2] = { 0, 0 };
|
||||
cpuVendor[0] = 0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
_asm {
|
||||
// Detect if cpuid instruction is supported by attempting
|
||||
// to change the ID bit of EFLAGS
|
||||
pushfd
|
||||
pop eax // get EFLAGS
|
||||
mov ecx, eax // store copy of original EFLAGS
|
||||
xor eax, 0x200000 // flip ID bit
|
||||
push eax
|
||||
popfd // replace EFLAGS
|
||||
pushfd // get EFLAGS
|
||||
pop eax
|
||||
xor eax, ecx
|
||||
je DONE
|
||||
|
||||
// Get processor id (GenuineIntel, AuthenticAMD, etc)
|
||||
xor eax, eax
|
||||
cpuid
|
||||
mov edi, cpuVendor
|
||||
mov [edi + 0], ebx
|
||||
mov [edi + 4], edx
|
||||
mov [edi + 8], ecx
|
||||
|
||||
// Check if capability flags are supported
|
||||
cmp eax, 1
|
||||
jl DONE
|
||||
|
||||
// Get processor capability flags and signature
|
||||
mov eax, 1
|
||||
cpuid
|
||||
mov signature, eax
|
||||
mov [flags + 0], edx
|
||||
mov [flags + 4], ecx
|
||||
|
||||
// Check for extended capabilities
|
||||
mov eax, 0x80000000
|
||||
cpuid
|
||||
cmp eax, 0x80000001
|
||||
jl DONE
|
||||
|
||||
// Get extended capabilities
|
||||
mov eax, 0x80000001
|
||||
cpuid
|
||||
mov extended, edx
|
||||
|
||||
DONE:
|
||||
}
|
||||
#endif
|
||||
|
||||
// Decode capability flags
|
||||
const static struct CpuCap {
|
||||
uint16_t cpuFlag;
|
||||
uint8_t field;
|
||||
uint8_t bit;
|
||||
} s_caps[] = {
|
||||
// feature field bit
|
||||
// ------- ----- ---
|
||||
{ kCpuCapCmov, 0, 15 },
|
||||
{ kCpuCapEst, 1, 7 },
|
||||
{ kCpuCapHtt, 0, 28 },
|
||||
{ kCpuCapMmx, 0, 23 },
|
||||
{ kCpuCapPsn, 0, 18 },
|
||||
{ kCpuCapSse, 0, 25 },
|
||||
{ kCpuCapSse2, 0, 26 },
|
||||
{ kCpuCapSse3, 1, 0 },
|
||||
{ kCpuCapTsc, 0, 4 },
|
||||
};
|
||||
for (unsigned i = 0; i < arrsize(s_caps); ++i) {
|
||||
const CpuCap & cap = s_caps[i];
|
||||
if (flags[cap.field] & (1 << cap.bit))
|
||||
*cpuCaps |= cap.cpuFlag;
|
||||
}
|
||||
|
||||
// Copy signature
|
||||
*cpuSignature = uint16_t(signature & 0xfff);
|
||||
|
||||
// If this is an AMD CPU, check for 3DNow support
|
||||
const char * vendorAmd = "AuthenticAMD";
|
||||
if (!memcmp(vendorAmd, cpuVendor, 12)) {
|
||||
if (extended & (1 << 31))
|
||||
*cpuCaps |= kCpuCap3dNow;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user