coreboot/src/console
Nicholas Chin 090f352c2c console: Only add non-stub code to romstage if SEPARATE_ROMSTAGE=y
If both CONFIG_SEPARATE_ROMSTAGE and CONFIG_BOOTBLOCK_CONSOLE are not
set, compilation will fail with errors indicating redefinitions of
various console methods.

When BOOTBLOCK_CONSOLE is not set, the __CONSOLE_ENABLE__ macro in
include/console/console.h evaluates to zero when compiling the
bootblock, resulting in various console methods being defined as stubs
in the header. In a typical build with a separate bootblock and
romstage, this will not cause a conflict as the non-stub definitions
found in the console/*.c files are added conditionally to the bootblock
depending on CONFIG_BOOTBLOCK_CONSOLE.

When SEPARATE_ROMSTAGE is not set, the list of romstage objects gets
added to the bootblock. Since the console sources were unconditionally
added to romstage, the non-stub definitions were able to slip into the
bootblock, causing a redefinition of the stubs.

Avoid this by conditionally adding these sources to romstage depending
on CONFIG_SEPARATE_ROMSTAGE. If SEPARATE_ROMSTAGE is set, the non-stub
definitions are handled in the same way as they were before. If it is
not set, the union of bootblock and romstage objects will only include
the non-stub definitions based on CONFIG_BOOTBLOCK_CONSOLE, which uses
existing console/Makefile.mk rules for the bootblock.

TEST=qemu-i440fx builds successfully with all possible settings of
CONFIG_SEPARATE_ROMSTAGE and CONFIG_BOOTBLOCK_CONSOLE.

Change-Id: I59b3f0c52a4338b1573e0a647bc16cec4943fd7f
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83088
Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2024-06-16 13:47:11 +00:00
..
console.c console.c: Enable gdb support in bootblock 2023-11-07 17:23:32 +00:00
die.c console/die.c: Add <stdarg.h> 2022-10-06 17:00:04 +00:00
hw-debug_sink.adb console/hw-debug_sink: Update for fast/slow console distinction 2021-08-04 15:15:45 +00:00
hw-debug_sink.ads treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
init.c Allow to build romstage sources inside the bootblock 2023-11-09 13:20:18 +00:00
Kconfig arch to cpu: Add SPDX license headers to Kconfig files 2024-02-18 01:58:52 +00:00
Makefile.mk console: Only add non-stub code to romstage if SEPARATE_ROMSTAGE=y 2024-06-16 13:47:11 +00:00
post.c console/post.c: Sort includes 2022-10-27 15:46:39 +00:00
printk.c console/printk.c: Add <types.h> 2022-10-06 17:00:15 +00:00
vsprintf.c tree: Remove unused <string.h> 2024-05-29 10:34:08 +00:00
vtxprintf.c tree: Drop duplicated <stdarg.h> and <stdio.h> 2024-04-12 04:25:07 +00:00