blob: f948d783386f3b226c636a04731db4c117ad4eec [file] [log] [blame]
Kevin O'Connor0525d292008-07-04 06:18:30 -04001// smbios table generation (on emulators)
Kevin O'Connora4d35762008-03-08 15:43:03 -05002//
Kevin O'Connor2929c352009-07-25 13:48:27 -04003// Copyright (C) 2008,2009 Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor0525d292008-07-04 06:18:30 -04004// Copyright (C) 2006 Fabrice Bellard
Kevin O'Connora4d35762008-03-08 15:43:03 -05005//
Kevin O'Connorb1b7c2a2009-01-15 20:52:58 -05006// This file may be distributed under the terms of the GNU LGPLv3 license.
Kevin O'Connora4d35762008-03-08 15:43:03 -05007
Kevin O'Connorac8df8c2008-05-24 23:46:33 -04008#include "util.h" // dprintf
Kevin O'Connor9521e262008-07-04 13:04:29 -04009#include "biosvar.h" // GET_EBDA
Kevin O'Connor01a85202009-10-18 09:49:59 -040010#include "paravirt.h" // qemu_cfg_smbios_load_field
11#include "smbios.h" // struct smbios_entry_point
Kevin O'Connor0525d292008-07-04 06:18:30 -040012
Kevin O'Connora4d35762008-03-08 15:43:03 -050013static void
Kevin O'Connor2929c352009-07-25 13:48:27 -040014smbios_entry_point_init(u16 max_structure_size,
Kevin O'Connore51313d2008-03-12 21:19:34 -040015 u16 structure_table_length,
Kevin O'Connor2929c352009-07-25 13:48:27 -040016 void *structure_table_address,
Kevin O'Connore51313d2008-03-12 21:19:34 -040017 u16 number_of_structures)
Kevin O'Connora4d35762008-03-08 15:43:03 -050018{
Kevin O'Connor2929c352009-07-25 13:48:27 -040019 struct smbios_entry_point *ep = malloc_fseg(sizeof(*ep));
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -050020 void *finaltable = malloc_high(structure_table_length);
21 if (!ep || !finaltable) {
Kevin O'Connorcfdc13f2010-02-14 13:07:54 -050022 warn_noalloc();
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -050023 free(ep);
24 free(finaltable);
Kevin O'Connor2929c352009-07-25 13:48:27 -040025 return;
26 }
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -050027 memcpy(finaltable, structure_table_address, structure_table_length);
Kevin O'Connora4d35762008-03-08 15:43:03 -050028
29 memcpy(ep->anchor_string, "_SM_", 4);
30 ep->length = 0x1f;
31 ep->smbios_major_version = 2;
32 ep->smbios_minor_version = 4;
33 ep->max_structure_size = max_structure_size;
34 ep->entry_point_revision = 0;
35 memset(ep->formatted_area, 0, 5);
36 memcpy(ep->intermediate_anchor_string, "_DMI_", 5);
37
38 ep->structure_table_length = structure_table_length;
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -050039 ep->structure_table_address = (u32)finaltable;
Kevin O'Connora4d35762008-03-08 15:43:03 -050040 ep->number_of_structures = number_of_structures;
41 ep->smbios_bcd_revision = 0x24;
42
Kevin O'Connor2929c352009-07-25 13:48:27 -040043 ep->checksum -= checksum(ep, 0x10);
Kevin O'Connora4d35762008-03-08 15:43:03 -050044
Kevin O'Connor2929c352009-07-25 13:48:27 -040045 ep->intermediate_checksum -= checksum((void*)ep + 0x10, ep->length - 0x10);
46
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -050047 dprintf(1, "SMBIOS ptr=%p table=%p\n", ep, finaltable);
Kevin O'Connor2e7ab8b2008-03-29 14:29:35 -040048}
Kevin O'Connora4d35762008-03-08 15:43:03 -050049
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040050#define load_str_field_with_default(type, field, def) \
51 do { \
52 size = qemu_cfg_smbios_load_field(type, \
53 offsetof(struct smbios_type_##type, \
54 field), end); \
55 if (size > 0) { \
56 end += size; \
57 } else { \
58 memcpy(end, def, sizeof(def)); \
59 end += sizeof(def); \
60 } \
61 p->field = ++str_index; \
62 } while (0)
63
64#define load_str_field_or_skip(type, field) \
65 do { \
66 size = qemu_cfg_smbios_load_field(type, \
67 offsetof(struct smbios_type_##type, \
68 field), end); \
69 if (size > 0) { \
70 end += size; \
71 p->field = ++str_index; \
72 } else { \
73 p->field = 0; \
74 } \
75 } while (0)
76
Kevin O'Connora4d35762008-03-08 15:43:03 -050077/* Type 0 -- BIOS Information */
78#define RELEASE_DATE_STR "01/01/2007"
79static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040080smbios_init_type_0(void *start)
Kevin O'Connora4d35762008-03-08 15:43:03 -050081{
82 struct smbios_type_0 *p = (struct smbios_type_0 *)start;
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040083 char *end = (char *)start + sizeof(struct smbios_type_0);
84 size_t size;
85 int str_index = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -050086
87 p->header.type = 0;
88 p->header.length = sizeof(struct smbios_type_0);
89 p->header.handle = 0;
90
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040091 load_str_field_with_default(0, vendor_str, CONFIG_APPNAME);
92 load_str_field_with_default(0, bios_version_str, CONFIG_APPNAME);
93
Kevin O'Connora4d35762008-03-08 15:43:03 -050094 p->bios_starting_address_segment = 0xe800;
Kevin O'Connor4e4b4102009-10-08 21:21:59 -040095
96 load_str_field_with_default(0, bios_release_date_str, RELEASE_DATE_STR);
97
Kevin O'Connora4d35762008-03-08 15:43:03 -050098 p->bios_rom_size = 0; /* FIXME */
99
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400100 memset(p->bios_characteristics, 0, 8);
Kevin O'Connor230a7b82008-10-25 14:43:11 -0400101 p->bios_characteristics[0] = 0x08; /* BIOS characteristics not supported */
Kevin O'Connora4d35762008-03-08 15:43:03 -0500102 p->bios_characteristics_extension_bytes[0] = 0;
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500103 /* Enable targeted content distribution. Needed for SVVP */
104 p->bios_characteristics_extension_bytes[1] = 4;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500105
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400106 if (!qemu_cfg_smbios_load_field(0, offsetof(struct smbios_type_0,
107 system_bios_major_release),
108 &p->system_bios_major_release))
109 p->system_bios_major_release = 1;
110
111 if (!qemu_cfg_smbios_load_field(0, offsetof(struct smbios_type_0,
112 system_bios_minor_release),
113 &p->system_bios_minor_release))
114 p->system_bios_minor_release = 0;
115
Kevin O'Connora4d35762008-03-08 15:43:03 -0500116 p->embedded_controller_major_release = 0xff;
117 p->embedded_controller_minor_release = 0xff;
118
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400119 *end = 0;
120 end++;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500121
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400122 return end;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500123}
124
125/* Type 1 -- System Information */
126static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400127smbios_init_type_1(void *start)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500128{
129 struct smbios_type_1 *p = (struct smbios_type_1 *)start;
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400130 char *end = (char *)start + sizeof(struct smbios_type_1);
131 size_t size;
132 int str_index = 0;
133
Kevin O'Connora4d35762008-03-08 15:43:03 -0500134 p->header.type = 1;
135 p->header.length = sizeof(struct smbios_type_1);
136 p->header.handle = 0x100;
137
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500138 load_str_field_with_default(1, manufacturer_str, CONFIG_APPNAME);
139 load_str_field_with_default(1, product_name_str, CONFIG_APPNAME);
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400140 load_str_field_or_skip(1, version_str);
141 load_str_field_or_skip(1, serial_number_str);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500142
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400143 size = qemu_cfg_smbios_load_field(1, offsetof(struct smbios_type_1,
144 uuid), &p->uuid);
145 if (size == 0)
146 memset(p->uuid, 0, 16);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500147
148 p->wake_up_type = 0x06; /* power switch */
Kevin O'Connora4d35762008-03-08 15:43:03 -0500149
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400150 load_str_field_or_skip(1, sku_number_str);
151 load_str_field_or_skip(1, family_str);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500152
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400153 *end = 0;
154 end++;
155 if (!str_index) {
156 *end = 0;
157 end++;
158 }
159
160 return end;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500161}
162
163/* Type 3 -- System Enclosure */
164static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400165smbios_init_type_3(void *start)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500166{
167 struct smbios_type_3 *p = (struct smbios_type_3 *)start;
168
169 p->header.type = 3;
170 p->header.length = sizeof(struct smbios_type_3);
171 p->header.handle = 0x300;
172
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500173 p->manufacturer_str = 1;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500174 p->type = 0x01; /* other */
175 p->version_str = 0;
176 p->serial_number_str = 0;
177 p->asset_tag_number_str = 0;
178 p->boot_up_state = 0x03; /* safe */
179 p->power_supply_state = 0x03; /* safe */
180 p->thermal_state = 0x03; /* safe */
181 p->security_status = 0x02; /* unknown */
182 p->oem_defined = 0;
183 p->height = 0;
184 p->number_of_power_cords = 0;
185 p->contained_element_count = 0;
186
187 start += sizeof(struct smbios_type_3);
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500188 memcpy((char *)start, CONFIG_APPNAME"\0\0", sizeof(CONFIG_APPNAME) + 1);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500189
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500190 return start + sizeof(CONFIG_APPNAME) + 1;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500191}
192
193/* Type 4 -- Processor Information */
194static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400195smbios_init_type_4(void *start, unsigned int cpu_number)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500196{
197 struct smbios_type_4 *p = (struct smbios_type_4 *)start;
198
199 p->header.type = 4;
200 p->header.length = sizeof(struct smbios_type_4);
201 p->header.handle = 0x400 + cpu_number;
202
203 p->socket_designation_str = 1;
204 p->processor_type = 0x03; /* CPU */
205 p->processor_family = 0x01; /* other */
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500206 p->processor_manufacturer_str = 2;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500207
Kevin O'Connor0525d292008-07-04 06:18:30 -0400208 u32 cpuid_signature, ebx, ecx, cpuid_features;
209 cpuid(1, &cpuid_signature, &ebx, &ecx, &cpuid_features);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500210 p->processor_id[0] = cpuid_signature;
211 p->processor_id[1] = cpuid_features;
212
213 p->processor_version_str = 0;
214 p->voltage = 0;
215 p->external_clock = 0;
216
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500217 p->max_speed = 2000;
218 p->current_speed = 2000;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500219
220 p->status = 0x41; /* socket populated, CPU enabled */
221 p->processor_upgrade = 0x01; /* other */
222
Kevin O'Connorf2ce1912008-10-25 15:23:53 -0400223 p->l1_cache_handle = 0xffff; /* cache information structure not provided */
224 p->l2_cache_handle = 0xffff;
225 p->l3_cache_handle = 0xffff;
226
Kevin O'Connora4d35762008-03-08 15:43:03 -0500227 start += sizeof(struct smbios_type_4);
228
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500229 snprintf((char*)start, 6, "CPU%2x", cpu_number);
230 start += 6;
231 memcpy((char *)start, CONFIG_APPNAME"\0\0", sizeof(CONFIG_APPNAME) + 1);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500232
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500233 return start + sizeof(CONFIG_APPNAME) + 1;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500234}
235
236/* Type 16 -- Physical Memory Array */
237static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400238smbios_init_type_16(void *start, u32 memory_size_mb, int nr_mem_devs)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500239{
240 struct smbios_type_16 *p = (struct smbios_type_16*)start;
241
242 p->header.type = 16;
243 p->header.length = sizeof(struct smbios_type_16);
244 p->header.handle = 0x1000;
245
246 p->location = 0x01; /* other */
247 p->use = 0x03; /* system memory */
Kevin O'Connorcf2affa2009-12-10 20:13:57 -0500248 p->error_correction = 0x06; /* Multi-bit ECC to make Microsoft happy */
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400249 p->maximum_capacity = memory_size_mb * 1024;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500250 p->memory_error_information_handle = 0xfffe; /* none provided */
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400251 p->number_of_memory_devices = nr_mem_devs;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500252
253 start += sizeof(struct smbios_type_16);
Kevin O'Connore51313d2008-03-12 21:19:34 -0400254 *((u16 *)start) = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500255
256 return start + 2;
257}
258
259/* Type 17 -- Memory Device */
260static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400261smbios_init_type_17(void *start, u32 memory_size_mb, int instance)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500262{
263 struct smbios_type_17 *p = (struct smbios_type_17 *)start;
264
265 p->header.type = 17;
266 p->header.length = sizeof(struct smbios_type_17);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400267 p->header.handle = 0x1100 + instance;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500268
269 p->physical_memory_array_handle = 0x1000;
270 p->total_width = 64;
271 p->data_width = 64;
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400272/* TODO: should assert in case something is wrong ASSERT((memory_size_mb & ~0x7fff) == 0); */
273 p->size = memory_size_mb;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500274 p->form_factor = 0x09; /* DIMM */
275 p->device_set = 0;
276 p->device_locator_str = 1;
277 p->bank_locator_str = 0;
278 p->memory_type = 0x07; /* RAM */
279 p->type_detail = 0;
280
281 start += sizeof(struct smbios_type_17);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400282 memcpy((char *)start, "DIMM 0", 7);
283 ((char*)start)[5] += instance;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500284 start += 7;
Kevin O'Connore51313d2008-03-12 21:19:34 -0400285 *((u8 *)start) = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500286
287 return start+1;
288}
289
290/* Type 19 -- Memory Array Mapped Address */
291static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400292smbios_init_type_19(void *start, u32 memory_size_mb, int instance)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500293{
294 struct smbios_type_19 *p = (struct smbios_type_19 *)start;
295
296 p->header.type = 19;
297 p->header.length = sizeof(struct smbios_type_19);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400298 p->header.handle = 0x1300 + instance;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500299
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400300 p->starting_address = instance << 24;
301 p->ending_address = p->starting_address + (memory_size_mb << 10) - 1;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500302 p->memory_array_handle = 0x1000;
303 p->partition_width = 1;
304
305 start += sizeof(struct smbios_type_19);
Kevin O'Connore51313d2008-03-12 21:19:34 -0400306 *((u16 *)start) = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500307
308 return start + 2;
309}
310
311/* Type 20 -- Memory Device Mapped Address */
312static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400313smbios_init_type_20(void *start, u32 memory_size_mb, int instance)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500314{
315 struct smbios_type_20 *p = (struct smbios_type_20 *)start;
316
317 p->header.type = 20;
318 p->header.length = sizeof(struct smbios_type_20);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400319 p->header.handle = 0x1400 + instance;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500320
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400321 p->starting_address = instance << 24;
322 p->ending_address = p->starting_address + (memory_size_mb << 10) - 1;
323 p->memory_device_handle = 0x1100 + instance;
324 p->memory_array_mapped_address_handle = 0x1300 + instance;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500325 p->partition_row_position = 1;
326 p->interleave_position = 0;
327 p->interleaved_data_depth = 0;
328
329 start += sizeof(struct smbios_type_20);
330
Kevin O'Connore51313d2008-03-12 21:19:34 -0400331 *((u16 *)start) = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500332 return start+2;
333}
334
335/* Type 32 -- System Boot Information */
336static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400337smbios_init_type_32(void *start)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500338{
339 struct smbios_type_32 *p = (struct smbios_type_32 *)start;
340
341 p->header.type = 32;
342 p->header.length = sizeof(struct smbios_type_32);
343 p->header.handle = 0x2000;
344 memset(p->reserved, 0, 6);
345 p->boot_status = 0; /* no errors detected */
346
347 start += sizeof(struct smbios_type_32);
Kevin O'Connore51313d2008-03-12 21:19:34 -0400348 *((u16 *)start) = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500349
350 return start+2;
351}
352
353/* Type 127 -- End of Table */
354static void *
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400355smbios_init_type_127(void *start)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500356{
357 struct smbios_type_127 *p = (struct smbios_type_127 *)start;
358
359 p->header.type = 127;
360 p->header.length = sizeof(struct smbios_type_127);
361 p->header.handle = 0x7f00;
362
363 start += sizeof(struct smbios_type_127);
Kevin O'Connore51313d2008-03-12 21:19:34 -0400364 *((u16 *)start) = 0;
Kevin O'Connora4d35762008-03-08 15:43:03 -0500365
366 return start + 2;
367}
368
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -0500369#define TEMPSMBIOSSIZE (32 * 1024)
370
Kevin O'Connor0525d292008-07-04 06:18:30 -0400371void
372smbios_init(void)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500373{
Kevin O'Connor6cb8ba92008-08-17 11:03:24 -0400374 if (! CONFIG_SMBIOS)
375 return;
376
Kevin O'Connor7b49cd92008-11-08 10:35:26 -0500377 dprintf(3, "init SMBIOS tables\n");
378
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -0500379 char *start = malloc_tmphigh(TEMPSMBIOSSIZE);
Kevin O'Connor2929c352009-07-25 13:48:27 -0400380 if (! start) {
Kevin O'Connorcfdc13f2010-02-14 13:07:54 -0500381 warn_noalloc();
Kevin O'Connor2929c352009-07-25 13:48:27 -0400382 return;
383 }
Kevin O'Connora4d35762008-03-08 15:43:03 -0500384
Kevin O'Connor2929c352009-07-25 13:48:27 -0400385 u32 nr_structs = 0, max_struct_size = 0;
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -0500386 char *q, *p = start;
387 char *end = start + TEMPSMBIOSSIZE - sizeof(struct smbios_type_127);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500388
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400389#define add_struct(type, args...) \
390 do { \
391 if (!qemu_cfg_smbios_load_external(type, &p, &nr_structs, \
392 &max_struct_size, end)) { \
393 q = smbios_init_type_##type(args); \
394 nr_structs++; \
395 if ((q - p) > max_struct_size) \
396 max_struct_size = q - p; \
397 p = q; \
398 } \
399 } while (0)
Kevin O'Connora4d35762008-03-08 15:43:03 -0500400
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400401 add_struct(0, p);
402 add_struct(1, p);
403 add_struct(3, p);
404
Kevin O'Connora26df9b2009-10-09 09:42:11 -0400405 int cpu_num;
406 for (cpu_num = 1; cpu_num <= MaxCountCPUs; cpu_num++)
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400407 add_struct(4, p, cpu_num);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400408 u64 memsize = RamSizeOver4G;
409 if (memsize)
410 memsize += 0x100000000ull;
411 else
412 memsize = RamSize;
413 memsize = memsize / (1024 * 1024);
414 int nr_mem_devs = (memsize + 0x3fff) >> 14;
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400415 add_struct(16, p, memsize, nr_mem_devs);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400416 int i;
417 for (i = 0; i < nr_mem_devs; i++) {
418 u32 dev_memsize = ((i == (nr_mem_devs - 1))
419 ? (((memsize-1) & 0x3fff)+1) : 0x4000);
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400420 add_struct(17, p, dev_memsize, i);
421 add_struct(19, p, dev_memsize, i);
422 add_struct(20, p, dev_memsize, i);
Kevin O'Connor2a3dfea2009-10-07 19:44:23 -0400423 }
Kevin O'Connor4e4b4102009-10-08 21:21:59 -0400424
425 add_struct(32, p);
426 /* Add any remaining provided entries before the end marker */
427 for (i = 0; i < 256; i++)
428 qemu_cfg_smbios_load_external(i, &p, &nr_structs, &max_struct_size,
429 end);
430 add_struct(127, p);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500431
432#undef add_struct
433
Kevin O'Connor2929c352009-07-25 13:48:27 -0400434 smbios_entry_point_init(max_struct_size, p - start, start, nr_structs);
Kevin O'Connorfe2c3ee2009-12-26 23:26:44 -0500435 free(start);
Kevin O'Connora4d35762008-03-08 15:43:03 -0500436}