SPM: Add a log level to support output ERROR log
Add a log level TFM_SPM_LOG_ERROR to just enable the SPMLOG_ERRMSGVAL
and SPMLOG_ERRMSG.
Change-Id: I16de565f8059a80c197b94bf82f8020530ccbcac
Signed-off-by: Shawn Shan <Shawn.Shan@arm.com>
diff --git a/docs/design_documents/tfm_log_system_design_document.rst b/docs/design_documents/tfm_log_system_design_document.rst
index 4f88198..fe40383 100644
--- a/docs/design_documents/tfm_log_system_design_document.rst
+++ b/docs/design_documents/tfm_log_system_design_document.rst
@@ -46,11 +46,12 @@
Three log levels for SPM log system are defined:
- TFM_SPM_LOG_LEVEL_DEBUG
- - TFM_SPM_LOG_LEVEL_RELEASE
+ - TFM_SPM_LOG_LEVEL_INFO
+ - TFM_SPM_LOG_LEVEL_ERROR
- TFM_SPM_LOG_LEVEL_SILENCE
Then a macro ``TFM_SPM_LOG_LEVEL`` is defined as an indicator, it should
-be equal to one of the three log levels.
+be equal to one of the four log levels.
API Definition
--------------
@@ -97,21 +98,21 @@
Here is a table about the effective APIs with different SPM log level.
-+------------------+-------------------------+---------------------------+---------------------------+
-| | TFM_SPM_LOG_LEVEL_DEBUG | TFM_SPM_LOG_LEVEL_RELEASE | TFM_SPM_LOG_LEVEL_SILENCE |
-+==================+=========================+===========================+===========================+
-| SPMLOG_DBGMSGVAL | Yes | No | No |
-+------------------+-------------------------+---------------------------+---------------------------+
-| SPMLOG_INFMSGVAL | Yes | Yes | No |
-+------------------+-------------------------+---------------------------+---------------------------+
-| SPMLOG_ERRMSGVAL | Yes | Yes | No |
-+------------------+-------------------------+---------------------------+---------------------------+
-| SPMLOG_DBGMSG | Yes | No | No |
-+------------------+-------------------------+---------------------------+---------------------------+
-| SPMLOG_INFMSG | Yes | Yes | No |
-+------------------+-------------------------+---------------------------+---------------------------+
-| SPMLOG_ERRMSG | Yes | Yes | No |
-+------------------+-------------------------+---------------------------+---------------------------+
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
+| | TFM_SPM_LOG_LEVEL_DEBUG | TFM_SPM_LOG_LEVEL_INFO | TFM_SPM_LOG_LEVEL_ERROR | TFM_SPM_LOG_LEVEL_SILENCE |
++==================+=========================+===========================+===========================+=============================+
+| SPMLOG_DBGMSGVAL | Yes | No | No | No |
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
+| SPMLOG_INFMSGVAL | Yes | Yes | No | No |
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
+| SPMLOG_ERRMSGVAL | Yes | Yes | Yes | No |
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
+| SPMLOG_DBGMSG | Yes | No | No | No |
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
+| SPMLOG_INFMSG | Yes | Yes | No | No |
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
+| SPMLOG_ERRMSG | Yes | Yes | Yes | No |
++------------------+-------------------------+---------------------------+---------------------------+-----------------------------+
HAL API
-------
@@ -141,11 +142,12 @@
Three log levels for partition log system are defined:
- TFM_PARTITION_LOG_LEVEL_DEBUG
- - TFM_PARTITION_LOG_LEVEL_RELEASE
+ - TFM_PARTITION_LOG_LEVEL_INFO
+ - TFM_PARTITION_LOG_LEVEL_ERROR
- TFM_PARTITION_LOG_LEVEL_SILENCE
Then a macro ``TFM_PARTITION_LOG_LEVEL`` is defined as an indicator. It should
-be equal to one of the three log levels and it is an overall setting for all
+be equal to one of the four log levels and it is an overall setting for all
partitions.
Log Format
@@ -173,15 +175,15 @@
Here is a table about the effective APIs with different partition log level.
-+------------+-------------------------------+---------------------------------+---------------------------------+
-| | TFM_PARTITION_LOG_LEVEL_DEBUG | TFM_PARTITION_LOG_LEVEL_RELEASE | TFM_PARTITION_LOG_LEVEL_SILENCE |
-+============+===============================+=================================+=================================+
-| LOG_DBGFMT | Yes | No | No |
-+------------+-------------------------------+---------------------------------+---------------------------------+
-| LOG_INFFMT | Yes | Yes | No |
-+------------+-------------------------------+---------------------------------+---------------------------------+
-| LOG_ERRFMT | Yes | Yes | No |
-+------------+-------------------------------+---------------------------------+---------------------------------+
++------------+-------------------------------+---------------------------------+---------------------------------+---------------------------------+
+| | TFM_PARTITION_LOG_LEVEL_DEBUG | TFM_PARTITION_LOG_LEVEL_INFO | TFM_PARTITION_LOG_LEVEL_ERROR | TFM_PARTITION_LOG_LEVEL_SILENCE |
++============+===============================+=================================+=================================+---------------------------------+
+| LOG_DBGFMT | Yes | No | No | No |
++------------+-------------------------------+---------------------------------+---------------------------------+---------------------------------+
+| LOG_INFFMT | Yes | Yes | No | No |
++------------+-------------------------------+---------------------------------+---------------------------------+---------------------------------+
+| LOG_ERRFMT | Yes | Yes | Yes | No |
++------------+-------------------------------+---------------------------------+---------------------------------+---------------------------------+
HAL API
-------
diff --git a/secure_fw/spm/include/tfm_spm_log.h b/secure_fw/spm/include/tfm_spm_log.h
index 5a2413a..4ad749e 100644
--- a/secure_fw/spm/include/tfm_spm_log.h
+++ b/secure_fw/spm/include/tfm_spm_log.h
@@ -14,11 +14,15 @@
#include "tfm_hal_spm_logdev.h"
/* The SPM log levels */
-#define TFM_SPM_LOG_LEVEL_DEBUG 2 /* All log APIs output */
-#define TFM_SPM_LOG_LEVEL_RELEASE 1 /*
+#define TFM_SPM_LOG_LEVEL_DEBUG 3 /* All log APIs output */
+#define TFM_SPM_LOG_LEVEL_INFO 2 /*
* All log APIs output except SPMLOG_DBG
* and SPMLOG_DBGMSGVAL
*/
+#define TFM_SPM_LOG_LEVEL_ERROR 1 /*
+ * Only SPMLOG_ERRMSG and SPMLOG_ERRMSGVAL
+ * APIs output.
+ */
#define TFM_SPM_LOG_LEVEL_SILENCE 0 /* All log APIs are suppressed */
#ifndef TFM_SPM_LOG_LEVEL
@@ -38,15 +42,19 @@
#define SPMLOG_DBGMSG(msg)
#endif
-#if (TFM_SPM_LOG_LEVEL >= TFM_SPM_LOG_LEVEL_RELEASE)
+#if (TFM_SPM_LOG_LEVEL >= TFM_SPM_LOG_LEVEL_INFO)
#define SPMLOG_INFMSGVAL(msg, val) spm_log_msgval(msg, sizeof(msg), val)
-#define SPMLOG_ERRMSGVAL(msg, val) spm_log_msgval(msg, sizeof(msg), val)
#define SPMLOG_INFMSG(msg) tfm_hal_output_spm_log(msg, sizeof(msg))
-#define SPMLOG_ERRMSG(msg) tfm_hal_output_spm_log(msg, sizeof(msg))
#else
#define SPMLOG_INFMSGVAL(msg, val)
-#define SPMLOG_ERRMSGVAL(msg, val)
#define SPMLOG_INFMSG(msg)
+#endif
+
+#if (TFM_SPM_LOG_LEVEL >= TFM_SPM_LOG_LEVEL_ERROR)
+#define SPMLOG_ERRMSGVAL(msg, val) spm_log_msgval(msg, sizeof(msg), val)
+#define SPMLOG_ERRMSG(msg) tfm_hal_output_spm_log(msg, sizeof(msg))
+#else
+#define SPMLOG_ERRMSGVAL(msg, val)
#define SPMLOG_ERRMSG(msg)
#endif