util/sconfig: Extract handling of SMBIOS data

Move the code that handles devices' SMBIOS data into a helper function.

Change-Id: I4f36d6c6f26e79558d360d319d09b0b8426def0e
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57369
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Angel Pons 2021-09-03 16:55:25 +02:00 committed by Felix Held
parent 39e029768b
commit d56d2a86ed
1 changed files with 26 additions and 17 deletions

View File

@ -1108,6 +1108,29 @@ static void pass0(FILE *fil, FILE *head, struct device *ptr, struct device *next
ptr->name);
}
static void emit_smbios_data(FILE *fil, struct device *ptr)
{
fprintf(fil, "#if !DEVTREE_EARLY\n");
fprintf(fil, "#if CONFIG(GENERATE_SMBIOS_TABLES)\n");
/* SMBIOS types start at 1, if zero it hasn't been set */
if (ptr->smbios_slot_type)
fprintf(fil, "\t.smbios_slot_type = %s,\n",
ptr->smbios_slot_type);
if (ptr->smbios_slot_data_width)
fprintf(fil, "\t.smbios_slot_data_width = %s,\n",
ptr->smbios_slot_data_width);
if (ptr->smbios_slot_designation)
fprintf(fil, "\t.smbios_slot_designation = \"%s\",\n",
ptr->smbios_slot_designation);
if (ptr->smbios_slot_length)
fprintf(fil, "\t.smbios_slot_length = %s,\n",
ptr->smbios_slot_length);
fprintf(fil, "#endif\n");
fprintf(fil, "#endif\n");
}
static void emit_resources(FILE *fil, struct device *ptr)
{
if (ptr->res == NULL)
@ -1266,23 +1289,9 @@ static void pass1(FILE *fil, FILE *head, struct device *ptr, struct device *next
chip_ins->chip->name_underscore, chip_ins->id);
if (next)
fprintf(fil, "\t.next=&%s,\n", next->name);
fprintf(fil, "#if !DEVTREE_EARLY\n");
fprintf(fil, "#if CONFIG(GENERATE_SMBIOS_TABLES)\n");
/* SMBIOS types start at 1, if zero it hasn't been set */
if (ptr->smbios_slot_type)
fprintf(fil, "\t.smbios_slot_type = %s,\n",
ptr->smbios_slot_type);
if (ptr->smbios_slot_data_width)
fprintf(fil, "\t.smbios_slot_data_width = %s,\n",
ptr->smbios_slot_data_width);
if (ptr->smbios_slot_designation)
fprintf(fil, "\t.smbios_slot_designation = \"%s\",\n",
ptr->smbios_slot_designation);
if (ptr->smbios_slot_length)
fprintf(fil, "\t.smbios_slot_length = %s,\n",
ptr->smbios_slot_length);
fprintf(fil, "#endif\n");
fprintf(fil, "#endif\n");
emit_smbios_data(fil, ptr);
fprintf(fil, "};\n");
emit_resources(fil, ptr);