Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 789