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