| 109 | } |
| 110 | |
| 111 | void Processor::init() |
| 112 | { |
| 113 | // Reference: |
| 114 | // www.cyrix.com |
| 115 | // www.amd.com |
| 116 | // www.intel.com |
| 117 | // http://developer.intel.com/design/PentiumII/manuals/24512701.pdf |
| 118 | |
| 119 | Platform::SystemInfo.processor.type = CPU_X86Compatible; |
| 120 | Platform::SystemInfo.processor.name = StringTable->insert("Unknown x86 Compatible"); |
| 121 | Platform::SystemInfo.processor.mhz = 0; |
| 122 | Platform::SystemInfo.processor.properties = CPU_PROP_C | CPU_PROP_FPU | CPU_PROP_LE; |
| 123 | |
| 124 | char vendor[0x20]; |
| 125 | dMemset(vendor, 0, sizeof(vendor)); |
| 126 | |
| 127 | S32 vendorInfo[4]; |
| 128 | __cpuid(vendorInfo, 0); |
| 129 | *reinterpret_cast<int*>(vendor) = vendorInfo[1]; // ebx |
| 130 | *reinterpret_cast<int*>(vendor + 4) = vendorInfo[3]; // edx |
| 131 | *reinterpret_cast<int*>(vendor + 8) = vendorInfo[2]; // ecx |
| 132 | |
| 133 | char brand[0x40]; |
| 134 | dMemset(brand, 0, sizeof(brand)); |
| 135 | getBrand(brand); |
| 136 | |
| 137 | SetProcessorInfo(Platform::SystemInfo.processor, vendor, brand); |
| 138 | detectCpuFeatures(Platform::SystemInfo.processor); |
| 139 | |
| 140 | U32 mhz = 1000; // default if it can't be found |
| 141 | |
| 142 | LONG result; |
| 143 | DWORD data = 0; |
| 144 | DWORD dataSize = 4; |
| 145 | HKEY hKey; |
| 146 | |
| 147 | result = ::RegOpenKeyExA (HKEY_LOCAL_MACHINE,"Hardware\\Description\\System\\CentralProcessor\\0", 0, KEY_QUERY_VALUE, &hKey); |
| 148 | |
| 149 | if (result == ERROR_SUCCESS) |
| 150 | { |
| 151 | result = ::RegQueryValueExA (hKey, "~MHz",NULL, NULL,(LPBYTE)&data, &dataSize); |
| 152 | |
| 153 | if (result == ERROR_SUCCESS) |
| 154 | mhz = data; |
| 155 | |
| 156 | ::RegCloseKey(hKey); |
| 157 | } |
| 158 | |
| 159 | Platform::SystemInfo.processor.mhz = mhz; |
| 160 | |
| 161 | Con::printf("Processor Init:"); |
| 162 | Con::printf(" Processor: %s", Platform::SystemInfo.processor.name); |
| 163 | if (Platform::SystemInfo.processor.properties & CPU_PROP_MMX) |
| 164 | Con::printf(" MMX detected" ); |
| 165 | if (Platform::SystemInfo.processor.properties & CPU_PROP_SSE) |
| 166 | Con::printf(" SSE detected" ); |
| 167 | if (Platform::SystemInfo.processor.properties & CPU_PROP_SSE2) |
| 168 | Con::printf(" SSE2 detected" ); |
nothing calls this directly
no test coverage detected