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

Archive Download this file

Revision: 2849