Chameleon

Chameleon Svn Source Tree

Root/branches/Bungo/i386/libsaio/smbios.h

1/*
2 * Copyright (c) 1998-2009 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef __LIBSAIO_SMBIOS_H
24#define __LIBSAIO_SMBIOS_H
25
26
27/* Based on System Management BIOS Reference Specification v2.5 */
28// http://dmtf.org/sites/default/files/standards/documents/DSP0134_2.8.0.pdf
29
30typedef uint8_t SMBString;
31typedef uint8_t SMBByte;
32typedef uint16_t SMBWord;
33typedef uint32_t SMBDWord;
34typedef uint64_t SMBQWord;
35
36
37typedef struct DMIEntryPoint
38{
39 SMBByte anchor[5];
40 SMBByte checksum;
41 SMBWord tableLength;
42 SMBDWord tableAddress;
43 SMBWord structureCount;
44 SMBByte bcdRevision;
45} __attribute__((packed)) DMIEntryPoint;
46
47typedef struct SMBEntryPoint
48{
49 SMBByte anchor[4];
50 SMBByte checksum;
51 SMBByte entryPointLength;
52 SMBByte majorVersion;
53 SMBByte minorVersion;
54 SMBWord maxStructureSize;
55 SMBByte entryPointRevision;
56 SMBByte formattedArea[5];
57 DMIEntryPoint dmi;
58} __attribute__((packed)) SMBEntryPoint;
59
60/* Header common to all SMBIOS structures */
61typedef struct SMBStructHeader
62{
63SMBBytetype;
64SMBBytelength;
65SMBWordhandle;
66//SMBByte*data;
67} __attribute__((packed)) SMBStructHeader;
68
69#define SMB_STRUCT_HEADER SMBStructHeader header;
70
71typedef struct SMBAnchor
72{
73const SMBStructHeader *header;
74const uint8_t *next;
75const uint8_t *end;
76} SMBAnchor;
77
78#define SMB_ANCHOR_IS_VALID(x)\
79((x) && ((x)->header) && ((x)->next) && ((x)->end))
80
81#define SMB_ANCHOR_RESET(x)\
82bzero(x, sizeof(typedef struct SMBAnchor));
83
84/*
85 =======================
86 SMBIOS structure types.
87 ======================= */
88enum
89{
90kSMBTypeBIOSInformation= 0, // BIOS information (Type 0)
91kSMBTypeSystemInformation= 1, // System Information (Type 1)
92kSMBTypeBaseBoard= 2, // BaseBoard Information (Type 2)
93kSMBTypeSystemEnclosure= 3, // System Chassis Information (Type 3)
94kSMBTypeProcessorInformation= 4, // Processor Information (Type 4)
95// Memory Controller Information (Type 5) Obsolete
96kSMBTypeMemoryModule= 6, // Memory Module Information (Type 6) Obsolete
97kSMBTypeCacheInformation= 7, // Cache Information (Type 7)
98// Port Connector Information (Type 8)
99kSMBTypeSystemSlot= 9, // System Slots (Type 9)
100// On Board Devices Information (Type 10) Obsolete
101kSMBOEMStrings= 11 ,// OEM Strings (Type 11)
102// System Configuration Options (Type 12)
103// BIOS Language Information (Type 13)
104// Group Associations (Type 14)
105// System Event Log (Type 15)
106kSMBTypePhysicalMemoryArray= 16, // Physical Memory Array (Type 16)
107kSMBTypeMemoryDevice= 17, // Memory Device (Type 17)
108kSMBType32BitMemoryErrorInfo= 18, // 32-Bit Memory Error Information (Type 18)
109// Memory Array Mapped Address (Type 19)
110// Memory Device Mapped Address (Type 20)
111// Built-in Pointing Device (Type 21)
112// Portable Battery (Type 22)
113// System Reset (Type 23)
114// Hardware Security (Type 24)
115// System Power Controls (Type 25)
116// Voltage Probe (Type 26)
117// Cooling Device (Type 27)
118// Temperature Probe (Type 28)
119// Electrical Current Probe (Type 29)
120// Out-of-Band Remote Access (Type 30)
121// Boot Integrity Service (BIS) Entry Point (Type 31)
122// System Boot Information (Type 32)
123kSMBType64BitMemoryErrorInfo= 33, // 64-Bit Memory Error Information (Type 33)
124// Managment Device (Type 34)
125// Managment Device Component (Type 35)
126// Management Device Threshold Data (Type 36)
127// Memory Channel (Type 37)
128// IPMI Device Information (Type 38)
129// System Power Supply (Type 39)
130// Additional Information (Type 40)
131// Onboard Devices Extended Information (Type 41)
132// Management Controlle Host Interface (Type 42)
133
134// Inactive (Type 126)
135kSMBTypeEndOfTable= 127, // End-of-Table (Type 127)
136
137// Apple Specific Structures
138kSMBTypeFirmwareVolume= 128, // FirmwareVolume (TYPE 128)
139kSMBTypeMemorySPD= 130, // MemorySPD (TYPE 130)
140kSMBTypeOemProcessorType= 131, // Processor Type (Type 131)
141kSMBTypeOemProcessorBusSpeed= 132 //Processor Bus Speed (Type 132)
142};
143
144/* =======================
145 BIOS Information (Type 0)
146 ========================= */
147typedef struct SMBBIOSInformation
148{
149 SMB_STRUCT_HEADER
150 SMBString vendor; // BIOS vendor name
151 SMBString version; // BIOS version
152 SMBWord startSegment; // BIOS segment start
153 SMBString releaseDate; // BIOS release date
154 SMBByte romSize; // BIOS ROM Size (n); 64K * (n+1) bytes
155 SMBQWord characteristics; // supported BIOS functions
156 // Bungo
157 SMBByte characteristicsExt1; // BIOS characteristics extension byte 1
158 SMBByte characteristicsExt2; // BIOS characteristics extension byte 2
159 SMBByte releaseMajor; // BIOS release (major)
160 SMBByte releaseMinor; // BIOS release (minor)
161 SMBByte ECreleaseMajor; // Embedded Controller firmware release (major)
162 SMBByte ECreleaseMinor; // Embedded Controller firmware release (minor)
163} __attribute__((packed)) SMBBIOSInformation;
164
165/* =========================
166 System Information (Type 1)
167 =========================== */
168typedef struct SMBSystemInformation
169{
170 // 2.0+ spec (8 bytes)
171 SMB_STRUCT_HEADER
172 SMBString manufacturer;
173 SMBString productName;
174 SMBString version;
175 SMBString serialNumber;
176 // 2.1+ spec (25 bytes)
177 SMBByte uuid[16]; // can be all 0 or all 1's
178 SMBByte wakeupReason; // reason for system wakeup
179 // 2.4+ spec (27 bytes)
180 SMBString skuNumber;
181 SMBString family;
182} __attribute__((packed)) SMBSystemInformation;
183
184/* =========================================
185 Base Board (or Module) Information (Type 2)
186 =========================================== */
187typedef struct SMBBaseBoard
188{
189SMB_STRUCT_HEADER // Type 2
190SMBStringmanufacturer;
191SMBStringproduct;
192SMBStringversion;
193SMBStringserialNumber;
194SMBStringassetTag;// Bungo: renamed from assetTagNumber folowing convention
195SMBByte featureFlags;// Collection of flag that identify features of this baseboard
196SMBStringlocationInChassis;
197SMBWord chassisHandle;
198SMBByte boardType;// Type of board
199SMBByte numberOfContainedHandles;
200//SMBWord containedObjectHandles[1];
201// 0 - 255 contained handles go here but we do not include
202// them in our structure. Be careful to use numberOfContainedHandles
203// times sizeof(SMBWord) when computing the actual record size,
204// if you need it.
205} __attribute__((packed)) SMBBaseBoard;
206
207/* ====================================
208 Values for boardType in Type 2 records
209 ====================================== */
210enum
211{
212 kSMBBaseBoardUnknown = 0x01,// Unknow
213 kSMBBaseBoardOther = 0x02,// Other
214 kSMBBaseBoardServerBlade = 0x03,// Server Blade
215 kSMBBaseBoardConnectivitySwitch = 0x04,// Connectivity Switch
216 kSMBBaseBoardSystemMgmtModule = 0x05,// System Management Module
217 kSMBBaseBoardProcessorModule = 0x06,// Processor Module
218 kSMBBaseBoardIOModule = 0x07,// I/O Module
219 kSMBBaseBoardMemoryModule = 0x08,// Memory Module
220 kSMBBaseBoardDaughter = 0x09,// Daughter Board
221 kSMBBaseBoardMotherboard = 0x0A,// Motherboard (includes processor, memory, and I/O)
222 kSMBBaseBoardProcessorMemoryModule = 0x0B,// Processor/Memory Module
223 kSMBBaseBoardProcessorIOModule = 0x0C,// Processor/IO Module
224 kSMBBaseBoardInterconnect = 0x0D// Interconnect board
225};
226
227/* =======================
228 System Enclosure (Type 3)
229 ========================= */
230typedef struct SMBSystemEnclosure
231{
232SMB_STRUCT_HEADER // Type 3
233SMBString manufacturer;
234SMBByte chassisType;// System Enclosure Indicator
235SMBString version;// Board Number?
236SMBString serialNumber;
237SMBString assetTag;// Bungo: renamed from assetTagNumber folowing convention
238SMBByte bootupState;// State of enclosure when when it was last booted
239SMBByte powerSupplyState;// State of enclosure's power supply when last booted
240SMBByte thermalState;// Thermal state of the enclosure when last booted
241SMBByte securityStatus;// Physical security status of the enclosure when last booted
242SMBDWord oemDefined;// OEM- or BIOS vendor-specific information
243 SMBByte height;// Height of the enclosure, in 'U's
244 SMBByte numberOfPowerCords;// Number of power cords associated with the enclosure or chassis
245 SMBByte containedElementCount;// Number of Contained Element record that follow, in the range 0 to 255
246// SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
247// SMBByte containedElements;// Elements, possibly defined by other SMBIOS structures present in chassis
248// SMBString skuNumber;// Number of null-terminated string describing the chassis or enclosure SKU number (2.7+)
249} __attribute__((packed)) SMBSystemEnclosure;
250
251// Bungo: values for SMBSystemEnclosure.chassisType
252enum {
253 kSMBchassisOther = 0x01,
254 kSMBchassisUnknown = 0x02,
255 kSMBchassisDesktop = 0x03,
256 kSMBchassisLPDesktop = 0x04,
257 kSMBchassisPizzaBox = 0x05,
258 kSMBchassisMiniTower = 0x06,
259 kSMBchassisTower = 0x07,
260 kSMBchassisPortable = 0x08,
261 kSMBchassisLaptop = 0x09,
262 kSMBchassisNotebook = 0x0A,
263 kSMBchassisHandHeld = 0x0B,
264 kSMBchassisDockingStation = 0x0C,
265 kSMBchassisAllInOne = 0x0D,
266 kSMBchassisSubNotebook = 0x0E,
267 // ... fill up if needed ;-)
268 kSMBchassisLunchBox = 0x10,
269 // ... fill up if needed ;-)
270 kSMBchassisBladeEnclosing = 0x1D
271};
272
273/* ============================
274 Processor Information (Type 4)
275 ============================== */
276typedef struct SMBProcessorInformation
277{
278// 2.0+ spec (26 bytes)
279SMB_STRUCT_HEADER // Type 4
280SMBString socketDesignation;
281SMBByte processorType; // CPU = 3
282SMBByte processorFamily; // processor family enum
283SMBString manufacturer;
284SMBQWord processorID; // based on CPUID
285SMBString processorVersion;
286SMBByte voltage; // bit7 cleared indicate legacy mode
287SMBWord externalClock; // external clock in MHz
288SMBWord maximumClock; // max internal clock in MHz
289SMBWord currentClock; // current internal clock in MHz
290SMBByte status;
291SMBByte processorUpgrade; // processor upgrade enum
292// 2.1+ spec (32 bytes)
293SMBWord L1CacheHandle;
294SMBWord L2CacheHandle;
295SMBWord L3CacheHandle;
296// 2.3+ spec (35 bytes)
297SMBString serialNumber;
298SMBString assetTag;
299SMBString partNumber;
300// 2.5+ spec (40 bytes)
301//SMBByte coreCount;
302//SMBByte coreEnabled;
303//SMBByte threadCount;
304//SMBWord processorFuncSupport;
305// 2.6+ spec (42 bytes)
306//SMBWord processorFamily2;
307} __attribute__((packed)) SMBProcessorInformation;
308
309#define kSMBProcessorInformationMinSize 26
310
311/* ========================================
312 Values for processorType in Type 4 records
313 ======================================== */
314enum
315{
316 kSMBprocessorTypeOther = 0x01,
317 kSMBprocessorTypeUnknown = 0x02,
318 kSMBprocessorTypeCPU = 0x03,
319 kSMBprocessorTypeMPU = 0x04,
320 kSMBprocessorTypeDSP = 0x05,
321 kSMBprocessorTypeGPU = 0x06
322};
323
324/* =======================================================================
325 Memory Controller Information (Type 5) Obsolete since SMBIOS version 2.1
326 ========================================================================= */
327
328/* ===================================================================
329 Memory Module Information (Type 6) Obsolete since SMBIOS version 2.1
330 ===================================================================== */
331
332/* ========================
333 Cache Information (Type 7)
334 ========================== */
335typedef struct SMBCacheInformation
336{
337 SMB_STRUCT_HEADER // Type 7
338 SMBString socketDesignation;
339 SMBWord cacheConfiguration;
340 SMBWord maximumCacheSize;
341 SMBWord installedSize;
342 SMBWord supportedSRAMType;
343 SMBWord currentSRAMType;
344 SMBByte cacheSpeed;
345 SMBByte errorCorrectionType;
346 SMBByte systemCacheType;
347 SMBByte associativity;
348} __attribute__((packed)) SMBCacheInformation;
349
350/* ===================
351 System Slots (Type 9)
352 ===================== */
353typedef struct SMBSystemSlot
354{
355 // 2.0+ spec (12 bytes)
356SMB_STRUCT_HEADER
357SMBString slotDesignation;
358SMBByte slotType;
359SMBByte slotDataBusWidth;
360SMBByte currentUsage;
361SMBByte slotLength;
362SMBWord slotID;
363SMBByte slotCharacteristics1;
364// 2.1+ spec (13 bytes)
365SMBByte slotCharacteristics2;
366// 2.6+ spec (17 bytes)
367//SMBWordsegmentGroupNumber;
368//SMBBytebusNumber;
369//SMBBytedeviceFunctionNumber;
370} __attribute__((packed)) SMBSystemSlot;
371
372/* ===================
373 OEM Strings (Type 11)
374 ===================== */
375typedef struct SMBOEMStrings
376{
377 SMB_STRUCT_HEADER // Type 11
378 SMBBytecount; // number of strings
379} __attribute__((packed)) SMBOEMStrings;
380
381/* =============================
382 Physical Memory Array (Type 16)
383 =============================== */
384typedef struct SMBPhysicalMemoryArray
385{
386// 2.1+ spec (15 bytes)
387SMB_STRUCT_HEADER // Type 16
388SMBByte physicalLocation; // physical location
389SMBByte arrayUse; // the use for the memory array
390SMBByte errorCorrection; // error correction/detection method
391SMBDWord maximumCapacity; // maximum memory capacity in kilobytes
392SMBWord errorHandle; // handle of a previously detected error
393SMBWord numMemoryDevices; // number of memory slots or sockets
394// 2.7+ spec
395//SMBQWord extMaximumCapacity;// maximum memory capacity in bytes
396} __attribute__((packed)) SMBPhysicalMemoryArray;
397
398/* ================
399 Memory Array - Use
400 ================== */
401enum
402{
403 kSMBMemoryArrayUseOther = 0x01,
404 kSMBMemoryArrayUseUnknown = 0x02,
405 kSMBMemoryArrayUseSystemMemory = 0x03,
406 kSMBMemoryArrayUseVideoMemory = 0x04,
407 kSMBMemoryArrayUseFlashMemory = 0x05,
408 kSMBMemoryArrayUseNonVolatileMemory = 0x06,
409 kSMBMemoryArrayUseCacheMemory = 0x07
410};
411
412/* ===================================
413 Memory Array - Error Correction Types
414 ===================================== */
415enum
416{
417 kSMBMemoryArrayErrorCorrectionTypeOther = 0x01,
418 kSMBMemoryArrayErrorCorrectionTypeUnknown = 0x02,
419 kSMBMemoryArrayErrorCorrectionTypeNone = 0x03,
420 kSMBMemoryArrayErrorCorrectionTypeParity = 0x04,
421 kSMBMemoryArrayErrorCorrectionTypeSingleBitECC = 0x05,
422 kSMBMemoryArrayErrorCorrectionTypeMultiBitECC = 0x06,
423 kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07
424};
425
426/* =====================
427 Memory Device (Type 17)
428 ======================= */
429typedef struct SMBMemoryDevice
430{
431// 2.1+ spec (21 bytes)
432SMB_STRUCT_HEADER // Type 17
433SMBWord arrayHandle; // handle of the parent memory array
434SMBWord errorHandle; // handle of a previously detected error
435SMBWord totalWidth; // total width in bits; including ECC bits
436SMBWord dataWidth; // data width in bits
437SMBWord memorySize; // bit15 is scale, 0 = MB, 1 = KB
438SMBByte formFactor; // memory device form factor
439SMBByte deviceSet; // parent set of identical memory devices
440SMBString deviceLocator; // labeled socket; e.g. "SIMM 3"
441SMBString bankLocator; // labeled bank; e.g. "Bank 0" or "A"
442SMBByte memoryType; // type of memory
443SMBWord memoryTypeDetail; // additional detail on memory type
444// 2.3+ spec (27 bytes)
445SMBWord memorySpeed; // speed of device in MHz (0 for unknown)
446SMBString manufacturer;
447SMBString serialNumber;
448SMBString assetTag;
449SMBString partNumber;
450// 2.6+ spec (28 bytes)
451//SMBByte attributes;
452// 2.7+ spec
453//SMBDWord memoryExtSize;
454//SMBWord confMemClkSpeed;
455// 2.8+ spec
456//SMBWord minimumVolt;
457//SMBWord maximumVolt;
458//SMBWord configuredVolt;
459} __attribute__((packed)) SMBMemoryDevice;
460
461/* ===================================
462 Memory Array Mapped Address (Type 19)
463 ===================================== */
464//typedef struct SMBMemoryArrayMappedAddress
465//{
466 // 2.1+ spec
467//SMB_STRUCT_HEADER // Type 19
468//SMBDWord startingAddress;
469//SMBDWord endingAddress;
470//SMBWord arrayHandle;
471//SMBByte partitionWidth;
472// 2.7+ spec
473//SMBQWord extStartAddress;
474//SMBQWord extEndAddress;
475//} __attribute__((packed)) SMBMemoryArrayMappedAddress;
476
477/* ====================================
478 Memory Device Mapped Address (Type 20)
479 ====================================== */
480//typedef struct SMBMemoryDeviceMappedAddress
481//{
482// 2.1+ spec
483//SMB_STRUCT_HEADER // Type 20
484//SMBDWord startingAddress;
485//SMBDWord endingAddress;
486//SMBWord arrayHandle;
487//SMBByte partitionRowPosition;
488//SMBByte interleavePosition;
489//SMBByte interleaveDataDepth;
490// 2.7+ spec
491//SMBQWord extStartAddress;
492//SMBQWord extEndAddress;
493//} __attribute__((packed)) SMBMemoryDeviceMappedAddress;
494
495/* =====================================================
496 Firmware Volume Description (Apple Specific - Type 128)
497 ======================================================= */
498enum
499{
500FW_REGION_RESERVED = 0,
501FW_REGION_RECOVERY = 1,
502FW_REGION_MAIN = 2,
503FW_REGION_NVRAM = 3,
504FW_REGION_CONFIG = 4,
505FW_REGION_DIAGVAULT = 5,
506
507NUM_FLASHMAP_ENTRIES = 8
508};
509
510typedef struct FW_REGION_INFO
511{
512SMBDWord StartAddress;
513SMBDWord EndAddress;
514} __attribute__((packed)) FW_REGION_INFO;
515
516/* ========
517 (Type 128)
518 ========== */
519typedef struct SMBFirmwareVolume
520{
521SMB_STRUCT_HEADER// Type 128
522SMBByte RegionCount;
523SMBByte Reserved[3];
524SMBDWord FirmwareFeatures;
525SMBDWord FirmwareFeaturesMask;
526SMBByte RegionType[ NUM_FLASHMAP_ENTRIES ];
527FW_REGION_INFO FlashMap[ NUM_FLASHMAP_ENTRIES ];
528} __attribute__((packed)) SMBFirmwareVolume;
529
530/* ===========================================
531 Memory SPD Data (Apple Specific - Type 130)
532 ============================================= */
533typedef struct SMBMemorySPD
534{
535SMB_STRUCT_HEADER// Type 130
536SMBWord Type17Handle;
537SMBWord Offset;
538SMBWord Size;
539SMBWord Data[];
540} __attribute__((packed)) SMBMemorySPD;
541
542/* ============================================
543 OEM Processor Type (Apple Specific - Type 131)
544 ============================================== */
545typedef struct SMBOemProcessorType
546{
547SMB_STRUCT_HEADER// Type131
548SMBWord ProcessorType;
549} __attribute__((packed)) SMBOemProcessorType;
550
551/* =================================================
552 OEM Processor Bus Speed (Apple Specific - Type 132)
553 =================================================== */
554typedef struct SMBOemProcessorBusSpeed
555{
556SMB_STRUCT_HEADER// Type 132
557SMBWord ProcessorBusSpeed; // MT/s unit
558} __attribute__((packed)) SMBOemProcessorBusSpeed;
559
560/* ==============================================
561 OEM Platform Feature (Apple Specific - Type 133)
562 ================================================ */
563struct SMBOemPlatformFeature
564{
565SMB_STRUCT_HEADER
566SMBWord PlatformFeature;
567} __attribute__((packed)) SMBOemPlatformFeature;
568
569//----------------------------------------------------------------------------------------------------------
570
571/* From Foundation/Efi/Guid/Smbios/SmBios.h */
572/* Modified to wrap Data4 array init with {} */
573#define EFI_SMBIOS_TABLE_GUID {0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}
574
575#define SMBIOS_ORIGINAL0
576#define SMBIOS_PATCHED1
577
578extern void *getSmbios(int which);
579extern void readSMBIOSInfo(SMBEntryPoint *eps);
580extern void setupSMBIOSTable(void);
581
582extern void decodeSMBIOSTable(SMBEntryPoint *eps);
583
584
585#endif /* !__LIBSAIO_SMBIOS_H */
586

Archive Download this file

Revision: 2360