From 35cb6b05f9ef5b50df37c0a3c543028292f82c43 Mon Sep 17 00:00:00 2001 From: Alvin Chang Date: Wed, 28 Feb 2024 21:17:09 +0800 Subject: [PATCH] [Review] drivers: Implement semihosting based console driver for log Add #ifdef guard for semihosting_console_init() to avoid potential link error when CFG_SEMIHOSTING_CONSOLE is not enabled. Add checking on CFG_SEMIHOSTING_CONSOLE_FILE. Signed-off-by: Alvin Chang --- core/include/drivers/semihosting_console.h | 6 ++++++ mk/config.mk | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/include/drivers/semihosting_console.h b/core/include/drivers/semihosting_console.h index b4f835ca35c..93cc7264253 100644 --- a/core/include/drivers/semihosting_console.h +++ b/core/include/drivers/semihosting_console.h @@ -5,6 +5,7 @@ #ifndef __DRIVERS_SEMIHOSTING_CONSOLE_H #define __DRIVERS_SEMIHOSTING_CONSOLE_H +#ifdef CFG_SEMIHOSTING_CONSOLE /* * Initialize console which uses architecture-specific semihosting mechanism. * If @file_path is not NULL, OP-TEE OS will try to output log to that file, @@ -13,5 +14,10 @@ * semihosting host debug console. */ void semihosting_console_init(const char *file_path); +#else +static inline void semihosting_console_init(const char *file_path __unused) +{ +} +#endif #endif /* __DRIVERS_SEMIHOSTING_CONSOLE_H */ diff --git a/mk/config.mk b/mk/config.mk index b97cf4ad661..5d591c7b96b 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -1166,12 +1166,15 @@ CFG_SEMIHOSTING ?= n # Enable the semihosting console driver which inputs/outputs the characters # from/to the file or debug terminal on the semihosting host computer. -# - Specify CFG_SEMIHOSTING_CONSOLE_FILE="{your_log_file}" to output the -# characters to that file. Output to "optee.log" by default. -# - Specify CFG_SEMIHOSTING_CONSOLE_FILE=NULL to output the characters to the -# semihosting host terminal. +# - Specify CFG_SEMIHOSTING_CONSOLE_FILE="{your_log_file}" to output the +# characters to that file. Output to "optee.log" by default. +# - Specify CFG_SEMIHOSTING_CONSOLE_FILE=NULL to output the characters to the +# semihosting host terminal. CFG_SEMIHOSTING_CONSOLE ?= n ifeq ($(CFG_SEMIHOSTING_CONSOLE),y) $(call force,CFG_SEMIHOSTING,y) endif CFG_SEMIHOSTING_CONSOLE_FILE ?= "optee.log" +ifeq ($(CFG_SEMIHOSTING_CONSOLE_FILE),) +$(error CFG_SEMIHOSTING_CONSOLE_FILE cannot be empty) +endif