Test: Enable CoreTest config on Muscas and AN524
Add abstraction for platform features that are used by the core tests.
This makes possible that platforms that do not support certain platform
features can mock the platform behaviour.
Detailed changes:
* Enable Core tests in MUSCA_A, MUSCA_B1 and AN524 platforms
* Add tfm_plat_test.h enumerating the test interface expected from
platform implementations by the Core Tests
* Move platform features used by Core tests to the platform directory
on MPS2 platforms
* Mock platform features used by Core tests in the platform directory
on MUSCA_A, MUSCA_B1 and AN524 platforms
* Link MT25QL device driver structure to TFM_SP_STORAGE partition so
that SST init can run in isolation level 3
Change-Id: I7385f34e364b8be330cf214b8f148affaa76613d
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index bfcdf18..8e00003 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -43,6 +43,7 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED Off)
set(BUILD_DEVICE_ID Off)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
@@ -146,7 +147,7 @@
set(SERVICE_TEST_NS ON)
if (CORE_IPC)
set(CORE_TEST_IPC ON)
- elseif (REFERENCE_PLATFORM)
+ else ()
set(CORE_TEST_POSITIVE ON)
endif()
endif()
@@ -154,7 +155,7 @@
if (CORE_TEST)
if (CORE_IPC)
set(CORE_TEST_IPC ON)
- elseif (REFERENCE_PLATFORM)
+ else()
set(CORE_TEST_POSITIVE ON)
set(CORE_TEST_INTERACTIVE OFF)
endif()
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index c05461f..b0f0de7 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -97,6 +97,7 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED Off)
set(BUILD_DEVICE_ID Off)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/bl2/ext/mcuboot/CMakeLists.txt b/bl2/ext/mcuboot/CMakeLists.txt
index 9efe032..3b4bf10 100644
--- a/bl2/ext/mcuboot/CMakeLists.txt
+++ b/bl2/ext/mcuboot/CMakeLists.txt
@@ -45,6 +45,7 @@
set(BUILD_TIME Off)
set(BUILD_UART_STDOUT On)
set(BUILD_FLASH On)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/configs/ConfigCoreIPC.cmake b/configs/ConfigCoreIPC.cmake
index 69103c6..bd1e5c3 100644
--- a/configs/ConfigCoreIPC.cmake
+++ b/configs/ConfigCoreIPC.cmake
@@ -33,7 +33,7 @@
#various project specific settings (e.g. what files to build, macro
#definitions) based on these.
set (REGRESSION False)
-set (CORE_TEST False)
+set (CORE_TEST True)
set (CORE_IPC True)
set (PSA_API_TEST False)
diff --git a/configs/ConfigCoreTest.cmake b/configs/ConfigCoreTest.cmake
index eed11d2..49f3cc3 100644
--- a/configs/ConfigCoreTest.cmake
+++ b/configs/ConfigCoreTest.cmake
@@ -19,6 +19,12 @@
set(PLATFORM_CMAKE_FILE "${TFM_ROOT_DIR}/platform/ext/Mps2AN521.cmake")
elseif(${TARGET_PLATFORM} STREQUAL "AN519")
set (PLATFORM_CMAKE_FILE "${TFM_ROOT_DIR}/platform/ext/Mps2AN519.cmake")
+elseif(${TARGET_PLATFORM} STREQUAL "AN524")
+ set (PLATFORM_CMAKE_FILE "${TFM_ROOT_DIR}/platform/ext/Mps3AN524.cmake")
+elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A")
+ set(PLATFORM_CMAKE_FILE "${TFM_ROOT_DIR}/platform/ext/musca_a.cmake")
+elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_B1")
+ set(PLATFORM_CMAKE_FILE "${TFM_ROOT_DIR}/platform/ext/musca_b1.cmake")
else()
message(FATAL_ERROR "ERROR: Target \"${TARGET_PLATFORM}\" is not supported.")
endif()
diff --git a/platform/ext/Mps2AN519.cmake b/platform/ext/Mps2AN519.cmake
index 1268299..6dcf5f9 100644
--- a/platform/ext/Mps2AN519.cmake
+++ b/platform/ext/Mps2AN519.cmake
@@ -50,6 +50,7 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/retarget" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/partition" ABSOLUTE)
+embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
#Gather all source files we need.
if (NOT DEFINED BUILD_CMSIS_CORE)
@@ -126,6 +127,12 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
endif()
+if (NOT DEFINED BUILD_PLAT_TEST)
+ message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
+elseif(BUILD_PLAT_TEST)
+ list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/plat_test.c")
+endif()
+
if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
elseif(BUILD_TARGET_HARDWARE_KEYS)
diff --git a/platform/ext/Mps2AN521.cmake b/platform/ext/Mps2AN521.cmake
index 339ebf0..90192c4 100644
--- a/platform/ext/Mps2AN521.cmake
+++ b/platform/ext/Mps2AN521.cmake
@@ -51,6 +51,7 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/retarget" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/native_drivers" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/partition" ABSOLUTE)
+embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
#Gather all source files we need.
if (NOT DEFINED BUILD_CMSIS_CORE)
@@ -127,6 +128,12 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
endif()
+if (NOT DEFINED BUILD_PLAT_TEST)
+ message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
+elseif(BUILD_PLAT_TEST)
+ list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/plat_test.c")
+endif()
+
if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
elseif(BUILD_TARGET_HARDWARE_KEYS)
diff --git a/platform/ext/Mps3AN524.cmake b/platform/ext/Mps3AN524.cmake
index 0230d2e..04d0e03 100644
--- a/platform/ext/Mps3AN524.cmake
+++ b/platform/ext/Mps3AN524.cmake
@@ -133,6 +133,12 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
endif()
+if (NOT DEFINED BUILD_PLAT_TEST)
+ message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
+elseif(BUILD_PLAT_TEST)
+ list(APPEND ALL_SRC_C_S "${AN524_DIR}/plat_test.c")
+endif()
+
if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
elseif(BUILD_TARGET_HARDWARE_KEYS)
diff --git a/platform/ext/musca_a.cmake b/platform/ext/musca_a.cmake
index 950e96b..d8db31a 100644
--- a/platform/ext/musca_a.cmake
+++ b/platform/ext/musca_a.cmake
@@ -48,6 +48,7 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/partition" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Libraries" ABSOLUTE)
+embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
#Gather all source files we need.
if (NOT DEFINED BUILD_CMSIS_CORE)
@@ -127,6 +128,12 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
endif()
+if (NOT DEFINED BUILD_PLAT_TEST)
+ message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
+elseif(BUILD_PLAT_TEST)
+ list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/plat_test.c")
+endif()
+
if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
elseif(BUILD_TARGET_HARDWARE_KEYS)
diff --git a/platform/ext/musca_b1.cmake b/platform/ext/musca_b1.cmake
index 894d731..4eb6f3b 100644
--- a/platform/ext/musca_b1.cmake
+++ b/platform/ext/musca_b1.cmake
@@ -52,6 +52,7 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_b1/Native_Driver" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_b1/partition" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_b1/services/include" ABSOLUTE)
+embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
# Gather all source files we need.
if (TFM_PARTITION_PLATFORM)
@@ -133,6 +134,12 @@
embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
endif()
+if (NOT DEFINED BUILD_PLAT_TEST)
+ message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
+elseif(BUILD_PLAT_TEST)
+ list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_b1/plat_test.c")
+endif()
+
if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
elseif (BUILD_TARGET_HARDWARE_KEYS)
diff --git a/platform/ext/target/mps2/an519/plat_test.c b/platform/ext/target/mps2/an519/plat_test.c
new file mode 100644
index 0000000..a136386
--- /dev/null
+++ b/platform/ext/target/mps2/an519/plat_test.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "platform_retarget.h"
+#include "platform_retarget_dev.h"
+#include "tfm_plat_test.h"
+
+#include "smm_mps2.h"
+
+#define USERLED_MASK (0x3)
+#define MPS2_USERPB0_BASE (0x50302008)
+#define MPS2_USERPB0_MASK (0x1)
+
+void tfm_plat_test_wait_user_button_pressed(void)
+{
+ volatile uint32_t *p_btn = (volatile uint32_t *) MPS2_USERPB0_BASE;
+
+ /* Wait until user button 0 is pressed */
+ while (!(*p_btn & MPS2_USERPB0_MASK)) {
+ ;
+ }
+}
+
+void tfm_plat_test_wait_user_button_released(void)
+{
+ volatile uint32_t *p_btn = (volatile uint32_t *) MPS2_USERPB0_BASE;
+
+ /* Wait until user button 0 is released */
+ while ((*p_btn & MPS2_USERPB0_MASK)) {
+ ;
+ }
+}
+
+uint32_t tfm_plat_test_get_led_status(void)
+{
+ struct arm_mps2_fpgaio_t *fpgaio = SEC_MPS2_FPGAIO;
+ return fpgaio->LED;
+}
+
+void tfm_plat_test_set_led_status(uint32_t status)
+{
+ struct arm_mps2_fpgaio_t *fpgaio = SEC_MPS2_FPGAIO;
+ fpgaio->LED = status;
+}
+
+uint32_t tfm_plat_test_get_userled_mask(void)
+{
+ return USERLED_MASK;
+}
+
diff --git a/platform/ext/target/mps2/an521/plat_test.c b/platform/ext/target/mps2/an521/plat_test.c
new file mode 100644
index 0000000..a136386
--- /dev/null
+++ b/platform/ext/target/mps2/an521/plat_test.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "platform_retarget.h"
+#include "platform_retarget_dev.h"
+#include "tfm_plat_test.h"
+
+#include "smm_mps2.h"
+
+#define USERLED_MASK (0x3)
+#define MPS2_USERPB0_BASE (0x50302008)
+#define MPS2_USERPB0_MASK (0x1)
+
+void tfm_plat_test_wait_user_button_pressed(void)
+{
+ volatile uint32_t *p_btn = (volatile uint32_t *) MPS2_USERPB0_BASE;
+
+ /* Wait until user button 0 is pressed */
+ while (!(*p_btn & MPS2_USERPB0_MASK)) {
+ ;
+ }
+}
+
+void tfm_plat_test_wait_user_button_released(void)
+{
+ volatile uint32_t *p_btn = (volatile uint32_t *) MPS2_USERPB0_BASE;
+
+ /* Wait until user button 0 is released */
+ while ((*p_btn & MPS2_USERPB0_MASK)) {
+ ;
+ }
+}
+
+uint32_t tfm_plat_test_get_led_status(void)
+{
+ struct arm_mps2_fpgaio_t *fpgaio = SEC_MPS2_FPGAIO;
+ return fpgaio->LED;
+}
+
+void tfm_plat_test_set_led_status(uint32_t status)
+{
+ struct arm_mps2_fpgaio_t *fpgaio = SEC_MPS2_FPGAIO;
+ fpgaio->LED = status;
+}
+
+uint32_t tfm_plat_test_get_userled_mask(void)
+{
+ return USERLED_MASK;
+}
+
diff --git a/platform/ext/target/mps3/an524/plat_test.c b/platform/ext/target/mps3/an524/plat_test.c
new file mode 100644
index 0000000..80408a9
--- /dev/null
+++ b/platform/ext/target/mps3/an524/plat_test.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "platform/include/tfm_plat_defs.h"
+#include "tfm_plat_test.h"
+
+#define USERLED_MASK (0x3)
+#define BTN_WAIT_INIT_COUNTER_VALUE (10000u)
+
+/**
+ * \brief Store the state of the mocked LED
+ *
+ * This variable have to be linked to the data section of the partition
+ * TFM_SP_CORE_TEST so that in case of in case of isolation within the secure
+ * domain the Core Test service can access it.
+ */
+uint32_t led_status
+ TFM_LINK_SET_RW_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+ = 0x02u;
+
+/**
+ * \brief Simulate user reaction time
+ */
+static void busy_wait_to_simulate_user(void)
+{
+ volatile uint32_t counter = BTN_WAIT_INIT_COUNTER_VALUE;
+ while (counter)
+ {
+ --counter;
+ }
+}
+
+void tfm_plat_test_wait_user_button_pressed(void)
+{
+ busy_wait_to_simulate_user();
+}
+
+void tfm_plat_test_wait_user_button_released(void)
+{
+ busy_wait_to_simulate_user();
+}
+
+uint32_t tfm_plat_test_get_led_status(void)
+{
+ return led_status;
+}
+
+void tfm_plat_test_set_led_status(uint32_t status)
+{
+ led_status = status & USERLED_MASK;
+}
+
+uint32_t tfm_plat_test_get_userled_mask(void)
+{
+ return USERLED_MASK;
+}
+
diff --git a/platform/ext/target/mps3/an524/tfm_peripherals_def.h b/platform/ext/target/mps3/an524/tfm_peripherals_def.h
index e56cde2..97922be 100644
--- a/platform/ext/target/mps3/an524/tfm_peripherals_def.h
+++ b/platform/ext/target/mps3/an524/tfm_peripherals_def.h
@@ -19,6 +19,7 @@
extern struct tfm_spm_partition_platform_data_t tfm_peripheral_std_uart;
#define TFM_PERIPHERAL_STD_UART (&tfm_peripheral_std_uart)
+#define TFM_PERIPHERAL_FPGA_IO (0)
#ifdef __cplusplus
}
diff --git a/platform/ext/target/musca_a/Device/Source/device_definition.c b/platform/ext/target/musca_a/Device/Source/device_definition.c
index cdafe2b..5b93b46 100644
--- a/platform/ext/target/musca_a/Device/Source/device_definition.c
+++ b/platform/ext/target/musca_a/Device/Source/device_definition.c
@@ -26,6 +26,7 @@
#include "device_cfg.h"
#include "device_definition.h"
#include "platform_base_address.h"
+#include "tfm_plat_defs.h"
/* ======= Peripheral configuration structure definitions ======= */
/* MUSCA A1 SCC driver structures */
@@ -620,7 +621,9 @@
#endif
#if (defined(MT25QL_NS) && defined(QSPI_IP6514E_NS))
-struct mt25ql_dev_t MT25QL_DEV_NS = {
+struct mt25ql_dev_t MT25QL_DEV_NS
+ TFM_LINK_SET_RW_IN_PARTITION_SECTION("TFM_SP_STORAGE")
+ = {
.controller = &QSPI_DEV_NS,
.direct_access_start_addr = MUSCA_QSPI_FLASH_NS_BASE,
.baud_rate_div = 4U,
diff --git a/platform/ext/target/musca_a/plat_test.c b/platform/ext/target/musca_a/plat_test.c
new file mode 100644
index 0000000..80408a9
--- /dev/null
+++ b/platform/ext/target/musca_a/plat_test.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "platform/include/tfm_plat_defs.h"
+#include "tfm_plat_test.h"
+
+#define USERLED_MASK (0x3)
+#define BTN_WAIT_INIT_COUNTER_VALUE (10000u)
+
+/**
+ * \brief Store the state of the mocked LED
+ *
+ * This variable have to be linked to the data section of the partition
+ * TFM_SP_CORE_TEST so that in case of in case of isolation within the secure
+ * domain the Core Test service can access it.
+ */
+uint32_t led_status
+ TFM_LINK_SET_RW_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+ = 0x02u;
+
+/**
+ * \brief Simulate user reaction time
+ */
+static void busy_wait_to_simulate_user(void)
+{
+ volatile uint32_t counter = BTN_WAIT_INIT_COUNTER_VALUE;
+ while (counter)
+ {
+ --counter;
+ }
+}
+
+void tfm_plat_test_wait_user_button_pressed(void)
+{
+ busy_wait_to_simulate_user();
+}
+
+void tfm_plat_test_wait_user_button_released(void)
+{
+ busy_wait_to_simulate_user();
+}
+
+uint32_t tfm_plat_test_get_led_status(void)
+{
+ return led_status;
+}
+
+void tfm_plat_test_set_led_status(uint32_t status)
+{
+ led_status = status & USERLED_MASK;
+}
+
+uint32_t tfm_plat_test_get_userled_mask(void)
+{
+ return USERLED_MASK;
+}
+
diff --git a/platform/ext/target/musca_a/tfm_peripherals_def.h b/platform/ext/target/musca_a/tfm_peripherals_def.h
index f47e756..872a73a 100644
--- a/platform/ext/target/musca_a/tfm_peripherals_def.h
+++ b/platform/ext/target/musca_a/tfm_peripherals_def.h
@@ -15,5 +15,6 @@
extern struct tfm_spm_partition_platform_data_t tfm_peripheral_std_uart;
#define TFM_PERIPHERAL_STD_UART (&tfm_peripheral_std_uart)
+#define TFM_PERIPHERAL_FPGA_IO (0)
#endif /* __TFM_PERIPHERALS_DEF_H__ */
diff --git a/platform/ext/target/musca_b1/plat_test.c b/platform/ext/target/musca_b1/plat_test.c
new file mode 100644
index 0000000..80408a9
--- /dev/null
+++ b/platform/ext/target/musca_b1/plat_test.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "platform/include/tfm_plat_defs.h"
+#include "tfm_plat_test.h"
+
+#define USERLED_MASK (0x3)
+#define BTN_WAIT_INIT_COUNTER_VALUE (10000u)
+
+/**
+ * \brief Store the state of the mocked LED
+ *
+ * This variable have to be linked to the data section of the partition
+ * TFM_SP_CORE_TEST so that in case of in case of isolation within the secure
+ * domain the Core Test service can access it.
+ */
+uint32_t led_status
+ TFM_LINK_SET_RW_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+ = 0x02u;
+
+/**
+ * \brief Simulate user reaction time
+ */
+static void busy_wait_to_simulate_user(void)
+{
+ volatile uint32_t counter = BTN_WAIT_INIT_COUNTER_VALUE;
+ while (counter)
+ {
+ --counter;
+ }
+}
+
+void tfm_plat_test_wait_user_button_pressed(void)
+{
+ busy_wait_to_simulate_user();
+}
+
+void tfm_plat_test_wait_user_button_released(void)
+{
+ busy_wait_to_simulate_user();
+}
+
+uint32_t tfm_plat_test_get_led_status(void)
+{
+ return led_status;
+}
+
+void tfm_plat_test_set_led_status(uint32_t status)
+{
+ led_status = status & USERLED_MASK;
+}
+
+uint32_t tfm_plat_test_get_userled_mask(void)
+{
+ return USERLED_MASK;
+}
+
diff --git a/platform/ext/target/musca_b1/tfm_peripherals_def.h b/platform/ext/target/musca_b1/tfm_peripherals_def.h
index 6663f8b..eae19a1 100644
--- a/platform/ext/target/musca_b1/tfm_peripherals_def.h
+++ b/platform/ext/target/musca_b1/tfm_peripherals_def.h
@@ -19,6 +19,7 @@
extern struct tfm_spm_partition_platform_data_t tfm_peripheral_std_uart;
#define TFM_PERIPHERAL_STD_UART (&tfm_peripheral_std_uart)
+#define TFM_PERIPHERAL_FPGA_IO (0)
#ifdef __cplusplus
}
diff --git a/platform/include/tfm_plat_test.h b/platform/include/tfm_plat_test.h
new file mode 100644
index 0000000..a71c0fc
--- /dev/null
+++ b/platform/include/tfm_plat_test.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_PLAT_TEST_H__
+#define __TFM_PLAT_TEST_H__
+
+#include "tfm_plat_defs.h"
+
+/**
+ * \brief Busy wait until the user presses a specific button
+ */
+TFM_LINK_SET_RO_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+void tfm_plat_test_wait_user_button_pressed(void);
+
+/**
+ * \brief Busy wait until the user releases a specific button
+ */
+TFM_LINK_SET_RO_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+void tfm_plat_test_wait_user_button_released(void);
+
+/**
+ * \brief Get the status of the LEDs used by tests
+ *
+ * \return Returns the current status of LEDs
+ */
+TFM_LINK_SET_RO_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+uint32_t tfm_plat_test_get_led_status(void);
+
+/**
+ * \brief Sets the status of the LEDs used by tests
+ *
+ * \param[in] status The status to be set
+ */
+TFM_LINK_SET_RO_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+void tfm_plat_test_set_led_status(uint32_t status);
+
+/**
+ * \brief Get the mask of the LEDs used for testing
+ *
+ * \return Returns the mask of the LEDs used for testing
+ */
+TFM_LINK_SET_RO_IN_PARTITION_SECTION("TFM_SP_CORE_TEST")
+uint32_t tfm_plat_test_get_userled_mask(void);
+
+#endif /* __TFM_PLAT_TEST_H__ */
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt
index 9b0909e..268355d 100644
--- a/secure_fw/CMakeLists.txt
+++ b/secure_fw/CMakeLists.txt
@@ -66,6 +66,7 @@
set(BUILD_FLASH On)
set(BUILD_BOOT_SEED On)
set(BUILD_DEVICE_ID On)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/secure_fw/core/CMakeLists.inc b/secure_fw/core/CMakeLists.inc
index 2568da2..250486f 100644
--- a/secure_fw/core/CMakeLists.inc
+++ b/secure_fw/core/CMakeLists.inc
@@ -64,6 +64,7 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED Off)
set(BUILD_DEVICE_ID Off)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/secure_fw/services/initial_attestation/CMakeLists.inc b/secure_fw/services/initial_attestation/CMakeLists.inc
index b25086a..4c00ef3 100644
--- a/secure_fw/services/initial_attestation/CMakeLists.inc
+++ b/secure_fw/services/initial_attestation/CMakeLists.inc
@@ -67,6 +67,7 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED On)
set(BUILD_DEVICE_ID On)
+ set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/secure_fw/services/secure_storage/CMakeLists.inc b/secure_fw/services/secure_storage/CMakeLists.inc
index a2a6cb8..ce1456f 100644
--- a/secure_fw/services/secure_storage/CMakeLists.inc
+++ b/secure_fw/services/secure_storage/CMakeLists.inc
@@ -131,6 +131,7 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED Off)
set(BUILD_DEVICE_ID Off)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/secure_fw/spm/CMakeLists.inc b/secure_fw/spm/CMakeLists.inc
index d1e57d8..ef9094b 100644
--- a/secure_fw/spm/CMakeLists.inc
+++ b/secure_fw/spm/CMakeLists.inc
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -51,6 +51,7 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED Off)
set(BUILD_DEVICE_ID Off)
+set(BUILD_PLAT_TEST Off)
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/test/test_services/CMakeLists.inc b/test/test_services/CMakeLists.inc
index b91ae2c..367cd83 100644
--- a/test/test_services/CMakeLists.inc
+++ b/test/test_services/CMakeLists.inc
@@ -58,6 +58,7 @@
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}/platform/include ABSOLUTE)
set(BUILD_CMSIS_CORE Off)
set(BUILD_RETARGET Off)
@@ -72,6 +73,11 @@
set(BUILD_FLASH Off)
set(BUILD_BOOT_SEED Off)
set(BUILD_DEVICE_ID On)
+if (REGRESSION OR CORE_TEST OR CORE_IPC)
+ set(BUILD_PLAT_TEST On)
+else()
+ set(BUILD_PLAT_TEST Off)
+endif()
if(NOT DEFINED PLATFORM_CMAKE_FILE)
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
diff --git a/test/test_services/tfm_core_test/tfm_ss_core_test.c b/test/test_services/tfm_core_test/tfm_ss_core_test.c
index dd6acd5..f6f3aa6 100644
--- a/test/test_services/tfm_core_test/tfm_ss_core_test.c
+++ b/test/test_services/tfm_core_test/tfm_ss_core_test.c
@@ -17,8 +17,7 @@
#include "psa_service.h"
#include "test/test_services/tfm_core_test/tfm_ss_core_test_signal.h"
#include "test/test_services/tfm_core_test_2/tfm_ss_core_test_2_signal.h"
-
-#include "smm_mps2.h"
+#include "tfm_plat_test.h"
static int32_t partition_init_done;
@@ -114,7 +113,6 @@
/* Service RW data array for testing memory accesses */
static int32_t mem[4] = {1, 2, 3, 4};
-#define MPS2_USERLED_MASK (0x3)
static psa_status_t test_mpu_access(
uint32_t *data_r_ptr, uint32_t *code_ptr, uint32_t *data_w_ptr)
@@ -220,15 +218,16 @@
static psa_status_t test_peripheral_access(void)
{
- struct arm_mps2_fpgaio_t *fpgaio = SEC_MPS2_FPGAIO;
- /* Check read access */
- uint32_t leds = fpgaio->LED;
- /* Write access */
- fpgaio->LED = ~leds;
- /* Check result of write access, only compare 2 valid bits */
- uint32_t invleds = fpgaio->LED;
+ uint32_t leds;
+ uint32_t invleds;
+ uint32_t userled_mask;
- if ((invleds & MPS2_USERLED_MASK) != (~leds & MPS2_USERLED_MASK)) {
+ leds = tfm_plat_test_get_led_status();
+ tfm_plat_test_set_led_status(~leds);
+ invleds = tfm_plat_test_get_led_status();
+ userled_mask = tfm_plat_test_get_userled_mask();
+
+ if ((invleds & userled_mask) != (~leds & userled_mask)) {
/* Code failed to invert value in peripheral reg */
return CORE_TEST_ERRNO_PERIPHERAL_ACCESS_FAILED;
}
@@ -472,29 +471,16 @@
}
#ifdef CORE_TEST_INTERACTIVE
-#define MPS2_USERPB0_BASE (0x50302008)
-#define MPS2_USERPB0_MASK (0x1)
-
static void wait_button_event(void)
{
- volatile uint32_t *p_btn = (volatile uint32_t *) MPS2_USERPB0_BASE;
- *p_btn = *p_btn;
-
- /* Wait until user button 0 is pressed */
- while (!(*p_btn & MPS2_USERPB0_MASK)) {
- ;
- }
-
+ tfm_plat_test_wait_user_button_pressed();
/*
* The follow wait is required to skip multiple continues in one go due to
* the fast execution of the code and time used by the user to
* release button.
*/
- /* Wait until user button 0 is released */
- while ((*p_btn & MPS2_USERPB0_MASK)) {
- ;
- }
+ tfm_plat_test_wait_user_button_released();
}
psa_status_t test_wait_button(void)