Allow to build romstage sources inside the bootblock

Having a separate romstage is only desirable:
 - with advanced setups like vboot or normal/fallback
 - boot medium is slow at startup (some ARM SOCs)
 - bootblock is limited in size (Intel APL 32K)

When this is not the case there is no need for the extra complexity
that romstage brings. Including the romstage sources inside the
bootblock substantially reduces the total code footprint. Often the
resulting code is 10-20k smaller.

This is controlled via a Kconfig option.

TESTED: works on qemu x86, arm and aarch64 with and without VBOOT.

Change-Id: Id68390edc1ba228b121cca89b80c64a92553e284
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55068
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Arthur Heymans
2021-05-29 08:10:49 +02:00
committed by Felix Held
parent 4ce52f622e
commit a2bc2540c2
46 changed files with 118 additions and 66 deletions

View File

@ -141,16 +141,21 @@ static inline bool cbfs_lzma_enabled(void)
return true;
if (fspm_env() && CONFIG(FSP_COMPRESS_FSP_M_LZMA))
return true;
/* We assume here romstage and postcar are never compressed. */
if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE)
/* Payload loader (ramstage) always needs LZMA. */
if (ENV_PAYLOAD_LOADER)
return true;
/* Only other use of LZMA is ramstage compression. */
if (!CONFIG(COMPRESS_RAMSTAGE_LZMA))
return false;
if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE))
return false;
if ((ENV_ROMSTAGE || ENV_POSTCAR) && !CONFIG(COMPRESS_RAMSTAGE_LZMA))
return false;
if (ENV_SMM)
return false;
return true;
/* If there is a postcar, it loads the ramstage. */
if (CONFIG(POSTCAR_STAGE))
return ENV_POSTCAR;
/* If there is no postcar but a separate romstage, it loads the ramstage. */
if (CONFIG(SEPARATE_ROMSTAGE))
return ENV_SEPARATE_ROMSTAGE;
/* Otherwise, the combined bootblock+romstage loads the ramstage. */
return ENV_BOOTBLOCK;
}
static bool cbfs_file_hash_mismatch(const void *buffer, size_t size,
@ -333,7 +338,7 @@ void cbfs_preload(const char *name)
dead_code();
/* We don't want to cross the vboot boundary */
if (ENV_ROMSTAGE && CONFIG(VBOOT_STARTS_IN_ROMSTAGE))
if (ENV_SEPARATE_ROMSTAGE && CONFIG(VBOOT_STARTS_IN_ROMSTAGE))
return;
DEBUG("%s(name='%s')\n", __func__, name);