Skip to content

Commit

Permalink
[Review] drivers: Implement semihosting based console driver for log
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gagachang committed Feb 28, 2024
1 parent 37c6df0 commit 35cb6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions core/include/drivers/semihosting_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 */
11 changes: 7 additions & 4 deletions mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 35cb6b0

Please sign in to comment.