Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/libsaio/SMBIOS.h

1/*
2 * Copyright (c) 1998-2006 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/* This file is a stripped-down version of the one found in the AppleSMBIOS project.
24 * Changes:
25 * - Don't use pragma pack but instead use GCC's packed attribute
26 */
27
28#ifndef _LIBSAIO_SMBIOS_H
29#define _LIBSAIO_SMBIOS_H
30
31#include "libsaio.h"
32
33#define kIsServer"IsServer"
34extern struct SMBEntryPoint *getSmbiosOriginal();
35
36#define theUUID 0
37#define thePlatformName 1
38#define theProducBoard 2
39extern int readSMBIOS(int value); // value copied into the platform structure
40
41#define SMBIOS_RANGE_START0x000F0000
42#define SMBIOS_RANGE_END0x000FFFFF
43
44/* '_SM_' in little endian: */
45//#define SMBIOS_ANCHOR_UINT32_LE 0x5f4d535f
46
47// getting smbios addr with fast compare ops, late checksum testing ...
48#define COMPARE_DWORD(a,b) ( *((u_int32_t *) a) == *((u_int32_t *) b) )
49
50
51//
52// SMBIOS structure types.
53//
54
55enum {
56 kSMBTypeBIOSInformation = 0,
57 kSMBTypeSystemInformation = 1,
58 kSMBTypeBaseBoard= 2,
59 kSMBTypeSystemEnclosure = 3,
60 kSMBTypeProcessorInformation = 4,
61 kSMBTypeMemoryModule = 6,
62 kSMBTypeCacheInformation = 7,
63 kSMBTypeSystemSlot = 9,
64 kSMBTypePhysicalMemoryArray = 16,
65 kSMBTypeMemoryDevice = 17,
66 kSMBType32BitMemoryErrorInfo = 18,
67 kSMBType64BitMemoryErrorInfo = 33,
68
69 kSMBTypeEndOfTable = 127,
70
71 /* Apple Specific Structures */
72 kSMBTypeFirmwareVolume = 128,
73 kSMBTypeMemorySPD = 130,
74 kSMBTypeOemProcessorType = 131,
75 kSMBTypeOemProcessorBusSpeed = 132
76};
77
78/*
79 * Based on System Management BIOS Reference Specification v2.5
80 */
81
82typedef uint8_tSMBString;
83typedef uint8_tSMBByte;
84typedef uint16_tSMBWord;
85typedef uint32_tSMBDWord;
86typedef uint64_tSMBQWord;
87
88typedef struct DMIHeader {
89SMBBytetype;
90SMBBytelength;
91SMBWordhandle;
92} __attribute__((packed)) DMIHeader;
93
94#define DMI_STRUCT_HEADER DMIHeader dmiHeader;
95
96typedef struct DMIEntryPoint {
97SMBByteanchor[5];
98SMBBytechecksum;
99SMBWordtableLength;
100SMBDWordtableAddress;
101SMBWordstructureCount;
102SMBBytebcdRevision;
103} __attribute__((packed)) DMIEntryPoint;
104
105typedef struct SMBEntryPoint {
106SMBByteanchor[4];
107SMBBytechecksum;
108SMBByteentryPointLength;
109SMBBytemajorVersion;
110SMBByteminorVersion;
111SMBWordmaxStructureSize;
112SMBByteentryPointRevision;
113SMBByteformattedArea[5];
114struct DMIEntryPointdmi;
115} __attribute__((packed)) SMBEntryPoint;
116
117typedef struct DMIMemoryControllerInfo {/* 3.3.6 Memory Controller Information (Type 5) */
118DMI_STRUCT_HEADER
119SMBByteerrorDetectingMethod;
120SMBByteerrorCorrectingCapability;
121SMBBytesupportedInterleave;
122SMBBytecurrentInterleave;
123SMBBytemaxMemoryModuleSize;
124SMBWordsupportedSpeeds;
125SMBWordsupportedMemoryTypes;
126SMBBytememoryModuleVoltage;
127SMBBytenumberOfMemorySlots;
128} __attribute__((packed)) DMIMemoryControllerInfo;
129
130typedef struct DMIMemoryModuleInfo {/* 3.3.7 Memory Module Information (Type 6) */
131DMI_STRUCT_HEADER
132SMBBytesocketDesignation;
133SMBBytebankConnections;
134SMBBytecurrentSpeed;
135SMBWordcurrentMemoryType;
136SMBByteinstalledSize;
137SMBByteenabledSize;
138SMBByteerrorStatus;
139} __attribute__((packed)) DMIMemoryModuleInfo;
140
141typedef struct DMIPhysicalMemoryArray {/* 3.3.17 Physical Memory Array (Type 16) */
142DMI_STRUCT_HEADER
143SMBBytelocation;
144SMBByteuse;
145SMBBytememoryCorrectionError;
146SMBDWordmaximumCapacity;
147SMBWordmemoryErrorInformationHandle;
148SMBWordnumberOfMemoryDevices;
149} __attribute__((packed)) DMIPhysicalMemoryArray;
150
151typedef struct DMIMemoryDevice {/* 3.3.18 Memory Device (Type 17) */
152DMI_STRUCT_HEADER
153SMBWordphysicalMemoryArrayHandle;
154SMBWordmemoryErrorInformationHandle;
155SMBWordtotalWidth;
156SMBWorddataWidth;
157SMBWordsize;
158SMBByteformFactor;
159SMBBytedeviceSet;
160SMBBytedeviceLocator;
161SMBBytebankLocator;
162SMBBytememoryType;
163SMBWordtypeDetail;
164 SMBWord speed;
165} __attribute__((packed)) DMIMemoryDevice;
166
167typedef struct SMBStructHeader {
168 SMBByte type;
169 SMBByte length;
170 SMBWord handle;
171}__attribute__((packed)) SMBStructHeader;
172
173#define SMB_STRUCT_HEADER SMBStructHeader header;
174
175typedef struct SMBSystemInformation {
176// 2.0+ spec (8 bytes)
177SMB_STRUCT_HEADER // Type 1
178SMBString manufacturer;
179SMBString productName;
180SMBString version;
181SMBString serialNumber;
182// 2.1+ spec (25 bytes)
183SMBByte uuid[16]; // can be all 0 or all 1's
184SMBByte wakeupReason; // reason for system wakeup
185// 2.4+ spec (27 bytes)
186 SMBString skuNumber;
187 SMBString family;
188}__attribute__((packed)) SMBSystemInformation;
189
190//
191// Base Board (Type 2)
192//
193typedef struct SMBBaseBoard {
194 SMB_STRUCT_HEADER // Type 2
195 SMBStringmanufacturer;
196 SMBStringproduct;
197 SMBStringversion;
198 SMBStringserialNumber;
199 SMBStringassetTagNumber;
200 SMBBytefeatureFlags;
201 SMBStringlocationInChassis;
202 SMBWordchassisHandle;
203 SMBByteboardType;
204 SMBBytenumberOfContainedHandles;
205// 0 - 255 contained handles go here but we do not include
206// them in our structure. Be careful to use numberOfContainedHandles
207// times sizeof(SMBWord) when computing the actual record size,
208// if you need it.
209} __attribute__((packed)) SMBBaseBoard;
210
211#endif /* !_LIBSAIO_SMBIOS_H */
212

Archive Download this file

Revision: 1119