diff options
author | Shawn Shan <Shawn.Shan@arm.com> | 2020-11-19 11:04:39 +0800 |
---|---|---|
committer | Shawn Shan <Shawn.Shan@arm.com> | 2021-01-15 14:47:47 +0800 |
commit | 9ea2f809eeacb14e091e258965ff994a8de523af (patch) | |
tree | 3be9199172e8805da4704b75e5edc4b7fcde191a | |
parent | 0680a58c20fef405c1e72018283190f55c81c264 (diff) | |
download | trusted-firmware-m-9ea2f809eeacb14e091e258965ff994a8de523af.tar.gz |
SPRTL: Add log level support for Secure partition
Add log level control for SP. Set the default SP log level as INFO
level.
Change-Id: I9aeaffdf0445fef8878a85ba4b678aba5762887a
Signed-off-by: Shawn Shan <Shawn.Shan@arm.com>
-rw-r--r-- | config/build_type/debug.cmake | 1 | ||||
-rw-r--r-- | config/build_type/minsizerel.cmake | 1 | ||||
-rw-r--r-- | config/build_type/release.cmake | 1 | ||||
-rw-r--r-- | config/config_default.cmake | 1 | ||||
-rw-r--r-- | secure_fw/partitions/lib/sprt/CMakeLists.txt | 5 | ||||
-rw-r--r-- | secure_fw/partitions/lib/sprt/include/tfm_sp_log.h | 36 |
6 files changed, 45 insertions, 0 deletions
diff --git a/config/build_type/debug.cmake b/config/build_type/debug.cmake index d098afb701..63abeb2759 100644 --- a/config/build_type/debug.cmake +++ b/config/build_type/debug.cmake @@ -7,3 +7,4 @@ set(MBEDCRYPTO_BUILD_TYPE relwithdebinfo CACHE STRING "Build type of Mbed Crypto library") set(TFM_SPM_LOG_LEVEL 3 CACHE STRING "Set debug SPM log level as Debug level" FORCE) +set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_DEBUG CACHE STRING "Set debug SP log level as Debug level") diff --git a/config/build_type/minsizerel.cmake b/config/build_type/minsizerel.cmake index b9bb0a3111..138021281d 100644 --- a/config/build_type/minsizerel.cmake +++ b/config/build_type/minsizerel.cmake @@ -6,3 +6,4 @@ #------------------------------------------------------------------------------- set(MCUBOOT_LOG_LEVEL "OFF" CACHE STRING "Level of logging to use for MCUboot [OFF, ERROR, WARNING, INFO, DEBUG]") +set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_SILENCE CACHE STRING "Set minsizerel SP log level as Silence level") diff --git a/config/build_type/release.cmake b/config/build_type/release.cmake index ff5139019d..4c04bee4f5 100644 --- a/config/build_type/release.cmake +++ b/config/build_type/release.cmake @@ -7,3 +7,4 @@ set(MBEDCRYPTO_BUILD_TYPE minsizerel CACHE STRING "Build type of Mbed Crypto library") set(MCUBOOT_LOG_LEVEL "OFF" CACHE STRING "Level of logging to use for MCUboot [OFF, ERROR, WARNING, INFO, DEBUG]") +set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_SILENCE CACHE STRING "Set release SP log level as Silence level") diff --git a/config/config_default.cmake b/config/config_default.cmake index d5773c3597..1388f9799b 100644 --- a/config/config_default.cmake +++ b/config/config_default.cmake @@ -27,6 +27,7 @@ set(TFM_EXTRA_MANIFEST_LIST_PATH "" CACHE PATH "Path to ext set(TFM_EXTRA_GENERATED_FILE_LIST_PATH "" CACHE PATH "Path to extra generated file list. Appended to stardard TFM generated file list.") set(TFM_SPM_LOG_LEVEL 2 CACHE STRING "Set default SPM log level as INFO level") +set(TFM_PARTITION_LOG_LEVEL TFM_PARTITION_LOG_LEVEL_INFO CACHE STRING "Set default Secure Partition log level as INFO level") set(TFM_CODE_SHARING OFF CACHE PATH "Enable code sharing between MCUboot and secure firmware") set(TFM_CODE_SHARING_PATH "" CACHE PATH "Path to repo which shares code with secure firmware") diff --git a/secure_fw/partitions/lib/sprt/CMakeLists.txt b/secure_fw/partitions/lib/sprt/CMakeLists.txt index 2e78e6a46e..3f9508de83 100644 --- a/secure_fw/partitions/lib/sprt/CMakeLists.txt +++ b/secure_fw/partitions/lib/sprt/CMakeLists.txt @@ -31,3 +31,8 @@ target_link_libraries(tfm_sprt tfm_boot_status tfm_secure_api ) + +target_compile_definitions(tfm_partition_defs + INTERFACE + TFM_PARTITION_LOG_LEVEL=${TFM_PARTITION_LOG_LEVEL} +) diff --git a/secure_fw/partitions/lib/sprt/include/tfm_sp_log.h b/secure_fw/partitions/lib/sprt/include/tfm_sp_log.h index dfdd98125e..d4e2579dbe 100644 --- a/secure_fw/partitions/lib/sprt/include/tfm_sp_log.h +++ b/secure_fw/partitions/lib/sprt/include/tfm_sp_log.h @@ -12,7 +12,43 @@ extern "C" { #endif +/* The Secure Partition log levels */ +#define TFM_PARTITION_LOG_LEVEL_DEBUG 3 /* All log APIs output */ +#define TFM_PARTITION_LOG_LEVEL_INFO 2 /* + * All log APIs output except + * LOG_DBGFMT + */ +#define TFM_PARTITION_LOG_LEVEL_ERROR 1 /* + * Only LOG_ERRFMT APIs output. + */ +#define TFM_PARTITION_LOG_LEVEL_SILENCE 0 /* All log APIs are suppressed */ + +#ifndef TFM_PARTITION_LOG_LEVEL +#error "TFM_PARTITION_LOG_LEVEL not defined!" +#endif + +#if (TFM_PARTITION_LOG_LEVEL > TFM_PARTITION_LOG_LEVEL_DEBUG || \ + TFM_PARTITION_LOG_LEVEL < TFM_PARTITION_LOG_LEVEL_SILENCE) +#error "Incorrect TFM_PARTITION_LOG_LEVEL value!" +#endif + +#if (TFM_PARTITION_LOG_LEVEL == TFM_PARTITION_LOG_LEVEL_DEBUG) +#define LOG_DBGFMT(...) tfm_sp_log_printf(__VA_ARGS__) +#else +#define LOG_DBGFMT(...) +#endif + +#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_INFO) #define LOG_INFFMT(...) tfm_sp_log_printf(__VA_ARGS__) +#else +#define LOG_INFFMT(...) +#endif + +#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_ERROR) +#define LOG_ERRFMT(...) tfm_sp_log_printf(__VA_ARGS__) +#else +#define LOG_ERRFMT(...) +#endif /** * \brief Print log messages |