1 | /*␊ |
2 | * Copyright 2008 mackerintel␊ |
3 | */␊ |
4 | ␊ |
5 | #include "libsaio.h"␊ |
6 | #include "boot.h"␊ |
7 | #include "acpi.h"␊ |
8 | #include "bootstruct.h"␊ |
9 | #include "efi_tables.h"␊ |
10 | #include "fake_efi.h"␊ |
11 | #include "platform.h"␊ |
12 | #include "smbios_patcher.h"␊ |
13 | #include "SMBIOS.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...)␊ |
23 | #endif␊ |
24 | ␊ |
25 | ␊ |
26 | // defaults for a MacBook␊ |
27 | static char sm_macbook_defaults[][2][40]={␊ |
28 | ␉{"SMbiosvendor",␉"Apple Inc."␉␉␉␉␉},␊ |
29 | ␉{"SMbiosversion",␉"MB41.88Z.0073.B00.0809221748"␉},␊ |
30 | ␉{"SMbiosdate",␉␉"04/01/2008"␉␉␉␉␉},␊ |
31 | ␉{"SMmanufacter",␉"Apple Inc."␉␉␉␉␉},␊ |
32 | ␉{"SMproductname",␉"MacBook4,1"␉␉␉␉␉},␊ |
33 | ␉{"SMsystemversion",␉"1.0"␉␉␉␉␉␉␉},␊ |
34 | ␉{"SMserial",␉␉"SOMESRLNMBR"␉␉␉␉␉},␊ |
35 | ␉{"SMfamily",␉␉"MacBook"␉␉␉␉␉␉},␊ |
36 | ␉{"SMboardmanufacter","Apple Inc."␉␉␉␉␉},␊ |
37 | ␉{"SMboardproduct",␉"Mac-F42D89C8"␉␉␉␉␉},␊ |
38 | ␉{ "",""␉}␊ |
39 | };␊ |
40 | ␊ |
41 | // defaults for a MacBook Pro␊ |
42 | static char sm_macbookpro_defaults[][2][40]={␊ |
43 | ␉{"SMbiosvendor",␉"Apple Inc."␉␉␉␉␉},␊ |
44 | ␉{"SMbiosversion",␉"MBP41.88Z.0073.B00.0809221748"␉},␊ |
45 | ␉{"SMbiosdate",␉␉"04/01/2008"␉␉␉␉␉},␊ |
46 | ␉{"SMmanufacter",␉"Apple Inc."␉␉␉␉␉},␊ |
47 | ␉{"SMproductname",␉"MacBookPro4,1"␉␉␉␉␉},␊ |
48 | ␉{"SMsystemversion",␉"1.0"␉␉␉␉␉␉␉},␊ |
49 | ␉{"SMserial",␉␉"SOMESRLNMBR"␉␉␉␉␉},␊ |
50 | ␉{"SMfamily",␉␉"MacBookPro"␉␉␉␉␉},␊ |
51 | ␉{"SMboardmanufacter","Apple Inc."␉␉␉␉␉},␊ |
52 | ␉{"SMboardproduct",␉"Mac-F42D89C8"␉␉␉␉␉},␊ |
53 | ␉{ "",""␉}␊ |
54 | };␊ |
55 | ␊ |
56 | // defaults for a Mac mini ␊ |
57 | static char sm_macmini_defaults[][2][40]={␊ |
58 | ␉{"SMbiosvendor",␉"Apple Inc."␉␉␉␉␉},␊ |
59 | ␉{"SMbiosversion",␉"MM21.88Z.009A.B00.0706281359"␉},␊ |
60 | ␉{"SMbiosdate",␉␉"04/01/2008"␉␉␉␉␉},␊ |
61 | ␉{"SMmanufacter",␉"Apple Inc."␉␉␉␉␉},␊ |
62 | ␉{"SMproductname",␉"Macmini2,1"␉␉␉␉␉},␊ |
63 | ␉{"SMsystemversion",␉"1.0"␉␉␉␉␉␉␉},␊ |
64 | ␉{"SMserial",␉␉"SOMESRLNMBR"␉␉␉␉␉},␊ |
65 | ␉{"SMfamily",␉␉"Napa Mac"␉␉␉␉␉␉},␊ |
66 | ␉{"SMboardmanufacter","Apple Inc."␉␉␉␉␉},␊ |
67 | ␉{"SMboardproduct",␉"Mac-F4208EAA"␉␉␉␉␉},␊ |
68 | ␉{ "",""␉}␊ |
69 | };␊ |
70 | ␊ |
71 | // defaults for an iMac␊ |
72 | static char sm_imac_defaults[][2][40]={␊ |
73 | ␉{"SMbiosvendor",␉"Apple Inc."␉␉␉␉␉},␊ |
74 | ␉{"SMbiosversion",␉"IM81.88Z.00C1.B00.0802091538"␉},␊ |
75 | ␉{"SMbiosdate",␉␉"04/01/2008"␉␉␉␉␉},␊ |
76 | ␉{"SMmanufacter",␉"Apple Inc."␉␉␉␉␉},␊ |
77 | ␉{"SMproductname",␉"iMac8,1"␉␉␉␉␉␉},␉␊ |
78 | ␉{"SMsystemversion",␉"1.0"␉␉␉␉␉␉␉},␊ |
79 | ␉{"SMserial",␉␉"SOMESRLNMBR"␉␉␉␉␉},␊ |
80 | ␉{"SMfamily",␉␉"Mac"␉␉␉␉␉␉␉},␊ |
81 | ␉{"SMboardmanufacter","Apple Inc."␉␉␉␉␉},␊ |
82 | ␉{"SMboardproduct",␉"Mac-F227BEC8"␉␉␉␉␉},␊ |
83 | ␉{ "",""␉}␊ |
84 | };␊ |
85 | ␊ |
86 | // defaults for a Mac Pro␊ |
87 | static char sm_macpro_defaults[][2][40]={␊ |
88 | ␉{"SMbiosvendor",␉"Apple Computer, Inc."␉␉␉},␊ |
89 | ␉{"SMbiosversion",␉"MP31.88Z.006C.B05.0802291410"␉},␊ |
90 | ␉{"SMbiosdate",␉␉"04/01/2008"␉␉␉␉␉},␊ |
91 | ␉{"SMmanufacter",␉"Apple Computer, Inc."␉␉␉},␊ |
92 | ␉{"SMproductname",␉"MacPro3,1"␉␉␉␉␉␉},␊ |
93 | ␉{"SMsystemversion",␉"1.0"␉␉␉␉␉␉␉},␊ |
94 | ␉{"SMserial",␉␉"SOMESRLNMBR"␉␉␉␉␉},␊ |
95 | ␉{"SMfamily",␉␉"MacPro"␉␉␉␉␉␉},␊ |
96 | ␉{"SMboardmanufacter","Apple Computer, Inc."␉␉␉},␊ |
97 | ␉{"SMboardproduct",␉"Mac-F4208DC8"␉␉␉␉␉},␊ |
98 | ␉{ "",""␉}␊ |
99 | };␊ |
100 | ␊ |
101 | static char *sm_get_defstr(char *name, int table_num)␊ |
102 | {␊ |
103 | ␉int i;␊ |
104 | ␉char (*sm_defaults)[2][40];␊ |
105 | ␊ |
106 | ␉if (platformCPUFeature(CPU_FEATURE_MOBILE)) {␊ |
107 | ␉␉if (Platform.CPU.NoCores > 1) {␊ |
108 | ␉␉␉sm_defaults=sm_macbookpro_defaults;␊ |
109 | ␉␉} else {␊ |
110 | ␉␉␉sm_defaults=sm_macbook_defaults;␊ |
111 | ␉␉}␊ |
112 | ␉} else {␊ |
113 | ␉␉switch (Platform.CPU.NoCores)␊ |
114 | ␉␉{␊ |
115 | ␉␉␉case 1: sm_defaults=sm_macmini_defaults; break;␊ |
116 | ␉␉␉case 2: sm_defaults=sm_imac_defaults; break;␊ |
117 | ␉␉ default: sm_defaults=sm_macpro_defaults; break;␊ |
118 | ␉␉}␊ |
119 | ␉}␊ |
120 | ␊ |
121 | ␉for (i=0;sm_defaults[i][0][0];i++)␊ |
122 | ␉␉if (!strcmp (sm_defaults[i][0],name))␊ |
123 | ␉␉␉return sm_defaults[i][1];␊ |
124 | ␊ |
125 | ␉// Shouldn't happen␊ |
126 | ␉printf ("Error: no default for '%s' known\n", name);␊ |
127 | ␉sleep (2);␊ |
128 | ␉return "";␊ |
129 | }␊ |
130 | ␊ |
131 | static int sm_get_fsb (char *name, int table_num)␊ |
132 | {␊ |
133 | ␉return Platform.CPU.FSBFrequency/1000000;␊ |
134 | }␊ |
135 | ␊ |
136 | static int sm_get_cpu (char *name, int table_num)␊ |
137 | {␊ |
138 | ␉/* round CPU frequency */␊ |
139 | //␉return round2(Platform.CPU.CPUFrequency/1000000, 10);␊ |
140 | //␉return roundup2(Platform.CPU.CPUFrequency/1000000, 100); ␊ |
141 | ␉return Platform.CPU.CPUFrequency/1000000;␊ |
142 | }␊ |
143 | ␊ |
144 | static int sm_get_cputype (char *name, int table_num)␊ |
145 | {␊ |
146 | ␉int cores = Platform.CPU.NoCores;␊ |
147 | ␊ |
148 | ␉if (cores == 1)␊ |
149 | ␉␉return 0x0101; // <01 01> Intel Core Solo?␊ |
150 | ␉else if (cores == 2)␊ |
151 | ␉␉return 0x0301; // <01 03> Intel Core 2 Duo␊ |
152 | ␉else if (cores >= 4)␊ |
153 | ␉␉return 0x0501; // <01 05> Quad-Core Intel Xeon␊ |
154 | ␉else␊ |
155 | ␉␉return 0x0301; // Default to Core 2 Duo␊ |
156 | }␊ |
157 | ␊ |
158 | static int sm_get_memtype (char *name, int table_num)␊ |
159 | {␊ |
160 | ␉if (table_num < MAX_RAM_SLOTS &&␊ |
161 | ␉ Platform.RAM.DIMM[table_num].InUse &&␊ |
162 | ␉ Platform.RAM.DIMM[table_num].Type != 0)␊ |
163 | ␉{␊ |
164 | ␉␉return Platform.RAM.DIMM[table_num].Type;␊ |
165 | ␉}␊ |
166 | ␉␉return SMB_MEM_TYPE_DDR2;␊ |
167 | }␊ |
168 | ␊ |
169 | static int sm_get_memspeed (char *name, int table_num)␊ |
170 | {␊ |
171 | ␉if (Platform.RAM.Frequency != 0) {␊ |
172 | ␉␉return Platform.RAM.Frequency/1000000;␊ |
173 | ␉}␊ |
174 | ␉␉return 667;␊ |
175 | }␊ |
176 | ␊ |
177 | static char *sm_get_memvendor (char *name, int table_num)␊ |
178 | {␉␊ |
179 | ␉if (table_num < MAX_RAM_SLOTS &&␊ |
180 | ␉ Platform.RAM.DIMM[table_num].InUse &&␊ |
181 | ␉ strlen(Platform.RAM.DIMM[table_num].Vendor) > 0)␊ |
182 | ␉{␊ |
183 | ␉␉DBG("Vendor[%d]='%s'\n", table_num, Platform.RAM.DIMM[table_num].Vendor);␊ |
184 | ␉␉return Platform.RAM.DIMM[table_num].Vendor;␊ |
185 | ␉}␊ |
186 | ␉return "N/A";␊ |
187 | }␊ |
188 | ␉␊ |
189 | static char *sm_get_memserial (char *name, int table_num)␊ |
190 | {␊ |
191 | ␉if (table_num < MAX_RAM_SLOTS &&␊ |
192 | ␉ Platform.RAM.DIMM[table_num].InUse &&␊ |
193 | ␉ strlen(Platform.RAM.DIMM[table_num].SerialNo) > 0)␊ |
194 | ␉{␊ |
195 | ␉␉DBG("SerialNo[%d]='%s'\n", table_num, Platform.RAM.DIMM[table_num].SerialNo);␊ |
196 | ␉␉return Platform.RAM.DIMM[table_num].SerialNo;␊ |
197 | ␉}␊ |
198 | ␉return "N/A";␊ |
199 | }␊ |
200 | ␊ |
201 | static char *sm_get_mempartno (char *name, int table_num)␊ |
202 | {␊ |
203 | ␉if (table_num < MAX_RAM_SLOTS &&␊ |
204 | ␉ Platform.RAM.DIMM[table_num].InUse &&␊ |
205 | ␉ strlen(Platform.RAM.DIMM[table_num].PartNo) > 0)␊ |
206 | ␉{␊ |
207 | ␉␉DBG("PartNo[%d]='%s'\n", table_num, Platform.RAM.DIMM[table_num].PartNo);␊ |
208 | ␉␉return Platform.RAM.DIMM[table_num].PartNo;␊ |
209 | ␉}␊ |
210 | ␉return "N/A";␊ |
211 | }␊ |
212 | ␊ |
213 | static int sm_one (int tablen)␊ |
214 | {␊ |
215 | ␉return 1;␊ |
216 | }␊ |
217 | ␊ |
218 | struct smbios_property smbios_properties[]=␊ |
219 | {␊ |
220 | ␉{.name="SMbiosvendor",␉␉.table_type= 0,␉.value_type=SMSTRING,␉.offset=0x04,␉.auto_str=sm_get_defstr␉},␊ |
221 | ␉{.name="SMbiosversion",␉␉.table_type= 0,␉.value_type=SMSTRING,␉.offset=0x05,␉.auto_str=sm_get_defstr␉},␊ |
222 | ␉{.name="SMbiosdate",␉␉.table_type= 0,␉.value_type=SMSTRING,␉.offset=0x08,␉.auto_str=sm_get_defstr␉},␊ |
223 | ␉{.name="SMmanufacter",␉␉.table_type= 1,␉.value_type=SMSTRING,␉.offset=0x04,␉.auto_str=sm_get_defstr␉},␊ |
224 | ␉{.name="SMproductname",␉␉.table_type= 1,␉.value_type=SMSTRING,␉.offset=0x05,␉.auto_str=sm_get_defstr␉},␊ |
225 | ␉{.name="SMsystemversion",␉.table_type= 1,␉.value_type=SMSTRING,␉.offset=0x06,␉.auto_str=sm_get_defstr␉},␊ |
226 | ␉{.name="SMserial",␉␉␉.table_type= 1,␉.value_type=SMSTRING,␉.offset=0x07,␉.auto_str=sm_get_defstr␉},␊ |
227 | ␉{.name="SMUUID",␉␉␉.table_type= 1, .value_type=SMOWORD,␉.offset=0x08,␉.auto_oword=0␉␉␉},␊ |
228 | ␉{.name="SMfamily",␉␉␉.table_type= 1,␉.value_type=SMSTRING,␉.offset=0x1a,␉.auto_str=sm_get_defstr␉},␊ |
229 | ␉{.name="SMboardmanufacter",␉.table_type= 2, .value_type=SMSTRING,␉.offset=0x04,␉.auto_str=sm_get_defstr␉},␊ |
230 | ␉{.name="SMboardproduct",␉.table_type= 2, .value_type=SMSTRING,␉.offset=0x05,␉.auto_str=sm_get_defstr␉},␊ |
231 | ␉{.name="SMexternalclock",␉.table_type= 4,␉.value_type=SMWORD,␉␉.offset=0x12,␉.auto_int=sm_get_fsb␉},␊ |
232 | ␉{.name="SMmaximalclock",␉.table_type= 4,␉.value_type=SMWORD,␉␉.offset=0x14,␉.auto_int=sm_get_cpu␉},␊ |
233 | ␉{.name="SMmemdevloc",␉␉.table_type=17,␉.value_type=SMSTRING,␉.offset=0x10,␉.auto_str=0␉␉␉␉},␊ |
234 | ␉{.name="SMmembankloc",␉␉.table_type=17,␉.value_type=SMSTRING,␉.offset=0x11,␉.auto_str=0␉␉␉␉},␊ |
235 | ␉{.name="SMmemtype",␉␉␉.table_type=17,␉.value_type=SMBYTE,␉␉.offset=0x12,␉.auto_int=sm_get_memtype},␊ |
236 | ␉{.name="SMmemspeed",␉␉.table_type=17,␉.value_type=SMWORD,␉␉.offset=0x15,␉.auto_int=sm_get_memspeed},␊ |
237 | ␉{.name="SMmemmanufacter",␉.table_type=17,␉.value_type=SMSTRING,␉.offset=0x17,␉.auto_str=sm_get_memvendor},␊ |
238 | ␉{.name="SMmemserial",␉␉.table_type=17,␉.value_type=SMSTRING,␉.offset=0x18,␉.auto_str=sm_get_memserial},␊ |
239 | ␉{.name="SMmempart",␉␉␉.table_type=17,␉.value_type=SMSTRING,␉.offset=0x1A,␉.auto_str=sm_get_mempartno},␊ |
240 | ␉{.name="SMcputype",␉␉␉.table_type=131,.value_type=SMWORD,␉␉.offset=0x04,␉.auto_int=sm_get_cputype},␊ |
241 | ␉{.name="SMbusspeed",␉␉.table_type=132,.value_type=SMWORD,␉␉.offset=0x04,␉.auto_str=0␉␉␉␉}␊ |
242 | };␊ |
243 | ␊ |
244 | struct smbios_table_description smbios_table_descriptions[]=␊ |
245 | {␊ |
246 | ␉{.type=0,␉.len=0x18,␉.numfunc=sm_one},␊ |
247 | ␉{.type=1,␉.len=0x1b,␉.numfunc=sm_one},␊ |
248 | ␉{.type=2,␉.len=0x0f,␉.numfunc=sm_one},␊ |
249 | ␉{.type=4,␉.len=0x2a,␉.numfunc=sm_one},␊ |
250 | ␉{.type=17,␉.len=0x1c,␉.numfunc=0},␊ |
251 | ␉{.type=131,␉.len=0x06,␉.numfunc=sm_one},␊ |
252 | ␉{.type=132,␉.len=0x06,␉.numfunc=sm_one}␊ |
253 | };␊ |
254 | ␊ |
255 | struct SMBEntryPoint * getAddressOfSmbiosTable()␊ |
256 | {␊ |
257 | ␉/* First see if we can even find the damn SMBIOS table␊ |
258 | * The logic here is to start at 0xf0000 and end at 0xfffff iterating 16 bytes at a time looking␊ |
259 | * for the SMBIOS entry-point structure anchor (literal ASCII "_SM_").␊ |
260 | */␊ |
261 | void *smbios_addr = (void*)SMBIOS_RANGE_START;␊ |
262 | for(; (smbios_addr <= (void*)SMBIOS_RANGE_END) && (*(uint32_t*)smbios_addr != SMBIOS_ANCHOR_UINT32_LE); smbios_addr += 16)␊ |
263 | ;␊ |
264 | if(smbios_addr <= (void*)SMBIOS_RANGE_END)␊ |
265 | {␊ |
266 | /* NOTE: The specification does not specifically state what to do in the event of finding an␊ |
267 | * SMBIOS anchor on an invalid table. It might be better to move this code into the for loop␊ |
268 | * so that searching can continue.␊ |
269 | */␊ |
270 | uint8_t csum = checksum8(smbios_addr, sizeof(struct SMBEntryPoint));␊ |
271 | /* The table already contains the checksum so we merely need to see if its checksum is now zero. */␊ |
272 | if(csum != 0)␊ |
273 | {␊ |
274 | printf("Found SMBIOS anchor but bad table checksum. Assuming no SMBIOS.\n");␊ |
275 | sleep(5);␊ |
276 | smbios_addr = 0;␊ |
277 | }␊ |
278 | }␊ |
279 | else␊ |
280 | {␊ |
281 | /* If this happens, it's possible that a PnP BIOS call can be done to retrieve the address of the table.␊ |
282 | * The latest versions of the spec state that modern programs should not even attempt to do this. */␊ |
283 | printf("Unable to find SMBIOS table.\n");␊ |
284 | sleep(5);␊ |
285 | smbios_addr = 0;␊ |
286 | }␊ |
287 | return smbios_addr;␊ |
288 | }␊ |
289 | ␊ |
290 | /* Compute necessary space requirements for new smbios */␊ |
291 | struct SMBEntryPoint *␊ |
292 | smbios_dry_run (struct SMBEntryPoint * origsmbios)␊ |
293 | {␊ |
294 | ␉struct SMBEntryPoint *ret;␊ |
295 | ␉char *smbiostables=0;␊ |
296 | ␉char *tablesptr;␊ |
297 | ␉int origsmbiosnum=0;␊ |
298 | ␉int i, j;␊ |
299 | ␉int tablespresent[256];␊ |
300 | ␉bool do_auto=1;␊ |
301 | ␊ |
302 | ␉getBoolForKey("SMBIOSdefaults",&do_auto,&bootInfo->bootConfig);␊ |
303 | ␊ |
304 | ␉for (i=0;i<256;i++)␊ |
305 | ␉␉tablespresent[i]=0;␊ |
306 | ␉ret=(struct SMBEntryPoint *)AllocateKernelMemory(sizeof (struct SMBEntryPoint));␊ |
307 | ␉if (origsmbios)␊ |
308 | ␉{␊ |
309 | ␉␉smbiostables=(char *)origsmbios->dmi.tableAddress;␊ |
310 | ␉␉origsmbiosnum=origsmbios->dmi.structureCount;␊ |
311 | ␉} else {␊ |
312 | ␉␉smbiostables = NULL;␊ |
313 | ␉␉origsmbiosnum = 0;␊ |
314 | }␊ |
315 | ␊ |
316 | ␉// _SM_␊ |
317 | ␉ret->anchor[0]=0x5f;␊ |
318 | ␉ret->anchor[1]=0x53;␊ |
319 | ␉ret->anchor[2]=0x4d;␊ |
320 | ␉ret->anchor[3]=0x5f; ␊ |
321 | ␉ret->entryPointLength=sizeof (*ret);␊ |
322 | ␉ret->majorVersion=2;␊ |
323 | ␉ret->minorVersion=1;␊ |
324 | ␉ret->maxStructureSize=0; ␊ |
325 | ␉ret->entryPointRevision=0;␊ |
326 | ␉for (i=0;i<5;i++)␊ |
327 | ␉␉ret->formattedArea[i]=0;␊ |
328 | ␉//_DMI_␊ |
329 | ␉ret->dmi.anchor[0]=0x5f;␊ |
330 | ␉ret->dmi.anchor[1]=0x44;␊ |
331 | ␉ret->dmi.anchor[2]=0x4d;␊ |
332 | ␉ret->dmi.anchor[3]=0x49;␊ |
333 | ␉ret->dmi.anchor[4]=0x5f;␊ |
334 | ␉ret->dmi.tableLength=0; ␊ |
335 | ␉ret->dmi.tableAddress=0; ␊ |
336 | ␉ret->dmi.structureCount=0; ␊ |
337 | ␉ret->dmi.bcdRevision=0x21;␊ |
338 | ␉tablesptr=smbiostables;␊ |
339 | ␉if (smbiostables)␊ |
340 | ␉␉for (i=0;i<origsmbiosnum;i++)␊ |
341 | ␉␉{␊ |
342 | ␉␉␉struct smbios_table_header *cur␊ |
343 | ␉␉␉=(struct smbios_table_header *) tablesptr;␊ |
344 | ␉␉␉char *stringsptr;␊ |
345 | ␉␉␉int stringlen;␊ |
346 | ␉␉␉tablesptr+=cur->length;␊ |
347 | ␉␉␉stringsptr=tablesptr;␊ |
348 | ␉␉␉for (;tablesptr[0]!=0 || tablesptr[1]!=0;tablesptr++);␊ |
349 | ␉␉␉tablesptr+=2;␊ |
350 | ␉␉␉stringlen=tablesptr-stringsptr-1;␊ |
351 | ␉␉␉if (stringlen==1)␊ |
352 | ␉␉␉␉stringlen=0;␊ |
353 | ␉␉␉for (j=0;j<sizeof (smbios_properties)/sizeof(smbios_properties[0]);␊ |
354 | ␉␉␉␉ j++)␊ |
355 | ␉␉␉{␊ |
356 | ␉␉␉␉const char *str;␊ |
357 | ␉␉␉␉int size;␊ |
358 | ␉␉␉␉char altname[40];␊ |
359 | ␉␉␉␉sprintf (altname, "%s_%d",smbios_properties[j].name,␊ |
360 | ␉␉␉␉␉␉ tablespresent[cur->type]+1);␉␉␉␉␊ |
361 | ␉␉␉␉if (smbios_properties[j].table_type==cur->type ␊ |
362 | ␉␉␉␉␉&& smbios_properties[j].value_type==SMSTRING␊ |
363 | ␉␉␉␉␉&& (getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig)␊ |
364 | ␉␉␉␉␉ || getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)))␊ |
365 | ␉␉␉␉␉stringlen+=size+1;␊ |
366 | ␉␉␉␉else if (smbios_properties[j].table_type==cur->type ␊ |
367 | ␉␉␉␉␉␉ && smbios_properties[j].value_type==SMSTRING␊ |
368 | ␉␉␉␉␉␉ && do_auto && smbios_properties[j].auto_str)␊ |
369 | ␉␉␉␉␉stringlen+=strlen(smbios_properties[j].auto_str(smbios_properties[j].name,tablespresent[cur->type]))+1;␊ |
370 | ␉␉␉}␊ |
371 | ␉␉␉if (stringlen==0)␊ |
372 | ␉␉␉␉stringlen=1;␊ |
373 | ␉␉␉stringlen++;␊ |
374 | ␉␉␉if (ret->maxStructureSize<cur->length+stringlen)␊ |
375 | ␉␉␉␉ret->maxStructureSize=cur->length+stringlen;␊ |
376 | ␉␉␉ret->dmi.tableLength+=cur->length+stringlen;␊ |
377 | ␉␉␉ret->dmi.structureCount++;␊ |
378 | ␉␉␉tablespresent[cur->type]++;␊ |
379 | ␉␉}␊ |
380 | ␉for (i=0;i<sizeof (smbios_table_descriptions)␊ |
381 | ␉␉ /sizeof(smbios_table_descriptions[0]);i++)␊ |
382 | ␉{␊ |
383 | ␉␉int numnec=-1;␊ |
384 | ␉␉char buffer[40];␊ |
385 | ␉␉sprintf (buffer, "SMtable%d", i);␊ |
386 | ␉␉if (!getIntForKey(buffer,&numnec,&bootInfo->smbiosConfig))␊ |
387 | ␉␉␉numnec=-1;␊ |
388 | ␉␉if (numnec==-1 && do_auto && smbios_table_descriptions[i].numfunc)␊ |
389 | ␉␉␉numnec=smbios_table_descriptions[i].numfunc (smbios_table_descriptions[i].type);␊ |
390 | ␉␉␊ |
391 | ␉␉while (tablespresent[smbios_table_descriptions[i].type]<numnec)␊ |
392 | ␉␉{␊ |
393 | ␉␉␉int stringlen=0;␊ |
394 | ␉␉␉for (j=0;j<sizeof (smbios_properties)/sizeof(smbios_properties[0]);␊ |
395 | ␉␉␉␉ j++)␊ |
396 | ␉␉␉{␊ |
397 | ␉␉␉␉const char *str;␊ |
398 | ␉␉␉␉int size;␊ |
399 | ␉␉␉␉char altname[40];␊ |
400 | ␉␉␉␉sprintf (altname, "%s_%d",smbios_properties[j].name,␊ |
401 | ␉␉␉␉␉␉ tablespresent[smbios_table_descriptions[i].type]+1);␊ |
402 | ␉␉␉␉if (smbios_properties[j].table_type␊ |
403 | ␉␉␉␉␉==smbios_table_descriptions[i].type ␊ |
404 | ␉␉␉␉␉&& smbios_properties[j].value_type==SMSTRING␊ |
405 | ␉␉␉␉␉&& (getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)␊ |
406 | ␉␉␉␉␉␉|| getValueForKey(smbios_properties[j].name,&str, &size, &bootInfo->smbiosConfig)))␊ |
407 | ␉␉␉␉␉stringlen+=size+1; ␊ |
408 | ␉␉␉␉else if (smbios_properties[j].table_type␊ |
409 | ␉␉␉␉␉␉ ==smbios_table_descriptions[i].type ␊ |
410 | ␉␉␉␉␉␉ && smbios_properties[j].value_type==SMSTRING␊ |
411 | ␉␉␉␉␉␉ && do_auto && smbios_properties[j].auto_str)␊ |
412 | ␉␉␉␉␉stringlen+=strlen(smbios_properties[j].auto_str␊ |
413 | ␉␉␉␉␉␉␉␉␉ (smbios_properties[j].name,␊ |
414 | ␉␉␉␉␉␉␉␉␉ tablespresent[smbios_table_descriptions[i].type]))+1;␊ |
415 | ␉␉␉}␊ |
416 | ␉␉␉if (stringlen==0)␊ |
417 | ␉␉␉␉stringlen=1;␊ |
418 | ␉␉␉stringlen++;␊ |
419 | ␉␉␉if (ret->maxStructureSize<smbios_table_descriptions[i].len+stringlen)␊ |
420 | ␉␉␉␉ret->maxStructureSize=smbios_table_descriptions[i].len+stringlen;␊ |
421 | ␉␉␉ret->dmi.tableLength+=smbios_table_descriptions[i].len+stringlen;␊ |
422 | ␉␉␉ret->dmi.structureCount++;␊ |
423 | ␉␉␉tablespresent[smbios_table_descriptions[i].type]++;␊ |
424 | ␉␉}␊ |
425 | ␉}␊ |
426 | ␉return ret;␊ |
427 | }␊ |
428 | ␊ |
429 | void␊ |
430 | smbios_real_run (struct SMBEntryPoint * origsmbios,␊ |
431 | ␉␉␉␉ struct SMBEntryPoint * newsmbios)␊ |
432 | {␊ |
433 | ␉char *smbiostables=0;␊ |
434 | ␉char *tablesptr, *newtablesptr;␊ |
435 | ␉int origsmbiosnum=0;␊ |
436 | ␉// bitmask of used handles␊ |
437 | ␉uint8_t handles[8192]; ␊ |
438 | ␉uint16_t nexthandle=0;␊ |
439 | ␉int i, j;␊ |
440 | ␉int tablespresent[256];␊ |
441 | ␉bool do_auto=1;␊ |
442 | ␉␊ |
443 | ␉getBoolForKey("SMBIOSdefaults",&do_auto,&bootInfo->bootConfig);␊ |
444 | ␉␊ |
445 | ␉for (i=0;i<256;i++)␊ |
446 | ␉␉tablespresent[i]=0;␊ |
447 | ␉␊ |
448 | ␉memset (handles,0,8192);␊ |
449 | ␉newsmbios->dmi.tableAddress=(uint32_t)AllocateKernelMemory(newsmbios->dmi.tableLength);␊ |
450 | ␉if (origsmbios)␊ |
451 | {␊ |
452 | ␉␉smbiostables=(char *) origsmbios->dmi.tableAddress;␊ |
453 | ␉␉origsmbiosnum=origsmbios->dmi.structureCount;␊ |
454 | ␉} else {␊ |
455 | ␉␉smbiostables = NULL;␊ |
456 | ␉␉origsmbiosnum = 0;␊ |
457 | }␊ |
458 | ␉tablesptr=smbiostables;␊ |
459 | ␉newtablesptr=(char *) newsmbios->dmi.tableAddress;␊ |
460 | ␉if (smbiostables)␊ |
461 | ␉␉for (i=0;i<origsmbiosnum;i++)␊ |
462 | ␉␉{␊ |
463 | ␉␉␉struct smbios_table_header␉*oldcur = (struct smbios_table_header *) tablesptr;␊ |
464 | ␉␉␉struct smbios_table_header␉*newcur = (struct smbios_table_header *) newtablesptr;␊ |
465 | ␉␉␉char *stringsptr;␊ |
466 | ␉␉␉int nstrings=0;␊ |
467 | ␉␉␉␊ |
468 | ␉␉␉handles[(oldcur->handle)/8]|=1<<((oldcur->handle)%8);␊ |
469 | ␉␉␉␊ |
470 | ␉␉␉memcpy (newcur,oldcur, oldcur->length);␊ |
471 | ␉␉␉␊ |
472 | ␉␉␉tablesptr+=oldcur->length;␊ |
473 | ␉␉␉stringsptr=tablesptr;␊ |
474 | ␉␉␉newtablesptr+=oldcur->length;␊ |
475 | ␉␉␉for (;tablesptr[0]!=0 || tablesptr[1]!=0;tablesptr++)␊ |
476 | ␉␉␉␉if (tablesptr[0]==0)␊ |
477 | ␉␉␉␉␉nstrings++;␊ |
478 | ␉␉␉if (tablesptr!=stringsptr)␊ |
479 | ␉␉␉␉nstrings++;␊ |
480 | ␉␉␉tablesptr+=2;␊ |
481 | ␉␉␉memcpy (newtablesptr,stringsptr,tablesptr-stringsptr);␊ |
482 | ␉␉␉//point to next possible space for a string␊ |
483 | ␉␉␉newtablesptr+=tablesptr-stringsptr-1;␊ |
484 | ␉␉␉if (nstrings==0)␊ |
485 | ␉␉␉␉newtablesptr--;␊ |
486 | ␉␉␉for (j=0;j<sizeof (smbios_properties)/sizeof(smbios_properties[0]);␊ |
487 | ␉␉␉␉ j++)␊ |
488 | ␉␉␉{␊ |
489 | ␉␉␉␉const char *str;␊ |
490 | ␉␉␉␉int size;␊ |
491 | ␉␉␉␉int num;␊ |
492 | ␉␉␉␉char altname[40];␊ |
493 | ␉␉␉␉sprintf (altname, "%s_%d",smbios_properties[j].name,␊ |
494 | ␉␉␉␉␉␉ tablespresent[newcur->type]+1);␉␉␉␉␊ |
495 | ␉␉␉␉␊ |
496 | ␉␉␉␉if (smbios_properties[j].table_type==newcur->type)␊ |
497 | ␉␉␉␉␉switch (smbios_properties[j].value_type)␊ |
498 | ␉␉␉␉{␊ |
499 | ␉␉␉␉␉case SMSTRING:␊ |
500 | ␉␉␉␉␉␉if (getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)␊ |
501 | ␉␉␉␉␉␉␉||getValueForKey(smbios_properties[j].name,&str, &size, &bootInfo->smbiosConfig))␊ |
502 | ␉␉␉␉␉␉{␊ |
503 | ␉␉␉␉␉␉␉memcpy (newtablesptr, str,size);␊ |
504 | ␉␉␉␉␉␉␉newtablesptr[size]=0;␊ |
505 | ␉␉␉␉␉␉␉newtablesptr+=size+1;␊ |
506 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))=++nstrings;␊ |
507 | ␉␉␉␉␉␉}␊ |
508 | ␉␉␉␉␉␉else if (do_auto && smbios_properties[j].auto_str)␊ |
509 | ␉␉␉␉␉␉{␊ |
510 | ␉␉␉␉␉␉␉str=smbios_properties[j].auto_str(smbios_properties[j].name,tablespresent[newcur->type]);␊ |
511 | ␉␉␉␉␉␉␉size=strlen (str);␊ |
512 | ␉␉␉␉␉␉␉memcpy (newtablesptr, str,size);␊ |
513 | ␉␉␉␉␉␉␉newtablesptr[size]=0;␊ |
514 | ␉␉␉␉␉␉␉newtablesptr+=size+1;␊ |
515 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))=++nstrings;␊ |
516 | ␉␉␉␉␉␉}␊ |
517 | ␉␉␉␉␉␉␊ |
518 | ␉␉␉␉␉␉break;␊ |
519 | ␉␉␉␉␉␉␊ |
520 | ␉␉␉␉␉case SMOWORD:␊ |
521 | ␉␉␉␉␉␉if (getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)␊ |
522 | ␉␉␉␉␉␉␉||getValueForKey(smbios_properties[j].name,&str, &size, &bootInfo->smbiosConfig))␊ |
523 | ␉␉␉␉␉␉{␊ |
524 | ␉␉␉␉␉␉␉int k=0, t=0, kk=0;␊ |
525 | ␉␉␉␉␉␉␉const char *ptr=str;␊ |
526 | ␉␉␉␉␉␉␉memset(((char*)newcur)+smbios_properties[j].offset, 0, 16);␊ |
527 | ␉␉␉␉␉␉␉while (ptr-str<size && *ptr && (*ptr==' ' || *ptr=='\t' || *ptr=='\n'))␊ |
528 | ␉␉␉␉␉␉␉␉ptr++;␊ |
529 | ␉␉␉␉␉␉␉if (size-(ptr-str)>=2 && ptr[0]=='0' && (ptr[1]=='x' || ptr[1]=='X'))␊ |
530 | ␉␉␉␉␉␉␉␉ptr+=2;␊ |
531 | ␉␉␉␉␉␉␉for (;ptr-str<size && *ptr && k<16;ptr++)␊ |
532 | ␉␉␉␉␉␉␉{␊ |
533 | ␉␉␉␉␉␉␉␉if (*ptr>='0' && *ptr<='9')␊ |
534 | ␉␉␉␉␉␉␉␉␉(t=(t<<4)|(*ptr-'0')),kk++;␊ |
535 | ␉␉␉␉␉␉␉␉if (*ptr>='a' && *ptr<='f')␊ |
536 | ␉␉␉␉␉␉␉␉␉(t=(t<<4)|(*ptr-'a'+10)),kk++;␊ |
537 | ␉␉␉␉␉␉␉␉if (*ptr>='A' && *ptr<='F')␊ |
538 | ␉␉␉␉␉␉␉␉␉(t=(t<<4)|(*ptr-'A'+10)),kk++;␊ |
539 | ␉␉␉␉␉␉␉␉if (kk==2)␊ |
540 | ␉␉␉␉␉␉␉␉{␊ |
541 | ␉␉␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset+k))=t;␊ |
542 | ␉␉␉␉␉␉␉␉␉k++;␊ |
543 | ␉␉␉␉␉␉␉␉␉kk=0;␊ |
544 | ␉␉␉␉␉␉␉␉␉t=0;␊ |
545 | ␉␉␉␉␉␉␉␉}␊ |
546 | ␉␉␉␉␉␉␉}␊ |
547 | ␉␉␉␉␉␉}␊ |
548 | ␉␉␉␉␉␉break;␊ |
549 | ␉␉␉␉␉␉␊ |
550 | ␉␉␉␉␉case SMBYTE:␊ |
551 | ␉␉␉␉␉␉if (getIntForKey(altname,&num,&bootInfo->smbiosConfig)␊ |
552 | ␉␉␉␉␉␉␉||getIntForKey(smbios_properties[j].name,&num,&bootInfo->smbiosConfig))␊ |
553 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))=num;␊ |
554 | ␉␉␉␉␉␉else if (do_auto && smbios_properties[j].auto_int)␊ |
555 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))␊ |
556 | ␉␉␉␉␉␉␉=smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]);␉␉␉␉␉␉␉␊ |
557 | ␉␉␉␉␉␉break;␊ |
558 | ␉␉␉␉␉␉␊ |
559 | ␉␉␉␉␉case SMWORD:␊ |
560 | ␉␉␉␉␉␉if (getIntForKey(altname,&num,&bootInfo->smbiosConfig)␊ |
561 | ␉␉␉␉␉␉␉||getIntForKey(smbios_properties[j].name,&num,&bootInfo->smbiosConfig))␊ |
562 | ␉␉␉␉␉␉␉*((uint16_t*)(((char*)newcur)+smbios_properties[j].offset))=num;␊ |
563 | ␉␉␉␉␉␉else if (do_auto && smbios_properties[j].auto_int)␊ |
564 | ␉␉␉␉␉␉␉*((uint16_t*)(((char*)newcur)+smbios_properties[j].offset))␊ |
565 | ␉␉␉␉␉␉␉=smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]);␊ |
566 | ␉␉␉␉␉␉break;␊ |
567 | ␉␉␉␉}␊ |
568 | ␉␉␉}␊ |
569 | ␉␉␉if (nstrings==0)␊ |
570 | ␉␉␉{␊ |
571 | ␉␉␉␉newtablesptr[0]=0;␊ |
572 | ␉␉␉␉newtablesptr++;␊ |
573 | ␉␉␉}␊ |
574 | ␉␉␉newtablesptr[0]=0;␊ |
575 | ␉␉␉newtablesptr++;␊ |
576 | ␉␉␉tablespresent[newcur->type]++;␊ |
577 | ␉␉}␊ |
578 | ␉for (i=0;i<sizeof (smbios_table_descriptions)␊ |
579 | ␉␉ /sizeof(smbios_table_descriptions[0]);i++)␊ |
580 | ␉{␊ |
581 | ␉␉int numnec=-1;␊ |
582 | ␉␉char buffer[40];␊ |
583 | ␉␉sprintf (buffer, "SMtable%d", i);␊ |
584 | ␉␉if (!getIntForKey(buffer,&numnec,&bootInfo->smbiosConfig))␊ |
585 | ␉␉␉numnec=-1;␊ |
586 | ␉␉if (numnec==-1 && do_auto && smbios_table_descriptions[i].numfunc)␊ |
587 | ␉␉␉numnec=smbios_table_descriptions[i].numfunc (smbios_table_descriptions[i].type);␊ |
588 | ␉␉␊ |
589 | ␉␉while (tablespresent[smbios_table_descriptions[i].type]<numnec)␊ |
590 | ␉␉{␊ |
591 | ␉␉␉struct smbios_table_header *newcur=(struct smbios_table_header *) newtablesptr;␊ |
592 | ␉␉␉int nstrings=0;␊ |
593 | ␉␉␉␊ |
594 | ␉␉␉memset (newcur,0, smbios_table_descriptions[i].len);␊ |
595 | ␉␉␉while (handles[(nexthandle)/8]&(1<<((nexthandle)%8)))␊ |
596 | ␉␉␉␉nexthandle++;␊ |
597 | ␉␉␉newcur->handle=nexthandle;␊ |
598 | ␉␉␉handles[nexthandle/8]|=1<<(nexthandle%8);␊ |
599 | ␉␉␉newcur->type=smbios_table_descriptions[i].type;␊ |
600 | ␉␉␉newcur->length=smbios_table_descriptions[i].len;␊ |
601 | ␉␉␉newtablesptr+=smbios_table_descriptions[i].len;␊ |
602 | ␉␉␉for (j=0;j<sizeof (smbios_properties)/sizeof(smbios_properties[0]);␊ |
603 | ␉␉␉␉ j++)␊ |
604 | ␉␉␉{␊ |
605 | ␉␉␉␉const char *str;␊ |
606 | ␉␉␉␉int size;␊ |
607 | ␉␉␉␉int num;␊ |
608 | ␉␉␉␉char altname[40];␊ |
609 | ␉␉␉␉sprintf (altname, "%s_%d",smbios_properties[j].name,␊ |
610 | ␉␉␉␉␉␉ tablespresent[newcur->type]+1);␉␉␉␉␊ |
611 | ␉␉␉␉␊ |
612 | ␉␉␉␉if (smbios_properties[j].table_type==newcur->type)␊ |
613 | ␉␉␉␉␉switch (smbios_properties[j].value_type)␊ |
614 | ␉␉␉␉{␊ |
615 | ␉␉␉␉␉case SMSTRING:␊ |
616 | ␉␉␉␉␉␉if (getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)␊ |
617 | ␉␉␉␉␉␉␉||getValueForKey(smbios_properties[j].name,&str, &size, &bootInfo->smbiosConfig))␊ |
618 | ␉␉␉␉␉␉{␊ |
619 | ␉␉␉␉␉␉␉memcpy (newtablesptr, str,size);␊ |
620 | ␉␉␉␉␉␉␉newtablesptr[size]=0;␊ |
621 | ␉␉␉␉␉␉␉newtablesptr+=size+1;␊ |
622 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))=++nstrings;␊ |
623 | ␉␉␉␉␉␉}␊ |
624 | ␉␉␉␉␉␉else if (do_auto && smbios_properties[j].auto_str)␊ |
625 | ␉␉␉␉␉␉{␊ |
626 | ␉␉␉␉␉␉␉str=smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]);␊ |
627 | ␉␉␉␉␉␉␉size=strlen (str);␊ |
628 | ␉␉␉␉␉␉␉memcpy (newtablesptr, str,size);␊ |
629 | ␉␉␉␉␉␉␉newtablesptr[size]=0;␊ |
630 | ␉␉␉␉␉␉␉newtablesptr+=size+1;␊ |
631 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))=++nstrings;␊ |
632 | ␉␉␉␉␉␉}␉␉␉␉␉␉␊ |
633 | ␉␉␉␉␉␉break;␊ |
634 | ␉␉␉␉␉␉␊ |
635 | ␉␉␉␉␉case SMOWORD:␊ |
636 | ␉␉␉␉␉␉if (getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)␊ |
637 | ␉␉␉␉␉␉␉||getValueForKey(smbios_properties[j].name,&str, &size, &bootInfo->smbiosConfig))␊ |
638 | ␉␉␉␉␉␉{␊ |
639 | ␉␉␉␉␉␉␉int k=0, t=0, kk=0;␊ |
640 | ␉␉␉␉␉␉␉const char *ptr=str;␊ |
641 | ␉␉␉␉␉␉␉memset(((char*)newcur)+smbios_properties[j].offset, 0, 16);␊ |
642 | ␉␉␉␉␉␉␉while (ptr-str<size && *ptr && (*ptr==' ' || *ptr=='\t' || *ptr=='\n'))␊ |
643 | ␉␉␉␉␉␉␉␉ptr++;␊ |
644 | ␉␉␉␉␉␉␉if (size-(ptr-str)>=2 && ptr[0]=='0' && (ptr[1]=='x' || ptr[1]=='X'))␊ |
645 | ␉␉␉␉␉␉␉␉ptr+=2;␊ |
646 | ␉␉␉␉␉␉␉for (;ptr-str<size && *ptr && k<16;ptr++)␊ |
647 | ␉␉␉␉␉␉␉{␊ |
648 | ␉␉␉␉␉␉␉␉if (*ptr>='0' && *ptr<='9')␊ |
649 | ␉␉␉␉␉␉␉␉␉(t=(t<<4)|(*ptr-'0')),kk++;␊ |
650 | ␉␉␉␉␉␉␉␉if (*ptr>='a' && *ptr<='f')␊ |
651 | ␉␉␉␉␉␉␉␉␉(t=(t<<4)|(*ptr-'a'+10)),kk++;␊ |
652 | ␉␉␉␉␉␉␉␉if (*ptr>='A' && *ptr<='F')␊ |
653 | ␉␉␉␉␉␉␉␉␉(t=(t<<4)|(*ptr-'A'+10)),kk++;␊ |
654 | ␉␉␉␉␉␉␉␉if (kk==2)␊ |
655 | ␉␉␉␉␉␉␉␉{␊ |
656 | ␉␉␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset+k))=t;␊ |
657 | ␉␉␉␉␉␉␉␉␉k++;␊ |
658 | ␉␉␉␉␉␉␉␉␉kk=0;␊ |
659 | ␉␉␉␉␉␉␉␉␉t=0;␊ |
660 | ␉␉␉␉␉␉␉␉}␊ |
661 | ␉␉␉␉␉␉␉}␊ |
662 | ␉␉␉␉␉␉}␊ |
663 | ␉␉␉␉␉␉break;␊ |
664 | ␉␉␉␉␉␉␊ |
665 | ␉␉␉␉␉case SMBYTE:␊ |
666 | ␉␉␉␉␉␉if (getIntForKey(altname,&num,&bootInfo->smbiosConfig)␊ |
667 | ␉␉␉␉␉␉␉||getIntForKey(smbios_properties[j].name,&num,&bootInfo->smbiosConfig))␊ |
668 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))=num;␊ |
669 | ␉␉␉␉␉␉else if (do_auto && smbios_properties[j].auto_int)␊ |
670 | ␉␉␉␉␉␉␉*((uint8_t*)(((char*)newcur)+smbios_properties[j].offset))␊ |
671 | ␉␉␉␉␉␉␉=smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]);␊ |
672 | ␉␉␉␉␉␉break;␊ |
673 | ␉␉␉␉␉␉␊ |
674 | ␉␉␉␉␉case SMWORD:␊ |
675 | ␉␉␉␉␉␉if (getIntForKey(altname,&num,&bootInfo->smbiosConfig)␊ |
676 | ␉␉␉␉␉␉␉||getIntForKey(smbios_properties[j].name,&num,&bootInfo->smbiosConfig))␊ |
677 | ␉␉␉␉␉␉␉*((uint16_t*)(((char*)newcur)+smbios_properties[j].offset))=num;␊ |
678 | ␉␉␉␉␉␉else if (do_auto && smbios_properties[j].auto_int)␊ |
679 | ␉␉␉␉␉␉␉*((uint16_t*)(((char*)newcur)+smbios_properties[j].offset))␊ |
680 | ␉␉␉␉␉␉␉=smbios_properties[j].auto_int(smbios_properties[j].name, tablespresent[newcur->type]);␊ |
681 | ␉␉␉␉␉␉break;␊ |
682 | ␉␉␉␉}␊ |
683 | ␉␉␉}␊ |
684 | ␉␉␉if (nstrings==0)␊ |
685 | ␉␉␉{␊ |
686 | ␉␉␉␉newtablesptr[0]=0;␊ |
687 | ␉␉␉␉newtablesptr++;␊ |
688 | ␉␉␉}␊ |
689 | ␉␉␉newtablesptr[0]=0;␊ |
690 | ␉␉␉newtablesptr++;␊ |
691 | ␉␉␉tablespresent[smbios_table_descriptions[i].type]++;␊ |
692 | ␉␉}␊ |
693 | ␉}␊ |
694 | ␉newsmbios->dmi.checksum=0;␊ |
695 | ␉newsmbios->dmi.checksum=256-checksum8 (&newsmbios->dmi,sizeof (newsmbios->dmi));␊ |
696 | ␉newsmbios->checksum=0;␊ |
697 | ␉newsmbios->checksum=256-checksum8 (newsmbios,sizeof (*newsmbios));␊ |
698 | ␉verbose("Patched DMI Table.\n");␊ |
699 | }␊ |
700 | ␊ |
701 | inline struct SMBEntryPoint *␊ |
702 | getSmbios()␊ |
703 | {␊ |
704 | ␉const char *smbios_filename;␊ |
705 | ␉char dirSpec[512];␊ |
706 | ␉int len;␊ |
707 | ␉struct SMBEntryPoint *orig_address;␊ |
708 | ␉struct SMBEntryPoint *new_address;␊ |
709 | ␉orig_address=getAddressOfSmbiosTable();␊ |
710 | ␊ |
711 | ␉if (!getValueForKey("SMBIOS", &smbios_filename, &len, &bootInfo->bootConfig))␊ |
712 | ␉␉smbios_filename = "smbios.plist";␊ |
713 | ␉␊ |
714 | ␉sprintf(dirSpec, "%s", smbios_filename);␊ |
715 | ␉if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1)␊ |
716 | ␉{␊ |
717 | ␉␉sprintf(dirSpec, "/Extra/%s", smbios_filename);␊ |
718 | ␉if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1)␊ |
719 | ␉␉{␊ |
720 | sprintf(dirSpec, "bt(0,0)/Extra/%s", smbios_filename);␊ |
721 | ␉if (loadConfigFile(dirSpec, &bootInfo->smbiosConfig) == -1)␊ |
722 | {␊ |
723 | verbose("No SMBIOS replacement found.\n");␊ |
724 | }␊ |
725 | }␊ |
726 | ␉}␊ |
727 | ␊ |
728 | //␉if( (loadConfigFile("/Extra/smbios.plist", &bootInfo->smbiosConfig)) == -1 )␊ |
729 | //␉␉loadConfigFile("bt(0,0)/Extra/smbios.plist", &bootInfo->smbiosConfig); // TODO: do we need this ?␊ |
730 | ␉␉␊ |
731 | ␉new_address = smbios_dry_run(orig_address);␊ |
732 | ␉smbios_real_run(orig_address, new_address);␊ |
733 | ␉return new_address;␊ |
734 | }␊ |
735 | |