Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/50612 )
Change subject: vc/google/chromeos: Refactor GNVS init ......................................................................
vc/google/chromeos: Refactor GNVS init
Move the support code for filling ChromeOS GNVS from acpi/chromeos-gnvs.c to vc/google/chromeos/gnvs.c.
Change-Id: I7e92206561812eb3dc69739df49b6c3a93853858 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/50612 Reviewed-by: Tim Wawrzynczak twawrzynczak@chromium.org Reviewed-by: Furquan Shaikh furquan@google.com Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Lance Zhao Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/acpi/Makefile.inc D src/acpi/chromeos-gnvs.c M src/acpi/gnvs.c M src/include/acpi/acpi_gnvs.h M src/vendorcode/google/chromeos/chromeos.h M src/vendorcode/google/chromeos/gnvs.c M src/vendorcode/google/chromeos/gnvs.h M src/vendorcode/google/chromeos/ramoops.c 8 files changed, 37 insertions(+), 61 deletions(-)
Approvals: build bot (Jenkins): Verified Furquan Shaikh: Looks good to me, approved Lance Zhao: Looks good to me, but someone else must approve Angel Pons: Looks good to me, approved Tim Wawrzynczak: Looks good to me, approved
diff --git a/src/acpi/Makefile.inc b/src/acpi/Makefile.inc index 3c3bd9e..efa7e3b 100644 --- a/src/acpi/Makefile.inc +++ b/src/acpi/Makefile.inc @@ -10,7 +10,6 @@ ramstage-y += acpigen_ps2_keybd.c ramstage-y += acpigen_usb.c ramstage-y += device.c -ramstage-$(CONFIG_CHROMEOS_NVS) += chromeos-gnvs.c ramstage-$(CONFIG_ACPI_SOC_NVS) += gnvs.c ramstage-y += pld.c ramstage-y += sata.c diff --git a/src/acpi/chromeos-gnvs.c b/src/acpi/chromeos-gnvs.c deleted file mode 100644 index 060d56d..0000000 --- a/src/acpi/chromeos-gnvs.c +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include <acpi/acpi_gnvs.h> -#include <ec/google/chromeec/ec.h> -#include <smbios.h> -#include <vendorcode/google/chromeos/gnvs.h> - -void gnvs_assign_chromeos(void *gnvs_section) -{ - chromeos_acpi_t *gnvs_chromeos = gnvs_section; - - chromeos_init_chromeos_acpi(gnvs_chromeos); - - /* EC can override to ECFW_RW. */ - gnvs_chromeos->vbt2 = ACTIVE_ECFW_RO; - - if (CONFIG(EC_GOOGLE_CHROMEEC) && !google_ec_running_ro()) - gnvs_chromeos->vbt2 = ACTIVE_ECFW_RW; -} - -void gnvs_set_ecfw_rw(void) -{ - chromeos_acpi_t *gnvs_chromeos = chromeos_get_chromeos_acpi(); - if (!gnvs_chromeos) - return; - - gnvs_chromeos->vbt2 = ACTIVE_ECFW_RW; -} - -void smbios_type0_bios_version(uintptr_t address) -{ - chromeos_acpi_t *gnvs_chromeos = chromeos_get_chromeos_acpi(); - if (!gnvs_chromeos) - return; - - /* Location of smbios_type0.bios_version() string filled with spaces. */ - gnvs_chromeos->vbt10 = address; -} diff --git a/src/acpi/gnvs.c b/src/acpi/gnvs.c index 3decebb..fc1a70d 100644 --- a/src/acpi/gnvs.c +++ b/src/acpi/gnvs.c @@ -38,8 +38,10 @@ if (CONFIG(CONSOLE_CBMEM)) gnvs->cbmc = (uintptr_t)cbmem_find(CBMEM_ID_CONSOLE);
- if (CONFIG(CHROMEOS_NVS)) - gnvs_assign_chromeos((u8 *)gnvs + GNVS_CHROMEOS_ACPI_OFFSET); + if (CONFIG(CHROMEOS_NVS)) { + chromeos_acpi_t *init = (void *)((u8 *)gnvs + GNVS_CHROMEOS_ACPI_OFFSET); + chromeos_init_chromeos_acpi(init); + } }
void *acpi_get_gnvs(void) diff --git a/src/include/acpi/acpi_gnvs.h b/src/include/acpi/acpi_gnvs.h index 86d68a4..f24f5ef 100644 --- a/src/include/acpi/acpi_gnvs.h +++ b/src/include/acpi/acpi_gnvs.h @@ -17,7 +17,6 @@ static inline int acpi_reset_gnvs_for_wake(struct global_nvs **gnvs) { return -1; } #endif
-void gnvs_assign_chromeos(void *gnvs_section); void gnvs_set_ecfw_rw(void);
/* diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h index 233078b..2b7be90 100644 --- a/src/vendorcode/google/chromeos/chromeos.h +++ b/src/vendorcode/google/chromeos/chromeos.h @@ -29,6 +29,7 @@
void cbmem_add_vpd_calibration_data(void); void chromeos_set_me_hash(u32*, int); +void chromeos_set_ramoops(void *ram_oops, size_t size);
/** * get_dsm_calibration_from_key - Gets value related to DSM calibration from VPD diff --git a/src/vendorcode/google/chromeos/gnvs.c b/src/vendorcode/google/chromeos/gnvs.c index 024dbe3..6e0e9f8 100644 --- a/src/vendorcode/google/chromeos/gnvs.c +++ b/src/vendorcode/google/chromeos/gnvs.c @@ -1,14 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <acpi/acpi_gnvs.h> #include <types.h> #include <string.h> #include <stdlib.h> #include <cbfs.h> #include <cbmem.h> #include <console/console.h> +#include <ec/google/chromeec/ec.h> #include <fmap.h> #include <security/vboot/vbnv.h> #include <security/vboot/vboot_common.h> +#include <smbios.h>
#include "chromeos.h" #include "gnvs.h" @@ -45,6 +48,12 @@ chromeos_acpi->vpd_rw_base = vpd_base; chromeos_acpi->vpd_rw_size = vpd_size; } + + /* EC can override to ECFW_RW. */ + chromeos_acpi->vbt2 = ACTIVE_ECFW_RO; + + if (CONFIG(EC_GOOGLE_CHROMEEC) && !google_ec_running_ro()) + chromeos_acpi->vbt2 = ACTIVE_ECFW_RW; }
void chromeos_set_me_hash(u32 *hash, int len) @@ -57,7 +66,27 @@ memcpy(chromeos_acpi->mehh, hash, len*sizeof(u32)); }
-chromeos_acpi_t *chromeos_get_chromeos_acpi(void) +void chromeos_set_ramoops(void *ram_oops, size_t size) { - return chromeos_acpi; + if (!chromeos_acpi) + return; + + printk(BIOS_DEBUG, "Ramoops buffer: 0x%zx@%p.\n", size, ram_oops); + chromeos_acpi->ramoops_base = (uintptr_t)ram_oops; + chromeos_acpi->ramoops_len = size; +} + +void gnvs_set_ecfw_rw(void) +{ + if (!chromeos_acpi) + return; + chromeos_acpi->vbt2 = ACTIVE_ECFW_RW; +} + +void smbios_type0_bios_version(uintptr_t address) +{ + if (!chromeos_acpi) + return; + /* Location of smbios_type0.bios_version() string filled with spaces. */ + chromeos_acpi->vbt10 = address; } diff --git a/src/vendorcode/google/chromeos/gnvs.h b/src/vendorcode/google/chromeos/gnvs.h index 3f47a33..8f8e259 100644 --- a/src/vendorcode/google/chromeos/gnvs.h +++ b/src/vendorcode/google/chromeos/gnvs.h @@ -42,6 +42,5 @@ } __packed chromeos_acpi_t;
void chromeos_init_chromeos_acpi(chromeos_acpi_t *init); -chromeos_acpi_t *chromeos_get_chromeos_acpi(void);
#endif diff --git a/src/vendorcode/google/chromeos/ramoops.c b/src/vendorcode/google/chromeos/ramoops.c index 3b658b7..1e3d7f0 100644 --- a/src/vendorcode/google/chromeos/ramoops.c +++ b/src/vendorcode/google/chromeos/ramoops.c @@ -7,22 +7,7 @@ #include <bootstate.h> #include <console/console.h> #include <cbmem.h> -#include <device/device.h> #include "chromeos.h" -#include "gnvs.h" - -static void set_ramoops(void *ram_oops, size_t size) -{ - chromeos_acpi_t *chromeos = chromeos_get_chromeos_acpi(); - if (chromeos == NULL) { - printk(BIOS_DEBUG, "chromeos gnvs is NULL. ramoops not set.\n"); - return; - } - - printk(BIOS_DEBUG, "Ramoops buffer: 0x%zx@%p.\n", size, ram_oops); - chromeos->ramoops_base = (uintptr_t)ram_oops; - chromeos->ramoops_len = size; -}
static void ramoops_alloc(void *arg) { @@ -39,7 +24,7 @@ }
if (CONFIG(CHROMEOS_NVS)) - set_ramoops(ram_oops, size); + chromeos_set_ramoops(ram_oops, size); }
BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, ramoops_alloc, NULL);