]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
test(tc): test for AP/RSS NV counter interface
authorlaurenw-arm <lauren.wehrmeister@arm.com>
Tue, 7 Feb 2023 19:40:05 +0000 (13:40 -0600)
committerlaurenw-arm <lauren.wehrmeister@arm.com>
Wed, 8 Mar 2023 18:05:06 +0000 (12:05 -0600)
Change in PLATFORM_TEST build flag from boolean -> string, with the
current string options being tfm-testsuite and rss-nv-counters.

To get the old behavior, i.e. where we used to use PLATFORM_TEST=1,
we now need to pass PLATFORM_TEST=tfm-testsuite.

Adding new test of the AP/RSS interface for non-volatile counters.
The test reads, increments, and reads again each 3 types of NV
counters for: CCA, secure, and non-secure firmware. Enabled by
PLATFORM_TEST=rss-nv-counters.

Change-Id: I2044cc9b2f37984697e0754c9c824eab51a11e7f
Signed-off-by: Lauren Wehrmeister <lauren.wehrmeister@arm.com>
Signed-off-by: Raef Coles <raef.coles@arm.com>
plat/arm/board/tc/include/tc_plat.h
plat/arm/board/tc/nv_counter_test.c [new file with mode: 0644]
plat/arm/board/tc/platform.mk
plat/arm/board/tc/platform_test.mk
plat/arm/board/tc/tc_bl31_setup.c

index f7ce2fe1db77f1eeb7f75b33f2e67b352b129ae9..ba1831fb3fb53f393fccb63d8fc7f4eb9aae2893 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2023, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,6 +11,7 @@ void tc_bl31_common_platform_setup(void);
 
 #ifdef PLATFORM_TEST
 void run_platform_tests(void);
+void nv_counter_test(void);
 #endif
 
 #endif /* TC_PLAT_H */
diff --git a/plat/arm/board/tc/nv_counter_test.c b/plat/arm/board/tc/nv_counter_test.c
new file mode 100644 (file)
index 0000000..76c9915
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023, ARM Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include <drivers/arm/rss_comms.h>
+#include <plat/common/platform.h>
+#include "rss_platform_api.h"
+
+#include <platform_def.h>
+
+void nv_counter_test(void)
+{
+       psa_status_t status;
+       uint32_t old_val;
+       uint32_t new_val;
+       uint32_t id;
+
+       status = rss_comms_init(PLAT_RSS_AP_SND_MHU_BASE, PLAT_RSS_AP_RCV_MHU_BASE);
+       if (status != PSA_SUCCESS) {
+               printf("Failed to initialize RSS communication channel\n");
+               plat_error_handler(-1);
+       }
+
+       for (id = 0; id < 3; id++) {
+               status = rss_platform_nv_counter_read(id, sizeof(old_val), (uint8_t *)&old_val);
+               if (status != PSA_SUCCESS) {
+                       printf("Failed during first id=(%d) rss_platform_nv_counter_read\n",
+                                      id);
+                       plat_error_handler(-1);
+               }
+
+               status = rss_platform_nv_counter_increment(id);
+               if (status != PSA_SUCCESS) {
+                       printf("Failed during id=(%d) rss_platform_nv_counter_increment\n",
+                                       id);
+                       plat_error_handler(-1);
+               }
+
+               status = rss_platform_nv_counter_read(id, sizeof(new_val), (uint8_t *)&new_val);
+               if (status != PSA_SUCCESS) {
+                       printf("Failed during second id=(%d) rss_platform_nv_counter_read\n",
+                                       id);
+                       plat_error_handler(-1);
+               }
+
+               if (old_val + 1 != new_val) {
+                       printf("Failed nv_counter_test: old_val (%d) + 1 != new_val (%d)\n",
+                                       old_val, new_val);
+                       plat_error_handler(-1);
+               }
+       }
+       printf("Passed nv_counter_test\n");
+}
index 218247769b4485944eaaa68d844a02832983fb21..05dca915e6a1024a5d68edb8b44596e4237639c1 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+# Copyright (c) 2021-2023, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -196,10 +196,30 @@ PLAT_INCLUDES             +=      -Iinclude/lib/psa
 
 endif
 
-# Add this include as first, before arm_common.mk. This is necessary because
-# arm_common.mk builds Mbed TLS, and platform_test.mk can change the list of
-# Mbed TLS files that are to be compiled (LIBMBEDTLS_SRCS).
-include plat/arm/board/tc/platform_test.mk
+ifeq (${PLATFORM_TEST},rss-nv-counters)
+    include drivers/arm/rss/rss_comms.mk
+
+    # Test code.
+    BL31_SOURCES       +=      plat/arm/board/tc/nv_counter_test.c
+
+    # Code under testing.
+    BL31_SOURCES       +=      lib/psa/rss_platform.c \
+                               drivers/arm/rss/rss_comms.c \
+                               ${RSS_COMMS_SOURCES}
+
+    PLAT_INCLUDES      +=      -Iinclude/lib/psa
+
+    $(eval $(call add_define,PLATFORM_TEST))
+else ifeq (${PLATFORM_TEST},tfm-testsuite)
+    # Add this include as first, before arm_common.mk. This is necessary
+    # because arm_common.mk builds Mbed TLS, and platform_test.mk can
+    # change the list of Mbed TLS files that are to be compiled
+    # (LIBMBEDTLS_SRCS).
+    include plat/arm/board/tc/platform_test.mk
+else ifneq (${PLATFORM_TEST},)
+    $(error "Unsupported PLATFORM_TEST value")
+endif
+
 
 include plat/arm/common/arm_common.mk
 include plat/arm/css/common/css_common.mk
index c2ee69ef52560c25e45382d67e926118ed17eb6f..5cdbb86bea57156352250b8cb5e81b035573058c 100644 (file)
@@ -1,9 +1,9 @@
-# Copyright (c) 2022, Arm Limited. All rights reserved.
+# Copyright (c) 2022-2023, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
 
-ifeq (${PLATFORM_TEST},1)
+ifeq (${PLATFORM_TEST},tfm-testsuite)
 
     # The variables need to be set to compile the platform test:
     ifeq (${TF_M_TESTS_PATH},)
index c79558de3fa937593c86a9bc036c48aa5f012046..1c1e2fb2ad59d9fdb637ef1745959d138a988968 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2022, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2023, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -52,9 +52,13 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
 void tc_bl31_common_platform_setup(void)
 {
        arm_bl31_platform_setup();
-#ifdef PLATFORM_TEST
-       run_platform_tests();
 
+#ifdef PLATFORM_TEST
+#if PLATFORM_TEST == rss-nv-counters
+       nv_counter_test();
+#elif PLATFORM_TEST == tfm-testsuite
+       run_platform_tests()
+#endif
        /* Suspend booting */
        plat_error_handler(-1);
 #endif