mirror of https://github.com/ARMmbed/mbed-os.git
Align to new spec changes and prep for TFM SPM
# Conflicts: # components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c # components/TARGET_PSA/services/crypto/COMPONENT_SPE/psa_crypto_partition.cpull/9529/head
parent
b08c0e2361
commit
8841ba69f8
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "spm_server.h"
|
||||
#include "psa/service.h"
|
||||
#include "spm_panic.h"
|
||||
#include "psa_client_tests_part1_partition.h"
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include "cmsis_os2.h"
|
||||
#include "spm_server.h"
|
||||
#include "psa/service.h"
|
||||
#include "spm_panic.h"
|
||||
#include "psa_server_test_part2_partition.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); \
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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); \
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
|
@ -20,7 +20,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
#include "spm_server.h"
|
||||
#include "psa/service.h"
|
||||
#include "spm_panic.h"
|
||||
#include "psa_smoke_test_part1_partition.h"
|
||||
|
||||
|
|
|
@ -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)
|
|
@ -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(
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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.
|
|
@ -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
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
);
|
||||
|
|
@ -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;
|
||||
|
|
@ -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)
|
|
@ -1,8 +1,9 @@
|
|||
// ---------------------------------- Includes ---------------------------------
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "psa/service.h"
|
||||
#include "psa/client.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define PSA_CRYPTO_SECURE 1
|
||||
#include "crypto_spe.h"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
|
@ -16,9 +16,8 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#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: {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -7868,7 +7868,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",
|
||||
|
@ -7893,7 +7893,7 @@
|
|||
},
|
||||
"FUTURE_SEQUANA_PSA": {
|
||||
"inherits": ["NSPE_Target", "FUTURE_SEQUANA"],
|
||||
"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"],
|
||||
|
|
|
@ -38,7 +38,7 @@ COMMON_TEMPLATES = [filename for filename in
|
|||
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')
|
||||
|
||||
|
||||
|
|
|
@ -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 #}
|
Loading…
Reference in New Issue