summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2020-12-10 13:10:15 -0500
committerKevin O'Connor <kevin@koconnor.net>2021-12-18 11:39:13 -0500
commit4e99229e326c7643b7c488d0a0690071d6a8c8ec (patch)
tree437a82dd63c94815ef2af80d75226a71c267a1a9
parent31eac039b2511dd58fb42998dd983f9f80f7b269 (diff)
downloadqemu-seabios-4e99229e326c7643b7c488d0a0690071d6a8c8ec.tar.gz
smbios: Make smbios_build_tables() more generic
Instead of taking a SMBIOS 2.1 entry point as argument, make smbios_build_tables() take pointers to the fields it actually changes. This will allow us to reuse the function for SMBIOS 3.0 later. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
-rw-r--r--src/fw/biostables.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/fw/biostables.c b/src/fw/biostables.c
index 5eeceb5..f0aa7ed 100644
--- a/src/fw/biostables.c
+++ b/src/fw/biostables.c
@@ -459,13 +459,15 @@ smbios_new_type_0(void *start,
*/
static int
smbios_build_tables(struct romfile_s *f_tables,
- struct smbios_21_entry_point *ep)
+ u32 *address, u16 *length,
+ u16 *max_structure_size,
+ u16 *number_of_structures)
{
struct smbios_type_0 *t0;
u16 qtables_len, need_t0 = 1;
u8 *qtables, *tables;
- if (f_tables->size != ep->structure_table_length)
+ if (f_tables->size != *length)
return 0;
qtables = malloc_tmphigh(f_tables->size);
@@ -489,29 +491,29 @@ smbios_build_tables(struct romfile_s *f_tables,
/* common case: add our own type 0, with 3 strings and 4 '\0's */
u16 t0_len = sizeof(struct smbios_type_0) + strlen(BIOS_NAME) +
strlen(VERSION) + strlen(BIOS_DATE) + 4;
- if (t0_len > (0xffff - ep->structure_table_length)) {
+ if (t0_len > (0xffff - *length)) {
dprintf(1, "Insufficient space (%d bytes) to add SMBIOS type 0 table (%d bytes)\n",
- 0xffff - ep->structure_table_length, t0_len);
+ 0xffff - *length, t0_len);
need_t0 = 0;
} else {
- ep->structure_table_length += t0_len;
- if (t0_len > ep->max_structure_size)
- ep->max_structure_size = t0_len;
- ep->number_of_structures++;
+ *length += t0_len;
+ if (t0_len > *max_structure_size)
+ *max_structure_size = t0_len;
+ (*number_of_structures)++;
}
}
/* allocate final blob and record its address in the entry point */
- if (ep->structure_table_length > BUILD_MAX_SMBIOS_FSEG)
- tables = malloc_high(ep->structure_table_length);
+ if (*length > BUILD_MAX_SMBIOS_FSEG)
+ tables = malloc_high(*length);
else
- tables = malloc_fseg(ep->structure_table_length);
+ tables = malloc_fseg(*length);
if (!tables) {
warn_noalloc();
free(qtables);
return 0;
}
- ep->structure_table_address = (u32)tables;
+ *address = (u32)tables;
/* populate final blob */
if (need_t0)
@@ -533,7 +535,11 @@ smbios_romfile_setup(void)
f_anchor->copy(f_anchor, &ep, f_anchor->size);
- if (!smbios_build_tables(f_tables, &ep))
+ if (!smbios_build_tables(f_tables,
+ &ep.structure_table_address,
+ &ep.structure_table_length,
+ &ep.max_structure_size,
+ &ep.number_of_structures))
return 0;
/* finalize entry point */