Chameleon

Chameleon Svn Source Tree

Root/branches/zenith432/i386/libsaio/smbios_decode.c

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
21extern 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
28static bool privateData = true;
29static SMBByte minorVersion; // SMBIOS rev. minor
30static SMBByte majorVersion; // SMBIOS rev. major
31static SMBByte bcdRevisionLo; // DMI rev. minor
32static SMBByte bcdRevisionHi; // DMI rev. major
33
34/*====
35 7.2.2
36 ===*/
37static 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 ===*/
53static 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 ===*/
73static 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 ===*/
112static 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 ===*/
125static 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
177static 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 ====*/
199static 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
234static 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
237char *SMBStringForField(SMBStructHeader *structHeader, uint8_t field, const bool mask)
238{
239char *str = NULL;
240str = getSMBStringForField(structHeader, field);
241if (!field)
242{
243str = NotSpecifiedStr;
244}
245else if (mask)
246{
247str = PrivateStr;
248}
249
250return str;
251}
252
253void printHeader(SMBStructHeader *structHeader)
254{
255DBG("Handle: 0x%04X, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);
256}
257
258//-------------------------------------------------------------------------------------------------------------------------
259// BIOS Information (Type 0)
260//-------------------------------------------------------------------------------------------------------------------------
261void decodeBIOSInformation(SMBStructHeader *structHeader)
262{
263printHeader(structHeader);
264DBG("BIOS Information\n");
265DBG("\tVendor: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->vendor, neverMask));
266DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBBIOSInformation *)structHeader)->version, neverMask));
267DBG("\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]);
272DBG("\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;
277DBG("\n");
278}
279
280//-------------------------------------------------------------------------------------------------------------------------
281// System Information (Type 1)
282//-------------------------------------------------------------------------------------------------------------------------
283void decodeSystemInformation(SMBStructHeader *structHeader)
284{
285printHeader(structHeader);
286DBG("System Information\n");
287DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->manufacturer, neverMask));
288DBG("\tProduct Name: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->productName, neverMask));
289DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->version, neverMask));
290DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->serialNumber, privateData));
291uint8_t *uuid = ((SMBSystemInformation *)structHeader)->uuid;
292if (privateData) {
293DBG("\tUUID: %s\n", PrivateStr);
294} else {
295DBG("\tUUID: %02X%02X%02X%02X-%02X%02X-%02X%02X-%02x%02X-%02X%02X%02X%02X%02X%02X\n",
296uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
297uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
298}
299if (((SMBSystemInformation *)structHeader)->wakeupReason > 8) {
300DBG("\tWake-up Type: %s\n", OutOfSpecStr);
301} else {
302DBG("\tWake-up Type: %s\n", SMBWakeUpTypes[((SMBSystemInformation *)structHeader)->wakeupReason]);
303}
304DBG("\tSKU Number: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->skuNumber, neverMask)); // System SKU#
305DBG("\tFamily: %s\n", SMBStringForField(structHeader, ((SMBSystemInformation *)structHeader)->family, neverMask));
306DBG("\n");
307}
308
309//-------------------------------------------------------------------------------------------------------------------------
310// Base Board (or Module) Information (Type 2)
311//-------------------------------------------------------------------------------------------------------------------------
312void decodeBaseBoard(SMBStructHeader *structHeader)
313{
314printHeader(structHeader);
315DBG("Base Board Information\n");
316DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->manufacturer, neverMask));
317DBG("\tProduct Name: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->product, neverMask));
318DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->version, neverMask));
319DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->serialNumber, privateData));
320DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->assetTag, neverMask));
321// Feature Flags (BYTE)
322DBG("\tLocation In Chassis: %s\n", SMBStringForField(structHeader, ((SMBBaseBoard *)structHeader)->locationInChassis, neverMask)); // Part Component
323// Chassis Handle (WORD)
324if ((((SMBBaseBoard *)structHeader)->boardType < kSMBBaseBoardUnknown) || (((SMBBaseBoard *)structHeader)->boardType > kSMBBaseBoardInterconnect)) {
325DBG("\tType: %s\n", OutOfSpecStr);
326} else {
327DBG("\tType: %s\n", SMBBaseBoardTypes[(((SMBBaseBoard *)structHeader)->boardType - 1)]);
328}
329// Number of Contained Object Handles (n) (BYTE)
330// Contained Object Handles n(WORDs)
331DBG("\n");
332}
333
334//-------------------------------------------------------------------------------------------------------------------------
335// System Enclosure or Chassis (Type 3)
336//-------------------------------------------------------------------------------------------------------------------------
337void decodeSystemEnclosure(SMBStructHeader *structHeader)
338{
339printHeader(structHeader);
340DBG("Chassis Information\n");
341DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->manufacturer, neverMask));
342if ((((SMBSystemEnclosure *)structHeader)->chassisType < kSMBchassisOther) || (((SMBSystemEnclosure *)structHeader)->chassisType > kSMBchassisBladeEnclosing)) {
343DBG("\tType: %s\n", OutOfSpecStr);
344} else {
345DBG("\tType: %s\n", SMBChassisTypes[(((SMBSystemEnclosure *)structHeader)->chassisType - 1)]);
346}
347// Lock:
348DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->version, neverMask));
349DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBSystemEnclosure *)structHeader)->serialNumber, privateData));
350DBG("\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
362DBG("\n");
363}
364
365//-------------------------------------------------------------------------------------------------------------------------
366// Processor Information (Type 4)
367//-------------------------------------------------------------------------------------------------------------------------
368void decodeProcessorInformation(SMBStructHeader *structHeader)
369{
370printHeader(structHeader);
371DBG("Processor Information\n");
372DBG("\tSocket Designation: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->socketDesignation, neverMask));
373if ((((SMBProcessorInformation *)structHeader)->processorType < kSMBprocessorTypeOther) || (((SMBProcessorInformation *)structHeader)->processorType > kSMBprocessorTypeGPU)) {
374DBG("\tType: %s\n", OutOfSpecStr);
375} else {
376DBG("\tType: %s\n", SMBProcessorTypes[((SMBProcessorInformation *)structHeader)->processorType - 1]);
377}
378DBG("\tFamily: 0x%X\n", ((SMBProcessorInformation *)structHeader)->processorFamily);
379DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->manufacturer, neverMask));
380DBG("\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:
383DBG("\tVersion: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->processorVersion, neverMask));
384//DBG("\tVoltage: 0.%dV\n", ((SMBProcessorInformation *)structHeader)->voltage);
385DBG("\tExternal Clock: %d MHz\n", ((SMBProcessorInformation *)structHeader)->externalClock);
386DBG("\tMax Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->maximumClock);
387DBG("\tCurrent Speed: %d MHz\n", ((SMBProcessorInformation *)structHeader)->currentClock);
388// Status: Populated/Unpopulated
389if ((((SMBProcessorInformation *)structHeader)->processorUpgrade < 1) || (((SMBProcessorInformation *)structHeader)->processorUpgrade > 0x2C))
390{
391DBG("\tUpgrade: %s\n", OutOfSpecStr);
392}
393else
394{
395DBG("\tUpgrade: %s\n", SMBProcessorUpgrades[((SMBProcessorInformation *)structHeader)->processorUpgrade - 1]);
396}
397// L1 Cache Handle:
398// L2 Cache Handle:
399// L3 Cache Handle:
400DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->serialNumber, privateData));
401DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->assetTag, neverMask));
402DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBProcessorInformation *)structHeader)->partNumber, neverMask));
403if(((SMBProcessorInformation *)structHeader)->coreCount != 0)
404{
405DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);
406}
407
408if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0)
409{
410DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);
411}
412
413if(((SMBProcessorInformation *)structHeader)->threadCount != 0)
414{
415DBG("\tThread Count: %d\n", ((SMBProcessorInformation *)structHeader)->threadCount);
416}
417// Characteristics:
418//DBG("\tProcessor Family 2: %d\n", ((SMBProcessorInformation *)structHeader)->processorFamily2);
419DBG("\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//-------------------------------------------------------------------------------------------------------------------------
461void decodeSMBOEMStrings(SMBStructHeader *structHeader)
462{
463char *stringPtr = (char *)structHeader + structHeader->length;
464printHeader(structHeader);
465DBG("OEM Strings\n");
466SMBByte i;
467for (i = 1; i <= ((SMBOEMStrings *)structHeader)->count; i++) {
468DBG("\tString %d: %s\n", i, stringPtr);
469stringPtr = stringPtr + strlen(stringPtr) + 1;
470}
471DBG("\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//-------------------------------------------------------------------------------------------------------------------------
488void decodeMemoryDevice(SMBStructHeader *structHeader)
489{
490printHeader(structHeader);
491DBG("Memory Device\n");
492// Aray Handle
493if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF)
494{
495DBG("\tError Information Handle: No Error\n");
496}
497else
498{
499DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle);
500}
501// Total Width:
502// Data Width:
503switch (((SMBMemoryDevice *)structHeader)->memorySize)
504{
505case 0:
506DBG("\tSize: No Module Installed\n");
507break;
508case 0x7FFF:
509DBG("\tSize: 32GB or more\n");
510break;
511case 0xFFFF:
512DBG("\tSize: Unknown\n");
513break;
514default:
515DBG("\tSize: %d %s\n", ((SMBMemoryDevice *)structHeader)->memorySize & 0x7FFF, ((((SMBMemoryDevice *)structHeader)->memorySize & 0x8000) == 0x8000) ? "kB" : "MB");
516break;
517}
518if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F))
519{
520 DBG("\tForm Factor: %s\n", OutOfSpecStr);
521 }
522else
523{
524DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]);
525}
526// Set:
527DBG("\tLocator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->deviceLocator, neverMask));
528DBG("\tBank Locator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->bankLocator, neverMask));
529if (((SMBMemoryDevice *)structHeader)->memoryType > kSMBMemoryDeviceTypeCount)
530{
531DBG("\tMemory Type: %s\n", OutOfSpecStr);
532}
533else
534{
535DBG("\tMemory Type: %s\n", SMBMemoryDeviceTypes[((SMBMemoryDevice *)structHeader)->memoryType]);
536}
537// Type Detail:
538DBG("\tSpeed: %d MHz\n", ((SMBMemoryDevice *)structHeader)->memorySpeed);
539DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->manufacturer, neverMask));
540DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->serialNumber, privateData));
541DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->assetTag, neverMask));
542DBG("\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:
548DBG("\n");
549}
550
551//-------------------------------------------------------------------------------------------------------------------------
552// Apple Specific (Type 131)
553//-------------------------------------------------------------------------------------------------------------------------
554void decodeOemProcessorType(SMBStructHeader *structHeader)
555{
556printHeader(structHeader);
557DBG("Apple specific Processor Type\n");
558DBG("\tCpu-type = 0x%04X\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);
559DBG("\n");
560}
561
562//-------------------------------------------------------------------------------------------------------------------------
563// Apple Specific (Type 132)
564//-------------------------------------------------------------------------------------------------------------------------
565void decodeOemProcessorBusSpeed(SMBStructHeader *structHeader)
566{
567printHeader(structHeader);
568DBG("Apple specific Processor Interconnect Speed\n");
569DBG("\tQPI = %d MT/s\n", ((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed);
570DBG("\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
599void decodeSMBIOSTable(SMBEntryPoint *eps)
600{
601uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;
602SMBStructHeader *structHeader = (SMBStructHeader *)ptr;
603
604minorVersion = eps->minorVersion;
605majorVersion = eps->majorVersion;
606bcdRevisionHi = eps->dmi.bcdRevision >> 4;
607bcdRevisionLo = eps->dmi.bcdRevision & 0x0F;
608
609getBoolForKey(kPrivateData, &privateData, &bootInfo->chameleonConfig); // Bungo: chek if mask some data
610
611DBG("\n");
612DBG("SMBIOS rev.: %d.%d, DMI rev.: %d.%d\n", majorVersion, minorVersion, bcdRevisionHi, bcdRevisionLo);
613DBG("\n");
614for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)
615{
616switch (structHeader->type)
617{
618case kSMBTypeBIOSInformation: // Type 0
619decodeBIOSInformation(structHeader);
620break;
621
622case kSMBTypeSystemInformation: // Type 1
623decodeSystemInformation(structHeader);
624break;
625
626case kSMBTypeBaseBoard: // Type 2
627decodeBaseBoard(structHeader);
628break;
629
630case kSMBTypeSystemEnclosure: // Type 3
631decodeSystemEnclosure(structHeader);
632break;
633
634case kSMBTypeProcessorInformation: // Type 4
635decodeProcessorInformation(structHeader);
636break;
637
638//case kSMBTypeMemoryModule: // Type 6
639//decodeMemoryModule(structHeader);
640//break;
641
642//case kSMBTypeSystemSlot: // Type 9
643//decodeSMBTypeSystemSlot(structHeader);
644//break;
645
646case kSMBOEMStrings: // Type 11
647decodeSMBOEMStrings(structHeader);
648break;
649
650case kSMBTypeMemoryDevice: // Type 17
651decodeMemoryDevice(structHeader);
652break;
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
662case kSMBTypeOemProcessorType: // Type 131
663decodeOemProcessorType(structHeader);
664break;
665
666case kSMBTypeOemProcessorBusSpeed: // Type 132
667decodeOemProcessorBusSpeed(structHeader);
668break;
669
670//case kSMBTypeOemPlatformFeature: // Type 133
671//decodeOemPlatformFeature(structHeader);
672//break;
673
674case kSMBTypeEndOfTable: // Type 127
675DBG("Handle 0x%04x, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);
676DBG("End of Table\n");
677break;
678
679default:
680break;
681}
682
683ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
684for (; ((uint16_t *)ptr)[0] != 0; ptr++);
685
686if (((uint16_t *)ptr)[0] == 0)
687{
688ptr += 2;
689}
690
691structHeader = (SMBStructHeader *)ptr;
692}
693DBG("\n");
694}
695
696

Archive Download this file

Revision: 2877