Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Enoch/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 < kSMBChassisTypeOther) || (((SMBSystemEnclosure *)structHeader)->chassisType > kSMBChassisTypeBladeEnclosing)) {
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));
403
404//
405// TODO: Check the size before printing this information.
406// Keep in mind that Apple does not use this info, and only uses a 35 bytes struct
407//
408//if(((SMBProcessorInformation *)structHeader)->coreCount != 0)
409//{
410//DBG("\tCore Count: %d\n", ((SMBProcessorInformation *)structHeader)->coreCount);
411//}
412//
413//if(((SMBProcessorInformation *)structHeader)->coreEnabled != 0)
414//{
415//DBG("\tCore Enabled: %d\n", ((SMBProcessorInformation *)structHeader)->coreEnabled);
416//}
417//
418//if(((SMBProcessorInformation *)structHeader)->threadCount != 0)
419//{
420//DBG("\tThread Count: %d\n", ((SMBProcessorInformation *)structHeader)->threadCount);
421//}
422// Characteristics:
423//DBG("\tProcessor Family 2: %d\n", ((SMBProcessorInformation *)structHeader)->processorFamily2);
424DBG("\n");
425}
426
427//-------------------------------------------------------------------------------------------------------------------------
428// Memory Controller Information (Type 5)
429//-------------------------------------------------------------------------------------------------------------------------
430
431//-------------------------------------------------------------------------------------------------------------------------
432// Memory Module Information (Type 6)
433//-------------------------------------------------------------------------------------------------------------------------
434//void decodeMemoryModule(SMBStructHeader *structHeader)
435//{
436//DBG("Memory Module Information\n");
437//DBG("\tSocket Designation: %s\n", getSMBStringForField((SMBStructHeader *)structHeader, structHeader->socketDesignation));
438//DBG("\tBank Connections: Type: %d\n", structHeader->bankConnections);
439//DBG("\tCurrent Speed: %X\n", structHeader->currentSpeed);
440//DBG("\tType: %llX\n", structHeader->currentMemoryType);
441//DBG("\tInstalled Size: %d\n", structHeader->installedSize);
442//DBG("\tEnabled Size: %d\n", structHeader->enabledSize);
443//DBG("\tError Status: %x\n", structHeader->errorStatus);
444//DBG("\n");
445//}
446
447//-------------------------------------------------------------------------------------------------------------------------
448// Cache Information (Type 7)
449//-------------------------------------------------------------------------------------------------------------------------
450
451//-------------------------------------------------------------------------------------------------------------------------
452// Port Connector Information (Type 8)
453//-------------------------------------------------------------------------------------------------------------------------
454
455//-------------------------------------------------------------------------------------------------------------------------
456// System Slot Information (Type 9)
457//-------------------------------------------------------------------------------------------------------------------------
458
459//-------------------------------------------------------------------------------------------------------------------------
460// On Board Device Information (Type 10)
461//-------------------------------------------------------------------------------------------------------------------------
462
463//-------------------------------------------------------------------------------------------------------------------------
464// OEM Strings (Type 11)
465//-------------------------------------------------------------------------------------------------------------------------
466void decodeSMBOEMStrings(SMBStructHeader *structHeader)
467{
468char *stringPtr = (char *)structHeader + structHeader->length;
469printHeader(structHeader);
470DBG("OEM Strings\n");
471SMBByte i;
472for (i = 1; i <= ((SMBOEMStrings *)structHeader)->count; i++) {
473DBG("\tString %d: %s\n", i, stringPtr);
474stringPtr = stringPtr + strlen(stringPtr) + 1;
475}
476DBG("\n");
477}
478//-------------------------------------------------------------------------------------------------------------------------
479// System Configuration Options (Type 12)
480//-------------------------------------------------------------------------------------------------------------------------
481
482//-------------------------------------------------------------------------------------------------------------------------
483// BIOS Language Information (Type 13)
484//-------------------------------------------------------------------------------------------------------------------------
485
486//-------------------------------------------------------------------------------------------------------------------------
487// Physical Memory Array (Type 16)
488//-------------------------------------------------------------------------------------------------------------------------
489
490//-------------------------------------------------------------------------------------------------------------------------
491// MemoryDevice (Type 17)
492//-------------------------------------------------------------------------------------------------------------------------
493void decodeMemoryDevice(SMBStructHeader *structHeader)
494{
495printHeader(structHeader);
496DBG("Memory Device\n");
497// Aray Handle
498if (((SMBMemoryDevice *)structHeader)->errorHandle == 0xFFFF)
499{
500DBG("\tError Information Handle: No Error\n");
501}
502else
503{
504DBG("\tError Information Handle: 0x%x\n", ((SMBMemoryDevice *)structHeader)->errorHandle);
505}
506// Total Width:
507// Data Width:
508switch (((SMBMemoryDevice *)structHeader)->memorySize)
509{
510case 0:
511DBG("\tSize: No Module Installed\n");
512break;
513case 0x7FFF:
514DBG("\tSize: 32GB or more\n");
515break;
516case 0xFFFF:
517DBG("\tSize: Unknown\n");
518break;
519default:
520DBG("\tSize: %d %s\n", ((SMBMemoryDevice *)structHeader)->memorySize & 0x7FFF, ((((SMBMemoryDevice *)structHeader)->memorySize & 0x8000) == 0x8000) ? "kB" : "MB");
521break;
522}
523if ((((SMBMemoryDevice *)structHeader)->formFactor < 0x01) || (((SMBMemoryDevice *)structHeader)->formFactor > 0x0F))
524{
525 DBG("\tForm Factor: %s\n", OutOfSpecStr);
526 }
527else
528{
529DBG("\tForm Factor: %s\n", SMBMemoryDeviceFormFactors[((SMBMemoryDevice *)structHeader)->formFactor - 1]);
530}
531// Set:
532DBG("\tLocator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->deviceLocator, neverMask));
533DBG("\tBank Locator: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->bankLocator, neverMask));
534if (((SMBMemoryDevice *)structHeader)->memoryType > kSMBMemoryDeviceTypeCount)
535{
536DBG("\tMemory Type: %s\n", OutOfSpecStr);
537}
538else
539{
540DBG("\tMemory Type: %s\n", SMBMemoryDeviceTypes[((SMBMemoryDevice *)structHeader)->memoryType]);
541}
542// Type Detail:
543DBG("\tSpeed: %d MHz\n", ((SMBMemoryDevice *)structHeader)->memorySpeed);
544DBG("\tManufacturer: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->manufacturer, neverMask));
545DBG("\tSerial Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->serialNumber, privateData));
546DBG("\tAsset Tag: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->assetTag, neverMask));
547DBG("\tPart Number: %s\n", SMBStringForField(structHeader, ((SMBMemoryDevice *)structHeader)->partNumber, neverMask));
548// Rank:
549// Configured Clock Speed:
550// Minimum Voltage:
551// Maximum Voltage:
552// Configured Voltage:
553DBG("\n");
554}
555
556//-------------------------------------------------------------------------------------------------------------------------
557// Apple Specific (Type 131)
558//-------------------------------------------------------------------------------------------------------------------------
559void decodeOemProcessorType(SMBStructHeader *structHeader)
560{
561printHeader(structHeader);
562DBG("Apple specific Processor Type\n");
563DBG("\tCpu-type = 0x%04X\n", ((SMBOemProcessorType *)structHeader)->ProcessorType);
564DBG("\n");
565}
566
567//-------------------------------------------------------------------------------------------------------------------------
568// Apple Specific (Type 132)
569//-------------------------------------------------------------------------------------------------------------------------
570void decodeOemProcessorBusSpeed(SMBStructHeader *structHeader)
571{
572printHeader(structHeader);
573DBG("Apple specific Processor Interconnect Speed\n");
574DBG("\tQPI = %d MT/s\n", ((SMBOemProcessorBusSpeed *)structHeader)->ProcessorBusSpeed);
575DBG("\n");
576}
577
578// 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
579//-------------------------------------------------------------------------------------------------------------------------
580// Apple Specific (Type 133)
581//-------------------------------------------------------------------------------------------------------------------------
582void decodeOemPlatformFeature(SMBStructHeader *structHeader)
583{
584printHeader(structHeader);
585DBG("Apple specific Platform Feature\n");
586DBG("\t%s\n", ((SMBOemPlatformFeature *)structHeader)->PlatformFeature);
587DBG("\n");
588}
589
590//-------------------------------------------------------------------------------------------------------------------------
591// Specific (Type 134)
592//-------------------------------------------------------------------------------------------------------------------------
593//void decodeOem(SMBStructHeader *structHeader)
594//{
595//printHeader(structHeader);
596//DBG("Apple specific Feature\n");
597//DBG("\t%s\n", ((SMBOemPlatformFeature *)structHeader)->Feature);
598//DBG("\n");
599//}
600
601//-------------------------------------------------------------------------------------------------------------------------
602
603
604void decodeSMBIOSTable(SMBEntryPoint *eps)
605{
606uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;
607SMBStructHeader *structHeader = (SMBStructHeader *)ptr;
608
609minorVersion = eps->minorVersion;
610majorVersion = eps->majorVersion;
611bcdRevisionHi = eps->dmi.bcdRevision >> 4;
612bcdRevisionLo = eps->dmi.bcdRevision & 0x0F;
613
614getBoolForKey(kPrivateData, &privateData, &bootInfo->chameleonConfig); // Bungo: chek if mask some data
615
616DBG("\n");
617DBG("SMBIOS rev.: %d.%d, DMI rev.: %d.%d\n", majorVersion, minorVersion, bcdRevisionHi, bcdRevisionLo);
618DBG("\n");
619for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)
620{
621switch (structHeader->type)
622{
623case kSMBTypeBIOSInformation: // Type 0
624decodeBIOSInformation(structHeader);
625break;
626
627case kSMBTypeSystemInformation: // Type 1
628decodeSystemInformation(structHeader);
629break;
630
631case kSMBTypeBaseBoard: // Type 2
632decodeBaseBoard(structHeader);
633break;
634
635case kSMBTypeSystemEnclosure: // Type 3
636decodeSystemEnclosure(structHeader);
637break;
638
639case kSMBTypeProcessorInformation: // Type 4
640decodeProcessorInformation(structHeader);
641break;
642
643//case kSMBTypeMemoryModule: // Type 6
644//decodeMemoryModule(structHeader);
645//break;
646
647//case kSMBTypeSystemSlot: // Type 9
648//decodeSMBTypeSystemSlot(structHeader);
649//break;
650
651case kSMBOEMStrings: // Type 11
652decodeSMBOEMStrings(structHeader);
653break;
654
655case kSMBTypeMemoryDevice: // Type 17
656decodeMemoryDevice(structHeader);
657break;
658
659//kSMBTypeMemoryArrayMappedAddress: // Type 19
660//break;
661
662/* Skip all Apple Specific Structures */
663case kSMBTypeFirmwareVolume: // Type 128
664// case kSMBTypeMemorySPD: // Type 130
665break;
666
667case kSMBTypeOemProcessorType: // Type 131
668decodeOemProcessorType(structHeader);
669break;
670
671case kSMBTypeOemProcessorBusSpeed: // Type 132
672decodeOemProcessorBusSpeed(structHeader);
673break;
674
675//case kSMBTypeOemPlatformFeature: // Type 133
676//decodeOemPlatformFeature(structHeader);
677//break;
678
679case kSMBTypeEndOfTable: // Type 127
680DBG("Handle 0x%04x, DMI type %d, %d bytes\n", structHeader->handle, structHeader->type, structHeader->length);
681DBG("End of Table\n");
682break;
683
684default:
685break;
686}
687
688ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);
689for (; ((uint16_t *)ptr)[0] != 0; ptr++);
690
691if (((uint16_t *)ptr)[0] == 0)
692{
693ptr += 2;
694}
695
696structHeader = (SMBStructHeader *)ptr;
697}
698DBG("\n");
699}
700
701

Archive Download this file

Revision: 2904