From ac7242921e0ec439bc7f86d620f33bdc97e2c8b8 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 17 Aug 2021 19:10:24 +0100 Subject: [PATCH] common: Introduce weak defaults for interfaces used by common code This avoids each architecture needing to implement stubs for possibly optional functionality. Signed-off-by: Andrew Cooper --- build/files.mk | 1 + common/weak-defaults.c | 27 +++++++++++++++++++++++++++ include/xtf/framework.h | 13 ++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 common/weak-defaults.c diff --git a/build/files.mk b/build/files.mk index dfa27e4..5c1cc8d 100644 --- a/build/files.mk +++ b/build/files.mk @@ -16,6 +16,7 @@ obj-perarch += $(ROOT)/common/libc/vsnprintf.o obj-perarch += $(ROOT)/common/report.o obj-perarch += $(ROOT)/common/setup.o obj-perarch += $(ROOT)/common/xenbus.o +obj-perarch += $(ROOT)/common/weak-defaults.o obj-perenv += $(ROOT)/arch/x86/decode.o obj-perenv += $(ROOT)/arch/x86/desc.o diff --git a/common/weak-defaults.c b/common/weak-defaults.c new file mode 100644 index 0000000..74cefeb --- /dev/null +++ b/common/weak-defaults.c @@ -0,0 +1,27 @@ +/* + * @file common/weak-defaults.c + * + * Default implementations of functions called by common code, which may need + * arch or environment specific implementations. + */ +#include + +const char __weak environment_description[] = "Unknown"; + +void __weak arch_setup(void) +{ +} + +void __weak test_setup(void) +{ +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xtf/framework.h b/include/xtf/framework.h index a71bf39..4c6527e 100644 --- a/include/xtf/framework.h +++ b/include/xtf/framework.h @@ -1,8 +1,19 @@ +/** + * @file include/xtf/framework.h + * + * Interfaces used by common code, needing to be implemented by + * arch/environment specific code. Default stubs are provided in + * common/weak-defaults.c + */ #ifndef XTF_FRAMEWORK_H #define XTF_FRAMEWORK_H -/* To be implemented by each arch */ +#include + +/* Set up exception handling, consoles, etc. */ void arch_setup(void); + +/* Set up test-specific configuration. */ void test_setup(void); /* Single line summary of execution environment. */ -- 2.39.5