From 4421bf3c1574c7d69a4be6a0c448ed401115f3a6 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 22 Sep 2011 21:47:15 -0700 Subject: Use the vdat firmware index when setting up the ACPI crossystem data table Instead of using a hardcoded value, set this field of the table used by the crossystem ACPI driver to whatever is stored in VDAT. BUG=chrome-os-partner:5944 BUG=chrome-os-partner:5961 BUG=chrome-os-partner:5962 TEST=Booted on Alex. Verified that corrupting firmware A made crossystem change mainfw_act to B instead of A. Signed-off-by: Gabe Black Change-Id: I01b26508fede3d15e78b584b638e1393c5b03501 Reviewed-on: http://gerrit.chromium.org/gerrit/8189 Reviewed-by: Stefan Reinauer Reviewed-by: Hung-Te Lin Reviewed-by: Simon Glass Tested-by: Gabe Black Commit-Ready: Gabe Black --- lib/chromeos/crossystem_data.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'lib/chromeos/crossystem_data.c') diff --git a/lib/chromeos/crossystem_data.c b/lib/chromeos/crossystem_data.c index 3720254c868..da53a5e5b12 100644 --- a/lib/chromeos/crossystem_data.c +++ b/lib/chromeos/crossystem_data.c @@ -20,6 +20,10 @@ #include #endif +#ifdef CONFIG_X86 +#include +#endif + #define CROSSYSTEM_DATA_SIGNATURE "CHROMEOS" /* This is used to keep bootstub and readwite main firmware in sync */ @@ -27,6 +31,18 @@ #define PREFIX "crossystem_data: " +enum VdatFwIndex { + VDAT_RW_A = 0, + VDAT_RW_B = 1, + VDAT_RECOVERY = 0xFF +}; + +enum BinfFwIndex { + BINF_RECOVERY = 0, + BINF_RW_A = 1, + BINF_RW_B = 2 +}; + DECLARE_GLOBAL_DATA_PTR; int crossystem_data_init(crossystem_data_t *cdata, @@ -239,12 +255,24 @@ int crossystem_data_embed_into_fdt(crossystem_data_t *cdata, void *fdt, #endif /* ^^^^ CONFIG_OF_LIBFDT NOT defined ^^^^ */ #ifdef CONFIG_X86 + +static int crossystem_fw_index_vdat_to_binf(int index) +{ + switch (index) { + case VDAT_RW_A: return BINF_RW_A; + case VDAT_RW_B: return BINF_RW_B; + case VDAT_RECOVERY: return BINF_RECOVERY; + default: return BINF_RECOVERY; + } +}; + int crossystem_data_update_acpi(crossystem_data_t *cdata) { const void *fdt = gd->blob; int node_offset, len; const uint32_t *cell; chromeos_acpi_t *acpi_table; + VbSharedDataHeader *vdat = (VbSharedDataHeader *)lib_sysinfo.vdat_addr; node_offset = fdt_path_offset(fdt, "/chromeos-config"); if (node_offset < 0) { @@ -261,7 +289,8 @@ int crossystem_data_update_acpi(crossystem_data_t *cdata) acpi_table = (chromeos_acpi_t *)(uintptr_t)ntohl(*cell); acpi_table->vbt0 = BOOT_REASON_OTHER; - acpi_table->vbt1 = ACTIVE_MAINFW_RW_A; + acpi_table->vbt1 = + crossystem_fw_index_vdat_to_binf(vdat->firmware_index); acpi_table->vbt2 = cdata->active_ec_firmware; acpi_table->vbt3 = (cdata->boot_write_protect_switch ? CHSW_FIRMWARE_WP_DIS : 0) | -- cgit v1.2.3