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

Archive Download this file

Revision: 1119