Browse Source

Kill the CpuGetInfo function.

We're probably going to kill pnNetDiag at some point anyways.
Darryl Pogue 13 years ago
parent
commit
3b39393077
  1. 11
      Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp
  2. 101
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Misc.cpp
  3. 29
      Sources/Plasma/NucleusLib/pnUtils/pnUtMisc.h

11
Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp

@ -138,17 +138,6 @@ void NetDiagSys (
dump(L"[SYS] OS Patch: %u.%u (%S)", info.wServicePackMajor, info.wServicePackMinor, info.szCSDVersion); dump(L"[SYS] OS Patch: %u.%u (%S)", info.wServicePackMajor, info.wServicePackMinor, info.szCSDVersion);
} }
{ // System
uint16_t cpuCaps;
uint32_t cpuVendor[3];
uint16_t cpuSignature;
CpuGetInfo(&cpuCaps, cpuVendor, &cpuSignature);
SYSTEM_INFO info;
GetSystemInfo(&info);
dump(L"[SYS] CPU Count: %u", info.dwNumberOfProcessors);
dump(L"[SYS] CPU Vendor: %.*S", sizeof(cpuVendor), cpuVendor);
}
{ // Adapters { // Adapters
if (!getAdaptersInfo) { if (!getAdaptersInfo) {
dump(L"[SYS] Failed to load IP helper API"); dump(L"[SYS] Failed to load IP helper API");

101
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Misc.cpp

@ -58,104 +58,3 @@ const wchar_t * AppGetCommandLine () {
return GetCommandLineW(); 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;
}
}

29
Sources/Plasma/NucleusLib/pnUtils/pnUtMisc.h

@ -83,33 +83,4 @@ typedef void (CDECL * FStateDump)(
... ...
); );
/*****************************************************************************
*
* System status
*
***/
void CpuGetInfo (
uint16_t * cpuCaps,
uint32_t * cpuVendor,
uint16_t * cpuSignature
);
// CPU capability flags
const unsigned kCpuCap3dNow = 1<<0;
const unsigned kCpuCapCmov = 1<<1; // conditional move
const unsigned kCpuCapEst = 1<<2; // enhanced speed step
const unsigned kCpuCapHtt = 1<<3; // hyperthreading
const unsigned kCpuCapMmx = 1<<4; // multimedia extensions
const unsigned kCpuCapPsn = 1<<5; // processor serial number
const unsigned kCpuCapSse = 1<<6; // streaming SIMD extensions
const unsigned kCpuCapSse2 = 1<<7;
const unsigned kCpuCapSse3 = 1<<8;
const unsigned kCpuCapTsc = 1<<9; // time stamp counter
// Macros for packing and unpacking CPU signature
#define CPU_SIGNATURE(family, model, stepping) ((stepping) | (model << 4) | (family << 8))
#define CPU_SIGNATURE_FAMILY(sig) ((sig >> 8) & 0xf)
#define CPU_SIGNATURE_MODEL(sig) ((sig >> 4) & 0xf)
#define CPU_SIGNATURE_STEPPING(sig) (sig & 0xf)
#endif #endif

Loading…
Cancel
Save