1 | /*␊ |
2 | * Add (c) here␊ |
3 | *␊ |
4 | * Copyright .... All rights reserved.␊ |
5 | *␊ |
6 | */␊ |
7 | ␊ |
8 | #include "smbios_getters.h"␊ |
9 | #include "modules.h"␊ |
10 | ␊ |
11 | #ifndef DEBUG_SMBIOS␊ |
12 | #define DEBUG_SMBIOS 0␊ |
13 | #endif␊ |
14 | ␊ |
15 | #if DEBUG_SMBIOS␊ |
16 | #define DBG(x...)␉printf(x)␊ |
17 | #else␊ |
18 | #define DBG(x...)␊ |
19 | #endif␊ |
20 | static uint16_t simpleGetSMBOemProcessorType(void);␊ |
21 | ␊ |
22 | ␊ |
23 | bool getProcessorInformationExternalClock(returnType *value)␊ |
24 | {␊ |
25 | ␉value->word = Platform->CPU.FSBFrequency/1000000;␊ |
26 | ␉return true;␊ |
27 | }␊ |
28 | ␊ |
29 | bool getProcessorInformationMaximumClock(returnType *value)␊ |
30 | {␊ |
31 | ␉// Note: it seems that AppleSMBIOS use the maximum clock to set the cpu clock␊ |
32 | ␉// that is showed in "About this mac" or in the System Information. ␊ |
33 | ␉// in my opinion the current clock should be used for this.␊ |
34 | ␉// value->word = Platform->CPU.TSCFrequency/1000000;␊ |
35 | ␉␊ |
36 | ␉value->word = Platform->CPU.CPUFrequency/1000000;␊ |
37 | ␉return true;␊ |
38 | }␊ |
39 | ␊ |
40 | bool getProcessorInformationCurrentClock(returnType *value)␊ |
41 | {␊ |
42 | ␉value->word = Platform->CPU.CPUFrequency/1000000;␊ |
43 | ␉return true;␊ |
44 | }␊ |
45 | ␊ |
46 | bool getSMBOemProcessorBusSpeed(returnType *value)␊ |
47 | {␊ |
48 | ␉if (Platform->CPU.Vendor == 0x756E6547) // Intel␊ |
49 | ␉{␉␉␊ |
50 | ␉␉switch (Platform->CPU.Family) ␊ |
51 | ␉␉{␊ |
52 | ␉␉␉case 0x06:␊ |
53 | ␉␉␉{␊ |
54 | ␉␉␉␉switch (Platform->CPU.Model)␊ |
55 | ␉␉␉␉{␊ |
56 | case CPUID_MODEL_BANIAS:␉// Banias␉␉0x09␊ |
57 | case CPUID_MODEL_DOTHAN:␉// Dothan␉␉0x0D␊ |
58 | ␉␉␉␉␉case CPUID_MODEL_YONAH:␉␉// Yonah␉␉0x0E␊ |
59 | ␉␉␉␉␉case CPUID_MODEL_MEROM:␉␉// Merom␉␉0x0F␊ |
60 | ␉␉␉␉␉case CPUID_MODEL_PENRYN:␉␉// Penryn␉␉0x17␊ |
61 | ␉␉␉␉␉case CPUID_MODEL_ATOM:␉␉// Atom 45nm␉0x1C␊ |
62 | ␉␉␉␉␉␉return false;␊ |
63 | ␊ |
64 | ␉␉␉␉␉case 0x19:␉␉␉␉␉// Intel Core i5 650 @3.20 Ghz␊ |
65 | ␉␉␉␉␉case CPUID_MODEL_NEHALEM:␉␉// Intel Core i7 LGA1366 (45nm)␊ |
66 | ␉␉␉␉␉case CPUID_MODEL_FIELDS:␉␉// Intel Core i5, i7 LGA1156 (45nm)␊ |
67 | ␉␉␉␉␉case CPUID_MODEL_DALES:␉␉// Intel Core i5, i7 LGA1156 (45nm) ???␊ |
68 | ␉␉␉␉␉case CPUID_MODEL_DALES_32NM:␉// Intel Core i3, i5, i7 LGA1156 (32nm)␊ |
69 | ␉␉␉␉␉case CPUID_MODEL_WESTMERE:␉// Intel Core i7 LGA1366 (32nm) 6 Core␊ |
70 | ␉␉␉␉␉case CPUID_MODEL_NEHALEM_EX:␉// Intel Core i7 LGA1366 (45nm) 6 Core ???␊ |
71 | ␉␉␉␉␉case CPUID_MODEL_WESTMERE_EX:␉// Intel Core i7 LGA1366 (45nm) 6 Core ???␊ |
72 | ␉␉␉␉␉case CPUID_MODEL_SANDYBRIDGE:␊ |
73 | ␉␉␉␉␉case CPUID_MODEL_JAKETOWN:␊ |
74 | ␉␉␉␉␉{␊ |
75 | ␉␉␉␉␉␉// thanks to dgobe for i3/i5/i7 bus speed detection␊ |
76 | ␉␉␉␉␉␉int nhm_bus = 0x3F;␊ |
77 | ␉␉␉␉␉␉static long possible_nhm_bus[] = {0xFF, 0x7F, 0x3F};␊ |
78 | ␉␉␉␉␉␉unsigned long did, vid;␊ |
79 | ␉␉␉␉␉␉unsigned int i;␊ |
80 | ␉␉␉␉␉␉␊ |
81 | ␉␉␉␉␉␉// Nehalem supports Scrubbing␊ |
82 | ␉␉␉␉␉␉// First, locate the PCI bus where the MCH is located␊ |
83 | ␉␉␉␉␉␉for(i = 0; i < sizeof(possible_nhm_bus); i++)␊ |
84 | ␉␉␉␉␉␉{␊ |
85 | ␉␉␉␉␉␉␉vid = pci_config_read16(PCIADDR(possible_nhm_bus[i], 3, 4), 0x00);␊ |
86 | ␉␉␉␉␉␉␉did = pci_config_read16(PCIADDR(possible_nhm_bus[i], 3, 4), 0x02);␊ |
87 | ␉␉␉␉␉␉␉vid &= 0xFFFF;␊ |
88 | ␉␉␉␉␉␉␉did &= 0xFF00;␊ |
89 | ␉␉␉␉␉␉␉␊ |
90 | ␉␉␉␉␉␉␉if(vid == 0x8086 && did >= 0x2C00)␊ |
91 | ␉␉␉␉␉␉␉␉nhm_bus = possible_nhm_bus[i]; ␊ |
92 | ␉␉␉␉␉␉}␊ |
93 | ␉␉␉␉␉␉␊ |
94 | ␉␉␉␉␉␉unsigned long qpimult, qpibusspeed;␊ |
95 | ␉␉␉␉␉␉qpimult = pci_config_read32(PCIADDR(nhm_bus, 2, 1), 0x50);␊ |
96 | ␉␉␉␉␉␉qpimult &= 0x7F;␊ |
97 | ␉␉␉␉␉␉DBG("qpimult %d\n", qpimult);␊ |
98 | ␉␉␉␉␉␉qpibusspeed = (qpimult * 2 * (Platform->CPU.FSBFrequency/1000000));␊ |
99 | ␉␉␉␉␉␉// Rek: rounding decimals to match original mac profile info␊ |
100 | ␉␉␉␉␉␉if (qpibusspeed%100 != 0)qpibusspeed = ((qpibusspeed+50)/100)*100;␊ |
101 | ␉␉␉␉␉␉DBG("qpibusspeed %d\n", qpibusspeed);␊ |
102 | ␉␉␉␉␉␉value->word = qpibusspeed;␊ |
103 | ␉␉␉␉␉␉return true;␊ |
104 | ␉␉␉␉␉}␊ |
105 | ␉␉␉␉␉default:␊ |
106 | ␉␉␉␉␉␉break; //Unsupported CPU type␊ |
107 | ␉␉␉␉}␊ |
108 | ␉␉␉}␊ |
109 | ␉␉␉default:␊ |
110 | ␉␉␉␉break; ␊ |
111 | ␉␉}␊ |
112 | ␉}␊ |
113 | ␉return false;␊ |
114 | }␊ |
115 | ␊ |
116 | static uint16_t simpleGetSMBOemProcessorType(void)␊ |
117 | {␊ |
118 | ␉if (Platform->CPU.NoCores >= 4) ␊ |
119 | ␉{␊ |
120 | ␉␉return 0x0501;␉// Quad-Core Xeon␊ |
121 | ␉}␊ |
122 | ␉if (((Platform->CPU.NoCores == 1) || (Platform->CPU.NoCores == 2)) && !(platformCPUExtFeature(CPUID_EXTFEATURE_EM64T))) ␊ |
123 | ␉{␊ |
124 | ␉␉return 0x0201;␉// Core Solo / Duo␊ |
125 | ␉};␊ |
126 | ␉␊ |
127 | ␉return 0x0301;␉␉// Core 2 Solo / Duo␊ |
128 | }␊ |
129 | ␊ |
130 | bool getSMBOemProcessorType(returnType *value)␊ |
131 | {␊ |
132 | ␉static bool done = false;␉␉␊ |
133 | ␉␉␊ |
134 | ␉value->word = simpleGetSMBOemProcessorType();␊ |
135 | ␊ |
136 | ␉if (Platform->CPU.Vendor == 0x756E6547) // Intel␊ |
137 | ␉{␊ |
138 | ␉␉if (!done)␊ |
139 | ␉␉{␊ |
140 | ␉␉␉verbose("CPU is %s, family 0x%x, model 0x%x\n", Platform->CPU.BrandString, Platform->CPU.Family, Platform->CPU.Model);␊ |
141 | ␉␉␉done = true;␊ |
142 | ␉␉}␊ |
143 | ␉␉␊ |
144 | ␉␉switch (Platform->CPU.Family) ␊ |
145 | ␉␉{␊ |
146 | ␉␉␉case 0x06:␊ |
147 | ␉␉␉{␊ |
148 | ␉␉␉␉switch (Platform->CPU.Model)␊ |
149 | ␉␉␉␉{␊ |
150 | case CPUID_MODEL_BANIAS:␉// Banias␉␉␊ |
151 | case CPUID_MODEL_DOTHAN:␉// Dothan␉␉␊ |
152 | ␉␉␉␉␉case CPUID_MODEL_YONAH:␉␉␉␉// Yonah␊ |
153 | ␉␉␉␉␉case CPUID_MODEL_MEROM:␉␉␉␉// Merom␊ |
154 | ␉␉␉␉␉case CPUID_MODEL_PENRYN:␉␉␉␉// Penryn␊ |
155 | ␉␉␉␉␉case CPUID_MODEL_ATOM:␉␉␉␉// Intel Atom (45nm)␊ |
156 | ␉␉␉␉␉␉return true;␊ |
157 | ␊ |
158 | ␉␉␉␉␉case CPUID_MODEL_NEHALEM:␉␉␉␉// Intel Core i7 LGA1366 (45nm)␊ |
159 | ␉␉␉␉␉␉value->word = 0x0701;␉␉␉// Core i7␊ |
160 | ␉␉␉␉␉␉return true;␊ |
161 | ␊ |
162 | ␉␉␉␉␉case CPUID_MODEL_FIELDS:␉␉␉␉// Lynnfield, Clarksfield, Jasper␊ |
163 | ␉␉␉␉␉␉if (strstr(Platform->CPU.BrandString, "Core(TM) i5"))␊ |
164 | ␉␉␉␉␉␉␉value->word = 0x601;␉␉// Core i5␊ |
165 | ␉␉␉␉␉␉else␊ |
166 | ␉␉␉␉␉␉␉value->word = 0x701;␉␉// Core i7␊ |
167 | ␉␉␉␉␉␉return true;␊ |
168 | ␊ |
169 | ␉␉␉␉␉case CPUID_MODEL_DALES:␉␉␉␉// Intel Core i5, i7 LGA1156 (45nm) (Havendale, Auburndale)␊ |
170 | ␉␉␉␉␉␉if (strstr(Platform->CPU.BrandString, "Core(TM) i5"))␊ |
171 | ␉␉␉␉␉␉␉value->word = 0x601;␉␉// Core i5␊ |
172 | ␉␉␉␉␉␉else␊ |
173 | ␉␉␉␉␉␉␉value->word = 0x0701;␉␉// Core i7␊ |
174 | ␉␉␉␉␉␉return true;␊ |
175 | ␊ |
176 | ␉␉␉␉␉case CPUID_MODEL_SANDYBRIDGE:␊ |
177 | ␉␉␉␉␉case CPUID_MODEL_DALES_32NM:␉␉␉// Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)␊ |
178 | ␉␉␉␉␉␉if (strstr(Platform->CPU.BrandString, "Core(TM) i3"))␊ |
179 | ␉␉␉␉␉␉␉␉value->word = 0x901;␉// Core i3␊ |
180 | ␉␉␉␉␉␉else if (strstr(Platform->CPU.BrandString, "Core(TM) i5"))␊ |
181 | ␉␉␉␉␉␉␉␉value->word = 0x601;␉// Core i5␊ |
182 | ␉␉␉␉␉␉else if (strstr(Platform->CPU.BrandString, "Core(TM) i7"))␊ |
183 | ␉␉␉␉␉␉␉␉value->word = 0x0701;␉// Core i7␊ |
184 | ␉␉␉␉␉␉/*else ␊ |
185 | ␉␉␉␉␉␉␉␉value->word = simpleGetSMBOemProcessorType();*/␊ |
186 | ␉␉␉␉␉␉return true;␊ |
187 | ␊ |
188 | case CPUID_MODEL_JAKETOWN:␊ |
189 | ␉␉␉␉␉case CPUID_MODEL_WESTMERE:␉␉␉// Intel Core i7 LGA1366 (32nm) 6 Core (Gulftown, Westmere-EP, Westmere-WS)␊ |
190 | ␉␉␉␉␉case CPUID_MODEL_WESTMERE_EX:␉␉␉// Intel Core i7 LGA1366 (45nm) 6 Core ???␊ |
191 | ␉␉␉␉␉␉value->word = 0x0501;␉␉␉// Core i7␊ |
192 | ␉␉␉␉␉␉return true;␊ |
193 | ␊ |
194 | ␉␉␉␉␉case 0x19:␉␉␉␉␉␉␉// Intel Core i5 650 @3.20 Ghz␊ |
195 | ␉␉␉␉␉␉value->word = 0x601;␉␉␉// Core i5␊ |
196 | ␉␉␉␉␉␉return true;␊ |
197 | ␉␉␉␉␉default:␊ |
198 | ␉␉␉␉␉␉break; //Unsupported CPU type␊ |
199 | ␉␉␉␉}␊ |
200 | ␉␉␉}␊ |
201 | ␉␉␉default:␊ |
202 | ␉␉␉␉break; ␊ |
203 | ␉␉}␊ |
204 | ␉}␊ |
205 | ␉␊ |
206 | ␉return false;␊ |
207 | }␊ |
208 | ␊ |
209 | bool getSMBMemoryDeviceMemoryType(returnType *value)␊ |
210 | {␊ |
211 | ␉static int idx = -1;␊ |
212 | ␉if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {␊ |
213 | ␉␉int␉map;␊ |
214 | ␊ |
215 | ␉␉idx++;␊ |
216 | ␉␉if (idx < MAX_RAM_SLOTS)␊ |
217 | ␉␉{␊ |
218 | ␉␉␉map = Platform->DMI.DIMM[idx];␊ |
219 | ␉␉␉if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Type != 0)␊ |
220 | ␉␉␉{␊ |
221 | ␉␉␉␉DBG("RAM Detected Type = %d\n", Platform->RAM.DIMM[map].Type);␊ |
222 | ␉␉␉␉value->byte = Platform->RAM.DIMM[map].Type;␊ |
223 | ␉␉␉␉return true;␊ |
224 | ␉␉␉}␊ |
225 | ␉␉}␊ |
226 | ␉}␊ |
227 | ␉value->byte = SMB_MEM_TYPE_DDR2;␊ |
228 | ␉return true;␊ |
229 | }␊ |
230 | ␊ |
231 | bool getSMBMemoryDeviceMemorySpeed(returnType *value)␊ |
232 | {␊ |
233 | ␉static int idx = -1;␊ |
234 | ␉if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {␊ |
235 | ␉␉int␉map;␊ |
236 | ␊ |
237 | ␉␉idx++;␊ |
238 | ␉␉if (idx < MAX_RAM_SLOTS)␊ |
239 | ␉␉{␊ |
240 | ␉␉␉map = Platform->DMI.DIMM[idx];␊ |
241 | ␉␉␉if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Frequency != 0)␊ |
242 | ␉␉␉{␊ |
243 | ␉␉␉␉DBG("RAM Detected Freq = %d Mhz\n", Platform->RAM.DIMM[map].Frequency);␊ |
244 | ␉␉␉␉value->dword = Platform->RAM.DIMM[map].Frequency;␊ |
245 | ␉␉␉␉return true;␊ |
246 | ␉␉␉}␊ |
247 | ␉␉}␊ |
248 | ␉}␊ |
249 | ␉value->dword = 800;␊ |
250 | ␉return true;␊ |
251 | }␊ |
252 | ␊ |
253 | bool getSMBMemoryDeviceManufacturer(returnType *value)␊ |
254 | {␊ |
255 | ␉static int idx = -1;␊ |
256 | ␉if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {␊ |
257 | ␉␉int␉map;␊ |
258 | ␊ |
259 | ␉␉idx++;␊ |
260 | ␉␉if (idx < MAX_RAM_SLOTS)␊ |
261 | ␉␉{␊ |
262 | ␉␉␉map = Platform->DMI.DIMM[idx];␊ |
263 | ␉␉␉if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].Vendor) > 0)␊ |
264 | ␉␉␉{␊ |
265 | ␉␉␉␉DBG("RAM Detected Vendor[%d]='%s'\n", idx, Platform->RAM.DIMM[map].Vendor);␊ |
266 | ␉␉␉␉value->string = Platform->RAM.DIMM[map].Vendor;␊ |
267 | ␉␉␉␉return true;␊ |
268 | ␉␉␉}␊ |
269 | ␉␉}␊ |
270 | ␉}␊ |
271 | ␉value->string = "N/A";␊ |
272 | ␉return true;␊ |
273 | }␊ |
274 | ␉␊ |
275 | bool getSMBMemoryDeviceSerialNumber(returnType *value)␊ |
276 | {␊ |
277 | ␉static int idx = -1;␊ |
278 | ␉if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {␊ |
279 | ␉␉int␉map;␊ |
280 | ␊ |
281 | ␉␉idx++;␊ |
282 | ␉␉if (idx < MAX_RAM_SLOTS)␊ |
283 | ␉␉{␊ |
284 | ␉␉␉map = Platform->DMI.DIMM[idx];␊ |
285 | ␉␉␉if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].SerialNo) > 0)␊ |
286 | ␉␉␉{␊ |
287 | ␉␉␉␉DBG("name = %s, map=%d, RAM Detected SerialNo[%d]='%s'\n", name ? name : "", ␊ |
288 | ␉␉␉␉map, idx, Platform->RAM.DIMM[map].SerialNo);␊ |
289 | ␉␉␉␉value->string = Platform->RAM.DIMM[map].SerialNo;␊ |
290 | ␉␉␉␉return true;␊ |
291 | ␉␉␉}␊ |
292 | ␉␉}␊ |
293 | ␉}␊ |
294 | ␉value->string = "N/A";␊ |
295 | ␉return true;␊ |
296 | }␊ |
297 | ␊ |
298 | bool getSMBMemoryDevicePartNumber(returnType *value)␊ |
299 | {␊ |
300 | ␉static int idx = -1;␊ |
301 | ␉if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {␊ |
302 | ␉␉int␉map;␊ |
303 | ␊ |
304 | ␉␉idx++;␊ |
305 | ␉␉if (idx < MAX_RAM_SLOTS)␊ |
306 | ␉␉{␊ |
307 | ␉␉␉map = Platform->DMI.DIMM[idx];␊ |
308 | ␉␉␉if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].PartNo) > 0)␊ |
309 | ␉␉␉{␊ |
310 | ␉␉␉␉DBG("Ram Detected PartNo[%d]='%s'\n", idx, Platform->RAM.DIMM[map].PartNo);␊ |
311 | ␉␉␉␉value->string = Platform->RAM.DIMM[map].PartNo;␊ |
312 | ␉␉␉␉return true;␊ |
313 | ␉␉␉}␊ |
314 | ␉␉}␊ |
315 | ␉}␊ |
316 | ␉value->string = "N/A";␊ |
317 | ␉return true;␊ |
318 | }␊ |
319 | |