Root/
Source at commit HEAD created 5 years 6 days ago. By ifabio, Few update to kernelPatcher (Credits to CrazyBirdy) | |
---|---|
1 | /*␊ |
2 | * A very simple SMBIOS Table decoder, part of the Chameleon Boot Loader Project␊ |
3 | *␊ |
4 | * Copyright 2010 by Islam M. Ahmed Zaid. All rights reserved.␊ |
5 | *␊ |
6 | */␊ |
7 | ␊ |
8 | #include "config.h"␊ |
9 | #include "libsaio.h"␊ |
10 | #include "smbios.h"␊ |
11 | // Bungo:␊ |
12 | #include "boot.h"␊ |
13 | #include "bootstruct.h"␊ |
14 | ␊ |
15 | #if DEBUG_SMBIOS␊ |
16 | ␉#define DBG(x...)␉printf(x)␊ |
17 | #else␊ |
18 | ␉#define DBG(x...)␉msglog(x)␊ |
19 | #endif␊ |
20 | ␊ |
21 | extern char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field);␊ |
22 | // Bungo:␊ |
23 | #define NotSpecifiedStr "Not Specified" // no string␊ |
24 | #define OutOfSpecStr "<OUT OF SPEC>" // value out of smbios spec. range␊ |
25 | #define PrivateStr "** PRIVATE **" // masking private data␊ |
26 | #define neverMask false␊ |
27 | ␊ |
28 | static bool privateData = true;␊ |
29 | static SMBByte minorVersion; // SMBIOS rev. minor␊ |
30 | static SMBByte majorVersion; // SMBIOS rev. major␊ |
31 | static SMBByte bcdRevisionLo; // DMI rev. minor␊ |
32 | static SMBByte bcdRevisionHi; // DMI rev. major␊ |
33 | ␊ |
34 | /*====␊ |
35 | 7.2.2␊ |
36 | ===*/␊ |
37 | static const char *SMBWakeUpTypes[] = // Bungo: strings for wake-up type (Table Type 1 - System Information)␊ |
38 | {␊ |
39 | ␉"Reserved", /* 00h */␊ |
40 | ␉"Other", /* 01h */␊ |
41 | ␉"Unknown", /* 02h */␊ |
42 | ␉"APM Timer", /* 03h */␊ |
43 | ␉"Modem Ring", /* 04h */␊ |
44 | ␉"LAN Remote", /* 05h */␊ |
45 | ␉"Power Switch", /* 06h */␊ |
46 | ␉"PCI PME#", /* 07h */␊ |
47 | ␉"AC Power Restored" /* 08h */␊ |
48 | };␊ |
49 | ␊ |
50 | /*====␊ |
51 | 7.3.2␊ |
52 | ===*/␊ |
53 | static const char *SMBBaseBoardTypes[] = // Bungo: strings for base board type (Table Type 2 - Base Board Information)␊ |
54 | {␊ |
55 | ␉"Unknown", /* 01h */␊ |
56 | ␉"Other", /* 02h */␊ |
57 | ␉"Server Blade", /* 03h */␊ |
58 | ␉"Connectivity Switch", /* 04h */␊ |
59 | ␉"System Management Module", /* 05h */␊ |
60 | ␉"Processor Module", /* 06h */␊ |
61 | ␉"I/O Module", /* 07h */␊ |
62 | ␉"Memory Module", /* 08h */␊ |
63 | ␉"Daughter Board", /* 09h */␊ |
64 | ␉"Motherboard", /* 0Ah */␊ |
65 | ␉"Processor+Memory Module", /* 0Bh */␊ |
66 | ␉"Processor+I/O Module", /* 0Ch */␊ |
67 | ␉"Interconnect Board" /* 0Dh */␊ |
68 | };␊ |
69 | ␊ |
70 | /*===␊ |
71 | 7.4.1␊ |
72 | ===*/␊ |
73 | static const char *SMBChassisTypes[] = // Bungo: strings for chassis type (Table Type 3 - Chassis Information)␊ |
74 | {␊ |
75 | ␉"Other", /* 01h */␊ |
76 | ␉"Unknown", /* 02h */␊ |
77 | ␉"Desktop", /* 03h */␊ |
78 | ␉"Low Profile Desktop", /* 04h */␊ |
79 | ␉"Pizza Box", /* 05h */␊ |
80 | ␉"Mini Tower", /* 06h */␊ |
81 | ␉"Tower", /* 07h */␊ |
82 | ␉"Portable", /* 08h */␊ |
83 | ␉"Laptop", /* 09h */␊ |
84 | ␉"Notebook", /* 0Ah */␊ |
85 | ␉"Hand Held", /* 0Bh */␊ |
86 | ␉"Docking Station", /* 0Ch */␊ |
87 | ␉"All in One", /* 0Dh */␊ |
88 | ␉"Sub Notebook", /* 0Eh */␊ |
89 | ␉"Space-saving", /* 0Fh */␊ |
90 | ␉"Lunch Box",␉␉/* 10h */␊ |
91 | ␉"Main Server Chassis",␉/* 11h */ /* CIM_Chassis.ChassisPackageType says "Main System Chassis" */␊ |
92 | ␉"Expansion Chassis",␉/* 12h */␊ |
93 | ␉"SubChassis",␉␉/* 13h */␊ |
94 | ␉"Bus Expansion Chassis",/* 14h */␊ |
95 | ␉"Peripheral Chassis",␉/* 15h */␊ |
96 | ␉"RAID Chassis",␉␉/* 16h */␊ |
97 | ␉"Rack Mount Chassis", /* 17h */␊ |
98 | ␉"Sealed-case PC",␉/* 18h */␊ |
99 | ␉"Multi-system Chassis", /* 19h */␊ |
100 | ␉"Compact PCI",␉␉/* 1Ah */␊ |
101 | ␉"Advanced TCA",␉␉/* 1Bh */␊ |
102 | ␉"Blade",␉␉/* 1Ch */ // An SMBIOS implementation for a Blade would contain a Type 3 Chassis structure␊ |
103 | ␉"Blade Enclosing",␉/* 1Dh */ // A Blade Enclosure is a specialized chassis that contains a set of Blades.␊ |
104 | ␉"Tablet",␉␉/* 1Eh */␊ |
105 | ␉"Convertible",␉␉/* 1Fh */␊ |
106 | ␉"Detachable"␉␉/* 0x20h */␊ |
107 | };␊ |
108 | ␊ |
109 | /*====␊ |
110 | 7.5.1␊ |
111 | ===*/␊ |
112 | static const char *SMBProcessorTypes[] = // Bungo: strings for processor type (Table Type 4 - Processor Information)␊ |
113 | {␊ |
114 | ␉"Other", /* 01h */␊ |
115 | ␉"Unknown", /* 02h */␊ |
116 | ␉"Central Processor", /* 03h */␊ |
117 | ␉"Math Processor", /* 04h */␊ |
118 | ␉"DSP Processor", /* 05h */␊ |
119 | ␉"Video Processor" /* 06h */␊ |
120 | };␊ |
121 | ␊ |
122 | /*====␊ |
123 | 7.5.5␊ |
124 | ===*/␊ |
125 | static const char *SMBProcessorUpgrades[] = // ErmaC: strings for processor upgrade (Table Type 4 - Processor Information)␊ |
126 | {␊ |
127 | ␉"Other", /* 01h */␊ |
128 | ␉"Unknown", /* 02h */␊ |
129 | ␉"Daughter Board",␊ |
130 | ␉"ZIF Socket",␊ |
131 | ␉"Replaceable Piggy Back",␊ |
132 | ␉"None",␊ |
133 | ␉"LIF Socket",␊ |
134 | ␉"Slot 1",␊ |
135 | ␉"Slot 2",␊ |
136 | ␉"370-pin Socket",␊ |
137 | ␉"Slot A",␊ |
138 | ␉"Slot M",␊ |
139 | ␉"Socket 423",␊ |
140 | ␉"Socket A (Socket 462)",␊ |
141 | ␉"Socket 478",␊ |
142 | ␉"Socket 754",␊ |
143 | ␉"Socket 940",␊ |
144 | ␉"Socket 939",␊ |
145 | ␉"Socket mPGA604",␊ |
146 | ␉"Socket LGA771",␊ |
147 | ␉"Socket LGA775",␊ |
148 | ␉"Socket S1",␊ |
149 | ␉"Socket AM2",␊ |
150 | ␉"Socket F (1207)",␊ |
151 | ␉"Socket LGA1366",␊ |
152 | ␉"Socket G34",␊ |
153 | ␉"Socket AM3",␊ |
154 | ␉"Socket C32",␊ |
155 | ␉"Socket LGA1156",␊ |
156 | ␉"Socket LGA1567",␊ |
157 | ␉"Socket PGA988A",␊ |
158 | ␉"Socket BGA1288",␊ |
159 | ␉"Socket rPGA988B",␊ |
160 | ␉"Socket BGA1023",␊ |
161 | ␉"Socket BGA1224",␊ |
162 | ␉"Socket BGA1155",␊ |
163 | ␉"Socket LGA1356",␊ |
164 | ␉"Socket LGA2011",␊ |
165 | ␉"Socket FS1",␊ |
166 | ␉"Socket FS2",␊ |
167 | ␉"Socket FM1",␊ |
168 | ␉"Socket FM2",␊ |
169 | ␉"Socket LGA2011-3",␊ |
170 | ␉"Socket LGA1356-3", /* 2Ch */␊ |
171 | ␉"Socket LGA1150",␊ |
172 | ␉"Socket BGA1168",␊ |
173 | ␉"Socket BGA1234",␊ |
174 | ␉"Socket BGA1364" /* 0x30h */␊ |
175 | };␊ |
176 | ␊ |
177 | static const char *SMBMemoryDeviceFormFactors[] = // Bungo: strings for form factor (Table Type 17 - Memory Device)␊ |
178 | {␊ |
179 | ␉"Other", /* 01h */␊ |
180 | ␉"Unknown", /* 02h */␊ |
181 | ␉"SIMM", /* 03h */␊ |
182 | ␉"SIP", /* 04h */␊ |
183 | ␉"Chip", /* 05h */␊ |
184 | ␉"DIP", /* 06h */␊ |
185 | ␉"ZIP", /* 07h */␊ |
186 | ␉"Proprietary Card", /* 08h */␊ |
187 | ␉"DIMM", /* 09h */␊ |
188 | ␉"TSOP", /* 0Ah */␊ |
189 | ␉"Row of chips", /* 0Bh */␊ |
190 | ␉"RIMM", /* 0Ch */␊ |
191 | ␉"SODIMM", /* 0Dh */␊ |
192 | ␉"SRIMM", /* 0Eh */␊ |
193 | ␉"FB-DIMM" /* 0Fh */␊ |
194 | };␊ |
195 | ␊ |
196 | /*=====␊ |
197 | 7.18.2␊ |
198 | ====*/␊ |
199 | static const char *SMBMemoryDeviceTypes[] =␊ |
200 | {␊ |
201 | ␉"RAM", /* 00h Undefined */␊ |
202 | ␉"RAM", /* 01h Other */␊ |
203 | ␉"RAM", /* 02h Unknown */␊ |
204 | ␉"DRAM", /* 03h DRAM */␊ |
205 | ␉"EDRAM", /* 04h EDRAM */␊ |
206 | ␉"VRAM", /* 05h VRAM */␊ |
207 | ␉"SRAM", /* 06h SRAM */␊ |
208 | ␉"RAM", /* 07h RAM */␊ |
209 | ␉"ROM", /* 08h ROM */␊ |
210 | ␉"FLASH", /* 09h FLASH */␊ |
211 | ␉"EEPROM", /* 0Ah EEPROM */␊ |
212 | ␉"FEPROM", /* 0Bh FEPROM */␊ |
213 | ␉"EPROM", /* 0Ch EPROM */␊ |
214 | ␉"CDRAM", /* 0Dh CDRAM */␊ |
215 | ␉"3DRAM", /* 0Eh 3DRAM */␊ |
216 | ␉"SDRAM", /* 0Fh SDRAM */␊ |
217 | ␉"SGRAM", /* 10h SGRAM */␊ |
218 | ␉"RDRAM", /* 11h RDRAM */␊ |
219 | ␉"DDR SDRAM", /* 12h DDR */␊ |
220 | ␉"DDR2 SDRAM", /* 13h DDR2 */␊ |
221 | ␉"DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */␊ |
222 | ␉"RAM",␉␉/* 15h unused */␊ |
223 | ␉"RAM",␉␉/* 16h unused */␊ |
224 | ␉"RAM",␉␉/* 17h unused */␊ |
225 | ␉"DDR3",␉␉/* 18h DDR3, chosen in [5776134] */␊ |
226 | ␉"FBD2",␉␉/* 19h FBD2 */␊ |
227 | ␉"DDR4",␉␉/* 1Ah DDR4 */␊ |
228 | ␉"LPDDR",␉/* 1Bh LPDDR */␊ |
229 | ␉"LPDDR2",␉/* 1Ch LPDDR2 */␊ |
230 | ␉"LPDDR3",␉/* 1Dh LPDDR3 */␊ |
231 | ␉"LPDDR4"␉/* 1Eh LPDDR5 */␊ |
232 | };␊ |
233 | ␊ |
234 | static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) / sizeof(SMBMemoryDeviceTypes[0]);␊ |
235 | ␊ |
236 | // Bungo: fixes random string readout if null in smbios to "Not Specified" as dmidecode displays␊ |
237 | char *SMBStringForField(SMBStructHeader *structHeader, uint8_t field, const bool mask)␊ |
238 | {␊ |
239 | ␉char *str = NULL;␊ |
240 | ␉str = getSMBStringForField(structHeader, field);␊ |
241 | ␉if (!field)␊ |
242 | ␉{␊ |
243 | ␉␉str = NotSpecifiedStr;␊ |
244 | ␉}␊ |
245 | ␉else if (mask)␊ |
246 | ␉{␊ |
247 | ␉␉str = PrivateStr;␊ |
248 | ␉}␊ |
249 | ␊ |
250 | ␉return str;␊ |
251 | }␊ |
252 | ␊ |
253 | void printHeader(SMBStructHeader *structHeader)␊ |
254 | {␊ |
255 | ␉DBG("Handle: 0x%04X, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);␊ |
256 | }␊ |
257 | ␊ |
258 | //-------------------------------------------------------------------------------------------------------------------------␊ |
259 | // BIOS Information (Type 0)␊ |
260 | //-------------------------------------------------------------------------------------------------------------------------␊ |
261 | void decodeBIOSInformation(SMBStructHeader *structHeader)␊ |
262 | {␊ |
263 | ␉printHeader(structHeader);␊ |
264 | ␉DBG("BIOS Information\n");␊ |
265 | ␉DBG("\tVendor: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->vendor, neverMask));␊ |
266 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->version, neverMask));␊ |
267 | ␉DBG("\tRelease Date: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->releaseDate, neverMask));␊ |
268 | // Address:␊ |
269 | // Runtime Size:␊ |
270 | // ROM Size:␊ |
271 | // DBG("\tSupported BIOS functions: (0x%llX) %s\n", ((SMBBIOSInformation *)structHeader)->characteristics, SMBBIOSInfoChar0[((SMBBIOSInformation *)structHeader)->characteristics]);␊ |
272 | ␉DBG("\tBIOS Revision: %d.%d\n", ((SMBBIOSInformation *)structHeader)->releaseMajor, ((SMBBIOSInformation *)structHeader)->releaseMinor);␊ |
273 | // Firmware Major Release␊ |
274 | // Firmware Minor Release␊ |
275 | // SMBByte characteristicsExt1;␊ |
276 | // SMBByte characteristicsExt2;␊ |
277 | ␉DBG("\n");␊ |
278 | }␊ |
279 | ␊ |
280 | //-------------------------------------------------------------------------------------------------------------------------␊ |
281 | // System Information (Type 1)␊ |
282 | //-------------------------------------------------------------------------------------------------------------------------␊ |
283 | void decodeSystemInformation(SMBStructHeader *structHeader)␊ |
284 | {␊ |
285 | ␉printHeader(structHeader);␊ |
286 | ␉DBG("System Information\n");␊ |
287 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->manufacturer, neverMask));␊ |
288 | ␉DBG("\tProduct Name: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->productName, neverMask));␊ |
289 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->version, neverMask));␊ |
290 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->serialNumber, privateData));␊ |
291 | ␉uint8_t *uuid = ((SMBSystemInformation *)structHeader)->uuid;␊ |
292 | ␉if (privateData) {␊ |
293 | ␉␉DBG("\tUUID: %s\n", PrivateStr);␊ |
294 | ␉} else {␊ |
295 | ␉␉DBG("\tUUID: %02X%02X%02X%02X-%02X%02X-%02X%02X-%02x%02X-%02X%02X%02X%02X%02X%02X\n",␊ |
296 | ␉␉␉uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],␊ |
297 | ␉␉␉uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);␊ |
298 | ␉}␊ |
299 | ␉if (((SMBSystemInformation *)structHeader)->wakeupReason > 8) {␊ |
300 | ␉␉DBG("\tWake-up Type: %s\n", OutOfSpecStr);␊ |
301 | ␉} else {␊ |
302 | ␉␉DBG("\tWake-up Type: %s\n", SMBWakeUpTypes[((SMBSystemInformation *)structHeader)->wakeupReason]);␊ |
303 | ␉}␊ |
304 | ␉DBG("\tSKU Number: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->skuNumber, neverMask)); // System SKU#␊ |
305 | ␉DBG("\tFamily: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->family, neverMask));␊ |
306 | ␉DBG("\n");␊ |
307 | }␊ |
308 | ␊ |
309 | //-------------------------------------------------------------------------------------------------------------------------␊ |
310 | // Base Board (or Module) Information (Type 2)␊ |
311 | //-------------------------------------------------------------------------------------------------------------------------␊ |
312 | void decodeBaseBoard(SMBStructHeader *structHeader)␊ |
313 | {␊ |
314 | ␉printHeader(structHeader);␊ |
315 | ␉DBG("Base Board Information\n");␊ |
316 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->manufacturer, neverMask));␊ |
317 | ␉DBG("\tProduct Name: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->product, neverMask));␊ |
318 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->version, neverMask));␊ |
319 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->serialNumber, privateData));␊ |
320 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->assetTag, neverMask));␊ |
321 | // Feature Flags (BYTE)␊ |
322 | ␉DBG("\tLocation In Chassis: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->locationInChassis, neverMask)); // Part Component␊ |
323 | // Chassis Handle (WORD)␊ |
324 | ␉if ((((SMBBaseBoard *)structHeader)->boardType < kSMBBaseBoardUnknown) || (((SMBBaseBoard *)structHeader)->boardType > kSMBBaseBoardInterconnect)) {␊ |
325 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
326 | ␉} else {␊ |
327 | ␉␉DBG("\tType: %s\n", SMBBaseBoardTypes[(((SMBBaseBoard *)structHeader)->boardType - 1)]);␊ |
328 | ␉}␊ |
329 | // Number of Contained Object Handles (n) (BYTE)␊ |
330 | // Contained Object Handles n(WORDs)␊ |
331 | ␉DBG("\n");␊ |
332 | }␊ |
333 | ␊ |
334 | //-------------------------------------------------------------------------------------------------------------------------␊ |
335 | // System Enclosure or Chassis (Type 3)␊ |
336 | //-------------------------------------------------------------------------------------------------------------------------␊ |
337 | void decodeSystemEnclosure(SMBStructHeader *structHeader)␊ |
338 | {␊ |
339 | ␉printHeader(structHeader);␊ |
340 | ␉DBG("Chassis Information\n");␊ |
341 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->manufacturer, neverMask));␊ |
342 | ␉if ((((SMBSystemEnclosure *)structHeader)->chassisType < kSMBchassisOther) || (((SMBSystemEnclosure *)structHeader)->chassisType > kSMBchassisBladeEnclosing)) {␊ |
343 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
344 | ␉} else {␊ |
345 | ␉␉DBG("\tType: %s\n", SMBChassisTypes[(((SMBSystemEnclosure *)structHeader)->chassisType - 1)]);␊ |
346 | ␉}␊ |
347 | // Lock:␊ |
348 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->version, neverMask));␊ |
349 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->serialNumber, privateData));␊ |
350 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->assetTag, neverMask));␊ |
351 | // Boot-up State:␊ |
352 | // Power Supply State␊ |
353 | // Thermal State␊ |
354 | // Security Status:␊ |
355 | // OEM Information:␊ |
356 | // Height;␊ |
357 | // Number Of Power Cords: Cords;␊ |
358 | // Contained Elements: ElementsCount;␊ |
359 | // SKU Number:␊ |
360 | // ElementLen;␊ |
361 | // Elements[1]; // open array of ElementsCount*ElementLen BYTEs␊ |
362 | ␉DBG("\n");␊ |
363 | }␊ |
364 | ␊ |
365 | //-------------------------------------------------------------------------------------------------------------------------␊ |
366 | // Processor Information (Type 4)␊ |
367 | //-------------------------------------------------------------------------------------------------------------------------␊ |
368 | void decodeProcessorInformation(SMBStructHeader *structHeader)␊ |
369 | {␊ |
370 | ␉printHeader(structHeader);␊ |
371 | ␉DBG("Processor Information\n");␊ |
372 | ␉DBG("\tSocket Designation: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->socketDesignation, neverMask));␊ |
373 | ␉if ((((SMBProcessorInformation *)structHeader)->processorType < kSMBprocessorTypeOther) || (((SMBProcessorInformation *)structHeader)->processorType > kSMBprocessorTypeGPU)) {␊ |
374 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
375 | ␉} else {␊ |
376 | ␉␉DBG("\tType: %s\n", SMBProcessorTypes[((SMBProcessorInformation *)structHeader)->processorType - 1]);␊ |
377 | ␉}␊ |
378 | ␉DBG("\tFamily: 0x%X\n", ((SMBProcessorInformation *)structHeader)->processorFamily);␊ |
379 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->manufacturer, neverMask));␊ |
380 | ␉DBG("\tID: 0x%llX\n", ((SMBProcessorInformation *)structHeader)->processorID);␊ |
381 | //␉DBG("\tSignature: Type %u, Family %u, Model %u, Stepping %u\n", (eax >> 12) & 0x3, ((eax >> 20) & 0xFF) + ((eax >> 8) & 0x0F), ((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F), eax & 0xF);␊ |
382 | // Flags:␊ |
383 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->processorVersion, neverMask));␊ |
384 | //␉DBG("\tVoltage: 0.%dV\n", ((SMBProcessorInformation *)structHeader)->voltage);␊ |
385 | ␉DBG("\tExternal Clock: %d MHz\n", ((SMBProcessorInformation *)structHeader)->externalClock);␊ |
386 | ␉DBG("\tMax Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->maximumClock);␊ |
387 | ␉DBG("\tCurrent Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->currentClock);␊ |
388 | // Status: Populated/Unpopulated␊ |
389 | ␉if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C))␊ |
390 | ␉{␊ |
391 | ␉␉DBG("\tUpgrade: %s\n", OutOfSpecStr);␊ |
392 | ␉}␊ |
393 | ␉else␊ |
394 | ␉{␊ |
395 | ␉␉DBG("\tUpgrade: %s\n", SMBProcessorUpgrades[((SMBProcessorInformation *)structHeader)->processorUpgrade - 1]);␊ |
396 | ␉}␊ |
397 | // L1 Cache Handle:␊ |
398 | // L2 Cache Handle:␊ |
399 | // L3 Cache Handle:␊ |
400 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->serialNumber, privateData));␊ |
401 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->assetTag, neverMask));␊ |
402 | ␉DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->partNumber, neverMask));␊ |
403 | ␉if(((SMBProcessorInformation *)structHeader)->coreCount != 0)␊ |
404 | ␉{␊ |
405 | ␉␉DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);␊ |
406 | ␉}␊ |
407 | ␊ |
408 | ␉if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0)␊ |
409 | ␉{␊ |
410 | ␉␉DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);␊ |
411 | ␉}␊ |
412 | ␊ |
413 | ␉if(((SMBProcessorInformation *)structHeader)->threadCount != 0)␊ |
414 | ␉{␊ |
415 | ␉␉DBG("\tThread Count: %d\n", ((SMBProcessorInformation *)structHeader)->threadCount);␊ |
416 | ␉}␊ |
417 | // Characteristics:␊ |
418 | //␉DBG("\tProcessor Family 2: %d\n", ((SMBProcessorInformation *)structHeader)->processorFamily2);␊ |
419 | ␉DBG("\n");␊ |
420 | }␊ |
421 | ␊ |
422 | //-------------------------------------------------------------------------------------------------------------------------␊ |
423 | // Memory Controller Information (Type 5)␊ |
424 | //-------------------------------------------------------------------------------------------------------------------------␊ |
425 | ␊ |
426 | //-------------------------------------------------------------------------------------------------------------------------␊ |
427 | // Memory Module Information (Type 6)␊ |
428 | //-------------------------------------------------------------------------------------------------------------------------␊ |
429 | //void decodeMemoryModule(SMBStructHeader *structHeader)␊ |
430 | //{␊ |
431 | //␉DBG("Memory Module Information\n");␊ |
432 | //␉DBG("\tSocket Designation: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->socketDesignation));␊ |
433 | //␉DBG("\tBank Connections: Type: %d\n", structHeader->bankConnections);␊ |
434 | //␉DBG("\tCurrent Speed: %X\n", structHeader->currentSpeed);␊ |
435 | //␉DBG("\tType: %llX\n", structHeader->currentMemoryType);␊ |
436 | //␉DBG("\tInstalled Size: %d\n", structHeader->installedSize);␊ |
437 | //␉DBG("\tEnabled Size: %d\n", structHeader->enabledSize);␊ |
438 | //␉DBG("\tError Status: %x\n", structHeader->errorStatus);␊ |
439 | //␉DBG("\n");␊ |
440 | //}␊ |
441 | ␊ |
442 | //-------------------------------------------------------------------------------------------------------------------------␊ |
443 | // Cache Information (Type 7)␊ |
444 | //-------------------------------------------------------------------------------------------------------------------------␊ |
445 | ␊ |
446 | //-------------------------------------------------------------------------------------------------------------------------␊ |
447 | // Port Connector Information (Type 8)␊ |
448 | //-------------------------------------------------------------------------------------------------------------------------␊ |
449 | ␊ |
450 | //-------------------------------------------------------------------------------------------------------------------------␊ |
451 | // System Slot Information (Type 9)␊ |
452 | //-------------------------------------------------------------------------------------------------------------------------␊ |
453 | ␊ |
454 | //-------------------------------------------------------------------------------------------------------------------------␊ |
455 | // On Board Device Information (Type 10)␊ |
456 | //-------------------------------------------------------------------------------------------------------------------------␊ |
457 | ␊ |
458 | //-------------------------------------------------------------------------------------------------------------------------␊ |
459 | // OEM Strings (Type 11)␊ |
460 | //-------------------------------------------------------------------------------------------------------------------------␊ |
461 | void decodeSMBOEMStrings(SMBStructHeader *structHeader)␊ |
462 | {␊ |
463 | ␉char *stringPtr = (char *)structHeader + structHeader->length;␊ |
464 | ␉printHeader(structHeader);␊ |
465 | ␉DBG("OEM Strings\n");␊ |
466 | ␉SMBByte i;␊ |
467 | ␉for (i = 1; i <= ((SMBOEMStrings *)structHeader)->count; i++) {␊ |
468 | ␉␉DBG("\tString %d: %s\n", i, stringPtr);␊ |
469 | ␉␉stringPtr = stringPtr + strlen(stringPtr) + 1;␊ |
470 | ␉}␊ |
471 | ␉DBG("\n");␊ |
472 | }␊ |
473 | //-------------------------------------------------------------------------------------------------------------------------␊ |
474 | // System Configuration Options (Type 12)␊ |
475 | //-------------------------------------------------------------------------------------------------------------------------␊ |
476 | ␊ |
477 | //-------------------------------------------------------------------------------------------------------------------------␊ |
478 | // BIOS Language Information (Type 13)␊ |
479 | //-------------------------------------------------------------------------------------------------------------------------␊ |
480 | ␊ |
481 | //-------------------------------------------------------------------------------------------------------------------------␊ |
482 | // Physical Memory Array (Type 16)␊ |
483 | //-------------------------------------------------------------------------------------------------------------------------␊ |
484 | ␊ |
485 | //-------------------------------------------------------------------------------------------------------------------------␊ |
486 | // MemoryDevice (Type 17)␊ |
487 | //-------------------------------------------------------------------------------------------------------------------------␊ |
488 | void decodeMemoryDevice(SMBStructHeader *structHeader)␊ |
489 | {␊ |
490 | ␉printHeader(structHeader);␊ |
491 | ␉DBG("Memory Device\n");␊ |
492 | // Aray Handle␊ |
493 | ␉if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF)␊ |
494 | ␉{␊ |
495 | ␉␉DBG("\tError Information Handle: No Error\n");␊ |
496 | ␉}␊ |
497 | ␉else␊ |
498 | ␉{␊ |
499 | ␉␉DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle);␊ |
500 | ␉}␊ |
501 | // Total Width:␊ |
502 | // Data Width:␊ |
503 | ␉switch (((SMBMemoryDevice *)structHeader)->memorySize)␊ |
504 | ␉{␊ |
505 | ␉␉case 0:␊ |
506 | ␉␉␉DBG("\tSize: No Module Installed\n");␊ |
507 | ␉␉␉break;␊ |
508 | ␉␉case 0x7FFF:␊ |
509 | ␉␉␉DBG("\tSize: 32GB or more\n");␊ |
510 | ␉␉␉break;␊ |
511 | ␉␉case 0xFFFF:␊ |
512 | ␉␉␉DBG("\tSize: Unknown\n");␊ |
513 | ␉␉␉break;␊ |
514 | ␉␉default:␊ |
515 | ␉␉␉DBG("\tSize: %d %s\n", ((SMBMemoryDevice *)structHeader)->memorySize & 0x7FFF, ((((SMBMemoryDevice *)structHeader)->memorySize & 0x8000) == 0x8000) ? "kB" : "MB");␊ |
516 | ␉␉␉break;␊ |
517 | ␉}␊ |
518 | ␉if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F))␊ |
519 | ␉{␊ |
520 | ␉␉DBG("\tForm Factor: %s\n", OutOfSpecStr);␊ |
521 | ␉}␊ |
522 | ␉else␊ |
523 | ␉{␊ |
524 | ␉␉DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]);␊ |
525 | ␉}␊ |
526 | // Set:␊ |
527 | ␉DBG("\tLocator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->deviceLocator, neverMask));␊ |
528 | ␉DBG("\tBank Locator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->bankLocator, neverMask));␊ |
529 | ␉if (((SMBMemoryDevice *)structHeader)->memoryType > kSMBMemoryDeviceTypeCount)␊ |
530 | ␉{␊ |
531 | ␉␉DBG("\tMemory Type: %s\n", OutOfSpecStr);␊ |
532 | ␉}␊ |
533 | ␉else␊ |
534 | ␉{␊ |
535 | ␉␉DBG("\tMemory Type: %s\n", SMBMemoryDeviceTypes[((SMBMemoryDevice *)structHeader)->memoryType]);␊ |
536 | ␉}␊ |
537 | // Type Detail:␊ |
538 | ␉DBG("\tSpeed: %d MHz\n", ((SMBMemoryDevice *)structHeader)->memorySpeed);␊ |
539 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->manufacturer, neverMask));␊ |
540 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->serialNumber, privateData));␊ |
541 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->assetTag, neverMask));␊ |
542 | ␉DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->partNumber, neverMask));␊ |
543 | // Rank:␊ |
544 | // Configured Clock Speed:␊ |
545 | // Minimum Voltage:␊ |
546 | // Maximum Voltage:␊ |
547 | // Configured Voltage:␊ |
548 | ␉DBG("\n");␊ |
549 | }␊ |
550 | ␊ |
551 | //-------------------------------------------------------------------------------------------------------------------------␊ |
552 | // Apple Specific (Type 131)␊ |
553 | //-------------------------------------------------------------------------------------------------------------------------␊ |
554 | void decodeOemProcessorType(SMBStructHeader *structHeader)␊ |
555 | {␊ |
556 | ␉printHeader(structHeader);␊ |
557 | ␉DBG("Apple specific Processor Type\n");␊ |
558 | ␉DBG("\tCpu-type = 0x%04X\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);␊ |
559 | ␉DBG("\n");␊ |
560 | }␊ |
561 | ␊ |
562 | //-------------------------------------------------------------------------------------------------------------------------␊ |
563 | // Apple Specific (Type 132)␊ |
564 | //-------------------------------------------------------------------------------------------------------------------------␊ |
565 | void decodeOemProcessorBusSpeed(SMBStructHeader *structHeader)␊ |
566 | {␊ |
567 | ␉printHeader(structHeader);␊ |
568 | ␉DBG("Apple specific Processor Interconnect Speed\n");␊ |
569 | ␉DBG("\tQPI = %d MT/s\n", ((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed);␊ |
570 | ␉DBG("\n");␊ |
571 | }␊ |
572 | ␊ |
573 | // Info for the Table Above: dmi 2.7+ https://wiki.debian.org/InstallingDebianOn/Thinkpad/T42/lenny?action=AttachFile&do=get&target=dmidecode.Lenny_Thinkpad_T42_2373.txt␊ |
574 | //-------------------------------------------------------------------------------------------------------------------------␊ |
575 | // Apple Specific (Type 133)␊ |
576 | //-------------------------------------------------------------------------------------------------------------------------␊ |
577 | //void decodeOemPlatformFeature(SMBStructHeader *structHeader)␊ |
578 | //{␊ |
579 | //␉printHeader(structHeader);␊ |
580 | //␉DBG("Apple specific Platform Feature\n");␊ |
581 | //␉DBG("\t%s\n", ((SMBOemPlatformFeature *)structHeader)->PlatformFeature);␊ |
582 | //␉DBG("\n");␊ |
583 | //}␊ |
584 | ␊ |
585 | //-------------------------------------------------------------------------------------------------------------------------␊ |
586 | // Specific (Type 134)␊ |
587 | //-------------------------------------------------------------------------------------------------------------------------␊ |
588 | //void decodeOem(SMBStructHeader *structHeader)␊ |
589 | //{␊ |
590 | //␉printHeader(structHeader);␊ |
591 | //␉DBG("Apple specific Feature\n");␊ |
592 | //␉DBG("\t%s\n", ((SMBOemPlatformFeature *)structHeader)->Feature);␊ |
593 | //␉DBG("\n");␊ |
594 | //}␊ |
595 | ␊ |
596 | //-------------------------------------------------------------------------------------------------------------------------␊ |
597 | ␊ |
598 | ␊ |
599 | void decodeSMBIOSTable(SMBEntryPoint *eps)␊ |
600 | {␊ |
601 | ␉uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;␊ |
602 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)ptr;␊ |
603 | ␊ |
604 | ␉minorVersion = eps->minorVersion;␊ |
605 | ␉majorVersion = eps->majorVersion;␊ |
606 | ␉bcdRevisionHi = eps->dmi.bcdRevision >> 4;␊ |
607 | ␉bcdRevisionLo = eps->dmi.bcdRevision & 0x0F;␊ |
608 | ␊ |
609 | ␉getBoolForKey(kPrivateData, &privateData, &bootInfo->chameleonConfig); // Bungo: chek if mask some data␊ |
610 | ␊ |
611 | ␉DBG("\n");␊ |
612 | ␉DBG("SMBIOS rev.: %d.%d, DMI rev.: %d.%d\n", majorVersion, minorVersion, bcdRevisionHi, bcdRevisionLo);␊ |
613 | ␉DBG("\n");␊ |
614 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)␊ |
615 | ␉{␊ |
616 | ␉␉switch (structHeader->type)␊ |
617 | ␉␉{␊ |
618 | ␉␉␉case kSMBTypeBIOSInformation: // Type 0␊ |
619 | ␉␉␉␉decodeBIOSInformation(structHeader);␊ |
620 | ␉␉␉␉break;␊ |
621 | ␊ |
622 | ␉␉␉case kSMBTypeSystemInformation: // Type 1␊ |
623 | ␉␉␉␉decodeSystemInformation(structHeader);␊ |
624 | ␉␉␉␉break;␊ |
625 | ␊ |
626 | ␉␉␉case kSMBTypeBaseBoard: // Type 2␊ |
627 | ␉␉␉␉decodeBaseBoard(structHeader);␊ |
628 | ␉␉␉␉break;␊ |
629 | ␊ |
630 | ␉␉␉case kSMBTypeSystemEnclosure: // Type 3␊ |
631 | ␉␉␉␉decodeSystemEnclosure(structHeader);␊ |
632 | ␉␉␉␉break;␊ |
633 | ␊ |
634 | ␉␉␉case kSMBTypeProcessorInformation: // Type 4␊ |
635 | ␉␉␉␉decodeProcessorInformation(structHeader);␊ |
636 | ␉␉␉␉break;␊ |
637 | ␊ |
638 | ␉␉␉//case kSMBTypeMemoryModule: // Type 6␊ |
639 | ␉␉␉//␉decodeMemoryModule(structHeader);␊ |
640 | ␉␉␉//␉break;␊ |
641 | ␊ |
642 | ␉␉␉//case kSMBTypeSystemSlot: // Type 9␊ |
643 | ␉␉␉//␉decodeSMBTypeSystemSlot(structHeader);␊ |
644 | ␉␉␉//␉break;␊ |
645 | ␊ |
646 | ␉␉␉case kSMBOEMStrings: // Type 11␊ |
647 | ␉␉␉␉decodeSMBOEMStrings(structHeader);␊ |
648 | ␉␉␉␉break;␊ |
649 | ␊ |
650 | ␉␉␉case kSMBTypeMemoryDevice: // Type 17␊ |
651 | ␉␉␉␉decodeMemoryDevice(structHeader);␊ |
652 | ␉␉␉␉break;␊ |
653 | ␊ |
654 | ␉␉␉//kSMBTypeMemoryArrayMappedAddress: // Type 19␊ |
655 | ␉␉␉//␉break;␊ |
656 | ␊ |
657 | ␉␉␉/* Skip all Apple Specific Structures */␊ |
658 | ␉␉␉// case kSMBTypeFirmwareVolume: // Type 128␊ |
659 | ␉␉␉// case kSMBTypeMemorySPD: // Type 130␊ |
660 | ␉␉␉//␉break;␊ |
661 | ␊ |
662 | ␉␉␉case kSMBTypeOemProcessorType: // Type 131␊ |
663 | ␉␉␉␉decodeOemProcessorType(structHeader);␊ |
664 | ␉␉␉␉break;␊ |
665 | ␊ |
666 | ␉␉␉case kSMBTypeOemProcessorBusSpeed: // Type 132␊ |
667 | ␉␉␉␉decodeOemProcessorBusSpeed(structHeader);␊ |
668 | ␉␉␉␉break;␊ |
669 | ␊ |
670 | ␉␉␉//case kSMBTypeOemPlatformFeature: // Type 133␊ |
671 | ␉␉␉//␉decodeOemPlatformFeature(structHeader);␊ |
672 | ␉␉␉//␉break;␊ |
673 | ␊ |
674 | ␉␉␉case kSMBTypeEndOfTable: // Type 127␊ |
675 | ␉␉␉␉DBG("Handle 0x%04x, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);␊ |
676 | ␉␉␉␉DBG("End of Table\n");␊ |
677 | ␉␉␉␉break;␊ |
678 | ␊ |
679 | ␉␉␉default:␊ |
680 | ␉␉␉␉break;␊ |
681 | ␉␉}␊ |
682 | ␊ |
683 | ␉␉ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
684 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
685 | ␊ |
686 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
687 | ␉␉{␊ |
688 | ␉␉␉ptr += 2;␊ |
689 | ␉␉}␊ |
690 | ␊ |
691 | ␉␉structHeader = (SMBStructHeader *)ptr;␊ |
692 | ␉}␊ |
693 | ␉DBG("\n");␊ |
694 | }␊ |
695 | ␊ |
696 |