Chameleon

Chameleon Svn Source Tree

Root/branches/slice/trunkM/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) //min len 18+num_of_extChars. Max=18h=24
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
121SMBByte extChars[2];//BIOS Characteristics Extension Bytes
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 // 2.5+ spec (38 bytes)
229SMBBytecoreCount;
230SMBBytecoreEnabled;
231SMBByteThreads;
232} __attribute__((packed)) SMBProcessorInformation;
233
234#define kSMBProcessorInformationMinSize 26
235
236typedef struct SMBMemoryControllerInfo {/* 3.3.6 Memory Controller Information (Type 5) */
237SMB_STRUCT_HEADER
238SMBByteerrorDetectingMethod;
239SMBByteerrorCorrectingCapability;
240SMBBytesupportedInterleave;
241SMBBytecurrentInterleave;
242SMBBytemaxMemoryModuleSize;
243SMBWordsupportedSpeeds;
244SMBWordsupportedMemoryTypes;
245SMBBytememoryModuleVoltage;
246SMBBytenumberOfMemorySlots;
247} __attribute__((packed)) SMBMemoryControllerInfo;
248
249//
250// Memory Module Information (Type 6)
251// Obsoleted since SMBIOS version 2.1
252//
253
254typedef struct SMBMemoryModule {
255 SMB_STRUCT_HEADER // Type 6
256 SMBString socketDesignation;
257 SMBByte bankConnections;
258 SMBByte currentSpeed;
259 SMBWord currentMemoryType;
260 SMBByte installedSize;
261 SMBByte enabledSize;
262 SMBByte errorStatus;
263} __attribute__((packed)) SMBMemoryModule;
264
265#define kSMBMemoryModuleSizeNotDeterminable 0x7D
266#define kSMBMemoryModuleSizeNotEnabled 0x7E
267#define kSMBMemoryModuleSizeNotInstalled 0x7F
268
269//
270// Cache Information (Type 7)
271//
272
273typedef struct SMBCacheInformation {
274 SMB_STRUCT_HEADER // Type 7
275 SMBString socketDesignation;
276 SMBWord cacheConfiguration;
277 SMBWord maximumCacheSize;
278 SMBWord installedSize;
279 SMBWord supportedSRAMType;
280 SMBWord currentSRAMType;
281 SMBByte cacheSpeed;
282 SMBByte errorCorrectionType;
283 SMBByte systemCacheType;
284 SMBByte associativity;
285} __attribute__((packed)) SMBCacheInformation;
286
287typedef struct SMBSystemSlot {
288 // 2.0+ spec (12 bytes)
289 SMB_STRUCT_HEADER // Type 9
290 SMBString slotDesignation;
291 SMBByte slotType;
292 SMBByte slotDataBusWidth;
293 SMBByte currentUsage;
294 SMBByte slotLength;
295 SMBWord slotID;
296 SMBByte slotCharacteristics1;
297 // 2.1+ spec (13 bytes)
298 SMBByte slotCharacteristics2;
299} __attribute__((packed)) SMBSystemSlot;
300
301//
302// Physical Memory Array (Type 16)
303//
304
305typedef struct SMBPhysicalMemoryArray {
306 // 2.1+ spec (15 bytes)
307 SMB_STRUCT_HEADER // Type 16
308 SMBByte physicalLocation; // physical location
309 SMBByte arrayUse; // the use for the memory array
310 SMBByte errorCorrection; // error correction/detection method
311 SMBDWord maximumCapacity; // maximum memory capacity in kilobytes
312 SMBWord errorHandle; // handle of a previously detected error
313 SMBWord numMemoryDevices; // number of memory slots or sockets
314} __attribute__((packed)) SMBPhysicalMemoryArray;
315
316// Memory Array - Use
317enum {
318 kSMBMemoryArrayUseOther = 0x01,
319 kSMBMemoryArrayUseUnknown = 0x02,
320 kSMBMemoryArrayUseSystemMemory = 0x03,
321 kSMBMemoryArrayUseVideoMemory = 0x04,
322 kSMBMemoryArrayUseFlashMemory = 0x05,
323 kSMBMemoryArrayUseNonVolatileMemory = 0x06,
324 kSMBMemoryArrayUseCacheMemory = 0x07
325};
326
327// Memory Array - Error Correction Types
328enum {
329 kSMBMemoryArrayErrorCorrectionTypeOther = 0x01,
330 kSMBMemoryArrayErrorCorrectionTypeUnknown = 0x02,
331 kSMBMemoryArrayErrorCorrectionTypeNone = 0x03,
332 kSMBMemoryArrayErrorCorrectionTypeParity = 0x04,
333 kSMBMemoryArrayErrorCorrectionTypeSingleBitECC = 0x05,
334 kSMBMemoryArrayErrorCorrectionTypeMultiBitECC = 0x06,
335 kSMBMemoryArrayErrorCorrectionTypeCRC = 0x07
336};
337
338//
339// Memory Device (Type 17)
340//
341
342typedef struct SMBMemoryDevice {
343 // 2.1+ spec (21 bytes)
344 SMB_STRUCT_HEADER // Type 17
345 SMBWord arrayHandle; // handle of the parent memory array
346 SMBWord errorHandle; // handle of a previously detected error
347 SMBWord totalWidth; // total width in bits; including ECC bits
348 SMBWord dataWidth; // data width in bits
349 SMBWord memorySize; // bit15 is scale, 0 = MB, 1 = KB
350 SMBByte formFactor; // memory device form factor
351 SMBByte deviceSet; // parent set of identical memory devices
352 SMBString deviceLocator; // labeled socket; e.g. "SIMM 3"
353 SMBString bankLocator; // labeled bank; e.g. "Bank 0" or "A"
354 SMBByte memoryType; // type of memory
355 SMBWord memoryTypeDetail; // additional detail on memory type
356 // 2.3+ spec (27 bytes)
357 SMBWord memorySpeed; // speed of device in MHz (0 for unknown)
358 SMBString manufacturer;
359 SMBString serialNumber;
360 SMBString assetTag;
361 SMBString partNumber;
362} __attribute__((packed)) SMBMemoryDevice;
363
364//
365// Firmware Volume Description (Apple Specific - Type 128)
366//
367
368enum {
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 SMB_STRUCT_HEADER // Type 128
387 SMBByte RegionCount;
388 SMBByte Reserved[3];
389 SMBDWord FirmwareFeatures;
390 SMBDWord FirmwareFeaturesMask;
391 SMBByte RegionType[ NUM_FLASHMAP_ENTRIES ];
392 FW_REGION_INFO FlashMap[ NUM_FLASHMAP_ENTRIES ];
393} __attribute__((packed)) SMBFirmwareVolume;
394
395//
396// Memory SPD Data (Apple Specific - Type 130)
397//
398
399typedef struct SMBMemorySPD {
400SMB_STRUCT_HEADER // Type 130
401SMBWord Type17Handle;
402SMBWord Offset;
403SMBWord Size;
404SMBWord Data[];
405} __attribute__((packed)) SMBMemorySPD;
406
407static const char *
408SMBMemoryDeviceTypes[] =
409{
410 "RAM", /* 00h Undefined */
411 "RAM", /* 01h Other */
412 "RAM", /* 02h Unknown */
413 "DRAM", /* 03h DRAM */
414 "EDRAM", /* 04h EDRAM */
415 "VRAM", /* 05h VRAM */
416 "SRAM", /* 06h SRAM */
417 "RAM", /* 07h RAM */
418 "ROM", /* 08h ROM */
419 "FLASH", /* 09h FLASH */
420 "EEPROM", /* 0Ah EEPROM */
421 "FEPROM", /* 0Bh FEPROM */
422 "EPROM", /* 0Ch EPROM */
423 "CDRAM", /* 0Dh CDRAM */
424 "3DRAM", /* 0Eh 3DRAM */
425 "SDRAM", /* 0Fh SDRAM */
426 "SGRAM", /* 10h SGRAM */
427 "RDRAM", /* 11h RDRAM */
428 "DDR SDRAM", /* 12h DDR */
429 "DDR2 SDRAM", /* 13h DDR2 */
430 "DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */
431 "RAM",/* 15h unused */
432 "RAM",/* 16h unused */
433 "RAM",/* 17h unused */
434 "DDR3",/* 18h DDR3, chosen in [5776134] */
435};
436
437static const int
438kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) /
439 sizeof(SMBMemoryDeviceTypes[0]);
440
441//
442// OEM Processor Type (Apple Specific - Type 131)
443//
444
445typedef struct SMBOemProcessorType {
446SMB_STRUCT_HEADER
447SMBWord ProcessorType;
448} __attribute__((packed)) SMBOemProcessorType;
449
450//
451// OEM Processor Bus Speed (Apple Specific - Type 132)
452//
453typedef struct SMBOemProcessorBusSpeed {
454SMB_STRUCT_HEADER
455SMBWord ProcessorBusSpeed; // MT/s unit
456} __attribute__((packed)) SMBOemProcessorBusSpeed;
457
458//----------------------------------------------------------------------------------------------------------
459
460/* From Foundation/Efi/Guid/Smbios/SmBios.h */
461/* Modified to wrap Data4 array init with {} */
462#define EFI_SMBIOS_TABLE_GUID {0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}
463
464#define SMBIOS_ORIGINAL0
465#define SMBIOS_PATCHED1
466
467extern void *getSmbios(int which);
468extern void readSMBIOSInfo(SMBEntryPoint *eps);
469extern void setupSMBIOSTable(void);
470
471extern void decodeSMBIOSTable(SMBEntryPoint *eps);
472extern char MacModel[8];
473extern unsigned int ModelRev;
474extern uint64_t smbios_p;
475
476
477
478#endif /* !__LIBSAIO_SMBIOS_H */
479

Archive Download this file

Revision: 1207