Jérémy Compostella has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/70274 )
Change subject: Add option to use Ada code in romstage ......................................................................
Add option to use Ada code in romstage
If selected, libgnat is linked into romstage. In addition, a call to romstage_adainit() is added to support Ada program data intialization.
BUG=b:252792591 BRANCH=firmware-brya-14505.B TEST=TO-BE-COMPLETED
Change-Id: I74f0460f6b14fde2b4bd6391e1782b2e5b217707 Signed-off-by: Jeremy Compostella jeremy.compostella@intel.com --- M Makefile M src/cpu/intel/car/romstage.c M src/include/adainit.h M src/lib/Kconfig M src/lib/Makefile.inc M src/lib/gnat/Makefile.inc 6 files changed, 48 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/70274/1
diff --git a/Makefile b/Makefile index 58cd85b..d09032d 100644 --- a/Makefile +++ b/Makefile @@ -315,6 +315,9 @@ ifeq ($(CONFIG_RAMSTAGE_ADA),y) ramstage-srcs += $(obj)/ramstage/$(notdir $(KCONFIG_AUTOADS)) endif +ifeq ($(CONFIG_ROMSTAGE_ADA),y) +romstage-srcs += $(obj)/romstage/$(notdir $(KCONFIG_AUTOADS)) +endif
# To track dependencies, we need all Ada specification (.ads) files in # *-srcs. Extract / filter all specification files that have a matching diff --git a/src/cpu/intel/car/romstage.c b/src/cpu/intel/car/romstage.c index c7c218b..7df512d 100644 --- a/src/cpu/intel/car/romstage.c +++ b/src/cpu/intel/car/romstage.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <adainit.h> #include <arch/romstage.h> #include <arch/symbols.h> #include <commonlib/helpers.h> @@ -40,6 +41,18 @@ if (CONFIG(VBOOT_EARLY_EC_SYNC)) vboot_sync_ec();
+ /* + * We can generally jump between C and Ada code back and forth + * without trouble. But since we don't have an Ada main() we + * have to do some Ada package initializations that GNAT would + * do there. This has to be done before calling any Ada code. + * + * The package initializations should not have any dependen- + * cies on C code. So we can call them here early, and don't + * have to worry at which point we can start to use Ada. + */ + romstage_adainit(); + mainboard_romstage_entry();
/* Check the stack. */ diff --git a/src/include/adainit.h b/src/include/adainit.h index 4953d44..389499e 100644 --- a/src/include/adainit.h +++ b/src/include/adainit.h @@ -21,4 +21,10 @@ static inline void ramstage_adainit(void) {} #endif
+#if CONFIG(ROMSTAGE_ADA) +void romstage_adainit(void); +#else +static inline void romstage_adainit(void) {} +#endif + #endif /* _ADAINIT_H */ diff --git a/src/lib/Kconfig b/src/lib/Kconfig index ae96fc6..96181c9 100644 --- a/src/lib/Kconfig +++ b/src/lib/Kconfig @@ -10,6 +10,11 @@ help Selected by features that use Ada code in ramstage.
+config ROMSTAGE_ADA + bool + help + Selected by features that use Ada code in romstage. + config RAMSTAGE_LIBHWBASE bool select RAMSTAGE_ADA diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 1c7bc22..600c6dc 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -340,6 +340,7 @@ $(RMODTOOL) -i $< -o $@
ramstage-$(CONFIG_RAMSTAGE_ADA) += cb.ads +romstage-$(CONFIG_ROMSTAGE_ADA) += cb.ads
ifeq ($(CONFIG_RAMSTAGE_LIBHWBASE),y)
diff --git a/src/lib/gnat/Makefile.inc b/src/lib/gnat/Makefile.inc index 065ba71..0dd642d 100644 --- a/src/lib/gnat/Makefile.inc +++ b/src/lib/gnat/Makefile.inc @@ -54,3 +54,6 @@ ifeq ($(CONFIG_RAMSTAGE_ADA),y) ramstage-libs += $(obj)/libgnat-$(ARCH-ramstage-y)/libgnat.a endif +ifeq ($(CONFIG_ROMSTAGE_ADA),y) +romstage-libs += $(obj)/libgnat-$(ARCH-romstage-y)/libgnat.a +endif