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