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