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