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

Archive Download this file

Revision: 1119