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

Archive Download this file

Revision: HEAD