From 9900c4f0b041cb0ac1c958500453a803beda3c8c Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 24 Nov 2020 18:02:39 +0100 Subject: soc/amd: move vboot bootblock functions to common folder Change-Id: I9e9fed26a686b8f90797687dd720902be48dae72 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/47975 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/soc/amd/common/vboot/Makefile.inc | 2 + src/soc/amd/common/vboot/vboot_bootblock.c | 53 +++++++++++++++++++++++++ src/soc/amd/picasso/Makefile.inc | 1 - src/soc/amd/picasso/bootblock/vboot_bootblock.c | 53 ------------------------- 4 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 src/soc/amd/common/vboot/vboot_bootblock.c delete mode 100644 src/soc/amd/picasso/bootblock/vboot_bootblock.c (limited to 'src') diff --git a/src/soc/amd/common/vboot/Makefile.inc b/src/soc/amd/common/vboot/Makefile.inc index aff927a5d0..8a6f1162f8 100644 --- a/src/soc/amd/common/vboot/Makefile.inc +++ b/src/soc/amd/common/vboot/Makefile.inc @@ -4,3 +4,5 @@ verstage-y += vbnv_cmos.c romstage-y += vbnv_cmos.c ramstage-y += vbnv_cmos.c endif + +bootblock-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += vboot_bootblock.c diff --git a/src/soc/amd/common/vboot/vboot_bootblock.c b/src/soc/amd/common/vboot/vboot_bootblock.c new file mode 100644 index 0000000000..3fbc4ef608 --- /dev/null +++ b/src/soc/amd/common/vboot/vboot_bootblock.c @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include +#include +#include +#include <2struct.h> + +void verify_psp_transfer_buf(void) +{ + if (*(uint32_t *)_vboot2_work == VB2_SHARED_DATA_MAGIC) { + cmos_write(0x00, CMOS_RECOVERY_BYTE); + return; + } + + /* + * If CMOS is valid and the system has already been rebooted once, but + * still returns here, instead of rebooting to verstage again, assume + * that the system is in a reboot loop and halt. + */ + if ((!vbnv_cmos_failed()) && cmos_read(CMOS_RECOVERY_BYTE) == + CMOS_RECOVERY_MAGIC_VAL) + die("Error: Reboot into recovery was unsuccessful. Halting."); + + printk(BIOS_ERR, "ERROR: VBOOT workbuf not valid.\n"); + printk(BIOS_DEBUG, "Signature: %#08x\n", *(uint32_t *)_vboot2_work); + cmos_init(0); + cmos_write(CMOS_RECOVERY_MAGIC_VAL, CMOS_RECOVERY_BYTE); + warm_reset(); +} + +void show_psp_transfer_info(void) +{ + struct transfer_info_struct *info = (struct transfer_info_struct *) + (void *)(uintptr_t)_transfer_buffer; + + if (info->magic_val == TRANSFER_MAGIC_VAL) { + if ((info->psp_info & PSP_INFO_VALID) == 0) { + printk(BIOS_INFO, "No PSP info found in transfer buffer.\n"); + return; + } + + printk(BIOS_INFO, "PSP boot mode: %s\n", + info->psp_info & PSP_INFO_PRODUCTION_MODE ? + "Production" : "Development"); + printk(BIOS_INFO, "Silicon level: %s\n", + info->psp_info & PSP_INFO_PRODUCTION_SILICON ? + "Production" : "Pre-Production"); + } +} diff --git a/src/soc/amd/picasso/Makefile.inc b/src/soc/amd/picasso/Makefile.inc index 5f4ab9bddb..f010c7b055 100644 --- a/src/soc/amd/picasso/Makefile.inc +++ b/src/soc/amd/picasso/Makefile.inc @@ -23,7 +23,6 @@ bootblock-y += gpio.c bootblock-y += smi_util.c bootblock-y += config.c bootblock-y += reset.c -bootblock-$(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK) += bootblock/vboot_bootblock.c romstage-y += i2c.c romstage-y += romstage.c diff --git a/src/soc/amd/picasso/bootblock/vboot_bootblock.c b/src/soc/amd/picasso/bootblock/vboot_bootblock.c deleted file mode 100644 index 3fbc4ef608..0000000000 --- a/src/soc/amd/picasso/bootblock/vboot_bootblock.c +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include -#include -#include -#include -#include -#include <2struct.h> - -void verify_psp_transfer_buf(void) -{ - if (*(uint32_t *)_vboot2_work == VB2_SHARED_DATA_MAGIC) { - cmos_write(0x00, CMOS_RECOVERY_BYTE); - return; - } - - /* - * If CMOS is valid and the system has already been rebooted once, but - * still returns here, instead of rebooting to verstage again, assume - * that the system is in a reboot loop and halt. - */ - if ((!vbnv_cmos_failed()) && cmos_read(CMOS_RECOVERY_BYTE) == - CMOS_RECOVERY_MAGIC_VAL) - die("Error: Reboot into recovery was unsuccessful. Halting."); - - printk(BIOS_ERR, "ERROR: VBOOT workbuf not valid.\n"); - printk(BIOS_DEBUG, "Signature: %#08x\n", *(uint32_t *)_vboot2_work); - cmos_init(0); - cmos_write(CMOS_RECOVERY_MAGIC_VAL, CMOS_RECOVERY_BYTE); - warm_reset(); -} - -void show_psp_transfer_info(void) -{ - struct transfer_info_struct *info = (struct transfer_info_struct *) - (void *)(uintptr_t)_transfer_buffer; - - if (info->magic_val == TRANSFER_MAGIC_VAL) { - if ((info->psp_info & PSP_INFO_VALID) == 0) { - printk(BIOS_INFO, "No PSP info found in transfer buffer.\n"); - return; - } - - printk(BIOS_INFO, "PSP boot mode: %s\n", - info->psp_info & PSP_INFO_PRODUCTION_MODE ? - "Production" : "Development"); - printk(BIOS_INFO, "Silicon level: %s\n", - info->psp_info & PSP_INFO_PRODUCTION_SILICON ? - "Production" : "Pre-Production"); - } -} -- cgit v1.2.3