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)
159value->word = 0x0701;// Core i7
160return true;
161
162case CPUID_MODEL_FIELDS:// Lynnfield, Clarksfield, Jasper
163if (strstr(Platform->CPU.BrandString, "Core(TM) i5"))
164value->word = 0x601;// Core i5
165else
166value->word = 0x701;// Core i7
167return true;
168
169case CPUID_MODEL_DALES:// Intel Core i5, i7 LGA1156 (45nm) (Havendale, Auburndale)
170if (strstr(Platform->CPU.BrandString, "Core(TM) i5"))
171value->word = 0x601;// Core i5
172else
173value->word = 0x0701;// Core i7
174return true;
175
176case CPUID_MODEL_SANDYBRIDGE:
177case CPUID_MODEL_DALES_32NM:// Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)
178if (strstr(Platform->CPU.BrandString, "Core(TM) i3"))
179value->word = 0x901;// Core i3
180else if (strstr(Platform->CPU.BrandString, "Core(TM) i5"))
181value->word = 0x601;// Core i5
182else if (strstr(Platform->CPU.BrandString, "Core(TM) i7"))
183value->word = 0x0701;// Core i7
184/*else
185value->word = simpleGetSMBOemProcessorType();*/
186return true;
187
188 case CPUID_MODEL_JAKETOWN:
189case CPUID_MODEL_WESTMERE:// Intel Core i7 LGA1366 (32nm) 6 Core (Gulftown, Westmere-EP, Westmere-WS)
190case CPUID_MODEL_WESTMERE_EX:// Intel Core i7 LGA1366 (45nm) 6 Core ???
191value->word = 0x0501;// Core i7
192return true;
193
194case 0x19:// Intel Core i5 650 @3.20 Ghz
195value->word = 0x601;// Core i5
196return true;
197default:
198break; //Unsupported CPU type
199}
200}
201default:
202break;
203}
204}
205
206return false;
207}
208
209bool getSMBMemoryDeviceMemoryType(returnType *value)
210{
211static int idx = -1;
212if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {
213intmap;
214
215idx++;
216if (idx < MAX_RAM_SLOTS)
217{
218map = Platform->DMI.DIMM[idx];
219if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Type != 0)
220{
221DBG("RAM Detected Type = %d\n", Platform->RAM.DIMM[map].Type);
222value->byte = Platform->RAM.DIMM[map].Type;
223return true;
224}
225}
226}
227value->byte = SMB_MEM_TYPE_DDR2;
228return true;
229}
230
231bool getSMBMemoryDeviceMemorySpeed(returnType *value)
232{
233static int idx = -1;
234if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {
235intmap;
236
237idx++;
238if (idx < MAX_RAM_SLOTS)
239{
240map = Platform->DMI.DIMM[idx];
241if (Platform->RAM.DIMM[map].InUse && Platform->RAM.DIMM[map].Frequency != 0)
242{
243DBG("RAM Detected Freq = %d Mhz\n", Platform->RAM.DIMM[map].Frequency);
244value->dword = Platform->RAM.DIMM[map].Frequency;
245return true;
246}
247}
248}
249value->dword = 800;
250return true;
251}
252
253bool getSMBMemoryDeviceManufacturer(returnType *value)
254{
255static int idx = -1;
256if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {
257intmap;
258
259idx++;
260if (idx < MAX_RAM_SLOTS)
261{
262map = Platform->DMI.DIMM[idx];
263if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].Vendor) > 0)
264{
265DBG("RAM Detected Vendor[%d]='%s'\n", idx, Platform->RAM.DIMM[map].Vendor);
266value->string = Platform->RAM.DIMM[map].Vendor;
267return true;
268}
269}
270}
271value->string = "N/A";
272return true;
273}
274
275bool getSMBMemoryDeviceSerialNumber(returnType *value)
276{
277static int idx = -1;
278if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {
279intmap;
280
281idx++;
282if (idx < MAX_RAM_SLOTS)
283{
284map = Platform->DMI.DIMM[idx];
285if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].SerialNo) > 0)
286{
287DBG("name = %s, map=%d, RAM Detected SerialNo[%d]='%s'\n", name ? name : "",
288map, idx, Platform->RAM.DIMM[map].SerialNo);
289value->string = Platform->RAM.DIMM[map].SerialNo;
290return true;
291}
292}
293}
294value->string = "N/A";
295return true;
296}
297
298bool getSMBMemoryDevicePartNumber(returnType *value)
299{
300static int idx = -1;
301if (execute_hook("isMemoryRegistred", NULL, NULL, NULL, NULL, NULL, NULL) == EFI_SUCCESS) {
302intmap;
303
304idx++;
305if (idx < MAX_RAM_SLOTS)
306{
307map = Platform->DMI.DIMM[idx];
308if (Platform->RAM.DIMM[map].InUse && strlen(Platform->RAM.DIMM[map].PartNo) > 0)
309{
310DBG("Ram Detected PartNo[%d]='%s'\n", idx, Platform->RAM.DIMM[map].PartNo);
311value->string = Platform->RAM.DIMM[map].PartNo;
312return true;
313}
314}
315}
316value->string = "N/A";
317return true;
318}
319

Archive Download this file

Revision: 1595