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