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"␉␊ |
34 | extern struct SMBEntryPoint *getSmbiosOriginal();␊ |
35 | ␊ |
36 | #define theUUID 0␊ |
37 | #define thePlatformName 1␊ |
38 | #define theProducBoard 2␊ |
39 | extern int readSMBIOS(int value); // value copied into the platform structure␊ |
40 | ␊ |
41 | #define SMBIOS_RANGE_START␉␉0x000F0000␊ |
42 | #define SMBIOS_RANGE_END␉␉0x000FFFFF␊ |
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 | ␊ |
55 | enum {␊ |
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 | ␊ |
82 | typedef uint8_t␉␉SMBString;␊ |
83 | typedef uint8_t␉␉SMBByte;␊ |
84 | typedef uint16_t␉SMBWord;␊ |
85 | typedef uint32_t␉SMBDWord;␊ |
86 | typedef uint64_t␉SMBQWord;␊ |
87 | ␊ |
88 | typedef struct DMIHeader {␊ |
89 | ␉SMBByte␉␉␉type;␊ |
90 | ␉SMBByte␉␉␉length;␊ |
91 | ␉SMBWord␉␉␉handle;␊ |
92 | } __attribute__((packed)) DMIHeader;␊ |
93 | ␊ |
94 | #define DMI_STRUCT_HEADER DMIHeader dmiHeader;␊ |
95 | ␊ |
96 | typedef struct DMIEntryPoint {␊ |
97 | ␉SMBByte␉␉␉anchor[5];␊ |
98 | ␉SMBByte␉␉␉checksum;␊ |
99 | ␉SMBWord␉␉␉tableLength;␊ |
100 | ␉SMBDWord␉␉tableAddress;␊ |
101 | ␉SMBWord␉␉␉structureCount;␊ |
102 | ␉SMBByte␉␉␉bcdRevision;␊ |
103 | } __attribute__((packed)) DMIEntryPoint;␊ |
104 | ␊ |
105 | typedef struct SMBEntryPoint {␊ |
106 | ␉SMBByte␉␉␉anchor[4];␊ |
107 | ␉SMBByte␉␉␉checksum;␊ |
108 | ␉SMBByte␉␉␉entryPointLength;␊ |
109 | ␉SMBByte␉␉␉majorVersion;␊ |
110 | ␉SMBByte␉␉␉minorVersion;␊ |
111 | ␉SMBWord␉␉␉maxStructureSize;␊ |
112 | ␉SMBByte␉␉␉entryPointRevision;␊ |
113 | ␉SMBByte␉␉␉formattedArea[5];␊ |
114 | ␉struct DMIEntryPoint␉dmi;␊ |
115 | } __attribute__((packed)) SMBEntryPoint;␊ |
116 | ␊ |
117 | typedef struct DMIMemoryControllerInfo {/* 3.3.6 Memory Controller Information (Type 5) */␊ |
118 | ␉DMI_STRUCT_HEADER␊ |
119 | ␉SMBByte␉␉␉errorDetectingMethod;␊ |
120 | ␉SMBByte␉␉␉errorCorrectingCapability;␊ |
121 | ␉SMBByte␉␉␉supportedInterleave;␊ |
122 | ␉SMBByte␉␉␉currentInterleave;␊ |
123 | ␉SMBByte␉␉␉maxMemoryModuleSize;␊ |
124 | ␉SMBWord␉␉␉supportedSpeeds;␊ |
125 | ␉SMBWord␉␉␉supportedMemoryTypes;␊ |
126 | ␉SMBByte␉␉␉memoryModuleVoltage;␊ |
127 | ␉SMBByte␉␉␉numberOfMemorySlots;␊ |
128 | } __attribute__((packed)) DMIMemoryControllerInfo;␊ |
129 | ␊ |
130 | typedef struct DMIMemoryModuleInfo {␉/* 3.3.7 Memory Module Information (Type 6) */␊ |
131 | ␉DMI_STRUCT_HEADER␊ |
132 | ␉SMBByte␉␉␉socketDesignation;␊ |
133 | ␉SMBByte␉␉␉bankConnections;␊ |
134 | ␉SMBByte␉␉␉currentSpeed;␊ |
135 | ␉SMBWord␉␉␉currentMemoryType;␊ |
136 | ␉SMBByte␉␉␉installedSize;␊ |
137 | ␉SMBByte␉␉␉enabledSize;␊ |
138 | ␉SMBByte␉␉␉errorStatus;␊ |
139 | } __attribute__((packed)) DMIMemoryModuleInfo;␊ |
140 | ␊ |
141 | typedef struct DMIPhysicalMemoryArray {␉/* 3.3.17 Physical Memory Array (Type 16) */␊ |
142 | ␉DMI_STRUCT_HEADER␊ |
143 | ␉SMBByte␉␉␉location;␊ |
144 | ␉SMBByte␉␉␉use;␊ |
145 | ␉SMBByte␉␉␉memoryCorrectionError;␊ |
146 | ␉SMBDWord␉␉maximumCapacity;␊ |
147 | ␉SMBWord␉␉␉memoryErrorInformationHandle;␊ |
148 | ␉SMBWord␉␉␉numberOfMemoryDevices;␊ |
149 | } __attribute__((packed)) DMIPhysicalMemoryArray;␊ |
150 | ␊ |
151 | typedef struct DMIMemoryDevice {␉/* 3.3.18 Memory Device (Type 17) */␊ |
152 | ␉DMI_STRUCT_HEADER␊ |
153 | ␉SMBWord␉␉␉physicalMemoryArrayHandle;␊ |
154 | ␉SMBWord␉␉␉memoryErrorInformationHandle;␊ |
155 | ␉SMBWord␉␉␉totalWidth;␊ |
156 | ␉SMBWord␉␉␉dataWidth;␊ |
157 | ␉SMBWord␉␉␉size;␊ |
158 | ␉SMBByte␉␉␉formFactor;␊ |
159 | ␉SMBByte␉␉␉deviceSet;␊ |
160 | ␉SMBByte␉␉␉deviceLocator;␊ |
161 | ␉SMBByte␉␉␉bankLocator;␊ |
162 | ␉SMBByte␉␉␉memoryType;␊ |
163 | ␉SMBWord␉␉␉typeDetail;␊ |
164 | SMBWord speed;␊ |
165 | } __attribute__((packed)) DMIMemoryDevice;␊ |
166 | ␊ |
167 | typedef struct SMBStructHeader {␊ |
168 | SMBByte type;␊ |
169 | SMBByte length;␊ |
170 | SMBWord handle;␊ |
171 | }__attribute__((packed)) SMBStructHeader;␊ |
172 | ␊ |
173 | #define SMB_STRUCT_HEADER SMBStructHeader header;␊ |
174 | ␊ |
175 | typedef struct SMBSystemInformation {␊ |
176 | ␉// 2.0+ spec (8 bytes)␊ |
177 | ␉SMB_STRUCT_HEADER // Type 1␊ |
178 | ␉SMBString manufacturer;␊ |
179 | ␉SMBString productName;␊ |
180 | ␉SMBString version;␊ |
181 | ␉SMBString serialNumber;␊ |
182 | ␉// 2.1+ spec (25 bytes)␊ |
183 | ␉SMBByte uuid[16]; // can be all 0 or all 1's␊ |
184 | ␉SMBByte 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 | //␊ |
193 | typedef struct SMBBaseBoard {␊ |
194 | SMB_STRUCT_HEADER // Type 2␊ |
195 | SMBString␉manufacturer;␊ |
196 | SMBString␉product;␊ |
197 | SMBString␉version;␊ |
198 | SMBString␉serialNumber;␊ |
199 | SMBString␉assetTagNumber;␊ |
200 | SMBByte␉␉featureFlags;␊ |
201 | SMBString␉locationInChassis;␊ |
202 | SMBWord␉␉chassisHandle;␊ |
203 | SMBByte␉␉boardType;␊ |
204 | SMBByte␉␉numberOfContainedHandles;␊ |
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 | |