Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 2238