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

Archive Download this file

Revision: 789