diff --git a/arch.mk b/arch.mk index 14761be0..cd0820ac 100644 --- a/arch.mk +++ b/arch.mk @@ -519,7 +519,7 @@ ifeq ("${FSP}", "1") OBJS+=src/x86/tgl_fsp.o OBJS+=src/fsp_tgl_s_upd.o OBJS+=src/ucode0.o - OBJS+=$(MATH_OBJS) + OBJS += hal/x86_fsp_tgl_loader.o CFLAGS += -DUCODE0_ADDRESS=$(UCODE0_BASE) endif ifeq ($(TARGET),x86_fsp_qemu) diff --git a/config/examples/kontron_vx3060_s2.config b/config/examples/kontron_vx3060_s2.config index d86e9352..ad4ee547 100644 --- a/config/examples/kontron_vx3060_s2.config +++ b/config/examples/kontron_vx3060_s2.config @@ -21,11 +21,11 @@ WOLFBOOT_LOAD_ADDRESS=0x1000000 WOLFBOOT_SECTOR_SIZE?=0x1000 WOLFBOOT_DATA_ADDRESS=0x1000000 -FSP_M_BASE=0xffe37000 +FSP_M_BASE=0xffc33000 FSP_S_BASE=0xffed6000 FSP_T_BASE=0xfffe0000 -WOLFBOOT_ORIGIN=0xffff0000 +WOLFBOOT_ORIGIN=0xfffa0000 # 4 MB BOOTLOADER_PARTITION_SIZE=0x400000 # 12 MB @@ -51,9 +51,14 @@ FSP_S_UPD_DATA_BASE=0xffe35000 PCI_USE_ECAM=1 PCH_HAS_PCR=1 -WOLFTPM=1 +WOLFTPM=0 64BIT=1 ELF=1 DEBUG_ELF=0 MULTIBOOT2=1 64BIT=1 + +STAGE1_AUTH=1 +FSP_M_LOAD_BASE=0x0FE2FF00 +FSP_S_LOAD_BASE=0x0FED5F00 + diff --git a/config/examples/x86_fsp_qemu_stage1_auth.config b/config/examples/x86_fsp_qemu_stage1_auth.config new file mode 100644 index 00000000..eea46c40 --- /dev/null +++ b/config/examples/x86_fsp_qemu_stage1_auth.config @@ -0,0 +1,44 @@ +ARCH=x86_64 +TARGET=x86_fsp_qemu +WOLFBOOT_SMALL_STACK=1 +SIGN?=ECC256 +HASH?=SHA256 +DEBUG=1 +SPMATH=1 +FORCE_32BIT=1 +ENCRYPTION=0 +WOLFBOOT_FIXED_PARTITIONS=1 +WOLFBOOT_PARTITION_SIZE=0x8000000 +WOLFTPM=0 + +# TPM Keystore options +#WOLFBOOT_TPM_KEYSTORE?=1 +#WOLFBOOT_TPM_KEYSTORE_NV_INDEX?=0x01800200 +#WOLFBOOT_TPM_POLICY_NV_INDEX?=0x01800201 + +# 4gb - 8mb +WOLFBOOT_PARTITION_BOOT_ADDRESS=0xff800000 +WOLFBOOT_PARTITION_SWAP_ADDRESS=0x0 +WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x0 +WOLFBOOT_LOAD_BASE=0x2000000 +WOLFBOOT_LOAD_ADDRESS=0x1000000 + +# required for keytools +WOLFBOOT_SECTOR_SIZE?=0x1000 +WOLFBOOT_DATA_ADDRESS=0x1000000 + +FSP_M_BASE=0xffe30000 +FSP_S_BASE=0xffed6000 +FSP_T_BASE=0xfffe0000 +FSP_M_LOAD_BASE=0x0FE2FF00 +FSP_S_LOAD_BASE=0x0FED5F00 +WOLFBOOT_ORIGIN=0xfffa0000 +LINUX_PAYLOAD=1 + +BOOTLOADER_PARTITION_SIZE=0xa0000 +BIOS_REGION_SIZE=0x800000 +MACHINE_OBJ=src/x86/qemu_fsp.o +FSP_T_BIN=./src/x86/fsp_t.bin +FSP_M_BIN=./src/x86/fsp_m.bin +FSP_S_BIN=./src/x86/fsp_s.bin +STAGE1_AUTH=1 diff --git a/hal/x86_fsp_tgl.c b/hal/x86_fsp_tgl.c index 1be61eff..b79d0973 100644 --- a/hal/x86_fsp_tgl.c +++ b/hal/x86_fsp_tgl.c @@ -47,3 +47,4 @@ void x86_fsp_tgl_init_sata(void) } #endif + diff --git a/hal/x86_fsp_tgl_loader.c b/hal/x86_fsp_tgl_loader.c new file mode 100644 index 00000000..b786e6d2 --- /dev/null +++ b/hal/x86_fsp_tgl_loader.c @@ -0,0 +1,95 @@ +/* x86_fsp_qemu_loader.c + * + * 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 +#include +#include +#include + +#ifdef __WOLFBOOT +#include + +extern uint8_t* _stage2_params[]; + +static void panic(void); + +void hal_init(void) +{ +} + +void hal_prepare_boot(void) +{ +} +#endif + +int hal_flash_write(uint32_t address, const uint8_t *data, int len) +{ + return 0; +} + +void hal_flash_unlock(void) +{ +} + +void hal_flash_lock(void) +{ +} + +int hal_flash_erase(uint32_t address, int len) +{ + return 0; +} + +int wolfBoot_fallback_is_possible(void) +{ + return 0; + +} + +int wolfBoot_dualboot_candidate(void) +{ + return PART_BOOT; +} + +void* hal_get_primary_address(void) +{ + return (void*)0; +} + +void* hal_get_update_address(void) +{ + return (void*)0; +} + +void *hal_get_dts_address(void) +{ + return 0; +} + +void *hal_get_dts_update_address(void) +{ + return 0; +} + +static void panic(void) +{ + while(1) {} +} diff --git a/hal/x86_fsp_tgl_stage1.ld.in b/hal/x86_fsp_tgl_stage1.ld.in index c11ebe42..dd8dd02f 100644 --- a/hal/x86_fsp_tgl_stage1.ld.in +++ b/hal/x86_fsp_tgl_stage1.ld.in @@ -1,15 +1,17 @@ FLASH_SIZE = @BOOTLOADER_PARTITION_SIZE@; FLASH_START = 0x100000000 - @BOOTLOADER_PARTITION_SIZE@; RESETVECTOR_START = 0xffffffec; +BOOTLOADER_JUMP32_START = 0xfffff000; FSP_T_BASE = @FSP_T_BASE@; /* default base:size 0xFFFFF000:0x3000 [0xfffff000:0x100002000] */ -FSP_M_BASE = @FSP_M_BASE@; /* default base:size 0xfffdd000:0x22000 [0xfffdd000:0xfffff000] */ -FSP_S_BASE = @FSP_S_BASE@; /* default base:size 0xfffc8000:0x15000 [0xfffdd000:0xfffdd000] */ +FSP_M_BASE = @FSP_M_BASE@ - 0x1000; /* default base:size 0xfffdd000:0x22000 [0xfffdd000:0xfffff000] */ +FSP_S_BASE = @FSP_S_BASE@ - 0x1000; /* default base:size 0xfffc8000:0x15000 [0xfffdd000:0xfffdd000] */ WOLFBOOT_LOAD_BASE = @WOLFBOOT_LOAD_BASE@; FIT_TABLE_PTR = 0xffffffc0; UCODE0_BASE = @UCODE0_BASE@; FSP_S_UPD_DATA_BASE = @FSP_S_UPD_DATA_BASE@; WOLFBOOT_ORIGIN = @WOLFBOOT_ORIGIN@; - +IMAGE_HEADER_SIZE = @IMAGE_HEADER_SIZE@; +PRE_HEADER_FILL_SIZE = 0x1000 - IMAGE_HEADER_SIZE; OUTPUT_FORMAT(elf32-i386) MEMORY @@ -20,6 +22,12 @@ MEMORY SECTIONS { + .jmpto32 BOOTLOADER_JUMP32_START : + { + _off_boot = ABSOLUTE(.) & 0xffff; + KEEP(*(.jmpto32)) + } + .fit_table_tr FIT_TABLE_PTR : { QUAD(fit_table); @@ -55,9 +63,11 @@ SECTIONS .text FLASH_START : { - _wolfboot_flash_start = ABSOLUTE(FLASH_START); - *(.wolfboot) - _wolfboot_flash_end = .; + . += PRE_HEADER_FILL_SIZE; + _wolfboot_flash_start = .; + KEEP(*(.sig_wolfboot_raw*)) + *(.wolfboot) + _wolfboot_flash_end = .; } .fsp_t FSP_T_BASE : @@ -69,14 +79,22 @@ SECTIONS .fsp_s FSP_S_BASE : { + . += PRE_HEADER_FILL_SIZE; + _fsp_s_hdr = .; + KEEP(*(.sig_fsp_s*)) _start_fsp_s = .; *(.fsp_s) + _end_fsp_s = .; } .fsp_m FSP_M_BASE : { + . += PRE_HEADER_FILL_SIZE; + _fsp_m_hdr = .; + KEEP(*(.sig_fsp_m*)) _start_fsp_m = .; *(.fsp_m) + _end_fsp_m = .; } } diff --git a/tools/x86_fsp/tgl/tgl_download_fsp.sh b/tools/x86_fsp/tgl/tgl_download_fsp.sh index 3d33a184..a68a9ffb 100755 --- a/tools/x86_fsp/tgl/tgl_download_fsp.sh +++ b/tools/x86_fsp/tgl/tgl_download_fsp.sh @@ -22,8 +22,8 @@ fi if [ -f "${CONFIG_FILE}" ] then FSP_T_BASE=$(grep -Eo '^FSP_T_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) - FSP_M_BASE=$(grep -Eo '^FSP_M_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) - FSP_S_BASE=$(grep -Eo '^FSP_S_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) + FSP_M_LOAD_BASE=$(grep -Eo '^FSP_M_LOAD_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) + FSP_S_LOAD_BASE=$(grep -Eo '^FSP_S_LOAD_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) else echo "Error: ${CONFIG_FILE} file not found in current directory" exit @@ -94,11 +94,11 @@ copy_tgl_fsp download_split_tool split_fsp rebase_fsp_component "T" ${FSP_T_BASE} -rebase_fsp_component "M" ${FSP_M_BASE} -rebase_fsp_component "S" ${FSP_S_BASE} +rebase_fsp_component "M" ${FSP_M_LOAD_BASE} +rebase_fsp_component "S" ${FSP_S_LOAD_BASE} copy_fsp_component "T" ${FSP_T_BASE} -copy_fsp_component "M" ${FSP_M_BASE} -copy_fsp_component "S" ${FSP_S_BASE} +copy_fsp_component "M" ${FSP_M_LOAD_BASE} +copy_fsp_component "S" ${FSP_S_LOAD_BASE} patch_tgl_fsp copy_fsp_headers download_ucode