1 | /*␊ |
2 | * SMBIOS Table Patcher, part of the Chameleon Boot Loader Project␊ |
3 | *␊ |
4 | * Copyright 2010 by Islam M. Ahmed Zaid. All rights reserved.␊ |
5 | *␊ |
6 | */␊ |
7 | ␊ |
8 | #include "config.h"␊ |
9 | #include "boot.h"␊ |
10 | #include "bootstruct.h"␊ |
11 | #include "smbios_getters.h"␊ |
12 | // Bungo␊ |
13 | #include "convert.h"␊ |
14 | ␊ |
15 | #if DEBUG_SMBIOS␊ |
16 | #define DBG(x...)␉printf(x)␊ |
17 | #else␊ |
18 | #define DBG(x...)␉msglog(x)␊ |
19 | #endif␊ |
20 | ␊ |
21 | #define SMBPlist␉␉␉&bootInfo->smbiosConfig␊ |
22 | /* ASSUMPTION: 16KB should be enough for the whole thing */␊ |
23 | #define SMB_ALLOC_SIZE␉16384␊ |
24 | ␊ |
25 | ␊ |
26 | //-------------------------------------------------------------------------------------------------------------------------␊ |
27 | // SMBIOS Plist Keys␊ |
28 | //-------------------------------------------------------------------------------------------------------------------------␊ |
29 | ␊ |
30 | /* =======================␊ |
31 | BIOS Information (Type 0)␊ |
32 | ========================= */␊ |
33 | #define kSMBBIOSInformationVendorKey␉␉␉"SMbiosvendor"␉␉// Apple Inc.␊ |
34 | #define kSMBBIOSInformationVersionKey␉␉␉"SMbiosversion"␉␉// MP31.88Z.006C.B05.0802291410␊ |
35 | #define kSMBBIOSInformationReleaseDateKey␉␉"SMbiosdate"␉␉// 02/29/08␊ |
36 | // Bungo␊ |
37 | #define kSMBBIOSInformationReleaseKey␉␉␉"SMbiosrelease"␉␉// BIOS Revision␊ |
38 | // example: BIOS Revision: 1.23 --> 2 bytes: Major=0x01, Minor=0x17 --> after swap: 0x1701hex = 5889dec (SMBIOS_spec_DSP0134_2.7.1)␊ |
39 | ␊ |
40 | /* =========================␊ |
41 | System Information (Type 1)␊ |
42 | =========================== */␊ |
43 | #define kSMBSystemInformationManufacturerKey␉␉"SMmanufacturer"␉// Apple Inc.␊ |
44 | #define kSMBSystemInformationProductNameKey␉␉"SMproductname"␉␉// MacPro3,1␊ |
45 | #define kSMBSystemInformationVersionKey␉␉␉"SMsystemversion"␉// 1.0␊ |
46 | #define kSMBSystemInformationSerialNumberKey␉␉"SMserial"␉␉// Serial number␊ |
47 | //Bungo␊ |
48 | #define kSMBSystemInformationUUIDKey␉␉␉"SMsystemuuid"␉␉// ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'␊ |
49 | #define kSMBSystemInformationSKUNumberKey␉␉"SMskunumber"␉␉// System SKU#␊ |
50 | ␊ |
51 | #define kSMBSystemInformationFamilyKey␉␉␉"SMfamily"␉␉// MacPro␊ |
52 | ␊ |
53 | /* =========================================␊ |
54 | Base Board (or Module) Information (Type 2)␊ |
55 | =========================================== */␊ |
56 | #define kSMBBaseBoardManufacturerKey␉␉␉"SMboardmanufacturer"␉// Apple Inc.␊ |
57 | #define kSMBBaseBoardProductKey␉␉␉␉"SMboardproduct"␉// Mac-F2268DC8␊ |
58 | // Bungo␊ |
59 | #define kSMBBaseBoardVersionKey␉␉␉␉"SMboardversion"␉// MacPro3,1␊ |
60 | #define kSMBBaseBoardSerialNumberKey␉␉␉"SMboardserial"␉␉// C02140302D5DMT31M␊ |
61 | #define kSMBBaseBoardAssetTagKey␉␉␉"SMboardassettag"␉// Base Board Asset Tag# Bungo: renamed folowing convention␊ |
62 | #define kSMBBaseBoardLocationInChassisKey␉␉"SMboardlocation"␉// Part Component␊ |
63 | ␊ |
64 | // ErmaC BoardType 0x0a(10) or 0x0b(11) MacPro Family␊ |
65 | #define kSMBBaseBoardTypeKey␉␉␉␉"SMboardtype"␉␉// 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro␊ |
66 | ␊ |
67 | // Bungo␊ |
68 | /* =======================␊ |
69 | System Enclosure (Type 3)␊ |
70 | ========================= */␊ |
71 | #define kSMBSystemEnclosureManufacturerKey␉␉"SMchassismanufacturer"␉// Apple Inc.␊ |
72 | #define kSMBSystemEnclosureTypeKey␉␉␉"SMchassistype"␉␉// 7 Desktop␊ |
73 | #define kSMBSystemEnclosureVersionKey␉␉␉"SMchassisversion"␉// Mac-F42C88C8␊ |
74 | #define kSMBSystemEnclosureSerialNumberKey␉␉"SMchassisserial"␉// Serial number␊ |
75 | #define kSMBSystemEnclosureAssetTagKey␉␉␉"SMchassisassettag"␉// Pro-Enclosure Bungo: renamed folowing convention␊ |
76 | ␊ |
77 | /* ============================␊ |
78 | Processor Information (Type 4)␊ |
79 | ============================== */␊ |
80 | // Bungo␊ |
81 | #define kSMBProcessorInformationSocketKey␉␉"SMcpusocket"␊ |
82 | #define kSMBProcessorInformationManufacturerKey␉␉"SMcpumanufacturer"␊ |
83 | #define kSMBProcessorInformationVersionKey␉␉"SMcpuversion"␊ |
84 | //␊ |
85 | #define kSMBProcessorInformationExternalClockKey␉"SMexternalclock"␊ |
86 | #define kSMBProcessorInformationMaximumClockKey␉␉"SMmaximalclock"␊ |
87 | // Bungo␊ |
88 | #define kSMBProcessorInformationCurrentClockKey␉␉"SMcurrentclock"␊ |
89 | #define kSMBProcessorInformationUpgradeKey␉␉"SMcpuupgrade"␊ |
90 | #define kSMBProcessorInformationSerialNumberKey␉␉"SMcpuserial"␊ |
91 | #define kSMBProcessorInformationAssetTagKey␉␉"SMcpuassettag"␉␉// Bungo: renamed folowing convention␊ |
92 | #define kSMBProcessorInformationPartNumberKey␉␉"SMcpupartnumber"␊ |
93 | ␊ |
94 | /* =====================␊ |
95 | Memory Device (Type 17)␊ |
96 | ======================= */␊ |
97 | #define kSMBMemoryDeviceDeviceLocatorKey␉␉"SMmemdevloc" //␊ |
98 | #define kSMBMemoryDeviceBankLocatorKey␉␉␉"SMmembankloc" //␊ |
99 | #define kSMBMemoryDeviceMemoryTypeKey␉␉␉"SMmemtype" //␊ |
100 | #define kSMBMemoryDeviceMemorySpeedKey␉␉␉"SMmemspeed" //␊ |
101 | #define kSMBMemoryDeviceManufacturerKey␉␉␉"SMmemmanufacturer" //␊ |
102 | #define kSMBMemoryDeviceSerialNumberKey␉␉␉"SMmemserial" //␊ |
103 | #define kSMBMemoryDevicePartNumberKey␉␉␉"SMmempart" //␊ |
104 | // Bungo:␊ |
105 | #define kSMBMemoryDeviceAssetTagKey␉␉␉"SMmemassettag" //␊ |
106 | ␊ |
107 | /* ===========================================␊ |
108 | Memory SPD Data (Apple Specific - Type 130)␊ |
109 | ============================================= */␊ |
110 | ␊ |
111 | /* ============================================␊ |
112 | OEM Processor Type (Apple Specific - Type 131)␊ |
113 | ============================================== */␊ |
114 | #define kSMBOemProcessorTypeKey␉␉␉␉"SMoemcputype"␉␉// Bungo: renamed from SMcputype␊ |
115 | ␊ |
116 | /* =================================================␊ |
117 | OEM Processor Bus Speed (Apple Specific - Type 132)␊ |
118 | =================================================== */␊ |
119 | #define kSMBOemProcessorBusSpeedKey␉␉␉"SMoemcpubusspeed"␉// Bungo: renamed from SMbusspeed␊ |
120 | ␊ |
121 | /* ==============================================␊ |
122 | OEM Platform Feature (Apple Specific - Type 133)␊ |
123 | ================================================ */␊ |
124 | //#define kSMBOemPlatformFeatureKey␉␉␉"SMoemplatformfeature"␊ |
125 | ␊ |
126 | /* ==================================================*/␊ |
127 | #define getFieldOffset(struct, field)␉((uint8_t)(uint32_t)&(((struct *)0)->field))␊ |
128 | ␊ |
129 | typedef struct␊ |
130 | {␊ |
131 | ␉SMBStructHeader *orig;␊ |
132 | ␉SMBStructHeader *new;␊ |
133 | } SMBStructPtrs;␊ |
134 | ␊ |
135 | /* =======================␊ |
136 | BIOS Information (Type 0)␊ |
137 | ========================= */␊ |
138 | typedef struct␊ |
139 | {␊ |
140 | ␉char *vendor;␊ |
141 | ␉char *version;␊ |
142 | ␉char *releaseDate;␊ |
143 | ␉uint16_t release; // Bungo␊ |
144 | } defaultBIOSInfo_t;␊ |
145 | ␊ |
146 | defaultBIOSInfo_t defaultBIOSInfo;␊ |
147 | ␊ |
148 | /* =========================␊ |
149 | System Information (Type 1)␊ |
150 | =========================== */␊ |
151 | typedef struct␊ |
152 | {␊ |
153 | ␉char *manufacturer;␊ |
154 | ␉char *productName;␊ |
155 | ␉char *version;␊ |
156 | ␉char *serialNumber;␊ |
157 | ␉char *skuNumber;␉// ErmaC␊ |
158 | ␉char *family;␊ |
159 | } defaultSystemInfo_t;␊ |
160 | ␊ |
161 | defaultSystemInfo_t defaultSystemInfo;␊ |
162 | ␊ |
163 | /* =========================================␊ |
164 | Base Board (or Module) Information (Type 2)␊ |
165 | =========================================== */␊ |
166 | typedef struct␊ |
167 | {␊ |
168 | ␉char *manufacturer;␊ |
169 | ␉char *product;␊ |
170 | ␉char *version;␉␉␉// Bungo␊ |
171 | ␉char *serialNumber;␉␉// ErmaC␊ |
172 | ␉char *assetTag;␉␉␉// ErmaC Bungo: renamed folowing convention␊ |
173 | ␉char *locationInChassis;␉// ErmaC␊ |
174 | ␉uint8_t boardType;␉␉// ErmaC␊ |
175 | } defaultBaseBoard_t;␊ |
176 | ␊ |
177 | defaultBaseBoard_t defaultBaseBoard;␊ |
178 | ␊ |
179 | // Bungo␊ |
180 | typedef struct {␊ |
181 | ␉char␉␉*manufacturer;␊ |
182 | ␉uint8_t␉␉chassisType;␊ |
183 | ␉char␉␉*version;␊ |
184 | ␉char␉␉*serialNumber;␊ |
185 | ␉char␉␉*assetTag;␊ |
186 | ␉char␉␉*skuNumber;␊ |
187 | } defaultChassis_t;␊ |
188 | ␊ |
189 | defaultChassis_t defaultChassis;␊ |
190 | ␊ |
191 | typedef struct␊ |
192 | {␊ |
193 | ␉uint8_t␉␉␉type;␊ |
194 | ␉SMBValueType␉␉valueType;␊ |
195 | ␉uint8_t␉␉␉fieldOffset;␊ |
196 | ␉char␉␉␉*keyString;␊ |
197 | ␉bool␉␉␉(*getSMBValue)(returnType *);␊ |
198 | ␉char␉␉␉**defaultValue;␊ |
199 | } SMBValueSetter;␊ |
200 | ␊ |
201 | SMBValueSetter SMBSetters[] = ␊ |
202 | {␊ |
203 | ␉/* =======================␊ |
204 | ␉ BIOS Information (Type 0)␊ |
205 | ␉ ========================= */␊ |
206 | ␉{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, vendor),␊ |
207 | ␉␉kSMBBIOSInformationVendorKey, NULL, &defaultBIOSInfo.vendor },␉␉␉␉// SMbiosvendor - Apple Inc.␊ |
208 | ␊ |
209 | ␉{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, version),␊ |
210 | ␉␉kSMBBIOSInformationVersionKey, NULL, &defaultBIOSInfo.version },␉␉␉// SMbiosversion - MP31.88Z.006C.B05.0802291410␊ |
211 | ␊ |
212 | ␉{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, releaseDate),␊ |
213 | ␉␉kSMBBIOSInformationReleaseDateKey, NULL, &defaultBIOSInfo.releaseDate },␉␉// SMbiosdate - 02/29/08␊ |
214 | ␊ |
215 | ␉// Bungo␊ |
216 | ␉{ kSMBTypeBIOSInformation, kSMBWord, getFieldOffset(SMBBIOSInformation, releaseMajor),␊ |
217 | ␉␉kSMBBIOSInformationReleaseKey, NULL,␉(char **)&defaultBIOSInfo.release },␉␉// SMbiosrelease - 0.1 (256)␊ |
218 | ␊ |
219 | ␉/* =========================␊ |
220 | ␉ System Information (Type 1)␊ |
221 | ␉ =========================== */␊ |
222 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, manufacturer),␊ |
223 | ␉␉kSMBSystemInformationManufacturerKey, NULL,␉&defaultSystemInfo.manufacturer␉},␉// SMmanufacturer - Apple Inc.␊ |
224 | ␊ |
225 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, productName),␊ |
226 | ␉␉kSMBSystemInformationProductNameKey, NULL, &defaultSystemInfo.productName },␉␉// SMproductname - MacPro3,1␊ |
227 | ␊ |
228 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, version),␊ |
229 | ␉␉kSMBSystemInformationVersionKey, NULL, &defaultSystemInfo.version },␉␉␉// SMsystemversion - 1.0␊ |
230 | ␊ |
231 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, serialNumber),␊ |
232 | ␉␉kSMBSystemInformationSerialNumberKey, NULL, &defaultSystemInfo.serialNumber },␉␉// SMserial - Serial number␊ |
233 | ␉/* Bungo:␊ |
234 | ␉{kSMBTypeSystemInformation,␉kSMBByte,␉getFieldOffset(SMBSystemInformation, uuid),␊ |
235 | ␉␉kSMBSystemInformationUUIDKey, NULL, NULL},␉␉␉␉␉␉// SMsystemuuid␊ |
236 | ␊ |
237 | ␉{kSMBTypeSystemInformation,␉kSMBByte,␉getFieldOffset(SMBSystemInformation, wakeupReason),␊ |
238 | ␉␉NULL, NULL, NULL},␉␉␉␉␉␉␉␉␉// reason for system wakeup␊ |
239 | ␉*/␊ |
240 | ␊ |
241 | ␉// Bungo␊ |
242 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, skuNumber),␊ |
243 | ␉␉kSMBSystemInformationSKUNumberKey, NULL, &defaultSystemInfo.skuNumber},␉␉␉// SMskunumber - System SKU#␊ |
244 | ␊ |
245 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, family),␊ |
246 | ␉␉kSMBSystemInformationFamilyKey,␉NULL,␉&defaultSystemInfo.family},␉␉␉// SMfamily - MacPro␊ |
247 | ␊ |
248 | ␊ |
249 | ␉/* =========================================␊ |
250 | ␉ Base Board (or Module) Information (Type 2)␊ |
251 | ␉ =========================================== */␊ |
252 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, manufacturer),␊ |
253 | ␉␉kSMBBaseBoardManufacturerKey, NULL, &defaultBaseBoard.manufacturer },␉␉␉// SMboardmanufacturer - Apple Inc.␊ |
254 | ␊ |
255 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, product),␊ |
256 | ␉␉kSMBBaseBoardProductKey, NULL, &defaultBaseBoard.product },␉␉␉␉// SMboardproduct - Mac-F2268DC8␊ |
257 | ␊ |
258 | ␉// Bungo␊ |
259 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, version),␊ |
260 | ␉␉kSMBBaseBoardVersionKey, NULL, &defaultBaseBoard.version },␉␉␉␉// SMboardversion - MacPro3,1␊ |
261 | ␊ |
262 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, serialNumber),␊ |
263 | ␉␉kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber },␉␉␉// SMboardserial - C02140302D5DMT31M␊ |
264 | ␊ |
265 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, assetTag),␊ |
266 | ␉␉kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag },␉␉␉␉// SMboardassettag - Base Board Asset Tag#␊ |
267 | ␊ |
268 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, locationInChassis),␊ |
269 | ␉␉kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis },␉␉// SMboardlocation - Part Component␊ |
270 | ␊ |
271 | ␉{kSMBTypeBaseBoard,␉kSMBByte,␉getFieldOffset(SMBBaseBoard, boardType),␊ |
272 | ␉␉kSMBBaseBoardTypeKey,␉NULL, (char **)&defaultBaseBoard.boardType },␉␉␉// SMboardtype - 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro␊ |
273 | ␊ |
274 | /*␉{kSMBTypeBaseBoard,␉kSMBByte, getFieldOffset(SMBBaseBoard, numberOfContainedHandles),␊ |
275 | ␉␉NULL , NULL, NULL },␉␉␉␉␉␉␉␉␉// numberOfContainedHandles = 0␊ |
276 | */␊ |
277 | ␉//␊ |
278 | ␊ |
279 | ␉// Bungo␊ |
280 | ␉/* =======================␊ |
281 | ␉ System Enclosure (Type 3)␊ |
282 | ␉ ========================= */␊ |
283 | ␉{kSMBTypeSystemEnclosure,␉kSMBString,␉getFieldOffset(SMBSystemEnclosure, manufacturer),␊ |
284 | ␉␉kSMBSystemEnclosureManufacturerKey, NULL,␉&defaultChassis.manufacturer },␉␉// SMchassismanufacturer - Apple Inc.␊ |
285 | ␊ |
286 | ␉{kSMBTypeSystemEnclosure, kSMBByte,␉getFieldOffset(SMBSystemEnclosure, chassisType),␊ |
287 | ␉␉kSMBSystemEnclosureTypeKey, NULL, (char **)&defaultChassis.chassisType␉},␉␉// SMchassistype - 7␊ |
288 | ␊ |
289 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, version),␊ |
290 | ␉␉kSMBSystemEnclosureVersionKey, NULL, &defaultChassis.version },␉␉␉␉// SMchassisversion - Mac-F42C88C8␊ |
291 | ␊ |
292 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, serialNumber),␊ |
293 | ␉␉kSMBSystemEnclosureSerialNumberKey, NULL, &defaultChassis.serialNumber },␉␉// SMchassisserial␊ |
294 | ␊ |
295 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, assetTag),␊ |
296 | ␉␉kSMBSystemEnclosureAssetTagKey, NULL, &defaultChassis.assetTag },␉␉␉// SMchassisassettag - Pro Enclosure␊ |
297 | ␊ |
298 | ␉/*␊ |
299 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, skuNumber),␊ |
300 | ␉␉NULL, NULL, &defaultChassis.skuNumber },␊ |
301 | ␉*/␊ |
302 | ␊ |
303 | ␉/* ============================␊ |
304 | ␉ Processor Information (Type 4)␊ |
305 | ␉ ============================== */␊ |
306 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, socketDesignation),␊ |
307 | ␉␉kSMBProcessorInformationSocketKey, NULL, NULL},␉␉␉␉␉␉// SMcpusocket -␊ |
308 | ␊ |
309 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, manufacturer),␊ |
310 | ␉␉kSMBProcessorInformationManufacturerKey, NULL, NULL},␉␉␉␉␉// SMcpumanufacturer - Intel(R) Corporation␊ |
311 | ␊ |
312 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, processorVersion),␊ |
313 | ␉␉kSMBProcessorInformationVersionKey, NULL, NULL},␉␉␉␉␉// SMcpuversion␊ |
314 | ␊ |
315 | ␉{kSMBTypeProcessorInformation,␉kSMBWord, getFieldOffset(SMBProcessorInformation, externalClock),␊ |
316 | ␉␉kSMBProcessorInformationExternalClockKey, getProcessorInformationExternalClock,␉NULL},␉// SMcpuexternalclock␊ |
317 | ␊ |
318 | ␉{kSMBTypeProcessorInformation,␉kSMBWord, getFieldOffset(SMBProcessorInformation, maximumClock),␊ |
319 | ␉␉kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock,␉NULL},␉// SMcpumaximumclock␊ |
320 | ␉// Bungo␊ |
321 | ␉{kSMBTypeProcessorInformation,␉kSMBWord,␉getFieldOffset(SMBProcessorInformation, currentClock),␊ |
322 | ␉␉kSMBProcessorInformationCurrentClockKey, NULL, NULL},␉␉␉␉␉// SMcpucurrentclock␊ |
323 | ␊ |
324 | ␉{kSMBTypeProcessorInformation,␉kSMBByte,␉getFieldOffset(SMBProcessorInformation, processorUpgrade),␊ |
325 | ␉␉kSMBProcessorInformationUpgradeKey, NULL, NULL},␉␉␉␉␉// SMcpuupgrade␊ |
326 | ␉//␊ |
327 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, serialNumber),␊ |
328 | ␉␉kSMBProcessorInformationSerialNumberKey, NULL, NULL},␊ |
329 | ␊ |
330 | ␉// Bungo␊ |
331 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, assetTag),␊ |
332 | ␉␉kSMBProcessorInformationAssetTagKey, NULL, NULL},␉␉␉␉␉// SMcpuassettag␊ |
333 | ␉//␊ |
334 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, partNumber),␊ |
335 | ␉␉kSMBProcessorInformationPartNumberKey, NULL, NULL},␊ |
336 | ␊ |
337 | ␉/* =====================␊ |
338 | ␉ Memory Device (Type 17)␊ |
339 | ␉ ======================= */␊ |
340 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, deviceLocator),␊ |
341 | ␉␉kSMBMemoryDeviceDeviceLocatorKey, NULL, NULL},␊ |
342 | ␊ |
343 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, bankLocator),␊ |
344 | ␉␉kSMBMemoryDeviceBankLocatorKey, NULL, NULL},␊ |
345 | ␊ |
346 | ␉{kSMBTypeMemoryDevice,␉kSMBByte,␉getFieldOffset(SMBMemoryDevice, memoryType),␊ |
347 | ␉␉kSMBMemoryDeviceMemoryTypeKey, getSMBMemoryDeviceMemoryType,␉NULL},␊ |
348 | ␊ |
349 | ␉{kSMBTypeMemoryDevice,␉kSMBWord,␉getFieldOffset(SMBMemoryDevice, memorySpeed),␊ |
350 | ␉␉kSMBMemoryDeviceMemorySpeedKey, getSMBMemoryDeviceMemorySpeed,␉NULL},␊ |
351 | ␊ |
352 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, manufacturer),␊ |
353 | ␉␉kSMBMemoryDeviceManufacturerKey, getSMBMemoryDeviceManufacturer, NULL},␊ |
354 | ␊ |
355 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, serialNumber),␊ |
356 | ␉␉kSMBMemoryDeviceSerialNumberKey, getSMBMemoryDeviceSerialNumber, NULL},␊ |
357 | ␊ |
358 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, assetTag),␊ |
359 | ␉␉kSMBMemoryDeviceAssetTagKey, NULL, NULL},␊ |
360 | ␊ |
361 | ␉{kSMBTypeMemoryDevice,␉kSMBWord,␉getFieldOffset(SMBMemoryDevice, errorHandle),␊ |
362 | ␉␉NULL, getSMBMemoryDeviceMemoryErrorHandle, NULL},␊ |
363 | ␊ |
364 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, partNumber),␊ |
365 | ␉␉kSMBMemoryDevicePartNumberKey, getSMBMemoryDevicePartNumber, NULL},␊ |
366 | ␊ |
367 | ␉/* ============␊ |
368 | ␉ Apple Specific␊ |
369 | ␉ ============== */␊ |
370 | ␊ |
371 | ␉// OEM Processor Type (Apple Specific - Type 131)␊ |
372 | ␉{kSMBTypeOemProcessorType,␉kSMBWord,␉getFieldOffset(SMBOemProcessorType, ProcessorType),␉kSMBOemProcessorTypeKey,␉␉␊ |
373 | ␉␉getSMBOemProcessorType,␉␉␉NULL},␊ |
374 | ␊ |
375 | ␉// OEM Processor Bus Speed (Apple Specific - Type 132)␊ |
376 | ␉{kSMBTypeOemProcessorBusSpeed,␉kSMBWord,␉getFieldOffset(SMBOemProcessorBusSpeed, ProcessorBusSpeed),␉kSMBOemProcessorBusSpeedKey,␉␊ |
377 | ␉␉getSMBOemProcessorBusSpeed,␉NULL}␊ |
378 | ␊ |
379 | ␉// OEM Platform Feature (Apple Specific - Type 133)␊ |
380 | ␉/*␊ |
381 | ␉{kSMBTypeOemPlatformFeature,␉kSMBWord,␉getFieldOffset(SMBOemPlatformFeature, PlatformFeature),␉kSMBOemPlatformFeatureKey,␊ |
382 | ␉␉getSMBOemPlatformFeature,␉NULL}␊ |
383 | ␉*/␊ |
384 | };␊ |
385 | ␊ |
386 | int numOfSetters = sizeof(SMBSetters) / sizeof(SMBValueSetter);␊ |
387 | ␊ |
388 | ␊ |
389 | SMBEntryPoint *origeps␉␉= 0;␊ |
390 | SMBEntryPoint *neweps␉␉= 0;␊ |
391 | ␊ |
392 | static uint8_t stringIndex;␉// increament when a string is added and set the field value accordingly␊ |
393 | static uint8_t stringsSize;␉// add string size␊ |
394 | ␊ |
395 | static SMBWord tableLength␉= 0;␊ |
396 | static SMBWord handle␉␉= 0;␊ |
397 | static SMBWord maxStructSize␉= 0;␊ |
398 | static SMBWord structureCount␉= 0;␊ |
399 | ␊ |
400 | //-------------------------------------------------------------------------------------------------------------------------␊ |
401 | // Default SMBIOS Data␊ |
402 | //-------------------------------------------------------------------------------------------------------------------------␊ |
403 | /* Rewrite: use a struct */␊ |
404 | ␊ |
405 | // Bungo: suggest to not mixing data from different Mac models, use real Mac SMBIOS dumps␊ |
406 | ␊ |
407 | #define kDefaultVendorManufacturer␉␉␉"Apple Inc."␊ |
408 | //#define kDefaultBIOSReleaseDate␉␉␉"11/06/2009"␊ |
409 | #define kDefaultSerialNumber␉␉␉␉"SOMESRLNMBR"␊ |
410 | //Bungo␊ |
411 | #define kDefaultSkuNumber␉␉␉␉"Default SKU#"␊ |
412 | #define kDefaultAssetTag␉␉␉␉"Default Asset Tag#"␊ |
413 | //#define kDefaultBoardType␉␉␉␉"10" // 0xA␊ |
414 | //#define kDefaultBoardProcessorType␉␉␉"11" // 0xB␊ |
415 | #define kDefaultSystemVersion␉␉␉␉"1.0"␊ |
416 | #define kDefaultBIOSRelease␉␉␉␉256 // 256 = 0x0100 -> swap bytes: 0x0001 -> Release: 0.1 (see SMBIOS spec. table Type 0)␊ |
417 | //#define kDefaultLocatioInChassis␉␉␉"Part Component"␊ |
418 | //#define KDefaultBoardSerialNumber␉␉␉"C02140302D5DMT31M" // new C07019501PLDCVHAD - C02032101R5DC771H␊ |
419 | ␊ |
420 | //=========== Mac mini ===========␊ |
421 | #define kDefaultMacMiniFamily␉␉␉␉"Napa Mac" // Macmini2,1 family = "Napa Mac" not "Mac mini"␊ |
422 | //#define kDefaultMacMiniBoardAssetTagNumber␉␉"Mini-Aluminum"␊ |
423 | ␊ |
424 | #define kDefaultMacMini␉␉␉␉␉"Macmini2,1"␊ |
425 | #define kDefaultMacMiniBIOSVersion␉␉␉" MM21.88Z.009A.B00.0706281359"␊ |
426 | #define kDefaultMacMiniBIOSReleaseDate␉␉␉"06/28/07"␊ |
427 | #define kDefaultMacMiniBoardProduct␉␉␉"Mac-F4208EAA"␊ |
428 | ␊ |
429 | // MacMini5,1 Mac-8ED6AF5B48C039E1 - MM51.88Z.0077.B0F.1110201309␊ |
430 | ␊ |
431 | // MacMini5,2 Mac-4BC72D62AD45599E␊ |
432 | ␊ |
433 | // MacMini5,3␊ |
434 | // Bios: MM51.88Z.0077.B10.1201241549␊ |
435 | // Board: Mac-F65AE981FFA204ED␊ |
436 | // Data: 01/24/2012␊ |
437 | ␊ |
438 | // MacMini 6,1␊ |
439 | // Bios: MM61.88Z.0106.B03.1211161202␊ |
440 | // Board: Mac-F65AE981FFA204ED␊ |
441 | // Data: 10/14/2012␊ |
442 | ␊ |
443 | // MacMini 6,2␊ |
444 | // Bios: MM61.88Z.0106.B03.1211161202␊ |
445 | // Board: Mac-FC02E91DDD3FA6A4␊ |
446 | // Data: 10/14/2012␊ |
447 | ␊ |
448 | //=========== MacBook ===========␊ |
449 | #define kDefaultMacBookFamily␉␉␉␉"MacBook"␊ |
450 | //#define kDefaultMacBookBoardAssetTagNumber␉␉"MacBook-Black"␊ |
451 | ␊ |
452 | #define kDefaultMacBook␉␉␉␉␉"MacBook4,1"␊ |
453 | #define kDefaultMacBookBIOSVersion␉␉␉" MB41.88Z.00C1.B00.0802091535"␊ |
454 | #define kDefaultMacBookBIOSReleaseDate␉␉␉"02/09/08"␊ |
455 | #define kDefaultMacBookBoardProduct␉␉␉"Mac-F22788A9"␊ |
456 | ␊ |
457 | //=========== MacBookAir ===========␊ |
458 | #define kDefaultMacBookAirFamily␉␉␉"MacBook Air"␊ |
459 | ␊ |
460 | // MacBookAir4,1 - Mac-C08A6BB70A942AC2␊ |
461 | // MacBookAir4,2 - Mac-742912EFDBEE19B3␊ |
462 | ␊ |
463 | // MacBookAir5,2␊ |
464 | #define kDefaultMacBookAir␉␉␉␉"MacBookAir5,2"␊ |
465 | #define kDefaultMacBookAirBIOSVersion␉␉␉" MBA51.88Z.00EF.B00.1205221442"␊ |
466 | #define kDefaultMacBookAirBIOSReleaseDate␉␉"05/10/12"␊ |
467 | #define kDefaultMacBookBoardAirProduct␉␉␉"Mac-2E6FAB96566FE58C"␊ |
468 | ␊ |
469 | // MacBookAir6,1␊ |
470 | // Bios: MBA61.88Z.0099.B04.1309271229␊ |
471 | // Board: Mac-35C1E88140C3E6CF␊ |
472 | // Data: 24/06/13␊ |
473 | ␊ |
474 | // MacBookAir6,2␊ |
475 | // Bios: MBA62.88Z.00EF.B00.1205221442␊ |
476 | // Board: Mac-7DF21CB3ED6977E5␊ |
477 | // Data: 24/06/13␊ |
478 | ␊ |
479 | //=========== MacBookPro ===========␊ |
480 | #define kDefaultMacBookProFamily␉␉␉"MacBook Pro"␊ |
481 | //#define kDefaultMacBookProBoardAssetTagNumber␉␉"MacBook-Aluminum"␊ |
482 | ␊ |
483 | #define kDefaultMacBookPro␉␉␉␉"MacBookPro4,1"␊ |
484 | #define kDefaultMacBookProBIOSVersion␉␉␉" MBP41.88Z.00C1.B03.0802271651"␊ |
485 | #define kDefaultMacBookProBIOSReleaseDate␉␉"02/27/08"␊ |
486 | #define kDefaultMacBookProBoardProduct␉␉␉"Mac-F42C89C8"␊ |
487 | ␊ |
488 | // MacBookPro8,1␊ |
489 | // Bios: MBP81.88Z.0047.B24.1110141131␊ |
490 | // Board: Mac-94245B3640C91C81␊ |
491 | // Data: 10/14/11␊ |
492 | ␊ |
493 | // MacBookPro8,2␊ |
494 | // Bios:␊ |
495 | // Board: Mac_94245A3940C91C80␊ |
496 | // Data: 10/14/11␊ |
497 | ␊ |
498 | // MacBookPro8,3␊ |
499 | // Bios:␊ |
500 | // Board: Mac-942459F5819B171B␊ |
501 | // Data: 10/31/11␊ |
502 | ␊ |
503 | // MacBookPro10,2␊ |
504 | // Bios: MBP102.88Z.0106.B01.1208311637␊ |
505 | // Board: Mac-AFD8A9D944EA4843␊ |
506 | // Data: 10/02/2012␊ |
507 | ␊ |
508 | // MacBookPro11,2 - Mac-3CBD00234E554E41 - MBP112.88Z.0138.B03.1310291227␊ |
509 | // MacBookPro11,3 - Mac-2BD1B31983FE1663 - MBP112.88Z.0138.B02.1310181745␊ |
510 | ␊ |
511 | //=========== iMac ===========␊ |
512 | #define kDefaultiMacFamily␉␉␉␉"iMac"␊ |
513 | //#define kDefaultiMacBoardAssetTagNumber␉␉"iMac-Aluminum"␊ |
514 | ␊ |
515 | #define kDefaultiMac␉␉␉␉␉"iMac8,1"␊ |
516 | #define kDefaultiMacBIOSVersion␉␉␉␉" IM81.88Z.00C1.B00.0903051113"␊ |
517 | #define kDefaultiMacBIOSReleaseDate␉␉␉"02/09/08"␊ |
518 | #define kDefaultiMacBoardProduct␉␉␉"Mac-F227BEC8"␊ |
519 | #define kDefaultMacFamily␉␉␉␉"Mac" // iMac8,1 family = "Mac" not "iMac"␊ |
520 | ␊ |
521 | // iMac10,1␊ |
522 | // iMac11,1 core i3/i5/i7␊ |
523 | #define kDefaultiMacNehalem␉␉␉␉"iMac11,1"␊ |
524 | #define kDefaultiMacNehalemBIOSVersion␉␉␉" IM111.88Z.0034.B02.1003171314"␊ |
525 | #define kDefaultiMacNehalemBIOSReleaseDate␉␉"03/17/10"␊ |
526 | #define kDefaultiMacNehalemBoardProduct␉␉␉"Mac-F2268DAE"␊ |
527 | // iMac11,2␊ |
528 | // iMac11,3␊ |
529 | ␊ |
530 | // iMac12,1␊ |
531 | #define kDefaultiMacSandy␉␉␉␉"iMac12,1"␊ |
532 | #define kDefaultiMacSandyBIOSVersion␉␉␉" IM121.88Z.0047.B00.1102091756"␊ |
533 | #define kDefaultiMacSandyBIOSReleaseDate␉␉"04/22/11"␊ |
534 | #define kDefaultiMacSandyBoardProduct␉␉␉"Mac-942B5BF58194151B"␊ |
535 | ␊ |
536 | // iMac12,2␊ |
537 | // Bios: IM121.88Z.0047.B1D.1110171110"␊ |
538 | // Data: 10/17/11␊ |
539 | // Board: Mac-942B59F58194171B"␊ |
540 | ␊ |
541 | // iMac13,1␊ |
542 | // Bios: IM131.88Z.010A.B05.1211151146␊ |
543 | // Data: 11/15/2012␊ |
544 | // Board: Mac-00BE6ED71E35EB86␊ |
545 | ␊ |
546 | // iMac13,2␊ |
547 | // Bios: IM131.88Z.00CE.B00.1203281326␊ |
548 | // Data: 03/28/2012␊ |
549 | // Board: Mac-FC02E91DDD3FA6A4␊ |
550 | ␊ |
551 | // iMac14,1␊ |
552 | // iMac14,2␊ |
553 | // iMac14,3␊ |
554 | // iMac14,4␊ |
555 | // Bios: IM144.88Z.0179.B03.1405241029␊ |
556 | // Data: 05/20/2014␊ |
557 | // Board: Mac-81E3E92DD6088272␊ |
558 | ␊ |
559 | //=========== MacPro ===========␊ |
560 | #define kDefaultMacProFamily␉␉␉␉"MacPro" // MacPro's family = "MacPro" not "Mac Pro"␊ |
561 | //#define KDefauktMacProBoardAssetTagNumber␉␉"Pro-Enclosure"␊ |
562 | //#define kDefaultMacProBoardType␉␉␉"0x0B" // 11␊ |
563 | ␊ |
564 | #define kDefaultMacPro␉␉␉␉␉"MacPro3,1"␊ |
565 | #define kDefaultMacProBIOSVersion␉␉␉" MP31.88Z.006C.B05.0903051113"␊ |
566 | #define kDefaultMacProBIOSReleaseDate␉␉␉"08/03/2010"␊ |
567 | //#define kDefaultMacProSystemVersion␉␉␉"1.3"␊ |
568 | #define kDefaultMacProBoardProduct␉␉␉"Mac-F42C88C8"␊ |
569 | //#define KDefaultMacProBoardSerialNumber␉␉"J593902RA4MFE"␊ |
570 | ␊ |
571 | // Mac Pro 4,1 core i7/Xeon␊ |
572 | #define kDefaultMacProNahWestSystemVersion␉␉"0.0"␊ |
573 | ␊ |
574 | #define kDefaultMacProNehalem␉␉␉␉"MacPro4,1"␊ |
575 | #define kDefaultMacProNehalemBIOSVersion␉␉" MP41.88Z.0081.B07.0910130729"␊ |
576 | #define kDefaultMacProNehalemBIOSReleaseDate␉␉"10/13/09"␊ |
577 | //#define kDefaultMacProNehalemSystemVersion␉␉"1.4"␊ |
578 | #define kDefaultMacProNehalemBoardProduct␉␉"Mac-F221BEC8"␊ |
579 | //#define KDefaultMacProNehalemBoardSerialNumber␉"J593004RB1LUE"␊ |
580 | //␉␉␉␉␉␉␉"J591302R61LUC " // 2-cpu board␊ |
581 | //␉␉␉␉␉␉␉"J591002JV4MFB " // 1-cpu board␊ |
582 | ␊ |
583 | // Mac Pro 5,1 core i7/Xeon␊ |
584 | #define kDefaultMacProWestmere␉␉␉␉"MacPro5,1"␊ |
585 | #define kDefaultMacProWestmereBIOSVersion␉␉" MP51.88Z.007F.B03.1010071432"␊ |
586 | #define kDefaultMacProWestmereBIOSReleaseDate␉␉"10/07/10"␊ |
587 | //#define kDefaultMacProWestmereSystemVersion␉␉"1.2"␊ |
588 | #define kDefaultMacProWestmereBoardProduct␉␉"Mac-F221BEC8"␊ |
589 | //#define KDefaultMacProWestmereBoardSerialNumber␉"J522700H7BH8C"␊ |
590 | //␉␉␉␉␉␉␉"J503104H1BH8A " // 2-cpu board␊ |
591 | ␊ |
592 | // Mac Pro 6,1␊ |
593 | #define kDefaultMacProHaswell␉␉␉␉"MacPro6,1"␊ |
594 | #define kDefaultMacProHaswellBIOSVersion␉␉"MP61.88Z.0116.B04.1312061508"␊ |
595 | #define kDefaultMacProHaswellBIOSReleaseDate␉␉"12/06/2013"␊ |
596 | //#define kDefaultMacProHaswellSystemVersion␉␉"1.?"␊ |
597 | #define kDefaultMacProHaswellBoardProduct␉␉"Mac-F60DEB81FF30ACF6"␊ |
598 | //#define KDefaultMacProHaswellBoardSerialNumber␉"F5K3474008JFNN215"␊ |
599 | ␊ |
600 | //#define KDefaultBoardSerialNumber␉␉␉"C02140302D5DMT31M"␊ |
601 | // "C07019501PLDCVHAD"␊ |
602 | // "C02032101R5DC771H"␊ |
603 | ␊ |
604 | // J593902RA4MFE 3,1␊ |
605 | // J5031046RCZJA 5,1␊ |
606 | // J521101A5CZJC 3,1␊ |
607 | // J593004RB1LUE MacPro4,1␊ |
608 | // J513401PZBH8C 5,1␊ |
609 | // J590802LC4ACB 3,1␊ |
610 | // J594900AH1LUE 4,1␊ |
611 | // J512500HZBH8C 5,1␊ |
612 | // J522700H7BH8C MacPro5,1␊ |
613 | ␊ |
614 | /* ============================================ */␊ |
615 | ␊ |
616 | bool useSMBIOSdefaults = true;␉// Bungo␊ |
617 | ␊ |
618 | SMBByte PlatformType␉␉= 1;␉// Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED.␊ |
619 | ␊ |
620 | /* Rewrite this function */␊ |
621 | void setDefaultSMBData(void) // Bungo: setting data from real Macs␊ |
622 | {␊ |
623 | ␉defaultBIOSInfo.vendor = kDefaultVendorManufacturer;␊ |
624 | ␉defaultBIOSInfo.release = kDefaultBIOSRelease; // Bungo␊ |
625 | ␊ |
626 | ␉defaultSystemInfo.manufacturer = kDefaultVendorManufacturer;␊ |
627 | ␉defaultSystemInfo.version = kDefaultSystemVersion;␊ |
628 | ␉defaultSystemInfo.serialNumber = kDefaultSerialNumber;␊ |
629 | ␉defaultSystemInfo.skuNumber = kDefaultSkuNumber; // Bungo␊ |
630 | ␊ |
631 | ␉defaultBaseBoard.manufacturer = kDefaultVendorManufacturer;␊ |
632 | ␉defaultBaseBoard.serialNumber = kDefaultSerialNumber;␊ |
633 | ␉defaultBaseBoard.assetTag = kDefaultAssetTag;␊ |
634 | ␊ |
635 | ␉defaultChassis.manufacturer = kDefaultVendorManufacturer;␊ |
636 | ␉defaultChassis.serialNumber = kDefaultSerialNumber;␊ |
637 | ␉defaultChassis.assetTag = kDefaultAssetTag;␊ |
638 | ␉defaultChassis.skuNumber = kDefaultSkuNumber;␊ |
639 | ␊ |
640 | ␉// if (platformCPUFeature(CPU_FEATURE_MOBILE)) Bungo: doesn't recognise correctly, need fixing␊ |
641 | ␉if (PlatformType == 2) // this works but it's a substitute␊ |
642 | ␉{␊ |
643 | ␉␉if (Platform.CPU.NoCores > 1)␊ |
644 | ␉␉{␊ |
645 | ␉␉␉defaultSystemInfo.productName = kDefaultMacBookPro;␊ |
646 | ␉␉␉defaultBIOSInfo.version = kDefaultMacBookProBIOSVersion;␊ |
647 | ␉␉␉defaultBIOSInfo.releaseDate = kDefaultMacBookProBIOSReleaseDate;␊ |
648 | ␉␉␉defaultSystemInfo.family = kDefaultMacBookProFamily;␊ |
649 | ␉␉␉defaultBaseBoard.product = kDefaultMacBookProBoardProduct;␊ |
650 | ␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
651 | ␉␉␉defaultChassis.chassisType = kSMBchassisUnknown;␊ |
652 | ␉␉}␊ |
653 | ␉␉else␊ |
654 | ␉␉{␊ |
655 | ␉␉␉defaultSystemInfo.productName = kDefaultMacBook;␊ |
656 | ␉␉␉defaultBIOSInfo.version = kDefaultMacBookBIOSVersion;␊ |
657 | ␉␉␉defaultBIOSInfo.releaseDate = kDefaultMacBookBIOSReleaseDate;␊ |
658 | ␉␉␉defaultSystemInfo.family = kDefaultMacBookFamily;␊ |
659 | ␉␉␉defaultBaseBoard.product = kDefaultMacBookBoardProduct;␊ |
660 | ␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
661 | ␉␉␉defaultChassis.chassisType = kSMBchassisUnknown;␊ |
662 | ␉␉}␊ |
663 | ␉}␊ |
664 | ␉else␊ |
665 | ␉{␊ |
666 | ␉␉switch (Platform.CPU.NoCores)␊ |
667 | ␉␉{␊ |
668 | ␉␉␉case 1:␊ |
669 | ␉␉␉␉defaultBIOSInfo.version = kDefaultMacMiniBIOSVersion;␊ |
670 | ␉␉␉␉defaultBIOSInfo.releaseDate = kDefaultMacMiniBIOSReleaseDate;␊ |
671 | ␉␉␉␉defaultSystemInfo.productName = kDefaultMacMini;␊ |
672 | ␉␉␉␉defaultSystemInfo.family = kDefaultMacMiniFamily;␊ |
673 | ␉␉␉␉defaultBaseBoard.product = kDefaultMacMiniBoardProduct;␊ |
674 | ␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardUnknown;␊ |
675 | ␉␉␉␉defaultChassis.chassisType = kSMBchassisLPDesktop;␊ |
676 | ␉␉␉␉break;␊ |
677 | ␊ |
678 | ␉␉␉case 2:␊ |
679 | ␉␉␉␉defaultBIOSInfo.version = kDefaultiMacBIOSVersion;␊ |
680 | ␉␉␉␉defaultBIOSInfo.releaseDate = kDefaultiMacBIOSReleaseDate;␊ |
681 | ␉␉␉␉defaultSystemInfo.productName = kDefaultiMac;␊ |
682 | ␉␉␉␉defaultSystemInfo.family = kDefaultMacFamily; // iMac8,1 family = Mac␊ |
683 | ␉␉␉␉defaultBaseBoard.product = kDefaultiMacBoardProduct;␊ |
684 | ␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
685 | ␉␉␉␉defaultChassis.chassisType = kSMBchassisAllInOne;␊ |
686 | ␉␉␉␉break;␊ |
687 | ␉␉␉default:␊ |
688 | ␉␉␉{␊ |
689 | ␉␉␉␉switch (Platform.CPU.Family)␊ |
690 | ␉␉␉␉{␊ |
691 | ␉␉␉␉␉case 0x06:␊ |
692 | ␉␉␉␉␉{␊ |
693 | ␉␉␉␉␉␉switch (Platform.CPU.Model)␊ |
694 | ␉␉␉␉␉␉{␊ |
695 | ␉␉␉␉␉␉␉case CPUID_MODEL_FIELDS:␉␉// Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)␊ |
696 | ␉␉␉␉␉␉␉case CPUID_MODEL_CLARKDALE:␊ |
697 | ␉␉␉␉␉␉␉case CPUID_MODEL_DALES:␉␉// Intel Core i3, i5 LGA1156 (32nm)␊ |
698 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultiMacNehalemBIOSVersion;␊ |
699 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉␉= kDefaultiMacNehalemBIOSReleaseDate;␊ |
700 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultiMacNehalem;␊ |
701 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultiMacFamily;␊ |
702 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultiMacNehalemBoardProduct;␊ |
703 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
704 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBchassisAllInOne;␊ |
705 | ␉␉␉␉␉␉␉␉break;␊ |
706 | ␊ |
707 | ␉␉␉␉␉␉␉case CPUID_MODEL_SANDYBRIDGE:␉␉// Intel Core i3, i5, i7 LGA1155 (32nm)␊ |
708 | ␉␉␉␉␉␉␉case CPUID_MODEL_IVYBRIDGE:␉␉// Intel Core i3, i5, i7 LGA1155 (22nm)␊ |
709 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version = kDefaultiMacSandyBIOSVersion;␊ |
710 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate = kDefaultiMacSandyBIOSReleaseDate;␊ |
711 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultiMacSandy;␊ |
712 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family = kDefaultiMacFamily;␊ |
713 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultiMacSandyBoardProduct;␊ |
714 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
715 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBchassisAllInOne;␊ |
716 | ␉␉␉␉␉␉␉␉break;␊ |
717 | ␊ |
718 | ␉␉␉␉␉␉␉case CPUID_MODEL_NEHALEM:␉␉// Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm)␊ |
719 | ␉␉␉␉␉␉␉case CPUID_MODEL_NEHALEM_EX:␉␉// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x␊ |
720 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProNehalemBIOSVersion;␊ |
721 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProNehalemBIOSReleaseDate;␊ |
722 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacProNehalem;␊ |
723 | ␉␉␉␉␉␉␉␉defaultSystemInfo.version = kDefaultMacProNahWestSystemVersion;␊ |
724 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
725 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProNehalemBoardProduct;␊ |
726 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardProcessorMemoryModule;␊ |
727 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBchassisTower;␊ |
728 | ␉␉␉␉␉␉␉␉break;␊ |
729 | ␊ |
730 | ␉␉␉␉␉␉␉case CPUID_MODEL_WESTMERE:␉␉// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core␊ |
731 | ␉␉␉␉␉␉␉case CPUID_MODEL_WESTMERE_EX:␉␉// Intel Xeon E7␊ |
732 | ␉␉␉␉␉␉␉case CPUID_MODEL_JAKETOWN:␉␉// Intel Core i7, Xeon E5 LGA2011 (32nm)␊ |
733 | ␉␉␉␉␉␉␉case CPUID_MODEL_IVYBRIDGE_XEON:␉// Intel Core i7, Xeon E5 v2 LGA2011 (22nm)␊ |
734 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProWestmereBIOSVersion;␊ |
735 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProWestmereBIOSReleaseDate;␊ |
736 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacProWestmere;␊ |
737 | ␉␉␉␉␉␉␉␉defaultSystemInfo.version = kDefaultMacProNahWestSystemVersion;␊ |
738 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
739 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProWestmereBoardProduct;␊ |
740 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardProcessorMemoryModule;␊ |
741 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBchassisTower;␊ |
742 | ␉␉␉␉␉␉␉␉break;␊ |
743 | ␊ |
744 | ␉␉␉␉␉␉␉default:␊ |
745 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProBIOSVersion;␊ |
746 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProBIOSReleaseDate;␊ |
747 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacPro;␊ |
748 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
749 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProBoardProduct;␊ |
750 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
751 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBchassisUnknown;␊ |
752 | ␉␉␉␉␉␉␉␉break;␊ |
753 | ␉␉␉␉␉␉}␊ |
754 | ␉␉␉␉␉␉break;␊ |
755 | ␉␉␉␉␉}␊ |
756 | ␉␉␉␉␉default:␊ |
757 | ␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProBIOSVersion;␊ |
758 | ␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProBIOSReleaseDate;␊ |
759 | ␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacPro;␊ |
760 | ␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
761 | ␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProBoardProduct;␊ |
762 | ␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
763 | ␉␉␉␉␉␉defaultChassis.chassisType = kSMBchassisUnknown;␊ |
764 | ␉␉␉␉␉␉break;␊ |
765 | ␉␉␉␉}␊ |
766 | ␉␉␉␉break;␊ |
767 | ␉␉␉}␊ |
768 | ␉␉}␊ |
769 | ␉}␊ |
770 | }␊ |
771 | ␊ |
772 | /* Used for SM*n smbios.plist keys */␊ |
773 | bool getSMBValueForKey(SMBStructHeader *structHeader, const char *keyString, const char **string, returnType *value)␊ |
774 | {␊ |
775 | ␉static int idx = -1;␊ |
776 | ␉static int current = -1;␊ |
777 | ␉int len;␊ |
778 | ␉char key[24];␊ |
779 | ␊ |
780 | ␉if (current != structHeader->handle)␊ |
781 | ␉{␊ |
782 | ␉␉idx++;␊ |
783 | ␉␉current = structHeader->handle;␊ |
784 | ␉}␊ |
785 | ␊ |
786 | ␉sprintf(key, "%s%d", keyString, idx);␊ |
787 | ␊ |
788 | ␉if (value)␊ |
789 | ␉{␊ |
790 | ␉␉if (getIntForKey(key, (int *)&(value->dword), SMBPlist))␊ |
791 | ␉␉{␊ |
792 | ␉␉␉return true;␊ |
793 | ␉␉}␊ |
794 | ␉}␊ |
795 | ␉else␊ |
796 | ␉{␊ |
797 | ␉␉if (getValueForKey(key, string, &len, SMBPlist))␊ |
798 | ␉␉{␊ |
799 | ␉␉␉return true;␊ |
800 | ␉␉}␊ |
801 | ␉}␊ |
802 | ␉return false;␊ |
803 | }␊ |
804 | ␊ |
805 | char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)␊ |
806 | {␊ |
807 | ␉if (!field || !structHeader)␊ |
808 | ␉{␊ |
809 | ␉␉return NULL;␊ |
810 | ␉}␊ |
811 | ␊ |
812 | ␉uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;␊ |
813 | ␊ |
814 | ␉for (field--; (field > 0) && (*stringPtr > 0) &&(*(uint16_t *)stringPtr != 0);␊ |
815 | ␉␉field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));␊ |
816 | ␊ |
817 | ␉return (char *)stringPtr;␊ |
818 | }␊ |
819 | ␊ |
820 | void setSMBStringForField(SMBStructHeader *structHeader, const char *string, uint8_t *field)␊ |
821 | {␊ |
822 | ␉int strSize;␊ |
823 | ␊ |
824 | ␉if (!field)␊ |
825 | ␉{␊ |
826 | ␉␉return;␊ |
827 | ␉}␊ |
828 | ␊ |
829 | ␉if (!string)␊ |
830 | ␉{␊ |
831 | ␉␉*field = 0;␊ |
832 | ␉␉return;␊ |
833 | ␉}␊ |
834 | ␊ |
835 | ␉strSize = strlen(string);␊ |
836 | ␊ |
837 | ␉// remove any spaces found at the end but only in MemoryDevice avoiding errors␊ |
838 | ␉if (structHeader->type == kSMBTypeMemoryDevice)␊ |
839 | ␉{␊ |
840 | ␉␉while ((strSize != 0) && (string[strSize - 1] == ' '))␊ |
841 | ␉␉{␊ |
842 | ␉␉␉strSize--;␊ |
843 | ␉␉}␊ |
844 | ␉}␊ |
845 | ␊ |
846 | ␉if (strSize == 0)␊ |
847 | ␉{␊ |
848 | ␉␉*field = 0;␊ |
849 | ␉␉return;␊ |
850 | ␉}␊ |
851 | ␊ |
852 | ␉memcpy((uint8_t *)structHeader + structHeader->length + stringsSize, string, strSize);␊ |
853 | ␉*field = stringIndex;␊ |
854 | ␊ |
855 | ␉stringIndex++;␊ |
856 | ␉stringsSize += strSize + 1;␊ |
857 | }␊ |
858 | ␊ |
859 | bool setSMBValue(SMBStructPtrs *structPtr, int idx, returnType *value)␊ |
860 | {␊ |
861 | ␉const char *string = 0;␊ |
862 | ␉int len;␊ |
863 | ␉bool parsed;␊ |
864 | ␉int val;␊ |
865 | ␊ |
866 | ␉if (numOfSetters <= idx)␊ |
867 | ␉{␊ |
868 | ␉␉return false;␊ |
869 | ␉}␊ |
870 | ␊ |
871 | ␉switch (SMBSetters[idx].valueType)␊ |
872 | ␉{␊ |
873 | ␉␉case kSMBString:␊ |
874 | ␉␉{␊ |
875 | ␉␉␉if (SMBSetters[idx].keyString)␊ |
876 | ␉␉␉{␊ |
877 | ␉␉␉␉if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist))␊ |
878 | ␉␉␉␉{␊ |
879 | ␉␉␉␉␉break;␊ |
880 | ␉␉␉␉}␊ |
881 | ␉␉␉␉else␊ |
882 | ␉␉␉␉{␊ |
883 | ␉␉␉␉␉if (structPtr->orig->type == kSMBTypeMemoryDevice)␉// MemoryDevice only␊ |
884 | ␉␉␉␉␉{␊ |
885 | ␉␉␉␉␉␉if (getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, &string, NULL))␊ |
886 | ␉␉␉␉␉␉{␊ |
887 | ␉␉␉␉␉␉␉break;␊ |
888 | ␉␉␉␉␉␉}␊ |
889 | ␉␉␉␉␉}␊ |
890 | ␉␉␉␉}␊ |
891 | ␊ |
892 | ␉␉␉}␊ |
893 | ␉␉␉if (SMBSetters[idx].getSMBValue)␊ |
894 | ␉␉␉{␊ |
895 | ␉␉␉␉if (SMBSetters[idx].getSMBValue((returnType *)&string))␊ |
896 | ␉␉␉␉{␊ |
897 | ␉␉␉␉␉break;␊ |
898 | ␉␉␉␉}␊ |
899 | ␉␉␉}␊ |
900 | ␉␉␉// if ((SMBSetters[idx].defaultValue) && *(SMBSetters[idx].defaultValue)) Bungo␊ |
901 | ␉␉␉if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue))␊ |
902 | ␉␉␉{␊ |
903 | ␉␉␉␉string = *(SMBSetters[idx].defaultValue);␊ |
904 | ␉␉␉␉break;␊ |
905 | ␉␉␉}␊ |
906 | ␉␉␉string = getSMBStringForField(structPtr->orig, *(uint8_t *)value);␊ |
907 | ␉␉␉break;␊ |
908 | ␉␉}␊ |
909 | ␊ |
910 | ␉␉case kSMBByte:␊ |
911 | ␉␉case kSMBWord:␊ |
912 | ␉␉case kSMBDWord:␊ |
913 | ␉␉case kSMBQWord:␊ |
914 | ␉␉␉if (SMBSetters[idx].keyString)␊ |
915 | ␉␉␉{␊ |
916 | ␉␉␉␉parsed = getIntForKey(SMBSetters[idx].keyString, &val, SMBPlist);␊ |
917 | ␉␉␉␉if (!parsed)␊ |
918 | ␉␉␉␉{␊ |
919 | ␉␉␉␉␉if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only␊ |
920 | ␉␉␉␉␉{␊ |
921 | ␉␉␉␉␉␉parsed = getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, NULL, (returnType *)&val);␊ |
922 | ␉␉␉␉␉}␊ |
923 | ␉␉␉␉}␊ |
924 | ␊ |
925 | ␉␉␉␉if (parsed)␊ |
926 | ␉␉␉␉{␊ |
927 | ␉␉␉␉␉switch (SMBSetters[idx].valueType)␊ |
928 | ␉␉␉␉␉{␊ |
929 | ␉␉␉␉␉␉case kSMBByte:␊ |
930 | ␉␉␉␉␉␉␉value->byte = (uint8_t)val;␊ |
931 | ␉␉␉␉␉␉␉break;␊ |
932 | ␉␉␉␉␉␉case kSMBWord:␊ |
933 | ␉␉␉␉␉␉␉value->word = (uint16_t)val;␊ |
934 | ␉␉␉␉␉␉␉break;␊ |
935 | ␉␉␉␉␉␉case kSMBQWord:␊ |
936 | ␉␉␉␉␉␉␉value->qword = (uint64_t)val;␊ |
937 | ␉␉␉␉␉␉␉break;␊ |
938 | ␉␉␉␉␉␉case kSMBDWord:␊ |
939 | ␉␉␉␉␉␉default:␊ |
940 | ␉␉␉␉␉␉␉value->dword = (uint32_t)val;␊ |
941 | ␉␉␉␉␉␉␉break;␊ |
942 | ␉␉␉␉␉}␊ |
943 | ␉␉␉␉␉return true;␊ |
944 | ␉␉␉␉}␊ |
945 | ␉␉␉}␊ |
946 | ␊ |
947 | ␉␉␉if (SMBSetters[idx].getSMBValue)␊ |
948 | ␉␉␉{␊ |
949 | ␉␉␉␉if (SMBSetters[idx].getSMBValue(value))␊ |
950 | ␉␉␉␉{␊ |
951 | ␉␉␉␉␉return true;␊ |
952 | ␉␉␉␉}␊ |
953 | ␉␉␉}␊ |
954 | // #if 0 Bungo: enables code below␊ |
955 | ␉␉␉// if (*(SMBSetters[idx].defaultValue)) Bungo␊ |
956 | ␉␉␉if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue))␊ |
957 | ␉␉␉{␊ |
958 | ␉␉␉// value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue); Bungo␊ |
959 | ␉␉␉switch (SMBSetters[idx].valueType) {␊ |
960 | ␉␉␉␉case kSMBByte:␊ |
961 | ␉␉␉␉␉value->byte = *(uint8_t *)(SMBSetters[idx].defaultValue);␊ |
962 | ␉␉␉␉␉break;␊ |
963 | ␉␉␉␉case kSMBWord:␊ |
964 | ␉␉␉␉␉value->word = *(uint16_t *)(SMBSetters[idx].defaultValue);␊ |
965 | ␉␉␉␉␉break;␊ |
966 | ␉␉␉␉case kSMBQWord:␊ |
967 | ␉␉␉␉␉value->qword = *(uint64_t *)(SMBSetters[idx].defaultValue);␊ |
968 | ␉␉␉␉␉break;␊ |
969 | ␉␉␉␉case kSMBDWord:␊ |
970 | ␉␉␉␉default:␊ |
971 | ␉␉␉␉␉value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue);␊ |
972 | ␉␉␉␉␉break;␊ |
973 | ␉␉␉}␊ |
974 | ␉␉␉return true;␊ |
975 | ␉␉}␊ |
976 | // #endif Bungo␊ |
977 | ␉␉break;␊ |
978 | ␉}␊ |
979 | ␊ |
980 | ␉// if (SMBSetters[idx].valueType == kSMBString && string) Bungo: use null string too -> "Not Specified"␊ |
981 | ␉if ((SMBSetters[idx].valueType == kSMBString) && string)␊ |
982 | ␉{␊ |
983 | ␉␉setSMBStringForField(structPtr->new, string, &value->byte);␊ |
984 | ␉}␊ |
985 | ␉return true;␊ |
986 | }␊ |
987 | ␊ |
988 | //-------------------------------------------------------------------------------------------------------------------------␊ |
989 | // Apple Specific␊ |
990 | //-------------------------------------------------------------------------------------------------------------------------␊ |
991 | ␊ |
992 | /* ===========================================␊ |
993 | Firmware Volume (Apple Specific - Type 128)␊ |
994 | ============================================= */␊ |
995 | void addSMBFirmwareVolume(SMBStructPtrs *structPtr)␊ |
996 | {␊ |
997 | ␉return;␊ |
998 | }␊ |
999 | ␊ |
1000 | /* ===========================================␊ |
1001 | Memory SPD Data (Apple Specific - Type 130)␊ |
1002 | ============================================= */␊ |
1003 | void addSMBMemorySPD(SMBStructPtrs *structPtr)␊ |
1004 | {␊ |
1005 | ␉/* SPD data from Platform.RAM.spd */␊ |
1006 | ␉return;␊ |
1007 | }␊ |
1008 | ␊ |
1009 | /* ============================================␊ |
1010 | OEM Processor Type (Apple Specific - Type 131)␊ |
1011 | ============================================== */␊ |
1012 | void addSMBOemProcessorType(SMBStructPtrs *structPtr)␊ |
1013 | {␊ |
1014 | ␉SMBOemProcessorType *p = (SMBOemProcessorType *)structPtr->new;␊ |
1015 | ␊ |
1016 | ␉p->header.type␉␉= kSMBTypeOemProcessorType;␊ |
1017 | ␉p->header.length␉= sizeof(SMBOemProcessorType);␊ |
1018 | ␉p->header.handle␉= handle++;␊ |
1019 | ␊ |
1020 | ␉setSMBValue(structPtr, numOfSetters - 2 , (returnType *)&(p->ProcessorType));␊ |
1021 | ␊ |
1022 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorType) + 2);␊ |
1023 | ␉tableLength += sizeof(SMBOemProcessorType) + 2;␊ |
1024 | ␉structureCount++;␊ |
1025 | }␊ |
1026 | ␊ |
1027 | /* =================================================␊ |
1028 | OEM Processor Bus Speed (Apple Specific - Type 132)␊ |
1029 | =================================================== */␊ |
1030 | void addSMBOemProcessorBusSpeed(SMBStructPtrs *structPtr)␊ |
1031 | {␊ |
1032 | ␉SMBOemProcessorBusSpeed *p = (SMBOemProcessorBusSpeed *)structPtr->new;␊ |
1033 | ␊ |
1034 | ␉switch (Platform.CPU.Family) ␊ |
1035 | ␉{␊ |
1036 | ␉␉case 0x06:␊ |
1037 | ␉␉{␊ |
1038 | ␉␉␉switch (Platform.CPU.Model)␊ |
1039 | ␉␉␉{␊ |
1040 | ␉␉␉␉case 0x19:␉␉␉// Intel Core i5 650 @3.20 Ghz␊ |
1041 | ␉␉␉␉case CPUID_MODEL_FIELDS:␉// Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)␊ |
1042 | ␉␉␉␉case CPUID_MODEL_CLARKDALE:␊ |
1043 | ␉␉␉␉case CPUID_MODEL_DALES:␉// Intel Core i3, i5 LGA1156 (32nm)␊ |
1044 | ␉␉␉␉case CPUID_MODEL_NEHALEM:␉// Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm)␊ |
1045 | ␉␉␉␉case CPUID_MODEL_NEHALEM_EX:␉// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x␊ |
1046 | ␉␉␉␉case CPUID_MODEL_WESTMERE:␉// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core␊ |
1047 | ␉␉␉␉case CPUID_MODEL_WESTMERE_EX:␉// Intel Xeon E7␊ |
1048 | ␉␉␉␉case CPUID_MODEL_SANDYBRIDGE:␉// Intel Core i3, i5, i7 LGA1155 (32nm)␊ |
1049 | ␉␉␉␉case CPUID_MODEL_IVYBRIDGE:␉// Intel Core i3, i5, i7 LGA1155 (22nm)␊ |
1050 | ␉␉␉␉case CPUID_MODEL_IVYBRIDGE_XEON:␊ |
1051 | ␉␉␉␉case CPUID_MODEL_JAKETOWN:␉// Intel Core i7, Xeon E5 LGA2011 (32nm)␊ |
1052 | ␉␉␉␉case CPUID_MODEL_HASWELL:␊ |
1053 | ␉␉␉␉case CPUID_MODEL_HASWELL_SVR:␊ |
1054 | ␉␉␉␉case CPUID_MODEL_HASWELL_ULT:␊ |
1055 | ␉␉␉␉case CPUID_MODEL_HASWELL_ULX:␊ |
1056 | ␊ |
1057 | ␉␉␉␉␉break;␊ |
1058 | ␊ |
1059 | ␉␉␉␉default:␊ |
1060 | ␉␉␉␉␉return;␊ |
1061 | ␉␉␉}␊ |
1062 | ␉␉}␊ |
1063 | ␉}␊ |
1064 | ␊ |
1065 | ␉p->header.type␉␉= kSMBTypeOemProcessorBusSpeed;␊ |
1066 | ␉p->header.length␉= sizeof(SMBOemProcessorBusSpeed);␊ |
1067 | ␉p->header.handle␉= handle++;␊ |
1068 | ␊ |
1069 | ␉setSMBValue(structPtr, numOfSetters -1, (returnType *)&(p->ProcessorBusSpeed));␊ |
1070 | ␊ |
1071 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorBusSpeed) + 2);␊ |
1072 | ␉tableLength += sizeof(SMBOemProcessorBusSpeed) + 2;␊ |
1073 | ␉structureCount++;␊ |
1074 | }␊ |
1075 | ␊ |
1076 | /* ==============================================␊ |
1077 | OEM Platform Feature (Apple Specific - Type 133)␊ |
1078 | ================================================ */␊ |
1079 | /*␊ |
1080 | void addSMBOemPlatformFeature(SMBStructPtrs *structPtr)␊ |
1081 | {␊ |
1082 | ␉SMBOemPlatformFeature *p = (SMBOemPlatformFeature *)structPtr->new;␊ |
1083 | ␊ |
1084 | ␉p->header.type␉␉= kSMBTypeOemPlatformFeature;␊ |
1085 | ␉p->header.length␉= sizeof(SMBOemPlatformFeature);␊ |
1086 | ␉p->header.handle␉= handle++;␊ |
1087 | ␊ |
1088 | ␉setSMBValue(structPtr, numOfSetters - 2 , (returnType *)&(p->PlatformFeature));␊ |
1089 | ␊ |
1090 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemPPlatformFeature) + 2);␊ |
1091 | ␉tableLength += sizeof(SMBOemPlatformFeature) + 2;␊ |
1092 | ␉structureCount++;␊ |
1093 | }␊ |
1094 | */␊ |
1095 | ␊ |
1096 | ␊ |
1097 | /* ==============================================␊ |
1098 | EndOfTable␊ |
1099 | ================================================ */␊ |
1100 | void addSMBEndOfTable(SMBStructPtrs *structPtr)␊ |
1101 | {␊ |
1102 | ␉structPtr->new->type␉= kSMBTypeEndOfTable;␊ |
1103 | ␉structPtr->new->length␉= sizeof(SMBStructHeader);␊ |
1104 | ␉structPtr->new->handle␉= handle++;␊ |
1105 | ␊ |
1106 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBStructHeader) + 2);␊ |
1107 | ␉tableLength += sizeof(SMBStructHeader) + 2;␊ |
1108 | ␉structureCount++;␊ |
1109 | }␊ |
1110 | ␊ |
1111 | void setSMBStruct(SMBStructPtrs *structPtr)␊ |
1112 | {␊ |
1113 | ␉bool setterFound = false;␊ |
1114 | ␊ |
1115 | ␉uint8_t *ptr;␊ |
1116 | ␉SMBWord structSize;␊ |
1117 | ␉int i;␊ |
1118 | ␊ |
1119 | ␉/* Bungo: not needed because of tables lengths fix in next lines␊ |
1120 | ␉// http://forge.voodooprojects.org/p/chameleon/issues/361/␊ |
1121 | ␉bool forceFullMemInfo = false;␊ |
1122 | ␊ |
1123 | ␉if (structPtr->orig->type == kSMBTypeMemoryDevice)␊ |
1124 | ␉{␊ |
1125 | ␉␉getBoolForKey(kMemFullInfo, &forceFullMemInfo, &bootInfo->chameleonConfig);␊ |
1126 | ␉␉if (forceFullMemInfo)␊ |
1127 | ␉␉{␊ |
1128 | ␉␉␉structPtr->orig->length = 27;␊ |
1129 | ␉␉}␊ |
1130 | ␉}*/␊ |
1131 | ␊ |
1132 | ␉stringIndex = 1;␊ |
1133 | ␉stringsSize = 0;␊ |
1134 | ␊ |
1135 | ␉if (handle < structPtr->orig->handle)␊ |
1136 | ␉{␊ |
1137 | ␉␉handle = structPtr->orig->handle;␊ |
1138 | ␉}␊ |
1139 | ␉// Bungo: fix unsuported tables lengths from original smbios: extend shorter or truncate longer - we use SMBIOS rev. 2.4 like Apple uses␊ |
1140 | ␉switch (structPtr->orig->type)␊ |
1141 | ␉{␊ |
1142 | ␉␉case kSMBTypeBIOSInformation:␊ |
1143 | ␉␉␉structSize = sizeof(SMBBIOSInformation);␊ |
1144 | ␉␉␉break;␊ |
1145 | ␉␉case kSMBTypeSystemInformation:␊ |
1146 | ␉␉␉structSize = sizeof(SMBSystemInformation);␊ |
1147 | ␉␉␉break;␊ |
1148 | ␉␉case kSMBTypeBaseBoard:␊ |
1149 | ␉␉␉structSize = sizeof(SMBBaseBoard);␊ |
1150 | ␉␉␉break;␊ |
1151 | ␉␉case kSMBTypeSystemEnclosure:␊ |
1152 | ␉␉␉structSize = sizeof(SMBSystemEnclosure);␊ |
1153 | ␉␉␉break;␊ |
1154 | ␉␉case kSMBTypeProcessorInformation:␊ |
1155 | ␉␉␉structSize = sizeof(SMBProcessorInformation);␊ |
1156 | ␉␉␉break;␊ |
1157 | ␉␉case kSMBTypeMemoryDevice:␊ |
1158 | ␉␉␉structSize = sizeof(SMBMemoryDevice);␊ |
1159 | ␉␉␉break;␊ |
1160 | ␉␉default:␊ |
1161 | ␉␉␉structSize = structPtr->orig->length; // doesn't change a length for unpatched␊ |
1162 | ␉␉␉break;␊ |
1163 | ␉}␊ |
1164 | ␊ |
1165 | ␉// memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);␊ |
1166 | ␉if (structPtr->orig->length <= structSize)␊ |
1167 | ␉{␊ |
1168 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);␊ |
1169 | ␉}␊ |
1170 | ␉else␊ |
1171 | ␉{␊ |
1172 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structSize);␊ |
1173 | ␉}␊ |
1174 | ␊ |
1175 | ␉structPtr->new->length = structSize;␊ |
1176 | ␊ |
1177 | ␉for (i = 0; i < numOfSetters; i++)␊ |
1178 | ␉{␊ |
1179 | ␉␉// Bungo:␊ |
1180 | ␉␉//if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structPtr->orig->length)) {␊ |
1181 | ␉␉if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structSize))␊ |
1182 | ␉␉{␊ |
1183 | ␉␉␉setterFound = true;␊ |
1184 | ␉␉␉setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset));␊ |
1185 | ␉␉}␊ |
1186 | ␉}␊ |
1187 | ␊ |
1188 | ␉if (setterFound)␊ |
1189 | ␉{␊ |
1190 | ␉␉// Bungo:␊ |
1191 | ␉␉// ptr = (uint8_t *)structPtr->new + structPtr->orig->length;␊ |
1192 | ␉␉ptr = (uint8_t *)structPtr->new + structPtr->new->length;␊ |
1193 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1194 | ␊ |
1195 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1196 | ␉␉{␊ |
1197 | ␉␉␉ptr += 2;␊ |
1198 | ␉␉}␊ |
1199 | ␉␉structSize = ptr - (uint8_t *)structPtr->new;␊ |
1200 | ␉}␊ |
1201 | ␉else␊ |
1202 | ␉{␊ |
1203 | ␉␉ptr = (uint8_t *)structPtr->orig + structPtr->orig->length;␊ |
1204 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1205 | ␊ |
1206 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1207 | ␉␉{␊ |
1208 | ␉␉␉ptr += 2;␊ |
1209 | ␉␉}␊ |
1210 | ␊ |
1211 | ␉␉structSize = ptr - (uint8_t *)structPtr->orig;␊ |
1212 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structSize);␊ |
1213 | ␉}␊ |
1214 | ␊ |
1215 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + structSize);␊ |
1216 | ␊ |
1217 | ␉tableLength += structSize;␊ |
1218 | ␊ |
1219 | ␉if (structSize > maxStructSize)␊ |
1220 | ␉{␊ |
1221 | ␉␉maxStructSize = structSize;␊ |
1222 | ␉}␊ |
1223 | ␊ |
1224 | ␉structureCount++;␊ |
1225 | }␊ |
1226 | ␊ |
1227 | void setupNewSMBIOSTable(SMBEntryPoint *eps, SMBStructPtrs *structPtr)␊ |
1228 | {␊ |
1229 | ␉uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;␊ |
1230 | ␉structPtr->orig = (SMBStructHeader *)ptr;␊ |
1231 | ␊ |
1232 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structPtr->orig + sizeof(SMBStructHeader)));) {␊ |
1233 | ␉␉switch (structPtr->orig->type) {␊ |
1234 | ␉␉␉/* Skip all Apple Specific Structures */␊ |
1235 | ␉␉␉case kSMBTypeFirmwareVolume:␊ |
1236 | ␉␉␉case kSMBTypeMemorySPD:␊ |
1237 | ␉␉␉case kSMBTypeOemProcessorType:␊ |
1238 | ␉␉␉case kSMBTypeOemProcessorBusSpeed:␊ |
1239 | //␉␉␉case kSMBTypeOemPlatformFeature:␊ |
1240 | ␉␉␉␉/* And this one too, to be added at the end */␊ |
1241 | ␉␉␉case kSMBTypeEndOfTable:␊ |
1242 | ␉␉␉␉break;␊ |
1243 | ␊ |
1244 | ␉␉␉default:␊ |
1245 | ␉␉␉{␊ |
1246 | ␉␉␉␉/* Add */␊ |
1247 | ␉␉␉␉setSMBStruct(structPtr);␊ |
1248 | ␉␉␉␉break;␊ |
1249 | ␉␉␉}␊ |
1250 | ␉␉}␊ |
1251 | ␊ |
1252 | ␉␉ptr = (uint8_t *)((uint32_t)structPtr->orig + structPtr->orig->length);␊ |
1253 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1254 | ␊ |
1255 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1256 | ␉␉{␊ |
1257 | ␉␉␉ptr += 2;␊ |
1258 | ␉␉}␊ |
1259 | ␊ |
1260 | ␉␉structPtr->orig = (SMBStructHeader *)ptr;␊ |
1261 | ␉}␊ |
1262 | ␊ |
1263 | ␉addSMBFirmwareVolume(structPtr);␊ |
1264 | ␉addSMBMemorySPD(structPtr);␊ |
1265 | ␉addSMBOemProcessorType(structPtr);␊ |
1266 | ␉addSMBOemProcessorBusSpeed(structPtr);␊ |
1267 | //␉addSMBOemPlatformFeature(structPtr);␊ |
1268 | ␉addSMBEndOfTable(structPtr);␊ |
1269 | }␊ |
1270 | ␊ |
1271 | // Bungo: does fix system uuid in SMBIOS & EFI instead of in EFI (IODT/efi/platform/system-id) only␊ |
1272 | uint8_t *fixSystemUUID()␊ |
1273 | {␊ |
1274 | ␉uint8_t *ptr = (uint8_t *)neweps->dmi.tableAddress;␊ |
1275 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)ptr;␊ |
1276 | ␉uint8_t *ret = NULL;␊ |
1277 | ␉int i, isZero, isOnes;␊ |
1278 | ␉uint8_t fixedUUID[UUID_LEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};␊ |
1279 | ␉const char *sysId = getStringForKey(kSMBSystemInformationUUIDKey, SMBPlist); // try to get user's uuid from smbios.plist␊ |
1280 | ␉ret = (uint8_t *)getUUIDFromString(sysId); // convert user's uuid from string␊ |
1281 | ␊ |
1282 | ␉for (;(structHeader->type != kSMBTypeSystemInformation);) // find System Information Table (Type 1) in patched SMBIOS␊ |
1283 | ␉{␊ |
1284 | ␉␉ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
1285 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1286 | ␊ |
1287 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1288 | ␉␉{␊ |
1289 | ␉␉␉ptr += 2;␊ |
1290 | ␉␉}␊ |
1291 | ␊ |
1292 | ␉␉structHeader = (SMBStructHeader *)ptr;␊ |
1293 | ␉}␊ |
1294 | ␊ |
1295 | ␉ptr = ((SMBSystemInformation *)structHeader)->uuid;␊ |
1296 | ␊ |
1297 | ␉if (!sysId || !ret) // no or bad custom uuid,...␊ |
1298 | ␉{␊ |
1299 | ␉␉sysId = 0;␊ |
1300 | ␉␉ret = Platform.UUID; // ...use original (factory) system uuid␊ |
1301 | ␉}␊ |
1302 | ␊ |
1303 | ␉for (i = 0, isZero = 1, isOnes = 1; i < UUID_LEN; i++) // check if empty (zeroed) or setable (FFed), means: no uuid present␊ |
1304 | ␉{␊ |
1305 | ␉␉if (ret[i] != 0x00)␊ |
1306 | ␉␉{␊ |
1307 | ␉␉␉isZero = 0;␊ |
1308 | ␉␉}␊ |
1309 | ␊ |
1310 | ␉␉if (ret[i] != 0xff)␊ |
1311 | ␉␉{␊ |
1312 | ␉␉␉isOnes = 0;␊ |
1313 | ␉␉}␊ |
1314 | ␉}␊ |
1315 | ␊ |
1316 | ␉if (isZero || isOnes) // if empty or setable...␊ |
1317 | ␉{␊ |
1318 | ␉␉verbose("System UUID: incorrect or not present. Fixing [00112233-4455-6677-8899-AABBCCDDEEFF]\n");␊ |
1319 | ␉␉ret = fixedUUID; // ...set a fixed value for system uuid: <00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF>␊ |
1320 | ␉}␊ |
1321 | ␊ |
1322 | ␉memcpy(ptr, ret, UUID_LEN); // save uuid into the patched SMBIOS Table 1␊ |
1323 | ␊ |
1324 | ␉return ptr;␊ |
1325 | } // Bungo: end fix␊ |
1326 | ␊ |
1327 | void setupSMBIOSTable(void)␊ |
1328 | {␊ |
1329 | ␉SMBStructPtrs *structPtr;␊ |
1330 | ␉uint8_t *buffer;␊ |
1331 | ␉// bool setSMB = true; Bungo: now we use useSMBIOSdefaults␊ |
1332 | ␊ |
1333 | ␉if (!origeps)␊ |
1334 | ␉{␊ |
1335 | ␉␉return;␊ |
1336 | ␉}␊ |
1337 | ␊ |
1338 | ␉neweps = origeps;␊ |
1339 | ␊ |
1340 | ␉structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs));␊ |
1341 | ␉if (!structPtr)␊ |
1342 | ␉{␊ |
1343 | ␉␉return;␊ |
1344 | ␉}␊ |
1345 | ␉␊ |
1346 | ␉buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE);␊ |
1347 | ␉if (!buffer)␊ |
1348 | ␉{␊ |
1349 | ␉␉free(structPtr);␊ |
1350 | ␉␉return;␊ |
1351 | ␉}␊ |
1352 | ␊ |
1353 | ␉bzero(buffer, SMB_ALLOC_SIZE);␊ |
1354 | ␉structPtr->new = (SMBStructHeader *)buffer;␊ |
1355 | ␊ |
1356 | ␉// getBoolForKey(kSMBIOSdefaults, &setSMB, &bootInfo->chameleonConfig); Bungo␊ |
1357 | ␉getBoolForKey(kSMBIOSdefaults, &useSMBIOSdefaults, &bootInfo->chameleonConfig);␊ |
1358 | ␉// if (setSMB) Bungo␊ |
1359 | ␉setDefaultSMBData();␊ |
1360 | ␊ |
1361 | ␉setupNewSMBIOSTable(origeps, structPtr);␊ |
1362 | ␊ |
1363 | ␉neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));␊ |
1364 | ␉if (!neweps)␊ |
1365 | ␉{␊ |
1366 | ␉␉free(buffer);␊ |
1367 | ␉␉free(structPtr);␊ |
1368 | ␉␉return;␊ |
1369 | ␉}␊ |
1370 | ␉bzero(neweps, sizeof(SMBEntryPoint));␊ |
1371 | ␊ |
1372 | ␉neweps->anchor[0]␉␉␉= '_';␊ |
1373 | ␉neweps->anchor[1]␉␉␉= 'S';␊ |
1374 | ␉neweps->anchor[2]␉␉␉= 'M';␊ |
1375 | ␉neweps->anchor[3]␉␉␉= '_';␊ |
1376 | ␉neweps->entryPointLength␉= sizeof(SMBEntryPoint);␊ |
1377 | ␉neweps->majorVersion␉␉= 2; // Bungo:␊ |
1378 | ␉neweps->minorVersion␉␉= 4; // Here we're using 2.4 SMBIOS rev. as real Macs␊ |
1379 | ␉neweps->maxStructureSize␉= maxStructSize;␊ |
1380 | ␉neweps->entryPointRevision␉= 0;␊ |
1381 | ␊ |
1382 | ␉neweps->dmi.anchor[0]␉␉= '_';␊ |
1383 | ␉neweps->dmi.anchor[1]␉␉= 'D';␊ |
1384 | ␉neweps->dmi.anchor[2]␉␉= 'M';␊ |
1385 | ␉neweps->dmi.anchor[3]␉␉= 'I';␊ |
1386 | ␉neweps->dmi.anchor[4]␉␉= '_';␊ |
1387 | ␉neweps->dmi.tableLength␉␉= tableLength;␊ |
1388 | ␉neweps->dmi.tableAddress␉= AllocateKernelMemory(tableLength);␊ |
1389 | ␉neweps->dmi.structureCount␉= structureCount;␊ |
1390 | ␉neweps->dmi.bcdRevision␉␉= 0x24; // ... and 2.4 DMI rev. as real Macs␊ |
1391 | ␊ |
1392 | ␉if (!neweps->dmi.tableAddress)␊ |
1393 | ␉{␊ |
1394 | ␉␉free(buffer);␊ |
1395 | ␉␉free(structPtr);␊ |
1396 | ␉␉return;␊ |
1397 | ␉}␊ |
1398 | ␊ |
1399 | ␉memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);␊ |
1400 | ␊ |
1401 | ␉Platform.UUID = fixSystemUUID(); // Bungo: fix System UUID␊ |
1402 | ␊ |
1403 | ␉neweps->dmi.checksum␉␉= 0;␊ |
1404 | ␉neweps->dmi.checksum␉␉= 0x100 - checksum8(&neweps->dmi, sizeof(DMIEntryPoint));␊ |
1405 | ␊ |
1406 | ␉neweps->checksum␉␉= 0;␊ |
1407 | ␉neweps->checksum␉␉= 0x100 - checksum8(neweps, sizeof(SMBEntryPoint));␊ |
1408 | ␊ |
1409 | ␉free(buffer);␊ |
1410 | ␉free(structPtr);␊ |
1411 | ␊ |
1412 | ␉DBG("SMBIOS orig was = %x\n", origeps);␊ |
1413 | ␉DBG("SMBIOS new is = %x\n", neweps);␊ |
1414 | ␊ |
1415 | ␉decodeSMBIOSTable(neweps);␊ |
1416 | ␊ |
1417 | }␊ |
1418 | ␊ |
1419 | void *getSmbios(int which)␊ |
1420 | {␊ |
1421 | ␉switch (which)␊ |
1422 | ␉{␊ |
1423 | ␉␉case SMBIOS_ORIGINAL:␊ |
1424 | ␉␉␉if (!origeps)␊ |
1425 | ␉␉␉{␊ |
1426 | ␉␉␉␉origeps = getAddressOfSmbiosTable();␊ |
1427 | ␉␉␉}␊ |
1428 | ␉␉␉return origeps;␊ |
1429 | ␉␉case SMBIOS_PATCHED:␊ |
1430 | ␉␉␉return neweps;␊ |
1431 | ␉}␊ |
1432 | ␊ |
1433 | ␉return 0;␊ |
1434 | }␊ |
1435 | ␊ |
1436 | /* Collect any information needed later */␊ |
1437 | void readSMBIOSInfo(SMBEntryPoint *eps)␊ |
1438 | {␊ |
1439 | ␉uint8_t *structPtr = (uint8_t *)eps->dmi.tableAddress;␊ |
1440 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)structPtr;␊ |
1441 | ␊ |
1442 | ␉int dimmnbr = 0;␊ |
1443 | ␉Platform.DMI.MaxMemorySlots␉= 0;␉// number of memory slots polulated by SMBIOS␊ |
1444 | ␉Platform.DMI.CntMemorySlots␉= 0;␉// number of memory slots counted␊ |
1445 | ␉Platform.DMI.MemoryModules␉= 0;␊ |
1446 | ␊ |
1447 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)␊ |
1448 | ␉{␊ |
1449 | ␉␉switch (structHeader->type)␊ |
1450 | ␉␉{␊ |
1451 | ␉␉␉case kSMBTypeSystemInformation:␊ |
1452 | ␉␉␉␉Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid; // save factory system uuid␊ |
1453 | ␉␉␉␉break;␊ |
1454 | ␊ |
1455 | ␉␉␉case kSMBTypeSystemEnclosure: // Bungo: determine platform type␊ |
1456 | ␉␉␉␉switch (((SMBSystemEnclosure *)structHeader)->chassisType)␊ |
1457 | ␉␉␉␉{␊ |
1458 | ␉␉␉␉␉case kSMBchassisPortable:␊ |
1459 | ␉␉␉␉␉case kSMBchassisLaptop:␊ |
1460 | ␉␉␉␉␉case kSMBchassisNotebook:␊ |
1461 | ␉␉␉␉␉case kSMBchassisHandHeld:␊ |
1462 | ␉␉␉␉␉case kSMBchassisSubNotebook:␊ |
1463 | ␉␉␉␉␉␉PlatformType = 2; // notebook (MacBooks/Pros)␊ |
1464 | ␉␉␉␉␉␉break;␊ |
1465 | ␉␉␉␉␉case kSMBchassisMiniTower:␊ |
1466 | ␉␉␉␉␉case kSMBchassisTower:␊ |
1467 | ␉␉␉␉␉case kSMBchassisBlade:␊ |
1468 | ␉␉␉␉␉case kSMBchassisBladeEnclosing:␊ |
1469 | ␉␉␉␉␉␉PlatformType = 3; // workstation (Mac Pro, Xserve)␊ |
1470 | ␉␉␉␉␉␉break;␊ |
1471 | ␉␉␉␉␉default:␊ |
1472 | ␉␉␉␉␉␉PlatformType = 1; // defulting to 1 desktop (iMac, MacMini)␊ |
1473 | ␉␉␉␉␉␉break;␊ |
1474 | ␉␉␉␉}␊ |
1475 | ␉␉␉␉break;␊ |
1476 | ␊ |
1477 | ␉␉␉case kSMBTypePhysicalMemoryArray:␊ |
1478 | ␉␉␉␉Platform.DMI.MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices;␊ |
1479 | ␉␉␉␉break;␊ |
1480 | ␊ |
1481 | ␉␉␉case kSMBTypeMemoryDevice:␊ |
1482 | ␉␉␉␉Platform.DMI.CntMemorySlots++;␊ |
1483 | ␉␉␉␉if (((SMBMemoryDevice *)structHeader)->memorySize != 0)␊ |
1484 | ␉␉␉␉{␊ |
1485 | ␉␉␉␉␉Platform.DMI.MemoryModules++;␊ |
1486 | ␉␉␉␉}␊ |
1487 | ␉␉␉␉if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0)␊ |
1488 | ␉␉␉␉{␊ |
1489 | ␉␉␉␉␉Platform.RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed;␊ |
1490 | ␉␉␉␉}␊ |
1491 | ␉␉␉␉dimmnbr++;␊ |
1492 | ␉␉␉␉break;␊ |
1493 | ␉␉␉default:␊ |
1494 | ␉␉␉␉break;␊ |
1495 | ␉␉}␊ |
1496 | ␊ |
1497 | ␉␉structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
1498 | ␉␉for (; ((uint16_t *)structPtr)[0] != 0; structPtr++);␊ |
1499 | ␊ |
1500 | ␉␉if (((uint16_t *)structPtr)[0] == 0)␊ |
1501 | ␉␉{␊ |
1502 | ␉␉␉structPtr += 2;␊ |
1503 | ␉␉}␊ |
1504 | ␊ |
1505 | ␉␉structHeader = (SMBStructHeader *)structPtr;␊ |
1506 | ␉}␊ |
1507 | }␊ |
1508 | |