From fd457e51a7de1e2122e4b0610d8a1729e3151efa Mon Sep 17 00:00:00 2001 From: Marco Oliverio Date: Wed, 25 Oct 2023 14:47:01 +0000 Subject: [PATCH] x86: fsp: move stage1 to stage2 related function in a separate file --- arch.mk | 1 + src/boot_x86_fsp_payload.c | 24 -------------------- src/stage1.c | 45 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 src/stage1.c diff --git a/arch.mk b/arch.mk index e67b871f..76b7f0e7 100644 --- a/arch.mk +++ b/arch.mk @@ -733,6 +733,7 @@ ifeq ("${FSP}", "1") OBJS += src/x86/ata.o OBJS += src/x86/gpt.o OBJS += src/x86/mptable.o + OBJS += src/stage1.o UPDATE_OBJS := src/update_disk.o ifeq ($(64BIT),1) LDFLAGS += -m elf_x86_64 --oformat elf64-x86-64 diff --git a/src/boot_x86_fsp_payload.c b/src/boot_x86_fsp_payload.c index 0e81dcaf..bd3e60ba 100644 --- a/src/boot_x86_fsp_payload.c +++ b/src/boot_x86_fsp_payload.c @@ -70,10 +70,6 @@ static char *cmdline = "console=ttyS0,115200 pci=earlydump debug"; static char *cmdline = "auto"; #endif /* TARGET_kontron_vx3060_s2 */ -/* must be global so the linker will export the symbol. It's used from loader 1 - * to fill the parameters */ -struct stage2_parameter _stage2_params; - /** * @brief Jump to the specified entry point. * @@ -89,26 +85,6 @@ void jump(uintptr_t entry) : "g"(entry)); } -struct stage2_parameter *stage2_get_parameters() -{ - return &_stage2_params; -} - -#if defined(WOLFBOOT_TPM_SEAL) -int stage2_get_tpm_policy(const uint8_t **policy, uint16_t *policy_sz) -{ -#if defined(WOLFBOOT_FSP) && !defined(BUILD_LOADER_STAGE1) - struct stage2_parameter *p; - p = stage2_get_parameters(); - *policy = (const uint8_t*)(uintptr_t)p->tpm_policy; - *policy_sz = p->tpm_policy_size; - return 0; -#else -#error "wolfBoot_get_tpm_policy is not implemented" -#endif -} -#endif /* WOLFBOOT_TPM_SEAL */ - /** * @brief Perform the boot process for the given application. * diff --git a/src/stage1.c b/src/stage1.c new file mode 100644 index 00000000..d3180249 --- /dev/null +++ b/src/stage1.c @@ -0,0 +1,45 @@ +/* stage1.h + * + * Copyright (C) 2023 wolfSSL Inc. + * + * This file is part of wolfBoot. + * + * wolfBoot is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfBoot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ +#include + +/* must be global so the linker will export the symbol. It's used from loader 1 + * to fill the parameters */ +struct stage2_parameter _stage2_params; + +struct stage2_parameter *stage2_get_parameters() +{ + return &_stage2_params; +} + +#if defined(WOLFBOOT_TPM_SEAL) +int stage2_get_tpm_policy(const uint8_t **policy, uint16_t *policy_sz) +{ +#if defined(WOLFBOOT_FSP) && !defined(BUILD_LOADER_STAGE1) + struct stage2_parameter *p; + p = stage2_get_parameters(); + *policy = (const uint8_t*)(uintptr_t)p->tpm_policy; + *policy_sz = p->tpm_policy_size; + return 0; +#else +#error "wolfBoot_get_tpm_policy is not implemented" +#endif +} +#endif /* WOLFBOOT_TPM_SEAL */