AuditLog: Build system changes
Modify the cmake build files in order to build the
Audit logging service.
Change-Id: If93d849ba845f883f2cb8b35b8e8a50a2032ab9f
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index b3074be..8241045 100755
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -163,6 +163,9 @@
set (ENABLE_SECURE_STORAGE ON)
set (MBEDTLS_DEBUG ON)
+##TF-M audit logging
+config_setting_shared_flags(tfm_audit)
+
##Tests
config_setting_shared_flags(tfm_secure_tests)
config_setting_shared_flags(tfm_non_secure_tests)
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index c657276..691c1e1 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -38,6 +38,8 @@
"${APP_DIR}/os_wrapper_rtx.c"
"${INTERFACE_DIR}/src/tfm_sst_api.c"
"${INTERFACE_DIR}/src/tfm_sst_svc_handler.c"
+ "${INTERFACE_DIR}/src/tfm_log_api.c"
+ "${INTERFACE_DIR}/src/tfm_log_svc_handler.c"
"${INTERFACE_DIR}/src/tfm_id_mngr_dummy.c"
"${INTERFACE_DIR}/src/tfm_ns_lock_rtx.c"
)
diff --git a/interface/include/tfm_ns_svc.h b/interface/include/tfm_ns_svc.h
index b40b7c0..2102060 100644
--- a/interface/include/tfm_ns_svc.h
+++ b/interface/include/tfm_ns_svc.h
@@ -19,6 +19,7 @@
* \brief Include all the SVC handler headers
*/
#include "tfm_sst_svc_handler.h"
+#include "tfm_log_svc_handler.h"
#include "svc_core_test_ns.h"
#include "sst_test_service_svc.h"
@@ -46,7 +47,7 @@
X(SVC_TFM_SST_READ, tfm_sst_svc_read) \
X(SVC_TFM_SST_WRITE, tfm_sst_svc_write) \
X(SVC_TFM_SST_DELETE, tfm_sst_svc_delete) \
- X(SVC_TFM_LOG_RETRIEVE, NULL)
+ X(SVC_TFM_LOG_RETRIEVE, tfm_log_svc_retrieve)
/**
* \def LIST_SVC_CORE_TEST_INTERACTIVE
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index 0e6fc23..352b863 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -66,8 +66,11 @@
#Add the secure storage library target
add_subdirectory(${SECURE_FW_DIR}/services/secure_storage)
+#Add the audit logging library target
+add_subdirectory(${SECURE_FW_DIR}/services/audit_logging)
add_dependencies(${PROJECT_NAME} tfm_storage)
+add_dependencies(${PROJECT_NAME} tfm_audit)
add_dependencies(${PROJECT_NAME} tfm_secure_tests)
#Set macro definitions for the project.
@@ -77,14 +80,14 @@
#The test service veneers may not be referenced in the secure binary so the
#veneer objects are explicitly loaded from the secure tests library.
if(${COMPILER} STREQUAL "ARMCLANG")
- target_link_libraries(${PROJECT_NAME} tfm_storage $<TARGET_LINKER_FILE:tfm_secure_tests>\(*veneers.o\) tfm_secure_tests)
+ target_link_libraries(${PROJECT_NAME} tfm_storage tfm_audit $<TARGET_LINKER_FILE:tfm_secure_tests>\(*veneers.o\) tfm_secure_tests)
elseif(${COMPILER} STREQUAL "GNUARM")
- target_link_libraries(${PROJECT_NAME} -Wl,--whole-archive tfm_secure_tests -Wl,--no-whole-archive tfm_storage)
+ target_link_libraries(${PROJECT_NAME} -Wl,--whole-archive tfm_secure_tests -Wl,--no-whole-archive tfm_storage tfm_audit)
else()
message(FATAL_ERROR "unknown compiler" )
endif()
else()
- target_link_libraries(${PROJECT_NAME} tfm_storage)
+ target_link_libraries(${PROJECT_NAME} tfm_storage tfm_audit)
endif()
embedded_set_target_link_defines(TARGET ${PROJECT_NAME} DEFINES "TFM_LVL=${TFM_LVL}")
diff --git a/secure_fw/ns_callable/CMakeLists.inc b/secure_fw/ns_callable/CMakeLists.inc
index 25b6493..214bc37 100644
--- a/secure_fw/ns_callable/CMakeLists.inc
+++ b/secure_fw/ns_callable/CMakeLists.inc
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -23,7 +23,8 @@
message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
endif()
-set (SS_NS_CALLABLE_C_SRC "${CMAKE_CURRENT_LIST_DIR}/tfm_sst_veneers.c")
+set (SS_NS_CALLABLE_C_SRC "${CMAKE_CURRENT_LIST_DIR}/tfm_sst_veneers.c"
+ "${CMAKE_CURRENT_LIST_DIR}/tfm_log_veneers.c")
#Append all our source files to global lists.
list(APPEND ALL_SRC_C ${SS_NS_CALLABLE_C_SRC})
diff --git a/secure_fw/services/audit_logging/CMakeLists.inc b/secure_fw/services/audit_logging/CMakeLists.inc
new file mode 100644
index 0000000..17b1f2e
--- /dev/null
+++ b/secure_fw/services/audit_logging/CMakeLists.inc
@@ -0,0 +1,46 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2018, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#Definitions to compile the "audit_logging" module.
+#This file assumes it will be included from a project specific cmakefile, and
+#will not create a library or executable.
+#Inputs:
+# TFM_ROOT_DIR - root directory of the TF-M repository.
+#Outputs:
+# Will modify include directories to make the source compile.
+# ALL_SRC_C: C source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# ALL_SRC_CXX: C++ source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# ALL_SRC_ASM: assembly source files to be compiled will be added to this list. This shall be added to your add_executable or add_library command.
+# Include directories will be modified by using the include_directories() commands as needed.
+
+#Get the current directory where this file is located.
+set(AUDIT_LOGGING_DIR ${CMAKE_CURRENT_LIST_DIR})
+
+#Check input variables
+if (NOT DEFINED ENABLE_AUDIT_LOGGING)
+ message(FATAL_ERROR "Incomplete build configuration: ENABLE_AUDIT_LOGGING is undefined. ")
+endif()
+
+if (ENABLE_AUDIT_LOGGING)
+ if (NOT DEFINED TFM_ROOT_DIR)
+ message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
+ endif()
+
+ set (AUDIT_LOGGING_C_SRC "${AUDIT_LOGGING_DIR}/log_core.c")
+
+ #Append all our source files to global lists.
+ list(APPEND ALL_SRC_C ${AUDIT_LOGGING_C_SRC})
+ unset(AUDIT_LOGGING_C_SRC)
+
+ #Setting include directories
+ embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
+ embedded_include_directories(PATH ${TFM_ROOT_DIR}/platform/ext/common ABSOLUTE)
+
+endif()
diff --git a/secure_fw/services/audit_logging/CMakeLists.txt b/secure_fw/services/audit_logging/CMakeLists.txt
new file mode 100644
index 0000000..0c1cd2a
--- /dev/null
+++ b/secure_fw/services/audit_logging/CMakeLists.txt
@@ -0,0 +1,40 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2018, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.7)
+
+#Tell cmake where our modules can be found
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../cmake)
+
+#Include common stuff to control cmake.
+include("Common/BuildSys")
+
+#Start an embedded project.
+embedded_project_start(CONFIG "${CMAKE_CURRENT_LIST_DIR}/../../../ConfigDefault.cmake")
+project(tfm_audit LANGUAGES ASM C)
+embedded_project_fixup()
+
+###Some project global settings
+set (AUDIT_LOGGING_DIR "${CMAKE_CURRENT_LIST_DIR}")
+get_filename_component(TFM_ROOT_DIR "${AUDIT_LOGGING_DIR}/../../.." ABSOLUTE)
+
+###Get the definition of what files we need to build
+set (ENABLE_AUDIT_LOGGING ON)
+include(CMakeLists.inc)
+
+###Configure how we build our target
+if(DEFINED CORE_TEST)
+ set (TFM_LVL 3)
+else()
+ set (TFM_LVL 1)
+endif()
+
+#Specify what we build (for the audit logging service, build as a static library)
+add_library(tfm_audit STATIC ${ALL_SRC_ASM} ${ALL_SRC_C})
+embedded_set_target_compile_defines(TARGET tfm_audit LANGUAGE C DEFINES __ARM_FEATURE_CMSE=3 __thumb2__ TFM_LVL=${TFM_LVL})
+
+embedded_project_end(tfm_audit)
diff --git a/secure_fw/spm/user_partition_defines.inc b/secure_fw/spm/user_partition_defines.inc
index b2c4d8e..2680968 100644
--- a/secure_fw/spm/user_partition_defines.inc
+++ b/secure_fw/spm/user_partition_defines.inc
@@ -32,7 +32,7 @@
/******************************* TFM_SP_AUDIT_LOG *****************************/
PARTITION_DECLARE(TFM_SP_AUDIT_LOG,
SPM_PART_FLAG_SECURE | SPM_PART_FLAG_TRUSTED);
-//PARTITION_ADD_INIT_FUNC(TFM_SP_AUDIT_LOG, log_core_init);
+PARTITION_ADD_INIT_FUNC(TFM_SP_AUDIT_LOG, log_core_init);
#ifdef TFM_PARTITION_TEST_SST
/**************************** TFM_SP_SST_TEST_PARTITION ***********************/