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 */␊ |
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 | };␊ |
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",␊ |
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 | };␊ |
172 | ␊ |
173 | static const char *SMBMemoryDeviceFormFactors[] = // Bungo: strings for form factor (Table Type 17 - Memory Device)␊ |
174 | {␊ |
175 | "Other", /* 01h */␊ |
176 | "Unknown", /* 02h */␊ |
177 | "SIMM", /* 03h */␊ |
178 | "SIP", /* 04h */␊ |
179 | "Chip", /* 05h */␊ |
180 | "DIP", /* 06h */␊ |
181 | "ZIP", /* 07h */␊ |
182 | "Proprietary Card", /* 08h */␊ |
183 | "DIMM", /* 09h */␊ |
184 | "TSOP", /* 0Ah */␊ |
185 | "Row of chips", /* 0Bh */␊ |
186 | "RIMM", /* 0Ch */␊ |
187 | "SODIMM", /* 0Dh */␊ |
188 | "SRIMM", /* 0Eh */␊ |
189 | "FB-DIMM" /* 0Fh */␊ |
190 | };␊ |
191 | ␊ |
192 | /*=====␊ |
193 | 7.18.2␊ |
194 | ====*/␊ |
195 | static const char *SMBMemoryDeviceTypes[] =␊ |
196 | {␊ |
197 | ␉"RAM", /* 00h Undefined */␊ |
198 | ␉"RAM", /* 01h Other */␊ |
199 | ␉"RAM", /* 02h Unknown */␊ |
200 | ␉"DRAM", /* 03h DRAM */␊ |
201 | ␉"EDRAM", /* 04h EDRAM */␊ |
202 | ␉"VRAM", /* 05h VRAM */␊ |
203 | ␉"SRAM", /* 06h SRAM */␊ |
204 | ␉"RAM", /* 07h RAM */␊ |
205 | ␉"ROM", /* 08h ROM */␊ |
206 | ␉"FLASH", /* 09h FLASH */␊ |
207 | ␉"EEPROM", /* 0Ah EEPROM */␊ |
208 | ␉"FEPROM", /* 0Bh FEPROM */␊ |
209 | ␉"EPROM", /* 0Ch EPROM */␊ |
210 | ␉"CDRAM", /* 0Dh CDRAM */␊ |
211 | ␉"3DRAM", /* 0Eh 3DRAM */␊ |
212 | ␉"SDRAM", /* 0Fh SDRAM */␊ |
213 | ␉"SGRAM", /* 10h SGRAM */␊ |
214 | ␉"RDRAM", /* 11h RDRAM */␊ |
215 | ␉"DDR SDRAM", /* 12h DDR */␊ |
216 | ␉"DDR2 SDRAM", /* 13h DDR2 */␊ |
217 | ␉"DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */␊ |
218 | ␉"RAM", /* 15h unused */␊ |
219 | ␉"RAM", /* 16h unused */␊ |
220 | ␉"RAM", /* 17h unused */␊ |
221 | ␉"DDR3", /* 18h DDR3, chosen in [5776134] */␊ |
222 | ␉"FBD2" /* 19h FBD2 */␊ |
223 | };␊ |
224 | ␊ |
225 | static const int kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) /␊ |
226 | sizeof(SMBMemoryDeviceTypes[0]);␊ |
227 | ␊ |
228 | // Bungo: fixes random string readout if null in smbios to "Not Specified" as dmidecode displays␊ |
229 | char *SMBStringForField(SMBStructHeader *structHeader, uint8_t field, const bool mask)␊ |
230 | {␊ |
231 | ␉char *str = NULL;␊ |
232 | ␉str = getSMBStringForField(structHeader, field);␊ |
233 | ␉if (!field) {␊ |
234 | ␉␉str = NotSpecifiedStr;␊ |
235 | ␉}␊ |
236 | else if (mask) {␊ |
237 | ␉␉str = PrivateStr;␊ |
238 | ␉}␊ |
239 | ␊ |
240 | return str;␊ |
241 | };␊ |
242 | ␊ |
243 | void printHeader(SMBStructHeader *structHeader)␊ |
244 | {␊ |
245 | DBG("Type: %d, Length: %d, Handle: 0x%04x\n", structHeader->type, structHeader->length, structHeader->handle);␊ |
246 | }␊ |
247 | ␊ |
248 | //-------------------------------------------------------------------------------------------------------------------------␊ |
249 | // BIOS Information (Type 0)␊ |
250 | //-------------------------------------------------------------------------------------------------------------------------␊ |
251 | void decodeBIOSInformation(SMBStructHeader *structHeader)␊ |
252 | {␊ |
253 | printHeader(structHeader);␊ |
254 | ␉DBG("BIOS Information:\n");␊ |
255 | ␉DBG("\tVendor: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->vendor, neverMask));␊ |
256 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->version, neverMask));␊ |
257 | DBG("\tRelease Date: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->releaseDate, neverMask));␊ |
258 | // Address:␊ |
259 | // Runtime Size:␊ |
260 | // ROM Size:␊ |
261 | // DBG("\tCharacteristics: (0x%llX) %s\n", ((SMBBIOSInformation *)structHeader)->characteristics, SMBBIOSInfoChar0[((SMBBIOSInformation *)structHeader)->characteristics]);␊ |
262 | ␉DBG("\tBIOS Revision: %d.%d\n", ((SMBBIOSInformation *)structHeader)->releaseMajor, ((SMBBIOSInformation *)structHeader)->releaseMinor);␊ |
263 | ␉DBG("\n");␊ |
264 | }␊ |
265 | ␊ |
266 | //-------------------------------------------------------------------------------------------------------------------------␊ |
267 | // System Information (Type 1)␊ |
268 | //-------------------------------------------------------------------------------------------------------------------------␊ |
269 | void decodeSystemInformation(SMBStructHeader *structHeader)␊ |
270 | {␊ |
271 | printHeader(structHeader);␊ |
272 | ␉DBG("System Information:\n");␊ |
273 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->manufacturer, neverMask));␊ |
274 | ␉DBG("\tProduct Name: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->productName, neverMask));␊ |
275 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->version, neverMask));␊ |
276 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->serialNumber, privateData));␊ |
277 | ␉uint8_t *uuid = ((SMBSystemInformation *)structHeader)->uuid;␊ |
278 | ␉if (privateData) {␊ |
279 | ␉␉DBG("\tUUID: %s\n", PrivateStr);␊ |
280 | ␉} else {␊ |
281 | ␉␉DBG("\tUUID: %02X%02X%02X%02X-%02X%02X-%02X%02X-%02x%02X-%02X%02X%02X%02X%02X%02X\n",␊ |
282 | ␉␉␉uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],␊ |
283 | ␉␉␉uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);␊ |
284 | ␉ }␊ |
285 | ␉if (((SMBSystemInformation *)structHeader)->wakeupReason > 8) {␊ |
286 | ␉␉DBG("\tWake-up Type: %s\n", OutOfSpecStr);␊ |
287 | ␉} else {␊ |
288 | ␉␉DBG("\tWake-up Type: %s\n", SMBWakeUpTypes[((SMBSystemInformation *)structHeader)->wakeupReason]);␊ |
289 | ␉ }␊ |
290 | ␉DBG("\tSKU Number: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->skuNumber, neverMask)); // System SKU#␊ |
291 | ␉DBG("\tFamily: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->family, neverMask));␊ |
292 | ␉DBG("\n");␊ |
293 | }␊ |
294 | ␊ |
295 | //-------------------------------------------------------------------------------------------------------------------------␊ |
296 | // Base Board (or Module) Information (Type 2)␊ |
297 | //-------------------------------------------------------------------------------------------------------------------------␊ |
298 | void decodeBaseBoard(SMBStructHeader *structHeader)␊ |
299 | {␊ |
300 | printHeader(structHeader);␊ |
301 | ␉DBG("Base Board Information:\n");␊ |
302 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->manufacturer, neverMask));␊ |
303 | ␉DBG("\tProduct Name: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->product, neverMask));␊ |
304 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->version, neverMask));␊ |
305 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->serialNumber, privateData));␊ |
306 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->assetTag, neverMask));␊ |
307 | ␉// Features:␊ |
308 | ␉DBG("\tLocation In Chassis: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->locationInChassis, neverMask)); // Part Component␊ |
309 | ␉// Chassis Handle:␊ |
310 | ␉if ((((SMBBaseBoard *)structHeader)->boardType < kSMBBaseBoardUnknown) || (((SMBBaseBoard *)structHeader)->boardType > kSMBBaseBoardInterconnect)) {␊ |
311 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
312 | ␉} else {␊ |
313 | ␉␉DBG("\tType: %s\n", SMBBaseBoardTypes[(((SMBBaseBoard *)structHeader)->boardType - 1)]);␊ |
314 | ␉ }␊ |
315 | //DBG("\tContained Object Handles: %d\n", ((SMBBaseBoard *)structHeader)->numberOfContainedHandles;␊ |
316 | ␉DBG("\n");␊ |
317 | }␊ |
318 | ␊ |
319 | //-------------------------------------------------------------------------------------------------------------------------␊ |
320 | // System Enclosure or Chassis (Type 3)␊ |
321 | //-------------------------------------------------------------------------------------------------------------------------␊ |
322 | void decodeSystemEnclosure(SMBStructHeader *structHeader)␊ |
323 | {␊ |
324 | printHeader(structHeader);␊ |
325 | ␉DBG("Chassis Information:\n");␊ |
326 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->manufacturer, neverMask));␊ |
327 | ␉if ((((SMBSystemEnclosure *)structHeader)->chassisType < kSMBchassisOther) || (((SMBSystemEnclosure *)structHeader)->chassisType > kSMBchassisBladeEnclosing)) {␊ |
328 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
329 | ␉} else {␊ |
330 | ␉␉DBG("\tType: %s\n", SMBChassisTypes[(((SMBSystemEnclosure *)structHeader)->chassisType - 1)]);␊ |
331 | ␉ }␊ |
332 | // Lock:␊ |
333 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->version, neverMask));␊ |
334 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->serialNumber, privateData));␊ |
335 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->assetTag, neverMask));␊ |
336 | ␉// Boot-up State:␊ |
337 | ␉// Power Supply State␊ |
338 | ␉// Thermal State␊ |
339 | ␉// Security Status:␊ |
340 | ␉// OEM Information:␊ |
341 | ␉// Height;␊ |
342 | ␉// Cords;␊ |
343 | ␉// ElementsCount;␊ |
344 | ␉// ElementLen;␊ |
345 | ␉// Elements[1]; // open array of ElementsCount*ElementLen BYTEs␊ |
346 | ␉DBG("\n");␊ |
347 | }␊ |
348 | ␊ |
349 | //-------------------------------------------------------------------------------------------------------------------------␊ |
350 | // Processor Information (Type 4)␊ |
351 | //-------------------------------------------------------------------------------------------------------------------------␊ |
352 | void decodeProcessorInformation(SMBStructHeader *structHeader)␊ |
353 | {␊ |
354 | printHeader(structHeader);␊ |
355 | ␉DBG("Processor Information:\n");␊ |
356 | ␉DBG("\tSocket Designation: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->socketDesignation, neverMask));␊ |
357 | if ((((SMBProcessorInformation *)structHeader)->processorType < kSMBprocessorTypeOther) || (((SMBProcessorInformation *)structHeader)->processorType > kSMBprocessorTypeGPU)) {␊ |
358 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
359 | ␉} else {␊ |
360 | ␉␉DBG("\tType: %s\n", SMBProcessorTypes[((SMBProcessorInformation *)structHeader)->processorType - 1]);␊ |
361 | ␉ }␊ |
362 | ␉DBG("\tFamily: 0x%X\n", ((SMBProcessorInformation *)structHeader)->processorFamily);␊ |
363 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->manufacturer, neverMask));␊ |
364 | ␉DBG("\tID: 0x%llX\n", ((SMBProcessorInformation *)structHeader)->processorID);␊ |
365 | //␉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);␊ |
366 | // Flags:␊ |
367 | ␉DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->processorVersion, neverMask));␊ |
368 | //␉DBG("\tVoltage: 0.%xV\n", ((SMBProcessorInformation *)structHeader)->voltage);␊ |
369 | ␉DBG("\tExternal Clock: %dMHz\n", ((SMBProcessorInformation *)structHeader)->externalClock);␊ |
370 | ␉DBG("\tMax Speed: %dMHz\n", ((SMBProcessorInformation *)structHeader)->maximumClock);␊ |
371 | ␉DBG("\tCurrent Speed: %dMHz\n", ((SMBProcessorInformation *)structHeader)->currentClock);␊ |
372 | // Status: Populated/Unpopulated␊ |
373 | if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C)) {␊ |
374 | ␉␉DBG("\tUpgrade: %s\n", OutOfSpecStr);␊ |
375 | ␉} else {␊ |
376 | ␉␉DBG("\tUpgrade: %s\n", SMBProcessorUpgrades[((SMBProcessorInformation *)structHeader)->processorUpgrade - 1]);␊ |
377 | ␉ }␊ |
378 | // L1 Cache Handle:␊ |
379 | // L2 Cache Handle:␊ |
380 | // L3 Cache Handle:␊ |
381 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->serialNumber, privateData));␊ |
382 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->assetTag, neverMask));␊ |
383 | ␉DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->partNumber, neverMask));␊ |
384 | /*␊ |
385 | if(((SMBProcessorInformation *)structHeader)->coreCount != 0) {␊ |
386 | DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);␊ |
387 | }␊ |
388 | if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0) {␊ |
389 | DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);␊ |
390 | }␊ |
391 | if(((SMBProcessorInformation *)structHeader)->threadCount != 0) {␊ |
392 | DBG("\tThread Count: %d\n", ((SMBProcessorInformation *)structHeader)->threadCount);␊ |
393 | }␊ |
394 | */␊ |
395 | // Characteristics:␊ |
396 | //␉DBG("\tProcessor Family 2: %d\n", ((SMBProcessorInformation *)structHeader)->processorFamily2);␊ |
397 | ␉DBG("\n");␊ |
398 | }␊ |
399 | ␊ |
400 | //-------------------------------------------------------------------------------------------------------------------------␊ |
401 | // OEM Strings (Type 11)␊ |
402 | //-------------------------------------------------------------------------------------------------------------------------␊ |
403 | void decodeSMBOEMStrings(SMBStructHeader *structHeader)␊ |
404 | {␊ |
405 | char *stringPtr = (char *)structHeader + structHeader->length;␊ |
406 | printHeader(structHeader);␊ |
407 | ␉DBG("OEM Strings:\n");␊ |
408 | SMBByte i;␊ |
409 | for (i = 1; i <= ((SMBOEMStrings *)structHeader)->count; i++) {␊ |
410 | DBG("\tString %d: %s\n", i, stringPtr);␊ |
411 | stringPtr = stringPtr + strlen(stringPtr) + 1;␊ |
412 | }␊ |
413 | ␉DBG("\n");␊ |
414 | }␊ |
415 | ␊ |
416 | //-------------------------------------------------------------------------------------------------------------------------␊ |
417 | // Memory Device (Type 17)␊ |
418 | //-------------------------------------------------------------------------------------------------------------------------␊ |
419 | void decodeMemoryDevice(SMBStructHeader *structHeader)␊ |
420 | {␊ |
421 | printHeader(structHeader);␊ |
422 | ␉DBG("Memory Device:\n");␊ |
423 | // Aray Handle␊ |
424 | if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF) {␊ |
425 | DBG("\tError Information Handle: No Error\n");␊ |
426 | } else {␊ |
427 | DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle);␊ |
428 | }␊ |
429 | // Total Width:␊ |
430 | // Data Width:␊ |
431 | switch (((SMBMemoryDevice *)structHeader)->memorySize) {␊ |
432 | case 0:␊ |
433 | DBG("\tSize: No Module Installed\n");␊ |
434 | break;␊ |
435 | case 0x7FFF:␊ |
436 | DBG("\tSize: 32GB or more\n");␊ |
437 | break;␊ |
438 | case 0xFFFF:␊ |
439 | DBG("\tSize: Unknown\n");␊ |
440 | break;␊ |
441 | default:␊ |
442 | DBG("\tSize: %d %s\n", ((SMBMemoryDevice *)structHeader)->memorySize & 0x7FFF, ((((SMBMemoryDevice *)structHeader)->memorySize & 0x8000) == 0x8000) ? "kB" : "MB");␊ |
443 | break;␊ |
444 | }␊ |
445 | if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F)) {␊ |
446 | ␉␉DBG("\tForm Factor: %s\n", OutOfSpecStr);␊ |
447 | ␉} else {␊ |
448 | DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]);␊ |
449 | }␊ |
450 | // Set:␊ |
451 | ␉DBG("\tLocator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->deviceLocator, neverMask));␊ |
452 | ␉DBG("\tBank Locator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->bankLocator, neverMask));␊ |
453 | if (((SMBMemoryDevice *)structHeader)->memoryType > kSMBMemoryDeviceTypeCount) {␊ |
454 | ␉␉DBG("\tType: %s\n", OutOfSpecStr);␊ |
455 | ␉} else {␊ |
456 | DBG("\tType: %s\n", SMBMemoryDeviceTypes[((SMBMemoryDevice *)structHeader)->memoryType]);␊ |
457 | }␊ |
458 | // Type Detail:␊ |
459 | ␉DBG("\tSpeed: %d MHz\n", ((SMBMemoryDevice *)structHeader)->memorySpeed);␊ |
460 | ␉DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->manufacturer, neverMask));␊ |
461 | ␉DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->serialNumber, privateData));␊ |
462 | ␉DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->assetTag, neverMask));␊ |
463 | ␉DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->partNumber, neverMask));␊ |
464 | // Rank:␊ |
465 | // Configured Clock Speed:␊ |
466 | ␉DBG("\n");␊ |
467 | }␊ |
468 | ␊ |
469 | //-------------------------------------------------------------------------------------------------------------------------␊ |
470 | // Apple Specific Processor Type (Type 131)␊ |
471 | //-------------------------------------------------------------------------------------------------------------------------␊ |
472 | void decodeOemProcessorType(SMBStructHeader *structHeader)␊ |
473 | {␊ |
474 | printHeader(structHeader);␊ |
475 | DBG("Apple specific Processor Type:\n");␊ |
476 | ␉DBG("\tcpu=0x%x\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);␊ |
477 | ␉DBG("\n");␊ |
478 | }␊ |
479 | ␊ |
480 | //-------------------------------------------------------------------------------------------------------------------------␊ |
481 | // Apple Specific Processor Bus Speed (Type 132)␊ |
482 | //-------------------------------------------------------------------------------------------------------------------------␊ |
483 | void decodeOemProcessorBusSpeed(SMBStructHeader *structHeader)␊ |
484 | {␊ |
485 | printHeader(structHeader);␊ |
486 | DBG("Apple specific Processor Interconnect Speed:\n");␊ |
487 | DBG("\tqpi=%d MT/s\n", ((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed);␊ |
488 | ␉DBG("\n");␊ |
489 | }␊ |
490 | // 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␊ |
491 | ␊ |
492 | //-------------------------------------------------------------------------------------------------------------------------␊ |
493 | // Apple Specific Platform Feature (Type 133)␊ |
494 | //-------------------------------------------------------------------------------------------------------------------------␊ |
495 | //void decodeOemPlatformFeature(SMBStructHeader *structHeader)␊ |
496 | //{␊ |
497 | //␉printHeader(structHeader);␊ |
498 | //␉DBG("Apple specific Platform Feature\n");␊ |
499 | //␉DBG("\t%s\n", ((SMBOemPlatformFeature *)structHeader)->PlatformFeature);␊ |
500 | //␉DBG("\n");␊ |
501 | //}␊ |
502 | ␊ |
503 | //-------------------------------------------------------------------------------------------------------------------------␊ |
504 | // Specific (Type 134)␊ |
505 | //-------------------------------------------------------------------------------------------------------------------------␊ |
506 | //void decodeOem(SMBStructHeader *structHeader)␊ |
507 | //{␊ |
508 | //␉printHeader(structHeader);␊ |
509 | //␉DBG("Apple specific Feature\n");␊ |
510 | //␉DBG("\t%s\n", ((SMBOemPlatformFeature *)structHeader)->Feature);␊ |
511 | //␉DBG("\n");␊ |
512 | //}␊ |
513 | ␊ |
514 | //-------------------------------------------------------------------------------------------------------------------------␊ |
515 | ␊ |
516 | void decodeSMBIOSTable(SMBEntryPoint *eps)␊ |
517 | {␊ |
518 | ␉uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;␊ |
519 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)ptr;␊ |
520 | ␊ |
521 | ␉minorVersion = eps->minorVersion;␊ |
522 | ␉majorVersion = eps->majorVersion;␊ |
523 | ␉bcdRevisionHi = eps->dmi.bcdRevision >> 4;␊ |
524 | ␉bcdRevisionLo = eps->dmi.bcdRevision & 0x0F;␊ |
525 | ␊ |
526 | ␉getBoolForKey(kPrivateData, &privateData, &bootInfo->chameleonConfig); // Bungo: chek if mask some data␊ |
527 | ␊ |
528 | DBG("\n");␊ |
529 | ␉DBG("SMBIOS rev.: %d.%d, DMI rev.: %d.%d\n", majorVersion, minorVersion, bcdRevisionHi, bcdRevisionLo);␊ |
530 | DBG("\n");␊ |
531 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)␊ |
532 | ␉{␊ |
533 | ␉␉switch (structHeader->type)␊ |
534 | ␉␉{␊ |
535 | ␉␉␉case kSMBTypeBIOSInformation: // Type 0␊ |
536 | ␉␉␉␉decodeBIOSInformation(structHeader);␊ |
537 | ␉␉␉␉break;␊ |
538 | ␊ |
539 | ␉␉␉case kSMBTypeSystemInformation: // Type 1␊ |
540 | ␉␉␉␉decodeSystemInformation(structHeader);␊ |
541 | ␉␉␉␉break;␊ |
542 | ␊ |
543 | ␉␉␉case kSMBTypeBaseBoard: // Type 2␊ |
544 | ␉␉␉␉decodeBaseBoard(structHeader);␊ |
545 | ␉␉␉␉break;␊ |
546 | ␊ |
547 | ␉␉␉case kSMBTypeSystemEnclosure: // Type 3␊ |
548 | ␉␉␉␉decodeSystemEnclosure(structHeader);␊ |
549 | ␉␉␉␉break;␊ |
550 | ␊ |
551 | ␉␉␉case kSMBTypeProcessorInformation: // Type 4␊ |
552 | ␉␉␉␉decodeProcessorInformation(structHeader);␊ |
553 | ␉␉␉␉break;␊ |
554 | ␊ |
555 | ␉␉␉//case 6: // kSMBTypeMemoryModule: // Type 6␊ |
556 | ␉␉␉//␉decodeMemoryModule(structHeader);␊ |
557 | ␉␉␉//␉break;␊ |
558 | ␊ |
559 | //case kSMBTypeSystemSlot: // Type 9␊ |
560 | //␉decodeSMBTypeSystemSlot(structHeader);␊ |
561 | //␉break;␊ |
562 | ␊ |
563 | ␉␉␉case kSMBOEMStrings: // Type 11␊ |
564 | ␉␉␉␉decodeSMBOEMStrings(structHeader);␊ |
565 | ␉␉␉␉break;␊ |
566 | ␊ |
567 | ␉␉␉case kSMBTypeMemoryDevice: // Type 17␊ |
568 | ␉␉␉␉decodeMemoryDevice(structHeader);␊ |
569 | ␉␉␉␉break;␊ |
570 | ␊ |
571 | ␉␉␉// kSMBTypeMemoryArrayMappedAddress: // Type 19␊ |
572 | ␊ |
573 | ␉␉␉/* Skip all Apple Specific Structures */␊ |
574 | ␉␉␉// case kSMBTypeFirmwareVolume: // Type 128␊ |
575 | ␉␉␉// case kSMBTypeMemorySPD: // Type 130␊ |
576 | ␉␉␉// ␉break;␊ |
577 | ␊ |
578 | ␉␉␉case kSMBTypeOemProcessorType: // Type 131␊ |
579 | ␉␉␉␉decodeOemProcessorType(structHeader);␊ |
580 | ␉␉␉␉break;␊ |
581 | ␊ |
582 | ␉␉␉case kSMBTypeOemProcessorBusSpeed: // Type 132␊ |
583 | ␉␉␉␉decodeOemProcessorBusSpeed(structHeader);␊ |
584 | ␉␉␉␉break;␊ |
585 | ␊ |
586 | ␉␉␉//case kSMBTypeOemPlatformFeature: // Type 133␊ |
587 | //␉decodeOemPlatformFeature(structHeader);␊ |
588 | //␉break;␊ |
589 | ␊ |
590 | ␉␉␉case kSMBTypeEndOfTable: // Type 127␊ |
591 | DBG("Type: %d, Length: %d, Handle: 0x%04x\n", structHeader->type, structHeader->length, structHeader->handle);␊ |
592 | DBG("End of Table\n");␊ |
593 | ␉␉␉␉break;␊ |
594 | ␊ |
595 | ␉␉␉default:␊ |
596 | ␉␉␉␉break;␊ |
597 | ␉␉}␊ |
598 | ␊ |
599 | ␉␉ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
600 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
601 | ␊ |
602 | ␉␉if (((uint16_t *)ptr)[0] == 0) {␊ |
603 | ␉␉␉ptr += 2;␊ |
604 | ␉␉}␊ |
605 | ␊ |
606 | ␉␉structHeader = (SMBStructHeader *)ptr;␊ |
607 | ␉}␊ |
608 | ␉DBG("\n");␊ |
609 | }␊ |
610 | ␊ |
611 | |