Chameleon

Chameleon Svn Source Tree

Root/trunk/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//
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
101// kSMBOEMStrings= 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;
194SMBStringassetTagNumber;
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 ========================= */
230
231typedef struct SMBSystemEnclosure
232{
233SMB_STRUCT_HEADER // Type 3
234SMBString manufacturer;
235SMBByte type;// System Enclosure Indicator
236SMBString version;// Board Number?
237SMBString serialNumber;
238SMBString assetTagNumber;
239SMBByte bootupState;// State of enclosure when when it was last booted
240SMBByte powerSupplyState;// State of enclosure's power supply when last booted
241SMBByte thermalState;// Thermal state of the enclosure when last booted
242SMBByte securityStatus;// Physical security status of the enclosure when last booted
243SMBDWord oemDefined;// OEM- or BIOS vendor-specific information
244//SMBByte height;// Height of the enclosure, in 'U's
245//SMBByte numberOfPowerCords;// Number of power cords associated with the enclosure or chassis
246//SMBByte containedElementCount;// Number of Contained Element record that follow, in the range 0 to 255
247//SMBByte containedElementRecord;// Byte leght of each Contained Element record that follow, in the range 0 to 255
248//SMBBytecontainedElements;// Elements, possibly defined by other SMBIOS structures present in chassis
249//SMBString skuNumber;// Number of null-terminated string describing the chassis or enclosure SKU number (2.7+)
250} __attribute__((packed)) SMBSystemEnclosure;
251
252/* ============================
253 Processor Information (Type 4)
254 ============================== */
255typedef struct SMBProcessorInformation
256{
257// 2.0+ spec (26 bytes)
258SMB_STRUCT_HEADER // Type 4
259SMBString socketDesignation;
260SMBByte processorType; // CPU = 3
261SMBByte processorFamily; // processor family enum
262SMBString manufacturer;
263SMBQWord processorID; // based on CPUID
264SMBString processorVersion;
265SMBByte voltage; // bit7 cleared indicate legacy mode
266SMBWord externalClock; // external clock in MHz
267SMBWord maximumClock; // max internal clock in MHz
268SMBWord currentClock; // current internal clock in MHz
269SMBByte status;
270SMBByte processorUpgrade; // processor upgrade enum
271// 2.1+ spec (32 bytes)
272SMBWord L1CacheHandle;
273SMBWord L2CacheHandle;
274SMBWord L3CacheHandle;
275// 2.3+ spec (35 bytes)
276SMBString serialNumber;
277SMBString assetTag;
278SMBString partNumber;
279// 2.5+ spec
280//SMBByte coreCount;
281//SMBByte coreEnabled;
282//SMBByte threadCount;
283//SMBWord processorCharacteristics;
284// 2.6+ spec
285//SMBWord processorFamily2;
286} __attribute__((packed)) SMBProcessorInformation;
287
288#define kSMBProcessorInformationMinSize 26
289
290/* =======================================================================
291 Memory Controller Information (Type 5) Obsoleted since SMBIOS version 2.1
292 ========================================================================= */
293
294/* ===================================================================
295 Memory Module Information (Type 6) Obsoleted since SMBIOS version 2.1
296 ===================================================================== */
297typedef struct SMBMemoryModule
298{
299 SMB_STRUCT_HEADER // Type 6
300 SMBString socketDesignation;
301 SMBByte bankConnections;
302 SMBByte currentSpeed;
303 SMBWord currentMemoryType;
304 SMBByte installedSize;
305 SMBByte enabledSize;
306 SMBByte errorStatus;
307} __attribute__((packed)) SMBMemoryModule;
308
309#define kSMBMemoryModuleSizeNotDeterminable 0x7D
310#define kSMBMemoryModuleSizeNotEnabled 0x7E
311#define kSMBMemoryModuleSizeNotInstalled 0x7F
312
313/* ========================
314 Cache Information (Type 7)
315 ========================== */
316typedef struct SMBCacheInformation
317{
318 SMB_STRUCT_HEADER // Type 7
319 SMBString socketDesignation;
320 SMBWord cacheConfiguration;
321 SMBWord maximumCacheSize;
322 SMBWord installedSize;
323 SMBWord supportedSRAMType;
324 SMBWord currentSRAMType;
325 SMBByte cacheSpeed;
326 SMBByte errorCorrectionType;
327 SMBByte systemCacheType;
328 SMBByte associativity;
329} __attribute__((packed)) SMBCacheInformation;
330
331/* ===================
332 System Slots (Type 9)
333 ===================== */
334typedef struct SMBSystemSlot
335{
336 // 2.0+ spec (12 bytes)
337SMB_STRUCT_HEADER
338SMBString slotDesignation;
339SMBByte slotType;
340SMBByte slotDataBusWidth;
341SMBByte currentUsage;
342SMBByte slotLength;
343SMBWord slotID;
344SMBByte slotCharacteristics1;
345// 2.1+ spec (13 bytes)
346SMBByte slotCharacteristics2;
347// 2.6+ spec
348//SMBWordsegmentGroupNumber;
349//SMBBytebusNumber;
350//SMBBytedevFuncNumber;
351} __attribute__((packed)) SMBSystemSlot;
352
353/* ===================
354 OEM Strings (Type 11)
355 ===================== */
356//typedef struct SMBOEMStrings
357//{
358//SMB_STRUCT_HEADER // Type 11
359//SMBBytecount;// number of strings
360//} __attribute__((packed)) SMBOEMStrings;
361
362/* =============================
363 Physical Memory Array (Type 16)
364 =============================== */
365typedef struct SMBPhysicalMemoryArray
366{
367// 2.1+ spec (15 bytes)
368SMB_STRUCT_HEADER // Type 16
369SMBByte physicalLocation; // physical location
370SMBByte arrayUse; // the use for the memory array
371SMBByte errorCorrection; // error correction/detection method
372SMBDWord maximumCapacity; // maximum memory capacity in kilobytes
373SMBWord errorHandle; // handle of a previously detected error
374SMBWord numMemoryDevices; // number of memory slots or sockets
375// 2.7+ spec
376//SMBQWord extMaximumCapacity;// maximum memory capacity in bytes
377} __attribute__((packed)) SMBPhysicalMemoryArray;
378
379/* ================
380 Memory Array - Use
381 ================== */
382enum
383{
384 kSMBMemoryArrayUseOther = 0x01,
385 kSMBMemoryArrayUseUnknown = 0x02,
386 kSMBMemoryArrayUseSystemMemory = 0x03,
387 kSMBMemoryArrayUseVideoMemory = 0x04,
388 kSMBMemoryArrayUseFlashMemory = 0x05,
389 kSMBMemoryArrayUseNonVolatileMemory = 0x06,
390 kSMBMemoryArrayUseCacheMemory = 0x07
391};
392
393/* ===================================
394 Memory Array - Error Correction Types
395 ===================================== */
396enum
397{
398 kSMBMemoryArrayErrorCorrectionTypeOther = 0x01,
399 kSMBMemoryArrayErrorCorrectionTypeUnknown = 0x02,
400 kSMBMemoryArrayErrorCorrectionTypeNone = 0x03,
401 kSMBMemoryArrayErrorCorrectionTypeParity = 0x04,
402 kSMBMemoryArrayErrorCorrectionTypeSingleBitECC = 0x05,
403 kSMBMemoryArrayErrorCorrectionTypeMultiBitECC = 0x06,
404 kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07
405};
406
407/* =====================
408 Memory Device (Type 17)
409 ======================= */
410typedef struct SMBMemoryDevice
411{
412// 2.1+ spec (21 bytes)
413SMB_STRUCT_HEADER // Type 17
414SMBWord arrayHandle; // handle of the parent memory array
415SMBWord errorHandle; // handle of a previously detected error
416SMBWord totalWidth; // total width in bits; including ECC bits
417SMBWord dataWidth; // data width in bits
418SMBWord memorySize; // bit15 is scale, 0 = MB, 1 = KB
419SMBByte formFactor; // memory device form factor
420SMBByte deviceSet; // parent set of identical memory devices
421SMBString deviceLocator; // labeled socket; e.g. "SIMM 3"
422SMBString bankLocator; // labeled bank; e.g. "Bank 0" or "A"
423SMBByte memoryType; // type of memory
424SMBWord memoryTypeDetail; // additional detail on memory type
425// 2.3+ spec (27 bytes)
426SMBWord memorySpeed; // speed of device in MHz (0 for unknown)
427SMBString manufacturer;
428SMBString serialNumber;
429SMBString assetTag;
430SMBString partNumber;
431// 2.6+ spec
432//SMBByte memoryAtributes;
433// 2.7+ spec
434//SMBDWord memoryExtSize;
435//SMBWord confMemClkSpeed;
436// 2.8+ spec
437//SMBWord minimumVolt;
438//SMBWord maximumVolt;
439//SMBWord configuredVolt;
440} __attribute__((packed)) SMBMemoryDevice;
441
442/* ===================================
443 Memory Array Mapped Address (Type 19)
444 ===================================== */
445//typedef struct SMBMemoryArrayMappedAddress
446//{
447 // 2.1+ spec
448//SMB_STRUCT_HEADER // Type 19
449//SMBDWord startingAddress;
450//SMBDWord endingAddress;
451//SMBWord arrayHandle;
452//SMBByte partitionWidth;
453// 2.7+ spec
454//SMBQWord extStartAddress;
455//SMBQWord extEndAddress;
456//} __attribute__((packed)) SMBMemoryArrayMappedAddress;
457
458/* ====================================
459 Memory Device Mapped Address (Type 20)
460 ====================================== */
461//typedef struct SMBMemoryDeviceMappedAddress
462//{
463// 2.1+ spec
464//SMB_STRUCT_HEADER // Type 20
465//SMBDWord startingAddress;
466//SMBDWord endingAddress;
467//SMBWord arrayHandle;
468//SMBByte partitionRowPosition;
469//SMBByte interleavePosition;
470//SMBByte interleaveDataDepth;
471// 2.7+ spec
472//SMBQWord extStartAddress;
473//SMBQWord extEndAddress;
474//} __attribute__((packed)) SMBMemoryDeviceMappedAddress;
475
476/* =====================================================
477 Firmware Volume Description (Apple Specific - Type 128)
478 ======================================================= */
479enum
480{
481FW_REGION_RESERVED = 0,
482FW_REGION_RECOVERY = 1,
483FW_REGION_MAIN = 2,
484FW_REGION_NVRAM = 3,
485FW_REGION_CONFIG = 4,
486FW_REGION_DIAGVAULT = 5,
487
488NUM_FLASHMAP_ENTRIES = 8
489};
490
491typedef struct FW_REGION_INFO
492{
493SMBDWord StartAddress;
494SMBDWord EndAddress;
495} __attribute__((packed)) FW_REGION_INFO;
496
497/* ========
498 (Type 128)
499 ========== */
500typedef struct SMBFirmwareVolume
501{
502SMB_STRUCT_HEADER// Type 128
503SMBByte RegionCount;
504SMBByte Reserved[3];
505SMBDWord FirmwareFeatures;
506SMBDWord FirmwareFeaturesMask;
507SMBByte RegionType[ NUM_FLASHMAP_ENTRIES ];
508FW_REGION_INFO FlashMap[ NUM_FLASHMAP_ENTRIES ];
509} __attribute__((packed)) SMBFirmwareVolume;
510
511/* ===========================================
512 Memory SPD Data (Apple Specific - Type 130)
513 ============================================= */
514typedef struct SMBMemorySPD
515{
516SMB_STRUCT_HEADER// Type 130
517SMBWord Type17Handle;
518SMBWord Offset;
519SMBWord Size;
520SMBWord Data[];
521} __attribute__((packed)) SMBMemorySPD;
522
523/* ============================================
524 OEM Processor Type (Apple Specific - Type 131)
525 ============================================== */
526typedef struct SMBOemProcessorType
527{
528SMB_STRUCT_HEADER// Type131
529SMBWord ProcessorType;
530} __attribute__((packed)) SMBOemProcessorType;
531
532/* =================================================
533 OEM Processor Bus Speed (Apple Specific - Type 132)
534 =================================================== */
535typedef struct SMBOemProcessorBusSpeed
536{
537SMB_STRUCT_HEADER// Type 132
538SMBWord ProcessorBusSpeed; // MT/s unit
539} __attribute__((packed)) SMBOemProcessorBusSpeed;
540
541//----------------------------------------------------------------------------------------------------------
542
543/* From Foundation/Efi/Guid/Smbios/SmBios.h */
544/* Modified to wrap Data4 array init with {} */
545#define EFI_SMBIOS_TABLE_GUID {0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}
546
547#define SMBIOS_ORIGINAL0
548#define SMBIOS_PATCHED1
549
550extern void *getSmbios(int which);
551extern void readSMBIOSInfo(SMBEntryPoint *eps);
552extern void setupSMBIOSTable(void);
553
554extern void decodeSMBIOSTable(SMBEntryPoint *eps);
555
556
557#endif /* !__LIBSAIO_SMBIOS_H */
558

Archive Download this file

Revision: 2285