Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/SMBiosGetters/smbios_getters.c

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

Archive Download this file

Revision: 1701