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