mirror of https://github.com/ARMmbed/mbed-os.git
Align PSA SPM tests to TF-M
parent
483b23c318
commit
f9fbd6ae82
|
@ -19,10 +19,6 @@
|
|||
#error [NOT_SUPPORTED] SPM tests can run only on SPM-enabled targets
|
||||
#endif // COMPONENT_PSA_SRV_IPC
|
||||
|
||||
#ifndef TARGET_MBED_SPM
|
||||
#error [NOT_SUPPORTED] SPM tests currently only run on MBED_SPM targets
|
||||
#endif // TARGET_MBED_SPM
|
||||
|
||||
#include "mbed.h"
|
||||
#include "greentea-client/test_env.h"
|
||||
#include "unity.h"
|
||||
|
@ -30,6 +26,11 @@
|
|||
#include "psa/client.h"
|
||||
#include "psa_client_tests_part1_ifs.h"
|
||||
|
||||
#if defined(TARGET_TFM)
|
||||
#include "psa/service.h"
|
||||
#define MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS TFM_CONN_HANDLE_MAX_NUM
|
||||
#endif
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
#define MINOR_VER 0
|
||||
|
@ -66,7 +67,7 @@ static void client_ipc_tests_call(
|
|||
uint8_t expected_size
|
||||
)
|
||||
{
|
||||
error_t status = PSA_SUCCESS;
|
||||
psa_status_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 resp = {NULL, rx_len};
|
||||
|
@ -92,9 +93,6 @@ static void client_ipc_tests_call(
|
|||
static void client_ipc_tests_close(psa_handle_t handle)
|
||||
{
|
||||
psa_close(handle);
|
||||
|
||||
// Wait for psa_close to finish on server side
|
||||
osDelay(50);
|
||||
}
|
||||
|
||||
//Testing iovec 0 sent as NULL
|
||||
|
@ -193,7 +191,7 @@ void in_len_0_in_vec_not_NULL()
|
|||
// Testing out_len is 0 but out_vec is not NULL
|
||||
void out_len_0_outvec_not_NULL()
|
||||
{
|
||||
error_t status = PSA_SUCCESS;
|
||||
psa_status_t status = PSA_SUCCESS;
|
||||
|
||||
uint8_t dummy_res[10] = {0};
|
||||
psa_outvec outvec_temp[1] = {{dummy_res, sizeof(dummy_res)}};
|
||||
|
@ -316,7 +314,10 @@ static void call_diff_handle(th_struct_t *thr_attr)
|
|||
//Testing multiple parallel calls to the same SID with different handles
|
||||
void multi_thread_diff_handles()
|
||||
{
|
||||
Thread T1, T2, T3;
|
||||
Thread T1(osPriorityNormal, 256);
|
||||
Thread T2(osPriorityNormal, 256);
|
||||
Thread T3(osPriorityNormal, 256);
|
||||
|
||||
th_struct_t thr_attr[] = {{0}, {0}, {0}};
|
||||
|
||||
uint8_t meta_iovec_1[] = { 2, //expect_size
|
||||
|
@ -459,7 +460,6 @@ Case cases[] = {
|
|||
Case("Testing client tx_buff_null", tx_buff_null),
|
||||
Case("Testing client rx_tx_null", rx_tx_null),
|
||||
Case("Testing client multiple_call from a single thread", multiple_call),
|
||||
Case("Testing client multiple calls on different channels to the same SID", multi_thread_diff_handles),
|
||||
Case("Testing client exceed num of max channels allowed", exceed_num_of_max_channels),
|
||||
Case("Testing client close on NULL handle", client_close_null_handle),
|
||||
Case("Testing DROP_CONNECTION State", drop_connection),
|
||||
|
@ -467,6 +467,7 @@ Case cases[] = {
|
|||
Case("Testing client psa_version() API on existing SID", psa_version_existing),
|
||||
Case("Testing client psa_version() API on non-existing SID", psa_version_non_existing),
|
||||
Case("Testing client psa_version() API to a service that is not NSPE callable", psa_version_secure_access_only),
|
||||
Case("Testing client multiple calls on different channels to the same SID", multi_thread_diff_handles),
|
||||
};
|
||||
|
||||
utest::v1::status_t test_setup(const size_t number_of_cases)
|
|
@ -15,14 +15,23 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "psa/client.h"
|
||||
#include "psa/service.h"
|
||||
#include "spm_panic.h"
|
||||
#include "psa_client_tests_part1_partition.h"
|
||||
|
||||
#if defined(TARGET_MBED_SPM)
|
||||
#include "spm_panic.h"
|
||||
#else
|
||||
#define SPM_PANIC(format, ...) \
|
||||
{ \
|
||||
while(1){}; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MSG_BUF_SIZE 128
|
||||
uint8_t data[MSG_BUF_SIZE] = {0};
|
||||
|
||||
void server_main(void *ptr)
|
||||
void client_part_main(void *ptr)
|
||||
{
|
||||
psa_signal_t signals = 0;
|
||||
psa_msg_t msg = {0};
|
|
@ -1,31 +0,0 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_CLIENT_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_CLIENT_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define PART1_ROT_SRV1 0x00001A05
|
||||
#define DROP_CONN 0x00001A06
|
||||
#define SECURE_CLIENTS_ONLY 0x00001A07
|
||||
|
||||
#endif // PSA_CLIENT_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
|
@ -100,7 +100,7 @@ static const osMutexAttr_t client_tests_part1_mutex_attr = {
|
|||
};
|
||||
|
||||
|
||||
extern void server_main(void *ptr);
|
||||
extern void client_part_main(void *ptr);
|
||||
|
||||
void client_tests_part1_init(spm_partition_t *partition)
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ void client_tests_part1_init(spm_partition_t *partition)
|
|||
}
|
||||
partition->rot_services = client_tests_part1_rot_services;
|
||||
|
||||
partition->thread_id = osThreadNew(server_main, NULL, &client_tests_part1_thread_attr);
|
||||
partition->thread_id = osThreadNew(client_part_main, NULL, &client_tests_part1_thread_attr);
|
||||
if (NULL == partition->thread_id) {
|
||||
SPM_PANIC("Failed to create start main thread of partition client_tests_part1!\n");
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
"type": "APPLICATION-ROT",
|
||||
"priority": "NORMAL",
|
||||
"id": "0x00000001",
|
||||
"entry_point": "server_main",
|
||||
"entry_point": "client_part_main",
|
||||
"stack_size": "0x400",
|
||||
"heap_size": "0x400",
|
||||
"services": [{
|
||||
|
@ -32,6 +32,6 @@
|
|||
}
|
||||
],
|
||||
"source_files": [
|
||||
"COMPONENT_SPE/server.c"
|
||||
"COMPONENT_SPE/client_tests_partition.c"
|
||||
]
|
||||
}
|
|
@ -19,17 +19,18 @@
|
|||
#error [NOT_SUPPORTED] SPM tests can run only on SPM-enabled targets
|
||||
#endif // COMPONENT_PSA_SRV_IPC
|
||||
|
||||
#ifndef TARGET_MBED_SPM
|
||||
#error [NOT_SUPPORTED] SPM tests currently only run on MBED_SPM targets
|
||||
#endif // TARGET_MBED_SPM
|
||||
|
||||
#include "mbed.h"
|
||||
#include "greentea-client/test_env.h"
|
||||
#include "unity.h"
|
||||
#include "utest.h"
|
||||
#include "psa/client.h"
|
||||
#include "psa_server_test_part1_ifs.h"
|
||||
#include "psa_server_tests_part1_ifs.h"
|
||||
#include "server_tests.h"
|
||||
|
||||
#if defined(TARGET_TFM)
|
||||
#include "psa/service.h"
|
||||
#endif
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
#define TEST_ROT_SRV_MINOR 12
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SERVER_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SERVER_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define CONTROL 0x00001A01
|
||||
#define TEST 0x00001A02
|
||||
|
||||
#endif // PSA_SERVER_TEST_PART1_PARTITION_ROT_SERVICES_H
|
|
@ -1,30 +0,0 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SERVER_TEST_PART2_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SERVER_TEST_PART2_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define ROT_SRV_REVERSE 0x00001A03
|
||||
#define ROT_SRV_DB_TST 0x00001A04
|
||||
|
||||
#endif // PSA_SERVER_TEST_PART2_PARTITION_ROT_SERVICES_H
|
|
@ -23,32 +23,32 @@
|
|||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SERVER_TEST_PART1_PARTITION_H
|
||||
#define PSA_SERVER_TEST_PART1_PARTITION_H
|
||||
#ifndef PSA_SERVER_TESTS_PART1_PARTITION_H
|
||||
#define PSA_SERVER_TESTS_PART1_PARTITION_H
|
||||
|
||||
#define SERVER_TEST_PART1_ID 2
|
||||
#define SERVER_TESTS_PART1_ID 2
|
||||
|
||||
#define SERVER_TEST_PART1_ROT_SRV_COUNT (2UL)
|
||||
#define SERVER_TEST_PART1_EXT_ROT_SRV_COUNT (2UL)
|
||||
#define SERVER_TESTS_PART1_ROT_SRV_COUNT (2UL)
|
||||
#define SERVER_TESTS_PART1_EXT_ROT_SRV_COUNT (2UL)
|
||||
|
||||
/* SERVER_TEST_PART1 event flags */
|
||||
#define SERVER_TEST_PART1_RESERVED1_POS (1UL)
|
||||
#define SERVER_TEST_PART1_RESERVED1_MSK (1UL << SERVER_TEST_PART1_RESERVED1_POS)
|
||||
/* SERVER_TESTS_PART1 event flags */
|
||||
#define SERVER_TESTS_PART1_RESERVED1_POS (1UL)
|
||||
#define SERVER_TESTS_PART1_RESERVED1_MSK (1UL << SERVER_TESTS_PART1_RESERVED1_POS)
|
||||
|
||||
#define SERVER_TEST_PART1_RESERVED2_POS (2UL)
|
||||
#define SERVER_TEST_PART1_RESERVED2_MSK (1UL << SERVER_TEST_PART1_RESERVED2_POS)
|
||||
#define SERVER_TESTS_PART1_RESERVED2_POS (2UL)
|
||||
#define SERVER_TESTS_PART1_RESERVED2_MSK (1UL << SERVER_TESTS_PART1_RESERVED2_POS)
|
||||
|
||||
|
||||
#define SERVER_TEST_PART1_WAIT_ANY_IRQ_MSK (0)
|
||||
#define SERVER_TESTS_PART1_WAIT_ANY_IRQ_MSK (0)
|
||||
|
||||
#define CONTROL_MSK_POS (4UL)
|
||||
#define CONTROL_MSK (1UL << CONTROL_MSK_POS)
|
||||
#define TEST_MSK_POS (5UL)
|
||||
#define TEST_MSK (1UL << TEST_MSK_POS)
|
||||
|
||||
#define SERVER_TEST_PART1_WAIT_ANY_SID_MSK (\
|
||||
#define SERVER_TESTS_PART1_WAIT_ANY_SID_MSK (\
|
||||
CONTROL_MSK | \
|
||||
TEST_MSK)
|
||||
|
||||
|
||||
#endif // PSA_SERVER_TEST_PART1_PARTITION_H
|
||||
#endif // PSA_SERVER_TESTS_PART1_PARTITION_H
|
|
@ -23,32 +23,32 @@
|
|||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SERVER_TEST_PART2_PARTITION_H
|
||||
#define PSA_SERVER_TEST_PART2_PARTITION_H
|
||||
#ifndef PSA_SERVER_TESTS_PART2_PARTITION_H
|
||||
#define PSA_SERVER_TESTS_PART2_PARTITION_H
|
||||
|
||||
#define SERVER_TEST_PART2_ID 3
|
||||
#define SERVER_TESTS_PART2_ID 3
|
||||
|
||||
#define SERVER_TEST_PART2_ROT_SRV_COUNT (2UL)
|
||||
#define SERVER_TEST_PART2_EXT_ROT_SRV_COUNT (0UL)
|
||||
#define SERVER_TESTS_PART2_ROT_SRV_COUNT (2UL)
|
||||
#define SERVER_TESTS_PART2_EXT_ROT_SRV_COUNT (0UL)
|
||||
|
||||
/* SERVER_TEST_PART2 event flags */
|
||||
#define SERVER_TEST_PART2_RESERVED1_POS (1UL)
|
||||
#define SERVER_TEST_PART2_RESERVED1_MSK (1UL << SERVER_TEST_PART2_RESERVED1_POS)
|
||||
/* SERVER_TESTS_PART2 event flags */
|
||||
#define SERVER_TESTS_PART2_RESERVED1_POS (1UL)
|
||||
#define SERVER_TESTS_PART2_RESERVED1_MSK (1UL << SERVER_TESTS_PART2_RESERVED1_POS)
|
||||
|
||||
#define SERVER_TEST_PART2_RESERVED2_POS (2UL)
|
||||
#define SERVER_TEST_PART2_RESERVED2_MSK (1UL << SERVER_TEST_PART2_RESERVED2_POS)
|
||||
#define SERVER_TESTS_PART2_RESERVED2_POS (2UL)
|
||||
#define SERVER_TESTS_PART2_RESERVED2_MSK (1UL << SERVER_TESTS_PART2_RESERVED2_POS)
|
||||
|
||||
|
||||
#define SERVER_TEST_PART2_WAIT_ANY_IRQ_MSK (0)
|
||||
#define SERVER_TESTS_PART2_WAIT_ANY_IRQ_MSK (0)
|
||||
|
||||
#define ROT_SRV_REVERSE_MSK_POS (4UL)
|
||||
#define ROT_SRV_REVERSE_MSK (1UL << ROT_SRV_REVERSE_MSK_POS)
|
||||
#define ROT_SRV_DB_TST_MSK_POS (5UL)
|
||||
#define ROT_SRV_DB_TST_MSK (1UL << ROT_SRV_DB_TST_MSK_POS)
|
||||
|
||||
#define SERVER_TEST_PART2_WAIT_ANY_SID_MSK (\
|
||||
#define SERVER_TESTS_PART2_WAIT_ANY_SID_MSK (\
|
||||
ROT_SRV_REVERSE_MSK | \
|
||||
ROT_SRV_DB_TST_MSK)
|
||||
|
||||
|
||||
#endif // PSA_SERVER_TEST_PART2_PARTITION_H
|
||||
#endif // PSA_SERVER_TESTS_PART2_PARTITION_H
|
|
@ -15,8 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __UVISOR_MBED_SPM_SERVER_TESTS_H__
|
||||
#define __UVISOR_MBED_SPM_SERVER_TESTS_H__
|
||||
#ifndef __SERVER_TESTS_H__
|
||||
#define __SERVER_TESTS_H__
|
||||
|
||||
typedef enum {
|
||||
START_TEST = 1,
|
||||
|
@ -54,4 +54,4 @@ PSA_TEST(skip_more_than_left)
|
|||
PSA_TEST(rhandle_factorial)
|
||||
PSA_TEST(cross_partition_call)
|
||||
PSA_TEST(doorbell_test)
|
||||
#endif /* __UVISOR_MBED_SPM_SERVER_TESTS_H__ */
|
||||
#endif /* __SERVER_TESTS_H__ */
|
||||
|
|
|
@ -16,11 +16,20 @@
|
|||
*/
|
||||
|
||||
#include "string.h"
|
||||
#include "psa/client.h"
|
||||
#include "psa/service.h"
|
||||
#include "spm_panic.h"
|
||||
#include "psa_server_test_part1_partition.h"
|
||||
#include "psa_server_tests_part1_partition.h"
|
||||
#include "server_tests.h"
|
||||
|
||||
#if defined(TARGET_MBED_SPM)
|
||||
#include "spm_panic.h"
|
||||
#else
|
||||
#define SPM_PANIC(format, ...) \
|
||||
{ \
|
||||
while(1){}; \
|
||||
}
|
||||
#endif
|
||||
|
||||
extern psa_test_server_side_func test_list[];
|
||||
static size_t num_of_tests = 0;
|
||||
static psa_msg_t msg = {0};
|
||||
|
@ -34,7 +43,7 @@ static void init_num_of_tests()
|
|||
num_of_tests = i;
|
||||
}
|
||||
|
||||
void part1_main(void *ptr)
|
||||
void server_part1_main(void *ptr)
|
||||
{
|
||||
psa_signal_t signals = 0;
|
||||
psa_status_t test_status = PSA_SUCCESS; // status of the api calls during the test
|
|
@ -15,23 +15,33 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cmsis_os2.h"
|
||||
#include "psa/client.h"
|
||||
#include "psa/service.h"
|
||||
#include "psa_server_tests_part2_partition.h"
|
||||
|
||||
#if defined(TARGET_MBED_SPM)
|
||||
#include "cmsis_os2.h"
|
||||
#include "spm_panic.h"
|
||||
#include "psa_server_test_part2_partition.h"
|
||||
#else
|
||||
#define SPM_PANIC(format, ...) \
|
||||
{ \
|
||||
while(1){}; \
|
||||
}
|
||||
#endif
|
||||
|
||||
static psa_msg_t msg = {0};
|
||||
|
||||
void part2_main(void *ptr)
|
||||
void server_part2_main(void *ptr)
|
||||
{
|
||||
psa_signal_t signals = 0;
|
||||
size_t len = 0;
|
||||
char *str = NULL;
|
||||
|
||||
while (1) {
|
||||
signals = psa_wait(SERVER_TEST_PART2_WAIT_ANY_SID_MSK, PSA_BLOCK);
|
||||
if (0 == (signals & SERVER_TEST_PART2_WAIT_ANY_SID_MSK)) {
|
||||
signals = psa_wait(SERVER_TESTS_PART2_WAIT_ANY_SID_MSK, PSA_BLOCK);
|
||||
if (0 == (signals & SERVER_TESTS_PART2_WAIT_ANY_SID_MSK)) {
|
||||
SPM_PANIC("returned from psa_wait without ROT_SRV_REVERSE_MSK or ROT_SRV_DB_TST_MSK bit on\n");
|
||||
}
|
||||
|
||||
|
@ -76,13 +86,15 @@ void part2_main(void *ptr)
|
|||
case PSA_IPC_CALL: {
|
||||
int32_t caller_part_id = msg.client_id;
|
||||
// Doorbell contract is valid only between secure partitions
|
||||
if (PSA_NSPE_IDENTIFIER == caller_part_id) {
|
||||
if (caller_part_id < 0) {
|
||||
SPM_PANIC("Caller partition is non secure\n");
|
||||
}
|
||||
// In doorbell scenario the server first calls psa_reply()
|
||||
psa_reply(msg.handle, PSA_SUCCESS);
|
||||
#if defined(TARGET_MBED_SPM)
|
||||
// Then the servers waits to some driver making long calculations - imitate using osDelay()
|
||||
osDelay(20);
|
||||
#endif
|
||||
// After work is done, ring the doorbell
|
||||
psa_notify(caller_part_id);
|
||||
break;
|
|
@ -18,11 +18,19 @@
|
|||
#include "string.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"
|
||||
#include "psa_server_tests_part1_partition.h"
|
||||
#include "psa_server_tests_part2_ifs.h"
|
||||
#include "server_tests.h"
|
||||
|
||||
#if defined(TARGET_MBED_SPM)
|
||||
#include "spm_panic.h"
|
||||
#else
|
||||
#define SPM_PANIC(format, ...) \
|
||||
{ \
|
||||
while(1){}; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Process a generic connect message to TEST ROT_SRV.
|
||||
* @return PSA_SUCCESS or negative error code if failed.
|
||||
|
|
|
@ -28,31 +28,31 @@
|
|||
#include "rtx_os.h"
|
||||
#include "spm_panic.h"
|
||||
#include "spm_internal.h"
|
||||
#include "psa_server_test_part1_partition.h"
|
||||
#include "psa_server_test_part1_ifs.h"
|
||||
#include "psa_server_test_part2_ifs.h"
|
||||
#include "psa_server_tests_part1_partition.h"
|
||||
#include "psa_server_tests_part1_ifs.h"
|
||||
#include "psa_server_tests_part2_ifs.h"
|
||||
|
||||
|
||||
/* Threads stacks */
|
||||
MBED_ALIGN(8) uint8_t server_test_part1_thread_stack[1024] = {0};
|
||||
MBED_ALIGN(8) uint8_t server_tests_part1_thread_stack[1024] = {0};
|
||||
|
||||
/* Threads control blocks */
|
||||
osRtxThread_t server_test_part1_thread_cb = {0};
|
||||
osRtxThread_t server_tests_part1_thread_cb = {0};
|
||||
|
||||
/* Thread attributes - for thread initialization */
|
||||
osThreadAttr_t server_test_part1_thread_attr = {
|
||||
.name = "server_test_part1",
|
||||
osThreadAttr_t server_tests_part1_thread_attr = {
|
||||
.name = "server_tests_part1",
|
||||
.attr_bits = 0,
|
||||
.cb_mem = &server_test_part1_thread_cb,
|
||||
.cb_size = sizeof(server_test_part1_thread_cb),
|
||||
.stack_mem = server_test_part1_thread_stack,
|
||||
.cb_mem = &server_tests_part1_thread_cb,
|
||||
.cb_size = sizeof(server_tests_part1_thread_cb),
|
||||
.stack_mem = server_tests_part1_thread_stack,
|
||||
.stack_size = 1024,
|
||||
.priority = osPriorityNormal,
|
||||
.tz_module = 0,
|
||||
.reserved = 0
|
||||
};
|
||||
|
||||
spm_rot_service_t server_test_part1_rot_services[SERVER_TEST_PART1_ROT_SRV_COUNT] = {
|
||||
spm_rot_service_t server_tests_part1_rot_services[SERVER_TESTS_PART1_ROT_SRV_COUNT] = {
|
||||
{
|
||||
.sid = CONTROL,
|
||||
.mask = CONTROL_MSK,
|
||||
|
@ -79,42 +79,42 @@ spm_rot_service_t server_test_part1_rot_services[SERVER_TEST_PART1_ROT_SRV_COUNT
|
|||
},
|
||||
};
|
||||
|
||||
/* External SIDs used by SERVER_TEST_PART1 */
|
||||
const uint32_t server_test_part1_external_sids[2] = {
|
||||
/* External SIDs used by SERVER_TESTS_PART1 */
|
||||
const uint32_t server_tests_part1_external_sids[2] = {
|
||||
ROT_SRV_REVERSE,
|
||||
ROT_SRV_DB_TST,
|
||||
};
|
||||
|
||||
static osRtxMutex_t server_test_part1_mutex = {0};
|
||||
static const osMutexAttr_t server_test_part1_mutex_attr = {
|
||||
.name = "server_test_part1_mutex",
|
||||
static osRtxMutex_t server_tests_part1_mutex = {0};
|
||||
static const osMutexAttr_t server_tests_part1_mutex_attr = {
|
||||
.name = "server_tests_part1_mutex",
|
||||
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
|
||||
.cb_mem = &server_test_part1_mutex,
|
||||
.cb_size = sizeof(server_test_part1_mutex),
|
||||
.cb_mem = &server_tests_part1_mutex,
|
||||
.cb_size = sizeof(server_tests_part1_mutex),
|
||||
};
|
||||
|
||||
|
||||
extern void part1_main(void *ptr);
|
||||
extern void server_part1_main(void *ptr);
|
||||
|
||||
void server_test_part1_init(spm_partition_t *partition)
|
||||
void server_tests_part1_init(spm_partition_t *partition)
|
||||
{
|
||||
if (NULL == partition) {
|
||||
SPM_PANIC("partition is NULL!\n");
|
||||
}
|
||||
|
||||
partition->mutex = osMutexNew(&server_test_part1_mutex_attr);
|
||||
partition->mutex = osMutexNew(&server_tests_part1_mutex_attr);
|
||||
if (NULL == partition->mutex) {
|
||||
SPM_PANIC("Failed to create mutex for secure partition server_test_part1!\n");
|
||||
SPM_PANIC("Failed to create mutex for secure partition server_tests_part1!\n");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < SERVER_TEST_PART1_ROT_SRV_COUNT; ++i) {
|
||||
server_test_part1_rot_services[i].partition = partition;
|
||||
for (uint32_t i = 0; i < SERVER_TESTS_PART1_ROT_SRV_COUNT; ++i) {
|
||||
server_tests_part1_rot_services[i].partition = partition;
|
||||
}
|
||||
partition->rot_services = server_test_part1_rot_services;
|
||||
partition->rot_services = server_tests_part1_rot_services;
|
||||
|
||||
partition->thread_id = osThreadNew(part1_main, NULL, &server_test_part1_thread_attr);
|
||||
partition->thread_id = osThreadNew(server_part1_main, NULL, &server_tests_part1_thread_attr);
|
||||
if (NULL == partition->thread_id) {
|
||||
SPM_PANIC("Failed to create start main thread of partition server_test_part1!\n");
|
||||
SPM_PANIC("Failed to create start main thread of partition server_tests_part1!\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -28,30 +28,30 @@
|
|||
#include "rtx_os.h"
|
||||
#include "spm_panic.h"
|
||||
#include "spm_internal.h"
|
||||
#include "psa_server_test_part2_partition.h"
|
||||
#include "psa_server_test_part2_ifs.h"
|
||||
#include "psa_server_tests_part2_partition.h"
|
||||
#include "psa_server_tests_part2_ifs.h"
|
||||
|
||||
|
||||
/* Threads stacks */
|
||||
MBED_ALIGN(8) uint8_t server_test_part2_thread_stack[1024] = {0};
|
||||
MBED_ALIGN(8) uint8_t server_tests_part2_thread_stack[1024] = {0};
|
||||
|
||||
/* Threads control blocks */
|
||||
osRtxThread_t server_test_part2_thread_cb = {0};
|
||||
osRtxThread_t server_tests_part2_thread_cb = {0};
|
||||
|
||||
/* Thread attributes - for thread initialization */
|
||||
osThreadAttr_t server_test_part2_thread_attr = {
|
||||
.name = "server_test_part2",
|
||||
osThreadAttr_t server_tests_part2_thread_attr = {
|
||||
.name = "server_tests_part2",
|
||||
.attr_bits = 0,
|
||||
.cb_mem = &server_test_part2_thread_cb,
|
||||
.cb_size = sizeof(server_test_part2_thread_cb),
|
||||
.stack_mem = server_test_part2_thread_stack,
|
||||
.cb_mem = &server_tests_part2_thread_cb,
|
||||
.cb_size = sizeof(server_tests_part2_thread_cb),
|
||||
.stack_mem = server_tests_part2_thread_stack,
|
||||
.stack_size = 1024,
|
||||
.priority = osPriorityNormal,
|
||||
.tz_module = 0,
|
||||
.reserved = 0
|
||||
};
|
||||
|
||||
spm_rot_service_t server_test_part2_rot_services[SERVER_TEST_PART2_ROT_SRV_COUNT] = {
|
||||
spm_rot_service_t server_tests_part2_rot_services[SERVER_TESTS_PART2_ROT_SRV_COUNT] = {
|
||||
{
|
||||
.sid = ROT_SRV_REVERSE,
|
||||
.mask = ROT_SRV_REVERSE_MSK,
|
||||
|
@ -79,36 +79,36 @@ spm_rot_service_t server_test_part2_rot_services[SERVER_TEST_PART2_ROT_SRV_COUNT
|
|||
};
|
||||
|
||||
|
||||
static osRtxMutex_t server_test_part2_mutex = {0};
|
||||
static const osMutexAttr_t server_test_part2_mutex_attr = {
|
||||
.name = "server_test_part2_mutex",
|
||||
static osRtxMutex_t server_tests_part2_mutex = {0};
|
||||
static const osMutexAttr_t server_tests_part2_mutex_attr = {
|
||||
.name = "server_tests_part2_mutex",
|
||||
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
|
||||
.cb_mem = &server_test_part2_mutex,
|
||||
.cb_size = sizeof(server_test_part2_mutex),
|
||||
.cb_mem = &server_tests_part2_mutex,
|
||||
.cb_size = sizeof(server_tests_part2_mutex),
|
||||
};
|
||||
|
||||
|
||||
extern void part2_main(void *ptr);
|
||||
extern void server_part2_main(void *ptr);
|
||||
|
||||
void server_test_part2_init(spm_partition_t *partition)
|
||||
void server_tests_part2_init(spm_partition_t *partition)
|
||||
{
|
||||
if (NULL == partition) {
|
||||
SPM_PANIC("partition is NULL!\n");
|
||||
}
|
||||
|
||||
partition->mutex = osMutexNew(&server_test_part2_mutex_attr);
|
||||
partition->mutex = osMutexNew(&server_tests_part2_mutex_attr);
|
||||
if (NULL == partition->mutex) {
|
||||
SPM_PANIC("Failed to create mutex for secure partition server_test_part2!\n");
|
||||
SPM_PANIC("Failed to create mutex for secure partition server_tests_part2!\n");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < SERVER_TEST_PART2_ROT_SRV_COUNT; ++i) {
|
||||
server_test_part2_rot_services[i].partition = partition;
|
||||
for (uint32_t i = 0; i < SERVER_TESTS_PART2_ROT_SRV_COUNT; ++i) {
|
||||
server_tests_part2_rot_services[i].partition = partition;
|
||||
}
|
||||
partition->rot_services = server_test_part2_rot_services;
|
||||
partition->rot_services = server_tests_part2_rot_services;
|
||||
|
||||
partition->thread_id = osThreadNew(part2_main, NULL, &server_test_part2_thread_attr);
|
||||
partition->thread_id = osThreadNew(server_part2_main, NULL, &server_tests_part2_thread_attr);
|
||||
if (NULL == partition->thread_id) {
|
||||
SPM_PANIC("Failed to create start main thread of partition server_test_part2!\n");
|
||||
SPM_PANIC("Failed to create start main thread of partition server_tests_part2!\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -23,10 +23,10 @@
|
|||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SERVER_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SERVER_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#ifndef PSA_SERVER_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SERVER_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define CONTROL 0x00001A01
|
||||
#define TEST 0x00001A02
|
||||
|
||||
#endif // PSA_SERVER_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#endif // PSA_SERVER_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
|
@ -23,10 +23,10 @@
|
|||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SERVER_TEST_PART2_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SERVER_TEST_PART2_PARTITION_ROT_SERVICES_H
|
||||
#ifndef PSA_SERVER_TESTS_PART2_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SERVER_TESTS_PART2_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define ROT_SRV_REVERSE 0x00001A03
|
||||
#define ROT_SRV_DB_TST 0x00001A04
|
||||
|
||||
#endif // PSA_SERVER_TEST_PART2_PARTITION_ROT_SERVICES_H
|
||||
#endif // PSA_SERVER_TESTS_PART2_PARTITION_ROT_SERVICES_H
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "SERVER_TEST_PART1",
|
||||
"name": "SERVER_TESTS_PART1",
|
||||
"type": "APPLICATION-ROT",
|
||||
"priority": "NORMAL",
|
||||
"id": "0x00000002",
|
||||
"entry_point": "part1_main",
|
||||
"entry_point": "server_part1_main",
|
||||
"stack_size": "0x400",
|
||||
"heap_size": "0x400",
|
||||
"services": [{
|
||||
|
@ -28,6 +28,7 @@
|
|||
"ROT_SRV_DB_TST"
|
||||
],
|
||||
"source_files": [
|
||||
"COMPONENT_SPE/partition.c"
|
||||
"COMPONENT_SPE/server_tests_partition1.c",
|
||||
"COMPONENT_SPE/tests.c"
|
||||
]
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "SERVER_TEST_PART2",
|
||||
"name": "SERVER_TESTS_PART2",
|
||||
"type": "APPLICATION-ROT",
|
||||
"priority": "NORMAL",
|
||||
"id": "0x00000003",
|
||||
"entry_point": "part2_main",
|
||||
"entry_point": "server_part2_main",
|
||||
"stack_size": "0x400",
|
||||
"heap_size": "0x400",
|
||||
"services": [{
|
||||
|
@ -24,6 +24,7 @@
|
|||
}
|
||||
],
|
||||
"source_files": [
|
||||
"COMPONENT_SPE/partition2.c"
|
||||
"COMPONENT_SPE/server_tests_partition2.c",
|
||||
"COMPONENT_SPE/tests.c"
|
||||
]
|
||||
}
|
|
@ -20,17 +20,17 @@
|
|||
#error [NOT_SUPPORTED] SPM tests can run only on SPM-enabled targets
|
||||
#endif // COMPONENT_PSA_SRV_IPC
|
||||
|
||||
#ifndef TARGET_MBED_SPM
|
||||
#error [NOT_SUPPORTED] SPM tests currently only run on MBED_SPM targets
|
||||
#endif // TARGET_MBED_SPM
|
||||
|
||||
/* -------------------------------------- Includes ----------------------------------- */
|
||||
|
||||
#include "greentea-client/test_env.h"
|
||||
#include "unity.h"
|
||||
#include "utest.h"
|
||||
#include "psa/client.h"
|
||||
#include "psa_smoke_test_part1_ifs.h"
|
||||
#include "psa_smoke_tests_part1_ifs.h"
|
||||
|
||||
#if defined(TARGET_TFM)
|
||||
#include "psa/service.h"
|
||||
#endif
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************************************
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* THIS FILE IS AN AUTO-GENERATED FILE - DO NOT MODIFY IT.
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SMOKE_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SMOKE_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define ROT_SRV1 0x00001A00
|
||||
|
||||
#endif // PSA_SMOKE_TEST_PART1_PARTITION_ROT_SERVICES_H
|
|
@ -23,29 +23,29 @@
|
|||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SMOKE_TEST_PART1_PARTITION_H
|
||||
#define PSA_SMOKE_TEST_PART1_PARTITION_H
|
||||
#ifndef PSA_SMOKE_TESTS_PART1_PARTITION_H
|
||||
#define PSA_SMOKE_TESTS_PART1_PARTITION_H
|
||||
|
||||
#define SMOKE_TEST_PART1_ID 4
|
||||
#define SMOKE_TESTS_PART1_ID 4
|
||||
|
||||
#define SMOKE_TEST_PART1_ROT_SRV_COUNT (1UL)
|
||||
#define SMOKE_TEST_PART1_EXT_ROT_SRV_COUNT (0UL)
|
||||
#define SMOKE_TESTS_PART1_ROT_SRV_COUNT (1UL)
|
||||
#define SMOKE_TESTS_PART1_EXT_ROT_SRV_COUNT (0UL)
|
||||
|
||||
/* SMOKE_TEST_PART1 event flags */
|
||||
#define SMOKE_TEST_PART1_RESERVED1_POS (1UL)
|
||||
#define SMOKE_TEST_PART1_RESERVED1_MSK (1UL << SMOKE_TEST_PART1_RESERVED1_POS)
|
||||
/* SMOKE_TESTS_PART1 event flags */
|
||||
#define SMOKE_TESTS_PART1_RESERVED1_POS (1UL)
|
||||
#define SMOKE_TESTS_PART1_RESERVED1_MSK (1UL << SMOKE_TESTS_PART1_RESERVED1_POS)
|
||||
|
||||
#define SMOKE_TEST_PART1_RESERVED2_POS (2UL)
|
||||
#define SMOKE_TEST_PART1_RESERVED2_MSK (1UL << SMOKE_TEST_PART1_RESERVED2_POS)
|
||||
#define SMOKE_TESTS_PART1_RESERVED2_POS (2UL)
|
||||
#define SMOKE_TESTS_PART1_RESERVED2_MSK (1UL << SMOKE_TESTS_PART1_RESERVED2_POS)
|
||||
|
||||
|
||||
#define SMOKE_TEST_PART1_WAIT_ANY_IRQ_MSK (0)
|
||||
#define SMOKE_TESTS_PART1_WAIT_ANY_IRQ_MSK (0)
|
||||
|
||||
#define ROT_SRV1_MSK_POS (4UL)
|
||||
#define ROT_SRV1_MSK (1UL << ROT_SRV1_MSK_POS)
|
||||
|
||||
#define SMOKE_TEST_PART1_WAIT_ANY_SID_MSK (\
|
||||
#define SMOKE_TESTS_PART1_WAIT_ANY_SID_MSK (\
|
||||
ROT_SRV1_MSK)
|
||||
|
||||
|
||||
#endif // PSA_SMOKE_TEST_PART1_PARTITION_H
|
||||
#endif // PSA_SMOKE_TESTS_PART1_PARTITION_H
|
|
@ -18,11 +18,19 @@
|
|||
// -------------------------------------- Includes -----------------------------------
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
#include <stdlib.h>
|
||||
#include "psa/client.h"
|
||||
#include "psa/service.h"
|
||||
#include "psa_smoke_tests_part1_partition.h"
|
||||
|
||||
#if defined(TARGET_MBED_SPM)
|
||||
#include "spm_panic.h"
|
||||
#include "psa_smoke_test_part1_partition.h"
|
||||
#else
|
||||
#define SPM_PANIC(format, ...) \
|
||||
{ \
|
||||
while(1){}; \
|
||||
}
|
||||
#endif
|
||||
|
||||
// ------------------------------------ Definitions ----------------------------------
|
||||
|
||||
|
@ -37,7 +45,7 @@ const char WRITE_MSG_BUF[] = "Response1";
|
|||
|
||||
// ------------------------------ Partition's Main Thread ----------------------------
|
||||
|
||||
void part1_main(void *ptr)
|
||||
void smoke_part_main(void *ptr)
|
||||
{
|
||||
uint32_t signals = 0;
|
||||
int32_t client_id = 0;
|
||||
|
@ -53,7 +61,7 @@ void part1_main(void *ptr)
|
|||
psa_get(ROT_SRV1_MSK, &msg);
|
||||
if (msg.handle != PSA_NULL_HANDLE) {
|
||||
client_id = msg.client_id;
|
||||
if (client_id != PSA_NSPE_IDENTIFIER) {
|
||||
if (client_id != -1) {
|
||||
SPM_PANIC("Received message from unexpected source (0x%08lx)\n", client_id);
|
||||
}
|
||||
}
|
|
@ -28,30 +28,30 @@
|
|||
#include "rtx_os.h"
|
||||
#include "spm_panic.h"
|
||||
#include "spm_internal.h"
|
||||
#include "psa_smoke_test_part1_partition.h"
|
||||
#include "psa_smoke_test_part1_ifs.h"
|
||||
#include "psa_smoke_tests_part1_partition.h"
|
||||
#include "psa_smoke_tests_part1_ifs.h"
|
||||
|
||||
|
||||
/* Threads stacks */
|
||||
MBED_ALIGN(8) uint8_t smoke_test_part1_thread_stack[512] = {0};
|
||||
MBED_ALIGN(8) uint8_t smoke_tests_part1_thread_stack[512] = {0};
|
||||
|
||||
/* Threads control blocks */
|
||||
osRtxThread_t smoke_test_part1_thread_cb = {0};
|
||||
osRtxThread_t smoke_tests_part1_thread_cb = {0};
|
||||
|
||||
/* Thread attributes - for thread initialization */
|
||||
osThreadAttr_t smoke_test_part1_thread_attr = {
|
||||
.name = "smoke_test_part1",
|
||||
osThreadAttr_t smoke_tests_part1_thread_attr = {
|
||||
.name = "smoke_tests_part1",
|
||||
.attr_bits = 0,
|
||||
.cb_mem = &smoke_test_part1_thread_cb,
|
||||
.cb_size = sizeof(smoke_test_part1_thread_cb),
|
||||
.stack_mem = smoke_test_part1_thread_stack,
|
||||
.cb_mem = &smoke_tests_part1_thread_cb,
|
||||
.cb_size = sizeof(smoke_tests_part1_thread_cb),
|
||||
.stack_mem = smoke_tests_part1_thread_stack,
|
||||
.stack_size = 512,
|
||||
.priority = osPriorityNormal,
|
||||
.tz_module = 0,
|
||||
.reserved = 0
|
||||
};
|
||||
|
||||
spm_rot_service_t smoke_test_part1_rot_services[SMOKE_TEST_PART1_ROT_SRV_COUNT] = {
|
||||
spm_rot_service_t smoke_tests_part1_rot_services[SMOKE_TESTS_PART1_ROT_SRV_COUNT] = {
|
||||
{
|
||||
.sid = ROT_SRV1,
|
||||
.mask = ROT_SRV1_MSK,
|
||||
|
@ -67,36 +67,36 @@ spm_rot_service_t smoke_test_part1_rot_services[SMOKE_TEST_PART1_ROT_SRV_COUNT]
|
|||
};
|
||||
|
||||
|
||||
static osRtxMutex_t smoke_test_part1_mutex = {0};
|
||||
static const osMutexAttr_t smoke_test_part1_mutex_attr = {
|
||||
.name = "smoke_test_part1_mutex",
|
||||
static osRtxMutex_t smoke_tests_part1_mutex = {0};
|
||||
static const osMutexAttr_t smoke_tests_part1_mutex_attr = {
|
||||
.name = "smoke_tests_part1_mutex",
|
||||
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
|
||||
.cb_mem = &smoke_test_part1_mutex,
|
||||
.cb_size = sizeof(smoke_test_part1_mutex),
|
||||
.cb_mem = &smoke_tests_part1_mutex,
|
||||
.cb_size = sizeof(smoke_tests_part1_mutex),
|
||||
};
|
||||
|
||||
|
||||
extern void part1_main(void *ptr);
|
||||
extern void smoke_part_main(void *ptr);
|
||||
|
||||
void smoke_test_part1_init(spm_partition_t *partition)
|
||||
void smoke_tests_part1_init(spm_partition_t *partition)
|
||||
{
|
||||
if (NULL == partition) {
|
||||
SPM_PANIC("partition is NULL!\n");
|
||||
}
|
||||
|
||||
partition->mutex = osMutexNew(&smoke_test_part1_mutex_attr);
|
||||
partition->mutex = osMutexNew(&smoke_tests_part1_mutex_attr);
|
||||
if (NULL == partition->mutex) {
|
||||
SPM_PANIC("Failed to create mutex for secure partition smoke_test_part1!\n");
|
||||
SPM_PANIC("Failed to create mutex for secure partition smoke_tests_part1!\n");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < SMOKE_TEST_PART1_ROT_SRV_COUNT; ++i) {
|
||||
smoke_test_part1_rot_services[i].partition = partition;
|
||||
for (uint32_t i = 0; i < SMOKE_TESTS_PART1_ROT_SRV_COUNT; ++i) {
|
||||
smoke_tests_part1_rot_services[i].partition = partition;
|
||||
}
|
||||
partition->rot_services = smoke_test_part1_rot_services;
|
||||
partition->rot_services = smoke_tests_part1_rot_services;
|
||||
|
||||
partition->thread_id = osThreadNew(part1_main, NULL, &smoke_test_part1_thread_attr);
|
||||
partition->thread_id = osThreadNew(smoke_part_main, NULL, &smoke_tests_part1_thread_attr);
|
||||
if (NULL == partition->thread_id) {
|
||||
SPM_PANIC("Failed to create start main thread of partition smoke_test_part1!\n");
|
||||
SPM_PANIC("Failed to create start main thread of partition smoke_tests_part1!\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -23,9 +23,9 @@
|
|||
* Generated by tools/spm/generate_partition_code.py Version 1.0
|
||||
**********************************************************************************************************************/
|
||||
|
||||
#ifndef PSA_SMOKE_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SMOKE_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#ifndef PSA_SMOKE_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
||||
#define PSA_SMOKE_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
||||
|
||||
#define ROT_SRV1 0x00001A00
|
||||
|
||||
#endif // PSA_SMOKE_TEST_PART1_PARTITION_ROT_SERVICES_H
|
||||
#endif // PSA_SMOKE_TESTS_PART1_PARTITION_ROT_SERVICES_H
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "SMOKE_TEST_PART1",
|
||||
"name": "SMOKE_TESTS_PART1",
|
||||
"type": "APPLICATION-ROT",
|
||||
"priority": "NORMAL",
|
||||
"id": "0x00000004",
|
||||
"entry_point": "part1_main",
|
||||
"entry_point": "smoke_part_main",
|
||||
"stack_size": "0x200",
|
||||
"heap_size": "0x400",
|
||||
"services": [{
|
||||
|
@ -16,6 +16,6 @@
|
|||
}
|
||||
],
|
||||
"source_files": [
|
||||
"COMPONENT_SPE/partition1.c"
|
||||
"COMPONENT_SPE/smoke_tests_partition.c"
|
||||
]
|
||||
}
|
|
@ -20,18 +20,38 @@
|
|||
#ifndef __TFM_PARTITION_DEFS_INC__
|
||||
#define __TFM_PARTITION_DEFS_INC__
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/*************************** Service Partitions ******************************/
|
||||
|
||||
#define ITS_ID (TFM_SP_BASE + 0)
|
||||
#endif
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
#define PLATFORM_ID (TFM_SP_BASE + 1)
|
||||
#endif
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
#define CRYPTO_SRV_ID (TFM_SP_BASE + 2)
|
||||
|
||||
/*************************** Test Partitions *********************************/
|
||||
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#ifdef USE_CLIENT_TESTS_PART1
|
||||
#define CLIENT_TESTS_PART1_ID (TFM_SP_BASE + 3 + 0)
|
||||
#endif
|
||||
|
||||
#define TFM_MAX_USER_PARTITIONS (3)
|
||||
#ifdef USE_SERVER_TESTS_PART1
|
||||
#define SERVER_TESTS_PART1_ID (TFM_SP_BASE + 3 + 1)
|
||||
#endif
|
||||
|
||||
#endif /* __TFM_PARTITION_DEFS_INC__ */
|
||||
#ifdef USE_SERVER_TESTS_PART2
|
||||
#define SERVER_TESTS_PART2_ID (TFM_SP_BASE + 3 + 2)
|
||||
#endif
|
||||
|
||||
#ifdef USE_SMOKE_TESTS_PART1
|
||||
#define SMOKE_TESTS_PART1_ID (TFM_SP_BASE + 3 + 3)
|
||||
#endif
|
||||
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
#define TFM_MAX_USER_PARTITIONS (3 + 4)
|
||||
#else
|
||||
#define TFM_MAX_USER_PARTITIONS (3)
|
||||
#endif
|
||||
|
||||
#endif // __TFM_PARTITION_DEFS_INC__
|
|
@ -10,28 +10,58 @@
|
|||
#ifndef __TFM_PARTITION_LIST_INC__
|
||||
#define __TFM_PARTITION_LIST_INC__
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/******** ITS ********/
|
||||
PARTITION_DECLARE(ITS, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 10, NORMAL, 2048);
|
||||
PARTITION_ADD_INIT_FUNC(ITS, its_entry);
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/******** PLATFORM ********/
|
||||
PARTITION_DECLARE(PLATFORM, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 8, NORMAL, 1024);
|
||||
PARTITION_ADD_INIT_FUNC(PLATFORM, platform_partition_entry);
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/******** CRYPTO_SRV ********/
|
||||
PARTITION_DECLARE(CRYPTO_SRV, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 35, NORMAL, 16384);
|
||||
PARTITION_ADD_INIT_FUNC(CRYPTO_SRV, crypto_main);
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
#endif /* __TFM_PARTITION_LIST_INC__ */
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#ifdef USE_CLIENT_TESTS_PART1
|
||||
/******** CLIENT_TESTS_PART1 ********/
|
||||
PARTITION_DECLARE(CLIENT_TESTS_PART1, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 1, NORMAL, 1024);
|
||||
PARTITION_ADD_INIT_FUNC(CLIENT_TESTS_PART1, client_part_main);
|
||||
#endif // USE_CLIENT_TESTS_PART1
|
||||
|
||||
#ifdef USE_SERVER_TESTS_PART1
|
||||
/******** SERVER_TESTS_PART1 ********/
|
||||
PARTITION_DECLARE(SERVER_TESTS_PART1, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 2, NORMAL, 1024);
|
||||
PARTITION_ADD_INIT_FUNC(SERVER_TESTS_PART1, server_part1_main);
|
||||
#endif // USE_SERVER_TESTS_PART1
|
||||
|
||||
#ifdef USE_SERVER_TESTS_PART2
|
||||
/******** SERVER_TESTS_PART2 ********/
|
||||
PARTITION_DECLARE(SERVER_TESTS_PART2, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 3, NORMAL, 1024);
|
||||
PARTITION_ADD_INIT_FUNC(SERVER_TESTS_PART2, server_part2_main);
|
||||
#endif // USE_SERVER_TESTS_PART2
|
||||
|
||||
#ifdef USE_SMOKE_TESTS_PART1
|
||||
/******** SMOKE_TESTS_PART1 ********/
|
||||
PARTITION_DECLARE(SMOKE_TESTS_PART1, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "APPLICATION-ROT", 4, NORMAL, 512);
|
||||
PARTITION_ADD_INIT_FUNC(SMOKE_TESTS_PART1, smoke_part_main);
|
||||
#endif // USE_SMOKE_TESTS_PART1
|
||||
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif // __TFM_PARTITION_LIST_INC__
|
|
@ -10,23 +10,18 @@
|
|||
#ifndef __TFM_SERVICE_LIST_INC__
|
||||
#define __TFM_SERVICE_LIST_INC__
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/******** ITS ********/
|
||||
{"PSA_ITS_GET", ITS_ID, PSA_ITS_GET_MSK, 0x00011A00, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
{"PSA_ITS_SET", ITS_ID, PSA_ITS_SET_MSK, 0x00011A01, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
{"PSA_ITS_INFO", ITS_ID, PSA_ITS_INFO_MSK, 0x00011A02, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
{"PSA_ITS_REMOVE", ITS_ID, PSA_ITS_REMOVE_MSK, 0x00011A03, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
{"PSA_ITS_RESET", ITS_ID, PSA_ITS_RESET_MSK, 0x00011A04, false, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/******** PLATFORM ********/
|
||||
{"PSA_PLATFORM_LC_GET", PLATFORM_ID, PSA_PLATFORM_LC_GET_MSK, 0x00011000, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
{"PSA_PLATFORM_LC_SET", PLATFORM_ID, PSA_PLATFORM_LC_SET_MSK, 0x00011001, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
{"PSA_PLATFORM_SYSTEM_RESET", PLATFORM_ID, PSA_PLATFORM_SYSTEM_RESET_MSK, 0x00011002, true, 1, TFM_VERSION_POLICY_RELAXED},
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
#ifdef TFM_PSA_API
|
||||
/******** CRYPTO_SRV ********/
|
||||
{"PSA_CRYPTO_INIT_ID", CRYPTO_SRV_ID, PSA_CRYPTO_INIT, 0x00000F00, true, 1, TFM_VERSION_POLICY_STRICT},
|
||||
{"PSA_MAC_ID", CRYPTO_SRV_ID, PSA_MAC, 0x00000F01, true, 1, TFM_VERSION_POLICY_STRICT},
|
||||
|
@ -39,6 +34,33 @@
|
|||
{"PSA_CRYPTO_FREE_ID", CRYPTO_SRV_ID, PSA_CRYPTO_FREE, 0x00000F08, true, 1, TFM_VERSION_POLICY_STRICT},
|
||||
{"PSA_GENERATOR_ID", CRYPTO_SRV_ID, PSA_GENERATOR, 0x00000F09, true, 1, TFM_VERSION_POLICY_STRICT},
|
||||
{"PSA_ENTROPY_ID", CRYPTO_SRV_ID, PSA_ENTROPY_INJECT, 0x00000F0A, true, 1, TFM_VERSION_POLICY_STRICT},
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
#endif /* __TFM_SERVICE_LIST_INC__ */
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#ifdef USE_CLIENT_TESTS_PART1
|
||||
/******** CLIENT_TESTS_PART1 ********/
|
||||
{"PART1_ROT_SRV1", CLIENT_TESTS_PART1_ID, PART1_ROT_SRV1_MSK, 0x00001A05, true, 5, TFM_VERSION_POLICY_RELAXED},
|
||||
{"DROP_CONN", CLIENT_TESTS_PART1_ID, DROP_CONN_MSK, 0x00001A06, true, 5, TFM_VERSION_POLICY_RELAXED},
|
||||
{"SECURE_CLIENTS_ONLY", CLIENT_TESTS_PART1_ID, SECURE_CLIENTS_ONLY_MSK, 0x00001A07, false, 5, TFM_VERSION_POLICY_RELAXED},
|
||||
#endif // USE_CLIENT_TESTS_PART1
|
||||
|
||||
#ifdef USE_SERVER_TESTS_PART1
|
||||
/******** SERVER_TESTS_PART1 ********/
|
||||
{"CONTROL", SERVER_TESTS_PART1_ID, CONTROL_MSK, 0x00001A01, true, 5, TFM_VERSION_POLICY_RELAXED},
|
||||
{"TEST", SERVER_TESTS_PART1_ID, TEST_MSK, 0x00001A02, true, 12, TFM_VERSION_POLICY_STRICT},
|
||||
#endif // USE_SERVER_TESTS_PART1
|
||||
|
||||
#ifdef USE_SERVER_TESTS_PART2
|
||||
/******** SERVER_TESTS_PART2 ********/
|
||||
{"ROT_SRV_REVERSE", SERVER_TESTS_PART2_ID, ROT_SRV_REVERSE_MSK, 0x00001A03, false, 5, TFM_VERSION_POLICY_STRICT},
|
||||
{"ROT_SRV_DB_TST", SERVER_TESTS_PART2_ID, ROT_SRV_DB_TST_MSK, 0x00001A04, false, 5, TFM_VERSION_POLICY_STRICT},
|
||||
#endif // USE_SERVER_TESTS_PART2
|
||||
|
||||
#ifdef USE_SMOKE_TESTS_PART1
|
||||
/******** SMOKE_TESTS_PART1 ********/
|
||||
{"ROT_SRV1", SMOKE_TESTS_PART1_ID, ROT_SRV1_MSK, 0x00001A00, true, 5, TFM_VERSION_POLICY_RELAXED},
|
||||
#endif // USE_SMOKE_TESTS_PART1
|
||||
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif // __TFM_SERVICE_LIST_INC__
|
|
@ -1,12 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
|
||||
|
||||
#ifndef __TFM_SPM_SIGNAL_DEFS_H__
|
||||
#define __TFM_SPM_SIGNAL_DEFS_H__
|
||||
|
||||
/******** ITS ********/
|
||||
#define PSA_ITS_GET_MSK_POS (4UL)
|
||||
#define PSA_ITS_GET_MSK (1UL << PSA_ITS_GET_MSK_POS)
|
||||
#define PSA_ITS_SET_MSK_POS (5UL)
|
||||
|
@ -18,6 +22,7 @@
|
|||
#define PSA_ITS_RESET_MSK_POS (8UL)
|
||||
#define PSA_ITS_RESET_MSK (1UL << PSA_ITS_RESET_MSK_POS)
|
||||
|
||||
/******** PLATFORM ********/
|
||||
#define PSA_PLATFORM_LC_GET_MSK_POS (4UL)
|
||||
#define PSA_PLATFORM_LC_GET_MSK (1UL << PSA_PLATFORM_LC_GET_MSK_POS)
|
||||
#define PSA_PLATFORM_LC_SET_MSK_POS (5UL)
|
||||
|
@ -25,6 +30,7 @@
|
|||
#define PSA_PLATFORM_SYSTEM_RESET_MSK_POS (6UL)
|
||||
#define PSA_PLATFORM_SYSTEM_RESET_MSK (1UL << PSA_PLATFORM_SYSTEM_RESET_MSK_POS)
|
||||
|
||||
/******** CRYPTO_SRV ********/
|
||||
#define PSA_CRYPTO_INIT_POS (4UL)
|
||||
#define PSA_CRYPTO_INIT (1UL << PSA_CRYPTO_INIT_POS)
|
||||
#define PSA_MAC_POS (5UL)
|
||||
|
@ -48,5 +54,40 @@
|
|||
#define PSA_ENTROPY_INJECT_POS (14UL)
|
||||
#define PSA_ENTROPY_INJECT (1UL << PSA_ENTROPY_INJECT_POS)
|
||||
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif
|
||||
#ifdef USE_CLIENT_TESTS_PART1
|
||||
/******** CLIENT_TESTS_PART1 ********/
|
||||
#define PART1_ROT_SRV1_MSK_POS (4UL)
|
||||
#define PART1_ROT_SRV1_MSK (1UL << PART1_ROT_SRV1_MSK_POS)
|
||||
#define DROP_CONN_MSK_POS (5UL)
|
||||
#define DROP_CONN_MSK (1UL << DROP_CONN_MSK_POS)
|
||||
#define SECURE_CLIENTS_ONLY_MSK_POS (6UL)
|
||||
#define SECURE_CLIENTS_ONLY_MSK (1UL << SECURE_CLIENTS_ONLY_MSK_POS)
|
||||
#endif // USE_CLIENT_TESTS_PART1
|
||||
|
||||
#ifdef USE_SERVER_TESTS_PART1
|
||||
/******** SERVER_TESTS_PART1 ********/
|
||||
#define CONTROL_MSK_POS (4UL)
|
||||
#define CONTROL_MSK (1UL << CONTROL_MSK_POS)
|
||||
#define TEST_MSK_POS (5UL)
|
||||
#define TEST_MSK (1UL << TEST_MSK_POS)
|
||||
#endif // USE_SERVER_TESTS_PART1
|
||||
|
||||
#ifdef USE_SERVER_TESTS_PART2
|
||||
/******** SERVER_TESTS_PART2 ********/
|
||||
#define ROT_SRV_REVERSE_MSK_POS (4UL)
|
||||
#define ROT_SRV_REVERSE_MSK (1UL << ROT_SRV_REVERSE_MSK_POS)
|
||||
#define ROT_SRV_DB_TST_MSK_POS (5UL)
|
||||
#define ROT_SRV_DB_TST_MSK (1UL << ROT_SRV_DB_TST_MSK_POS)
|
||||
#endif // USE_SERVER_TESTS_PART2
|
||||
|
||||
#ifdef USE_SMOKE_TESTS_PART1
|
||||
/******** SMOKE_TESTS_PART1 ********/
|
||||
#define ROT_SRV1_MSK_POS (4UL)
|
||||
#define ROT_SRV1_MSK (1UL << ROT_SRV1_MSK_POS)
|
||||
#endif // USE_SMOKE_TESTS_PART1
|
||||
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif // __TFM_SPM_SIGNAL_DEFS_H__
|
|
@ -17,7 +17,7 @@
|
|||
"rot_pool_size": {
|
||||
"help": "maximum number of RoT services allowed",
|
||||
"macro_name": "TFM_SPM_MAX_ROT_SERV_NUM",
|
||||
"value": 20
|
||||
"value": 30
|
||||
},
|
||||
"message_pool_size": {
|
||||
"help": "maximum number of active messages allowed",
|
||||
|
|
|
@ -25,7 +25,8 @@ from jinja2 import Environment, FileSystemLoader, StrictUndefined
|
|||
ROOT = os.path.abspath(path_join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
from tools.psa.mbed_spm_tfm_common import Manifest, validate_partition_manifests, manifests_discovery
|
||||
from tools.psa.mbed_spm_tfm_common import \
|
||||
Manifest, validate_partition_manifests, manifests_discovery, MBED_OS_ROOT
|
||||
|
||||
__version__ = '1.0'
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -39,9 +40,7 @@ COMMON_TEMPLATES = [filename for filename in
|
|||
os.walk(TEMPLATES_DIR) for f in fn if f.endswith('.tpl')]
|
||||
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', 'TARGET_MBED_SPM')
|
||||
SPM_TESTS_ROOT = path_join(MBED_OS_ROOT, 'TESTS', 'psa')
|
||||
SPM_CORE_ROOT = path_join(MBED_OS_ROOT, 'components', 'TARGET_PSA')
|
||||
|
||||
|
||||
def generate_source_files(
|
||||
|
@ -133,8 +132,7 @@ def generate_partitions_sources(manifest_files, extra_filters=None):
|
|||
return list(generated_folders)
|
||||
|
||||
|
||||
def generate_psa_setup(manifest_files, output_dir, weak_setup,
|
||||
extra_filters=None):
|
||||
def generate_psa_setup(manifest_files, output_dir, weak_setup, extra_filters=None):
|
||||
"""
|
||||
Process all the given manifest files and generate C setup code from them
|
||||
:param manifest_files: List of manifest files
|
||||
|
@ -190,37 +188,26 @@ Process all the given manifest files and generate C setup code from them
|
|||
|
||||
def generate_psa_code():
|
||||
# Find all manifest files in the mbed-os tree
|
||||
manifest_files = manifests_discovery(MBED_OS_ROOT)
|
||||
service_manifest_files, test_manifest_files = manifests_discovery(root_dir=MBED_OS_ROOT)
|
||||
|
||||
# Generate partition code for each manifest file
|
||||
generate_partitions_sources(manifest_files)
|
||||
|
||||
test_manifest_files = sorted(
|
||||
[path for path in manifest_files if 'TESTS' in path])
|
||||
system_manifest_files = sorted(
|
||||
list(set(manifest_files) - set(test_manifest_files)))
|
||||
generate_partitions_sources(service_manifest_files + test_manifest_files)
|
||||
|
||||
# Generate default system psa setup file (only system partitions)
|
||||
generate_psa_setup(system_manifest_files, SPM_CORE_ROOT, weak_setup=True)
|
||||
generate_psa_setup(service_manifest_files,
|
||||
SPM_CORE_ROOT, weak_setup=True)
|
||||
|
||||
tests_dir_content = [path_join(SPM_TESTS_ROOT, f) for f in
|
||||
os.listdir(SPM_TESTS_ROOT)]
|
||||
spm_tests = [path for path in tests_dir_content if os.path.isdir(path)]
|
||||
tests_dict = {}
|
||||
for test_manifest in test_manifest_files:
|
||||
test_dir = os.path.dirname(test_manifest)
|
||||
if test_dir not in tests_dict:
|
||||
tests_dict[test_dir] = [test_manifest]
|
||||
else:
|
||||
tests_dict[test_dir].append(test_manifest)
|
||||
|
||||
# Build a dictionary for test partition in the form of:
|
||||
# { test_root: manifest_list }
|
||||
# For each test generate specific psa setup file (system + test partitions)
|
||||
tests_dict = {test_root: [] for test_root in spm_tests}
|
||||
for test_root in spm_tests:
|
||||
tests_dict[test_root] = [manifest_path for manifest_path in
|
||||
test_manifest_files if
|
||||
test_root in manifest_path]
|
||||
|
||||
if not tests_dict[test_root]:
|
||||
continue
|
||||
tests_dict[test_root] += system_manifest_files
|
||||
generate_psa_setup(sorted(tests_dict[test_root]), test_root,
|
||||
weak_setup=False)
|
||||
for test_dir in tests_dict:
|
||||
generate_psa_setup(service_manifest_files + tests_dict[test_dir],
|
||||
test_dir, weak_setup=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -25,13 +25,12 @@ from jinja2 import Environment, FileSystemLoader, StrictUndefined
|
|||
ROOT = os.path.abspath(path_join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
from tools.psa.mbed_spm_tfm_common import Manifest, validate_partition_manifests
|
||||
from tools.psa.mbed_spm_tfm_common import \
|
||||
Manifest, validate_partition_manifests, manifests_discovery, MBED_OS_ROOT, SERVICES_DIR, TESTS_DIR
|
||||
|
||||
__version__ = '1.0'
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
MBED_OS_ROOT = os.path.abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir))
|
||||
TEMPLATES_LIST_FILE = path_join(SCRIPT_DIR, 'tfm', 'tfm_generated_file_list.json')
|
||||
SERVICES_DIR = os.path.join(MBED_OS_ROOT, "components", "TARGET_PSA", "services")
|
||||
|
||||
SERVICES_MANIFESTS = [
|
||||
path_join(SERVICES_DIR, 'storage', 'its', 'pits_psa.json'),
|
||||
|
@ -40,30 +39,39 @@ SERVICES_MANIFESTS = [
|
|||
]
|
||||
|
||||
|
||||
def generate_partition_source_files(manifest_files, extra_filters=None):
|
||||
def parse_manifests(manifests_files):
|
||||
region_list = []
|
||||
manifests = []
|
||||
for manifest_file in manifests_files:
|
||||
manifest_obj = Manifest.from_json(manifest_file, psa_type='TFM')
|
||||
manifests.append(manifest_obj)
|
||||
for region in manifest_obj.mmio_regions:
|
||||
region_list.append(region)
|
||||
|
||||
return manifests, region_list
|
||||
|
||||
|
||||
def generate_partition_source_files(service_manifest_files, test_manifest_files, extra_filters=None):
|
||||
"""
|
||||
Process all the given manifest files and generate C code from them.
|
||||
|
||||
:param manifest_files: List of manifest files
|
||||
:param service_manifest_files: List of PSA serices manifest files
|
||||
:param test_manifest_files: List of tests manifest files
|
||||
:param extra_filters: Dictionary of extra filters to use in the rendering
|
||||
process
|
||||
:return: path to the setup generated files
|
||||
"""
|
||||
|
||||
# Construct lists of all the manifests and mmio_regions.
|
||||
region_list = []
|
||||
manifests = []
|
||||
for manifest_file in manifest_files:
|
||||
manifest_obj = Manifest.from_json(manifest_file, psa_type='TFM')
|
||||
manifests.append(manifest_obj)
|
||||
for region in manifest_obj.mmio_regions:
|
||||
region_list.append(region)
|
||||
service_manifests, service_region_list = parse_manifests(service_manifest_files)
|
||||
test_manifests, test_region_list = parse_manifests(test_manifest_files)
|
||||
|
||||
# Validate the correctness of the manifest collection.
|
||||
validate_partition_manifests(manifests)
|
||||
validate_partition_manifests(service_manifests + test_manifests)
|
||||
|
||||
render_args = {
|
||||
'partitions': manifests,
|
||||
'service_partitions': service_manifests,
|
||||
'test_partitions': test_manifests
|
||||
}
|
||||
|
||||
# Load templates for the code generation.
|
||||
|
@ -95,7 +103,8 @@ def generate_partition_source_files(manifest_files, extra_filters=None):
|
|||
|
||||
|
||||
def generate_tfm_code():
|
||||
generate_partition_source_files(SERVICES_MANIFESTS)
|
||||
_, tests_manifests = manifests_discovery(TESTS_DIR)
|
||||
generate_partition_source_files(SERVICES_MANIFESTS, tests_manifests)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -23,6 +23,9 @@ import fnmatch
|
|||
from six import integer_types, string_types
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
MBED_OS_ROOT = os.path.abspath(path_join(SCRIPT_DIR, os.pardir, os.pardir))
|
||||
SERVICES_DIR = path_join(MBED_OS_ROOT, "components", "TARGET_PSA", "services")
|
||||
TESTS_DIR = path_join(MBED_OS_ROOT, "TESTS", "psa")
|
||||
MANIFEST_FILE_PATTERN = '*_psa.json'
|
||||
|
||||
|
||||
|
@ -594,13 +597,22 @@ def validate_partition_manifests(manifests):
|
|||
)
|
||||
|
||||
|
||||
def manifests_discovery(root_dir):
|
||||
manifest_files = set()
|
||||
def is_test_manifest(manifest):
|
||||
return 'tests' in manifest
|
||||
|
||||
|
||||
def is_service_manifest(manifest):
|
||||
return not is_test_manifest(manifest)
|
||||
|
||||
|
||||
def manifests_discovery(root_dir=SERVICES_DIR):
|
||||
service_manifest_files = set()
|
||||
test_manifest_files = set()
|
||||
|
||||
for root, dirs, files in os.walk(root_dir):
|
||||
to_add = [path_join(root, f) for f in
|
||||
fnmatch.filter(files, MANIFEST_FILE_PATTERN) if
|
||||
'TARGET_IGNORE' not in root]
|
||||
manifest_files.update(to_add)
|
||||
fnmatch.filter(files, MANIFEST_FILE_PATTERN)]
|
||||
service_manifest_files.update(filter(is_service_manifest, to_add))
|
||||
test_manifest_files.update(filter(is_test_manifest, to_add))
|
||||
|
||||
return list(manifest_files)
|
||||
return sorted(list(service_manifest_files)), sorted(list(test_manifest_files))
|
||||
|
|
|
@ -20,13 +20,30 @@
|
|||
#ifndef __TFM_PARTITION_DEFS_INC__
|
||||
#define __TFM_PARTITION_DEFS_INC__
|
||||
|
||||
{% for partition in partitions %}
|
||||
/*************************** Service Partitions ******************************/
|
||||
|
||||
{% for partition in service_partitions %}
|
||||
{% set partition_loop = loop %}
|
||||
#ifdef TFM_PSA_API
|
||||
#define {{partition.name|upper}}_ID (TFM_SP_BASE + {{ partition_loop.index0 }})
|
||||
{% endfor %}
|
||||
|
||||
/*************************** Test Partitions *********************************/
|
||||
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
{% for partition in test_partitions %}
|
||||
{% set partition_loop = loop %}
|
||||
#ifdef USE_{{partition.name|upper}}
|
||||
#define {{partition.name|upper}}_ID (TFM_SP_BASE + {{service_partitions|count}} + {{ partition_loop.index0 }})
|
||||
#endif
|
||||
|
||||
{% endfor %}
|
||||
#define TFM_MAX_USER_PARTITIONS ({{partitions|count}})
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif /* __TFM_PARTITION_DEFS_INC__ */
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
#define TFM_MAX_USER_PARTITIONS ({{service_partitions|count}} + {{test_partitions|count}})
|
||||
#else
|
||||
#define TFM_MAX_USER_PARTITIONS ({{service_partitions|count}})
|
||||
#endif
|
||||
|
||||
#endif // __TFM_PARTITION_DEFS_INC__
|
||||
|
|
|
@ -10,14 +10,26 @@
|
|||
#ifndef __TFM_PARTITION_LIST_INC__
|
||||
#define __TFM_PARTITION_LIST_INC__
|
||||
|
||||
{% for partition in partitions %}
|
||||
#ifdef TFM_PSA_API
|
||||
{% for partition in service_partitions %}
|
||||
/******** {{partition.name|upper}} ********/
|
||||
PARTITION_DECLARE({{partition.name|upper}}, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "{{partition.type}}", {{partition.id}}, {{partition.priority}}, {{partition.stack_size}});
|
||||
PARTITION_ADD_INIT_FUNC({{partition.name|upper}}, {{partition.entry_point}});
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
{% endfor %}
|
||||
#endif /* __TFM_PARTITION_LIST_INC__ */
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
{% for partition in test_partitions %}
|
||||
#ifdef USE_{{partition.name|upper}}
|
||||
/******** {{partition.name|upper}} ********/
|
||||
PARTITION_DECLARE({{partition.name|upper}}, 0
|
||||
| SPM_PART_FLAG_IPC
|
||||
, "{{partition.type}}", {{partition.id}}, {{partition.priority}}, {{partition.stack_size}});
|
||||
PARTITION_ADD_INIT_FUNC({{partition.name|upper}}, {{partition.entry_point}});
|
||||
#endif // USE_{{partition.name|upper}}
|
||||
|
||||
{% endfor %}
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif // __TFM_PARTITION_LIST_INC__
|
||||
|
|
|
@ -10,13 +10,24 @@
|
|||
#ifndef __TFM_SERVICE_LIST_INC__
|
||||
#define __TFM_SERVICE_LIST_INC__
|
||||
|
||||
{% for partition in partitions %}
|
||||
#ifdef TFM_PSA_API
|
||||
{% for partition in service_partitions %}
|
||||
/******** {{partition.name|upper}} ********/
|
||||
{% for rot_srv in partition.rot_services %}
|
||||
{"{{rot_srv.name|upper}}", {{partition.name|upper}}_ID, {{rot_srv.signal|upper}}, {{rot_srv.id}}, {% if rot_srv.nspe_callable %}true{% else %}false{% endif %}, {{rot_srv.minor_version}}, TFM_VERSION_POLICY_{{rot_srv.minor_policy|upper}}},
|
||||
{% endfor %}
|
||||
#endif /* TFM_PSA_API */
|
||||
|
||||
{% endfor %}
|
||||
#endif /* __TFM_SERVICE_LIST_INC__ */
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
{% for partition in test_partitions %}
|
||||
#ifdef USE_{{partition.name|upper}}
|
||||
/******** {{partition.name|upper}} ********/
|
||||
{% for rot_srv in partition.rot_services %}
|
||||
{"{{rot_srv.name|upper}}", {{partition.name|upper}}_ID, {{rot_srv.signal|upper}}, {{rot_srv.id}}, {% if rot_srv.nspe_callable %}true{% else %}false{% endif %}, {{rot_srv.minor_version}}, TFM_VERSION_POLICY_{{rot_srv.minor_policy|upper}}},
|
||||
{% endfor %}
|
||||
#endif // USE_{{partition.name|upper}}
|
||||
|
||||
{% endfor %}
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif // __TFM_SERVICE_LIST_INC__
|
||||
|
|
|
@ -1,18 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
|
||||
|
||||
#ifndef __TFM_SPM_SIGNAL_DEFS_H__
|
||||
#define __TFM_SPM_SIGNAL_DEFS_H__
|
||||
|
||||
{% for partition in partitions %}
|
||||
{% for partition in service_partitions %}
|
||||
/******** {{partition.name|upper}} ********/
|
||||
{% for rot_srv in partition.rot_services %}
|
||||
#define {{rot_srv.signal|upper}}_POS ({{loop.index + 3}}UL)
|
||||
#define {{rot_srv.signal|upper}} (1UL << {{rot_srv.signal|upper}}_POS)
|
||||
{% endfor %}
|
||||
|
||||
{% endfor %}
|
||||
#ifdef USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif
|
||||
{% for partition in test_partitions %}
|
||||
#ifdef USE_{{partition.name|upper}}
|
||||
/******** {{partition.name|upper}} ********/
|
||||
{% for rot_srv in partition.rot_services %}
|
||||
#define {{rot_srv.signal|upper}}_POS ({{loop.index + 3}}UL)
|
||||
#define {{rot_srv.signal|upper}} (1UL << {{rot_srv.signal|upper}}_POS)
|
||||
{% endfor %}
|
||||
#endif // USE_{{partition.name|upper}}
|
||||
|
||||
{% endfor %}
|
||||
#endif // USE_PSA_TEST_PARTITIONS
|
||||
|
||||
#endif // __TFM_SPM_SIGNAL_DEFS_H__
|
||||
|
|
Loading…
Reference in New Issue