Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 2839