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 | ␊ |
13 | #ifndef DEBUG_SMBIOS␊ |
14 | #define DEBUG_SMBIOS 0␊ |
15 | #endif␊ |
16 | ␊ |
17 | #if DEBUG_SMBIOS␊ |
18 | #define DBG(x...)␉printf(x)␊ |
19 | #else␊ |
20 | #define DBG(x...)␉msglog(x)␊ |
21 | #endif␊ |
22 | ␊ |
23 | #define SMBPlist␉␉␉&bootInfo->smbiosConfig␊ |
24 | /* ASSUMPTION: 16KB should be enough for the whole thing */␊ |
25 | #define SMB_ALLOC_SIZE␉16384␊ |
26 | ␊ |
27 | ␊ |
28 | //-------------------------------------------------------------------------------------------------------------------------␊ |
29 | // SMBIOS Plist Keys␊ |
30 | //-------------------------------------------------------------------------------------------------------------------------␊ |
31 | /* BIOS Information */␊ |
32 | #define kSMBBIOSInformationVendorKey␉␉␉␉"SMbiosvendor"␊ |
33 | #define kSMBBIOSInformationVersionKey␉␉␉␉"SMbiosversion"␊ |
34 | #define kSMBBIOSInformationReleaseDateKey␉␉␉"SMbiosdate"␊ |
35 | ␊ |
36 | /* System Information */␊ |
37 | #define kSMBSystemInformationManufacturerKey␉␉"SMmanufacturer"␊ |
38 | #define kSMBSystemInformationProductNameKey␉␉␉"SMproductname"␊ |
39 | #define kSMBSystemInformationVersionKey␉␉␉␉"SMsystemversion"␊ |
40 | #define kSMBSystemInformationSerialNumberKey␉␉"SMserial"␊ |
41 | #define kSMBSystemInformationFamilyKey␉␉␉␉"SMfamily"␊ |
42 | ␊ |
43 | /* Base Board */␊ |
44 | #define kSMBBaseBoardManufacturerKey␉␉␉␉"SMboardmanufacturer"␊ |
45 | #define kSMBBaseBoardProductKey␉␉␉␉␉␉"SMboardproduct"␊ |
46 | ␊ |
47 | /* Processor Information */␊ |
48 | #define kSMBProcessorInformationExternalClockKey␉"SMexternalclock"␊ |
49 | #define kSMBProcessorInformationMaximumClockKey␉␉"SMmaximalclock"␊ |
50 | ␊ |
51 | /* Memory Device */␊ |
52 | #define kSMBMemoryDeviceDeviceLocatorKey␉␉␉"SMmemdevloc"␊ |
53 | #define kSMBMemoryDeviceBankLocatorKey␉␉␉␉"SMmembankloc"␊ |
54 | #define kSMBMemoryDeviceMemoryTypeKey␉␉␉␉"SMmemtype"␊ |
55 | #define kSMBMemoryDeviceMemorySpeedKey␉␉␉␉"SMmemspeed"␊ |
56 | #define kSMBMemoryDeviceManufacturerKey␉␉␉␉"SMmemmanufacturer"␊ |
57 | #define kSMBMemoryDeviceSerialNumberKey␉␉␉␉"SMmemserial"␊ |
58 | #define kSMBMemoryDevicePartNumberKey␉␉␉␉"SMmempart"␊ |
59 | ␊ |
60 | /* Apple Specific */␊ |
61 | #define kSMBOemProcessorTypeKey␉␉␉␉␉␉"SMcputype"␊ |
62 | #define kSMBOemProcessorBusSpeedKey␉␉␉␉␉"SMbusspeed"␊ |
63 | ␊ |
64 | //-------------------------------------------------------------------------------------------------------------------------␊ |
65 | // Default SMBIOS Data␊ |
66 | //-------------------------------------------------------------------------------------------------------------------------␊ |
67 | /* Rewrite: use a struct */␊ |
68 | ␊ |
69 | #define kDefaultVendorManufacturer␉␉␉␉␉"Apple Inc."␊ |
70 | #define kDefaultBIOSReleaseDate␉␉␉␉␉␉"11/06/2009"␊ |
71 | #define kDefaultSerialNumber␉␉␉␉␉␉"SOMESRLNMBR"␊ |
72 | #define kDefaultBoardProduct␉␉␉␉␉␉"Mac-F4208DC8"␊ |
73 | #define kDefaultSystemVersion␉␉␉␉␉␉"1.0"␊ |
74 | ␊ |
75 | // defaults for a Mac mini ␊ |
76 | #define kDefaultMacminiFamily␉␉␉␉␉␉"Macmini"␊ |
77 | #define kDefaultMacmini␉␉␉␉␉␉␉␉"Macmini2,1"␊ |
78 | #define kDefaultMacminiBIOSVersion␉␉␉␉␉" MM21.88Z.009A.B00.0903051113"␊ |
79 | ␊ |
80 | // defaults for a MacBook␊ |
81 | #define kDefaultMacBookFamily␉␉␉␉␉␉"MacBook"␊ |
82 | #define kDefaultMacBook␉␉␉␉␉␉␉␉"MacBook4,1"␊ |
83 | #define kDefaultMacBookBIOSVersion␉␉␉␉␉" MB41.88Z.0073.B00.0903051113"␊ |
84 | ␊ |
85 | // defaults for a MacBook Pro␊ |
86 | #define kDefaultMacBookProFamily␉␉␉␉␉"MacBookPro"␊ |
87 | #define kDefaultMacBookPro␉␉␉␉␉␉␉"MacBookPro4,1"␊ |
88 | #define kDefaultMacBookProBIOSVersion␉␉␉␉" MBP41.88Z.0073.B00.0903051113"␊ |
89 | ␊ |
90 | // defaults for an iMac␊ |
91 | #define kDefaultiMacFamily␉␉␉␉␉␉␉"iMac"␊ |
92 | #define kDefaultiMac␉␉␉␉␉␉␉␉"iMac8,1"␊ |
93 | #define kDefaultiMacBIOSVersion␉␉␉␉␉␉" IM81.88Z.00C1.B00.0903051113"␊ |
94 | // defaults for an iMac11,1 core i3/i5/i7␊ |
95 | #define kDefaultiMacNehalem␉␉␉␉␉␉␉"iMac11,1"␊ |
96 | #define kDefaultiMacNehalemBIOSVersion␉␉␉␉" IM111.88Z.0034.B00.0903051113"␊ |
97 | ␊ |
98 | // defaults for a Mac Pro␊ |
99 | #define kDefaultMacProFamily␉␉␉␉␉␉"MacPro"␊ |
100 | #define kDefaultMacPro␉␉␉␉␉␉␉␉"MacPro3,1"␊ |
101 | #define kDefaultMacProBIOSVersion␉␉␉␉␉" MP31.88Z.006C.B05.0903051113"␊ |
102 | // defaults for a Mac Pro 4,1 core i7/Xeon␊ |
103 | #define kDefaultMacProNehalem␉␉␉␉␉␉"MacPro4,1"␊ |
104 | #define kDefaultMacProNehalemBIOSVersion␉␉␉" MP41.88Z.0081.B04.0903051113"␊ |
105 | // defaults for a Mac Pro 5,1 core i7/Xeon␊ |
106 | #define kDefaultMacProWestmere␉␉␉␉␉␉"MacPro5,1"␊ |
107 | #define kDefaultMacProWestmereBIOSVersion␉␉␉" MP51.88Z.007F.B00.1008031144"␊ |
108 | #define kDefaulMacProWestmereBIOSReleaseDate␉␉"08/03/10"␊ |
109 | //-------------------------------------------------------------------------------------------------------------------------␊ |
110 | ␊ |
111 | ␊ |
112 | #define getFieldOffset(struct, field)␉((uint8_t)(uint32_t)&(((struct *)0)->field))␊ |
113 | ␊ |
114 | typedef struct {␊ |
115 | ␉SMBStructHeader *orig;␊ |
116 | ␉SMBStructHeader *new;␊ |
117 | } SMBStructPtrs;␊ |
118 | ␊ |
119 | struct {␊ |
120 | ␉char *vendor;␊ |
121 | ␉char *version;␊ |
122 | ␉char *releaseDate;␊ |
123 | } defaultBIOSInfo;␊ |
124 | ␊ |
125 | struct {␊ |
126 | ␉char *manufacturer;␊ |
127 | ␉char *productName;␊ |
128 | ␉char *version;␊ |
129 | ␉char *serialNumber;␊ |
130 | ␉char *family;␊ |
131 | } defaultSystemInfo;␊ |
132 | ␊ |
133 | struct {␊ |
134 | ␉char *manufacturer;␊ |
135 | ␉char *product;␊ |
136 | } defaultBaseBoard;␊ |
137 | ␊ |
138 | ␊ |
139 | typedef struct {␊ |
140 | ␉uint8_t␉␉␉type;␊ |
141 | ␉SMBValueType␉valueType;␊ |
142 | ␉uint8_t␉␉␉fieldOffset;␊ |
143 | ␉char␉␉␉*keyString;␊ |
144 | ␉bool␉␉␉(*getSMBValue)(returnType *);␊ |
145 | ␉char␉␉␉**defaultValue;␊ |
146 | } SMBValueSetter;␊ |
147 | ␊ |
148 | SMBValueSetter SMBSetters[] = ␊ |
149 | { ␊ |
150 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
151 | ␉// BIOSInformation␊ |
152 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
153 | ␉{kSMBTypeBIOSInformation,␉kSMBString,␉getFieldOffset(SMBBIOSInformation, vendor),␉␉␉kSMBBIOSInformationVendorKey,␉␉␊ |
154 | ␉␉NULL,␉&defaultBIOSInfo.vendor␉␉␉},␊ |
155 | ␊ |
156 | ␉{kSMBTypeBIOSInformation,␉kSMBString,␉getFieldOffset(SMBBIOSInformation, version),␉␉kSMBBIOSInformationVersionKey,␉␉␊ |
157 | ␉␉NULL,␉&defaultBIOSInfo.version␉␉},␊ |
158 | ␊ |
159 | ␉{kSMBTypeBIOSInformation,␉kSMBString,␉getFieldOffset(SMBBIOSInformation, releaseDate),␉kSMBBIOSInformationReleaseDateKey,␉␊ |
160 | ␉␉NULL,␉&defaultBIOSInfo.releaseDate␉},␊ |
161 | ␊ |
162 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
163 | ␉// SystemInformation␊ |
164 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
165 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, manufacturer),␉kSMBSystemInformationManufacturerKey,␉␊ |
166 | ␉␉NULL,␉&defaultSystemInfo.manufacturer␉},␊ |
167 | ␊ |
168 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, productName),␉kSMBSystemInformationProductNameKey,␉␊ |
169 | ␉␉NULL,␉&defaultSystemInfo.productName␉},␊ |
170 | ␊ |
171 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, version),␉␉kSMBSystemInformationVersionKey,␉␉␊ |
172 | ␉␉NULL,␉&defaultSystemInfo.version␉␉},␊ |
173 | ␊ |
174 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, serialNumber),␉kSMBSystemInformationSerialNumberKey,␉␊ |
175 | ␉␉NULL,␉&defaultSystemInfo.serialNumber␉},␊ |
176 | ␊ |
177 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, skuNumber),␉NULL,␉␉␉␉␉␉␉␉␉␊ |
178 | ␉␉NULL,␉NULL␉␉␉␉␉␉␉},␊ |
179 | ␊ |
180 | ␉{kSMBTypeSystemInformation,␉kSMBString,␉getFieldOffset(SMBSystemInformation, family),␉␉kSMBSystemInformationFamilyKey,␉␉␉␊ |
181 | ␉␉NULL,␉&defaultSystemInfo.family␉␉},␊ |
182 | ␊ |
183 | ␊ |
184 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
185 | ␉// BaseBoard␊ |
186 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
187 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, manufacturer),␉␉␉kSMBBaseBoardManufacturerKey,␉␊ |
188 | ␉␉NULL,␉&defaultBaseBoard.manufacturer␉},␊ |
189 | ␊ |
190 | ␉{kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, product),␉␉␉␉kSMBBaseBoardProductKey,␉␉␊ |
191 | ␉␉NULL,␉&defaultBaseBoard.product␉␉},␊ |
192 | ␊ |
193 | {kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, version),␉␉␉␉NULL,␉NULL,␉NULL},␊ |
194 | ␊ |
195 | {kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, serialNumber),␉␉␉NULL,␉NULL,␉NULL},␊ |
196 | ␊ |
197 | {kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, assetTagNumber),␉␉NULL,␉NULL,␉NULL},␊ |
198 | ␊ |
199 | {kSMBTypeBaseBoard,␉kSMBString,␉getFieldOffset(SMBBaseBoard, locationInChassis),␉NULL,␉NULL,␉NULL},␊ |
200 | ␊ |
201 | ␊ |
202 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
203 | ␉// ProcessorInformation␊ |
204 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
205 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, socketDesignation),␉NULL,␉NULL,␉NULL},␊ |
206 | ␊ |
207 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, manufacturer),␉␉NULL,␉NULL,␉NULL},␊ |
208 | ␊ |
209 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, processorVersion),␉NULL,␉NULL,␉NULL},␊ |
210 | ␊ |
211 | ␉{kSMBTypeProcessorInformation,␉kSMBWord,␉getFieldOffset(SMBProcessorInformation, externalClock),␉␉kSMBProcessorInformationExternalClockKey,␉␊ |
212 | ␉␉getProcessorInformationExternalClock,␉NULL},␊ |
213 | ␊ |
214 | ␉{kSMBTypeProcessorInformation,␉kSMBWord,␉getFieldOffset(SMBProcessorInformation, maximumClock),␉␉kSMBProcessorInformationMaximumClockKey,␉␊ |
215 | ␉␉getProcessorInformationMaximumClock,␉NULL},␊ |
216 | ␊ |
217 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, serialNumber),␉␉NULL,␉NULL,␉NULL},␊ |
218 | ␊ |
219 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, assetTag),␉␉␉NULL,␉NULL,␉NULL},␊ |
220 | ␊ |
221 | ␉{kSMBTypeProcessorInformation,␉kSMBString,␉getFieldOffset(SMBProcessorInformation, partNumber),␉␉NULL,␉NULL,␉NULL},␊ |
222 | ␊ |
223 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
224 | ␉// Memory Device␊ |
225 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
226 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, deviceLocator),␉kSMBMemoryDeviceDeviceLocatorKey,␉␊ |
227 | ␉␉NULL,␉␉␉␉␉␉␉NULL},␊ |
228 | ␊ |
229 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, bankLocator),␉kSMBMemoryDeviceBankLocatorKey,␉␉␊ |
230 | ␉␉NULL,␉␉␉␉␉␉␉NULL},␊ |
231 | ␊ |
232 | ␉{kSMBTypeMemoryDevice,␉kSMBByte,␉getFieldOffset(SMBMemoryDevice, memoryType),␉kSMBMemoryDeviceMemoryTypeKey,␉␉␊ |
233 | ␉␉getSMBMemoryDeviceMemoryType,␉NULL},␊ |
234 | ␊ |
235 | ␉{kSMBTypeMemoryDevice,␉kSMBWord,␉getFieldOffset(SMBMemoryDevice, memorySpeed),␉kSMBMemoryDeviceMemorySpeedKey,␉␉␊ |
236 | ␉␉getSMBMemoryDeviceMemorySpeed,␉NULL},␊ |
237 | ␊ |
238 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, manufacturer),␉kSMBMemoryDeviceManufacturerKey,␉␊ |
239 | ␉␉getSMBMemoryDeviceManufacturer,␉NULL},␊ |
240 | ␊ |
241 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, serialNumber),␉kSMBMemoryDeviceSerialNumberKey,␉␊ |
242 | ␉␉getSMBMemoryDeviceSerialNumber,␉NULL},␊ |
243 | ␊ |
244 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, assetTag),␉␉NULL,␉NULL,␉NULL},␊ |
245 | ␊ |
246 | ␉{kSMBTypeMemoryDevice,␉kSMBString,␉getFieldOffset(SMBMemoryDevice, partNumber),␉kSMBMemoryDevicePartNumberKey,␉␉␊ |
247 | ␉␉getSMBMemoryDevicePartNumber,␉NULL},␊ |
248 | ␊ |
249 | ␊ |
250 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
251 | ␉// Apple Specific␊ |
252 | ␉//-------------------------------------------------------------------------------------------------------------------------␊ |
253 | ␉{kSMBTypeOemProcessorType,␉␉kSMBWord,␉getFieldOffset(SMBOemProcessorType, ProcessorType),␉␉␉kSMBOemProcessorTypeKey,␉␉␊ |
254 | ␉␉getSMBOemProcessorType,␉␉␉NULL},␊ |
255 | ␊ |
256 | ␉{kSMBTypeOemProcessorBusSpeed,␉kSMBWord,␉getFieldOffset(SMBOemProcessorBusSpeed, ProcessorBusSpeed),␉kSMBOemProcessorBusSpeedKey,␉␊ |
257 | ␉␉getSMBOemProcessorBusSpeed,␉␉NULL}␊ |
258 | };␊ |
259 | ␊ |
260 | int numOfSetters = sizeof(SMBSetters) / sizeof(SMBValueSetter);␊ |
261 | ␊ |
262 | ␊ |
263 | SMBEntryPoint *origeps␉= 0;␊ |
264 | SMBEntryPoint *neweps␉= 0;␊ |
265 | ␊ |
266 | static uint8_t stringIndex;␉// increament when a string is added and set the field value accordingly␊ |
267 | static uint8_t stringsSize;␉// add string size␊ |
268 | ␊ |
269 | static SMBWord tableLength␉␉= 0;␊ |
270 | static SMBWord handle␉␉␉= 0;␊ |
271 | static SMBWord maxStructSize␉= 0;␊ |
272 | static SMBWord structureCount␉= 0;␊ |
273 | ␊ |
274 | /* Rewrite this function */␊ |
275 | void setDefaultSMBData(void)␊ |
276 | {␊ |
277 | ␉defaultBIOSInfo.vendor␉␉␉= kDefaultVendorManufacturer;␊ |
278 | ␉defaultBIOSInfo.releaseDate␉␉= kDefaultBIOSReleaseDate;␊ |
279 | ␊ |
280 | ␉defaultSystemInfo.manufacturer␉= kDefaultVendorManufacturer;␊ |
281 | ␉defaultSystemInfo.version␉␉= kDefaultSystemVersion;␊ |
282 | ␉defaultSystemInfo.serialNumber␉= kDefaultSerialNumber;␊ |
283 | ␊ |
284 | ␉defaultBaseBoard.manufacturer␉= kDefaultVendorManufacturer;␊ |
285 | ␉defaultBaseBoard.product␉␉= kDefaultBoardProduct;␊ |
286 | ␊ |
287 | ␉if (platformCPUFeature(CPU_FEATURE_MOBILE))␊ |
288 | ␉{␊ |
289 | ␉␉if (Platform.CPU.NoCores > 1)␊ |
290 | ␉␉{␊ |
291 | ␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacBookProBIOSVersion;␊ |
292 | ␉␉␉defaultSystemInfo.productName␉= kDefaultMacBookPro;␊ |
293 | ␉␉␉defaultSystemInfo.family␉␉= kDefaultMacBookProFamily;␊ |
294 | ␉␉}␊ |
295 | ␉␉else␊ |
296 | ␉␉{␊ |
297 | ␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacBookBIOSVersion;␊ |
298 | ␉␉␉defaultSystemInfo.productName␉= kDefaultMacBook;␊ |
299 | ␉␉␉defaultSystemInfo.family␉␉= kDefaultMacBookFamily;␊ |
300 | ␉␉}␊ |
301 | ␉}␊ |
302 | ␉else␊ |
303 | ␉{␊ |
304 | ␉␉switch (Platform.CPU.NoCores) ␊ |
305 | ␉␉{␊ |
306 | ␉␉␉case 1: ␊ |
307 | ␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacminiBIOSVersion;␊ |
308 | ␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacmini;␊ |
309 | ␉␉␉␉defaultSystemInfo.family␉␉= kDefaultMacminiFamily;␊ |
310 | ␉␉␉␉break;␊ |
311 | ␊ |
312 | ␉␉␉case 2:␊ |
313 | ␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultiMacBIOSVersion;␊ |
314 | ␉␉␉␉defaultSystemInfo.productName␉= kDefaultiMac;␊ |
315 | ␉␉␉␉defaultSystemInfo.family␉␉= kDefaultiMacFamily;␊ |
316 | ␉␉␉␉break;␊ |
317 | ␉␉␉default:␊ |
318 | ␉␉␉{␊ |
319 | ␉␉␉␉switch (Platform.CPU.Family) ␊ |
320 | ␉␉␉␉{␊ |
321 | ␉␉␉␉␉case 0x06:␊ |
322 | ␉␉␉␉␉{␊ |
323 | ␉␉␉␉␉␉switch (Platform.CPU.Model)␊ |
324 | ␉␉␉␉␉␉{␊ |
325 | ␉␉␉␉␉␉␉case CPU_MODEL_FIELDS:␉␉// Intel Core i5, i7 LGA1156 (45nm)␊ |
326 | ␉␉␉␉␉␉␉case CPU_MODEL_DALES:␉␉// Intel Core i5, i7 LGA1156 (45nm) ???␊ |
327 | ␉␉␉␉␉␉␉case CPU_MODEL_DALES_32NM:␉// Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)␊ |
328 | ␉␉␉␉␉␉␉case 0x19:␉␉␉␉␉// Intel Core i5 650 @3.20 Ghz ␊ |
329 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultiMacNehalemBIOSVersion;␊ |
330 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultiMacNehalem;␊ |
331 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultiMacFamily;␊ |
332 | ␉␉␉␉␉␉␉␉break;␊ |
333 | ␊ |
334 | ␉␉␉␉␉␉␉case CPU_MODEL_NEHALEM: ␊ |
335 | ␉␉␉␉␉␉␉case CPU_MODEL_NEHALEM_EX:␊ |
336 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacProNehalemBIOSVersion;␊ |
337 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacProNehalem;␊ |
338 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultMacProFamily;␊ |
339 | ␉␉␉␉␉␉␉␉break;␊ |
340 | ␊ |
341 | ␉␉␉␉␉␉␉case CPU_MODEL_WESTMERE: ␊ |
342 | ␉␉␉␉␉␉␉case CPU_MODEL_WESTMERE_EX:␊ |
343 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacProWestmereBIOSVersion;␊ |
344 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.releaseDate␉␉= kDefaulMacProWestmereBIOSReleaseDate;␊ |
345 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacProWestmere;␊ |
346 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultMacProFamily;␊ |
347 | ␉␉␉␉␉␉␉␉break;␊ |
348 | ␊ |
349 | ␉␉␉␉␉␉␉default:␊ |
350 | ␉␉␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacProBIOSVersion;␊ |
351 | ␉␉␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacPro;␊ |
352 | ␉␉␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultMacProFamily;␊ |
353 | ␉␉␉␉␉␉␉␉break;␊ |
354 | ␉␉␉␉␉␉}␊ |
355 | ␉␉␉␉␉␉break;␊ |
356 | ␉␉␉␉␉}␊ |
357 | ␉␉␉␉␉default:␊ |
358 | ␉␉␉␉␉␉defaultBIOSInfo.version␉␉␉= kDefaultMacProBIOSVersion;␊ |
359 | ␉␉␉␉␉␉defaultSystemInfo.productName␉= kDefaultMacPro;␊ |
360 | ␉␉␉␉␉␉defaultSystemInfo.family␉␉= kDefaultMacProFamily;␊ |
361 | ␉␉␉␉␉␉break;␊ |
362 | ␉␉␉␉}␊ |
363 | ␉␉␉␉break;␊ |
364 | ␉␉␉}␊ |
365 | ␉␉}␊ |
366 | ␉}␊ |
367 | }␊ |
368 | ␊ |
369 | /* Used for SM*_N smbios.plist keys */␊ |
370 | bool getSMBValueForKey(SMBStructHeader *structHeader, const char *keyString, const char **string, returnType *value)␊ |
371 | {␊ |
372 | ␉static int idx = -1;␊ |
373 | ␉static int current = -1;␊ |
374 | ␉int len;␊ |
375 | ␉char key[24];␊ |
376 | ␊ |
377 | ␉if (current != structHeader->handle)␊ |
378 | ␉{␊ |
379 | ␉␉idx++;␊ |
380 | ␉␉current = structHeader->handle;␊ |
381 | ␉}␊ |
382 | ␊ |
383 | ␉sprintf(key, "%s%d", keyString, idx);␊ |
384 | ␊ |
385 | ␉if (value)␊ |
386 | ␉␉if (getIntForKey(key, (int *)&(value->dword), SMBPlist))␊ |
387 | ␉␉␉return true;␊ |
388 | ␉else␊ |
389 | ␉␉if (getValueForKey(key, string, &len, SMBPlist))␊ |
390 | ␉␉␉return true;␊ |
391 | ␉return false;␊ |
392 | }␊ |
393 | ␊ |
394 | char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field)␊ |
395 | {␊ |
396 | ␉uint8_t *stringPtr = (uint8_t *)structHeader + structHeader->length;␊ |
397 | ␊ |
398 | ␉if (!field)␊ |
399 | ␉␉return (char *)0;␊ |
400 | ␊ |
401 | ␉for (field--; field != 0 && strlen((char *)stringPtr) > 0; ␊ |
402 | ␉␉field--, stringPtr = (uint8_t *)((uint32_t)stringPtr + strlen((char *)stringPtr) + 1));␊ |
403 | ␊ |
404 | ␉return (char *)stringPtr;␊ |
405 | }␊ |
406 | ␊ |
407 | void setSMBStringForField(SMBStructHeader *structHeader, const char *string, uint8_t *field)␊ |
408 | {␊ |
409 | ␉int strSize;␊ |
410 | ␊ |
411 | ␉if (!field)␊ |
412 | ␉␉return;␊ |
413 | ␉if (!string)␊ |
414 | ␉{␊ |
415 | ␉␉*field = 0;␊ |
416 | ␉␉return;␊ |
417 | ␉}␊ |
418 | ␊ |
419 | ␉strSize = strlen(string);␊ |
420 | ␊ |
421 | ␉// remove any spaces found at the end␊ |
422 | ␉while (string[strSize - 1] == ' ')␊ |
423 | ␉␉strSize--;␊ |
424 | ␊ |
425 | ␉memcpy((uint8_t *)structHeader + structHeader->length + stringsSize, string, strSize);␊ |
426 | ␉*field = stringIndex;␊ |
427 | ␊ |
428 | ␉stringIndex++;␊ |
429 | ␉stringsSize += strSize + 1;␊ |
430 | }␊ |
431 | ␊ |
432 | bool setSMBValue(SMBStructPtrs *structPtr, int idx, returnType *value)␊ |
433 | {␊ |
434 | ␉const char *string = 0;␊ |
435 | ␉int len;␊ |
436 | ␊ |
437 | ␉if (numOfSetters <= idx)␊ |
438 | ␉␉return false;␊ |
439 | ␊ |
440 | ␉switch (SMBSetters[idx].valueType)␊ |
441 | ␉{␊ |
442 | ␉␉case kSMBString:␊ |
443 | ␉␉␉if (SMBSetters[idx].keyString)␊ |
444 | ␉␉␉{␊ |
445 | ␉␉␉␉if (getValueForKey(SMBSetters[idx].keyString, &string, &len, SMBPlist))␊ |
446 | ␉␉␉␉␉break;␊ |
447 | ␉␉␉␉else␊ |
448 | ␉␉␉␉␉if (structPtr->orig->type == kSMBTypeMemoryDevice)␉// MemoryDevice only␊ |
449 | ␉␉␉␉␉␉if (getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, &string, NULL))␊ |
450 | ␉␉␉␉␉␉␉break;␊ |
451 | ␉␉␉}␊ |
452 | ␉␉␉if (SMBSetters[idx].getSMBValue)␊ |
453 | ␉␉␉␉if (SMBSetters[idx].getSMBValue((returnType *)&string))␊ |
454 | ␉␉␉␉␉break;␊ |
455 | ␉␉␉if ((SMBSetters[idx].defaultValue) && *(SMBSetters[idx].defaultValue))␊ |
456 | ␉␉␉{␊ |
457 | ␉␉␉␉string = *(SMBSetters[idx].defaultValue);␊ |
458 | ␉␉␉␉break;␊ |
459 | ␉␉␉}␊ |
460 | ␉␉␉string = getSMBStringForField(structPtr->orig, *(uint8_t *)value);␊ |
461 | ␉␉␉break;␊ |
462 | ␊ |
463 | ␉␉case kSMBByte:␊ |
464 | ␉␉case kSMBWord:␊ |
465 | ␉␉case kSMBDWord:␊ |
466 | ␉␉//case kSMBQWord:␊ |
467 | ␉␉␉if (SMBSetters[idx].keyString)␊ |
468 | ␉␉␉{␊ |
469 | ␉␉␉␉if (getIntForKey(SMBSetters[idx].keyString, (int *)&(value->dword), SMBPlist))␊ |
470 | ␉␉␉␉␉return true;␊ |
471 | ␉␉␉␉else␊ |
472 | ␉␉␉␉␉if (structPtr->orig->type == kSMBTypeMemoryDevice)␉// MemoryDevice only␊ |
473 | ␉␉␉␉␉␉if (getSMBValueForKey(structPtr->orig, SMBSetters[idx].keyString, NULL, value))␊ |
474 | ␉␉␉␉␉␉␉return true;␊ |
475 | ␉␉␉}␊ |
476 | ␉␉␉if (SMBSetters[idx].getSMBValue)␊ |
477 | ␉␉␉␉if (SMBSetters[idx].getSMBValue(value))␊ |
478 | ␉␉␉␉␉return true;␊ |
479 | #if 0␊ |
480 | ␉␉␉if (*(SMBSetters[idx].defaultValue))␊ |
481 | ␉␉␉{␊ |
482 | ␉␉␉␉value->dword = *(uint32_t *)(SMBSetters[idx].defaultValue);␊ |
483 | ␉␉␉␉return true;␊ |
484 | ␉␉␉}␊ |
485 | #endif␊ |
486 | ␉␉␉break;␊ |
487 | ␉}␊ |
488 | ␊ |
489 | ␉if (SMBSetters[idx].valueType == kSMBString && string)␊ |
490 | ␉␉setSMBStringForField(structPtr->new, string, &value->byte);␊ |
491 | ␊ |
492 | ␉return true;␊ |
493 | }␊ |
494 | ␊ |
495 | //-------------------------------------------------------------------------------------------------------------------------␊ |
496 | // Apple Specific␊ |
497 | //-------------------------------------------------------------------------------------------------------------------------␊ |
498 | void addSMBFirmwareVolume(SMBStructPtrs *structPtr)␊ |
499 | {␊ |
500 | ␉return;␊ |
501 | }␊ |
502 | ␊ |
503 | void addSMBMemorySPD(SMBStructPtrs *structPtr)␊ |
504 | {␊ |
505 | ␉/* SPD data from Platform.RAM.spd */␊ |
506 | ␉return;␊ |
507 | }␊ |
508 | ␊ |
509 | void addSMBOemProcessorType(SMBStructPtrs *structPtr)␊ |
510 | {␊ |
511 | ␉SMBOemProcessorType *p = (SMBOemProcessorType *)structPtr->new;␊ |
512 | ␊ |
513 | ␉p->header.type␉␉= kSMBTypeOemProcessorType;␊ |
514 | ␉p->header.length␉= sizeof(SMBOemProcessorType);␊ |
515 | ␉p->header.handle␉= handle++;␊ |
516 | ␊ |
517 | ␉setSMBValue(structPtr, numOfSetters - 2 , (returnType *)&(p->ProcessorType));␊ |
518 | ␊ |
519 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorType) + 2);␊ |
520 | ␉tableLength += sizeof(SMBOemProcessorType) + 2;␊ |
521 | ␉structureCount++;␊ |
522 | }␊ |
523 | ␊ |
524 | void addSMBOemProcessorBusSpeed(SMBStructPtrs *structPtr)␊ |
525 | {␊ |
526 | ␉SMBOemProcessorBusSpeed *p = (SMBOemProcessorBusSpeed *)structPtr->new;␊ |
527 | ␊ |
528 | ␉p->header.type␉␉= kSMBTypeOemProcessorBusSpeed;␊ |
529 | ␉p->header.length␉= sizeof(SMBOemProcessorBusSpeed);␊ |
530 | ␉p->header.handle␉= handle++;␊ |
531 | ␊ |
532 | ␉setSMBValue(structPtr, numOfSetters -1, (returnType *)&(p->ProcessorBusSpeed));␊ |
533 | ␊ |
534 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBOemProcessorBusSpeed) + 2);␊ |
535 | ␉tableLength += sizeof(SMBOemProcessorBusSpeed) + 2;␊ |
536 | ␉structureCount++;␊ |
537 | }␊ |
538 | ␊ |
539 | //-------------------------------------------------------------------------------------------------------------------------␊ |
540 | // EndOfTable␊ |
541 | //-------------------------------------------------------------------------------------------------------------------------␊ |
542 | void addSMBEndOfTable(SMBStructPtrs *structPtr)␊ |
543 | {␊ |
544 | ␉structPtr->new->type␉= kSMBTypeEndOfTable;␊ |
545 | ␉structPtr->new->length␉= sizeof(SMBStructHeader);␊ |
546 | ␉structPtr->new->handle␉= handle++;␊ |
547 | ␊ |
548 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + sizeof(SMBStructHeader) + 2);␊ |
549 | ␉tableLength += sizeof(SMBStructHeader) + 2;␊ |
550 | ␉structureCount++;␊ |
551 | }␊ |
552 | ␊ |
553 | void setSMBStruct(SMBStructPtrs *structPtr)␊ |
554 | {␊ |
555 | ␉bool setterFound = false;␊ |
556 | ␊ |
557 | ␉uint8_t *ptr;␊ |
558 | ␉SMBWord structSize;␊ |
559 | ␉int i;␊ |
560 | ␊ |
561 | ␉stringIndex = 1;␊ |
562 | ␉stringsSize = 0;␊ |
563 | ␊ |
564 | ␉if (handle < structPtr->orig->handle)␊ |
565 | ␉␉handle = structPtr->orig->handle;␊ |
566 | ␊ |
567 | ␉memcpy((void *)structPtr->new, structPtr->orig, structPtr->orig->length);␊ |
568 | ␊ |
569 | ␉for (i = 0; i < numOfSetters; i++)␊ |
570 | ␉␉if (structPtr->orig->type == SMBSetters[i].type)␊ |
571 | ␉␉{␊ |
572 | ␉␉␉setterFound = true;␊ |
573 | ␉␉␉setSMBValue(structPtr, i, (returnType *)((uint8_t *)structPtr->new + SMBSetters[i].fieldOffset));␊ |
574 | ␉␉}␊ |
575 | ␊ |
576 | ␉if (setterFound)␊ |
577 | ␉{␊ |
578 | ␉␉ptr = (uint8_t *)structPtr->new + structPtr->orig->length;␊ |
579 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
580 | ␊ |
581 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
582 | ␉␉␉ptr += 2;␊ |
583 | ␊ |
584 | ␉␉structSize = ptr - (uint8_t *)structPtr->new;␊ |
585 | ␉}␊ |
586 | ␉else␊ |
587 | ␉{␊ |
588 | ␉␉ptr = (uint8_t *)structPtr->orig + structPtr->orig->length;␊ |
589 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
590 | ␊ |
591 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
592 | ␉␉␉ptr += 2;␊ |
593 | ␉␉␊ |
594 | ␉␉structSize = ptr - (uint8_t *)structPtr->orig;␊ |
595 | ␉␉memcpy((void *)structPtr->new, structPtr->orig, structSize);␊ |
596 | ␉}␊ |
597 | ␊ |
598 | ␉structPtr->new = (SMBStructHeader *)((uint8_t *)structPtr->new + structSize);␊ |
599 | ␊ |
600 | ␉tableLength += structSize;␊ |
601 | ␊ |
602 | ␉if (structSize > maxStructSize)␊ |
603 | ␉␉maxStructSize = structSize;␊ |
604 | ␊ |
605 | ␉structureCount++;␊ |
606 | }␊ |
607 | ␊ |
608 | void setupNewSMBIOSTable(SMBEntryPoint *eps, SMBStructPtrs *structPtr)␊ |
609 | {␊ |
610 | ␉uint8_t *ptr = (uint8_t *)eps->dmi.tableAddress;␊ |
611 | ␉structPtr->orig = (SMBStructHeader *)ptr;␊ |
612 | ␊ |
613 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structPtr->orig + sizeof(SMBStructHeader)));)␊ |
614 | ␉{␊ |
615 | ␉␉switch (structPtr->orig->type)␊ |
616 | ␉␉{␊ |
617 | ␉␉␉/* Skip all Apple Specific Structures */␊ |
618 | ␉␉␉case kSMBTypeFirmwareVolume:␊ |
619 | ␉␉␉case kSMBTypeMemorySPD:␊ |
620 | ␉␉␉case kSMBTypeOemProcessorType:␊ |
621 | ␉␉␉case kSMBTypeOemProcessorBusSpeed:␊ |
622 | ␉␉␉␉/* And this one too, to be added at the end */␊ |
623 | ␉␉␉case kSMBTypeEndOfTable:␊ |
624 | ␉␉␉␉break;␊ |
625 | ␊ |
626 | ␉␉␉default:␊ |
627 | ␉␉␉␉/* Add */␊ |
628 | ␉␉␉␉setSMBStruct(structPtr);␊ |
629 | ␉␉␉␉break;␊ |
630 | ␉␉}␊ |
631 | ␊ |
632 | ␉␉ptr = (uint8_t *)((uint32_t)structPtr->orig + structPtr->orig->length);␊ |
633 | ␉␉for (; ((uint16_t *)ptr)[0] != 0; ptr++);␊ |
634 | ␊ |
635 | ␉␉if (((uint16_t *)ptr)[0] == 0)␊ |
636 | ␉␉␉ptr += 2;␊ |
637 | ␊ |
638 | ␉␉structPtr->orig = (SMBStructHeader *)ptr;␊ |
639 | ␉}␊ |
640 | ␊ |
641 | ␉addSMBFirmwareVolume(structPtr);␊ |
642 | ␉addSMBMemorySPD(structPtr);␊ |
643 | ␉addSMBOemProcessorType(structPtr);␊ |
644 | ␉addSMBOemProcessorBusSpeed(structPtr);␊ |
645 | ␊ |
646 | ␉addSMBEndOfTable(structPtr);␊ |
647 | }␊ |
648 | ␊ |
649 | void setupSMBIOSTable(void)␊ |
650 | {␊ |
651 | ␉SMBStructPtrs *structPtr;␊ |
652 | ␉uint8_t *buffer;␊ |
653 | ␉bool setSMB = true;␊ |
654 | ␊ |
655 | ␉if (!origeps)␊ |
656 | ␉␉return;␊ |
657 | ␊ |
658 | ␉neweps = origeps;␊ |
659 | ␊ |
660 | ␉structPtr = (SMBStructPtrs *)malloc(sizeof(SMBStructPtrs));␊ |
661 | ␉if (!structPtr)␊ |
662 | ␉␉return;␊ |
663 | ␉␊ |
664 | ␉buffer = malloc(SMB_ALLOC_SIZE);␊ |
665 | ␉if (!buffer)␊ |
666 | ␉␉return;␊ |
667 | ␊ |
668 | ␉bzero(buffer, SMB_ALLOC_SIZE);␊ |
669 | ␉structPtr->new = (SMBStructHeader *)buffer;␊ |
670 | ␊ |
671 | ␉getBoolForKey(kSMBIOSdefaults, &setSMB, &bootInfo->bootConfig);␊ |
672 | ␉if (setSMB)␊ |
673 | ␉␉setDefaultSMBData();␊ |
674 | ␊ |
675 | ␉setupNewSMBIOSTable(origeps, structPtr);␊ |
676 | ␊ |
677 | ␉neweps = (SMBEntryPoint *)AllocateKernelMemory(sizeof(SMBEntryPoint));␊ |
678 | ␉if (!neweps)␊ |
679 | ␉␉return;␊ |
680 | ␉bzero(neweps, sizeof(SMBEntryPoint));␊ |
681 | ␊ |
682 | ␉neweps->anchor[0]␉␉␉= '_';␊ |
683 | ␉neweps->anchor[1]␉␉␉= 'S';␊ |
684 | ␉neweps->anchor[2]␉␉␉= 'M';␊ |
685 | ␉neweps->anchor[3]␉␉␉= '_';␊ |
686 | ␉neweps->entryPointLength␉= sizeof(SMBEntryPoint);␊ |
687 | ␉neweps->majorVersion␉␉= 2;␊ |
688 | ␉neweps->minorVersion␉␉= 4;␊ |
689 | ␉neweps->maxStructureSize␉= maxStructSize;␊ |
690 | ␉neweps->entryPointRevision␉= 0;␊ |
691 | ␊ |
692 | ␉neweps->dmi.anchor[0]␉␉= '_';␊ |
693 | ␉neweps->dmi.anchor[1]␉␉= 'D';␊ |
694 | ␉neweps->dmi.anchor[2]␉␉= 'M';␊ |
695 | ␉neweps->dmi.anchor[3]␉␉= 'I';␊ |
696 | ␉neweps->dmi.anchor[4]␉␉= '_';␊ |
697 | ␉neweps->dmi.tableLength␉␉= tableLength;␊ |
698 | ␉neweps->dmi.tableAddress␉= AllocateKernelMemory(tableLength);␊ |
699 | ␉neweps->dmi.structureCount␉= structureCount;␊ |
700 | ␉neweps->dmi.bcdRevision␉␉= 0x24;␊ |
701 | ␊ |
702 | ␉if (!neweps->dmi.tableAddress)␊ |
703 | ␉␉return;␊ |
704 | ␊ |
705 | ␉memcpy((void *)neweps->dmi.tableAddress, buffer, tableLength);␊ |
706 | ␊ |
707 | ␉neweps->dmi.checksum␉␉= 0;␊ |
708 | ␉neweps->dmi.checksum␉␉= 0x100 - checksum8(&neweps->dmi, sizeof(DMIEntryPoint));␊ |
709 | ␊ |
710 | ␉neweps->checksum␉␉␉= 0;␊ |
711 | ␉neweps->checksum␉␉␉= 0x100 - checksum8(neweps, sizeof(SMBEntryPoint));␊ |
712 | ␊ |
713 | ␉free(buffer);␊ |
714 | ␉decodeSMBIOSTable(neweps);␊ |
715 | }␊ |
716 | ␊ |
717 | void *getSmbios(int which)␊ |
718 | {␊ |
719 | ␉switch (which)␊ |
720 | ␉{␊ |
721 | ␉␉case SMBIOS_ORIGINAL:␊ |
722 | ␉␉␉if (!origeps)␊ |
723 | ␉␉␉␉origeps = getAddressOfSmbiosTable();␊ |
724 | ␉␉␉return origeps;␊ |
725 | ␉␉case SMBIOS_PATCHED:␊ |
726 | ␉␉␉return neweps;␊ |
727 | ␉}␊ |
728 | ␊ |
729 | ␉return 0;␊ |
730 | }␊ |
731 | ␊ |
732 | /* Collect any information needed later */␊ |
733 | void readSMBIOSInfo(SMBEntryPoint *eps)␊ |
734 | {␊ |
735 | ␉uint8_t *structPtr = (uint8_t *)eps->dmi.tableAddress;␊ |
736 | ␉SMBStructHeader *structHeader = (SMBStructHeader *)structPtr;␊ |
737 | ␊ |
738 | ␉int dimmnbr = 0;␊ |
739 | ␉Platform.DMI.MaxMemorySlots␉= 0;␊ |
740 | ␉Platform.DMI.CntMemorySlots␉= 0;␊ |
741 | ␉Platform.DMI.MemoryModules␉= 0;␊ |
742 | ␊ |
743 | ␉for (;((eps->dmi.tableAddress + eps->dmi.tableLength) > ((uint32_t)(uint8_t *)structHeader + sizeof(SMBStructHeader)));)␊ |
744 | ␉{␊ |
745 | ␉␉switch (structHeader->type)␊ |
746 | ␉␉{␊ |
747 | ␉␉␉case kSMBTypeSystemInformation:␊ |
748 | ␉␉␉␉Platform.UUID = ((SMBSystemInformation *)structHeader)->uuid;␊ |
749 | ␉␉␉␉break;␊ |
750 | ␊ |
751 | ␉␉␉case kSMBTypePhysicalMemoryArray:␊ |
752 | ␉␉␉␉Platform.DMI.MaxMemorySlots += ((SMBPhysicalMemoryArray *)structHeader)->numMemoryDevices;␊ |
753 | ␉␉␉␉break;␊ |
754 | ␊ |
755 | ␉␉␉case kSMBTypeMemoryDevice:␊ |
756 | ␉␉␉␉Platform.DMI.CntMemorySlots++;␊ |
757 | ␉␉if (((SMBMemoryDevice *)structHeader)->memorySize != 0)␊ |
758 | ␉␉␉␉␉Platform.DMI.MemoryModules++;␊ |
759 | ␉␉if (((SMBMemoryDevice *)structHeader)->memorySpeed > 0)␊ |
760 | ␉␉␉␉␉Platform.RAM.DIMM[dimmnbr].Frequency = ((SMBMemoryDevice *)structHeader)->memorySpeed;␊ |
761 | ␉␉␉␉dimmnbr++;␊ |
762 | ␉␉␉␉break;␊ |
763 | ␉␉}␊ |
764 | ␊ |
765 | ␉␉structPtr = (uint8_t *)((uint32_t)structHeader + structHeader->length);␊ |
766 | ␉␉for (; ((uint16_t *)structPtr)[0] != 0; structPtr++);␊ |
767 | ␊ |
768 | ␉␉if (((uint16_t *)structPtr)[0] == 0)␊ |
769 | ␉␉␉structPtr += 2;␊ |
770 | ␊ |
771 | ␉␉structHeader = (SMBStructHeader *)structPtr;␊ |
772 | ␉}␊ |
773 | }␊ |
774 | ␊ |
775 | |