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