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>
This commit is contained in:
Kyösti Mälkki 2021-02-12 18:43:36 +02:00 committed by Patrick Georgi
parent 715cdc370c
commit 8a1fcf4754
8 changed files with 37 additions and 61 deletions

View File

@ -10,7 +10,6 @@ ramstage-$(CONFIG_PCI) += acpigen_pci.c
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

View File

@ -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;
}

View File

@ -38,8 +38,10 @@ void acpi_create_gnvs(void)
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)

View File

@ -17,7 +17,6 @@ static inline void *acpi_get_gnvs(void) { return NULL; }
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);
/*

View File

@ -29,6 +29,7 @@ void mainboard_prepare_cr50_reset(void);
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

View File

@ -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 @@ void chromeos_init_chromeos_acpi(chromeos_acpi_t *init)
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 @@ void chromeos_set_me_hash(u32 *hash, int len)
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;
}

View File

@ -42,6 +42,5 @@ typedef struct {
} __packed chromeos_acpi_t;
void chromeos_init_chromeos_acpi(chromeos_acpi_t *init);
chromeos_acpi_t *chromeos_get_chromeos_acpi(void);
#endif

View File

@ -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 @@ static void ramoops_alloc(void *arg)
}
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);