Chameleon Applications

Chameleon Applications Svn Source Tree

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

Archive Download this file

Revision: 458