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