Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/ErmaC/ChameleonPrefPane/Sources/smbios/smbios.h

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

Archive Download this file

Revision: 396