diff --git a/plat/arm/board/tc/include/tc_rse_comms.h b/plat/arm/board/tc/include/tc_rse_comms.h new file mode 100644 index 000000000..dc2000e5d --- /dev/null +++ b/plat/arm/board/tc/include/tc_rse_comms.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef TC_RSE_COMMS_H +#define TC_RSE_COMMS_H + +int plat_rse_comms_init(void); + +#endif /* TC_RSE_COMMS_H */ diff --git a/plat/arm/board/tc/nv_counter_test.c b/plat/arm/board/tc/nv_counter_test.c index 902556932..94cba2297 100644 --- a/plat/arm/board/tc/nv_counter_test.c +++ b/plat/arm/board/tc/nv_counter_test.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Arm Limited. All rights reserved. + * Copyright (c) 2023-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,11 +7,11 @@ #include #include -#include #include #include "rse_platform_api.h" #include +#include int nv_counter_test(void) { @@ -20,7 +20,7 @@ int nv_counter_test(void) uint32_t new_val; uint32_t id; - status = rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, PLAT_RSE_AP_RCV_MHU_BASE); + status = plat_rse_comms_init(); if (status != PSA_SUCCESS) { printf("Failed to initialize RSE communication channel - psa_status = %d\n", status); return -1; diff --git a/plat/arm/board/tc/platform.mk b/plat/arm/board/tc/platform.mk index e0c40a455..1e12a127a 100644 --- a/plat/arm/board/tc/platform.mk +++ b/plat/arm/board/tc/platform.mk @@ -249,9 +249,12 @@ $(eval $(call TOOL_ADD_PAYLOAD,${TC_HW_CONFIG},--hw-config,${TC_HW_CONFIG})) $(info Including rse_comms.mk) include drivers/arm/rse/rse_comms.mk -BL1_SOURCES += ${RSE_COMMS_SOURCES} -BL2_SOURCES += ${RSE_COMMS_SOURCES} +BL1_SOURCES += ${RSE_COMMS_SOURCES} \ + plat/arm/board/tc/tc_rse_comms.c +BL2_SOURCES += ${RSE_COMMS_SOURCES} \ + plat/arm/board/tc/tc_rse_comms.c BL31_SOURCES += ${RSE_COMMS_SOURCES} \ + plat/arm/board/tc/tc_rse_comms.c \ lib/psa/rse_platform.c # Include Measured Boot makefile before any Crypto library makefile. diff --git a/plat/arm/board/tc/platform_test.mk b/plat/arm/board/tc/platform_test.mk index 2ce664859..4afa30f38 100644 --- a/plat/arm/board/tc/platform_test.mk +++ b/plat/arm/board/tc/platform_test.mk @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, Arm Limited. All rights reserved. +# Copyright (c) 2022-2025, Arm Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -9,7 +9,8 @@ ifeq (${PLATFORM_TEST},rse-nv-counters) include drivers/arm/rse/rse_comms.mk # Test code. - BL31_SOURCES += plat/arm/board/tc/nv_counter_test.c + BL31_SOURCES += plat/arm/board/tc/nv_counter_test.c \ + plat/arm/board/tc/tc_rse_comms.c # Code under testing. BL31_SOURCES += lib/psa/rse_platform.c \ @@ -22,7 +23,8 @@ else ifeq (${PLATFORM_TEST},rse-rotpk) include drivers/arm/rse/rse_comms.mk # Test code. - BL31_SOURCES += plat/arm/board/tc/rotpk_test.c + BL31_SOURCES += plat/arm/board/tc/rotpk_test.c \ + plat/arm/board/tc/tc_rse_comms.c # Code under testing. BL31_SOURCES += lib/psa/rse_platform.c \ @@ -75,6 +77,7 @@ else ifeq (${PLATFORM_TEST},tfm-testsuite) ${TC_BASE}/rse_ap_tests.c \ ${TC_BASE}/rse_ap_testsuites.c \ ${TC_BASE}/rse_ap_test_stubs.c \ + ${TC_BASE}/tc_rse_comms.c \ $(TF_M_TESTS_PATH)/tests_reg/test/framework/test_framework.c \ $(MEASURED_BOOT_TESTS_PATH)/measured_boot_common.c \ $(MEASURED_BOOT_TESTS_PATH)/measured_boot_tests_common.c \ diff --git a/plat/arm/board/tc/rotpk_test.c b/plat/arm/board/tc/rotpk_test.c index 2178f6973..3d6c95da7 100644 --- a/plat/arm/board/tc/rotpk_test.c +++ b/plat/arm/board/tc/rotpk_test.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Arm Limited. All rights reserved. + * Copyright (c) 2023-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,10 +7,10 @@ #include #include -#include #include #include #include +#include static void print_hex(const char *key_id_name, size_t key_size, const uint8_t *key_buf) { @@ -33,9 +33,10 @@ int rotpk_test(void) {.key_id = RSE_BUILTIN_KEY_ID_HOST_CCA_ROTPK, .key_id_name = "CCA-ROTPK"} }; - status = rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, PLAT_RSE_AP_RCV_MHU_BASE); + status = plat_rse_comms_init(); if (status != PSA_SUCCESS) { - printf("Failed to initialize RSE communication channel - psa_status = %d\n", status); + printf("Failed to initialize RSE communication channel - psa_status = %d\n", + status); return -1; } @@ -43,7 +44,8 @@ int rotpk_test(void) status = rse_platform_key_read(key_ids[i].key_id, key_buf, sizeof(key_buf), &key_size); if (status != PSA_SUCCESS) { - printf("Failed to retrieve %s - psa_status = %d\n", key_ids[i].key_id_name, status); + printf("Failed to retrieve %s - psa_status = %d\n", key_ids[i].key_id_name, + status); return -1; } print_hex(key_ids[i].key_id_name, key_size, key_buf); diff --git a/plat/arm/board/tc/rse_ap_tests.c b/plat/arm/board/tc/rse_ap_tests.c index 3ca628a6c..f8ee1c5bf 100644 --- a/plat/arm/board/tc/rse_ap_tests.c +++ b/plat/arm/board/tc/rse_ap_tests.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Arm Ltd. All rights reserved. + * Copyright (c) 2022-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,9 +10,9 @@ #include #include #include -#include #include "rse_ap_testsuites.h" +#include static struct test_suite_t test_suites[] = { {.freg = register_testsuite_delegated_attest}, @@ -32,7 +32,7 @@ static int run_tests(void) size_t i; /* Initialize test environment. */ - rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, PLAT_RSE_AP_RCV_MHU_BASE); + plat_rse_comms_init(); mbedtls_init(); status = psa_crypto_init(); if (status != PSA_SUCCESS) { diff --git a/plat/arm/board/tc/tc_bl1_dpe.c b/plat/arm/board/tc/tc_bl1_dpe.c index de5702a71..62e86f95d 100644 --- a/plat/arm/board/tc/tc_bl1_dpe.c +++ b/plat/arm/board/tc/tc_bl1_dpe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Arm Limited. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -19,6 +18,7 @@ #include #include "tc_dpe.h" +#include struct dpe_metadata tc_dpe_metadata[] = { { @@ -122,8 +122,7 @@ void plat_dpe_get_context_handle(int *ctx_handle) void bl1_plat_mboot_init(void) { /* Initialize the communication channel between AP and RSE */ - (void)rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, - PLAT_RSE_AP_RCV_MHU_BASE); + (void)plat_rse_comms_init(); dpe_init(tc_dpe_metadata); } diff --git a/plat/arm/board/tc/tc_bl1_measured_boot.c b/plat/arm/board/tc/tc_bl1_measured_boot.c index 28a1e316b..b5617cc49 100644 --- a/plat/arm/board/tc/tc_bl1_measured_boot.c +++ b/plat/arm/board/tc/tc_bl1_measured_boot.c @@ -1,18 +1,18 @@ /* - * Copyright (c) 2022-2024, Arm Limited. All rights reserved. + * Copyright (c) 2022-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include -#include #include #include #include #include #include +#include /* Table with platform specific image IDs and metadata. Intentionally not a * const struct, some members might set by bootloaders during trusted boot. @@ -47,8 +47,7 @@ struct rse_mboot_metadata tc_rse_mboot_metadata[] = { void bl1_plat_mboot_init(void) { /* Initialize the communication channel between AP and RSE */ - (void)rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, - PLAT_RSE_AP_RCV_MHU_BASE); + (void)plat_rse_comms_init(); rse_measured_boot_init(tc_rse_mboot_metadata); } diff --git a/plat/arm/board/tc/tc_bl2_dpe.c b/plat/arm/board/tc/tc_bl2_dpe.c index 94fddd4f1..e2c3a3808 100644 --- a/plat/arm/board/tc/tc_bl2_dpe.c +++ b/plat/arm/board/tc/tc_bl2_dpe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Arm Limited. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -16,6 +15,7 @@ #include #include "tc_dpe.h" +#include /* * The content and the values of this array depends on: @@ -254,8 +254,7 @@ void bl2_plat_mboot_init(void) #endif /* Initialize the communication channel between AP and RSE */ - (void)rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, - PLAT_RSE_AP_RCV_MHU_BASE); + (void)plat_rse_comms_init(); dpe_init(tc_dpe_metadata); } diff --git a/plat/arm/board/tc/tc_bl2_measured_boot.c b/plat/arm/board/tc/tc_bl2_measured_boot.c index 3957c9064..8238b8ba0 100644 --- a/plat/arm/board/tc/tc_bl2_measured_boot.c +++ b/plat/arm/board/tc/tc_bl2_measured_boot.c @@ -1,18 +1,18 @@ /* - * Copyright (c) 2022-2024, Arm Limited. All rights reserved. + * Copyright (c) 2022-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include -#include #include #include #include #include #include +#include /* TC specific table with image IDs and metadata. Intentionally not a * const struct, some members might set by bootloaders during trusted boot. @@ -53,8 +53,7 @@ struct rse_mboot_metadata tc_rse_mboot_metadata[] = { void bl2_plat_mboot_init(void) { /* Initialize the communication channel between AP and RSE */ - (void)rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, - PLAT_RSE_AP_RCV_MHU_BASE); + (void)plat_rse_comms_init(); rse_measured_boot_init(tc_rse_mboot_metadata); } diff --git a/plat/arm/board/tc/tc_bl31_setup.c b/plat/arm/board/tc/tc_bl31_setup.c index 4e346ab17..c5ebfde64 100644 --- a/plat/arm/board/tc/tc_bl31_setup.c +++ b/plat/arm/board/tc/tc_bl31_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2020-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -27,8 +27,8 @@ #endif /* PLATFORM_TEST_TFM_TESTSUITE */ #include -#include #include +#include #ifdef PLATFORM_TEST_TFM_TESTSUITE /* @@ -126,7 +126,7 @@ void bl31_platform_setup(void) #endif /* Initialise RSE communication channel */ - status = rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, PLAT_RSE_AP_RCV_MHU_BASE); + status = plat_rse_comms_init(); if (status != PSA_SUCCESS) { ERROR("Failed to initialize RSE communication channel - psa_status = %d\n", status); } diff --git a/plat/arm/board/tc/tc_rse_comms.c b/plat/arm/board/tc/tc_rse_comms.c new file mode 100644 index 000000000..d048f288a --- /dev/null +++ b/plat/arm/board/tc/tc_rse_comms.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +int plat_rse_comms_init(void) +{ + VERBOSE("Initializing the rse_comms now\n"); + /* Initialize the communication channel between AP and RSE */ + return rse_comms_init(PLAT_RSE_AP_SND_MHU_BASE, PLAT_RSE_AP_RCV_MHU_BASE); +}