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