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
commit a2bc2540c2
46 changed files with 118 additions and 66 deletions

View file

@ -10,7 +10,7 @@ void cbmemc_tx_byte(unsigned char data);
#define __CBMEM_CONSOLE_ENABLE__ (CONFIG(CONSOLE_CBMEM) && \
(ENV_RAMSTAGE || ENV_SEPARATE_VERSTAGE || ENV_POSTCAR || \
ENV_ROMSTAGE || (ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \
ENV_SEPARATE_ROMSTAGE || (ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \
(ENV_SMM && CONFIG(DEBUG_SMI))))
#if __CBMEM_CONSOLE_ENABLE__

View file

@ -44,7 +44,7 @@ static inline int get_console_loglevel(void)
#define __CONSOLE_ENABLE__ \
((ENV_BOOTBLOCK && CONFIG(BOOTBLOCK_CONSOLE)) || \
(ENV_POSTCAR && CONFIG(POSTCAR_CONSOLE)) || \
ENV_SEPARATE_VERSTAGE || ENV_ROMSTAGE || ENV_RAMSTAGE || \
ENV_SEPARATE_VERSTAGE || ENV_SEPARATE_ROMSTAGE || ENV_RAMSTAGE || \
ENV_LIBAGESA || (ENV_SMM && CONFIG(DEBUG_SMI)))
#if __CONSOLE_ENABLE__

View file

@ -9,7 +9,7 @@ void qemu_debugcon_init(void);
void qemu_debugcon_tx_byte(unsigned char data);
#if CONFIG(CONSOLE_QEMU_DEBUGCON) && \
(ENV_ROMSTAGE || ENV_RAMSTAGE || ENV_POSTCAR || ENV_BOOTBLOCK)
(ENV_SEPARATE_ROMSTAGE || ENV_RAMSTAGE || ENV_POSTCAR || ENV_BOOTBLOCK)
static inline void __qemu_debugcon_init(void) { qemu_debugcon_init(); }
static inline void __qemu_debugcon_tx_byte(u8 data)
{

View file

@ -11,7 +11,7 @@ void system76_ec_flush(void);
void system76_ec_print(uint8_t byte);
#define __CONSOLE_SYSTEM76_EC_ENABLE__ (CONFIG(CONSOLE_SYSTEM76_EC) && \
(ENV_BOOTBLOCK || ENV_ROMSTAGE || ENV_RAMSTAGE \
(ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE || ENV_RAMSTAGE \
|| ENV_SEPARATE_VERSTAGE || ENV_POSTCAR \
|| (ENV_SMM && CONFIG(DEBUG_SMI))))

View file

@ -62,7 +62,7 @@ static inline void *uart_platform_baseptr(unsigned int idx)
void oxford_remap(unsigned int new_base);
#define __CONSOLE_SERIAL_ENABLE__ (CONFIG(CONSOLE_SERIAL) && \
(ENV_BOOTBLOCK || ENV_ROMSTAGE || ENV_RAMSTAGE || ENV_SEPARATE_VERSTAGE \
(ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE || ENV_RAMSTAGE || ENV_SEPARATE_VERSTAGE \
|| ENV_POSTCAR || (ENV_SMM && CONFIG(DEBUG_SMI))))
#if __CONSOLE_SERIAL_ENABLE__

View file

@ -15,7 +15,7 @@ int usb_can_rx_byte(int idx);
#define __CONSOLE_USB_ENABLE__ (CONFIG(CONSOLE_USB) && \
((ENV_BOOTBLOCK && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
(ENV_ROMSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
(ENV_SEPARATE_ROMSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
(ENV_POSTCAR && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
(ENV_SEPARATE_VERSTAGE && CONFIG(USBDEBUG_IN_PRE_RAM)) || \
ENV_RAMSTAGE))

View file

@ -134,7 +134,7 @@
REGION(bootblock, addr, sz, 1)
#endif
#if ENV_ROMSTAGE
#if ENV_SEPARATE_ROMSTAGE
#define ROMSTAGE(addr, sz) \
SYMBOL(romstage, addr) \
_eromstage = ABSOLUTE(_romstage + sz); \

View file

@ -22,7 +22,7 @@
#if defined(__DECOMPRESSOR__)
#define ENV_DECOMPRESSOR 1
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -34,7 +34,7 @@
#elif defined(__BOOTBLOCK__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 1
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -46,7 +46,7 @@
#elif defined(__ROMSTAGE__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 1
#define ENV_SEPARATE_ROMSTAGE 1
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -58,7 +58,7 @@
#elif defined(__SMM__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 1
#define ENV_SEPARATE_VERSTAGE 0
@ -72,13 +72,13 @@
* bootblock/romstage, depending on the setting of the VBOOT_SEPARATE_VERSTAGE
* kconfig option. The ENV_SEPARATE_VERSTAGE macro will only return true for
* "verstage" code when CONFIG(VBOOT_SEPARATE_VERSTAGE) is true, otherwise that
* code will have ENV_BOOTBLOCK or ENV_ROMSTAGE set (depending on the
* code will have ENV_BOOTBLOCK or ENV_SEPARATE_ROMSTAGE set (depending on the
* "VBOOT_STARTS_IN_"... kconfig options).
*/
#elif defined(__VERSTAGE__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 1
@ -94,7 +94,7 @@
#elif defined(__RAMSTAGE__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 1
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -106,7 +106,7 @@
#elif defined(__RMODULE__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -118,7 +118,7 @@
#elif defined(__POSTCAR__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -130,7 +130,7 @@
#elif defined(__LIBAGESA__)
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -146,7 +146,7 @@
*/
#define ENV_DECOMPRESSOR 0
#define ENV_BOOTBLOCK 0
#define ENV_ROMSTAGE 0
#define ENV_SEPARATE_ROMSTAGE 0
#define ENV_RAMSTAGE 0
#define ENV_SMM 0
#define ENV_SEPARATE_VERSTAGE 0
@ -268,7 +268,7 @@
#endif
#define ENV_ROMSTAGE_OR_BEFORE \
(ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_ROMSTAGE || \
(ENV_DECOMPRESSOR || ENV_BOOTBLOCK || ENV_SEPARATE_ROMSTAGE || \
(ENV_SEPARATE_VERSTAGE && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE)))
#if ENV_X86
@ -299,9 +299,9 @@
#define ENV_INITIAL_STAGE ENV_BOOTBLOCK
#endif
#define ENV_CREATES_CBMEM ENV_ROMSTAGE
#define ENV_HAS_CBMEM (ENV_ROMSTAGE | ENV_POSTCAR | ENV_RAMSTAGE)
#define ENV_RAMINIT ENV_ROMSTAGE
#define ENV_CREATES_CBMEM (ENV_SEPARATE_ROMSTAGE || (ENV_BOOTBLOCK && !CONFIG(SEPARATE_ROMSTAGE)))
#define ENV_HAS_CBMEM (ENV_CREATES_CBMEM || ENV_POSTCAR || ENV_RAMSTAGE)
#define ENV_RAMINIT (ENV_SEPARATE_ROMSTAGE || (ENV_BOOTBLOCK && !CONFIG(SEPARATE_ROMSTAGE)))
#if ENV_X86
#define ENV_HAS_SPINLOCKS !ENV_ROMSTAGE_OR_BEFORE
@ -314,7 +314,7 @@
/* When set <arch/smp/spinlock.h> is included for the spinlock implementation. */
#define ENV_SUPPORTS_SMP (CONFIG(SMP) && ENV_HAS_SPINLOCKS)
#if ENV_X86 && CONFIG(COOP_MULTITASKING) && (ENV_RAMSTAGE || ENV_ROMSTAGE)
#if ENV_X86 && CONFIG(COOP_MULTITASKING) && (ENV_RAMSTAGE || ENV_CREATES_CBMEM)
/* TODO: Enable in all x86 stages */
#define ENV_SUPPORTS_COOP 1
#else

View file

@ -39,7 +39,7 @@ DECLARE_REGION(cbfs_mcache)
DECLARE_REGION(fmap_cache)
DECLARE_REGION(tpm_log)
#if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
#if ENV_SEPARATE_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE)
DECLARE_REGION(bss)
DECLARE_REGION(asan_shadow)
#endif

View file

@ -11,7 +11,7 @@
* timestamp_init() needs to be called once in *one* of the ENV_ROMSTAGE_OR_BEFORE
* stages (bootblock, romstage, verstage, etc). It's up to the chipset/arch
* to make the call in the earliest stage, otherwise some timestamps will be lost.
* For x86 ENV_ROMSTAGE call must be made before CAR is torn down.
* For x86 ENV_BOOTBLOCK / ENV_SEPARATE_ROMSTAGE call must be made before CAR is torn down.
*/
void timestamp_init(uint64_t base);
/*