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 SMBByte anchor[5];
39 SMBByte checksum;
40 SMBWord tableLength;
41 SMBDWord tableAddress;
42 SMBWord structureCount;
43 SMBByte bcdRevision;
44} __attribute__((packed)) DMIEntryPoint;
45
46typedef struct SMBEntryPoint {
47 SMBByte anchor[4];
48 SMBByte checksum;
49 SMBByte entryPointLength;
50 SMBByte majorVersion;
51 SMBByte minorVersion;
52 SMBWord maxStructureSize;
53 SMBByte entryPointRevision;
54 SMBByte formattedArea[5];
55 DMIEntryPoint dmi;
56} __attribute__((packed)) SMBEntryPoint;
57
58//
59// Header common to all SMBIOS structures
60//
61
62typedef struct SMBStructHeader {
63 SMBByte type;
64 SMBByte length;
65 SMBWord handle;
66} __attribute__((packed)) SMBStructHeader;
67
68#define SMB_STRUCT_HEADER SMBStructHeader header;
69
70typedef struct SMBAnchor
71{
72const SMBStructHeader *header;
73const uint8_t *next;
74const uint8_t *end;
75} SMBAnchor;
76
77#define SMB_ANCHOR_IS_VALID(x)\
78((x) && ((x)->header) && ((x)->next) && ((x)->end))
79
80#define SMB_ANCHOR_RESET(x)\
81bzero(x, sizeof(typedef struct SMBAnchor));
82
83//
84// SMBIOS structure types.
85//
86
87enum {
88 kSMBTypeBIOSInformation = 0,
89 kSMBTypeSystemInformation = 1,
90 kSMBTypeBaseBoard= 2,
91 kSMBTypeSystemEnclosure = 3,
92 kSMBTypeProcessorInformation = 4,
93 kSMBTypeMemoryModule = 6,
94 kSMBTypeCacheInformation = 7,
95 kSMBTypeSystemSlot = 9,
96 kSMBTypePhysicalMemoryArray = 16,
97 kSMBTypeMemoryDevice = 17,
98 kSMBType32BitMemoryErrorInfo = 18,
99 kSMBType64BitMemoryErrorInfo = 33,
100
101 kSMBTypeEndOfTable = 127,
102
103 /* Apple Specific Structures */
104 kSMBTypeFirmwareVolume = 128,
105 kSMBTypeMemorySPD = 130,
106 kSMBTypeOemProcessorType = 131,
107 kSMBTypeOemProcessorBusSpeed = 132
108};
109
110//
111// BIOS Information (Type 0)
112//
113typedef struct SMBBIOSInformation {
114 SMB_STRUCT_HEADER // Type 0
115 SMBString vendor; // BIOS vendor name
116 SMBString version; // BIOS version
117 SMBWord startSegment; // BIOS segment start
118 SMBString releaseDate; // BIOS release date
119 SMBByte romSize; // (n); 64K * (n+1) bytes
120 SMBQWord characteristics; // supported BIOS functions
121 // Bungo
122 SMBByte characteristicsExt1; // BIOS characteristics extension byte 1
123 SMBByte characteristicsExt2; // BIOS characteristics extension byte 2
124 SMBByte releaseMajor; // BIOS release (major)
125 SMBByte releaseMinor; // BIOS release (minor)
126 SMBByte ECreleaseMajor; // Embedded Controller firmware release (major)
127 SMBByte ECreleaseMinor; // Embedded Controller firmware release (minor)
128} __attribute__((packed)) SMBBIOSInformation;
129
130//
131// System Information (Type 1)
132//
133
134typedef struct SMBSystemInformation {
135 // 2.0+ spec (8 bytes)
136 SMB_STRUCT_HEADER // Type 1
137 SMBString manufacturer;
138 SMBString productName;
139 SMBString version;
140 SMBString serialNumber;
141 // 2.1+ spec (25 bytes)
142 SMBByte uuid[16]; // can be all 0 or all 1's
143 SMBByte wakeupReason; // reason for system wakeup
144 // 2.4+ spec (27 bytes)
145 SMBString skuNumber;
146 SMBString family;
147} __attribute__((packed)) SMBSystemInformation;
148
149//
150// Base Board (Type 2)
151//
152
153typedef struct SMBBaseBoard {
154 SMB_STRUCT_HEADER // Type 2
155 SMBStringmanufacturer;
156 SMBStringproduct;
157 SMBStringversion;
158 SMBStringserialNumber;
159 SMBStringassetTagNumber;
160 SMBBytefeatureFlags;
161 SMBStringlocationInChassis;
162 SMBWordchassisHandle;
163 SMBByteboardType;
164 SMBBytenumberOfContainedHandles;
165// 0 - 255 contained handles go here but we do not include
166// them in our structure. Be careful to use numberOfContainedHandles
167// times sizeof(SMBWord) when computing the actual record size,
168// if you need it.
169} __attribute__((packed)) SMBBaseBoard;
170
171// Values for boardType in Type 2 records
172enum {
173 kSMBBaseBoardUnknown= 0x01,
174 kSMBBaseBoardOther= 0x02,
175 kSMBBaseBoardServerBlade= 0x03,
176 kSMBBaseBoardConnectivitySwitch= 0x04,
177 kSMBBaseBoardSystemMgmtModule= 0x05,
178 kSMBBaseBoardProcessorModule= 0x06,
179 kSMBBaseBoardIOModule= 0x07,
180 kSMBBaseBoardMemoryModule= 0x08,
181 kSMBBaseBoardDaughter= 0x09,
182 kSMBBaseBoardMotherboard= 0x0A,
183 kSMBBaseBoardProcessorMemoryModule= 0x0B,
184 kSMBBaseBoardProcessorIOModule= 0x0C,
185 kSMBBaseBoardInterconnect= 0x0D,
186};
187
188
189//
190// System Enclosure (Type 3)
191//
192
193typedef struct SMBSystemEnclosure {
194 SMB_STRUCT_HEADER // Type 3
195 SMBString manufacturer;
196 SMBByte type;
197 SMBString version;
198 SMBString serialNumber;
199 SMBString assetTagNumber;
200 SMBByte bootupState;
201 SMBByte powerSupplyState;
202 SMBByte thermalState;
203 SMBByte securityStatus;
204 SMBDWord oemDefined;
205} __attribute__((packed)) SMBSystemEnclosure;
206
207//
208// Processor Information (Type 4)
209//
210
211typedef struct SMBProcessorInformation {
212 // 2.0+ spec (26 bytes)
213 SMB_STRUCT_HEADER // Type 4
214 SMBString socketDesignation;
215 SMBByte processorType; // CPU = 3
216 SMBByte processorFamily; // processor family enum
217 SMBString manufacturer;
218 SMBQWord processorID; // based on CPUID
219 SMBString processorVersion;
220 SMBByte voltage; // bit7 cleared indicate legacy mode
221 SMBWord externalClock; // external clock in MHz
222 SMBWord maximumClock; // max internal clock in MHz
223 SMBWord currentClock; // current internal clock in MHz
224 SMBByte status;
225 SMBByte processorUpgrade; // processor upgrade enum
226 // 2.1+ spec (32 bytes)
227 SMBWord L1CacheHandle;
228 SMBWord L2CacheHandle;
229 SMBWord L3CacheHandle;
230 // 2.3+ spec (35 bytes)
231 SMBString serialNumber;
232 SMBString assetTag;
233 SMBString partNumber;
234} __attribute__((packed)) SMBProcessorInformation;
235
236#define kSMBProcessorInformationMinSize 26
237
238//
239// Memory Module Information (Type 6)
240// Obsoleted since SMBIOS version 2.1
241//
242
243typedef struct SMBMemoryModule {
244 SMB_STRUCT_HEADER // Type 6
245 SMBString socketDesignation;
246 SMBByte bankConnections;
247 SMBByte currentSpeed;
248 SMBWord currentMemoryType;
249 SMBByte installedSize;
250 SMBByte enabledSize;
251 SMBByte errorStatus;
252} __attribute__((packed)) SMBMemoryModule;
253
254#define kSMBMemoryModuleSizeNotDeterminable 0x7D
255#define kSMBMemoryModuleSizeNotEnabled 0x7E
256#define kSMBMemoryModuleSizeNotInstalled 0x7F
257
258//
259// Cache Information (Type 7)
260//
261
262typedef struct SMBCacheInformation {
263 SMB_STRUCT_HEADER // Type 7
264 SMBString socketDesignation;
265 SMBWord cacheConfiguration;
266 SMBWord maximumCacheSize;
267 SMBWord installedSize;
268 SMBWord supportedSRAMType;
269 SMBWord currentSRAMType;
270 SMBByte cacheSpeed;
271 SMBByte errorCorrectionType;
272 SMBByte systemCacheType;
273 SMBByte associativity;
274} __attribute__((packed)) SMBCacheInformation;
275
276typedef struct SMBSystemSlot {
277 // 2.0+ spec (12 bytes)
278 SMB_STRUCT_HEADER // Type 9
279 SMBString slotDesignation;
280 SMBByte slotType;
281 SMBByte slotDataBusWidth;
282 SMBByte currentUsage;
283 SMBByte slotLength;
284 SMBWord slotID;
285 SMBByte slotCharacteristics1;
286 // 2.1+ spec (13 bytes)
287 SMBByte slotCharacteristics2;
288} __attribute__((packed)) SMBSystemSlot;
289
290//
291// Physical Memory Array (Type 16)
292//
293
294typedef struct SMBPhysicalMemoryArray {
295 // 2.1+ spec (15 bytes)
296 SMB_STRUCT_HEADER // Type 16
297 SMBByte physicalLocation; // physical location
298 SMBByte arrayUse; // the use for the memory array
299 SMBByte errorCorrection; // error correction/detection method
300 SMBDWord maximumCapacity; // maximum memory capacity in kilobytes
301 SMBWord errorHandle; // handle of a previously detected error
302 SMBWord numMemoryDevices; // number of memory slots or sockets
303} __attribute__((packed)) SMBPhysicalMemoryArray;
304
305// Memory Array - Use
306enum {
307 kSMBMemoryArrayUseOther = 0x01,
308 kSMBMemoryArrayUseUnknown = 0x02,
309 kSMBMemoryArrayUseSystemMemory = 0x03,
310 kSMBMemoryArrayUseVideoMemory = 0x04,
311 kSMBMemoryArrayUseFlashMemory = 0x05,
312 kSMBMemoryArrayUseNonVolatileMemory = 0x06,
313 kSMBMemoryArrayUseCacheMemory = 0x07
314};
315
316// Memory Array - Error Correction Types
317enum {
318 kSMBMemoryArrayErrorCorrectionTypeOther = 0x01,
319 kSMBMemoryArrayErrorCorrectionTypeUnknown = 0x02,
320 kSMBMemoryArrayErrorCorrectionTypeNone = 0x03,
321 kSMBMemoryArrayErrorCorrectionTypeParity = 0x04,
322 kSMBMemoryArrayErrorCorrectionTypeSingleBitECC = 0x05,
323 kSMBMemoryArrayErrorCorrectionTypeMultiBitECC = 0x06,
324 kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07
325};
326
327//
328// Memory Device (Type 17)
329//
330
331typedef struct SMBMemoryDevice {
332 // 2.1+ spec (21 bytes)
333 SMB_STRUCT_HEADER // Type 17
334 SMBWord arrayHandle; // handle of the parent memory array
335 SMBWord errorHandle; // handle of a previously detected error
336 SMBWord totalWidth; // total width in bits; including ECC bits
337 SMBWord dataWidth; // data width in bits
338 SMBWord memorySize; // bit15 is scale, 0 = MB, 1 = KB
339 SMBByte formFactor; // memory device form factor
340 SMBByte deviceSet; // parent set of identical memory devices
341 SMBString deviceLocator; // labeled socket; e.g. "SIMM 3"
342 SMBString bankLocator; // labeled bank; e.g. "Bank 0" or "A"
343 SMBByte memoryType; // type of memory
344 SMBWord memoryTypeDetail; // additional detail on memory type
345 // 2.3+ spec (27 bytes)
346 SMBWord memorySpeed; // speed of device in MHz (0 for unknown)
347 SMBString manufacturer;
348 SMBString serialNumber;
349 SMBString assetTag;
350 SMBString partNumber;
351} __attribute__((packed)) SMBMemoryDevice;
352
353//
354// Firmware Volume Description (Apple Specific - Type 128)
355//
356
357enum {
358 FW_REGION_RESERVED = 0,
359 FW_REGION_RECOVERY = 1,
360 FW_REGION_MAIN = 2,
361 FW_REGION_NVRAM = 3,
362 FW_REGION_CONFIG = 4,
363 FW_REGION_DIAGVAULT = 5,
364
365 NUM_FLASHMAP_ENTRIES = 8
366};
367
368typedef struct FW_REGION_INFO
369{
370 SMBDWord StartAddress;
371 SMBDWord EndAddress;
372} __attribute__((packed)) FW_REGION_INFO;
373
374typedef struct SMBFirmwareVolume {
375 SMB_STRUCT_HEADER // Type 128
376 SMBByte RegionCount;
377 SMBByte Reserved[3];
378 SMBDWord FirmwareFeatures;
379 SMBDWord FirmwareFeaturesMask;
380 SMBByte RegionType[ NUM_FLASHMAP_ENTRIES ];
381 FW_REGION_INFO FlashMap[ NUM_FLASHMAP_ENTRIES ];
382} __attribute__((packed)) SMBFirmwareVolume;
383
384//
385// Memory SPD Data (Apple Specific - Type 130)
386//
387
388typedef struct SMBMemorySPD {
389SMB_STRUCT_HEADER // Type 130
390SMBWord Type17Handle;
391SMBWord Offset;
392SMBWord Size;
393SMBWord Data[];
394} __attribute__((packed)) SMBMemorySPD;
395
396//
397// OEM Processor Type (Apple Specific - Type 131)
398//
399
400typedef struct SMBOemProcessorType {
401SMB_STRUCT_HEADER
402SMBWord ProcessorType;
403} __attribute__((packed)) SMBOemProcessorType;
404
405//
406// OEM Processor Bus Speed (Apple Specific - Type 132)
407//
408typedef struct SMBOemProcessorBusSpeed {
409SMB_STRUCT_HEADER
410SMBWord ProcessorBusSpeed; // MT/s unit
411} __attribute__((packed)) SMBOemProcessorBusSpeed;
412
413//----------------------------------------------------------------------------------------------------------
414
415/* From Foundation/Efi/Guid/Smbios/SmBios.h */
416/* Modified to wrap Data4 array init with {} */
417#define EFI_SMBIOS_TABLE_GUID {0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}
418
419#define SMBIOS_ORIGINAL0
420#define SMBIOS_PATCHED1
421
422extern void *getSmbios(int which);
423extern void readSMBIOSInfo(SMBEntryPoint *eps);
424extern void setupSMBIOSTable(void);
425
426extern void decodeSMBIOSTable(SMBEntryPoint *eps);
427
428
429#endif /* !__LIBSAIO_SMBIOS_H */
430

Archive Download this file

Revision: 2284