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