diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-11-13 12:56:30 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-11-18 12:50:42 +0100 |
commit | e851a685ef9d6280982465b319971e4252859227 (patch) | |
tree | 0d8549972238990591ad22bf5f8e0e5b5e3cc2da /src/mainboard/emulation/qemu-i440fx/fw_cfg.c | |
parent | 06262743c76102083287f5085380138164117bc7 (diff) |
qemu: set smbios entries from fw_cfg
Qemu makes the guest uuid (qemu -uuid $uuid) available
to the guest via fw_cfg. Other smbios fields can be
configured in qemu using the -smbios command line
switch (check the qemu manpage for details).
This patch adds coreboot support for this, so the
values provided by qemu will actually show up in the
smbios table.
Change-Id: Ifd9ae0d02749af4e7070a65eadbd1a9585a8a8e6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-on: http://review.coreboot.org/4086
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/mainboard/emulation/qemu-i440fx/fw_cfg.c')
-rw-r--r-- | src/mainboard/emulation/qemu-i440fx/fw_cfg.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c b/src/mainboard/emulation/qemu-i440fx/fw_cfg.c index 615aa2be3b..085f2a9ad4 100644 --- a/src/mainboard/emulation/qemu-i440fx/fw_cfg.c +++ b/src/mainboard/emulation/qemu-i440fx/fw_cfg.c @@ -17,6 +17,7 @@ #include <string.h> #include <swab.h> +#include <smbios.h> #include <console/console.h> #include <arch/io.h> #include <arch/acpigen.h> @@ -307,3 +308,86 @@ err: free(addrs); return 0; } + +/* ---------------------------------------------------------------------- */ +/* pick up smbios information from fw_cfg */ + +static const char *type1_manufacturer; +static const char *type1_product_name; +static const char *type1_version; +static const char *type1_serial_number; +static const char *type1_family; +static u8 type1_uuid[16]; + +static void fw_cfg_smbios_init(void) +{ + static int done = 0; + uint16_t i, count = 0; + FwCfgSmbios entry; + char *buf; + + if (done) + return; + done = 1; + + fw_cfg_get(FW_CFG_SMBIOS_ENTRIES, &count, sizeof(count)); + for (i = 0; i < count; i++) { + insb(FW_CFG_PORT_DATA, &entry, sizeof(entry)); + buf = malloc(entry.length - sizeof(entry)); + insb(FW_CFG_PORT_DATA, buf, entry.length - sizeof(entry)); + if (entry.headertype == SMBIOS_FIELD_ENTRY && + entry.tabletype == 1) { + switch (entry.fieldoffset) { + case offsetof(struct smbios_type1, manufacturer): + type1_manufacturer = strdup(buf); + break; + case offsetof(struct smbios_type1, product_name): + type1_product_name = strdup(buf); + break; + case offsetof(struct smbios_type1, version): + type1_version = strdup(buf); + break; + case offsetof(struct smbios_type1, serial_number): + type1_serial_number = strdup(buf); + break; + case offsetof(struct smbios_type1, family): + type1_family = strdup(buf); + break; + case offsetof(struct smbios_type1, uuid): + memcpy(type1_uuid, buf, 16); + break; + } + } + free(buf); + } +} + +const char *smbios_mainboard_manufacturer(void) +{ + fw_cfg_smbios_init(); + return type1_manufacturer ?: CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; +} + +const char *smbios_mainboard_product_name(void) +{ + fw_cfg_smbios_init(); + return type1_product_name ?: CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME; +} + +const char *smbios_mainboard_version(void) +{ + fw_cfg_smbios_init(); + return type1_version ?: CONFIG_MAINBOARD_VERSION; +} + +const char *smbios_mainboard_serial_number(void) +{ + fw_cfg_smbios_init(); + return type1_serial_number ?: CONFIG_MAINBOARD_SERIAL_NUMBER; +} + +void smbios_mainboard_set_uuid(u8 *uuid) +{ + fw_cfg_smbios_init(); + memcpy(uuid, type1_uuid, 16); +} |