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 | #include "config.h"␊ |
9 | #include "boot.h"␊ |
10 | #include "bootstruct.h"␊ |
11 | #include "smbios_getters.h"␊ |
12 | // Bungo␊ |
13 | #include "convert.h"␊ |
14 | ␊ |
15 | #if DEBUG_SMBIOS␊ |
16 | #define DBG(x...)␉printf(x)␊ |
17 | #else␊ |
18 | #define DBG(x...)␉msglog(x)␊ |
19 | #endif␊ |
20 | ␊ |
21 | #define SMBPlist␉␉␉&bootInfo->smbiosConfig␊ |
22 | /* ASSUMPTION: 16KB should be enough for the whole thing */␊ |
23 | #define SMB_ALLOC_SIZE␉16384␊ |
24 | ␊ |
25 | ␊ |
26 | //-------------------------------------------------------------------------------------------------------------------------␊ |
27 | // SMBIOS Plist Keys␊ |
28 | //-------------------------------------------------------------------------------------------------------------------------␊ |
29 | ␊ |
30 | /* =======================␊ |
31 | BIOS Information (Type 0)␊ |
32 | ========================= */␊ |
33 | #define kSMBBIOSInformationVendorKey␉␉␉"SMbiosvendor"␉␉// Apple Inc.␊ |
34 | #define kSMBBIOSInformationVersionKey␉␉␉"SMbiosversion"␉␉// MP31.88Z.006C.B05.0802291410␊ |
35 | #define kSMBBIOSInformationReleaseDateKey␉␉"SMbiosdate"␉␉// 02/29/08␊ |
36 | // Bungo␊ |
37 | #define kSMBBIOSInformationReleaseKey␉␉␉"SMbiosrelease"␉␉// BIOS Revision␊ |
38 | // example: BIOS Revision: 1.23 --> 2 bytes: Major=0x01, Minor=0x17 --> after swap: 0x1701hex = 5889dec (SMBIOS_spec_DSP0134_2.7.1)␊ |
39 | ␊ |
40 | /* =========================␊ |
41 | System Information (Type 1)␊ |
42 | =========================== */␊ |
43 | #define kSMBSystemInformationManufacturerKey␉␉"SMmanufacturer"␉// Apple Inc.␊ |
44 | #define kSMBSystemInformationProductNameKey␉␉"SMproductname"␉␉// MacPro3,1␊ |
45 | #define kSMBSystemInformationVersionKey␉␉␉"SMsystemversion"␉// 1.0␊ |
46 | #define kSMBSystemInformationSerialNumberKey␉␉"SMserial"␉␉// Serial number␊ |
47 | //Bungo␊ |
48 | #define kSMBSystemInformationUUIDKey␉␉␉"SMsystemuuid"␉␉// ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'␊ |
49 | #define kSMBSystemInformationSKUNumberKey␉␉"SMskunumber"␉␉// System SKU#␊ |
50 | ␊ |
51 | #define kSMBSystemInformationFamilyKey␉␉␉"SMfamily"␉␉// MacPro␊ |
52 | ␊ |
53 | /* =========================================␊ |
54 | Base Board (or Module) Information (Type 2)␊ |
55 | =========================================== */␊ |
56 | #define kSMBBaseBoardManufacturerKey␉␉␉"SMboardmanufacturer"␉// Apple Inc.␊ |
57 | #define kSMBBaseBoardProductKey␉␉␉␉"SMboardproduct"␉// Mac-F2268DC8␊ |
58 | // Bungo␊ |
59 | #define kSMBBaseBoardVersionKey␉␉␉␉"SMboardversion"␉// MacPro3,1␊ |
60 | #define kSMBBaseBoardSerialNumberKey␉␉␉"SMboardserial"␉␉// C02140302D5DMT31M␊ |
61 | #define kSMBBaseBoardAssetTagKey␉␉␉"SMboardassettag"␉// Base Board Asset Tag# Bungo: renamed folowing convention␊ |
62 | #define kSMBBaseBoardLocationInChassisKey␉␉"SMboardlocation"␉// Part Component␊ |
63 | ␊ |
64 | // ErmaC BoardType 0x0a(10) or 0x0b(11) MacPro Family␊ |
65 | #define kSMBBaseBoardTypeKey␉␉␉␉"SMboardtype"␉␉// 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro␊ |
66 | ␊ |
67 | // Bungo␊ |
68 | /* =======================␊ |
69 | System Enclosure (Type 3)␊ |
70 | ========================= */␊ |
71 | #define kSMBSystemEnclosureManufacturerKey␉␉"SMchassismanufacturer"␉// Apple Inc.␊ |
72 | #define kSMBSystemEnclosureTypeKey␉␉␉"SMchassistype"␉␉// 7 Desktop␊ |
73 | #define kSMBSystemEnclosureVersionKey␉␉␉"SMchassisversion"␉// Mac-F42C88C8␊ |
74 | #define kSMBSystemEnclosureSerialNumberKey␉␉"SMchassisserial"␉// Serial number␊ |
75 | #define kSMBSystemEnclosureAssetTagKey␉␉␉"SMchassisassettag"␉// Pro-Enclosure Bungo: renamed folowing convention␊ |
76 | ␊ |
77 | /* ============================␊ |
78 | Processor Information (Type 4)␊ |
79 | ============================== */␊ |
80 | // Bungo␊ |
81 | #define kSMBProcessorInformationSocketKey␉␉"SMcpusocket"␊ |
82 | #define kSMBProcessorInformationManufacturerKey␉␉"SMcpumanufacturer"␊ |
83 | #define kSMBProcessorInformationVersionKey␉␉"SMcpuversion"␊ |
84 | //␊ |
85 | #define kSMBProcessorInformationExternalClockKey␉"SMexternalclock"␊ |
86 | #define kSMBProcessorInformationMaximumClockKey␉␉"SMmaximalclock"␊ |
87 | // Bungo␊ |
88 | #define kSMBProcessorInformationCurrentClockKey␉␉"SMcurrentclock"␊ |
89 | #define kSMBProcessorInformationUpgradeKey␉␉"SMcpuupgrade"␊ |
90 | #define kSMBProcessorInformationSerialNumberKey␉␉"SMcpuserial"␊ |
91 | #define kSMBProcessorInformationAssetTagKey␉␉"SMcpuassettag"␉␉// Bungo: renamed folowing convention␊ |
92 | #define kSMBProcessorInformationPartNumberKey␉␉"SMcpupartnumber"␊ |
93 | ␊ |
94 | /* =====================␊ |
95 | Memory Device (Type 17)␊ |
96 | ======================= */␊ |
97 | #define kSMBMemoryDeviceDeviceLocatorKey␉␉"SMmemdevloc" //␊ |
98 | #define kSMBMemoryDeviceBankLocatorKey␉␉␉"SMmembankloc" //␊ |
99 | #define kSMBMemoryDeviceMemoryTypeKey␉␉␉"SMmemtype" //␊ |
100 | #define kSMBMemoryDeviceMemorySpeedKey␉␉␉"SMmemspeed" //␊ |
101 | #define kSMBMemoryDeviceManufacturerKey␉␉␉"SMmemmanufacturer" //␊ |
102 | #define kSMBMemoryDeviceSerialNumberKey␉␉␉"SMmemserial" //␊ |
103 | #define kSMBMemoryDevicePartNumberKey␉␉␉"SMmempart" //␊ |
104 | // Bungo:␊ |
105 | #define kSMBMemoryDeviceAssetTagKey␉␉␉"SMmemassettag" //␊ |
106 | ␊ |
107 | /* =====================================================␊ |
108 | Firmware Volume Description (Apple Specific - Type 128)␊ |
109 | ======================================================= */␊ |
110 | #define kSMBFirmwareVolumeFirmwareFeaturesKey "SMfirmwarefeatures" //␊ |
111 | #define kSMBFirmwareVolumeFirmwareFeaturesMaskKey "SMfirmwarefeaturesmask" //␊ |
112 | ␊ |
113 | /* =========================================␊ |
114 | Memory SPD Data (Apple Specific - Type 130)␊ |
115 | =========================================== */␊ |
116 | ␊ |
117 | /* ============================================␊ |
118 | OEM Processor Type (Apple Specific - Type 131)␊ |
119 | ============================================== */␊ |
120 | #define kSMBOemProcessorTypeKey␉␉␉␉"SMoemcputype"␉␉// Bungo: renamed from SMcputype␊ |
121 | ␊ |
122 | /* =================================================␊ |
123 | OEM Processor Bus Speed (Apple Specific - Type 132)␊ |
124 | =================================================== */␊ |
125 | #define kSMBOemProcessorBusSpeedKey␉␉␉"SMoemcpubusspeed"␉// Bungo: renamed from SMbusspeed␊ |
126 | ␊ |
127 | /* ==============================================␊ |
128 | OEM Platform Feature (Apple Specific - Type 133)␊ |
129 | ================================================ */␊ |
130 | //#define kSMBOemPlatformFeatureKey␉␉␉"SMoemplatformfeature"␊ |
131 | ␊ |
132 | /* ==========================================␊ |
133 | OEM Platform SMC (Apple Specific - Type 134)␊ |
134 | ============================================ */␊ |
135 | //#define kSMBOemSMCKey␉␉␉␉␉"SMoemsmc"␊ |
136 | ␊ |
137 | ␊ |
138 | /* ==================================================*/␊ |
139 | #define getFieldOffset(struct, field)␉((uint8_t)(uint32_t)&(((struct *)0)->field))␊ |
140 | ␊ |
141 | typedef struct␊ |
142 | {␊ |
143 | ␉SMBStructHeader *orig;␊ |
144 | ␉SMBStructHeader *new;␊ |
145 | } SMBStructPtrs;␊ |
146 | ␊ |
147 | /* =======================␊ |
148 | BIOS Information (Type 0)␊ |
149 | ========================= */␊ |
150 | typedef struct␊ |
151 | {␊ |
152 | ␉char *vendor;␊ |
153 | ␉char *version;␊ |
154 | ␉char *releaseDate;␊ |
155 | ␉uint16_t release; // Bungo␊ |
156 | } defaultBIOSInfo_t;␊ |
157 | ␊ |
158 | defaultBIOSInfo_t defaultBIOSInfo;␊ |
159 | ␊ |
160 | /* =========================␊ |
161 | System Information (Type 1)␊ |
162 | =========================== */␊ |
163 | typedef struct␊ |
164 | {␊ |
165 | ␉char *manufacturer;␊ |
166 | ␉char *productName;␊ |
167 | ␉char *version;␊ |
168 | ␉char *serialNumber;␊ |
169 | ␉char *skuNumber;␉// ErmaC␊ |
170 | ␉char *family;␊ |
171 | } defaultSystemInfo_t;␊ |
172 | ␊ |
173 | defaultSystemInfo_t defaultSystemInfo;␊ |
174 | ␊ |
175 | /* =========================================␊ |
176 | Base Board (or Module) Information (Type 2)␊ |
177 | =========================================== */␊ |
178 | typedef struct␊ |
179 | {␊ |
180 | ␉char *manufacturer;␊ |
181 | ␉char *product;␊ |
182 | ␉char *version;␉␉␉// Bungo␊ |
183 | ␉char *serialNumber;␉␉// ErmaC␊ |
184 | ␉char *assetTag;␉␉␉// ErmaC Bungo: renamed folowing convention␊ |
185 | ␉char *locationInChassis;␉// ErmaC␊ |
186 | ␉uint8_t boardType;␉␉// ErmaC␊ |
187 | } defaultBaseBoard_t;␊ |
188 | ␊ |
189 | defaultBaseBoard_t defaultBaseBoard;␊ |
190 | ␊ |
191 | // Bungo␊ |
192 | typedef struct {␊ |
193 | ␉char␉␉*manufacturer;␊ |
194 | ␉uint8_t␉␉chassisType;␊ |
195 | ␉char␉␉*version;␊ |
196 | ␉char␉␉*serialNumber;␊ |
197 | ␉char␉␉*assetTag;␊ |
198 | ␉char␉␉*skuNumber;␊ |
199 | } defaultChassis_t;␊ |
200 | ␊ |
201 | defaultChassis_t defaultChassis;␊ |
202 | ␊ |
203 | typedef struct␊ |
204 | {␊ |
205 | ␉uint8_t␉␉␉type;␊ |
206 | ␉SMBValueType␉␉valueType;␊ |
207 | ␉uint8_t␉␉␉fieldOffset;␊ |
208 | ␉char␉␉␉*keyString;␊ |
209 | ␉bool␉␉␉(*getSMBValue)(returnType *);␊ |
210 | ␉char␉␉␉**defaultValue;␊ |
211 | } SMBValueSetter;␊ |
212 | ␊ |
213 | SMBValueSetter SMBSetters[] = ␊ |
214 | {␊ |
215 | ␉/* =======================␊ |
216 | ␉ BIOS Information (Type 0)␊ |
217 | ␉ ========================= */␊ |
218 | ␉{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, vendor),␊ |
219 | ␉␉kSMBBIOSInformationVendorKey, NULL, &defaultBIOSInfo.vendor },␉␉␉␉// SMbiosvendor - Apple Inc.␊ |
220 | ␊ |
221 | ␉{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, version),␊ |
222 | ␉␉kSMBBIOSInformationVersionKey, NULL, &defaultBIOSInfo.version },␉␉␉// SMbiosversion - MP31.88Z.006C.B05.0802291410␊ |
223 | ␊ |
224 | ␉{ kSMBTypeBIOSInformation, kSMBString, getFieldOffset(SMBBIOSInformation, releaseDate),␊ |
225 | ␉␉kSMBBIOSInformationReleaseDateKey, NULL, &defaultBIOSInfo.releaseDate },␉␉// SMbiosdate - 02/29/08␊ |
226 | ␊ |
227 | ␉// Bungo␊ |
228 | ␉{ kSMBTypeBIOSInformation, kSMBWord, getFieldOffset(SMBBIOSInformation, releaseMajor),␊ |
229 | ␉␉kSMBBIOSInformationReleaseKey, NULL,␉(char **)&defaultBIOSInfo.release },␉␉// SMbiosrelease - 0.1 (256)␊ |
230 | ␊ |
231 | ␉/* =========================␊ |
232 | ␉ System Information (Type 1)␊ |
233 | ␉ =========================== */␊ |
234 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, manufacturer),␊ |
235 | ␉␉kSMBSystemInformationManufacturerKey, NULL,␉&defaultSystemInfo.manufacturer␉},␉// SMmanufacturer - Apple Inc.␊ |
236 | ␊ |
237 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, productName),␊ |
238 | ␉␉kSMBSystemInformationProductNameKey, NULL, &defaultSystemInfo.productName },␉␉// SMproductname - MacPro3,1␊ |
239 | ␊ |
240 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, version),␊ |
241 | ␉␉kSMBSystemInformationVersionKey, NULL, &defaultSystemInfo.version },␉␉␉// SMsystemversion - 1.0␊ |
242 | ␊ |
243 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, serialNumber),␊ |
244 | ␉␉kSMBSystemInformationSerialNumberKey, NULL, &defaultSystemInfo.serialNumber },␉␉// SMserial - Serial number␊ |
245 | ␉/* Bungo:␊ |
246 | ␉{kSMBTypeSystemInformation,␉kSMBByte,␉getFieldOffset(SMBSystemInformation, uuid),␊ |
247 | ␉␉kSMBSystemInformationUUIDKey, NULL, NULL},␉␉␉␉␉␉// SMsystemuuid␊ |
248 | ␊ |
249 | ␉{kSMBTypeSystemInformation,␉kSMBByte,␉getFieldOffset(SMBSystemInformation, wakeupReason),␊ |
250 | ␉␉NULL, NULL, NULL},␉␉␉␉␉␉␉␉␉// reason for system wakeup␊ |
251 | ␉*/␊ |
252 | ␊ |
253 | ␉// Bungo␊ |
254 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, skuNumber),␊ |
255 | ␉␉kSMBSystemInformationSKUNumberKey, NULL, &defaultSystemInfo.skuNumber},␉␉␉// SMskunumber - System SKU#␊ |
256 | ␊ |
257 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, family),␊ |
258 | ␉␉kSMBSystemInformationFamilyKey,␉NULL,␉&defaultSystemInfo.family},␉␉␉// SMfamily - MacPro␊ |
259 | ␊ |
260 | ␊ |
261 | ␉/* =========================================␊ |
262 | ␉ Base Board (or Module) Information (Type 2)␊ |
263 | ␉ =========================================== */␊ |
264 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, manufacturer),␊ |
265 | ␉␉kSMBBaseBoardManufacturerKey, NULL, &defaultBaseBoard.manufacturer },␉␉␉// SMboardmanufacturer - Apple Inc.␊ |
266 | ␊ |
267 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, product),␊ |
268 | ␉␉kSMBBaseBoardProductKey, NULL, &defaultBaseBoard.product },␉␉␉␉// SMboardproduct - Mac-F2268DC8␊ |
269 | ␊ |
270 | ␉// Bungo␊ |
271 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, version),␊ |
272 | ␉␉kSMBBaseBoardVersionKey, NULL, &defaultBaseBoard.version },␉␉␉␉// SMboardversion - MacPro3,1␊ |
273 | ␊ |
274 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, serialNumber),␊ |
275 | ␉␉kSMBBaseBoardSerialNumberKey, NULL, &defaultBaseBoard.serialNumber },␉␉␉// SMboardserial - C02140302D5DMT31M␊ |
276 | ␊ |
277 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, assetTag),␊ |
278 | ␉␉kSMBBaseBoardAssetTagKey, NULL, &defaultBaseBoard.assetTag },␉␉␉␉// SMboardassettag - Base Board Asset Tag#␊ |
279 | ␊ |
280 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, locationInChassis),␊ |
281 | ␉␉kSMBBaseBoardLocationInChassisKey, NULL, &defaultBaseBoard.locationInChassis },␉␉// SMboardlocation - Part Component␊ |
282 | ␊ |
283 | ␉{kSMBTypeBaseBoard,␉kSMBByte,␉getFieldOffset(SMBBaseBoard, boardType),␊ |
284 | ␉␉kSMBBaseBoardTypeKey,␉NULL, (char **)&defaultBaseBoard.boardType },␉␉␉// SMboardtype - 10 (Motherboard) all model, 11 (Processor+Memory Module) MacPro␊ |
285 | ␊ |
286 | /*␉{kSMBTypeBaseBoard,␉kSMBByte, getFieldOffset(SMBBaseBoard, numberOfContainedHandles),␊ |
287 | ␉␉NULL , NULL, NULL },␉␉␉␉␉␉␉␉␉// numberOfContainedHandles = 0␊ |
288 | */␊ |
289 | ␉//␊ |
290 | ␊ |
291 | ␉// Bungo␊ |
292 | ␉/* =======================␊ |
293 | ␉ System Enclosure (Type 3)␊ |
294 | ␉ ========================= */␊ |
295 | ␉{kSMBTypeSystemEnclosure,␉kSMBString,␉getFieldOffset(SMBSystemEnclosure, manufacturer),␊ |
296 | ␉␉kSMBSystemEnclosureManufacturerKey, NULL,␉&defaultChassis.manufacturer },␉␉// SMchassismanufacturer - Apple Inc.␊ |
297 | ␊ |
298 | ␉{kSMBTypeSystemEnclosure, kSMBByte,␉getFieldOffset(SMBSystemEnclosure, chassisType),␊ |
299 | ␉␉kSMBSystemEnclosureTypeKey, NULL, (char **)&defaultChassis.chassisType␉},␉␉// SMchassistype - 7␊ |
300 | ␊ |
301 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, version),␊ |
302 | ␉␉kSMBSystemEnclosureVersionKey, NULL, &defaultChassis.version },␉␉␉␉// SMchassisversion - Mac-F42C88C8␊ |
303 | ␊ |
304 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, serialNumber),␊ |
305 | ␉␉kSMBSystemEnclosureSerialNumberKey, NULL, &defaultChassis.serialNumber },␉␉// SMchassisserial␊ |
306 | ␊ |
307 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, assetTag),␊ |
308 | ␉␉kSMBSystemEnclosureAssetTagKey, NULL, &defaultChassis.assetTag },␉␉␉// SMchassisassettag - Pro Enclosure␊ |
309 | ␊ |
310 | ␉/*␊ |
311 | ␉{kSMBTypeSystemEnclosure, kSMBString, getFieldOffset(SMBSystemEnclosure, skuNumber),␊ |
312 | ␉␉NULL, NULL, &defaultChassis.skuNumber },␊ |
313 | ␉*/␊ |
314 | ␊ |
315 | ␉/* ============================␊ |
316 | ␉ Processor Information (Type 4)␊ |
317 | ␉ ============================== */␊ |
318 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, socketDesignation),␊ |
319 | ␉␉kSMBProcessorInformationSocketKey, NULL, NULL},␉␉␉␉␉␉// SMcpusocket -␊ |
320 | ␊ |
321 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, manufacturer),␊ |
322 | ␉␉kSMBProcessorInformationManufacturerKey, NULL, NULL},␉␉␉␉␉// SMcpumanufacturer - Intel(R) Corporation␊ |
323 | ␊ |
324 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, processorVersion),␊ |
325 | ␉␉kSMBProcessorInformationVersionKey, NULL, NULL},␉␉␉␉␉// SMcpuversion␊ |
326 | ␊ |
327 | ␉{kSMBTypeProcessorInformation,␉kSMBWord, getFieldOffset(SMBProcessorInformation, externalClock),␊ |
328 | ␉␉kSMBProcessorInformationExternalClockKey, getProcessorInformationExternalClock,␉NULL},␉// SMcpuexternalclock␊ |
329 | ␊ |
330 | ␉{kSMBTypeProcessorInformation,␉kSMBWord, getFieldOffset(SMBProcessorInformation, maximumClock),␊ |
331 | ␉␉kSMBProcessorInformationMaximumClockKey, getProcessorInformationMaximumClock,␉NULL},␉// SMcpumaximumclock␊ |
332 | ␉// Bungo␊ |
333 | ␉{kSMBTypeProcessorInformation,␉kSMBWord,␉getFieldOffset(SMBProcessorInformation, currentClock),␊ |
334 | ␉␉kSMBProcessorInformationCurrentClockKey, NULL, NULL},␉␉␉␉␉// SMcpucurrentclock␊ |
335 | ␊ |
336 | ␉{kSMBTypeProcessorInformation,␉kSMBByte,␉getFieldOffset(SMBProcessorInformation, processorUpgrade),␊ |
337 | ␉␉kSMBProcessorInformationUpgradeKey, NULL, NULL},␉␉␉␉␉// SMcpuupgrade␊ |
338 | ␉//␊ |
339 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, serialNumber),␊ |
340 | ␉␉kSMBProcessorInformationSerialNumberKey, NULL, NULL},␊ |
341 | ␊ |
342 | ␉// Bungo␊ |
343 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, assetTag),␊ |
344 | ␉␉kSMBProcessorInformationAssetTagKey, NULL, NULL},␉␉␉␉␉// SMcpuassettag␊ |
345 | ␉//␊ |
346 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, partNumber),␊ |
347 | ␉␉kSMBProcessorInformationPartNumberKey, NULL, NULL},␊ |
348 | ␊ |
349 | ␉/* =====================␊ |
350 | ␉ Memory Device (Type 17)␊ |
351 | ␉ ======================= */␊ |
352 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, deviceLocator),␊ |
353 | ␉␉kSMBMemoryDeviceDeviceLocatorKey, NULL, NULL},␊ |
354 | ␊ |
355 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, bankLocator),␊ |
356 | ␉␉kSMBMemoryDeviceBankLocatorKey, NULL, NULL},␊ |
357 | ␊ |
358 | ␉{kSMBTypeMemoryDevice,␉kSMBByte,␉getFieldOffset(SMBMemoryDevice, memoryType),␊ |
359 | ␉␉kSMBMemoryDeviceMemoryTypeKey, getSMBMemoryDeviceMemoryType,␉NULL},␊ |
360 | ␊ |
361 | ␉{kSMBTypeMemoryDevice,␉kSMBWord,␉getFieldOffset(SMBMemoryDevice, memorySpeed),␊ |
362 | ␉␉kSMBMemoryDeviceMemorySpeedKey, getSMBMemoryDeviceMemorySpeed,␉NULL},␊ |
363 | ␊ |
364 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, manufacturer),␊ |
365 | ␉␉kSMBMemoryDeviceManufacturerKey, getSMBMemoryDeviceManufacturer, NULL},␊ |
366 | ␊ |
367 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, serialNumber),␊ |
368 | ␉␉kSMBMemoryDeviceSerialNumberKey, getSMBMemoryDeviceSerialNumber, NULL},␊ |
369 | ␊ |
370 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, assetTag),␊ |
371 | ␉␉kSMBMemoryDeviceAssetTagKey, NULL, NULL},␊ |
372 | ␊ |
373 | ␉{kSMBTypeMemoryDevice,␉kSMBWord,␉getFieldOffset(SMBMemoryDevice, errorHandle),␊ |
374 | ␉␉NULL, getSMBMemoryDeviceMemoryErrorHandle, NULL},␊ |
375 | ␊ |
376 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, partNumber),␊ |
377 | ␉␉kSMBMemoryDevicePartNumberKey, getSMBMemoryDevicePartNumber, NULL},␊ |
378 | ␊ |
379 | ␉/* ============␊ |
380 | ␉ Apple Specific␊ |
381 | ␉ ============== */␊ |
382 | ␊ |
383 | ␉// Firmware Volume Description (Apple Specific - Type 128)␊ |
384 | ␉// kSMBTypeFirmwareVolume␊ |
385 | ␉{kSMBTypeFirmwareVolume, kSMBDWord, getFieldOffset(SMBFirmwareVolume, FirmwareFeatures),␊ |
386 | ␉␉kSMBFirmwareVolumeFirmwareFeaturesKey, NULL, NULL},␊ |
387 | ␉{kSMBTypeFirmwareVolume, kSMBDWord, getFieldOffset(SMBFirmwareVolume, FirmwareFeaturesMask),␊ |
388 | ␉␉kSMBFirmwareVolumeFirmwareFeaturesMaskKey, NULL, NULL},␊ |
389 | ␊ |
390 | ␉// Memory SPD Data (Apple Specific - Type 130)␊ |
391 | ␉// kSMBTypeMemorySPD␊ |
392 | ␊ |
393 | ␉// OEM Processor Type (Apple Specific - Type 131)␊ |
394 | ␉{kSMBTypeOemProcessorType,␉kSMBWord,␉getFieldOffset(SMBOemProcessorType, ProcessorType),␉kSMBOemProcessorTypeKey,␉␉␊ |
395 | ␉␉getSMBOemProcessorType,␉␉␉NULL},␊ |
396 | ␊ |
397 | ␉// OEM Processor Bus Speed (Apple Specific - Type 132)␊ |
398 | ␉{kSMBTypeOemProcessorBusSpeed,␉kSMBWord,␉getFieldOffset(SMBOemProcessorBusSpeed, ProcessorBusSpeed),␉kSMBOemProcessorBusSpeedKey,␉␊ |
399 | ␉␉getSMBOemProcessorBusSpeed,␉NULL}␊ |
400 | ␊ |
401 | ␉// OEM Platform Feature (Apple Specific - Type 133)␊ |
402 | ␉/*␊ |
403 | ␉{kSMBTypeOemPlatformFeature,␉kSMBWord,␉getFieldOffset(SMBOemPlatformFeature, PlatformFeature),␉kSMBOemPlatformFeatureKey,␊ |
404 | ␉␉getSMBOemPlatformFeature,␉NULL}␊ |
405 | ␊ |
406 | ␉// OEM Platform Feature (Apple Specific - Type 134)␊ |
407 | ␊ |
408 | ␉{kSMBTypeOemSMCVersion,␉kSMBWord,␉getFieldOffset(SMBOemSMCVersion, SMCVersion),␉kSMBOemSMCVersionKey,␊ |
409 | ␉␉getSMBOemSMCVersion,␉NULL}␊ |
410 | ␉*/␊ |
411 | ␊ |
412 | };␊ |
413 | ␊ |
414 | int numOfSetters = sizeof(SMBSetters) / sizeof(SMBValueSetter);␊ |
415 | ␊ |
416 | ␊ |
417 | SMBEntryPoint *origeps␉␉= 0;␊ |
418 | SMBEntryPoint *neweps␉␉= 0;␊ |
419 | ␊ |
420 | static uint8_t stringIndex;␉// increament when a string is added and set the field value accordingly␊ |
421 | static uint8_t stringsSize;␉// add string size␊ |
422 | ␊ |
423 | static SMBWord tableLength␉= 0;␊ |
424 | static SMBWord handle␉␉= 0;␊ |
425 | static SMBWord maxStructSize␉= 0;␊ |
426 | static SMBWord structureCount␉= 0;␊ |
427 | ␊ |
428 | //-------------------------------------------------------------------------------------------------------------------------␊ |
429 | // Default SMBIOS Data␊ |
430 | //-------------------------------------------------------------------------------------------------------------------------␊ |
431 | /* Rewrite: use a struct */␊ |
432 | ␊ |
433 | // Bungo: suggest to not mixing data from different Mac models, use real Mac SMBIOS dumps␊ |
434 | ␊ |
435 | #define kDefaultVendorManufacturer␉␉␉"Apple Inc."␊ |
436 | //#define kDefaultBIOSReleaseDate␉␉␉"11/06/2009"␊ |
437 | #define kDefaultSerialNumber␉␉␉␉"SOMESRLNMBR"␊ |
438 | //Bungo␊ |
439 | #define kDefaultSkuNumber␉␉␉␉"Default SKU#"␊ |
440 | #define kDefaultAssetTag␉␉␉␉"Default Asset Tag#"␊ |
441 | //#define kDefaultBoardType␉␉␉␉"10" // 0xA␊ |
442 | //#define kDefaultBoardProcessorType␉␉␉"11" // 0xB␊ |
443 | #define kDefaultSystemVersion␉␉␉␉"1.0"␊ |
444 | #define kDefaultBIOSRelease␉␉␉␉256 // 256 = 0x0100 -> swap bytes: 0x0001 -> Release: 0.1 (see SMBIOS spec. table Type 0)␊ |
445 | ␊ |
446 | ␊ |
447 | //=========== Mac mini ===========␊ |
448 | #define kDefaultMacMiniFamily␉␉␉␉"Napa Mac" // Macmini2,1 family = "Napa Mac" not "Mac mini"␊ |
449 | #define kDefaultMacMini␉␉␉␉␉"Macmini2,1"␊ |
450 | #define kDefaultMacMiniBIOSVersion␉␉␉" MM21.88Z.009A.B00.0706281359"␊ |
451 | #define kDefaultMacMiniBIOSReleaseDate␉␉␉"06/28/07"␊ |
452 | #define kDefaultMacMiniBoardProduct␉␉␉"Mac-F4208EAA"␊ |
453 | ␊ |
454 | //=========== MacBook ===========␊ |
455 | #define kDefaultMacBookFamily␉␉␉␉"MacBook"␊ |
456 | ␊ |
457 | #define kDefaultMacBook␉␉␉␉␉"MacBook4,1"␊ |
458 | #define kDefaultMacBookBIOSVersion␉␉␉" MB41.88Z.00C1.B00.0802091535"␊ |
459 | #define kDefaultMacBookBIOSReleaseDate␉␉␉"02/09/08"␊ |
460 | #define kDefaultMacBookBoardProduct␉␉␉"Mac-F22788A9"␊ |
461 | ␊ |
462 | //=========== MacBookAir ===========␊ |
463 | #define kDefaultMacBookAirFamily␉␉␉"MacBook Air"␊ |
464 | ␊ |
465 | // MacBookAir5,2␊ |
466 | #define kDefaultMacBookAir␉␉␉␉"MacBookAir5,2"␊ |
467 | #define kDefaultMacBookAirBIOSVersion␉␉␉" MBA51.88Z.00EF.B00.1205221442"␊ |
468 | #define kDefaultMacBookAirBIOSReleaseDate␉␉"05/10/12"␊ |
469 | #define kDefaultMacBookBoardAirProduct␉␉␉"Mac-2E6FAB96566FE58C"␊ |
470 | ␊ |
471 | //=========== MacBookPro ===========␊ |
472 | #define kDefaultMacBookProFamily␉␉␉"MacBook Pro"␊ |
473 | ␊ |
474 | #define kDefaultMacBookPro␉␉␉␉"MacBookPro4,1"␊ |
475 | #define kDefaultMacBookProBIOSVersion␉␉␉" MBP41.88Z.00C1.B03.0802271651"␊ |
476 | #define kDefaultMacBookProBIOSReleaseDate␉␉"02/27/08"␊ |
477 | #define kDefaultMacBookProBoardProduct␉␉␉"Mac-F42C89C8"␊ |
478 | ␊ |
479 | //=========== iMac ===========␊ |
480 | #define kDefaultiMacFamily␉␉␉␉"iMac"␊ |
481 | ␊ |
482 | #define kDefaultiMac␉␉␉␉␉"iMac8,1"␊ |
483 | #define kDefaultiMacBIOSVersion␉␉␉␉" IM81.88Z.00C1.B00.0903051113"␊ |
484 | #define kDefaultiMacBIOSReleaseDate␉␉␉"02/09/08"␊ |
485 | #define kDefaultiMacBoardProduct␉␉␉"Mac-F227BEC8"␊ |
486 | #define kDefaultMacFamily␉␉␉␉"Mac" // iMac8,1 family = "Mac" not "iMac"␊ |
487 | ␊ |
488 | // iMac10,1␊ |
489 | // iMac11,1 core i3/i5/i7␊ |
490 | #define kDefaultiMacNehalem␉␉␉␉"iMac11,1"␊ |
491 | #define kDefaultiMacNehalemBIOSVersion␉␉␉" IM111.88Z.0034.B02.1003171314"␊ |
492 | #define kDefaultiMacNehalemBIOSReleaseDate␉␉"03/17/10"␊ |
493 | #define kDefaultiMacNehalemBoardProduct␉␉␉"Mac-F2268DAE"␊ |
494 | ␊ |
495 | // iMac12,1␊ |
496 | #define kDefaultiMacSandy␉␉␉␉"iMac12,1"␊ |
497 | #define kDefaultiMacSandyBIOSVersion␉␉␉" IM121.88Z.0047.B00.1102091756"␊ |
498 | #define kDefaultiMacSandyBIOSReleaseDate␉␉"04/22/11"␊ |
499 | #define kDefaultiMacSandyBoardProduct␉␉␉"Mac-942B5BF58194151B"␊ |
500 | ␊ |
501 | //=========== MacPro ===========␊ |
502 | #define kDefaultMacProFamily␉␉␉␉"MacPro" // MacPro's family = "MacPro" not "Mac Pro"␊ |
503 | ␊ |
504 | #define kDefaultMacPro␉␉␉␉␉"MacPro3,1"␊ |
505 | #define kDefaultMacProBIOSVersion␉␉␉" MP31.88Z.006C.B05.0802291410"␊ |
506 | #define kDefaultMacProBIOSReleaseDate␉␉␉"02/29/08"␊ |
507 | #define kDefaultMacProBoardProduct␉␉␉"Mac-F42C88C8"␊ |
508 | ␊ |
509 | // Mac Pro 4,1 core i7/Xeon␊ |
510 | #define kDefaultMacProNahWestSystemVersion␉␉"0.0"␊ |
511 | ␊ |
512 | #define kDefaultMacProNehalem␉␉␉␉"MacPro4,1"␊ |
513 | #define kDefaultMacProNehalemBIOSVersion␉␉" MP41.88Z.0081.B07.0910130729"␊ |
514 | #define kDefaultMacProNehalemBIOSReleaseDate␉␉"10/13/09"␊ |
515 | #define kDefaultMacProNehalemBoardProduct␉␉"Mac-F221BEC8"␊ |
516 | ␊ |
517 | // Mac Pro 5,1 core i7/Xeon␊ |
518 | #define kDefaultMacProWestmere␉␉␉␉"MacPro5,1"␊ |
519 | #define kDefaultMacProWestmereBIOSVersion␉␉" MP51.88Z.007F.B03.1010071432"␊ |
520 | #define kDefaultMacProWestmereBIOSReleaseDate␉␉"10/07/10"␊ |
521 | #define kDefaultMacProWestmereBoardProduct␉␉"Mac-F221BEC8"␊ |
522 | ␊ |
523 | // Mac Pro 6,1␊ |
524 | #define kDefaultMacProHaswell␉␉␉␉"MacPro6,1"␊ |
525 | #define kDefaultMacProHaswellBIOSVersion␉␉"MP61.88Z.0116.B25.1702171857"␊ |
526 | #define kDefaultMacProHaswellBIOSReleaseDate␉␉"02/17/2017"␊ |
527 | #define kDefaultMacProHaswellBoardProduct␉␉"Mac-F60DEB81FF30ACF6"␊ |
528 | ␊ |
529 | /* ============================================ */␊ |
530 | ␊ |
531 | bool useSMBIOSdefaults = true;␉// Bungo␊ |
532 | ␊ |
533 | SMBByte PlatformType␉␉= 1;␉// Bungo: same as Platfom.Type in platform.h. Because can't get from ACPI FADT PM profile and platformCPUFeature(CPU_FEATURE_MOBILE)) doesn't work as expect, FIXING NEEDED.␊ |
534 | ␊ |
535 | /* Rewrite this function */␊ |
536 | void setDefaultSMBData(void) // Bungo: setting data from real Macs␊ |
537 | {␊ |
538 | ␉defaultBIOSInfo.vendor = kDefaultVendorManufacturer;␊ |
539 | ␉defaultBIOSInfo.release = kDefaultBIOSRelease; // Bungo␊ |
540 | ␊ |
541 | ␉defaultSystemInfo.manufacturer = kDefaultVendorManufacturer;␊ |
542 | ␉defaultSystemInfo.version = kDefaultSystemVersion;␊ |
543 | ␉defaultSystemInfo.serialNumber = kDefaultSerialNumber;␊ |
544 | ␉defaultSystemInfo.skuNumber = kDefaultSkuNumber; // Bungo␊ |
545 | ␊ |
546 | ␉defaultBaseBoard.manufacturer = kDefaultVendorManufacturer;␊ |
547 | ␉defaultBaseBoard.serialNumber = kDefaultSerialNumber;␊ |
548 | ␉defaultBaseBoard.assetTag = kDefaultAssetTag;␊ |
549 | ␊ |
550 | ␉defaultChassis.manufacturer = kDefaultVendorManufacturer;␊ |
551 | ␉defaultChassis.serialNumber = kDefaultSerialNumber;␊ |
552 | ␉defaultChassis.assetTag = kDefaultAssetTag;␊ |
553 | ␉defaultChassis.skuNumber = kDefaultSkuNumber;␊ |
554 | ␊ |
555 | ␉// if (platformCPUFeature(CPU_FEATURE_MOBILE)) Bungo: doesn't recognise correctly, need fixing␊ |
556 | ␉if (PlatformType == 2) // this works but it's a substitute␊ |
557 | ␉{␊ |
558 | ␉␉if (Platform.CPU.NoCores > 1)␊ |
559 | ␉␉{␊ |
560 | ␉␉␉defaultSystemInfo.productName = kDefaultMacBookPro;␊ |
561 | ␉␉␉defaultBIOSInfo.version = kDefaultMacBookProBIOSVersion;␊ |
562 | ␉␉␉defaultBIOSInfo.releaseDate = kDefaultMacBookProBIOSReleaseDate;␊ |
563 | ␉␉␉defaultSystemInfo.family = kDefaultMacBookProFamily;␊ |
564 | ␉␉␉defaultBaseBoard.product = kDefaultMacBookProBoardProduct;␊ |
565 | ␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
566 | ␉␉␉defaultChassis.chassisType = kSMBChassisTypeUnknown;␊ |
567 | ␉␉}␊ |
568 | ␉␉else␊ |
569 | ␉␉{␊ |
570 | ␉␉␉defaultSystemInfo.productName = kDefaultMacBook;␊ |
571 | ␉␉␉defaultBIOSInfo.version = kDefaultMacBookBIOSVersion;␊ |
572 | ␉␉␉defaultBIOSInfo.releaseDate = kDefaultMacBookBIOSReleaseDate;␊ |
573 | ␉␉␉defaultSystemInfo.family = kDefaultMacBookFamily;␊ |
574 | ␉␉␉defaultBaseBoard.product = kDefaultMacBookBoardProduct;␊ |
575 | ␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
576 | ␉␉␉defaultChassis.chassisType = kSMBChassisTypeUnknown;␊ |
577 | ␉␉}␊ |
578 | ␉}␊ |
579 | ␉else␊ |
580 | ␉{␊ |
581 | ␉␉switch (Platform.CPU.NoCores)␊ |
582 | ␉␉{␊ |
583 | ␉␉␉case 1:␊ |
584 | ␉␉␉␉defaultBIOSInfo.version = kDefaultMacMiniBIOSVersion;␊ |
585 | ␉␉␉␉defaultBIOSInfo.releaseDate = kDefaultMacMiniBIOSReleaseDate;␊ |
586 | ␉␉␉␉defaultSystemInfo.productName = kDefaultMacMini;␊ |
587 | ␉␉␉␉defaultSystemInfo.family = kDefaultMacMiniFamily;␊ |
588 | ␉␉␉␉defaultBaseBoard.product = kDefaultMacMiniBoardProduct;␊ |
589 | ␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardUnknown;␊ |
590 | ␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeLowProfileDesktop;␊ |
591 | ␉␉␉␉break;␊ |
592 | ␊ |
593 | ␉␉␉case 2:␊ |
594 | ␉␉␉␉defaultBIOSInfo.version = kDefaultiMacBIOSVersion;␊ |
595 | ␉␉␉␉defaultBIOSInfo.releaseDate = kDefaultiMacBIOSReleaseDate;␊ |
596 | ␉␉␉␉defaultSystemInfo.productName = kDefaultiMac;␊ |
597 | ␉␉␉␉defaultSystemInfo.family = kDefaultMacFamily; // iMac8,1 family = Mac␊ |
598 | ␉␉␉␉defaultBaseBoard.product = kDefaultiMacBoardProduct;␊ |
599 | ␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
600 | ␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeAllInOne;␊ |
601 | ␉␉␉␉break;␊ |
602 | ␉␉␉default:␊ |
603 | ␉␉␉{␊ |
604 | ␉␉␉␉switch (Platform.CPU.Family)␊ |
605 | ␉␉␉␉{␊ |
606 | ␉␉␉␉␉case 0x06:␊ |
607 | ␉␉␉␉␉{␊ |
608 | ␉␉␉␉␉␉switch (Platform.CPU.Model)␊ |
609 | ␉␉␉␉␉␉{␊ |
610 | ␉␉␉␉␉␉␉case CPUID_MODEL_FIELDS:␉␉// Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)␊ |
611 | ␉␉␉␉␉␉␉case CPUID_MODEL_CLARKDALE:␊ |
612 | ␉␉␉␉␉␉␉case CPUID_MODEL_DALES:␉␉// Intel Core i3, i5 LGA1156 (32nm)␊ |
613 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultiMacNehalemBIOSVersion;␊ |
614 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉␉= kDefaultiMacNehalemBIOSReleaseDate;␊ |
615 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultiMacNehalem;␊ |
616 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultiMacFamily;␊ |
617 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultiMacNehalemBoardProduct;␊ |
618 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
619 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeAllInOne;␊ |
620 | ␉␉␉␉␉␉␉␉break;␊ |
621 | ␊ |
622 | ␉␉␉␉␉␉␉case CPUID_MODEL_SANDYBRIDGE:␉␉// Intel Core i3, i5, i7 LGA1155 (32nm)␊ |
623 | ␉␉␉␉␉␉␉case CPUID_MODEL_IVYBRIDGE:␉␉// Intel Core i3, i5, i7 LGA1155 (22nm)␊ |
624 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version = kDefaultiMacSandyBIOSVersion;␊ |
625 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate = kDefaultiMacSandyBIOSReleaseDate;␊ |
626 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultiMacSandy;␊ |
627 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family = kDefaultiMacFamily;␊ |
628 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultiMacSandyBoardProduct;␊ |
629 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
630 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeAllInOne;␊ |
631 | ␉␉␉␉␉␉␉␉break;␊ |
632 | ␊ |
633 | ␉␉␉␉␉␉␉case CPUID_MODEL_NEHALEM:␉␉// Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm)␊ |
634 | ␉␉␉␉␉␉␉case CPUID_MODEL_NEHALEM_EX:␉␉// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x␊ |
635 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProNehalemBIOSVersion;␊ |
636 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProNehalemBIOSReleaseDate;␊ |
637 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacProNehalem;␊ |
638 | ␉␉␉␉␉␉␉␉defaultSystemInfo.version = kDefaultMacProNahWestSystemVersion;␊ |
639 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
640 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProNehalemBoardProduct;␊ |
641 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardProcessorMemoryModule;␊ |
642 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeTower;␊ |
643 | ␉␉␉␉␉␉␉␉break;␊ |
644 | ␊ |
645 | ␉␉␉␉␉␉␉case CPUID_MODEL_WESTMERE:␉␉// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core␊ |
646 | ␉␉␉␉␉␉␉case CPUID_MODEL_WESTMERE_EX:␉␉// Intel Xeon E7␊ |
647 | ␉␉␉␉␉␉␉case CPUID_MODEL_JAKETOWN:␉␉// Intel Core i7, Xeon E5 LGA2011 (32nm)␊ |
648 | ␉␉␉␉␉␉␉case CPUID_MODEL_IVYBRIDGE_XEON:␉// Intel Core i7, Xeon E5 v2 LGA2011 (22nm)␊ |
649 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProWestmereBIOSVersion;␊ |
650 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProWestmereBIOSReleaseDate;␊ |
651 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacProWestmere;␊ |
652 | ␉␉␉␉␉␉␉␉defaultSystemInfo.version = kDefaultMacProNahWestSystemVersion;␊ |
653 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
654 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProWestmereBoardProduct;␊ |
655 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardProcessorMemoryModule;␊ |
656 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeTower;␊ |
657 | ␉␉␉␉␉␉␉␉break;␊ |
658 | ␊ |
659 | ␉␉␉␉␉␉␉default:␊ |
660 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProBIOSVersion;␊ |
661 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProBIOSReleaseDate;␊ |
662 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacPro;␊ |
663 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
664 | ␉␉␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProBoardProduct;␊ |
665 | ␉␉␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
666 | ␉␉␉␉␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeUnknown;␊ |
667 | ␉␉␉␉␉␉␉␉break;␊ |
668 | ␉␉␉␉␉␉}␊ |
669 | ␉␉␉␉␉␉break;␊ |
670 | ␉␉␉␉␉}␊ |
671 | ␉␉␉␉␉default:␊ |
672 | ␉␉␉␉␉␉defaultBIOSInfo.version␉␉= kDefaultMacProBIOSVersion;␊ |
673 | ␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉= kDefaultMacProBIOSReleaseDate;␊ |
674 | ␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacPro;␊ |
675 | ␉␉␉␉␉␉defaultSystemInfo.family␉= kDefaultMacProFamily;␊ |
676 | ␉␉␉␉␉␉defaultBaseBoard.product = kDefaultMacProBoardProduct;␊ |
677 | ␉␉␉␉␉␉defaultBaseBoard.boardType = kSMBBaseBoardMotherboard;␊ |
678 | ␉␉␉␉␉␉defaultChassis.chassisType = kSMBChassisTypeUnknown;␊ |
679 | ␉␉␉␉␉␉break;␊ |
680 | ␉␉␉␉}␊ |
681 | ␉␉␉␉break;␊ |
682 | ␉␉␉}␊ |
683 | ␉␉}␊ |
684 | ␉}␊ |
685 | }␊ |
686 | ␊ |
687 | /* Used for SM*n smbios.plist keys */␊ |
688 | bool getSMBValueForKey(SMBStructHeader *structHeader, const char *keyString, const char **string, returnType *value)␊ |
689 | {␊ |
690 | ␉static int idx = -1;␊ |
691 | ␉static int current = -1;␊ |
692 | ␉int len;␊ |
693 | ␉char key[24];␊ |
694 | ␊ |
695 | ␉if (current != structHeader->handle)␊ |
696 | ␉{␊ |
697 | ␉␉idx++;␊ |
698 | ␉␉current = structHeader->handle;␊ |
699 | ␉}␊ |
700 | ␊ |
701 | ␉sprintf(key, "%s%d", keyString, idx);␊ |
702 | ␊ |
703 | ␉if (value)␊ |
704 | ␉{␊ |
705 | ␉␉if (getIntForKey(key, (int *)&(value->dword), SMBPlist))␊ |
706 | ␉␉{␊ |
707 | ␉␉␉return true;␊ |
708 | ␉␉}␊ |
709 | ␉}␊ |
710 | ␉else␊ |
711 | ␉{␊ |
712 | ␉␉if (getValueForKey(key, string, &len, SMBPlist))␊ |
713 | ␉␉{␊ |
714 | ␉␉␉return true;␊ |
715 | ␉␉}␊ |
716 | ␉}␊ |
717 | ␉return false;␊ |
718 | }␊ |
719 | ␊ |
720 | char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)␊ |
721 | {␊ |
722 | ␉if (!field || !structHeader)␊ |
723 | ␉{␊ |
724 | ␉␉return NULL;␊ |
725 | ␉}␊ |
726 | ␊ |
727 | ␉uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;␊ |
728 | ␊ |
729 | ␉for (field--; (field > 0) && (*stringPtr > 0) &&(*(uint16_t *)stringPtr != 0);␊ |
730 | ␉␉field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));␊ |
731 | ␊ |
732 | ␉return (char *)stringPtr;␊ |
733 | }␊ |
734 | ␊ |
735 | void setSMBStringForField(SMBStructHeader *structHeader, const char *string, uint8_t *field)␊ |
736 | {␊ |
737 | ␉int strSize;␊ |
738 | ␊ |
739 | ␉if (!field)␊ |
740 | ␉{␊ |
741 | ␉␉return;␊ |
742 | ␉}␊ |
743 | ␊ |
744 | ␉if (!string)␊ |
745 | ␉{␊ |
746 | ␉␉*field = 0;␊ |
747 | ␉␉return;␊ |
748 | ␉}␊ |
749 | ␊ |
750 | ␉strSize = strlen(string);␊ |
751 | ␊ |
752 | ␉// remove any spaces found at the end but only in MemoryDevice avoiding errors␊ |
753 | ␉if (structHeader->type == kSMBTypeMemoryDevice)␊ |
754 | ␉{␊ |
755 | ␉␉while ((strSize != 0) && (string[strSize - 1] == ' '))␊ |
756 | ␉␉{␊ |
757 | ␉␉␉strSize--;␊ |
758 | ␉␉}␊ |
759 | ␉}␊ |
760 | ␊ |
761 | ␉if (strSize == 0)␊ |
762 | ␉{␊ |
763 | ␉␉*field = 0;␊ |
764 | ␉␉return;␊ |
765 | ␉}␊ |
766 | ␊ |
767 | ␉memcpy((uint8_t *)structHeader + structHeader->length + stringsSize, string, strSize);␊ |
768 | ␉*field = stringIndex;␊ |
769 | ␊ |
770 | ␉stringIndex++;␊ |
771 | ␉stringsSize += strSize + 1;␊ |
772 | }␊ |
773 | ␊ |
774 | bool setSMBValue(SMBStructPtrs *structPtr, int idx, returnType *value)␊ |
775 | {␊ |
776 | ␉const char *string = 0;␊ |
777 | ␉int len;␊ |
778 | ␉bool parsed;␊ |
779 | ␉int val;␊ |
780 | ␊ |
781 | ␉if (numOfSetters <= idx)␊ |
782 | ␉{␊ |
783 | ␉␉return false;␊ |
784 | ␉}␊ |
785 | ␊ |
786 | ␉switch (SMBSetters[idx].valueType)␊ |
787 | ␉{␊ |
788 | ␉␉case kSMBString:␊ |
789 | ␉␉{␊ |
790 | ␉␉␉if (SMBSetters[idx].keyString)␊ |
791 | ␉␉␉{␊ |
792 | ␉␉␉␉if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist))␊ |
793 | ␉␉␉␉{␊ |
794 | ␉␉␉␉␉break;␊ |
795 | ␉␉␉␉}␊ |
796 | ␉␉␉␉else␊ |
797 | ␉␉␉␉{␊ |
798 | ␉␉␉␉␉if (structPtr->orig->type == kSMBTypeMemoryDevice)␉// MemoryDevice only␊ |
799 | ␉␉␉␉␉{␊ |
800 | ␉␉␉␉␉␉if (getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, &string, NULL))␊ |
801 | ␉␉␉␉␉␉{␊ |
802 | ␉␉␉␉␉␉␉break;␊ |
803 | ␉␉␉␉␉␉}␊ |
804 | ␉␉␉␉␉}␊ |
805 | ␉␉␉␉}␊ |
806 | ␊ |
807 | ␉␉␉}␊ |
808 | ␉␉␉if (SMBSetters[idx].getSMBValue)␊ |
809 | ␉␉␉{␊ |
810 | ␉␉␉␉if (SMBSetters[idx].getSMBValue((returnType *)&string))␊ |
811 | ␉␉␉␉{␊ |
812 | ␉␉␉␉␉break;␊ |
813 | ␉␉␉␉}␊ |
814 | ␉␉␉}␊ |
815 | ␉␉␉// if ((SMBSetters[idx].defaultValue) && *(SMBSetters[idx].defaultValue)) Bungo␊ |
816 | ␉␉␉if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue))␊ |
817 | ␉␉␉{␊ |
818 | ␉␉␉␉string = *(SMBSetters[idx].defaultValue);␊ |
819 | ␉␉␉␉break;␊ |
820 | ␉␉␉}␊ |
821 | ␉␉␉string = getSMBStringForField(structPtr->orig, *(uint8_t *)value);␊ |
822 | ␉␉␉break;␊ |
823 | ␉␉}␊ |
824 | ␊ |
825 | ␉␉case kSMBByte:␊ |
826 | ␉␉case kSMBWord:␊ |
827 | ␉␉case kSMBDWord:␊ |
828 | ␉␉case kSMBQWord:␊ |
829 | ␉␉␉if (SMBSetters[idx].keyString)␊ |
830 | ␉␉␉{␊ |
831 | ␉␉␉␉parsed = getIntForKey(SMBSetters[idx].keyString, &val, SMBPlist);␊ |
832 | ␉␉␉␉if (!parsed)␊ |
833 | ␉␉␉␉{␊ |
834 | ␉␉␉␉␉if (structPtr->orig->type == kSMBTypeMemoryDevice) // MemoryDevice only␊ |
835 | ␉␉␉␉␉{␊ |
836 | ␉␉␉␉␉␉parsed = getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, NULL, (returnType *)&val);␊ |
837 | ␉␉␉␉␉}␊ |
838 | ␉␉␉␉}␊ |
839 | ␊ |
840 | ␉␉␉␉if (parsed)␊ |
841 | ␉␉␉␉{␊ |
842 | ␉␉␉␉␉switch (SMBSetters[idx].valueType)␊ |
843 | ␉␉␉␉␉{␊ |
844 | ␉␉␉␉␉␉case kSMBByte:␊ |
845 | ␉␉␉␉␉␉␉value->byte = (uint8_t)val;␊ |
846 | ␉␉␉␉␉␉␉break;␊ |
847 | ␉␉␉␉␉␉case kSMBWord:␊ |
848 | ␉␉␉␉␉␉␉value->word = (uint16_t)val;␊ |
849 | ␉␉␉␉␉␉␉break;␊ |
850 | ␉␉␉␉␉␉case kSMBQWord:␊ |
851 | ␉␉␉␉␉␉␉value->qword = (uint64_t)val;␊ |
852 | ␉␉␉␉␉␉␉break;␊ |
853 | ␉␉␉␉␉␉case kSMBDWord:␊ |
854 | ␉␉␉␉␉␉default:␊ |
855 | ␉␉␉␉␉␉␉value->dword = (uint32_t)val;␊ |
856 | ␉␉␉␉␉␉␉break;␊ |
857 | ␉␉␉␉␉}␊ |
858 | ␉␉␉␉␉return true;␊ |
859 | ␉␉␉␉}␊ |
860 | ␉␉␉}␊ |
861 | ␊ |
862 | ␉␉␉if (SMBSetters[idx].getSMBValue)␊ |
863 | ␉␉␉{␊ |
864 | ␉␉␉␉if (SMBSetters[idx].getSMBValue(value))␊ |
865 | ␉␉␉␉{␊ |
866 | ␉␉␉␉␉return true;␊ |
867 | ␉␉␉␉}␊ |
868 | ␉␉␉}␊ |
869 | // #if 0 Bungo: enables code below␊ |
870 | ␉␉␉// if (*(SMBSetters[idx].defaultValue)) Bungo␊ |
871 | ␉␉␉if (useSMBIOSdefaults && SMBSetters[idx].defaultValue && *(SMBSetters[idx].defaultValue))␊ |
872 | ␉␉␉{␊ |
873 | ␉␉␉// value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue); Bungo␊ |
874 | ␉␉␉switch (SMBSetters[idx].valueType) {␊ |
875 | ␉␉␉␉case kSMBByte:␊ |
876 | ␉␉␉␉␉value->byte = *(uint8_t *)(SMBSetters[idx].defaultValue);␊ |
877 | ␉␉␉␉␉break;␊ |
878 | ␉␉␉␉case kSMBWord:␊ |
879 | ␉␉␉␉␉value->word = *(uint16_t *)(SMBSetters[idx].defaultValue);␊ |
880 | ␉␉␉␉␉break;␊ |
881 | ␉␉␉␉case kSMBQWord:␊ |
882 | ␉␉␉␉␉value->qword = *(uint64_t *)(SMBSetters[idx].defaultValue);␊ |
883 | ␉␉␉␉␉break;␊ |
884 | ␉␉␉␉case kSMBDWord:␊ |
885 | ␉␉␉␉default:␊ |
886 | ␉␉␉␉␉value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue);␊ |
887 | ␉␉␉␉␉break;␊ |
888 | ␉␉␉}␊ |
889 | ␉␉␉return true;␊ |
890 | ␉␉}␊ |
891 | // #endif Bungo␊ |
892 | ␉␉break;␊ |
893 | ␉}␊ |
894 | ␊ |
895 | ␉// if (SMBSetters[idx].valueType == kSMBString && string) Bungo: use null string too -> "Not Specified"␊ |
896 | ␉if ((SMBSetters[idx].valueType == kSMBString) && string)␊ |
897 | ␉{␊ |
898 | ␉␉setSMBStringForField(structPtr->new, string, &value->byte);␊ |
899 | ␉}␊ |
900 | ␉return true;␊ |
901 | }␊ |
902 | ␊ |
903 | //-------------------------------------------------------------------------------------------------------------------------␊ |
904 | // Apple Specific␊ |
905 | //-------------------------------------------------------------------------------------------------------------------------␊ |
906 | ␊ |
907 | /* ===========================================␊ |
908 | Firmware Volume (Apple Specific - Type 128)␊ |
909 | ============================================= */␊ |
910 | void addSMBFirmwareVolume(SMBStructPtrs *structPtr)␊ |
911 | {␊ |
912 | ␉int val;␊ |
913 | ␉␊ |
914 | ␉//␊ |
915 | ␉// Several old Macs don't have a firmware volume block in their SMBIOS.␊ |
916 | ␉// Therefore, the block will only be added if the keys are set in the plist␊ |
917 | ␉// file.␊ |
918 | ␉//␊ |
919 | ␉if (getIntForKey(kSMBFirmwareVolumeFirmwareFeaturesKey, &val, SMBPlist) &&␊ |
920 | ␉ getIntForKey(kSMBFirmwareVolumeFirmwareFeaturesMaskKey, &val, SMBPlist))␊ |
921 | ␉{␊ |
922 | ␉␉SMBFirmwareVolume *p = (SMBFirmwareVolume *)structPtr->new;␊ |
923 | ␊ |
924 | ␉␉// initialize new table␊ |
925 | ␉␉bzero(p, sizeof(SMBFirmwareVolume));␊ |
926 | ␊ |
927 | ␉␉// common rules␊ |
928 | ␉␉p->header.type = kSMBTypeFirmwareVolume;␊ |
929 | ␉␉p->header.length = sizeof(SMBFirmwareVolume);␊ |
930 | ␉␉p->header.handle = 0x8000;␊ |
931 | ␊ |
932 | ␉␉setSMBValue(structPtr, numOfSetters - 4 , (returnType *)(void *)&(p->FirmwareFeatures));␊ |
933 | ␉␉setSMBValue(structPtr, numOfSetters - 3 , (returnType *)(void *)&(p->FirmwareFeaturesMask));␊ |
934 | ␊ |
935 | ␉␉p->RegionCount = 1;␊ |
936 | ␉␉p->RegionType[0] = FW_REGION_MAIN;␊ |
937 | ␉␉p->FlashMap[0].StartAddress = 0xFFE00000;␊ |
938 | ␉␉p->FlashMap[0].EndAddress = 0xFFEFFFFF;␊ |
939 | ␊ |
940 | ␉␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBFirmwareVolume) + 2);␊ |
941 | ␉␉tableLength += sizeof(SMBFirmwareVolume) + 2;␊ |
942 | ␉␉structureCount++;␊ |
943 | ␉}␊ |
944 | ␊ |
945 | ␉return;␊ |
946 | }␊ |
947 | ␊ |
948 | /* ===========================================␊ |
949 | Memory SPD Data (Apple Specific - Type 130)␊ |
950 | ============================================= */␊ |
951 | void addSMBMemorySPD(SMBStructPtrs *structPtr)␊ |
952 | {␊ |
953 | ␉/* SPD data from Platform.RAM.spd */␊ |
954 | ␉return;␊ |
955 | }␊ |
956 | ␊ |
957 | /* ============================================␊ |
958 | OEM Processor Type (Apple Specific - Type 131)␊ |
959 | ============================================== */␊ |
960 | void addSMBOemProcessorType(SMBStructPtrs *structPtr)␊ |
961 | {␊ |
962 | ␉SMBOemProcessorType *p = (SMBOemProcessorType *)structPtr->new;␊ |
963 | ␊ |
964 | ␉p->header.type␉␉= kSMBTypeOemProcessorType;␊ |
965 | ␉p->header.length␉= sizeof(SMBOemProcessorType);␊ |
966 | ␉p->header.handle␉= handle++;␊ |
967 | ␊ |
968 | ␉setSMBValue(structPtr, numOfSetters - 2 , (returnType *)(void *)&(p->ProcessorType));␊ |
969 | ␊ |
970 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorType) + 2);␊ |
971 | ␉tableLength += sizeof(SMBOemProcessorType) + 2;␊ |
972 | ␉structureCount++;␊ |
973 | }␊ |
974 | ␊ |
975 | /* =================================================␊ |
976 | OEM Processor Bus Speed (Apple Specific - Type 132)␊ |
977 | =================================================== */␊ |
978 | void addSMBOemProcessorBusSpeed(SMBStructPtrs *structPtr)␊ |
979 | {␊ |
980 | ␉SMBOemProcessorBusSpeed *p = (SMBOemProcessorBusSpeed *)structPtr->new;␊ |
981 | ␊ |
982 | ␉switch (Platform.CPU.Family) ␊ |
983 | ␉{␊ |
984 | ␉␉case 0x06:␊ |
985 | ␉␉{␊ |
986 | ␉␉␉switch (Platform.CPU.Model)␊ |
987 | ␉␉␉{␊ |
988 | ␉␉␉␉case 0x19:␉␉␉// Intel Core i5 650 @3.20 Ghz␊ |
989 | ␉␉␉␉case CPUID_MODEL_FIELDS:␉// Intel Core i5, i7, Xeon X34xx LGA1156 (45nm)␊ |
990 | ␉␉␉␉case CPUID_MODEL_CLARKDALE:␊ |
991 | ␉␉␉␉case CPUID_MODEL_DALES:␉// Intel Core i3, i5 LGA1156 (32nm)␊ |
992 | ␉␉␉␉case CPUID_MODEL_NEHALEM:␉// Intel Core i7, Xeon W35xx, Xeon X55xx, Xeon E55xx LGA1366 (45nm)␊ |
993 | ␉␉␉␉case CPUID_MODEL_NEHALEM_EX:␉// Intel Xeon X75xx, Xeon X65xx, Xeon E75xx, Xeon E65x␊ |
994 | ␉␉␉␉case CPUID_MODEL_WESTMERE:␉// Intel Core i7, Xeon X56xx, Xeon E56xx, Xeon W36xx LGA1366 (32nm) 6 Core␊ |
995 | ␉␉␉␉case CPUID_MODEL_WESTMERE_EX:␉// Intel Xeon E7␊ |
996 | ␉␉␉␉case CPUID_MODEL_SANDYBRIDGE:␉// Intel Core i3, i5, i7 LGA1155 (32nm)␊ |
997 | ␉␉␉␉case CPUID_MODEL_IVYBRIDGE:␉// Intel Core i3, i5, i7 LGA1155 (22nm)␊ |
998 | ␉␉␉␉case CPUID_MODEL_IVYBRIDGE_XEON:␊ |
999 | ␉␉␉␉case CPUID_MODEL_JAKETOWN:␉// Intel Core i7, Xeon E5 LGA2011 (32nm)␊ |
1000 | ␉␉␉␉case CPUID_MODEL_HASWELL:␊ |
1001 | ␉␉␉␉case CPUID_MODEL_HASWELL_SVR:␊ |
1002 | ␉␉␉␉case CPUID_MODEL_HASWELL_ULT:␊ |
1003 | ␉␉␉␉case CPUID_MODEL_HASWELL_ULX:␊ |
1004 | ␊ |
1005 | ␉␉␉␉␉break;␊ |
1006 | ␊ |
1007 | ␉␉␉␉default:␊ |
1008 | ␉␉␉␉␉return;␊ |
1009 | ␉␉␉}␊ |
1010 | ␉␉}␊ |
1011 | ␉}␊ |
1012 | ␊ |
1013 | ␉p->header.type␉␉= kSMBTypeOemProcessorBusSpeed;␊ |
1014 | ␉p->header.length␉= sizeof(SMBOemProcessorBusSpeed);␊ |
1015 | ␉p->header.handle␉= handle++;␊ |
1016 | ␊ |
1017 | ␉setSMBValue(structPtr, numOfSetters -1, (returnType *)(void *)&(p->ProcessorBusSpeed));␊ |
1018 | ␊ |
1019 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorBusSpeed) + 2);␊ |
1020 | ␉tableLength += sizeof(SMBOemProcessorBusSpeed) + 2;␊ |
1021 | ␉structureCount++;␊ |
1022 | }␊ |
1023 | ␊ |
1024 | /* ==============================================␊ |
1025 | OEM Platform Feature (Apple Specific - Type 133)␊ |
1026 | ================================================ */␊ |
1027 | /*␊ |
1028 | void addSMBOemPlatformFeature(SMBStructPtrs *structPtr)␊ |
1029 | {␊ |
1030 | ␉SMBOemPlatformFeature *p = (SMBOemPlatformFeature *)structPtr->new;␊ |
1031 | ␊ |
1032 | ␉p->header.type␉␉= kSMBTypeOemPlatformFeature;␊ |
1033 | ␉p->header.length␉= sizeof(SMBOemPlatformFeature);␊ |
1034 | ␉p->header.handle␉= handle++;␊ |
1035 | ␊ |
1036 | ␉setSMBValue(structPtr, numOfSetters - 2 , (returnType *)&(p->PlatformFeature));␊ |
1037 | ␊ |
1038 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemPlatformFeature) + 2);␊ |
1039 | ␉tableLength += sizeof(SMBOemPlatformFeature) + 2;␊ |
1040 | ␉structureCount++;␊ |
1041 | }␊ |
1042 | */␊ |
1043 | /* =========================================␊ |
1044 | OEM SMC Version (Apple Specific - Type 134)␊ |
1045 | =========================================== */␊ |
1046 | /*␊ |
1047 | void addSMBOemSMCVersion(SMBStructPtrs *structPtr)␊ |
1048 | {␊ |
1049 | SMBOemSMCVersion *p = (SMBOemSMCVersion *)structPtr->new;␊ |
1050 | ␊ |
1051 | p->header.type␉␉= kSMBTypeOemSMCVersion;␊ |
1052 | p->header.length␉= sizeof(SMBOemSMCVersion);␊ |
1053 | p->header.handle␉= handle++;␊ |
1054 | ␊ |
1055 | setSMBValue(structPtr, numOfSetters - 2 , (returnType *)&(p->SMCVersion));␊ |
1056 | ␊ |
1057 | structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemSMCVersion) + 2);␊ |
1058 | tableLength += sizeof(SMBOemSMCVersion) + 2;␊ |
1059 | structureCount++;␊ |
1060 | }␊ |
1061 | */␊ |
1062 | ␊ |
1063 | /* ==============================================␊ |
1064 | EndOfTable␊ |
1065 | ================================================ */␊ |
1066 | void addSMBEndOfTable(SMBStructPtrs *structPtr)␊ |
1067 | {␊ |
1068 | ␉structPtr->new->type␉= kSMBTypeEndOfTable;␊ |
1069 | ␉structPtr->new->length␉= sizeof(SMBStructHeader);␊ |
1070 | ␉structPtr->new->handle␉= handle++;␊ |
1071 | ␊ |
1072 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBStructHeader) + 2);␊ |
1073 | ␉tableLength += sizeof(SMBStructHeader) + 2;␊ |
1074 | ␉structureCount++;␊ |
1075 | }␊ |
1076 | ␊ |
1077 | void setSMBStruct(SMBStructPtrs *structPtr)␊ |
1078 | {␊ |
1079 | ␉bool setterFound = false;␊ |
1080 | ␊ |
1081 | ␉uint8_t *ptr;␊ |
1082 | ␉SMBWord structSize;␊ |
1083 | ␉int i;␊ |
1084 | ␊ |
1085 | ␉/* Bungo: not needed because of tables lengths fix in next lines␊ |
1086 | ␉// http://forge.voodooprojects.org/p/chameleon/issues/361/␊ |
1087 | ␉bool forceFullMemInfo = false;␊ |
1088 | ␊ |
1089 | ␉if (structPtr->orig->type == kSMBTypeMemoryDevice)␊ |
1090 | ␉{␊ |
1091 | ␉␉getBoolForKey(kMemFullInfo, &forceFullMemInfo, &bootInfo->chameleonConfig);␊ |
1092 | ␉␉if (forceFullMemInfo)␊ |
1093 | ␉␉{␊ |
1094 | ␉␉␉structPtr->orig->length = 27;␊ |
1095 | ␉␉}␊ |
1096 | ␉}*/␊ |
1097 | ␊ |
1098 | ␉stringIndex = 1;␊ |
1099 | ␉stringsSize = 0;␊ |
1100 | ␊ |
1101 | ␉if (handle < structPtr->orig->handle)␊ |
1102 | ␉{␊ |
1103 | ␉␉handle = structPtr->orig->handle;␊ |
1104 | ␉}␊ |
1105 | ␉// Bungo: fix unsuported tables lengths from original smbios: extend shorter or truncate longer - we use SMBIOS rev. 2.4 like Apple uses␊ |
1106 | ␉switch (structPtr->orig->type)␊ |
1107 | ␉{␊ |
1108 | ␉␉case kSMBTypeBIOSInformation:␊ |
1109 | ␉␉␉structSize = sizeof(SMBBIOSInformation);␊ |
1110 | ␉␉␉break;␊ |
1111 | ␉␉case kSMBTypeSystemInformation:␊ |
1112 | ␉␉␉structSize = sizeof(SMBSystemInformation);␊ |
1113 | ␉␉␉break;␊ |
1114 | ␉␉case kSMBTypeBaseBoard:␊ |
1115 | ␉␉␉structSize = sizeof(SMBBaseBoard);␊ |
1116 | ␉␉␉break;␊ |
1117 | ␉␉case kSMBTypeSystemEnclosure:␊ |
1118 | ␉␉␉structSize = sizeof(SMBSystemEnclosure);␊ |
1119 | ␉␉␉break;␊ |
1120 | ␉␉case kSMBTypeProcessorInformation:␊ |
1121 | ␉␉␉structSize = sizeof(SMBProcessorInformation);␊ |
1122 | ␉␉␉break;␊ |
1123 | ␉␉case kSMBTypeMemoryDevice:␊ |
1124 | ␉␉␉structSize = sizeof(SMBMemoryDevice);␊ |
1125 | ␉␉␉break;␊ |
1126 | ␉␉default:␊ |
1127 | ␉␉␉structSize = structPtr->orig->length; // doesn't change a length for unpatched␊ |
1128 | ␉␉␉break;␊ |
1129 | ␉}␊ |
1130 | ␊ |
1131 | ␉// memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);␊ |
1132 | ␉if (structPtr->orig->length <= structSize)␊ |
1133 | ␉{␊ |
1134 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);␊ |
1135 | ␉}␊ |
1136 | ␉else␊ |
1137 | ␉{␊ |
1138 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structSize);␊ |
1139 | ␉}␊ |
1140 | ␊ |
1141 | ␉structPtr->new->length = structSize;␊ |
1142 | ␊ |
1143 | ␉for (i = 0; i < numOfSetters; i++)␊ |
1144 | ␉{␊ |
1145 | ␉␉// Bungo:␊ |
1146 | ␉␉//if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structPtr->orig->length)) {␊ |
1147 | ␉␉if ((structPtr->orig->type == SMBSetters[i].type) && (SMBSetters[i].fieldOffset < structSize))␊ |
1148 | ␉␉{␊ |
1149 | ␉␉␉setterFound = true;␊ |
1150 | ␉␉␉setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset));␊ |
1151 | ␉␉}␊ |
1152 | ␉}␊ |
1153 | ␊ |
1154 | ␉if (setterFound)␊ |
1155 | ␉{␊ |
1156 | ␉␉// Bungo:␊ |
1157 | ␉␉// ptr = (uint8_t *)structPtr->new + structPtr->orig->length;␊ |
1158 | ␉␉ptr = (uint8_t *)structPtr->new + structPtr->new->length;␊ |
1159 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1160 | ␊ |
1161 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1162 | ␉␉{␊ |
1163 | ␉␉␉ptr += 2;␊ |
1164 | ␉␉}␊ |
1165 | ␉␉structSize = ptr - (uint8_t *)structPtr->new;␊ |
1166 | ␉}␊ |
1167 | ␉else␊ |
1168 | ␉{␊ |
1169 | ␉␉ptr = (uint8_t *)structPtr->orig + structPtr->orig->length;␊ |
1170 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1171 | ␊ |
1172 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1173 | ␉␉{␊ |
1174 | ␉␉␉ptr += 2;␊ |
1175 | ␉␉}␊ |
1176 | ␊ |
1177 | ␉␉structSize = ptr - (uint8_t *)structPtr->orig;␊ |
1178 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structSize);␊ |
1179 | ␉}␊ |
1180 | ␊ |
1181 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + structSize);␊ |
1182 | ␊ |
1183 | ␉tableLength += structSize;␊ |
1184 | ␊ |
1185 | ␉if (structSize > maxStructSize)␊ |
1186 | ␉{␊ |
1187 | ␉␉maxStructSize = structSize;␊ |
1188 | ␉}␊ |
1189 | ␊ |
1190 | ␉structureCount++;␊ |
1191 | }␊ |
1192 | ␊ |
1193 | void setupNewSMBIOSTable(SMBEntryPoint *eps, SMBStructPtrs *structPtr)␊ |
1194 | {␊ |
1195 | ␉uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;␊ |
1196 | ␉structPtr->orig = (SMBStructHeader *)ptr;␊ |
1197 | ␊ |
1198 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structPtr->orig + sizeof(SMBStructHeader)));) {␊ |
1199 | ␉␉switch (structPtr->orig->type) {␊ |
1200 | ␉␉␉/* Skip all Apple Specific Structures */␊ |
1201 | ␉␉␉case kSMBTypeFirmwareVolume:␊ |
1202 | ␉␉␉case kSMBTypeMemorySPD:␊ |
1203 | ␉␉␉case kSMBTypeOemProcessorType:␊ |
1204 | ␉␉␉case kSMBTypeOemProcessorBusSpeed:␊ |
1205 | //␉␉␉case kSMBTypeOemPlatformFeature:␊ |
1206 | //␉␉␉case kSMBTypeOemSMCVersion:␊ |
1207 | ␉␉␉/* And this one too, to be added at the end */␊ |
1208 | ␉␉␉case kSMBTypeEndOfTable:␊ |
1209 | ␉␉␉␉break;␊ |
1210 | ␊ |
1211 | ␉␉␉default:␊ |
1212 | ␉␉␉{␊ |
1213 | ␉␉␉␉/* Add */␊ |
1214 | ␉␉␉␉setSMBStruct(structPtr);␊ |
1215 | ␉␉␉␉break;␊ |
1216 | ␉␉␉}␊ |
1217 | ␉␉}␊ |
1218 | ␊ |
1219 | ␉␉ptr = (uint8_t *)((uint32_t)structPtr->orig + structPtr->orig->length);␊ |
1220 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1221 | ␊ |
1222 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1223 | ␉␉{␊ |
1224 | ␉␉␉ptr += 2;␊ |
1225 | ␉␉}␊ |
1226 | ␊ |
1227 | ␉␉structPtr->orig = (SMBStructHeader *)ptr;␊ |
1228 | ␉}␊ |
1229 | ␊ |
1230 | ␉addSMBFirmwareVolume(structPtr);␊ |
1231 | ␉addSMBMemorySPD(structPtr);␊ |
1232 | ␉addSMBOemProcessorType(structPtr);␊ |
1233 | ␉addSMBOemProcessorBusSpeed(structPtr);␊ |
1234 | //␉addSMBOemPlatformFeature(structPtr);␊ |
1235 | //␉addSMBOemSMCVersion(structPtr);␊ |
1236 | ␉addSMBEndOfTable(structPtr);␊ |
1237 | }␊ |
1238 | ␊ |
1239 | // Bungo: does fix system uuid in SMBIOS & EFI instead of in EFI (IODT/efi/platform/system-id) only␊ |
1240 | uint8_t *fixSystemUUID()␊ |
1241 | {␊ |
1242 | ␉uint8_t *ptr = (uint8_t *)neweps->dmi.tableAddress;␊ |
1243 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)ptr;␊ |
1244 | ␉uint8_t *ret = NULL;␊ |
1245 | ␉int i, isZero, isOnes;␊ |
1246 | ␉uint8_t fixedUUID[UUID_LEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};␊ |
1247 | ␉const char *sysId = getStringForKey(kSMBSystemInformationUUIDKey, SMBPlist); // try to get user's uuid from smbios.plist␊ |
1248 | ␉ret = (uint8_t *)getUUIDFromString(sysId); // convert user's uuid from string␊ |
1249 | ␊ |
1250 | ␉for (;(structHeader->type != kSMBTypeSystemInformation);) // find System Information Table (Type 1) in patched SMBIOS␊ |
1251 | ␉{␊ |
1252 | ␉␉ptr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
1253 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
1254 | ␊ |
1255 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
1256 | ␉␉{␊ |
1257 | ␉␉␉ptr += 2;␊ |
1258 | ␉␉}␊ |
1259 | ␊ |
1260 | ␉␉structHeader = (SMBStructHeader *)ptr;␊ |
1261 | ␉}␊ |
1262 | ␊ |
1263 | ␉ptr = ((SMBSystemInformation *)structHeader)->uuid;␊ |
1264 | ␊ |
1265 | ␉if (!sysId || !ret) // no or bad custom uuid,...␊ |
1266 | ␉{␊ |
1267 | ␉␉sysId = 0;␊ |
1268 | ␉␉ret = Platform.UUID; // ...use original (factory) system uuid␊ |
1269 | ␉}␊ |
1270 | ␊ |
1271 | ␉for (i = 0, isZero = 1, isOnes = 1; i < UUID_LEN; i++) // check if empty (zeroed) or setable (FFed), means: no uuid present␊ |
1272 | ␉{␊ |
1273 | ␉␉if (ret[i] != 0x00)␊ |
1274 | ␉␉{␊ |
1275 | ␉␉␉isZero = 0;␊ |
1276 | ␉␉}␊ |
1277 | ␊ |
1278 | ␉␉if (ret[i] != 0xff)␊ |
1279 | ␉␉{␊ |
1280 | ␉␉␉isOnes = 0;␊ |
1281 | ␉␉}␊ |
1282 | ␉}␊ |
1283 | ␊ |
1284 | ␉if (isZero || isOnes) // if empty or setable...␊ |
1285 | ␉{␊ |
1286 | ␉␉verbose("System UUID: incorrect or not present. Fixing [00112233-4455-6677-8899-AABBCCDDEEFF]\n");␊ |
1287 | ␉␉ret = fixedUUID; // ...set a fixed value for system uuid: <00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF>␊ |
1288 | ␉}␊ |
1289 | ␊ |
1290 | ␉memcpy(ptr, ret, UUID_LEN); // save uuid into the patched SMBIOS Table 1␊ |
1291 | ␊ |
1292 | ␉return ptr;␊ |
1293 | } // Bungo: end fix␊ |
1294 | ␊ |
1295 | void setupSMBIOSTable(void)␊ |
1296 | {␊ |
1297 | ␉SMBStructPtrs *structPtr;␊ |
1298 | ␉uint8_t *buffer;␊ |
1299 | ␉// bool setSMB = true; Bungo: now we use useSMBIOSdefaults␊ |
1300 | ␊ |
1301 | ␉if (!origeps)␊ |
1302 | ␉{␊ |
1303 | ␉␉return;␊ |
1304 | ␉}␊ |
1305 | ␊ |
1306 | ␉neweps = origeps;␊ |
1307 | ␊ |
1308 | ␉structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs));␊ |
1309 | ␉if (!structPtr)␊ |
1310 | ␉{␊ |
1311 | ␉␉return;␊ |
1312 | ␉}␊ |
1313 | ␉␊ |
1314 | ␉buffer = (uint8_t *)malloc(SMB_ALLOC_SIZE);␊ |
1315 | ␉if (!buffer)␊ |
1316 | ␉{␊ |
1317 | ␉␉free(structPtr);␊ |
1318 | ␉␉return;␊ |
1319 | ␉}␊ |
1320 | ␊ |
1321 | ␉bzero(buffer, SMB_ALLOC_SIZE);␊ |
1322 | ␉structPtr->new = (SMBStructHeader *)buffer;␊ |
1323 | ␊ |
1324 | ␉// getBoolForKey(kSMBIOSdefaults, &setSMB, &bootInfo->chameleonConfig); Bungo␊ |
1325 | ␉getBoolForKey(kSMBIOSdefaults, &useSMBIOSdefaults, &bootInfo->chameleonConfig);␊ |
1326 | ␉// if (setSMB) Bungo␊ |
1327 | ␉setDefaultSMBData();␊ |
1328 | ␊ |
1329 | ␉setupNewSMBIOSTable(origeps, structPtr);␊ |
1330 | ␊ |
1331 | ␉neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));␊ |
1332 | ␉if (!neweps)␊ |
1333 | ␉{␊ |
1334 | ␉␉free(buffer);␊ |
1335 | ␉␉free(structPtr);␊ |
1336 | ␉␉return;␊ |
1337 | ␉}␊ |
1338 | ␉bzero(neweps, sizeof(SMBEntryPoint));␊ |
1339 | ␊ |
1340 | ␉neweps->anchor[0]␉␉␉= '_';␊ |
1341 | ␉neweps->anchor[1]␉␉␉= 'S';␊ |
1342 | ␉neweps->anchor[2]␉␉␉= 'M';␊ |
1343 | ␉neweps->anchor[3]␉␉␉= '_';␊ |
1344 | ␉neweps->entryPointLength␉= sizeof(SMBEntryPoint);␊ |
1345 | ␉neweps->majorVersion␉␉= 2; // Bungo:␊ |
1346 | ␉neweps->minorVersion␉␉= 4; // Here we're using 2.4 SMBIOS rev. as real Macs␊ |
1347 | ␉neweps->maxStructureSize␉= maxStructSize;␊ |
1348 | ␉neweps->entryPointRevision␉= 0;␊ |
1349 | ␊ |
1350 | ␉neweps->dmi.anchor[0]␉␉= '_';␊ |
1351 | ␉neweps->dmi.anchor[1]␉␉= 'D';␊ |
1352 | ␉neweps->dmi.anchor[2]␉␉= 'M';␊ |
1353 | ␉neweps->dmi.anchor[3]␉␉= 'I';␊ |
1354 | ␉neweps->dmi.anchor[4]␉␉= '_';␊ |
1355 | ␉neweps->dmi.tableLength␉␉= tableLength;␊ |
1356 | ␉neweps->dmi.tableAddress␉= AllocateKernelMemory(tableLength);␊ |
1357 | ␉neweps->dmi.structureCount␉= structureCount;␊ |
1358 | ␉neweps->dmi.bcdRevision␉␉= 0x24; // ... and 2.4 DMI rev. as real Macs␊ |
1359 | ␊ |
1360 | ␉if (!neweps->dmi.tableAddress)␊ |
1361 | ␉{␊ |
1362 | ␉␉free(buffer);␊ |
1363 | ␉␉free(structPtr);␊ |
1364 | ␉␉return;␊ |
1365 | ␉}␊ |
1366 | ␊ |
1367 | ␉memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);␊ |
1368 | ␊ |
1369 | ␉Platform.UUID = fixSystemUUID(); // Bungo: fix System UUID␊ |
1370 | ␊ |
1371 | ␉neweps->dmi.checksum␉␉= 0;␊ |
1372 | ␉neweps->dmi.checksum␉␉= 0x100 - checksum8(&neweps->dmi, sizeof(DMIEntryPoint));␊ |
1373 | ␊ |
1374 | ␉neweps->checksum␉␉= 0;␊ |
1375 | ␉neweps->checksum␉␉= 0x100 - checksum8(neweps, sizeof(SMBEntryPoint));␊ |
1376 | ␊ |
1377 | ␉free(buffer);␊ |
1378 | ␉free(structPtr);␊ |
1379 | ␊ |
1380 | ␉DBG("SMBIOS orig was = %x\n", origeps);␊ |
1381 | ␉DBG("SMBIOS new is = %x\n", neweps);␊ |
1382 | ␊ |
1383 | ␉decodeSMBIOSTable(neweps);␊ |
1384 | ␊ |
1385 | }␊ |
1386 | ␊ |
1387 | void *getSmbios(int which)␊ |
1388 | {␊ |
1389 | ␉switch (which)␊ |
1390 | ␉{␊ |
1391 | ␉␉case SMBIOS_ORIGINAL:␊ |
1392 | ␉␉␉if (!origeps)␊ |
1393 | ␉␉␉{␊ |
1394 | ␉␉␉␉origeps = getAddressOfSmbiosTable();␊ |
1395 | ␉␉␉}␊ |
1396 | ␉␉␉return origeps;␊ |
1397 | ␉␉case SMBIOS_PATCHED:␊ |
1398 | ␉␉␉return neweps;␊ |
1399 | ␉}␊ |
1400 | ␊ |
1401 | ␉return 0;␊ |
1402 | }␊ |
1403 | ␊ |
1404 | /* Collect any information needed later */␊ |
1405 | void readSMBIOSInfo(SMBEntryPoint *eps)␊ |
1406 | {␊ |
1407 | ␉uint8_t *structPtr = (uint8_t *)eps->dmi.tableAddress;␊ |
1408 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)structPtr;␊ |
1409 | ␊ |
1410 | ␉int dimmnbr = 0;␊ |
1411 | ␉Platform.DMI.MaxMemorySlots␉= 0;␉// number of memory slots polulated by SMBIOS␊ |
1412 | ␉Platform.DMI.CntMemorySlots␉= 0;␉// number of memory slots counted␊ |
1413 | ␉Platform.DMI.MemoryModules␉= 0;␊ |
1414 | ␊ |
1415 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)␊ |
1416 | ␉{␊ |
1417 | ␉␉switch (structHeader->type)␊ |
1418 | ␉␉{␊ |
1419 | ␉␉␉case kSMBTypeSystemInformation:␊ |
1420 | ␉␉␉␉Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid; // save factory system uuid␊ |
1421 | ␉␉␉␉break;␊ |
1422 | ␊ |
1423 | ␉␉␉case kSMBTypeSystemEnclosure: // Bungo: determine platform type␊ |
1424 | ␉␉␉␉switch (((SMBSystemEnclosure *)structHeader)->chassisType)␊ |
1425 | ␉␉␉␉{␊ |
1426 | ␉␉␉␉␉case kSMBChassisTypePortable:␊ |
1427 | ␉␉␉␉␉case kSMBChassisTypeLaptop:␊ |
1428 | ␉␉␉␉␉case kSMBChassisTypeNotebook:␊ |
1429 | ␉␉␉␉␉case kSMBChassisTypeHandHeld:␊ |
1430 | ␉␉␉␉␉case kSMBChassisTypeSubNotebook:␊ |
1431 | ␉␉␉␉␉␉PlatformType = 2; // notebook (MacBooks/Pros)␊ |
1432 | ␉␉␉␉␉␉break;␊ |
1433 | ␉␉␉␉␉case kSMBChassisTypeMiniTower:␊ |
1434 | ␉␉␉␉␉case kSMBChassisTypeTower:␊ |
1435 | ␉␉␉␉␉case kSMBChassisTypeBlade:␊ |
1436 | ␉␉␉␉␉case kSMBChassisTypeBladeEnclosing:␊ |
1437 | ␉␉␉␉␉␉PlatformType = 3; // workstation (Mac Pro, Xserve)␊ |
1438 | ␉␉␉␉␉␉break;␊ |
1439 | ␉␉␉␉␉default:␊ |
1440 | ␉␉␉␉␉␉PlatformType = 1; // defulting to 1 desktop (iMac, MacMini)␊ |
1441 | ␉␉␉␉␉␉break;␊ |
1442 | ␉␉␉␉}␊ |
1443 | ␉␉␉␉break;␊ |
1444 | ␊ |
1445 | ␉␉␉case kSMBTypePhysicalMemoryArray:␊ |
1446 | ␉␉␉␉Platform.DMI.MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices;␊ |
1447 | ␉␉␉␉break;␊ |
1448 | ␊ |
1449 | ␉␉␉case kSMBTypeMemoryDevice:␊ |
1450 | ␉␉␉␉Platform.DMI.CntMemorySlots++;␊ |
1451 | ␉␉␉␉if (((SMBMemoryDevice *)structHeader)->memorySize != 0)␊ |
1452 | ␉␉␉␉{␊ |
1453 | ␉␉␉␉␉Platform.DMI.MemoryModules++;␊ |
1454 | ␉␉␉␉}␊ |
1455 | ␉␉␉␉if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0)␊ |
1456 | ␉␉␉␉{␊ |
1457 | ␉␉␉␉␉Platform.RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed;␊ |
1458 | ␉␉␉␉}␊ |
1459 | ␉␉␉␉dimmnbr++;␊ |
1460 | ␉␉␉␉break;␊ |
1461 | ␉␉␉default:␊ |
1462 | ␉␉␉␉break;␊ |
1463 | ␉␉}␊ |
1464 | ␊ |
1465 | ␉␉structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
1466 | ␉␉for (; ((uint16_t *)structPtr)[0] != 0; structPtr++);␊ |
1467 | ␊ |
1468 | ␉␉if (((uint16_t *)structPtr)[0] == 0)␊ |
1469 | ␉␉{␊ |
1470 | ␉␉␉structPtr += 2;␊ |
1471 | ␉␉}␊ |
1472 | ␊ |
1473 | ␉␉structHeader = (SMBStructHeader *)structPtr;␊ |
1474 | ␉}␊ |
1475 | }␊ |
1476 | |