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

Archive Download this file

Revision: 1468