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