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