From 7d6449613519bd3bf05056f48b32d5e49493b823 Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Thu, 24 Jan 2019 12:33:38 +0200 Subject: [PATCH 1/3] Create new PSA compliant headers --- components/TARGET_PSA/inc/psa/client.h | 25 ++++++++++++++++++ .../inc/psa/internal_trusted_storage.h | 23 ++++++++++++++++ components/TARGET_PSA/inc/psa/service.h | 26 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 components/TARGET_PSA/inc/psa/client.h create mode 100644 components/TARGET_PSA/inc/psa/internal_trusted_storage.h create mode 100644 components/TARGET_PSA/inc/psa/service.h diff --git a/components/TARGET_PSA/inc/psa/client.h b/components/TARGET_PSA/inc/psa/client.h new file mode 100644 index 00000000000..d871026be51 --- /dev/null +++ b/components/TARGET_PSA/inc/psa/client.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2017-2018 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(TARGET_MBED_SPM) +#include "psa_defs.h" +#include "spm_client.h" +#endif + +#if defined(TARGET_TFM) +#include "interface/include/psa_client.h" +#endif diff --git a/components/TARGET_PSA/inc/psa/internal_trusted_storage.h b/components/TARGET_PSA/inc/psa/internal_trusted_storage.h new file mode 100644 index 00000000000..7b3b6a9785a --- /dev/null +++ b/components/TARGET_PSA/inc/psa/internal_trusted_storage.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2017-2018 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MBED_INTERNAL_TRUSTED_STORAGE_H__ +#define __MBED_INTERNAL_TRUSTED_STORAGE_H__ + +#include "psa_prot_internal_storage.h" + +#endif // __MBED_INTERNAL_TRUSTED_STORAGE_H__ diff --git a/components/TARGET_PSA/inc/psa/service.h b/components/TARGET_PSA/inc/psa/service.h new file mode 100644 index 00000000000..623c4d503d4 --- /dev/null +++ b/components/TARGET_PSA/inc/psa/service.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2017-2018 ARM Limited + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined(TARGET_MBED_SPM) +#include "psa_defs.h" +#include "spm_server.h" +#include "spm_panic.h" +#endif + +#if defined(TARGET_TFM) +#include "interface/include/psa_service.h" +#endif From 441cd94780cb5f37f5d5fb86a6e46b9bfe4663de Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Thu, 24 Jan 2019 12:36:33 +0200 Subject: [PATCH 2/3] Align to new spec changes and prep for TFM SPM --- .../COMPONENT_PSA_SRV_IPC/test_pits.c | 4 +- .../psa_test_its_reset_partition.c | 4 + .../COMPONENT_SPE/test_pits_reset_partition.c | 4 +- .../COMPONENT_PSA_SRV_IPC/test_pits.c | 4 +- .../psa_test_its_reset_partition.c | 4 + .../COMPONENT_SPE/test_pits_reset_partition.c | 4 +- .../COMPONENT_NSPE/client_ipc_tests.cpp | 36 +- .../psa_client_tests_part1_partition.c | 4 + TESTS/psa/spm_client/COMPONENT_SPE/server.c | 2 +- TESTS/psa/spm_server/COMPONENT_NSPE/main.cpp | 52 +-- .../psa_server_test_part1_partition.c | 4 + .../psa_server_test_part2_partition.c | 4 + .../psa/spm_server/COMPONENT_SPE/partition.c | 6 +- .../psa/spm_server/COMPONENT_SPE/partition2.c | 2 +- .../spm_server/COMPONENT_SPE/server_tests.h | 4 +- TESTS/psa/spm_server/COMPONENT_SPE/tests.c | 64 ++-- TESTS/psa/spm_server/server_tests.h | 4 +- TESTS/psa/spm_smoke/COMPONENT_NSPE/main.cpp | 8 +- .../psa_smoke_test_part1_partition.c | 4 + .../psa/spm_smoke/COMPONENT_SPE/partition1.c | 2 +- .../COMPONENT_SPE/handles_manager.c | 0 .../COMPONENT_SPE/handles_manager.h | 0 .../COMPONENT_SPE/psa_setup.c | 0 .../COMPONENT_SPE/spm_client.c | 10 +- .../COMPONENT_SPE/spm_common.c | 0 .../COMPONENT_SPE/spm_init.c | 0 .../COMPONENT_SPE/spm_internal.h | 8 +- .../COMPONENT_SPE/spm_main.c | 0 .../COMPONENT_SPE/spm_panic.h | 0 .../COMPONENT_SPE/spm_server.c | 12 +- .../COMPONENT_SPE/spm_server.h | 2 +- .../COMPONENT_NSPE/spm_client_proxy.c | 12 +- .../COMPONENT_NSPE/spm_mailbox_nspe.c | 0 .../COMPONENT_SPE/spm_mailbox_spe.c | 0 .../COMPONENT_SPM_MAILBOX/ipc_defs.h | 0 .../COMPONENT_SPM_MAILBOX/ipc_queue.c | 0 .../COMPONENT_SPM_MAILBOX/ipc_queue.h | 0 .../{spm => TARGET_MBED_SPM}/mbed_lib.json | 0 .../{spm => TARGET_MBED_SPM}/psa_defs.h | 15 +- .../{spm => TARGET_MBED_SPM}/spm_client.h | 16 +- .../{spm => TARGET_MBED_SPM}/spm_init.h | 0 .../{spm => TARGET_MBED_SPM}/spm_messages.h | 8 +- .../COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h | 4 +- .../COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c | 329 +++++++++--------- .../psa_crypto_srv_partition.c | 4 + .../COMPONENT_SPE/psa_crypto_partition.c | 19 +- .../psa_prot_internal_storage.c | 22 +- .../{ => TARGET_MBED_SPM}/psa_its_partition.c | 4 + .../COMPONENT_SPE/its_partition.c | 17 +- features/mbedtls/inc/psa/crypto.h | 15 +- rtos/TARGET_CORTEX/mbed_rtos_rtx.c | 10 +- targets/targets.json | 4 +- tools/spm/generate_partition_code.py | 2 +- .../psa_NAME_partition.c.tpl | 4 + 54 files changed, 378 insertions(+), 359 deletions(-) rename TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_test_its_reset_partition.c (98%) rename TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_test_its_reset_partition.c (98%) rename TESTS/psa/spm_client/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_client_tests_part1_partition.c (98%) rename TESTS/psa/spm_server/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_server_test_part1_partition.c (98%) rename TESTS/psa/spm_server/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_server_test_part2_partition.c (98%) rename TESTS/psa/spm_smoke/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_smoke_test_part1_partition.c (98%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/handles_manager.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/handles_manager.h (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/psa_setup.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_client.c (98%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_common.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_init.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_internal.h (98%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_main.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_panic.h (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_server.c (98%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPE/spm_server.h (98%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c (95%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_mailbox_nspe.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPM_MAILBOX/COMPONENT_SPE/spm_mailbox_spe.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPM_MAILBOX/ipc_defs.h (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPM_MAILBOX/ipc_queue.c (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/COMPONENT_SPM_MAILBOX/ipc_queue.h (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/mbed_lib.json (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/psa_defs.h (88%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/spm_client.h (85%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/spm_init.h (100%) rename components/TARGET_PSA/{spm => TARGET_MBED_SPM}/spm_messages.h (89%) rename components/TARGET_PSA/services/crypto/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_crypto_srv_partition.c (99%) rename components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_its_partition.c (98%) rename tools/spm/templates/COMPONENT_SPE/{ => TARGET_MBED_SPM}/psa_NAME_partition.c.tpl (98%) diff --git a/TESTS/psa/entropy_inject/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c b/TESTS/psa/entropy_inject/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c index 8493581f9ee..0e73b0f5929 100644 --- a/TESTS/psa/entropy_inject/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c +++ b/TESTS/psa/entropy_inject/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "spm_client.h" +#include "psa/client.h" #include "psa_prot_internal_storage.h" #include "test_pits.h" #include "psa_test_its_reset_ifs.h" @@ -27,7 +27,7 @@ psa_its_status_t test_psa_its_reset(void) return PSA_ITS_ERROR_STORAGE_FAILURE; } - psa_error_t status = psa_call(conn, NULL, 0, NULL, 0); + psa_status_t status = psa_call(conn, NULL, 0, NULL, 0); if (status == PSA_DROP_CONNECTION) { status = PSA_ITS_ERROR_STORAGE_FAILURE; } diff --git a/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c b/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c similarity index 98% rename from TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c rename to TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c index 88b3fc93078..7710b2e8ceb 100644 --- a/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c +++ b/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -99,3 +101,5 @@ void test_its_reset_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition test_its_reset!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/test_pits_reset_partition.c b/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/test_pits_reset_partition.c index efdd1ad0c70..e4d7b2fc789 100644 --- a/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/test_pits_reset_partition.c +++ b/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/test_pits_reset_partition.c @@ -19,7 +19,7 @@ #include #include "cmsis_os2.h" -#include "spm_server.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_test_its_reset_partition.h" #include "psa_prot_internal_storage.h" @@ -34,7 +34,7 @@ void test_pits_entry(void *ptr) { uint32_t signals = 0; psa_msg_t msg = {0}; - psa_error_t status = PSA_SUCCESS; + psa_status_t status = PSA_SUCCESS; while (1) { signals = psa_wait_any(PSA_BLOCK); diff --git a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c index 8493581f9ee..0e73b0f5929 100644 --- a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c +++ b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_PSA_SRV_IPC/test_pits.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "spm_client.h" +#include "psa/client.h" #include "psa_prot_internal_storage.h" #include "test_pits.h" #include "psa_test_its_reset_ifs.h" @@ -27,7 +27,7 @@ psa_its_status_t test_psa_its_reset(void) return PSA_ITS_ERROR_STORAGE_FAILURE; } - psa_error_t status = psa_call(conn, NULL, 0, NULL, 0); + psa_status_t status = psa_call(conn, NULL, 0, NULL, 0); if (status == PSA_DROP_CONNECTION) { status = PSA_ITS_ERROR_STORAGE_FAILURE; } diff --git a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c similarity index 98% rename from TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c rename to TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c index 88b3fc93078..7710b2e8ceb 100644 --- a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c +++ b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -99,3 +101,5 @@ void test_its_reset_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition test_its_reset!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/test_pits_reset_partition.c b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/test_pits_reset_partition.c index efdd1ad0c70..e4d7b2fc789 100644 --- a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/test_pits_reset_partition.c +++ b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/test_pits_reset_partition.c @@ -19,7 +19,7 @@ #include #include "cmsis_os2.h" -#include "spm_server.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_test_its_reset_partition.h" #include "psa_prot_internal_storage.h" @@ -34,7 +34,7 @@ void test_pits_entry(void *ptr) { uint32_t signals = 0; psa_msg_t msg = {0}; - psa_error_t status = PSA_SUCCESS; + psa_status_t status = PSA_SUCCESS; while (1) { signals = psa_wait_any(PSA_BLOCK); diff --git a/TESTS/psa/spm_client/COMPONENT_NSPE/client_ipc_tests.cpp b/TESTS/psa/spm_client/COMPONENT_NSPE/client_ipc_tests.cpp index 8023b85870c..b726ac0614d 100644 --- a/TESTS/psa/spm_client/COMPONENT_NSPE/client_ipc_tests.cpp +++ b/TESTS/psa/spm_client/COMPONENT_NSPE/client_ipc_tests.cpp @@ -23,7 +23,7 @@ #include "greentea-client/test_env.h" #include "unity.h" #include "utest.h" -#include "spm_client.h" +#include "psa/client.h" #include "psa_client_tests_part1_ifs.h" using namespace utest::v1; @@ -37,7 +37,7 @@ using namespace utest::v1; typedef struct th_struct { psa_handle_t handle; - psa_invec_t *iovec_temp; + psa_invec *iovec_temp; uint8_t *expected; uint8_t expected_size; } th_struct_t; @@ -55,7 +55,7 @@ static psa_handle_t client_ipc_tests_connect(uint32_t sid, uint32_t minor_versio static void client_ipc_tests_call( psa_handle_t handle, - psa_invec_t *iovec_temp, + psa_invec *iovec_temp, size_t tx_len, size_t rx_len, uint8_t *expected, @@ -65,7 +65,7 @@ static void client_ipc_tests_call( error_t status = PSA_SUCCESS; uint8_t *response_buf = (uint8_t *)malloc(CLIENT_RSP_BUF_SIZE * sizeof(uint8_t)); memset(response_buf, 0, CLIENT_RSP_BUF_SIZE); - psa_outvec_t resp = {NULL, rx_len}; + psa_outvec resp = {NULL, rx_len}; if (rx_len > 0) { resp.base = response_buf; @@ -105,7 +105,7 @@ void iovec_0_NULL() uint8_t buff1[] = {1, 2, 3, 4, 5}; uint8_t expected_buff[] = {1, 2, 3, 4, 5}; - psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = { + psa_invec iovec_temp[PSA_MAX_IOVEC - 1] = { {NULL, 0}, {meta_iovec, sizeof(meta_iovec)}, {buff1, sizeof(buff1)} @@ -128,7 +128,7 @@ void iovec_1_NULL() uint8_t buff1[] = {1, 2, 3, 4, 5}; uint8_t expected_buff[] = {2, 3}; - psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, + psa_invec iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, {NULL, 0}, {buff1, sizeof(buff1)} }; @@ -150,7 +150,7 @@ void iovec_2_NULL() uint8_t buff1[] = {1, 2, 3, 4, 5}; uint8_t expected_buff[] = {2, 3}; - psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, + psa_invec iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, {buff1, sizeof(buff1)}, {NULL, 0} }; @@ -164,7 +164,7 @@ void iovec_2_NULL() void in_vec_base_not_NULL_size_0() { uint8_t dummy_buff[] = {1, 2, 3, 4, 5}; - psa_invec_t iovec_temp[1] = { {dummy_buff, 0} }; + psa_invec iovec_temp[1] = { {dummy_buff, 0} }; psa_handle_t handle = client_ipc_tests_connect(PART1_ROT_SRV1, MINOR_VER); @@ -177,7 +177,7 @@ void in_vec_base_not_NULL_size_0() void in_len_0_in_vec_not_NULL() { uint8_t dummy_buff[] = {1, 2, 3, 4, 5}; - psa_invec_t iovec_temp[1] = { {dummy_buff, sizeof(dummy_buff)} }; + psa_invec iovec_temp[1] = { {dummy_buff, sizeof(dummy_buff)} }; psa_handle_t handle = client_ipc_tests_connect(PART1_ROT_SRV1, MINOR_VER); @@ -192,13 +192,13 @@ void out_len_0_outvec_not_NULL() error_t status = PSA_SUCCESS; uint8_t dummy_res[10] = {0}; - psa_outvec_t outvec_temp[1] = {{dummy_res, sizeof(dummy_res)}}; + psa_outvec outvec_temp[1] = {{dummy_res, sizeof(dummy_res)}}; uint8_t dummy_buff[] = {1, 2, 3, 4, 5}; psa_handle_t handle = client_ipc_tests_connect(PART1_ROT_SRV1, MINOR_VER); - psa_invec_t in_vec_temp[2] = { {dummy_buff, sizeof(dummy_buff)}, + psa_invec in_vec_temp[2] = { {dummy_buff, sizeof(dummy_buff)}, {dummy_buff, sizeof(dummy_buff)} }; @@ -219,7 +219,7 @@ void rx_buff_null() uint8_t meta_iovec[2] = {expect_size, off}; uint8_t buff1[] = {1, 2, 3, 4, 5}, buff2[] = {6}; - psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, + psa_invec iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, {buff1, sizeof(buff1)}, {buff2, sizeof(buff2)} }; @@ -261,7 +261,7 @@ void multiple_call() uint8_t buff2[] = {4, 5, 6}; uint8_t expected_buff[] = {1, 2}; - psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, + psa_invec iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)}, {buff1, sizeof(buff1)}, {buff2, sizeof(buff2)} }; @@ -285,7 +285,7 @@ void multiple_call() client_ipc_tests_close(handle); } -static void set_struct(th_struct_t *thr_attr, psa_handle_t handle, psa_invec_t *iovec_temp, uint8_t *expect, uint8_t expected_size) +static void set_struct(th_struct_t *thr_attr, psa_handle_t handle, psa_invec *iovec_temp, uint8_t *expect, uint8_t expected_size) { thr_attr->handle = handle; thr_attr->iovec_temp = iovec_temp; @@ -322,7 +322,7 @@ void multi_thread_diff_handles() uint8_t buff2[] = {4, 5, 6}; uint8_t expected_buff_1[] = {1, 2}; - psa_invec_t iovec_temp_1[PSA_MAX_IOVEC - 1] = {{meta_iovec_1, sizeof(meta_iovec_1)}, + psa_invec iovec_temp_1[PSA_MAX_IOVEC - 1] = {{meta_iovec_1, sizeof(meta_iovec_1)}, {buff1, sizeof(buff1)}, {buff2, sizeof(buff2)} }; @@ -338,7 +338,7 @@ void multi_thread_diff_handles() }; uint8_t expected_buff_2[] = {2, 3}; - psa_invec_t iovec_temp_2[PSA_MAX_IOVEC - 1] = {{meta_iovec_2, sizeof(meta_iovec_2)}, + psa_invec iovec_temp_2[PSA_MAX_IOVEC - 1] = {{meta_iovec_2, sizeof(meta_iovec_2)}, {buff1, sizeof(buff1)}, {buff2, sizeof(buff2)} }; @@ -353,7 +353,7 @@ void multi_thread_diff_handles() }; uint8_t expected_buff_3[] = {3, 4}; - psa_invec_t iovec_temp_3[PSA_MAX_IOVEC - 1] = {{meta_iovec_3, sizeof(meta_iovec_3)}, + psa_invec iovec_temp_3[PSA_MAX_IOVEC - 1] = {{meta_iovec_3, sizeof(meta_iovec_3)}, {buff1, sizeof(buff1)}, {buff2, sizeof(buff2)} }; @@ -408,7 +408,7 @@ void client_close_null_handle() void drop_connection() { psa_handle_t handle = client_ipc_tests_connect(DROP_CONN, DROP_CONN_MINOR_VER); - psa_error_t status = psa_call(handle, NULL, 0, NULL, 0); + psa_status_t status = psa_call(handle, NULL, 0, NULL, 0); TEST_ASSERT_EQUAL_INT(PSA_DROP_CONNECTION, status); status = PSA_SUCCESS; diff --git a/TESTS/psa/spm_client/COMPONENT_SPE/psa_client_tests_part1_partition.c b/TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c similarity index 98% rename from TESTS/psa/spm_client/COMPONENT_SPE/psa_client_tests_part1_partition.c rename to TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c index dff2c310450..fb87681fb43 100644 --- a/TESTS/psa/spm_client/COMPONENT_SPE/psa_client_tests_part1_partition.c +++ b/TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -123,3 +125,5 @@ void client_tests_part1_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition client_tests_part1!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_client/COMPONENT_SPE/server.c b/TESTS/psa/spm_client/COMPONENT_SPE/server.c index df197febdd2..b3419abab27 100644 --- a/TESTS/psa/spm_client/COMPONENT_SPE/server.c +++ b/TESTS/psa/spm_client/COMPONENT_SPE/server.c @@ -15,7 +15,7 @@ * limitations under the License. */ #include -#include "spm_server.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_client_tests_part1_partition.h" diff --git a/TESTS/psa/spm_server/COMPONENT_NSPE/main.cpp b/TESTS/psa/spm_server/COMPONENT_NSPE/main.cpp index d4b9a7e7ddf..57010262a32 100644 --- a/TESTS/psa/spm_server/COMPONENT_NSPE/main.cpp +++ b/TESTS/psa/spm_server/COMPONENT_NSPE/main.cpp @@ -23,7 +23,7 @@ #include "greentea-client/test_env.h" #include "unity.h" #include "utest.h" -#include "spm_client.h" +#include "psa/client.h" #include "psa_server_test_part1_ifs.h" #include "server_tests.h" using namespace utest::v1; @@ -57,7 +57,7 @@ PSA_TEST_CLIENT(identity_during_connect) PSA_TEST_CLIENT(identity_during_call) { - psa_error_t status = PSA_SUCCESS; + psa_status_t status = PSA_SUCCESS; psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT(test_handle > 0); @@ -69,8 +69,8 @@ PSA_TEST_CLIENT(identity_during_call) PSA_TEST_CLIENT(msg_size_assertion) { - psa_error_t status = PSA_SUCCESS; - psa_invec_t data[PSA_MAX_IOVEC] = { + psa_status_t status = PSA_SUCCESS; + psa_invec data[PSA_MAX_IOVEC] = { {test_str, 4}, {test_str + 5, 6}, {test_str + 13, 1}, @@ -93,8 +93,8 @@ PSA_TEST_CLIENT(reject_connection) PSA_TEST_CLIENT(read_at_outofboud_offset) { - psa_error_t status = PSA_SUCCESS; - psa_invec_t data = { test_str, sizeof(test_str) }; + psa_status_t status = PSA_SUCCESS; + psa_invec data = { test_str, sizeof(test_str) }; psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT(test_handle > 0); @@ -106,8 +106,8 @@ PSA_TEST_CLIENT(read_at_outofboud_offset) PSA_TEST_CLIENT(msg_read_truncation) { - psa_error_t status = PSA_SUCCESS; - psa_invec_t data[3] = { + psa_status_t status = PSA_SUCCESS; + psa_invec data[3] = { {test_str, 4}, {test_str + 5, 6}, {test_str + 13, 1} @@ -123,8 +123,8 @@ PSA_TEST_CLIENT(msg_read_truncation) PSA_TEST_CLIENT(skip_zero) { - psa_error_t status = PSA_SUCCESS; - psa_invec_t data = { test_str, sizeof(test_str) }; + psa_status_t status = PSA_SUCCESS; + psa_invec data = { test_str, sizeof(test_str) }; psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT(test_handle > 0); @@ -136,8 +136,8 @@ PSA_TEST_CLIENT(skip_zero) PSA_TEST_CLIENT(skip_some) { - psa_error_t status = PSA_SUCCESS; - psa_invec_t data = { test_str, sizeof(test_str) }; + psa_status_t status = PSA_SUCCESS; + psa_invec data = { test_str, sizeof(test_str) }; psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT(test_handle > 0); @@ -149,8 +149,8 @@ PSA_TEST_CLIENT(skip_some) PSA_TEST_CLIENT(skip_more_than_left) { - psa_error_t status = PSA_SUCCESS; - psa_invec_t data = { test_str, 8 }; + psa_status_t status = PSA_SUCCESS; + psa_invec data = { test_str, 8 }; psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT(test_handle > 0); @@ -164,8 +164,8 @@ PSA_TEST_CLIENT(rhandle_factorial) { uint32_t secure_value = 0; uint32_t value = 1; - psa_error_t status = PSA_SUCCESS; - psa_outvec_t resp = { &secure_value, sizeof(secure_value) }; + psa_status_t status = PSA_SUCCESS; + psa_outvec resp = { &secure_value, sizeof(secure_value) }; psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT(test_handle > 0); @@ -185,12 +185,12 @@ PSA_TEST_CLIENT(cross_partition_call) size_t in_len = strlen(cross_part_buf); TEST_ASSERT_MESSAGE(test_handle > 0, "psa_connect() failed"); - psa_invec_t iovec = { cross_part_buf, in_len }; + psa_invec iovec = { cross_part_buf, in_len }; uint8_t *response_buf = (uint8_t *)malloc(sizeof(uint8_t) * OUT_BUFFER_SIZE); memset(response_buf, 0, OUT_BUFFER_SIZE); - psa_outvec_t resp = { response_buf, OUT_BUFFER_SIZE }; + psa_outvec resp = { response_buf, OUT_BUFFER_SIZE }; - psa_error_t status = psa_call(test_handle, &iovec, 1, &resp, 1); + psa_status_t status = psa_call(test_handle, &iovec, 1, &resp, 1); TEST_ASSERT_EQUAL(PSA_SUCCESS, status); TEST_ASSERT_EQUAL_STRING_LEN("MPS emoclew dna olleHMPS emoclew dna olleH", response_buf, in_len * 2); free(response_buf); @@ -204,7 +204,7 @@ PSA_TEST_CLIENT(doorbell_test) psa_handle_t test_handle = psa_connect(TEST, TEST_ROT_SRV_MINOR); TEST_ASSERT_MESSAGE(test_handle > 0, "psa_connect() failed"); - psa_error_t status = psa_call(test_handle, NULL, 0, NULL, 0); + psa_status_t status = psa_call(test_handle, NULL, 0, NULL, 0); TEST_ASSERT_EQUAL(PSA_SUCCESS, status); psa_close(test_handle); @@ -232,9 +232,9 @@ void spm_teardown(const size_t passed, const size_t failed, const failure_t fail utest::v1::status_t spm_case_setup(const Case *const source, const size_t index_of_case) { - psa_error_t status = PSA_SUCCESS; + psa_status_t status = PSA_SUCCESS; test_action_t action = START_TEST; - psa_invec_t data = {&action, sizeof(action)}; + psa_invec data = {&action, sizeof(action)}; status = psa_call(control_handle, &data, 1, NULL, 0); TEST_ASSERT_EQUAL(PSA_SUCCESS, status); @@ -244,11 +244,11 @@ utest::v1::status_t spm_case_setup(const Case *const source, const size_t index_ utest::v1::status_t spm_case_teardown(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) { - psa_error_t status = PSA_SUCCESS; - psa_error_t test_status = PSA_SUCCESS; + psa_status_t status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; test_action_t action = GET_TEST_RESULT; - psa_invec_t data = {&action, sizeof(action)}; - psa_outvec_t resp = {&test_status, sizeof(test_status)}; + psa_invec data = {&action, sizeof(action)}; + psa_outvec resp = {&test_status, sizeof(test_status)}; // Wait for psa_close to finish on server side osDelay(50); diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/psa_server_test_part1_partition.c b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c similarity index 98% rename from TESTS/psa/spm_server/COMPONENT_SPE/psa_server_test_part1_partition.c rename to TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c index 8d1b0a53332..9d3d1e63ea7 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/psa_server_test_part1_partition.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -117,3 +119,5 @@ void server_test_part1_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition server_test_part1!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/psa_server_test_part2_partition.c b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c similarity index 98% rename from TESTS/psa/spm_server/COMPONENT_SPE/psa_server_test_part2_partition.c rename to TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c index a4fc7572c8a..992394745ae 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/psa_server_test_part2_partition.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -111,3 +113,5 @@ void server_test_part2_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition server_test_part2!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/partition.c b/TESTS/psa/spm_server/COMPONENT_SPE/partition.c index 0c78bde8afd..34d95958ab2 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/partition.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/partition.c @@ -16,7 +16,7 @@ */ #include "string.h" -#include "spm_server.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_server_test_part1_partition.h" #include "server_tests.h" @@ -37,8 +37,8 @@ static void init_num_of_tests() void part1_main(void *ptr) { uint32_t signals = 0; - psa_error_t test_status = PSA_SUCCESS; // status of the api calls during the test - psa_error_t test_result = PSA_SUCCESS; // result of the critical section of the test + psa_status_t test_status = PSA_SUCCESS; // status of the api calls during the test + psa_status_t test_result = PSA_SUCCESS; // result of the critical section of the test test_action_t action; uint32_t test_idx = 0; diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/partition2.c b/TESTS/psa/spm_server/COMPONENT_SPE/partition2.c index e5972079ba0..fe1d4740592 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/partition2.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/partition2.c @@ -17,7 +17,7 @@ #include #include "cmsis_os2.h" -#include "spm_server.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_server_test_part2_partition.h" diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h b/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h index 99002eb6b36..1964ab3a55b 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h +++ b/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h @@ -28,13 +28,13 @@ typedef struct factorial_data { uint32_t val; } factorial_data_t; -typedef psa_error_t (*psa_test_server_side_func)(psa_error_t *); +typedef psa_status_t (*psa_test_server_side_func)(psa_status_t *); #define PSA_TEST_ERROR (-1L) #define PSA_TEST_CLIENT_NAME(name) psa_test_client_side_ ## name #define PSA_TEST_SERVER_NAME(name) psa_test_server_side_ ## name #define PSA_TEST_CLIENT(name) void PSA_TEST_CLIENT_NAME(name) (void) -#define PSA_TEST_SERVER(name) psa_error_t PSA_TEST_SERVER_NAME(name) (psa_error_t* status_ptr) +#define PSA_TEST_SERVER(name) psa_status_t PSA_TEST_SERVER_NAME(name) (psa_status_t* status_ptr) #define PSA_TEST(name) \ PSA_TEST_CLIENT(name); \ diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/tests.c b/TESTS/psa/spm_server/COMPONENT_SPE/tests.c index c0b4b4d04d0..9aec3a67eed 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/tests.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/tests.c @@ -16,8 +16,8 @@ */ #include "string.h" -#include "spm_client.h" -#include "spm_server.h" +#include "psa/client.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_server_test_part1_partition.h" #include "psa_server_test_part2_ifs.h" @@ -27,9 +27,9 @@ * Process a generic connect message to TEST ROT_SRV. * @return PSA_SUCCESS or negative error code if failed. */ -static psa_error_t process_connect_request(void) +static psa_status_t process_connect_request(void) { - psa_error_t res = PSA_SUCCESS; + psa_status_t res = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = psa_wait_any(PSA_BLOCK); if ((signals & TEST_MSK) == 0) { @@ -50,9 +50,9 @@ static psa_error_t process_connect_request(void) * Process a generic disconnect message to TEST ROT_SRV. * @return PSA_SUCCESS or negative error code if failed. */ -static psa_error_t process_disconnect_request(void) +static psa_status_t process_disconnect_request(void) { - psa_error_t res = PSA_SUCCESS; + psa_status_t res = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = psa_wait_any(PSA_BLOCK); if ((signals & TEST_MSK) == 0) { @@ -71,7 +71,7 @@ static psa_error_t process_disconnect_request(void) PSA_TEST_SERVER(wait_timeout) { - psa_error_t test_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; uint32_t signals = psa_wait_any(7); *status_ptr = ((signals & TEST_MSK) == 0) ? PSA_SUCCESS : PSA_TEST_ERROR;; @@ -89,8 +89,8 @@ PSA_TEST_SERVER(wait_timeout) PSA_TEST_SERVER(identity_during_connect) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; int32_t identity = 0; @@ -117,8 +117,8 @@ PSA_TEST_SERVER(identity_during_connect) PSA_TEST_SERVER(identity_during_call) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; int32_t identity = 0; uint32_t signals = 0; @@ -151,8 +151,8 @@ PSA_TEST_SERVER(identity_during_call) PSA_TEST_SERVER(msg_size_assertion) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = 0; size_t read_size = 0; @@ -199,7 +199,7 @@ PSA_TEST_SERVER(msg_size_assertion) PSA_TEST_SERVER(reject_connection) { - psa_error_t res = PSA_SUCCESS; + psa_status_t res = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = psa_wait_any(PSA_BLOCK); if ((signals & TEST_MSK) == 0) { @@ -220,8 +220,8 @@ PSA_TEST_SERVER(read_at_outofboud_offset) { uint32_t signals = 0; psa_msg_t msg = {0}; - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; uint32_t buff = 52; test_status = process_connect_request(); @@ -255,8 +255,8 @@ PSA_TEST_SERVER(read_at_outofboud_offset) PSA_TEST_SERVER(msg_read_truncation) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = 0; size_t read_size = 0; @@ -301,8 +301,8 @@ PSA_TEST_SERVER(msg_read_truncation) PSA_TEST_SERVER(skip_zero) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = 0; size_t read_size = 0; @@ -347,8 +347,8 @@ PSA_TEST_SERVER(skip_zero) PSA_TEST_SERVER(skip_some) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = 0; size_t read_size1 = 0; @@ -396,8 +396,8 @@ PSA_TEST_SERVER(skip_some) PSA_TEST_SERVER(skip_more_than_left) { - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; psa_msg_t msg = {0}; uint32_t signals = 0; size_t read_size1 = 0; @@ -537,9 +537,9 @@ PSA_TEST_SERVER(cross_partition_call) { uint32_t signals = 0; psa_msg_t msg = {0}; - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; - psa_error_t partition_call_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; + psa_status_t partition_call_status = PSA_SUCCESS; uint32_t data_read = 0; uint32_t str_len = 0; char *buff = malloc(sizeof(char) * 60); @@ -575,9 +575,9 @@ PSA_TEST_SERVER(cross_partition_call) memcpy(buff + str_len, buff, str_len); data_read *= 2; - psa_invec_t data = { buff, data_read }; + psa_invec data = { buff, data_read }; - psa_outvec_t resp = { buff, data_read }; + psa_outvec resp = { buff, data_read }; psa_handle_t conn_handle = psa_connect(ROT_SRV_REVERSE, 5); if (conn_handle <= 0) { partition_call_status = PSA_TEST_ERROR; @@ -608,9 +608,9 @@ PSA_TEST_SERVER(doorbell_test) { uint32_t signals = 0; psa_msg_t msg = {0}; - psa_error_t test_status = PSA_SUCCESS; - psa_error_t disconnect_status = PSA_SUCCESS; - psa_error_t partition_call_status = PSA_SUCCESS; + psa_status_t test_status = PSA_SUCCESS; + psa_status_t disconnect_status = PSA_SUCCESS; + psa_status_t partition_call_status = PSA_SUCCESS; test_status = process_connect_request(); diff --git a/TESTS/psa/spm_server/server_tests.h b/TESTS/psa/spm_server/server_tests.h index 99002eb6b36..1964ab3a55b 100644 --- a/TESTS/psa/spm_server/server_tests.h +++ b/TESTS/psa/spm_server/server_tests.h @@ -28,13 +28,13 @@ typedef struct factorial_data { uint32_t val; } factorial_data_t; -typedef psa_error_t (*psa_test_server_side_func)(psa_error_t *); +typedef psa_status_t (*psa_test_server_side_func)(psa_status_t *); #define PSA_TEST_ERROR (-1L) #define PSA_TEST_CLIENT_NAME(name) psa_test_client_side_ ## name #define PSA_TEST_SERVER_NAME(name) psa_test_server_side_ ## name #define PSA_TEST_CLIENT(name) void PSA_TEST_CLIENT_NAME(name) (void) -#define PSA_TEST_SERVER(name) psa_error_t PSA_TEST_SERVER_NAME(name) (psa_error_t* status_ptr) +#define PSA_TEST_SERVER(name) psa_status_t PSA_TEST_SERVER_NAME(name) (psa_status_t* status_ptr) #define PSA_TEST(name) \ PSA_TEST_CLIENT(name); \ diff --git a/TESTS/psa/spm_smoke/COMPONENT_NSPE/main.cpp b/TESTS/psa/spm_smoke/COMPONENT_NSPE/main.cpp index 67e386601ef..6af907fa33c 100644 --- a/TESTS/psa/spm_smoke/COMPONENT_NSPE/main.cpp +++ b/TESTS/psa/spm_smoke/COMPONENT_NSPE/main.cpp @@ -24,7 +24,7 @@ #include "greentea-client/test_env.h" #include "unity.h" #include "utest.h" -#include "spm_client.h" +#include "psa/client.h" #include "psa_smoke_test_part1_ifs.h" using namespace utest::v1; @@ -47,7 +47,7 @@ void example_main(void) TEST_ASSERT_MESSAGE(conn_handle > 0, "psa_connect() failed"); - psa_invec_t iovec[PSA_MAX_IOVEC - 1] = { + psa_invec iovec[PSA_MAX_IOVEC - 1] = { { msg_buf, 6 }, { msg_buf + 6, 12 }, { msg_buf + 18, 4 } @@ -55,9 +55,9 @@ void example_main(void) uint8_t *response_buf = (uint8_t *)malloc(sizeof(uint8_t) * CLIENT_RSP_BUF_SIZE); memset(response_buf, 0, CLIENT_RSP_BUF_SIZE); - psa_outvec_t outvec = {response_buf, CLIENT_RSP_BUF_SIZE}; + psa_outvec outvec = {response_buf, CLIENT_RSP_BUF_SIZE}; - psa_error_t status = psa_call(conn_handle, iovec, PSA_MAX_IOVEC - 1, &outvec, 1); + psa_status_t status = psa_call(conn_handle, iovec, PSA_MAX_IOVEC - 1, &outvec, 1); TEST_ASSERT_MESSAGE(PSA_SUCCESS == status, "psa_call() failed"); TEST_ASSERT_EQUAL_STRING(CLIENT_EXPECTED_RESPONSE, response_buf); diff --git a/TESTS/psa/spm_smoke/COMPONENT_SPE/psa_smoke_test_part1_partition.c b/TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c similarity index 98% rename from TESTS/psa/spm_smoke/COMPONENT_SPE/psa_smoke_test_part1_partition.c rename to TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c index d80f58e41b2..b4e06172016 100644 --- a/TESTS/psa/spm_smoke/COMPONENT_SPE/psa_smoke_test_part1_partition.c +++ b/TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -99,3 +101,5 @@ void smoke_test_part1_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition smoke_test_part1!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_smoke/COMPONENT_SPE/partition1.c b/TESTS/psa/spm_smoke/COMPONENT_SPE/partition1.c index 9cd19d6a1bc..07c28a40782 100644 --- a/TESTS/psa/spm_smoke/COMPONENT_SPE/partition1.c +++ b/TESTS/psa/spm_smoke/COMPONENT_SPE/partition1.c @@ -20,7 +20,7 @@ #include #include "cmsis_os2.h" -#include "spm_server.h" +#include "psa/service.h" #include "spm_panic.h" #include "psa_smoke_test_part1_partition.h" diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/handles_manager.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/handles_manager.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.h b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/handles_manager.h similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/handles_manager.h rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/handles_manager.h diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/psa_setup.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/psa_setup.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/psa_setup.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/psa_setup.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_client.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_client.c similarity index 98% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_client.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_client.c index 17f4a497b59..54766b7b9a0 100644 --- a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_client.c +++ b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_client.c @@ -145,7 +145,7 @@ void psa_connect_async(uint32_t sid, spm_pending_connect_msg_t *msg) } // Create the handle in the user message so we could destroy it in case of failure. - msg->rc = (psa_error_t)create_channel_handle(channel, dst_rot_service->partition->partition_id); + msg->rc = (psa_status_t)create_channel_handle(channel, dst_rot_service->partition->partition_id); // NOTE: all struct fields must be initialized as the allocated memory is not zeroed. channel->state = SPM_CHANNEL_STATE_CONNECTING; @@ -230,11 +230,11 @@ void psa_call_async(psa_handle_t handle, spm_pending_call_msg_t *msg) spm_rot_service_queue_enqueue(channel->dst_rot_service, channel); } -psa_error_t psa_call( +psa_status_t psa_call( psa_handle_t handle, - const psa_invec_t *in_vec, + const psa_invec *in_vec, size_t in_len, - const psa_outvec_t *out_vec, + const psa_outvec *out_vec, size_t out_len ) { @@ -272,7 +272,7 @@ psa_error_t psa_call( PSA_UNUSED(os_status); - return (psa_error_t)msg.rc; + return (psa_status_t)msg.rc; } void psa_close_async(psa_handle_t handle, spm_pending_close_msg_t *msg) diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_common.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_common.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_common.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_common.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_init.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_init.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_init.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_init.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_internal.h b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_internal.h similarity index 98% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_internal.h rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_internal.h index 0b3e1246b8e..dcd81db1b1f 100644 --- a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_internal.h +++ b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_internal.h @@ -72,8 +72,8 @@ typedef struct mem_region { } mem_region_t; typedef union spm_iovec { - psa_invec_t in; - psa_outvec_t out; + psa_invec in; + psa_outvec out; } spm_iovec_t; /* @@ -215,9 +215,9 @@ void psa_close_async(psa_handle_t handle, spm_pending_close_msg_t *msg); /* * Validates IOvecs. * - * @param[in] in_vec - psa_invec_t array + * @param[in] in_vec - psa_invec array * @param[in] in_len - number of elements in in_vec - * @param[in] out_vec - psa_outvec_t array + * @param[in] out_vec - psa_outvec array * @param[in] out_len - number of elements in out_vec */ void validate_iovec( diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_main.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_main.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_main.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_main.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_panic.h b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_panic.h similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_panic.h rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_panic.h diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_server.c similarity index 98% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_server.c index b2183f66fcf..46be590e47e 100644 --- a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.c +++ b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_server.c @@ -94,9 +94,9 @@ static void copy_message_to_spm(spm_ipc_channel_t *channel, psa_msg_t *user_msg) spm_pending_call_msg_t *call_msg_data = (spm_pending_call_msg_t *)channel->msg_ptr; // Copy pointers and sizes to secure memory to prevent TOCTOU - const psa_invec_t *temp_invec = call_msg_data->in_vec; + const psa_invec *temp_invec = call_msg_data->in_vec; const uint32_t temp_invec_size = call_msg_data->in_vec_size; - const psa_outvec_t *temp_outvec = call_msg_data->out_vec; + const psa_outvec *temp_outvec = call_msg_data->out_vec; const uint32_t temp_outvec_size = call_msg_data->out_vec_size; validate_iovec(temp_invec, temp_invec_size, temp_outvec, temp_outvec_size); @@ -320,7 +320,7 @@ static size_t read_or_skip(psa_handle_t msg_handle, uint32_t invec_idx, void *bu return 0; } - psa_invec_t *active_iovec = &active_msg->iovecs[invec_idx].in; + psa_invec *active_iovec = &active_msg->iovecs[invec_idx].in; if (num_bytes > active_iovec->len) { num_bytes = active_iovec->len; @@ -376,7 +376,7 @@ void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, const void *buffer, SPM_PANIC("Invalid outvec_idx\n"); } - psa_outvec_t *active_iovec = &active_msg->iovecs[outvec_idx].out; + psa_outvec *active_iovec = &active_msg->iovecs[outvec_idx].out; if (num_bytes > active_iovec->len) { SPM_PANIC("Invalid write operation (Requested %d, Avialable %d)\n", num_bytes, active_iovec->len); } @@ -388,7 +388,7 @@ void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, const void *buffer, return; } -void psa_reply(psa_handle_t msg_handle, psa_error_t status) +void psa_reply(psa_handle_t msg_handle, psa_status_t status) { spm_active_msg_t *active_msg = get_msg_from_handle(msg_handle); spm_ipc_channel_t *active_channel = active_msg->channel; @@ -411,7 +411,7 @@ void psa_reply(psa_handle_t msg_handle, psa_error_t status) bool nspe_call = (active_channel->src_partition == NULL); switch (active_channel->msg_type) { case PSA_IPC_CONNECT: { - if ((status != PSA_CONNECTION_ACCEPTED) && (status != PSA_CONNECTION_REFUSED)) { + if ((status != PSA_SUCCESS) && (status != PSA_CONNECTION_REFUSED)) { SPM_PANIC("status (0X%08x) is not allowed for PSA_IPC_CONNECT", status); } diff --git a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.h b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_server.h similarity index 98% rename from components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.h rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_server.h index c99efd7a0fc..abd3990ad20 100644 --- a/components/TARGET_PSA/spm/COMPONENT_SPE/spm_server.h +++ b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPE/spm_server.h @@ -140,7 +140,7 @@ void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, const void *buffer, * @param[in] msg_handle Handle for the client's message. * @param[in] status Message result value to be reported to the client. */ -void psa_reply(psa_handle_t msg_handle, psa_error_t status); +void psa_reply(psa_handle_t msg_handle, psa_status_t status); /** * Send a doorbell signal to a specific partition that is listening for that signal type. diff --git a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c similarity index 95% rename from components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c index e5820a02ebd..fcfc1a6474b 100644 --- a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c +++ b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_client_proxy.c @@ -121,12 +121,12 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version) return (psa_handle_t)(msg.rc); } -psa_error_t psa_call(psa_handle_t handle, - const psa_invec_t *in_vec, - size_t in_len, - const psa_outvec_t *out_vec, - size_t out_len - ) +psa_status_t psa_call(psa_handle_t handle, + const psa_invec *in_vec, + size_t in_len, + const psa_outvec *out_vec, + size_t out_len + ) { // - Immediate errors are checked here. // - Other errors are checked on the SPM core code diff --git a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_mailbox_nspe.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_mailbox_nspe.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_mailbox_nspe.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_NSPE/spm_mailbox_nspe.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_SPE/spm_mailbox_spe.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_SPE/spm_mailbox_spe.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/COMPONENT_SPE/spm_mailbox_spe.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/COMPONENT_SPE/spm_mailbox_spe.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/ipc_defs.h b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/ipc_defs.h similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/ipc_defs.h rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/ipc_defs.h diff --git a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/ipc_queue.c b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/ipc_queue.c similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/ipc_queue.c rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/ipc_queue.c diff --git a/components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/ipc_queue.h b/components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/ipc_queue.h similarity index 100% rename from components/TARGET_PSA/spm/COMPONENT_SPM_MAILBOX/ipc_queue.h rename to components/TARGET_PSA/TARGET_MBED_SPM/COMPONENT_SPM_MAILBOX/ipc_queue.h diff --git a/components/TARGET_PSA/spm/mbed_lib.json b/components/TARGET_PSA/TARGET_MBED_SPM/mbed_lib.json similarity index 100% rename from components/TARGET_PSA/spm/mbed_lib.json rename to components/TARGET_PSA/TARGET_MBED_SPM/mbed_lib.json diff --git a/components/TARGET_PSA/spm/psa_defs.h b/components/TARGET_PSA/TARGET_MBED_SPM/psa_defs.h similarity index 88% rename from components/TARGET_PSA/spm/psa_defs.h rename to components/TARGET_PSA/TARGET_MBED_SPM/psa_defs.h index e282570f718..a8967331052 100644 --- a/components/TARGET_PSA/spm/psa_defs.h +++ b/components/TARGET_PSA/TARGET_MBED_SPM/psa_defs.h @@ -50,7 +50,7 @@ extern "C" { #define PSA_NULL_HANDLE ((psa_handle_t)0) /**< Denotes an invalid handle.*/ -#define PSA_MAX_IOVEC (4UL) /**< Maximum number of psa_invec_t and psa_outvec_t structures allowed for psa_call().*/ +#define PSA_MAX_IOVEC (4UL) /**< Maximum number of psa_invec and psa_outvec structures allowed for psa_call().*/ #define PSA_POLL (0x00000000UL) /**< Returns immediately even if none of the requested signals is asserted.*/ #define PSA_BLOCK (0x80000000UL) /**< Block the caller until one of the requested signals is asserted.*/ @@ -61,7 +61,6 @@ extern "C" { #define PSA_DOORBELL (0x00000008UL) /**< Mask for PSA_DOORBELL signal.*/ #define PSA_SUCCESS (0L) /**< A general result code for calls to psa_call() indicating success.*/ -#define PSA_CONNECTION_ACCEPTED (0L) /**< The result code for calls to psa_connect() indicating the acceptance of a new connection request.*/ #define PSA_IPC_CONNECT (1) /**< The IPC message type that indicates a new connection.*/ #define PSA_IPC_CALL (2) /**< The IPC message type that indicates a client request.*/ #define PSA_IPC_DISCONNECT (3) /**< The IPC message type that indicates the end of a connection.*/ @@ -69,16 +68,16 @@ extern "C" { /* Error codes */ #define PSA_DROP_CONNECTION (INT32_MIN) /**< The result code in a call to psa_reply() to indicate a nonrecoverable error in the client.*/ -#define PSA_CONNECTION_REFUSED (INT32_MIN + 1) /**< The return value from psa_connect() if the RoT Service or SPM was unable to establish a connection.*/ - +#define PSA_CONNECTION_REFUSED (INT32_MIN + 1) /**< The return value from psa_connect() if the RoT Service or SPM was unable to establish a connection.*/ +#define PSA_CONNECTION_BUSY (INT32_MIN + 2) /**< The return value from psa_connect() if the RoT Service rejects the connection for a transient reason.*/ #define PSA_UNUSED(var) ((void)(var)) /* -------------------------------------- Typedefs ----------------------------------- */ typedef uint32_t psa_signal_t; -typedef int32_t psa_error_t; +typedef int32_t psa_status_t; typedef int32_t psa_handle_t; -typedef psa_error_t error_t; +typedef psa_status_t error_t; /* -------------------------------------- Structs ------------------------------------ */ @@ -99,7 +98,7 @@ typedef struct psa_msg { typedef struct psa_invec { const void *base; /**< Starting address of the buffer.*/ size_t len; /**< Length in bytes of the buffer.*/ -} psa_invec_t; +} psa_invec; /** * Structure which describes a scatter-gather output buffer. @@ -107,7 +106,7 @@ typedef struct psa_invec { typedef struct psa_outvec { void *base; /**< Starting address of the buffer.*/ size_t len; /**< Length in bytes of the buffer.*/ -} psa_outvec_t; +} psa_outvec; #ifdef __cplusplus } diff --git a/components/TARGET_PSA/spm/spm_client.h b/components/TARGET_PSA/TARGET_MBED_SPM/spm_client.h similarity index 85% rename from components/TARGET_PSA/spm/spm_client.h rename to components/TARGET_PSA/TARGET_MBED_SPM/spm_client.h index 2213a698428..5cb0f3011d7 100644 --- a/components/TARGET_PSA/spm/spm_client.h +++ b/components/TARGET_PSA/TARGET_MBED_SPM/spm_client.h @@ -73,23 +73,23 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version); /** * Call a connected Root of Trust Service.@n - * The caller must provide an array of ::psa_invec_t structures as the input payload. + * The caller must provide an array of ::psa_invec structures as the input payload. * * @param[in] handle Handle for the connection. - * @param[in] in_vec Array of ::psa_invec_t structures. - * @param[in] in_len Number of ::psa_invec_t structures in in_vec. (At most ::PSA_MAX_IOVEC - out_len) - * @param[out] out_vec Array of ::psa_outvec_t structures for optional Root of Trust Service response. - * @param[in] out_len Number of ::psa_outvec_t structures in out_vec. (At most ::PSA_MAX_IOVEC - in_len) + * @param[in] in_vec Array of ::psa_invec structures. + * @param[in] in_len Number of ::psa_invec structures in in_vec. (At most ::PSA_MAX_IOVEC - out_len) + * @param[out] out_vec Array of ::psa_outvec structures for optional Root of Trust Service response. + * @param[in] out_len Number of ::psa_outvec structures in out_vec. (At most ::PSA_MAX_IOVEC - in_len) * @return 0 for success or@n * @a positive numbers for application-specific return code. * @a negative numbers for application-specific error code. * @a PSA_DROP_CONNECTION if the connection has been dropped by the RoT Service. */ -psa_error_t psa_call( +psa_status_t psa_call( psa_handle_t handle, - const psa_invec_t *in_vec, + const psa_invec *in_vec, size_t in_len, - const psa_outvec_t *out_vec, + const psa_outvec *out_vec, size_t out_len ); diff --git a/components/TARGET_PSA/spm/spm_init.h b/components/TARGET_PSA/TARGET_MBED_SPM/spm_init.h similarity index 100% rename from components/TARGET_PSA/spm/spm_init.h rename to components/TARGET_PSA/TARGET_MBED_SPM/spm_init.h diff --git a/components/TARGET_PSA/spm/spm_messages.h b/components/TARGET_PSA/TARGET_MBED_SPM/spm_messages.h similarity index 89% rename from components/TARGET_PSA/spm/spm_messages.h rename to components/TARGET_PSA/TARGET_MBED_SPM/spm_messages.h index 96b5743032f..66c29a38e64 100644 --- a/components/TARGET_PSA/spm/spm_messages.h +++ b/components/TARGET_PSA/TARGET_MBED_SPM/spm_messages.h @@ -29,11 +29,11 @@ * Structure containing data sent from NSPE for ROT_SRV call. */ typedef __PACKED_STRUCT spm_pending_call_msg { - const psa_invec_t *in_vec; /* Invecs sent.*/ + const psa_invec *in_vec; /* Invecs sent.*/ uint32_t in_vec_size; /* Number of Invecs sent.*/ - const psa_outvec_t *out_vec; /* Outvecs for response.*/ + const psa_outvec *out_vec; /* Outvecs for response.*/ uint32_t out_vec_size; /* Number of Outvecs for response.*/ - psa_error_t rc; /* Return code to be filled by the Root of Trust Service.*/ + psa_status_t rc; /* Return code to be filled by the Root of Trust Service.*/ osSemaphoreId_t completion_sem_id; /* Semaphore to be released at the end of execution */ } __ALIGNED(4) spm_pending_call_msg_t; @@ -42,7 +42,7 @@ typedef __PACKED_STRUCT spm_pending_call_msg { */ typedef __PACKED_STRUCT spm_pending_connect_msg { uint32_t min_version; /* Minor version of the Root of Trust Service interface.*/ - psa_error_t rc; /* Return code to be filled by the Root of Trust Service.*/ + psa_status_t rc; /* Return code to be filled by the Root of Trust Service.*/ osSemaphoreId_t completion_sem_id; /* Semaphore to be released at the end of execution */ } __ALIGNED(4) spm_pending_connect_msg_t; diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h index 8b20939da70..f1d0e826339 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h +++ b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h @@ -1,5 +1,3 @@ -#include "spm/psa_defs.h" - /** * \file psa/crypto_struct.h * @@ -27,6 +25,8 @@ #ifndef PSA_CRYPTO_STRUCT_H #define PSA_CRYPTO_STRUCT_H +#include "psa/client.h" + struct psa_hash_operation_s { psa_handle_t handle; }; diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c index d7349038746..f5f050bad22 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c +++ b/components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c @@ -25,8 +25,7 @@ #include #include "psa_crypto_srv_ifs.h" -#include "spm/psa_defs.h" -#include "spm/spm_client.h" +#include "psa/client.h" #include "crypto.h" #include "crypto_platform_spe.h" @@ -35,7 +34,7 @@ psa_status_t psa_crypto_init(void) { - psa_error_t err_call; + psa_status_t err_call; psa_handle_t handle = PSA_NULL_HANDLE; handle = psa_connect(PSA_CRYPTO_INIT_ID, MINOR_VER); @@ -47,7 +46,7 @@ psa_status_t psa_crypto_init(void) psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -59,7 +58,7 @@ psa_status_t psa_crypto_init(void) psa_status_t psa_mac_abort(psa_mac_operation_t *operation) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; if (operation->handle <= 0) { @@ -68,14 +67,14 @@ psa_status_t psa_mac_abort(psa_mac_operation_t *operation) psa_crypto_ipc.func = PSA_MAC_ABORT; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; err_call = psa_call(operation->handle, &in_vec, 1, NULL, 0); psa_close(operation->handle); operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -86,14 +85,14 @@ static psa_status_t psa_mac_setup(psa_mac_operation_t *operation, psa_algorithm_t alg, psa_sec_function_t func) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = func; psa_crypto_ipc.key = key; psa_crypto_ipc.alg = alg; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; operation->handle = psa_connect(PSA_MAC_ID, MINOR_VER); @@ -133,12 +132,12 @@ psa_status_t psa_mac_update(psa_mac_operation_t *operation, const uint8_t *input, size_t input_length) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_MAC_UPDATE; - psa_invec_t in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { input, input_length } }; @@ -159,15 +158,15 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, size_t mac_size, size_t *mac_length) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_MAC_SIGN_FINISH; - psa_invec_t in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { &mac_size, sizeof(mac_size) } }; - psa_outvec_t out_vec[2] = { { mac, mac_size }, { mac_length, sizeof(*mac_length) } }; + psa_outvec out_vec[2] = { { mac, mac_size }, { mac_length, sizeof(*mac_length) } }; if (operation->handle <= 0) { return (PSA_ERROR_INVALID_ARGUMENT); @@ -178,7 +177,7 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -188,12 +187,12 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_MAC_VERIFY_FINISH; - psa_invec_t in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { &mac_length, sizeof(mac_length) }, { mac, mac_length } }; @@ -207,7 +206,7 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -220,7 +219,7 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, psa_status_t psa_hash_abort(psa_hash_operation_t *operation) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; if (operation->handle <= 0) { @@ -229,14 +228,14 @@ psa_status_t psa_hash_abort(psa_hash_operation_t *operation) psa_crypto_ipc.func = PSA_HASH_ABORT; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; err_call = psa_call(operation->handle, &in_vec, 1, NULL, 0); psa_close(operation->handle); operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -245,13 +244,13 @@ psa_status_t psa_hash_abort(psa_hash_operation_t *operation) psa_status_t psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_HASH_SETUP; psa_crypto_ipc.alg = alg; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; operation->handle = psa_connect(PSA_HASH_ID, MINOR_VER); if (operation->handle <= 0) { @@ -270,12 +269,12 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_HASH_UPDATE; - psa_invec_t in_vec[2] = { {&psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[2] = { {&psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { input, input_length } }; @@ -296,15 +295,15 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation, size_t hash_size, size_t *hash_length) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_HASH_FINISH; - psa_invec_t in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { &hash_size, sizeof(hash_size) } }; - psa_outvec_t out_vec[2] = { { hash, hash_size }, + psa_outvec out_vec[2] = { { hash, hash_size }, { hash_length, sizeof(*hash_length) } }; @@ -317,7 +316,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation, operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -327,12 +326,12 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; psa_crypto_ipc.func = PSA_HASH_VERIFY; - psa_invec_t in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc_t) }, + psa_invec in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc_t) }, { &hash_length, sizeof(hash_length) }, { hash, hash_length } }; @@ -346,7 +345,7 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation, operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -369,10 +368,10 @@ psa_status_t psa_aead_encrypt(psa_key_slot_t key, size_t *ciphertext_length) { psa_handle_t handle = PSA_NULL_HANDLE; - psa_error_t call_error = PSA_SUCCESS; + psa_status_t call_error = PSA_SUCCESS; psa_crypto_ipc_aead_t psa_crypto_ipc = { 0, 0, 0, 0, 0, 0, { 0 } }; - psa_invec_t in_vec[2]; - psa_outvec_t out_vec[2]; + psa_invec in_vec[2]; + psa_outvec out_vec[2]; psa_crypto_ipc.func = PSA_AEAD_ENCRYPT; psa_crypto_ipc.key = key; @@ -397,19 +396,19 @@ psa_status_t psa_aead_encrypt(psa_key_slot_t key, memcpy(buffer + additional_data_length, plaintext, plaintext_length); - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc_aead_t) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { buffer, additional_data_length + plaintext_length }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { ciphertext, ciphertext_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { ciphertext_length, sizeof(*ciphertext_length) }; @@ -423,7 +422,7 @@ psa_status_t psa_aead_encrypt(psa_key_slot_t key, psa_close(handle); if (call_error < 0) { - call_error = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + call_error = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t)call_error); } @@ -442,10 +441,10 @@ psa_status_t psa_aead_decrypt(psa_key_slot_t key, size_t *plaintext_length) { psa_handle_t handle = PSA_NULL_HANDLE; - psa_error_t call_error = PSA_SUCCESS; + psa_status_t call_error = PSA_SUCCESS; psa_crypto_ipc_aead_t psa_crypto_ipc = { 0, 0, 0, 0, 0, 0, { 0 } }; - psa_invec_t in_vec[2]; - psa_outvec_t out_vec[2]; + psa_invec in_vec[2]; + psa_outvec out_vec[2]; psa_crypto_ipc.func = PSA_AEAD_DECRYPT; psa_crypto_ipc.key = key; @@ -469,19 +468,19 @@ psa_status_t psa_aead_decrypt(psa_key_slot_t key, memcpy(buffer, additional_data, additional_data_length); memcpy(buffer + additional_data_length, ciphertext, ciphertext_length); - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc_aead_t) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { buffer, additional_data_length + ciphertext_length }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { plaintext, plaintext_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { plaintext_length, sizeof(*plaintext_length) }; @@ -495,7 +494,7 @@ psa_status_t psa_aead_decrypt(psa_key_slot_t key, psa_close(handle); if (call_error < 0) { - call_error = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + call_error = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t)call_error); } @@ -513,26 +512,26 @@ psa_status_t psa_asymmetric_sign(psa_key_slot_t key, size_t *signature_length) { psa_handle_t handle = PSA_NULL_HANDLE; - psa_error_t call_error = PSA_SUCCESS; + psa_status_t call_error = PSA_SUCCESS; psa_crypto_ipc_asymmetric_t psa_crypto_ipc = { 0, 0, 0, 0, 0 }; - psa_invec_t in_vec[2]; - psa_outvec_t out_vec[2]; + psa_invec in_vec[2]; + psa_outvec out_vec[2]; psa_crypto_ipc.func = PSA_ASYMMETRIC_SIGN; psa_crypto_ipc.key = key; psa_crypto_ipc.alg = alg; - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc_asymmetric_t) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { hash, hash_length }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { signature, signature_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { signature_length, sizeof(*signature_length) }; @@ -546,7 +545,7 @@ psa_status_t psa_asymmetric_sign(psa_key_slot_t key, psa_close(handle); if (call_error < 0) { - call_error = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + call_error = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t)call_error); } @@ -559,22 +558,22 @@ psa_status_t psa_asymmetric_verify(psa_key_slot_t key, size_t signature_size) { psa_handle_t handle = PSA_NULL_HANDLE; - psa_error_t call_error = PSA_SUCCESS; + psa_status_t call_error = PSA_SUCCESS; psa_crypto_ipc_asymmetric_t psa_crypto_ipc = { 0, 0, 0, 0, 0 }; - psa_invec_t in_vec[3]; + psa_invec in_vec[3]; psa_crypto_ipc.func = PSA_ASYMMETRIC_VERIFY; psa_crypto_ipc.key = key; psa_crypto_ipc.alg = alg; - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc_asymmetric_t) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { signature, signature_size }; - in_vec[2] = (psa_invec_t) { + in_vec[2] = (psa_invec) { hash, hash_length }; handle = psa_connect(PSA_ASYMMETRIC_ID, MINOR_VER); @@ -585,7 +584,7 @@ psa_status_t psa_asymmetric_verify(psa_key_slot_t key, psa_close(handle); if (call_error < 0) { - call_error = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + call_error = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t)call_error); } @@ -602,10 +601,10 @@ static psa_status_t psa_asymmetric_operation(psa_sec_function_t func, size_t *output_length) { psa_handle_t handle = PSA_NULL_HANDLE; - psa_error_t call_error = PSA_SUCCESS; + psa_status_t call_error = PSA_SUCCESS; psa_crypto_ipc_asymmetric_t psa_crypto_ipc = { 0, 0, 0, 0, 0 }; - psa_invec_t in_vec[2]; - psa_outvec_t out_vec[2]; + psa_invec in_vec[2]; + psa_outvec out_vec[2]; psa_crypto_ipc.func = func; psa_crypto_ipc.key = key; @@ -621,18 +620,18 @@ static psa_status_t psa_asymmetric_operation(psa_sec_function_t func, memcpy(buffer, input, input_length); memcpy(buffer + input_length, salt, salt_length); - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc_asymmetric_t) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { buffer, input_length + salt_length }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { output, output_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { output_length, sizeof(*output_length) }; @@ -646,7 +645,7 @@ static psa_status_t psa_asymmetric_operation(psa_sec_function_t func, psa_close(handle); if (call_error < 0) { - call_error = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + call_error = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t)call_error); } @@ -692,16 +691,16 @@ psa_status_t psa_asymmetric_decrypt(psa_key_slot_t key, psa_status_t psa_get_key_lifetime(psa_key_slot_t key, psa_key_lifetime_t *lifetime) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = PSA_GET_KEY_LIFETIME; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[1] = { + psa_invec in_vec[1] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) } }; - psa_outvec_t out_vec[1] = { { + psa_outvec out_vec[1] = { { lifetime, (lifetime == NULL ? 0 : sizeof(*lifetime)) } @@ -716,7 +715,7 @@ psa_status_t psa_get_key_lifetime(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -724,13 +723,13 @@ psa_status_t psa_get_key_lifetime(psa_key_slot_t key, psa_status_t psa_set_key_lifetime(psa_key_slot_t key, psa_key_lifetime_t lifetime) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = PSA_SET_KEY_LIFETIME; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[2] = { + psa_invec in_vec[2] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) }, { &lifetime, sizeof(psa_key_lifetime_t) } }; @@ -744,7 +743,7 @@ psa_status_t psa_set_key_lifetime(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -778,13 +777,13 @@ void psa_key_policy_set_usage(psa_key_policy_t *policy, psa_status_t psa_set_key_policy(psa_key_slot_t key, const psa_key_policy_t *policy) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = PSA_SET_KEY_POLICY; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[2] = { + psa_invec in_vec[2] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) }, { policy, (policy == NULL ? 0 : sizeof(*policy)) } }; @@ -798,7 +797,7 @@ psa_status_t psa_set_key_policy(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -806,18 +805,18 @@ psa_status_t psa_set_key_policy(psa_key_slot_t key, psa_status_t psa_get_key_policy(psa_key_slot_t key, psa_key_policy_t *policy) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = PSA_GET_KEY_POLICY; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[1] = { { + psa_invec in_vec[1] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) } }; - psa_outvec_t out_vec[1] = { { + psa_outvec out_vec[1] = { { policy, (policy == NULL ? 0 : sizeof(*policy)) } @@ -832,7 +831,7 @@ psa_status_t psa_get_key_policy(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -842,13 +841,13 @@ psa_status_t psa_import_key(psa_key_slot_t key, const uint8_t *data, size_t data_length) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = type; psa_key_mng_ipc.func = PSA_IMPORT_KEY; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[2] = { + psa_invec in_vec[2] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) }, { data, data_length } }; @@ -862,20 +861,20 @@ psa_status_t psa_import_key(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } psa_status_t psa_destroy_key(psa_key_slot_t key) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = PSA_DESTROY_KEY; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[1] = { + psa_invec in_vec[1] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) } }; @@ -888,7 +887,7 @@ psa_status_t psa_destroy_key(psa_key_slot_t key) psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -897,18 +896,18 @@ psa_status_t psa_get_key_information(psa_key_slot_t key, psa_key_type_t *type, size_t *bits) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = PSA_GET_KEY_INFORMATION; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[1] = { { + psa_invec in_vec[1] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) } }; - psa_outvec_t out_vec[2] = { { + psa_outvec out_vec[2] = { { type, (type == NULL ? 0 : sizeof(psa_key_type_t)) }, @@ -927,7 +926,7 @@ psa_status_t psa_get_key_information(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -938,15 +937,15 @@ static psa_status_t psa_export_key_common(psa_key_slot_t key, size_t *data_length, psa_sec_function_t func) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = 0; psa_key_mng_ipc.func = func; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[1] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) } }; - psa_outvec_t out_vec[2] = { { data, data_size }, + psa_invec in_vec[1] = { { &psa_key_mng_ipc, sizeof(psa_key_mng_ipc_t) } }; + psa_outvec out_vec[2] = { { data, data_size }, { data_length, sizeof(*data_length) } }; @@ -959,7 +958,7 @@ static psa_status_t psa_export_key_common(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -991,13 +990,13 @@ psa_status_t psa_generate_key(psa_key_slot_t key, const void *parameters, size_t parameters_size) { - psa_error_t err_call; + psa_status_t err_call; psa_key_mng_ipc_t psa_key_mng_ipc = { 0, 0, 0 }; psa_key_mng_ipc.key = key; psa_key_mng_ipc.type = type; psa_key_mng_ipc.func = PSA_GENERATE_KEY; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec[3]; + psa_invec in_vec[3]; in_vec[0].base = &psa_key_mng_ipc; in_vec[0].len = sizeof(psa_key_mng_ipc_t); in_vec[1].base = &bits; @@ -1024,7 +1023,7 @@ psa_status_t psa_generate_key(psa_key_slot_t key, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -1036,9 +1035,9 @@ psa_status_t psa_generate_key(psa_key_slot_t key, psa_status_t psa_generate_random(uint8_t *output, size_t output_size) { - psa_error_t err_call; + psa_status_t err_call; psa_handle_t handle = PSA_NULL_HANDLE; - psa_outvec_t out_vec[1] = { { output, output_size } }; + psa_outvec out_vec[1] = { { output, output_size } }; handle = psa_connect(PSA_RNG_ID, MINOR_VER); if (handle <= 0) { @@ -1049,7 +1048,7 @@ psa_status_t psa_generate_random(uint8_t *output, psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -1061,9 +1060,9 @@ psa_status_t psa_generate_random(uint8_t *output, psa_status_t mbedtls_psa_inject_entropy(const unsigned char *seed, size_t seed_size) { - psa_error_t err_call; + psa_status_t err_call; psa_handle_t handle = PSA_NULL_HANDLE; - psa_invec_t in_vec = { seed, seed_size }; + psa_invec in_vec = { seed, seed_size }; handle = psa_connect(PSA_ENTROPY_ID, MINOR_VER); if (handle <= 0) { @@ -1073,7 +1072,7 @@ psa_status_t mbedtls_psa_inject_entropy(const unsigned char *seed, err_call = psa_call(handle, &in_vec, 1, NULL, 0); psa_close(handle); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -1084,11 +1083,11 @@ psa_status_t mbedtls_psa_inject_entropy(const unsigned char *seed, psa_status_t psa_get_generator_capacity(const psa_crypto_generator_t *generator, size_t *capacity) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_derivation_ipc_t psa_crypto_ipc = { 0, 0, 0, 0 }; psa_crypto_ipc.func = PSA_GET_GENERATOR_CAPACITY; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; - psa_outvec_t out_vec = { capacity, sizeof(*capacity) }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_outvec out_vec = { capacity, sizeof(*capacity) }; if (generator->handle <= 0) { return (PSA_ERROR_INVALID_ARGUMENT); @@ -1097,7 +1096,7 @@ psa_status_t psa_get_generator_capacity(const psa_crypto_generator_t *generator, err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -1106,11 +1105,11 @@ psa_status_t psa_generator_read(psa_crypto_generator_t *generator, uint8_t *output, size_t output_length) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_derivation_ipc_t psa_crypto_ipc = { 0, 0, 0, 0 }; psa_crypto_ipc.func = PSA_GENERATOR_READ; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; - psa_outvec_t out_vec = { output, output_length }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_outvec out_vec = { output, output_length }; if (generator->handle <= 0) { return (PSA_ERROR_INVALID_ARGUMENT); @@ -1119,7 +1118,7 @@ psa_status_t psa_generator_read(psa_crypto_generator_t *generator, err_call = psa_call(generator->handle, &in_vec, 1, &out_vec, 1); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -1129,11 +1128,11 @@ psa_status_t psa_generator_import_key(psa_key_slot_t key, size_t bits, psa_crypto_generator_t *generator) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_derivation_ipc_t psa_crypto_ipc = { 0, 0, 0, 0 }; psa_crypto_ipc.key = key; psa_crypto_ipc.func = PSA_GENERATOR_IMPORT_KEY; - psa_invec_t in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { &type, sizeof(type) }, { &bits, sizeof(bits) } }; @@ -1145,7 +1144,7 @@ psa_status_t psa_generator_import_key(psa_key_slot_t key, err_call = psa_call(generator->handle, in_vec, 3, NULL, 0); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } @@ -1159,14 +1158,14 @@ psa_status_t psa_key_derivation(psa_crypto_generator_t *generator, size_t label_length, size_t capacity) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_derivation_ipc_t psa_crypto_ipc = { 0, 0, 0, 0 }; psa_crypto_ipc.key = key; psa_crypto_ipc.alg = alg; psa_crypto_ipc.func = PSA_KEY_DERIVATION; psa_crypto_ipc.capacity = capacity; - psa_invec_t in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[3] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { salt, salt_length }, { label, label_length } }; @@ -1179,7 +1178,7 @@ psa_status_t psa_key_derivation(psa_crypto_generator_t *generator, err_call = psa_call(generator->handle, in_vec, 3, NULL, 0); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -1191,13 +1190,13 @@ psa_status_t psa_key_agreement(psa_crypto_generator_t *generator, size_t peer_key_length, psa_algorithm_t alg) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_derivation_ipc_t psa_crypto_ipc = { 0, 0, 0, 0 }; psa_crypto_ipc.key = private_key; psa_crypto_ipc.alg = alg; psa_crypto_ipc.func = PSA_KEY_AGREEMENT; - psa_invec_t in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, + psa_invec in_vec[2] = { { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }, { peer_key, peer_key_length } }; @@ -1209,24 +1208,24 @@ psa_status_t psa_key_agreement(psa_crypto_generator_t *generator, err_call = psa_call(generator->handle, in_vec, 2, NULL, 0); if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } psa_status_t psa_generator_abort(psa_crypto_generator_t *generator) { - psa_error_t err_call = PSA_SUCCESS; + psa_status_t err_call = PSA_SUCCESS; psa_crypto_derivation_ipc_t psa_crypto_ipc = { 0, 0, 0, 0 }; psa_crypto_ipc.func = PSA_GENERATOR_ABORT; - psa_invec_t in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; + psa_invec in_vec = { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; if (generator->handle != PSA_NULL_HANDLE) { err_call = psa_call(generator->handle, &in_vec, 1, NULL, 0); psa_close(generator->handle); generator->handle = PSA_NULL_HANDLE; } if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); @@ -1241,9 +1240,9 @@ psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, psa_key_slot_t key, psa_algorithm_t alg) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec; + psa_invec in_vec; psa_crypto_ipc.func = PSA_CIPHER_ENCRYPT_SETUP; psa_crypto_ipc.key = key; @@ -1259,7 +1258,7 @@ psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, err = psa_call(operation->handle, &in_vec, 1, NULL, 0); if (err < 0) { - err = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err); } @@ -1268,15 +1267,15 @@ psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, psa_key_slot_t key, psa_algorithm_t alg) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec; + psa_invec in_vec; psa_crypto_ipc.func = PSA_CIPHER_DECRYPT_SETUP; psa_crypto_ipc.key = key; psa_crypto_ipc.alg = alg; - in_vec = (psa_invec_t) { + in_vec = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; @@ -1288,7 +1287,7 @@ psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, err = psa_call(operation->handle, &in_vec, 1, NULL, 0); if (err < 0) { - err = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err); } @@ -1298,21 +1297,21 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, size_t iv_size, size_t *iv_length) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec; - psa_outvec_t out_vec[2]; + psa_invec in_vec; + psa_outvec out_vec[2]; psa_crypto_ipc.func = PSA_CIPHER_GENERATE_IV; - in_vec = (psa_invec_t) { + in_vec = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { iv, iv_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { iv_length, sizeof(*iv_length) }; @@ -1322,7 +1321,7 @@ psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, err = psa_call(operation->handle, &in_vec, 1, out_vec, 2); if (err < 0) { - err = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err); } @@ -1331,16 +1330,16 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const unsigned char *iv, size_t iv_length) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec[2]; + psa_invec in_vec[2]; psa_crypto_ipc.func = PSA_CIPHER_SET_IV; - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { iv, iv_length }; @@ -1350,7 +1349,7 @@ psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, err = psa_call(operation->handle, in_vec, 2, NULL, 0); if (err < 0) { - err = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err); } @@ -1362,24 +1361,24 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, size_t output_size, size_t *output_length) { - psa_error_t err; + psa_status_t err; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec[2]; - psa_outvec_t out_vec[2]; + psa_invec in_vec[2]; + psa_outvec out_vec[2]; psa_crypto_ipc.func = PSA_CIPHER_UPDATE; - in_vec[0] = (psa_invec_t) { + in_vec[0] = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; - in_vec[1] = (psa_invec_t) { + in_vec[1] = (psa_invec) { input, input_length }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { output, output_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { output_length, (output_length == NULL ? 0 : sizeof(*output_length)) }; @@ -1390,7 +1389,7 @@ psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, err = psa_call(operation->handle, in_vec, 2, out_vec, 2); if (err < 0) { - err = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err); } @@ -1400,21 +1399,21 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, size_t output_size, size_t *output_length) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec; - psa_outvec_t out_vec[2]; + psa_invec in_vec; + psa_outvec out_vec[2]; psa_crypto_ipc.func = PSA_CIPHER_FINISH; - in_vec = (psa_invec_t) { + in_vec = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; - out_vec[0] = (psa_outvec_t) { + out_vec[0] = (psa_outvec) { output, output_size }; - out_vec[1] = (psa_outvec_t) { + out_vec[1] = (psa_outvec) { output_length, (output_length == NULL ? 0 : sizeof(*output_length)) }; @@ -1427,16 +1426,16 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, psa_close(operation->handle); operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation) { - psa_error_t err_call; + psa_status_t err_call; psa_crypto_ipc_t psa_crypto_ipc = { 0, 0, 0 }; - psa_invec_t in_vec; + psa_invec in_vec; if (operation->handle <= 0) { return (PSA_SUCCESS); @@ -1444,7 +1443,7 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation) psa_crypto_ipc.func = PSA_CIPHER_ABORT; - in_vec = (psa_invec_t) { + in_vec = (psa_invec) { &psa_crypto_ipc, sizeof(psa_crypto_ipc) }; @@ -1452,7 +1451,7 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation) psa_close(operation->handle); operation->handle = PSA_NULL_HANDLE; if (err_call < 0) { - err_call = (psa_error_t) PSA_ERROR_COMMUNICATION_FAILURE; + err_call = (psa_status_t) PSA_ERROR_COMMUNICATION_FAILURE; } return ((psa_status_t) err_call); } diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_srv_partition.c b/components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c similarity index 99% rename from components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_srv_partition.c rename to components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c index fdba6a48f17..4e388950b68 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_srv_partition.c +++ b/components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -227,3 +229,5 @@ void crypto_srv_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition crypto_srv!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_partition.c b/components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_partition.c index 36ac8803f06..49e8809e68b 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_partition.c +++ b/components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_partition.c @@ -1,8 +1,7 @@ // ---------------------------------- Includes --------------------------------- +#include "psa/service.h" +#include "psa/client.h" #include "spm_panic.h" -#include "spm_server.h" -#include "spm/psa_defs.h" -#include "spm/spm_client.h" #define PSA_CRYPTO_SECURE 1 #include "crypto_spe.h" @@ -47,7 +46,7 @@ static void psa_crypto_init_operation(void) } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } static void psa_crypto_free_operation(void) @@ -83,7 +82,7 @@ static void psa_crypto_free_operation(void) } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } static void psa_mac_operation(void) @@ -238,7 +237,7 @@ static void psa_mac_operation(void) } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } static void psa_hash_operation(void) @@ -568,7 +567,7 @@ static void psa_asymmetric_operation(void) } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } static void psa_aead_operation() @@ -677,7 +676,7 @@ static void psa_aead_operation() } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } static void psa_symmetric_operation(void) @@ -847,7 +846,7 @@ static void psa_symmetric_operation(void) } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } @@ -1334,7 +1333,7 @@ void psa_crypto_generator_operations(void) } } - psa_reply(msg.handle, (psa_error_t) status); + psa_reply(msg.handle, (psa_status_t) status); } diff --git a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_PSA_SRV_IPC/psa_prot_internal_storage.c b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_PSA_SRV_IPC/psa_prot_internal_storage.c index af2aed4fd30..2f9e62385b0 100644 --- a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_PSA_SRV_IPC/psa_prot_internal_storage.c +++ b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_PSA_SRV_IPC/psa_prot_internal_storage.c @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "spm_client.h" +#include "psa/client.h" #include "psa_prot_internal_storage.h" #include "psa_its_ifs.h" @@ -25,7 +25,7 @@ psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_d return PSA_ITS_ERROR_BAD_POINTER; } - psa_invec_t msg[3] = { + psa_invec msg[3] = { { &uid, sizeof(uid) }, { p_data, data_length }, { &create_flags, sizeof(create_flags) } @@ -36,7 +36,7 @@ psa_its_status_t psa_its_set(uint32_t uid, uint32_t data_length, const void *p_d return PSA_ITS_ERROR_STORAGE_FAILURE; } - psa_error_t status = psa_call(conn, msg, 3, NULL, 0); + psa_status_t status = psa_call(conn, msg, 3, NULL, 0); if (status == PSA_DROP_CONNECTION) { status = PSA_ITS_ERROR_STORAGE_FAILURE; } @@ -51,18 +51,18 @@ psa_its_status_t psa_its_get(uint32_t uid, uint32_t data_offset, uint32_t data_l return PSA_ITS_ERROR_BAD_POINTER; } - psa_invec_t msg[2] = { + psa_invec msg[2] = { { &uid, sizeof(uid) }, { &data_offset, sizeof(data_offset) } }; - psa_outvec_t resp = { p_data, data_length }; + psa_outvec resp = { p_data, data_length }; psa_handle_t conn = psa_connect(PSA_ITS_GET, 1); if (conn <= PSA_NULL_HANDLE) { return PSA_ITS_ERROR_STORAGE_FAILURE; } - psa_error_t status = psa_call(conn, msg, 2, &resp, 1); + psa_status_t status = psa_call(conn, msg, 2, &resp, 1); if (status == PSA_DROP_CONNECTION) { status = PSA_ITS_ERROR_STORAGE_FAILURE; @@ -79,14 +79,14 @@ psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info) } struct psa_its_info_t info = { 0 }; - psa_invec_t msg = { &uid, sizeof(uid) }; - psa_outvec_t resp = { &info, sizeof(info) }; + psa_invec msg = { &uid, sizeof(uid) }; + psa_outvec resp = { &info, sizeof(info) }; psa_handle_t conn = psa_connect(PSA_ITS_INFO, 1); if (conn <= PSA_NULL_HANDLE) { return PSA_ITS_ERROR_STORAGE_FAILURE; } - psa_error_t status = psa_call(conn, &msg, 1, &resp, 1); + psa_status_t status = psa_call(conn, &msg, 1, &resp, 1); *p_info = info; @@ -100,13 +100,13 @@ psa_its_status_t psa_its_get_info(uint32_t uid, struct psa_its_info_t *p_info) psa_its_status_t psa_its_remove(uint32_t uid) { - psa_invec_t msg = { &uid, sizeof(uid) }; + psa_invec msg = { &uid, sizeof(uid) }; psa_handle_t conn = psa_connect(PSA_ITS_REMOVE, 1); if (conn <= PSA_NULL_HANDLE) { return PSA_ITS_ERROR_STORAGE_FAILURE; } - psa_error_t status = psa_call(conn, &msg, 1, NULL, 0); + psa_status_t status = psa_call(conn, &msg, 1, NULL, 0); if (status == PSA_DROP_CONNECTION) { status = PSA_ITS_ERROR_STORAGE_FAILURE; } diff --git a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/psa_its_partition.c b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c similarity index 98% rename from components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/psa_its_partition.c rename to components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c index 0fcd2952479..1f0a76703d0 100644 --- a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/psa_its_partition.c +++ b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -135,3 +137,5 @@ void its_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition its!\n"); } } + +#endif // !defined(TARGET_TFM) diff --git a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/its_partition.c b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/its_partition.c index ab8799f509e..531b5d6946e 100644 --- a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/its_partition.c +++ b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/its_partition.c @@ -16,9 +16,8 @@ */ #include -#include "cmsis_os2.h" -#include "spm_server.h" -#include "spm_panic.h" +#include "psa/client.h" +#include "psa/service.h" #include "psa_its_partition.h" #include "psa_prot_internal_storage.h" #include "pits_impl.h" @@ -30,9 +29,9 @@ extern "C" { #endif -typedef psa_error_t (*SignalHandler)(psa_msg_t *); +typedef psa_status_t (*SignalHandler)(psa_msg_t *); -static psa_error_t storage_set(psa_msg_t *msg) +static psa_status_t storage_set(psa_msg_t *msg) { uint32_t key = 0; void *data = NULL; @@ -68,7 +67,7 @@ static psa_error_t storage_set(psa_msg_t *msg) return status; } -static psa_error_t storage_get(psa_msg_t *msg) +static psa_status_t storage_get(psa_msg_t *msg) { uint32_t key = 0; uint32_t offset = 0; @@ -100,7 +99,7 @@ static psa_error_t storage_get(psa_msg_t *msg) return status; } -static psa_error_t storage_info(psa_msg_t *msg) +static psa_status_t storage_info(psa_msg_t *msg) { struct psa_its_info_t info = { 0 }; uint32_t key = 0; @@ -121,7 +120,7 @@ static psa_error_t storage_info(psa_msg_t *msg) return status; } -static psa_error_t storage_remove(psa_msg_t *msg) +static psa_status_t storage_remove(psa_msg_t *msg) { uint32_t key = 0; @@ -138,7 +137,7 @@ static psa_error_t storage_remove(psa_msg_t *msg) static void message_handler(psa_msg_t *msg, SignalHandler handler) { - psa_error_t status = PSA_SUCCESS; + psa_status_t status = PSA_SUCCESS; switch (msg->type) { case PSA_IPC_CONNECT: //fallthrough case PSA_IPC_DISCONNECT: { diff --git a/features/mbedtls/inc/psa/crypto.h b/features/mbedtls/inc/psa/crypto.h index 1ca64922e5e..93b695bab4e 100644 --- a/features/mbedtls/inc/psa/crypto.h +++ b/features/mbedtls/inc/psa/crypto.h @@ -61,20 +61,7 @@ extern "C" { * @{ */ -#if defined(PSA_SUCCESS) -/* If PSA_SUCCESS is defined, assume that PSA crypto is being used - * together with PSA IPC, which also defines the identifier - * PSA_SUCCESS. We must not define PSA_SUCCESS ourselves in that case; - * the other error code names don't clash. Also define psa_status_t as - * an alias for the type used by PSA IPC. This is a temporary hack - * until we unify error reporting in PSA IPC and PSA crypto. - * - * Note that psa_defs.h must be included before this header! - */ -typedef psa_error_t psa_status_t; - -#else /* defined(PSA_SUCCESS) */ - +#if !defined(PSA_SUCCESS) /** * \brief Function return status. * diff --git a/rtos/TARGET_CORTEX/mbed_rtos_rtx.c b/rtos/TARGET_CORTEX/mbed_rtos_rtx.c index 87dba802d55..af8e528333f 100644 --- a/rtos/TARGET_CORTEX/mbed_rtos_rtx.c +++ b/rtos/TARGET_CORTEX/mbed_rtos_rtx.c @@ -24,7 +24,7 @@ #include "mbed_critical.h" #include "mbed_boot.h" -#if defined(TARGET_PSA) +#if defined(TARGET_PSA) && defined(TARGET_MBED_SPM) #include "spm_init.h" #include "spm_api.h" #endif @@ -85,18 +85,18 @@ MBED_NORETURN void mbed_rtos_start() spm_ipc_mailbox_init(); #endif // defined(COMPONENT_SPM_MAILBOX) -#if defined(COMPONENT_SPE) +#if defined(COMPONENT_SPE) && defined(TARGET_MBED_SPM) // At this point, the mailbox is already initialized spm_hal_start_nspe(); psa_spm_init(); -#endif // defined(COMPONENT_SPE) +#endif // defined(COMPONENT_SPE) && defined(TARGET_MBED_SPM) -#if defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) +#if defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) && defined(TARGET_MBED_SPM) osThreadId_t spm_result = osThreadNew((osThreadFunc_t)psa_spm_mailbox_dispatcher, NULL, &psa_spm_dispatcher_th_attr); if ((void *)spm_result == NULL) { MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Dispatcher thread not created", &psa_spm_dispatcher_th_attr); } -#endif // defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) +#endif // defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) && defined(TARGET_MBED_SPM) singleton_mutex_id = osMutexNew(&singleton_mutex_attr); osThreadId_t result = osThreadNew((osThreadFunc_t)mbed_start, NULL, &_main_thread_attr); diff --git a/targets/targets.json b/targets/targets.json index c7f034297ef..824b07fa705 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -7869,7 +7869,7 @@ "FUTURE_SEQUANA_M0_PSA": { "inherits": ["SPE_Target", "FUTURE_SEQUANA_M0"], "components_add": ["SPM_MAILBOX", "FLASHIAP"], - "extra_labels_add": ["PSA"], + "extra_labels_add": ["PSA", "MBED_SPM"], "macros_add": [ "PSOC6_DYNSRM_DISABLE=1", "MBEDTLS_PSA_CRYPTO_SPM", @@ -7895,7 +7895,7 @@ "FUTURE_SEQUANA_PSA": { "inherits": ["NSPE_Target", "FUTURE_SEQUANA"], "sub_target": "FUTURE_SEQUANA_M0_PSA", - "extra_labels_add": ["PSA"], + "extra_labels_add": ["PSA", "MBED_SPM"], "extra_labels_remove": ["CORDIO"], "components_add": ["SPM_MAILBOX"], "macros_add": ["PSOC6_DYNSRM_DISABLE=1", "MBEDTLS_PSA_CRYPTO_C"], diff --git a/tools/spm/generate_partition_code.py b/tools/spm/generate_partition_code.py index 99dcdabb75c..85271e19bee 100644 --- a/tools/spm/generate_partition_code.py +++ b/tools/spm/generate_partition_code.py @@ -38,7 +38,7 @@ if '_NAME_' not in filename] MANIFEST_FILE_PATTERN = '*_psa.json' MBED_OS_ROOT = os.path.abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir)) -SPM_CORE_ROOT = path_join(MBED_OS_ROOT, 'components', 'TARGET_PSA', 'spm') +SPM_CORE_ROOT = path_join(MBED_OS_ROOT, 'components', 'TARGET_PSA', 'TARGET_MBED_SPM') SPM_TESTS_ROOT = path_join(MBED_OS_ROOT, 'TESTS', 'psa') diff --git a/tools/spm/templates/COMPONENT_SPE/psa_NAME_partition.c.tpl b/tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl similarity index 98% rename from tools/spm/templates/COMPONENT_SPE/psa_NAME_partition.c.tpl rename to tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl index 769087c5bc6..f42826a096e 100644 --- a/tools/spm/templates/COMPONENT_SPE/psa_NAME_partition.c.tpl +++ b/tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl @@ -23,6 +23,8 @@ * Generated by tools/spm/generate_partition_code.py Version {{script_ver}} **********************************************************************************************************************/ +#if !defined(TARGET_TFM) + #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -143,4 +145,6 @@ void {{partition.name|lower}}_init(spm_partition_t *partition) SPM_PANIC("Failed to create start main thread of partition {{partition.name|lower}}!\n"); } } + +#endif // !defined(TARGET_TFM) {# End of file #} From 9f1dbc1f75689930fd8fdf6904b40fe2be313808 Mon Sep 17 00:00:00 2001 From: Oren Cohen Date: Fri, 25 Jan 2019 17:32:36 +0200 Subject: [PATCH 3/3] CR fixes --- .../psa_test_its_reset_partition.c | 3 --- .../psa_test_its_reset_partition.c | 3 --- .../psa_client_tests_part1_partition.c | 3 --- .../psa_server_test_part1_partition.c | 3 --- .../psa_server_test_part2_partition.c | 3 --- TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h | 2 +- TESTS/psa/spm_server/server_tests.h | 2 +- .../psa_smoke_test_part1_partition.c | 3 --- .../TARGET_MBED_SPM/psa_crypto_srv_partition.c | 3 --- .../TARGET_MBED_SPM/psa_its_partition.c | 3 --- rtos/TARGET_CORTEX/mbed_rtos_rtx.c | 15 +++++++++------ .../TARGET_MBED_SPM/psa_NAME_partition.c.tpl | 3 --- 12 files changed, 11 insertions(+), 35 deletions(-) diff --git a/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c b/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c index 7710b2e8ceb..7ef3168f0d4 100644 --- a/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c +++ b/TESTS/psa/entropy_inject/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -102,4 +100,3 @@ void test_its_reset_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c index 7710b2e8ceb..7ef3168f0d4 100644 --- a/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c +++ b/TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/TARGET_MBED_SPM/psa_test_its_reset_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -102,4 +100,3 @@ void test_its_reset_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c b/TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c index fb87681fb43..895071bf3f5 100644 --- a/TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c +++ b/TESTS/psa/spm_client/COMPONENT_SPE/TARGET_MBED_SPM/psa_client_tests_part1_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -126,4 +124,3 @@ void client_tests_part1_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c index 9d3d1e63ea7..04eebdb5dc5 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part1_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -120,4 +118,3 @@ void server_test_part1_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c index 992394745ae..256c72cba82 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c +++ b/TESTS/psa/spm_server/COMPONENT_SPE/TARGET_MBED_SPM/psa_server_test_part2_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -114,4 +112,3 @@ void server_test_part2_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h b/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h index 1964ab3a55b..437f10609ef 100644 --- a/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h +++ b/TESTS/psa/spm_server/COMPONENT_SPE/server_tests.h @@ -34,7 +34,7 @@ typedef psa_status_t (*psa_test_server_side_func)(psa_status_t *); #define PSA_TEST_SERVER_NAME(name) psa_test_server_side_ ## name #define PSA_TEST_CLIENT(name) void PSA_TEST_CLIENT_NAME(name) (void) -#define PSA_TEST_SERVER(name) psa_status_t PSA_TEST_SERVER_NAME(name) (psa_status_t* status_ptr) +#define PSA_TEST_SERVER(name) psa_status_t PSA_TEST_SERVER_NAME(name) (psa_status_t *status_ptr) #define PSA_TEST(name) \ PSA_TEST_CLIENT(name); \ diff --git a/TESTS/psa/spm_server/server_tests.h b/TESTS/psa/spm_server/server_tests.h index 1964ab3a55b..437f10609ef 100644 --- a/TESTS/psa/spm_server/server_tests.h +++ b/TESTS/psa/spm_server/server_tests.h @@ -34,7 +34,7 @@ typedef psa_status_t (*psa_test_server_side_func)(psa_status_t *); #define PSA_TEST_SERVER_NAME(name) psa_test_server_side_ ## name #define PSA_TEST_CLIENT(name) void PSA_TEST_CLIENT_NAME(name) (void) -#define PSA_TEST_SERVER(name) psa_status_t PSA_TEST_SERVER_NAME(name) (psa_status_t* status_ptr) +#define PSA_TEST_SERVER(name) psa_status_t PSA_TEST_SERVER_NAME(name) (psa_status_t *status_ptr) #define PSA_TEST(name) \ PSA_TEST_CLIENT(name); \ diff --git a/TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c b/TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c index b4e06172016..d59eedae572 100644 --- a/TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c +++ b/TESTS/psa/spm_smoke/COMPONENT_SPE/TARGET_MBED_SPM/psa_smoke_test_part1_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -102,4 +100,3 @@ void smoke_test_part1_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c b/components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c index 4e388950b68..86b5e88e610 100644 --- a/components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c +++ b/components/TARGET_PSA/services/crypto/COMPONENT_SPE/TARGET_MBED_SPM/psa_crypto_srv_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -230,4 +228,3 @@ void crypto_srv_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c index 1f0a76703d0..2f829941adb 100644 --- a/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c +++ b/components/TARGET_PSA/services/psa_prot_internal_storage/COMPONENT_SPE/TARGET_MBED_SPM/psa_its_partition.c @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version 1.0 **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -138,4 +136,3 @@ void its_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) diff --git a/rtos/TARGET_CORTEX/mbed_rtos_rtx.c b/rtos/TARGET_CORTEX/mbed_rtos_rtx.c index af8e528333f..9172dfe62c7 100644 --- a/rtos/TARGET_CORTEX/mbed_rtos_rtx.c +++ b/rtos/TARGET_CORTEX/mbed_rtos_rtx.c @@ -24,12 +24,11 @@ #include "mbed_critical.h" #include "mbed_boot.h" -#if defined(TARGET_PSA) && defined(TARGET_MBED_SPM) +#if defined(TARGET_MBED_SPM) #include "spm_init.h" #include "spm_api.h" #endif - #if defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) MBED_ALIGN(8) char psa_spm_dispatcher_th_stack[0x100]; @@ -85,18 +84,22 @@ MBED_NORETURN void mbed_rtos_start() spm_ipc_mailbox_init(); #endif // defined(COMPONENT_SPM_MAILBOX) -#if defined(COMPONENT_SPE) && defined(TARGET_MBED_SPM) +#if defined(TARGET_MBED_SPM) + +#if defined(COMPONENT_SPE) // At this point, the mailbox is already initialized spm_hal_start_nspe(); psa_spm_init(); -#endif // defined(COMPONENT_SPE) && defined(TARGET_MBED_SPM) +#endif // defined(COMPONENT_SPE) -#if defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) && defined(TARGET_MBED_SPM) +#if defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) osThreadId_t spm_result = osThreadNew((osThreadFunc_t)psa_spm_mailbox_dispatcher, NULL, &psa_spm_dispatcher_th_attr); if ((void *)spm_result == NULL) { MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Dispatcher thread not created", &psa_spm_dispatcher_th_attr); } -#endif // defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) && defined(TARGET_MBED_SPM) +#endif // defined(COMPONENT_NSPE) && defined(COMPONENT_SPM_MAILBOX) + +#endif // defined(TARGET_MBED_SPM) singleton_mutex_id = osMutexNew(&singleton_mutex_attr); osThreadId_t result = osThreadNew((osThreadFunc_t)mbed_start, NULL, &_main_thread_attr); diff --git a/tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl b/tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl index f42826a096e..19fc22cc1de 100644 --- a/tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl +++ b/tools/spm/templates/COMPONENT_SPE/TARGET_MBED_SPM/psa_NAME_partition.c.tpl @@ -23,8 +23,6 @@ * Generated by tools/spm/generate_partition_code.py Version {{script_ver}} **********************************************************************************************************************/ -#if !defined(TARGET_TFM) - #include "cmsis.h" #include "mbed_toolchain.h" /* For using MBED_ALIGN macro */ #include "rtx_os.h" @@ -146,5 +144,4 @@ void {{partition.name|lower}}_init(spm_partition_t *partition) } } -#endif // !defined(TARGET_TFM) {# End of file #}