ChromeOS: Refactor SMBIOS type0 bios_version()

Pointer to an empty string (filled with spaces) is
stored inside GNVS. Rearrange things to avoid having
<chromeos/gnvs.h> in SMBIOS code.

Change-Id: I9405afbea29b896488b4cdd6dd32c4db686fe48c
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49281
Reviewed-by: Lance Zhao
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Kyösti Mälkki 2020-12-20 08:27:21 +02:00 committed by Patrick Georgi
parent 661ad4666c
commit 0fcbd3a125
3 changed files with 20 additions and 8 deletions

View File

@ -2,6 +2,7 @@
#include <acpi/acpi_gnvs.h> #include <acpi/acpi_gnvs.h>
#include <ec/google/chromeec/ec.h> #include <ec/google/chromeec/ec.h>
#include <smbios.h>
#include <vendorcode/google/chromeos/gnvs.h> #include <vendorcode/google/chromeos/gnvs.h>
void gnvs_assign_chromeos(void) void gnvs_assign_chromeos(void)
@ -27,3 +28,13 @@ void gnvs_set_ecfw_rw(void)
gnvs_chromeos->vbt2 = ACTIVE_ECFW_RW; gnvs_chromeos->vbt2 = ACTIVE_ECFW_RW;
} }
void smbios_type0_bios_version(uintptr_t address)
{
chromeos_acpi_t *gnvs_chromeos = gnvs_chromeos_ptr(acpi_get_gnvs());
if (!gnvs_chromeos)
return;
/* Location of smbios_type0.bios_version() string filled with spaces. */
gnvs_chromeos->vbt10 = address;
}

View File

@ -16,9 +16,6 @@
#include <device/pci_ids.h> #include <device/pci_ids.h>
#include <device/pci_def.h> #include <device/pci_def.h>
#include <device/pci.h> #include <device/pci.h>
#if CONFIG(CHROMEOS)
#include <vendorcode/google/chromeos/gnvs.h>
#endif
#include <drivers/vpd/vpd.h> #include <drivers/vpd/vpd.h>
#include <stdlib.h> #include <stdlib.h>
@ -411,11 +408,12 @@ static int smbios_write_type0(unsigned long *current, int handle)
t->vendor = smbios_add_string(t->eos, "coreboot"); t->vendor = smbios_add_string(t->eos, "coreboot");
t->bios_release_date = smbios_add_string(t->eos, coreboot_dmi_date); t->bios_release_date = smbios_add_string(t->eos, coreboot_dmi_date);
#if CONFIG(CHROMEOS) && CONFIG(HAVE_ACPI_TABLES) if (CONFIG(CHROMEOS)) {
u32 version_offset = (u32)smbios_string_table_len(t->eos); uintptr_t version_address = (uintptr_t)t->eos;
/* SMBIOS offsets start at 1 rather than 0 */ /* SMBIOS offsets start at 1 rather than 0 */
chromeos_get_chromeos_acpi()->vbt10 = (uintptr_t)t->eos + (version_offset - 1); version_address += (u32)smbios_string_table_len(t->eos) - 1;
#endif smbios_type0_bios_version(version_address);
}
t->bios_version = smbios_add_string(t->eos, get_bios_version()); t->bios_version = smbios_add_string(t->eos, get_bios_version());
uint32_t rom_size = CONFIG_ROM_SIZE; uint32_t rom_size = CONFIG_ROM_SIZE;
rom_size = MIN(CONFIG_ROM_SIZE, 16 * MiB); rom_size = MIN(CONFIG_ROM_SIZE, 16 * MiB);

View File

@ -55,6 +55,9 @@ const char *smbios_chassis_version(void);
const char *smbios_chassis_serial_number(void); const char *smbios_chassis_serial_number(void);
const char *smbios_processor_serial_number(void); const char *smbios_processor_serial_number(void);
/* This string could be filled late in payload. */
void smbios_type0_bios_version(uintptr_t address);
void smbios_ec_revision(uint8_t *ec_major_revision, uint8_t *ec_minor_revision); void smbios_ec_revision(uint8_t *ec_major_revision, uint8_t *ec_minor_revision);
unsigned int smbios_memory_error_correction_type(struct memory_info *meminfo); unsigned int smbios_memory_error_correction_type(struct memory_info *meminfo);