Remove SPM negative tests

pull/8744/head
Oren Cohen 2018-11-25 14:16:55 +02:00
parent 6cd4f7789f
commit 1e27eb1c77
37 changed files with 0 additions and 3802 deletions

View File

@ -1,28 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_CLIENT_PART1_PARTITION_ROT_SERVICES_H
#define PSA_NEG_CLIENT_PART1_PARTITION_ROT_SERVICES_H
#define NEG_CLIENT_PART1_ROT_SRV1 0x00001A06
#define NEG_CLIENT_PART1_ROT_SRV2 0x00001A07
#endif // PSA_NEG_CLIENT_PART1_PARTITION_ROT_SERVICES_H

View File

@ -1,109 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "cmsis.h"
#include "mbed_toolchain.h" /* For using MBED_ALIGN macro */
#include "rtx_os.h"
#include "spm_panic.h"
#include "spm_internal.h"
#include "psa_neg_client_part1_partition.h"
#include "psa_neg_client_part1_ifs.h"
/* Threads stacks */
MBED_ALIGN(8) uint8_t neg_client_part1_thread_stack[512] = {0};
/* Threads control blocks */
osRtxThread_t neg_client_part1_thread_cb = {0};
/* Thread attributes - for thread initialization */
osThreadAttr_t neg_client_part1_thread_attr = {
.name = "neg_client_part1",
.attr_bits = 0,
.cb_mem = &neg_client_part1_thread_cb,
.cb_size = sizeof(neg_client_part1_thread_cb),
.stack_mem = neg_client_part1_thread_stack,
.stack_size = 512,
.priority = osPriorityNormal,
.tz_module = 0,
.reserved = 0
};
spm_rot_service_t neg_client_part1_rot_services[NEG_CLIENT_PART1_ROT_SRV_COUNT] = {
{
.sid = NEG_CLIENT_PART1_ROT_SRV1,
.mask = NEG_CLIENT_PART1_ROT_SRV1_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = NEG_CLIENT_PART1_ROT_SRV2,
.mask = NEG_CLIENT_PART1_ROT_SRV2_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_STRICT,
.allow_nspe = false,
.queue = {
.head = NULL,
.tail = NULL
}
},
};
static osRtxMutex_t neg_client_part1_mutex = {0};
static const osMutexAttr_t neg_client_part1_mutex_attr = {
.name = "neg_client_part1_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &neg_client_part1_mutex,
.cb_size = sizeof(neg_client_part1_mutex),
};
extern void server_main1(void *ptr);
void neg_client_part1_init(spm_partition_t *partition)
{
if (NULL == partition) {
SPM_PANIC("partition is NULL!\n");
}
partition->mutex = osMutexNew(&neg_client_part1_mutex_attr);
if (NULL == partition->mutex) {
SPM_PANIC("Failed to create mutex for secure partition neg_client_part1!\n");
}
for (uint32_t i = 0; i < NEG_CLIENT_PART1_ROT_SRV_COUNT; ++i) {
neg_client_part1_rot_services[i].partition = partition;
}
partition->rot_services = neg_client_part1_rot_services;
partition->thread_id = osThreadNew(server_main1, NULL, &neg_client_part1_thread_attr);
if (NULL == partition->thread_id) {
SPM_PANIC("Failed to create start main thread of partition neg_client_part1!\n");
}
}

View File

@ -1,55 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_CLIENT_PART1_PARTITION_H
#define PSA_NEG_CLIENT_PART1_PARTITION_H
#define NEG_CLIENT_PART1_ID 5
#define NEG_CLIENT_PART1_ROT_SRV_COUNT (2UL)
#define NEG_CLIENT_PART1_EXT_ROT_SRV_COUNT (0UL)
/* NEG_CLIENT_PART1 event flags */
#define NEG_CLIENT_PART1_RESERVED1_POS (1UL)
#define NEG_CLIENT_PART1_RESERVED1_MSK (1UL << NEG_CLIENT_PART1_RESERVED1_POS)
#define NEG_CLIENT_PART1_RESERVED2_POS (2UL)
#define NEG_CLIENT_PART1_RESERVED2_MSK (1UL << NEG_CLIENT_PART1_RESERVED2_POS)
#define NEG_CLIENT_PART1_ROT_SRV1_MSK_POS (4UL)
#define NEG_CLIENT_PART1_ROT_SRV1_MSK (1UL << NEG_CLIENT_PART1_ROT_SRV1_MSK_POS)
#define NEG_CLIENT_PART1_ROT_SRV2_MSK_POS (5UL)
#define NEG_CLIENT_PART1_ROT_SRV2_MSK (1UL << NEG_CLIENT_PART1_ROT_SRV2_MSK_POS)
#define NEG_CLIENT_PART1_WAIT_ANY_SID_MSK (\
NEG_CLIENT_PART1_ROT_SRV1_MSK | \
NEG_CLIENT_PART1_ROT_SRV2_MSK)
/*
#define NEG_CLIENT_PART1_WAIT_ANY_MSK (\
NEG_CLIENT_PART1_WAIT_ANY_SID_MSK) | \
PSA_DOORBELL)
*/
#endif // PSA_NEG_CLIENT_PART1_PARTITION_H

View File

@ -1,357 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !ENABLE_SPM
#error [NOT_SUPPORTED] SPM is not supported on this platform
#endif
#include "cmsis_os2.h"
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "rtos.h"
#include "spm_client.h"
#include "psa_neg_client_part1_ifs.h"
#include "neg_tests.h"
#define MINOR_VER 5
#define CLIENT_RSP_BUF_SIZE 128
#define OFFSET_POS 1
#define INVALID_SID (NEG_CLIENT_PART1_ROT_SRV1 + 30)
#define INVALID_MINOR (MINOR_VER + 10)
#define INVALID_TX_LEN (PSA_MAX_IOVEC + 1)
using namespace utest::v1;
Semaphore test_sem(0);
bool error_thrown = false;
uint8_t response_buf[CLIENT_RSP_BUF_SIZE];
extern "C" void spm_reboot(void);
void error(const char *format, ...)
{
error_thrown = true;
osStatus status = test_sem.release();
MBED_ASSERT(status == osOK);
PSA_UNUSED(status);
while (1);
}
/* ------------------------------------- Functions ----------------------------------- */
static psa_handle_t negative_client_ipc_tests_connect(uint32_t sid, uint32_t minor_version)
{
psa_handle_t handle = psa_connect(sid, minor_version);
TEST_ASSERT_TRUE(handle > 0);
return handle;
}
static void negative_client_ipc_tests_call(psa_handle_t handle,
psa_invec_t *iovec_temp,
size_t tx_len,
size_t rx_len
)
{
error_t status = PSA_SUCCESS;
memset(response_buf, 0, sizeof(response_buf));
psa_outvec_t resp = { response_buf, rx_len };
status = psa_call(handle, iovec_temp, tx_len, &resp, 1);
TEST_ASSERT_EQUAL_INT(PSA_SUCCESS, status);
}
static void negative_client_ipc_tests_close(psa_handle_t handle)
{
psa_close(handle);
// Wait for psa_close to finish on server side
osDelay(50);
}
//Testing client call with an invalid SID
void client_connect_invalid_sid()
{
psa_connect(INVALID_SID,
MINOR_VER
);
TEST_FAIL_MESSAGE("client_connect_invalid_sid negative test failed");
}
//Testing client connect version policy is RELAXED and minor version is bigger than the minimum version
void client_connect_invalid_pol_ver_RELAXED()
{
psa_connect(NEG_CLIENT_PART1_ROT_SRV1, //NEG_CLIENT_PART1_ROT_SRV1 should have RELAXED policy
INVALID_MINOR
);
TEST_FAIL_MESSAGE("client_connect_invalid_pol_ver_RELAXED negative test failed");
}
//Testing client connect version policy is STRICT and requeted version is higher than the minimum version
void client_connect_invalid_high_pol_ver_STRICT()
{
psa_connect(NEG_CLIENT_PART1_ROT_SRV2, //NEG_CLIENT_PART1_ROT_SRV2 should have STRICT policy
INVALID_MINOR
);
TEST_FAIL_MESSAGE("client_connect_invalid_high_pol_ver_STRICT negative test failed");
}
//Testing client connect version policy is STRICT and requeted version equales the minimum version
void client_connect_invalid_equal_pol_ver_STRICT()
{
psa_connect(NEG_CLIENT_PART1_ROT_SRV2, //NEG_CLIENT_PART1_ROT_SRV2 should have STRICT policy
MINOR_VER
);
TEST_FAIL_MESSAGE("client_connect_invalid_equal_pol_ver_STRICT negative test failed");
}
//Testing client call num of iovecs (tx_len + rx_len) is bigger than max value allowed
void client_call_invalid_iovecs_len()
{
psa_handle_t handle = 0;
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t invec_temp[PSA_MAX_IOVEC] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
psa_outvec_t outvec_temp[1] = {
{data, sizeof(data)}
};
// PSA_MAX_IOVEC invecs + 1 outvec
psa_call(handle, invec_temp, PSA_MAX_IOVEC, outvec_temp, 1);
TEST_FAIL_MESSAGE("client_call_invalid_iovecs_len negative test failed");
}
//Testing client call return buffer (rx_buff) is NULL and return buffer len is not 0
void client_call_rx_buff_null_rx_len_not_zero()
{
psa_handle_t handle = 0;
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[3] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
psa_call(handle, iovec_temp, 3, NULL, 1);
TEST_FAIL_MESSAGE("client_call_rx_buff_null_rx_len_not_zero negative test failed");
}
//Testing client call iovecs pointer is NULL and num of iovecs is not 0
void client_call_iovecs_null_tx_len_not_zero()
{
psa_handle_t handle = 0;
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
memset(response_buf, 0, CLIENT_RSP_BUF_SIZE);
psa_outvec_t resp = { response_buf, CLIENT_RSP_BUF_SIZE };
psa_call(handle, NULL, 2, &resp, 1);
TEST_FAIL_MESSAGE("client_call_iovecs_null_tx_len_not_zero negative test failed");
}
//Testing client call iovec base pointer is NULL and iovec size is not 0
void client_call_iovec_base_null_len_not_zero()
{
negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{NULL, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
negative_client_ipc_tests_call(PSA_NULL_HANDLE, iovec_temp, PSA_MAX_IOVEC - 1, 0);
TEST_FAIL_MESSAGE("client_call_iovec_base_null_len_not_zero negative test failed");
}
//Testing client call handle does not exist on the platform
void client_call_invalid_handle()
{
psa_handle_t handle = 0, invalid_handle = 0;
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
invalid_handle = handle + 10;
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
negative_client_ipc_tests_call(invalid_handle, iovec_temp, PSA_MAX_IOVEC - 1, 0);
TEST_FAIL_MESSAGE("client_call_invalid_handle negative test failed");
}
//Testing client call handle is null (PSA_NULL_HANDLE)
void client_call_handle_is_null()
{
negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
negative_client_ipc_tests_call(PSA_NULL_HANDLE, iovec_temp, PSA_MAX_IOVEC - 1, 0);
TEST_FAIL_MESSAGE("client_call_handle_is_null negative test failed");
}
//Testing client close handle does not exist on the platform
void client_close_invalid_handle()
{
psa_handle_t handle = 0, invalid_handle = 0;
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
invalid_handle = handle + 10;
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
negative_client_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, 0);
negative_client_ipc_tests_close(invalid_handle);
TEST_FAIL_MESSAGE("client_close_invalid_handle negative test failed");
}
void client_call_buffer_wrap_around()
{
psa_handle_t handle = 0;
psa_invec_t iovec_temp = { (void *)0x80000000, UINT32_MAX };
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
psa_call(handle, &iovec_temp, 1, NULL, 0);
TEST_FAIL_MESSAGE("client_call_buffer_wrap_around negative test failed");
}
void client_connect_not_allowed_from_nspe()
{
psa_connect(NEG_CLIENT_PART1_ROT_SRV2, 5);
TEST_FAIL_MESSAGE("client_connect_not_allowed_from_nspe negative test failed");
}
void client_call_excess_outvec()
{
psa_handle_t handle = 0;
uint8_t data[2] = {1, 0};
psa_outvec_t iovec_temp[PSA_MAX_IOVEC + 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
handle = negative_client_ipc_tests_connect(NEG_CLIENT_PART1_ROT_SRV1, MINOR_VER);
psa_call(handle, NULL, 0, iovec_temp, PSA_MAX_IOVEC + 1);
TEST_FAIL_MESSAGE("client_call_excess_outvec negative test failed");
}
PSA_NEG_TEST(client_connect_invalid_sid)
PSA_NEG_TEST(client_connect_invalid_pol_ver_RELAXED)
PSA_NEG_TEST(client_connect_invalid_high_pol_ver_STRICT)
PSA_NEG_TEST(client_connect_invalid_equal_pol_ver_STRICT)
PSA_NEG_TEST(client_call_invalid_iovecs_len)
PSA_NEG_TEST(client_call_rx_buff_null_rx_len_not_zero)
PSA_NEG_TEST(client_call_iovecs_null_tx_len_not_zero)
PSA_NEG_TEST(client_call_iovec_base_null_len_not_zero)
PSA_NEG_TEST(client_call_invalid_handle)
PSA_NEG_TEST(client_call_handle_is_null)
PSA_NEG_TEST(client_close_invalid_handle)
PSA_NEG_TEST(client_call_buffer_wrap_around)
PSA_NEG_TEST(client_connect_not_allowed_from_nspe)
PSA_NEG_TEST(client_call_excess_outvec)
utest::v1::status_t spm_case_teardown(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)
{
spm_reboot();
error_thrown = false;
return greentea_case_teardown_handler(source, passed, failed, reason);
}
#define SPM_UTEST_CASE(desc, test) Case(desc, PSA_NEG_TEST_NAME(test), spm_case_teardown)
// Test cases
Case cases[] = {
SPM_UTEST_CASE("Testing client connect invalid sid", client_connect_invalid_sid),
SPM_UTEST_CASE("Testing client connect version policy RELAXED invalid minor", client_connect_invalid_pol_ver_RELAXED),
SPM_UTEST_CASE("Testing client connect version policy STRICT high minor", client_connect_invalid_high_pol_ver_STRICT),
SPM_UTEST_CASE("Testing client connect version policy STRICT equal minor", client_connect_invalid_equal_pol_ver_STRICT),
SPM_UTEST_CASE("Testing client call invalid num of iovecs (tx_len + rx_len)", client_call_invalid_iovecs_len),
SPM_UTEST_CASE("Testing client call rx_buff is NULL rx_len is not 0", client_call_rx_buff_null_rx_len_not_zero),
SPM_UTEST_CASE("Testing client call iovecs is NULL tx_len is not 0", client_call_iovecs_null_tx_len_not_zero),
SPM_UTEST_CASE("Testing client call iovec base NULL while iovec len not 0", client_call_iovec_base_null_len_not_zero),
SPM_UTEST_CASE("Testing client call handle does not exist", client_call_invalid_handle),
SPM_UTEST_CASE("Testing client call handle is PSA_NULL_HANDLE", client_call_handle_is_null),
SPM_UTEST_CASE("Testing client close handle does not exist", client_close_invalid_handle),
SPM_UTEST_CASE("Testing client call with buffer wrap-around", client_call_buffer_wrap_around),
SPM_UTEST_CASE("Testing client connect to non-NSPE ROT_SRV", client_connect_not_allowed_from_nspe),
SPM_UTEST_CASE("Testing client call with too much outvec's", client_call_excess_outvec)
};
utest::v1::status_t spm_setup(const size_t number_of_cases)
{
#ifndef NO_GREENTEA
GREENTEA_SETUP(60, "default_auto");
#endif
return greentea_test_setup_handler(number_of_cases);
}
Specification specification(spm_setup, cases);
int main()
{
Harness::run(specification);
return 0;
}

View File

@ -1,32 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#define PSA_NEG_TEST_NAME(test_name) psa_neg_test_ ## test_name
#define PSA_NEG_TEST(test_name) \
void PSA_NEG_TEST_NAME(test_name)() \
{ \
osStatus status = osOK; \
Thread T1; \
\
status = T1.start(test_name); \
TEST_ASSERT_TRUE(status == osOK); \
test_sem.wait(osWaitForever); \
TEST_ASSERT_TRUE(error_thrown); \
\
status = T1.terminate(); \
TEST_ASSERT_TRUE(status == osOK); \
} \

View File

@ -1,29 +0,0 @@
{
"name": "NEG_CLIENT_PART1",
"type": "APPLICATION-ROT",
"priority": "NORMAL",
"id": "0x00000005",
"entry_point": "server_main1",
"stack_size": "0x200",
"heap_size": "0x400",
"services": [{
"name": "NEG_CLIENT_PART1_ROT_SRV1",
"identifier": "0x00001A06",
"signal": "NEG_CLIENT_PART1_ROT_SRV1_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "NEG_CLIENT_PART1_ROT_SRV2",
"identifier": "0x00001A07",
"signal": "NEG_CLIENT_PART1_ROT_SRV2_MSK",
"non_secure_clients": false,
"minor_version": 5,
"minor_policy": "STRICT"
}
],
"source_files": [
"server1.c"
]
}

View File

@ -1,64 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "spm_panic.h"
#include "spm_internal.h"
#include "handles_manager.h"
#include "cmsis.h"
#include "psa_neg_client_part1_partition.h"
spm_partition_t g_partitions[1] = {
{
.partition_id = NEG_CLIENT_PART1_ID,
.thread_id = 0,
.flags_rot_srv = NEG_CLIENT_PART1_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = NEG_CLIENT_PART1_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = NEG_CLIENT_PART1_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
};
/* Check all the defined memory regions for overlapping. */
/* A list of all the memory regions. */
const mem_region_t *mem_regions = NULL;
const uint32_t mem_region_count = 0;
// forward declaration of partition initializers
void neg_client_part1_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions)
{
if (NULL == partitions) {
SPM_PANIC("partitions is NULL!\n");
}
neg_client_part1_init(&(g_partitions[0]));
*partitions = g_partitions;
return 1;
}

View File

@ -1,58 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <stdbool.h>
#include <string.h>
#include "spm_server.h"
#include "spm_panic.h"
#include "psa_neg_client_part1_partition.h"
#define msg_buff_SIZE 128
char msg_buff[msg_buff_SIZE];
void server_main1(void *ptr)
{
uint32_t signals = 0;
memset(msg_buff, 0, sizeof(msg_buff));
while (true) {
signals = psa_wait_any(PSA_BLOCK);
if (signals & NEG_CLIENT_PART1_ROT_SRV1_MSK) {
psa_msg_t msg = {0};
psa_get(NEG_CLIENT_PART1_ROT_SRV1_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT:
case PSA_IPC_DISCONNECT:
break;
case PSA_IPC_CALL: {
memset(msg_buff, 0, msg_buff_SIZE);
uint32_t bytes_read = 0;
for (size_t i = 0; i < PSA_MAX_IOVEC; i++) {
bytes_read = psa_read(msg.handle, i, msg_buff + bytes_read, msg.in_size[i]);
}
if (msg.out_size[0] > 0) {
psa_write(msg.handle, 0, msg_buff, bytes_read);
}
break;
}
default:
SPM_PANIC("Unknown message type");
break;
}
psa_reply(msg.handle, PSA_SUCCESS);
}
}
}

View File

@ -1,67 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <string.h>
#include "spm_internal.h"
extern spm_db_t g_spm;
extern psa_handle_item_t g_channels_handle_storage[];
extern psa_handle_item_t g_messages_handle_storage[];
extern spm_ipc_channel_t g_channel_data[];
extern spm_active_msg_t g_active_messages_data[];
void psa_spm_init(void);
void spm_reboot(void)
{
osStatus_t status;
for (uint32_t i = 0; i < g_spm.partition_count; ++i) {
status = osThreadTerminate(g_spm.partitions[i].thread_id);
MBED_ASSERT(status == osOK);
status = osMutexDelete(g_spm.partitions[i].mutex);
MBED_ASSERT(status == osOK);
for (uint32_t j = 0; j < g_spm.partitions[i].rot_services_count; ++j) {
g_spm.partitions[i].rot_services[j].partition = NULL;
g_spm.partitions[i].rot_services[j].queue.head = NULL;
g_spm.partitions[i].rot_services[j].queue.tail = NULL;
}
g_spm.partitions[i].rot_services = NULL;
g_spm.partitions[i].mutex = NULL;
g_spm.partitions[i].thread_id = NULL;
}
status = osMemoryPoolDelete(g_spm.channel_mem_pool);
MBED_ASSERT(status == osOK);
status = osMemoryPoolDelete(g_spm.active_messages_mem_pool);
MBED_ASSERT(status == osOK);
memset(g_channels_handle_storage, 0, (sizeof(psa_handle_item_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS));
memset(g_messages_handle_storage, 0, (sizeof(psa_handle_item_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES));
memset(g_channel_data, 0, (sizeof(spm_ipc_channel_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS));
memset(g_active_messages_data, 0, (sizeof(spm_active_msg_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES));
memset(&g_spm, 0, sizeof(g_spm));
g_spm.channels_handle_mgr.handle_generator = PSA_HANDLE_MGR_INVALID_HANDLE;
g_spm.channels_handle_mgr.pool_size = MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS;
g_spm.channels_handle_mgr.handles_pool = g_channels_handle_storage;
g_spm.messages_handle_mgr.handle_generator = PSA_HANDLE_MGR_INVALID_HANDLE;
g_spm.messages_handle_mgr.pool_size = MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES;
g_spm.messages_handle_mgr.handles_pool = g_messages_handle_storage;
psa_spm_init();
PSA_UNUSED(status);
}

View File

@ -1,27 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_DUAL_PART1_PARTITION_ROT_SERVICES_H
#define PSA_NEG_DUAL_PART1_PARTITION_ROT_SERVICES_H
#define PART1_CALL_NON_EXISTS_EXTERN_SID 0x00001A08
#endif // PSA_NEG_DUAL_PART1_PARTITION_ROT_SERVICES_H

View File

@ -1,97 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "cmsis.h"
#include "mbed_toolchain.h" /* For using MBED_ALIGN macro */
#include "rtx_os.h"
#include "spm_panic.h"
#include "spm_internal.h"
#include "psa_neg_dual_part1_partition.h"
#include "psa_neg_dual_part1_ifs.h"
/* Threads stacks */
MBED_ALIGN(8) uint8_t neg_dual_part1_thread_stack[512] = {0};
/* Threads control blocks */
osRtxThread_t neg_dual_part1_thread_cb = {0};
/* Thread attributes - for thread initialization */
osThreadAttr_t neg_dual_part1_thread_attr = {
.name = "neg_dual_part1",
.attr_bits = 0,
.cb_mem = &neg_dual_part1_thread_cb,
.cb_size = sizeof(neg_dual_part1_thread_cb),
.stack_mem = neg_dual_part1_thread_stack,
.stack_size = 512,
.priority = osPriorityNormal,
.tz_module = 0,
.reserved = 0
};
spm_rot_service_t neg_dual_part1_rot_services[NEG_DUAL_PART1_ROT_SRV_COUNT] = {
{
.sid = PART1_CALL_NON_EXISTS_EXTERN_SID,
.mask = PART1_CALL_NON_EXISTS_EXTERN_SID_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
};
static osRtxMutex_t neg_dual_part1_mutex = {0};
static const osMutexAttr_t neg_dual_part1_mutex_attr = {
.name = "neg_dual_part1_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &neg_dual_part1_mutex,
.cb_size = sizeof(neg_dual_part1_mutex),
};
extern void server_main1(void *ptr);
void neg_dual_part1_init(spm_partition_t *partition)
{
if (NULL == partition) {
SPM_PANIC("partition is NULL!\n");
}
partition->mutex = osMutexNew(&neg_dual_part1_mutex_attr);
if (NULL == partition->mutex) {
SPM_PANIC("Failed to create mutex for secure partition neg_dual_part1!\n");
}
for (uint32_t i = 0; i < NEG_DUAL_PART1_ROT_SRV_COUNT; ++i) {
neg_dual_part1_rot_services[i].partition = partition;
}
partition->rot_services = neg_dual_part1_rot_services;
partition->thread_id = osThreadNew(server_main1, NULL, &neg_dual_part1_thread_attr);
if (NULL == partition->thread_id) {
SPM_PANIC("Failed to create start main thread of partition neg_dual_part1!\n");
}
}

View File

@ -1,52 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_DUAL_PART1_PARTITION_H
#define PSA_NEG_DUAL_PART1_PARTITION_H
#define NEG_DUAL_PART1_ID 6
#define NEG_DUAL_PART1_ROT_SRV_COUNT (1UL)
#define NEG_DUAL_PART1_EXT_ROT_SRV_COUNT (0UL)
/* NEG_DUAL_PART1 event flags */
#define NEG_DUAL_PART1_RESERVED1_POS (1UL)
#define NEG_DUAL_PART1_RESERVED1_MSK (1UL << NEG_DUAL_PART1_RESERVED1_POS)
#define NEG_DUAL_PART1_RESERVED2_POS (2UL)
#define NEG_DUAL_PART1_RESERVED2_MSK (1UL << NEG_DUAL_PART1_RESERVED2_POS)
#define PART1_CALL_NON_EXISTS_EXTERN_SID_MSK_POS (4UL)
#define PART1_CALL_NON_EXISTS_EXTERN_SID_MSK (1UL << PART1_CALL_NON_EXISTS_EXTERN_SID_MSK_POS)
#define NEG_DUAL_PART1_WAIT_ANY_SID_MSK (\
PART1_CALL_NON_EXISTS_EXTERN_SID_MSK)
/*
#define NEG_DUAL_PART1_WAIT_ANY_MSK (\
NEG_DUAL_PART1_WAIT_ANY_SID_MSK) | \
PSA_DOORBELL)
*/
#endif // PSA_NEG_DUAL_PART1_PARTITION_H

View File

@ -1,28 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_DUAL_PART2_PARTITION_ROT_SERVICES_H
#define PSA_NEG_DUAL_PART2_PARTITION_ROT_SERVICES_H
#define DUMMY 0x00001A09
#define PART2_CALL_INSIDE_PARTITION 0x00001A0A
#endif // PSA_NEG_DUAL_PART2_PARTITION_ROT_SERVICES_H

View File

@ -1,114 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "cmsis.h"
#include "mbed_toolchain.h" /* For using MBED_ALIGN macro */
#include "rtx_os.h"
#include "spm_panic.h"
#include "spm_internal.h"
#include "psa_neg_dual_part2_partition.h"
#include "psa_neg_dual_part2_ifs.h"
#include "psa_neg_dual_part1_ifs.h"
/* Threads stacks */
MBED_ALIGN(8) uint8_t neg_dual_part2_thread_stack[512] = {0};
/* Threads control blocks */
osRtxThread_t neg_dual_part2_thread_cb = {0};
/* Thread attributes - for thread initialization */
osThreadAttr_t neg_dual_part2_thread_attr = {
.name = "neg_dual_part2",
.attr_bits = 0,
.cb_mem = &neg_dual_part2_thread_cb,
.cb_size = sizeof(neg_dual_part2_thread_cb),
.stack_mem = neg_dual_part2_thread_stack,
.stack_size = 512,
.priority = osPriorityNormal,
.tz_module = 0,
.reserved = 0
};
spm_rot_service_t neg_dual_part2_rot_services[NEG_DUAL_PART2_ROT_SRV_COUNT] = {
{
.sid = DUMMY,
.mask = DUMMY_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = false,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_CALL_INSIDE_PARTITION,
.mask = PART2_CALL_INSIDE_PARTITION_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
};
/* External SIDs used by NEG_DUAL_PART2 */
const uint32_t neg_dual_part2_external_sids[1] = {
PART1_CALL_NON_EXISTS_EXTERN_SID,
};
static osRtxMutex_t neg_dual_part2_mutex = {0};
static const osMutexAttr_t neg_dual_part2_mutex_attr = {
.name = "neg_dual_part2_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &neg_dual_part2_mutex,
.cb_size = sizeof(neg_dual_part2_mutex),
};
extern void server_main2(void *ptr);
void neg_dual_part2_init(spm_partition_t *partition)
{
if (NULL == partition) {
SPM_PANIC("partition is NULL!\n");
}
partition->mutex = osMutexNew(&neg_dual_part2_mutex_attr);
if (NULL == partition->mutex) {
SPM_PANIC("Failed to create mutex for secure partition neg_dual_part2!\n");
}
for (uint32_t i = 0; i < NEG_DUAL_PART2_ROT_SRV_COUNT; ++i) {
neg_dual_part2_rot_services[i].partition = partition;
}
partition->rot_services = neg_dual_part2_rot_services;
partition->thread_id = osThreadNew(server_main2, NULL, &neg_dual_part2_thread_attr);
if (NULL == partition->thread_id) {
SPM_PANIC("Failed to create start main thread of partition neg_dual_part2!\n");
}
}

View File

@ -1,55 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_DUAL_PART2_PARTITION_H
#define PSA_NEG_DUAL_PART2_PARTITION_H
#define NEG_DUAL_PART2_ID 7
#define NEG_DUAL_PART2_ROT_SRV_COUNT (2UL)
#define NEG_DUAL_PART2_EXT_ROT_SRV_COUNT (1UL)
/* NEG_DUAL_PART2 event flags */
#define NEG_DUAL_PART2_RESERVED1_POS (1UL)
#define NEG_DUAL_PART2_RESERVED1_MSK (1UL << NEG_DUAL_PART2_RESERVED1_POS)
#define NEG_DUAL_PART2_RESERVED2_POS (2UL)
#define NEG_DUAL_PART2_RESERVED2_MSK (1UL << NEG_DUAL_PART2_RESERVED2_POS)
#define DUMMY_MSK_POS (4UL)
#define DUMMY_MSK (1UL << DUMMY_MSK_POS)
#define PART2_CALL_INSIDE_PARTITION_MSK_POS (5UL)
#define PART2_CALL_INSIDE_PARTITION_MSK (1UL << PART2_CALL_INSIDE_PARTITION_MSK_POS)
#define NEG_DUAL_PART2_WAIT_ANY_SID_MSK (\
DUMMY_MSK | \
PART2_CALL_INSIDE_PARTITION_MSK)
/*
#define NEG_DUAL_PART2_WAIT_ANY_MSK (\
NEG_DUAL_PART2_WAIT_ANY_SID_MSK) | \
PSA_DOORBELL)
*/
#endif // PSA_NEG_DUAL_PART2_PARTITION_H

View File

@ -1,101 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !ENABLE_SPM
#error [NOT_SUPPORTED] SPM is not supported on this platform
#endif
#include "cmsis_os2.h"
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "rtos.h"
#include "spm_client.h"
#include "psa_neg_dual_part1_ifs.h"
#include "psa_neg_dual_part2_ifs.h"
#include "neg_tests.h"
#define MINOR_VER 5
using namespace utest::v1;
Semaphore test_sem(0);
bool error_thrown = false;
extern "C" void spm_reboot(void);
void error(const char *format, ...)
{
error_thrown = true;
osStatus status = test_sem.release();
MBED_ASSERT(status == osOK);
PSA_UNUSED(status);
while (1);
}
/* ------------------------------------- Functions ----------------------------------- */
void server_call_sid_without_extern_sid()
{
psa_handle_t handle = psa_connect(PART1_CALL_NON_EXISTS_EXTERN_SID, MINOR_VER);
TEST_ASSERT_TRUE(handle > 0);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("psa_call from SP to SID not listed as extern_sids didn't fail");
}
void server_call_sid_in_same_partition()
{
psa_handle_t handle = psa_connect(PART2_CALL_INSIDE_PARTITION, MINOR_VER);
TEST_ASSERT_TRUE(handle > 0);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("psa_call from SP to SID within same SP didn't fail");
}
PSA_NEG_TEST(server_call_sid_without_extern_sid)
PSA_NEG_TEST(server_call_sid_in_same_partition)
utest::v1::status_t spm_case_teardown(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)
{
spm_reboot();
error_thrown = false;
return greentea_case_teardown_handler(source, passed, failed, reason);
}
#define SPM_UTEST_CASE(desc, test) Case(desc, PSA_NEG_TEST_NAME(test), spm_case_teardown)
// Test cases
Case cases[] = {
SPM_UTEST_CASE("Testing server calling sid without extern sid", server_call_sid_without_extern_sid),
SPM_UTEST_CASE("Testing server calling sid within the same partition", server_call_sid_in_same_partition)
};
utest::v1::status_t spm_setup(const size_t number_of_cases)
{
#ifndef NO_GREENTEA
GREENTEA_SETUP(60, "default_auto");
#endif
return greentea_test_setup_handler(number_of_cases);
}
Specification specification(spm_setup, cases);
int main()
{
Harness::run(specification);
return 0;
}

View File

@ -1,32 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#define PSA_NEG_TEST_NAME(test_name) psa_neg_test_ ## test_name
#define PSA_NEG_TEST(test_name) \
void PSA_NEG_TEST_NAME(test_name)() \
{ \
osStatus status = osOK; \
Thread T1; \
\
status = T1.start(test_name); \
TEST_ASSERT_TRUE(status == osOK); \
test_sem.wait(osWaitForever); \
TEST_ASSERT_TRUE(error_thrown); \
\
status = T1.terminate(); \
TEST_ASSERT_TRUE(status == osOK); \
} \

View File

@ -1,21 +0,0 @@
{
"name": "NEG_DUAL_PART1",
"type": "APPLICATION-ROT",
"priority": "NORMAL",
"id": "0x00000006",
"entry_point": "server_main1",
"stack_size": "0x200",
"heap_size": "0x400",
"services": [{
"name": "PART1_CALL_NON_EXISTS_EXTERN_SID",
"identifier": "0x00001A08",
"signal": "PART1_CALL_NON_EXISTS_EXTERN_SID_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
}
],
"source_files": [
"server1.c"
]
}

View File

@ -1,32 +0,0 @@
{
"name": "NEG_DUAL_PART2",
"type": "APPLICATION-ROT",
"priority": "NORMAL",
"id": "0x00000007",
"entry_point": "server_main2",
"stack_size": "0x200",
"heap_size": "0x400",
"services": [{
"name": "DUMMY",
"identifier": "0x00001A09",
"signal": "DUMMY_MSK",
"non_secure_clients": false,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_CALL_INSIDE_PARTITION",
"identifier": "0x00001A0A",
"signal": "PART2_CALL_INSIDE_PARTITION_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
}
],
"extern_sids": [
"PART1_CALL_NON_EXISTS_EXTERN_SID"
],
"source_files": [
"server2.c"
]
}

View File

@ -1,79 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "spm_panic.h"
#include "spm_internal.h"
#include "handles_manager.h"
#include "cmsis.h"
#include "psa_neg_dual_part1_partition.h"
#include "psa_neg_dual_part2_partition.h"
extern const uint32_t neg_dual_part2_external_sids[1];
spm_partition_t g_partitions[2] = {
{
.partition_id = NEG_DUAL_PART1_ID,
.thread_id = 0,
.flags_rot_srv = NEG_DUAL_PART1_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = NEG_DUAL_PART1_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = NEG_DUAL_PART1_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{
.partition_id = NEG_DUAL_PART2_ID,
.thread_id = 0,
.flags_rot_srv = NEG_DUAL_PART2_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = NEG_DUAL_PART2_ROT_SRV_COUNT,
.extern_sids = neg_dual_part2_external_sids,
.extern_sids_count = NEG_DUAL_PART2_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
};
/* Check all the defined memory regions for overlapping. */
/* A list of all the memory regions. */
const mem_region_t *mem_regions = NULL;
const uint32_t mem_region_count = 0;
// forward declaration of partition initializers
void neg_dual_part1_init(spm_partition_t *partition);
void neg_dual_part2_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions)
{
if (NULL == partitions) {
SPM_PANIC("partitions is NULL!\n");
}
neg_dual_part1_init(&(g_partitions[0]));
neg_dual_part2_init(&(g_partitions[1]));
*partitions = g_partitions;
return 2;
}

View File

@ -1,55 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <stdbool.h>
#include <string.h>
#include "unity.h"
#include "spm_panic.h"
#include "spm_server.h"
#include "spm_client.h"
#include "spm_panic.h"
#include "psa_neg_dual_part1_partition.h"
#include "psa_neg_dual_part2_ifs.h"
#define MINOR_VER 5
void server_main1(void *ptr)
{
psa_msg_t msg = {0};
uint32_t signals = 0;
while (true) {
signals = psa_wait_any(PSA_BLOCK);
if (signals & PART1_CALL_NON_EXISTS_EXTERN_SID_MSK) {
psa_get(PART1_CALL_NON_EXISTS_EXTERN_SID_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_reply(msg.handle, PSA_SUCCESS);
break;
}
case PSA_IPC_CALL: {
psa_connect(PART2_CALL_INSIDE_PARTITION, MINOR_VER);
TEST_FAIL_MESSAGE("server_call_sid_without_extern_sid negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_call_sid_without_extern_sid msg type failure");
}
}
} else {
SPM_PANIC("Unknown signal (0x%08x)", signals);
}
}
}

View File

@ -1,66 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <string.h>
#include "cmsis_os2.h"
#include "unity.h"
#include "spm_panic.h"
#include "spm_server.h"
#include "spm_client.h"
#include "spm_panic.h"
#include "psa_neg_dual_part2_partition.h"
#include "psa_neg_dual_part2_ifs.h"
#define MINOR_VER 5
void server_main2(void *ptr)
{
uint32_t signals = 0;
psa_msg_t msg = {0};
while (1) {
signals = psa_wait_any(PSA_BLOCK);
if (signals & DUMMY_MSK) {
psa_get(DUMMY_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CALL:
case PSA_IPC_CONNECT:
case PSA_IPC_DISCONNECT:
psa_reply(msg.handle, PSA_SUCCESS);
break;
default:
SPM_PANIC("Invalid msg type");
}
} else if (signals & PART2_CALL_INSIDE_PARTITION_MSK) {
psa_get(PART2_CALL_INSIDE_PARTITION_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_reply(msg.handle, PSA_SUCCESS);
break;
}
case PSA_IPC_CALL: {
psa_connect(DUMMY, MINOR_VER);
TEST_FAIL_MESSAGE("server_call_sid_in_same_partition negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_call_sid_in_same_partition msg type failure");
}
}
} else {
SPM_PANIC("Unknown signal (0x%08x)", signals);
}
}
}

View File

@ -1,67 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <string.h>
#include "spm_internal.h"
extern spm_db_t g_spm;
extern psa_handle_item_t g_channels_handle_storage[];
extern psa_handle_item_t g_messages_handle_storage[];
extern spm_ipc_channel_t g_channel_data[];
extern spm_active_msg_t g_active_messages_data[];
void psa_spm_init(void);
void spm_reboot(void)
{
osStatus_t status;
for (uint32_t i = 0; i < g_spm.partition_count; ++i) {
status = osThreadTerminate(g_spm.partitions[i].thread_id);
MBED_ASSERT(status == osOK);
status = osMutexDelete(g_spm.partitions[i].mutex);
MBED_ASSERT(status == osOK);
for (uint32_t j = 0; j < g_spm.partitions[i].rot_services_count; ++j) {
g_spm.partitions[i].rot_services[j].partition = NULL;
g_spm.partitions[i].rot_services[j].queue.head = NULL;
g_spm.partitions[i].rot_services[j].queue.tail = NULL;
}
g_spm.partitions[i].rot_services = NULL;
g_spm.partitions[i].mutex = NULL;
g_spm.partitions[i].thread_id = NULL;
}
status = osMemoryPoolDelete(g_spm.channel_mem_pool);
MBED_ASSERT(status == osOK);
status = osMemoryPoolDelete(g_spm.active_messages_mem_pool);
MBED_ASSERT(status == osOK);
memset(g_channels_handle_storage, 0, (sizeof(psa_handle_item_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS));
memset(g_messages_handle_storage, 0, (sizeof(psa_handle_item_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES));
memset(g_channel_data, 0, (sizeof(spm_ipc_channel_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS));
memset(g_active_messages_data, 0, (sizeof(spm_active_msg_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES));
memset(&g_spm, 0, sizeof(g_spm));
g_spm.channels_handle_mgr.handle_generator = PSA_HANDLE_MGR_INVALID_HANDLE;
g_spm.channels_handle_mgr.pool_size = MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS;
g_spm.channels_handle_mgr.handles_pool = g_channels_handle_storage;
g_spm.messages_handle_mgr.handle_generator = PSA_HANDLE_MGR_INVALID_HANDLE;
g_spm.messages_handle_mgr.pool_size = MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES;
g_spm.messages_handle_mgr.handles_pool = g_messages_handle_storage;
psa_spm_init();
PSA_UNUSED(status);
}

View File

@ -1,30 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_SERVER_PART1_PARTITION_ROT_SERVICES_H
#define PSA_NEG_SERVER_PART1_PARTITION_ROT_SERVICES_H
#define PART1_REPLY_INVALID_RETVAL_CONNECT 0x00001A25
#define PART1_REPLY_INVALID_RETVAL_CALL 0x00001A26
#define PART1_CLEAR_NO_DOORBELL 0x00001A27
#define PART1_WRITE_OUTVEC_IX_SIZE_0 0x00001A28
#endif // PSA_NEG_SERVER_PART1_PARTITION_ROT_SERVICES_H

View File

@ -1,133 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "cmsis.h"
#include "mbed_toolchain.h" /* For using MBED_ALIGN macro */
#include "rtx_os.h"
#include "spm_panic.h"
#include "spm_internal.h"
#include "psa_neg_server_part1_partition.h"
#include "psa_neg_server_part1_ifs.h"
/* Threads stacks */
MBED_ALIGN(8) uint8_t neg_server_part1_thread_stack[512] = {0};
/* Threads control blocks */
osRtxThread_t neg_server_part1_thread_cb = {0};
/* Thread attributes - for thread initialization */
osThreadAttr_t neg_server_part1_thread_attr = {
.name = "neg_server_part1",
.attr_bits = 0,
.cb_mem = &neg_server_part1_thread_cb,
.cb_size = sizeof(neg_server_part1_thread_cb),
.stack_mem = neg_server_part1_thread_stack,
.stack_size = 512,
.priority = osPriorityNormal,
.tz_module = 0,
.reserved = 0
};
spm_rot_service_t neg_server_part1_rot_services[NEG_SERVER_PART1_ROT_SRV_COUNT] = {
{
.sid = PART1_REPLY_INVALID_RETVAL_CONNECT,
.mask = PART1_REPLY_INVALID_RETVAL_CONNECT_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART1_REPLY_INVALID_RETVAL_CALL,
.mask = PART1_REPLY_INVALID_RETVAL_CALL_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART1_CLEAR_NO_DOORBELL,
.mask = PART1_CLEAR_NO_DOORBELL_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART1_WRITE_OUTVEC_IX_SIZE_0,
.mask = PART1_WRITE_OUTVEC_IX_SIZE_0_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
};
static osRtxMutex_t neg_server_part1_mutex = {0};
static const osMutexAttr_t neg_server_part1_mutex_attr = {
.name = "neg_server_part1_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &neg_server_part1_mutex,
.cb_size = sizeof(neg_server_part1_mutex),
};
extern void server_main1(void *ptr);
void neg_server_part1_init(spm_partition_t *partition)
{
if (NULL == partition) {
SPM_PANIC("partition is NULL!\n");
}
partition->mutex = osMutexNew(&neg_server_part1_mutex_attr);
if (NULL == partition->mutex) {
SPM_PANIC("Failed to create mutex for secure partition neg_server_part1!\n");
}
for (uint32_t i = 0; i < NEG_SERVER_PART1_ROT_SRV_COUNT; ++i) {
neg_server_part1_rot_services[i].partition = partition;
}
partition->rot_services = neg_server_part1_rot_services;
partition->thread_id = osThreadNew(server_main1, NULL, &neg_server_part1_thread_attr);
if (NULL == partition->thread_id) {
SPM_PANIC("Failed to create start main thread of partition neg_server_part1!\n");
}
}

View File

@ -1,61 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_SERVER_PART1_PARTITION_H
#define PSA_NEG_SERVER_PART1_PARTITION_H
#define NEG_SERVER_PART1_ID 7
#define NEG_SERVER_PART1_ROT_SRV_COUNT (4UL)
#define NEG_SERVER_PART1_EXT_ROT_SRV_COUNT (0UL)
/* NEG_SERVER_PART1 event flags */
#define NEG_SERVER_PART1_RESERVED1_POS (1UL)
#define NEG_SERVER_PART1_RESERVED1_MSK (1UL << NEG_SERVER_PART1_RESERVED1_POS)
#define NEG_SERVER_PART1_RESERVED2_POS (2UL)
#define NEG_SERVER_PART1_RESERVED2_MSK (1UL << NEG_SERVER_PART1_RESERVED2_POS)
#define PART1_REPLY_INVALID_RETVAL_CONNECT_MSK_POS (4UL)
#define PART1_REPLY_INVALID_RETVAL_CONNECT_MSK (1UL << PART1_REPLY_INVALID_RETVAL_CONNECT_MSK_POS)
#define PART1_REPLY_INVALID_RETVAL_CALL_MSK_POS (5UL)
#define PART1_REPLY_INVALID_RETVAL_CALL_MSK (1UL << PART1_REPLY_INVALID_RETVAL_CALL_MSK_POS)
#define PART1_CLEAR_NO_DOORBELL_MSK_POS (6UL)
#define PART1_CLEAR_NO_DOORBELL_MSK (1UL << PART1_CLEAR_NO_DOORBELL_MSK_POS)
#define PART1_WRITE_OUTVEC_IX_SIZE_0_MSK_POS (7UL)
#define PART1_WRITE_OUTVEC_IX_SIZE_0_MSK (1UL << PART1_WRITE_OUTVEC_IX_SIZE_0_MSK_POS)
#define NEG_SERVER_PART1_WAIT_ANY_SID_MSK (\
PART1_REPLY_INVALID_RETVAL_CONNECT_MSK | \
PART1_REPLY_INVALID_RETVAL_CALL_MSK | \
PART1_CLEAR_NO_DOORBELL_MSK | \
PART1_WRITE_OUTVEC_IX_SIZE_0_MSK)
/*
#define NEG_SERVER_PART1_WAIT_ANY_MSK (\
NEG_SERVER_PART1_WAIT_ANY_SID_MSK) | \
PSA_DOORBELL)
*/
#endif // PSA_NEG_SERVER_PART1_PARTITION_H

View File

@ -1,52 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_SERVER_PART2_PARTITION_ROT_SERVICES_H
#define PSA_NEG_SERVER_PART2_PARTITION_ROT_SERVICES_H
#define PART2_INT_MASK 0x00001A0B
#define PART2_GET_MSG_NULL 0x00001A0C
#define PART2_GET_SIGNUM_MULTIPLE_BIT 0x00001A0D
#define PART2_GET_SIGNUM_NOT_SUBSET 0x00001A0E
#define PART2_GET_SIGNUM_NOT_ACTIVE 0x00001A0F
#define PART2_GET_SIGNUM_TWICE 0x00001A10
#define PART2_READ_INVALID_HANDLE 0x00001A11
#define PART2_READ_NULL_HANDLE 0x00001A12
#define PART2_READ_TX_SIZE_ZERO 0x00001A13
#define PART2_WRITE_BUFFER_NULL 0x00001A14
#define PART2_WRITE_RX_BUFF_NULL 0x00001A15
#define PART2_WRITE_INVALID_HANDLE 0x00001A16
#define PART2_WRITE_NULL_HANDLE 0x00001A17
#define PART2_REPLY_INVALID_HANDLE 0x00001A18
#define PART2_REPLY_NULL_HANDLE 0x00001A19
#define PART2_NOTIFY_PART_ID_INVALID 0x00001A1A
#define PART2_IDENTITY_INVALID_HANDLE 0x00001A1B
#define PART2_IDENTITY_NULL_HANDLE 0x00001A1C
#define PART2_SET_RHANDLE_INVALID_HANDLE 0x00001A1D
#define PART2_SET_RHANDLE_NULL_HANDLE 0x00001A1E
#define PART2_READ_WRAPAROUND 0x00001A1F
#define PART2_READ_EXCESS_INVEC 0x00001A20
#define PART2_WRITE_WRAPAROUND 0x00001A21
#define PART2_WRITE_EXCESS_OUTVEC 0x00001A22
#define PART2_WRITE_SIZE_OVERFLOW 0x00001A23
#define PART2_READ_NULL_BUFFER 0x00001A24
#endif // PSA_NEG_SERVER_PART2_PARTITION_ROT_SERVICES_H

View File

@ -1,397 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "cmsis.h"
#include "mbed_toolchain.h" /* For using MBED_ALIGN macro */
#include "rtx_os.h"
#include "spm_panic.h"
#include "spm_internal.h"
#include "psa_neg_server_part2_partition.h"
#include "psa_neg_server_part2_ifs.h"
/* Threads stacks */
MBED_ALIGN(8) uint8_t neg_server_part2_thread_stack[640] = {0};
/* Threads control blocks */
osRtxThread_t neg_server_part2_thread_cb = {0};
/* Thread attributes - for thread initialization */
osThreadAttr_t neg_server_part2_thread_attr = {
.name = "neg_server_part2",
.attr_bits = 0,
.cb_mem = &neg_server_part2_thread_cb,
.cb_size = sizeof(neg_server_part2_thread_cb),
.stack_mem = neg_server_part2_thread_stack,
.stack_size = 640,
.priority = osPriorityNormal,
.tz_module = 0,
.reserved = 0
};
spm_rot_service_t neg_server_part2_rot_services[NEG_SERVER_PART2_ROT_SRV_COUNT] = {
{
.sid = PART2_INT_MASK,
.mask = PART2_INT_MASK_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_GET_MSG_NULL,
.mask = PART2_GET_MSG_NULL_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_GET_SIGNUM_MULTIPLE_BIT,
.mask = PART2_GET_SIGNUM_MULTIPLE_BIT_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_GET_SIGNUM_NOT_SUBSET,
.mask = PART2_GET_SIGNUM_NOT_SUBSET_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_GET_SIGNUM_NOT_ACTIVE,
.mask = PART2_GET_SIGNUM_NOT_ACTIVE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_GET_SIGNUM_TWICE,
.mask = PART2_GET_SIGNUM_TWICE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_READ_INVALID_HANDLE,
.mask = PART2_READ_INVALID_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_READ_NULL_HANDLE,
.mask = PART2_READ_NULL_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_READ_TX_SIZE_ZERO,
.mask = PART2_READ_TX_SIZE_ZERO_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_BUFFER_NULL,
.mask = PART2_WRITE_BUFFER_NULL_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_RX_BUFF_NULL,
.mask = PART2_WRITE_RX_BUFF_NULL_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_INVALID_HANDLE,
.mask = PART2_WRITE_INVALID_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_NULL_HANDLE,
.mask = PART2_WRITE_NULL_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_REPLY_INVALID_HANDLE,
.mask = PART2_REPLY_INVALID_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_REPLY_NULL_HANDLE,
.mask = PART2_REPLY_NULL_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_NOTIFY_PART_ID_INVALID,
.mask = PART2_NOTIFY_PART_ID_INVALID_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_IDENTITY_INVALID_HANDLE,
.mask = PART2_IDENTITY_INVALID_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_IDENTITY_NULL_HANDLE,
.mask = PART2_IDENTITY_NULL_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_SET_RHANDLE_INVALID_HANDLE,
.mask = PART2_SET_RHANDLE_INVALID_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_SET_RHANDLE_NULL_HANDLE,
.mask = PART2_SET_RHANDLE_NULL_HANDLE_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_READ_WRAPAROUND,
.mask = PART2_READ_WRAPAROUND_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_READ_EXCESS_INVEC,
.mask = PART2_READ_EXCESS_INVEC_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_WRAPAROUND,
.mask = PART2_WRITE_WRAPAROUND_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_EXCESS_OUTVEC,
.mask = PART2_WRITE_EXCESS_OUTVEC_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_WRITE_SIZE_OVERFLOW,
.mask = PART2_WRITE_SIZE_OVERFLOW_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
{
.sid = PART2_READ_NULL_BUFFER,
.mask = PART2_READ_NULL_BUFFER_MSK,
.partition = NULL,
.min_version = 5,
.min_version_policy = PSA_MINOR_VERSION_POLICY_RELAXED,
.allow_nspe = true,
.queue = {
.head = NULL,
.tail = NULL
}
},
};
static osRtxMutex_t neg_server_part2_mutex = {0};
static const osMutexAttr_t neg_server_part2_mutex_attr = {
.name = "neg_server_part2_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_mem = &neg_server_part2_mutex,
.cb_size = sizeof(neg_server_part2_mutex),
};
extern void server_main2(void *ptr);
void neg_server_part2_init(spm_partition_t *partition)
{
if (NULL == partition) {
SPM_PANIC("partition is NULL!\n");
}
partition->mutex = osMutexNew(&neg_server_part2_mutex_attr);
if (NULL == partition->mutex) {
SPM_PANIC("Failed to create mutex for secure partition neg_server_part2!\n");
}
for (uint32_t i = 0; i < NEG_SERVER_PART2_ROT_SRV_COUNT; ++i) {
neg_server_part2_rot_services[i].partition = partition;
}
partition->rot_services = neg_server_part2_rot_services;
partition->thread_id = osThreadNew(server_main2, NULL, &neg_server_part2_thread_attr);
if (NULL == partition->thread_id) {
SPM_PANIC("Failed to create start main thread of partition neg_server_part2!\n");
}
}

View File

@ -1,127 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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_NEG_SERVER_PART2_PARTITION_H
#define PSA_NEG_SERVER_PART2_PARTITION_H
#define NEG_SERVER_PART2_ID 8
#define NEG_SERVER_PART2_ROT_SRV_COUNT (26UL)
#define NEG_SERVER_PART2_EXT_ROT_SRV_COUNT (0UL)
/* NEG_SERVER_PART2 event flags */
#define NEG_SERVER_PART2_RESERVED1_POS (1UL)
#define NEG_SERVER_PART2_RESERVED1_MSK (1UL << NEG_SERVER_PART2_RESERVED1_POS)
#define NEG_SERVER_PART2_RESERVED2_POS (2UL)
#define NEG_SERVER_PART2_RESERVED2_MSK (1UL << NEG_SERVER_PART2_RESERVED2_POS)
#define PART2_INT_MASK_MSK_POS (4UL)
#define PART2_INT_MASK_MSK (1UL << PART2_INT_MASK_MSK_POS)
#define PART2_GET_MSG_NULL_MSK_POS (5UL)
#define PART2_GET_MSG_NULL_MSK (1UL << PART2_GET_MSG_NULL_MSK_POS)
#define PART2_GET_SIGNUM_MULTIPLE_BIT_MSK_POS (6UL)
#define PART2_GET_SIGNUM_MULTIPLE_BIT_MSK (1UL << PART2_GET_SIGNUM_MULTIPLE_BIT_MSK_POS)
#define PART2_GET_SIGNUM_NOT_SUBSET_MSK_POS (7UL)
#define PART2_GET_SIGNUM_NOT_SUBSET_MSK (1UL << PART2_GET_SIGNUM_NOT_SUBSET_MSK_POS)
#define PART2_GET_SIGNUM_NOT_ACTIVE_MSK_POS (8UL)
#define PART2_GET_SIGNUM_NOT_ACTIVE_MSK (1UL << PART2_GET_SIGNUM_NOT_ACTIVE_MSK_POS)
#define PART2_GET_SIGNUM_TWICE_MSK_POS (9UL)
#define PART2_GET_SIGNUM_TWICE_MSK (1UL << PART2_GET_SIGNUM_TWICE_MSK_POS)
#define PART2_READ_INVALID_HANDLE_MSK_POS (10UL)
#define PART2_READ_INVALID_HANDLE_MSK (1UL << PART2_READ_INVALID_HANDLE_MSK_POS)
#define PART2_READ_NULL_HANDLE_MSK_POS (11UL)
#define PART2_READ_NULL_HANDLE_MSK (1UL << PART2_READ_NULL_HANDLE_MSK_POS)
#define PART2_READ_TX_SIZE_ZERO_MSK_POS (12UL)
#define PART2_READ_TX_SIZE_ZERO_MSK (1UL << PART2_READ_TX_SIZE_ZERO_MSK_POS)
#define PART2_WRITE_BUFFER_NULL_MSK_POS (13UL)
#define PART2_WRITE_BUFFER_NULL_MSK (1UL << PART2_WRITE_BUFFER_NULL_MSK_POS)
#define PART2_WRITE_RX_BUFF_NULL_MSK_POS (14UL)
#define PART2_WRITE_RX_BUFF_NULL_MSK (1UL << PART2_WRITE_RX_BUFF_NULL_MSK_POS)
#define PART2_WRITE_INVALID_HANDLE_MSK_POS (15UL)
#define PART2_WRITE_INVALID_HANDLE_MSK (1UL << PART2_WRITE_INVALID_HANDLE_MSK_POS)
#define PART2_WRITE_NULL_HANDLE_MSK_POS (16UL)
#define PART2_WRITE_NULL_HANDLE_MSK (1UL << PART2_WRITE_NULL_HANDLE_MSK_POS)
#define PART2_REPLY_INVALID_HANDLE_MSK_POS (17UL)
#define PART2_REPLY_INVALID_HANDLE_MSK (1UL << PART2_REPLY_INVALID_HANDLE_MSK_POS)
#define PART2_REPLY_NULL_HANDLE_MSK_POS (18UL)
#define PART2_REPLY_NULL_HANDLE_MSK (1UL << PART2_REPLY_NULL_HANDLE_MSK_POS)
#define PART2_NOTIFY_PART_ID_INVALID_MSK_POS (19UL)
#define PART2_NOTIFY_PART_ID_INVALID_MSK (1UL << PART2_NOTIFY_PART_ID_INVALID_MSK_POS)
#define PART2_IDENTITY_INVALID_HANDLE_MSK_POS (20UL)
#define PART2_IDENTITY_INVALID_HANDLE_MSK (1UL << PART2_IDENTITY_INVALID_HANDLE_MSK_POS)
#define PART2_IDENTITY_NULL_HANDLE_MSK_POS (21UL)
#define PART2_IDENTITY_NULL_HANDLE_MSK (1UL << PART2_IDENTITY_NULL_HANDLE_MSK_POS)
#define PART2_SET_RHANDLE_INVALID_HANDLE_MSK_POS (22UL)
#define PART2_SET_RHANDLE_INVALID_HANDLE_MSK (1UL << PART2_SET_RHANDLE_INVALID_HANDLE_MSK_POS)
#define PART2_SET_RHANDLE_NULL_HANDLE_MSK_POS (23UL)
#define PART2_SET_RHANDLE_NULL_HANDLE_MSK (1UL << PART2_SET_RHANDLE_NULL_HANDLE_MSK_POS)
#define PART2_READ_WRAPAROUND_MSK_POS (24UL)
#define PART2_READ_WRAPAROUND_MSK (1UL << PART2_READ_WRAPAROUND_MSK_POS)
#define PART2_READ_EXCESS_INVEC_MSK_POS (25UL)
#define PART2_READ_EXCESS_INVEC_MSK (1UL << PART2_READ_EXCESS_INVEC_MSK_POS)
#define PART2_WRITE_WRAPAROUND_MSK_POS (26UL)
#define PART2_WRITE_WRAPAROUND_MSK (1UL << PART2_WRITE_WRAPAROUND_MSK_POS)
#define PART2_WRITE_EXCESS_OUTVEC_MSK_POS (27UL)
#define PART2_WRITE_EXCESS_OUTVEC_MSK (1UL << PART2_WRITE_EXCESS_OUTVEC_MSK_POS)
#define PART2_WRITE_SIZE_OVERFLOW_MSK_POS (28UL)
#define PART2_WRITE_SIZE_OVERFLOW_MSK (1UL << PART2_WRITE_SIZE_OVERFLOW_MSK_POS)
#define PART2_READ_NULL_BUFFER_MSK_POS (29UL)
#define PART2_READ_NULL_BUFFER_MSK (1UL << PART2_READ_NULL_BUFFER_MSK_POS)
#define NEG_SERVER_PART2_WAIT_ANY_SID_MSK (\
PART2_INT_MASK_MSK | \
PART2_GET_MSG_NULL_MSK | \
PART2_GET_SIGNUM_MULTIPLE_BIT_MSK | \
PART2_GET_SIGNUM_NOT_SUBSET_MSK | \
PART2_GET_SIGNUM_NOT_ACTIVE_MSK | \
PART2_GET_SIGNUM_TWICE_MSK | \
PART2_READ_INVALID_HANDLE_MSK | \
PART2_READ_NULL_HANDLE_MSK | \
PART2_READ_TX_SIZE_ZERO_MSK | \
PART2_WRITE_BUFFER_NULL_MSK | \
PART2_WRITE_RX_BUFF_NULL_MSK | \
PART2_WRITE_INVALID_HANDLE_MSK | \
PART2_WRITE_NULL_HANDLE_MSK | \
PART2_REPLY_INVALID_HANDLE_MSK | \
PART2_REPLY_NULL_HANDLE_MSK | \
PART2_NOTIFY_PART_ID_INVALID_MSK | \
PART2_IDENTITY_INVALID_HANDLE_MSK | \
PART2_IDENTITY_NULL_HANDLE_MSK | \
PART2_SET_RHANDLE_INVALID_HANDLE_MSK | \
PART2_SET_RHANDLE_NULL_HANDLE_MSK | \
PART2_READ_WRAPAROUND_MSK | \
PART2_READ_EXCESS_INVEC_MSK | \
PART2_WRITE_WRAPAROUND_MSK | \
PART2_WRITE_EXCESS_OUTVEC_MSK | \
PART2_WRITE_SIZE_OVERFLOW_MSK | \
PART2_READ_NULL_BUFFER_MSK)
/*
#define NEG_SERVER_PART2_WAIT_ANY_MSK (\
NEG_SERVER_PART2_WAIT_ANY_SID_MSK) | \
PSA_DOORBELL)
*/
#endif // PSA_NEG_SERVER_PART2_PARTITION_H

View File

@ -1,460 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !ENABLE_SPM
#error [NOT_SUPPORTED] SPM is not supported on this platform
#endif
#include "cmsis_os2.h"
#include "mbed.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
#include "rtos.h"
#include "spm_client.h"
#include "psa_neg_server_part1_ifs.h"
#include "psa_neg_server_part2_ifs.h"
#include "neg_tests.h"
#define MINOR_VER 5
#define CLIENT_RSP_BUF_SIZE 128
#define OFFSET_POS 1
#define INVALID_SID (PART1_ROT_SRV1 + 30)
#define INVALID_MINOR (MINOR_VER + 10)
using namespace utest::v1;
Semaphore test_sem(0);
bool error_thrown = false;
uint8_t response_buf[CLIENT_RSP_BUF_SIZE];
extern "C" void spm_reboot(void);
void error(const char *format, ...)
{
error_thrown = true;
osStatus status = test_sem.release();
MBED_ASSERT(status == osOK);
PSA_UNUSED(status);
while (1);
}
/* ------------------------------------- Functions ----------------------------------- */
static psa_handle_t negative_server_ipc_tests_connect(uint32_t sid, uint32_t minor_version)
{
psa_handle_t handle = psa_connect(sid, minor_version);
TEST_ASSERT_TRUE(handle > 0);
return handle;
}
static void negative_server_ipc_tests_call(psa_handle_t handle,
psa_invec_t *invec,
size_t tx_len,
psa_outvec_t *outvec,
size_t rx_len
)
{
error_t status = PSA_SUCCESS;
status = psa_call(handle, invec, tx_len, outvec, rx_len);
TEST_ASSERT_EQUAL_INT(PSA_SUCCESS, status);
}
//Testing server interrupt mask contains only a subset of interrupt signal mask
void server_interrupt_mask_invalid()
{
psa_connect(PART2_INT_MASK, MINOR_VER);
TEST_FAIL_MESSAGE("server_interrupt_mask_invalid negative test failed at client side");
}
//Testing server get with msg NULL
void server_get_msg_null()
{
psa_connect(PART2_GET_MSG_NULL, MINOR_VER);
TEST_FAIL_MESSAGE("server_get_msg_null negative test failed at client side");
}
//Testing server get signum have more than one bit ON
void server_get_multiple_bit_signum()
{
psa_connect(PART2_GET_SIGNUM_MULTIPLE_BIT, MINOR_VER);
TEST_FAIL_MESSAGE("server_get_multiple_bit_signum negative test failed at client side");
}
//Testing server get signum is not a subset of current partition flags
void server_get_signum_not_subset()
{
psa_connect(PART2_GET_SIGNUM_NOT_SUBSET, MINOR_VER);
TEST_FAIL_MESSAGE("server_get_signum_not_subset negative test failed at client side");
}
//Testing server get signum flag is not active
void server_get_signum_not_active()
{
psa_connect(PART2_GET_SIGNUM_NOT_ACTIVE, MINOR_VER);
TEST_FAIL_MESSAGE("server_get_signum_not_active negative test failed at client side");
}
//Testing server get signum flag twice
void server_get_signum_twice()
{
psa_connect(PART2_GET_SIGNUM_TWICE, MINOR_VER);
TEST_FAIL_MESSAGE("server_get_signum_twice negative test failed at client side");
}
//Testing server read handle does not exist on the platform
void server_read_invalid_handle()
{
uint32_t data = 52;
psa_invec_t data_vec = {&data, sizeof(data)};
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_READ_INVALID_HANDLE, MINOR_VER);
negative_server_ipc_tests_call(handle, &data_vec, 1, NULL, 0);
TEST_FAIL_MESSAGE("server_read_invalid_handle negative test failed at client side");
}
//Testing server read handle is null (PSA_NULL_HANDLE)
void server_read_null_handle()
{
uint32_t data = 52;
psa_invec_t data_vec = {&data, sizeof(data)};
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_READ_NULL_HANDLE, MINOR_VER);
negative_server_ipc_tests_call(handle, &data_vec, 1, NULL, 0);
TEST_FAIL_MESSAGE("server_read_null_handle negative test failed at client side");
}
//Testing server read buffer is null
void server_read_null_buffer()
{
uint32_t data = 52;
psa_invec_t data_vec = {&data, sizeof(data)};
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_READ_NULL_BUFFER, MINOR_VER);
negative_server_ipc_tests_call(handle, &data_vec, 1, NULL, 0);
TEST_FAIL_MESSAGE("server_read_null_buffer negative test failed at client side");
}
//Testing server write buffer is null
void server_write_null_buffer()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_BUFFER_NULL, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
psa_outvec_t resp = { NULL, CLIENT_RSP_BUF_SIZE };
negative_server_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, &resp, 1);
TEST_FAIL_MESSAGE("server_write_null_buffer negative test failed at client side");
}
//Testing server write rx_buff is null
void server_write_rx_buff_null()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_RX_BUFF_NULL, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
negative_server_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC, NULL, 0);
TEST_FAIL_MESSAGE("server_write_rx_buff_null negative test failed at client side");
}
//Testing server write handle does not exist on the platform
void server_write_invalid_handle()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_INVALID_HANDLE, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
psa_outvec_t resp = { response_buf, CLIENT_RSP_BUF_SIZE };
negative_server_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, &resp, 1);
TEST_FAIL_MESSAGE("server_write_invalid_handle negative test failed at client side");
}
//Testing server write handle is null (PSA_NULL_HANDLE)
void server_write_null_handle()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_NULL_HANDLE, MINOR_VER);
uint8_t data[2] = {1, 0};
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
{data, sizeof(data)},
{data, sizeof(data)},
{data, sizeof(data)}
};
psa_outvec_t resp = { response_buf, CLIENT_RSP_BUF_SIZE };
negative_server_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, &resp, 1);
TEST_FAIL_MESSAGE("server_write_null_handle negative test failed at client side");
}
//Testing server reply with a null handle
void server_reply_null_handle()
{
psa_connect(PART2_REPLY_NULL_HANDLE, MINOR_VER);
TEST_FAIL_MESSAGE("server_reply_null_handle negative test failed at client side");
}
//Testing server reply handle does not exist on the platform
void server_reply_invalid_handle()
{
psa_connect(PART2_REPLY_INVALID_HANDLE, MINOR_VER);
TEST_FAIL_MESSAGE("server_reply_invalid_handle negative test failed at client side");
}
//Testing server reply invalid retval for connect
void server_reply_invalid_retval_connect()
{
psa_connect(PART1_REPLY_INVALID_RETVAL_CONNECT, MINOR_VER);
TEST_FAIL_MESSAGE("server_reply_invalid_retval_connect negative test failed at client side");
}
//Testing server reply invalid retval for call
void server_reply_invalid_retval_call()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART1_REPLY_INVALID_RETVAL_CALL, MINOR_VER);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("server_reply_invalid_retval_call negative test failed at client side");
}
//Testing server notify partition id doesnt exist
void server_notify_part_id_invalid()
{
psa_connect(PART2_NOTIFY_PART_ID_INVALID, MINOR_VER);
TEST_FAIL_MESSAGE("server_notify_part_id_invalid negative test failed at client side");
}
//Testing server psa_identity handle does not exist on the platform
void server_psa_identity_invalid_handle()
{
psa_connect(PART2_IDENTITY_INVALID_HANDLE, MINOR_VER);
TEST_FAIL_MESSAGE("server_psa_identity_invalid_handle negative test failed at client side");
}
//Testing server psa_identity handle is null (PSA_NULL_HANDLE)
void server_psa_identity_null_handle()
{
psa_connect(PART2_IDENTITY_NULL_HANDLE, MINOR_VER);
TEST_FAIL_MESSAGE("server_psa_identity_null_handle negative test failed at client side");
}
//Testing server psa_set_rhandle handle does not exist on the platform
void server_set_rhandle_invalid_handle()
{
psa_connect(PART2_SET_RHANDLE_INVALID_HANDLE, MINOR_VER);
TEST_FAIL_MESSAGE("server_set_rhandle_invalid_handle negative test failed at client side");
}
//Testing server psa_set_rhandle handle is null (PSA_NULL_HANDLE)
void server_set_rhandle_null_handle()
{
psa_connect(PART2_SET_RHANDLE_NULL_HANDLE, MINOR_VER);
TEST_FAIL_MESSAGE("server_set_rhandle_null_handle negative test failed at client side");
}
void server_read_on_wraparound_msg_ptr()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_READ_WRAPAROUND, MINOR_VER);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("server_read_on_wraparound_msg_ptr negative test failed at client side");
}
void server_read_from_excess_invec()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_READ_EXCESS_INVEC, MINOR_VER);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("server_read_from_excess_invec negative test failed at client side");
}
void server_write_on_wraparound_msg_ptr()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_WRAPAROUND, MINOR_VER);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("server_write_on_wraparound_msg_ptr negative test failed at client side");
}
void server_write_from_excess_outvec()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_EXCESS_OUTVEC, MINOR_VER);
psa_call(handle, NULL, 0, NULL, 0);
TEST_FAIL_MESSAGE("server_write_from_excess_outvec negative test failed at client side");
}
void server_write_from_outvec_index_size_0()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART1_WRITE_OUTVEC_IX_SIZE_0, MINOR_VER);
psa_outvec_t resp[2] = { {response_buf, CLIENT_RSP_BUF_SIZE},
{response_buf, 0}
};
psa_call(handle, NULL, 0, resp, 2);
TEST_FAIL_MESSAGE("server_write_from_outvec_index_size_0 negative test failed at client side");
}
void server_write_with_size_overflow()
{
psa_handle_t handle = negative_server_ipc_tests_connect(PART2_WRITE_SIZE_OVERFLOW, MINOR_VER);
psa_outvec_t resp = { response_buf, CLIENT_RSP_BUF_SIZE };
psa_call(handle, NULL, 0, &resp, 1);
TEST_FAIL_MESSAGE("server_write_with_size_overflow negative test failed at client side");
}
// Testing server psa_clear() when doorbell signal is not currently asserted
void server_clear_no_doorbell()
{
psa_connect(PART1_CLEAR_NO_DOORBELL, MINOR_VER);
TEST_FAIL_MESSAGE("server_clear_no_doorbell negative test failed at client side");
}
PSA_NEG_TEST(server_interrupt_mask_invalid)
PSA_NEG_TEST(server_get_msg_null)
PSA_NEG_TEST(server_get_multiple_bit_signum)
PSA_NEG_TEST(server_get_signum_not_subset)
PSA_NEG_TEST(server_get_signum_not_active)
PSA_NEG_TEST(server_get_signum_twice)
PSA_NEG_TEST(server_read_invalid_handle)
PSA_NEG_TEST(server_read_null_handle)
PSA_NEG_TEST(server_read_null_buffer)
PSA_NEG_TEST(server_write_null_buffer)
PSA_NEG_TEST(server_write_rx_buff_null)
PSA_NEG_TEST(server_write_invalid_handle)
PSA_NEG_TEST(server_write_null_handle)
PSA_NEG_TEST(server_reply_null_handle)
PSA_NEG_TEST(server_reply_invalid_handle)
PSA_NEG_TEST(server_reply_invalid_retval_connect)
PSA_NEG_TEST(server_reply_invalid_retval_call)
PSA_NEG_TEST(server_notify_part_id_invalid)
PSA_NEG_TEST(server_psa_identity_invalid_handle)
PSA_NEG_TEST(server_psa_identity_null_handle)
PSA_NEG_TEST(server_set_rhandle_invalid_handle)
PSA_NEG_TEST(server_set_rhandle_null_handle)
PSA_NEG_TEST(server_read_on_wraparound_msg_ptr)
PSA_NEG_TEST(server_read_from_excess_invec)
PSA_NEG_TEST(server_write_on_wraparound_msg_ptr)
PSA_NEG_TEST(server_write_with_size_overflow)
PSA_NEG_TEST(server_write_from_excess_outvec)
PSA_NEG_TEST(server_write_from_outvec_index_size_0)
PSA_NEG_TEST(server_clear_no_doorbell)
utest::v1::status_t spm_case_setup(const Case *const source, const size_t index_of_case)
{
memset(response_buf, 0, sizeof(response_buf));
return greentea_case_setup_handler(source, index_of_case);
}
utest::v1::status_t spm_case_teardown(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)
{
spm_reboot();
error_thrown = false;
return greentea_case_teardown_handler(source, passed, failed, reason);
}
#define SPM_UTEST_CASE(desc, test) Case(desc, spm_case_setup, PSA_NEG_TEST_NAME(test), spm_case_teardown)
// Test cases
Case cases[] = {
SPM_UTEST_CASE("Testing server interrupt mask invalid", server_interrupt_mask_invalid),
SPM_UTEST_CASE("Testing server get with msg NULL", server_get_msg_null),
SPM_UTEST_CASE("Testing server get signum have more than one bit ON", server_get_multiple_bit_signum),
SPM_UTEST_CASE("Testing server get signum flag is not a subset of current partition flags", server_get_signum_not_subset),
SPM_UTEST_CASE("Testing server get signum flag is not active", server_get_signum_not_active),
SPM_UTEST_CASE("Testing server get signum twice", server_get_signum_twice),
SPM_UTEST_CASE("Testing server read handle does not exist on the platform", server_read_invalid_handle),
SPM_UTEST_CASE("Testing server read handle is PSA_NULL_HANDLE", server_read_null_handle),
SPM_UTEST_CASE("Testing server read buffer is NULL", server_read_null_buffer),
SPM_UTEST_CASE("Testing server write buffer is NULL", server_write_null_buffer),
SPM_UTEST_CASE("Testing server write rx_buff is null", server_write_rx_buff_null),
SPM_UTEST_CASE("Testing server write handle does not exist on the platform", server_write_invalid_handle),
SPM_UTEST_CASE("Testing server write handle is PSA_NULL_HANDLE", server_write_null_handle),
SPM_UTEST_CASE("Testing server reply with PSA_NULL_HANDLE", server_reply_null_handle),
SPM_UTEST_CASE("Testing server reply handle does not exist on the platform", server_reply_invalid_handle),
SPM_UTEST_CASE("Testing server reply invalid retval for connect", server_reply_invalid_retval_connect),
SPM_UTEST_CASE("Testing server reply invalid retval for call", server_reply_invalid_retval_call),
SPM_UTEST_CASE("Testing server notify partition id does not exist", server_notify_part_id_invalid),
SPM_UTEST_CASE("Testing server identify handle does not exist on the platform", server_psa_identity_invalid_handle),
SPM_UTEST_CASE("Testing server identify handle is PSA_NULL_HANDLE", server_psa_identity_null_handle),
SPM_UTEST_CASE("Testing server set_rhandle handle does not exist on the platform", server_set_rhandle_invalid_handle),
SPM_UTEST_CASE("Testing server set_rhandle handle is PSA_NULL_HANDLE", server_set_rhandle_null_handle),
SPM_UTEST_CASE("Testing server read on wrap around pointer", server_read_on_wraparound_msg_ptr),
SPM_UTEST_CASE("Testing server read on excess invec index", server_read_from_excess_invec),
SPM_UTEST_CASE("Testing server write on wrap around pointer", server_write_on_wraparound_msg_ptr),
SPM_UTEST_CASE("Testing server write on excess out_vec index", server_write_from_excess_outvec),
SPM_UTEST_CASE("Testing server write on out_vec index with size 0", server_write_from_outvec_index_size_0),
SPM_UTEST_CASE("Testing server write with size overflow", server_write_with_size_overflow),
SPM_UTEST_CASE("Testing server clear when doorbell signal is not asserted", server_clear_no_doorbell)
};
utest::v1::status_t spm_setup(const size_t number_of_cases)
{
#ifndef NO_GREENTEA
GREENTEA_SETUP(60, "default_auto");
#endif
return greentea_test_setup_handler(number_of_cases);
}
Specification specification(spm_setup, cases);
int main()
{
Harness::run(specification);
return 0;
}

View File

@ -1,32 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#define PSA_NEG_TEST_NAME(test_name) psa_neg_test_ ## test_name
#define PSA_NEG_TEST(test_name) \
void PSA_NEG_TEST_NAME(test_name)() \
{ \
osStatus status = osOK; \
Thread T1; \
\
status = T1.start(test_name); \
TEST_ASSERT_TRUE(status == osOK); \
test_sem.wait(osWaitForever); \
TEST_ASSERT_TRUE(error_thrown); \
\
status = T1.terminate(); \
TEST_ASSERT_TRUE(status == osOK); \
} \

View File

@ -1,45 +0,0 @@
{
"name": "NEG_SERVER_PART1",
"type": "APPLICATION-ROT",
"priority": "NORMAL",
"id": "0x00000007",
"entry_point": "server_main1",
"stack_size": "0x200",
"heap_size": "0x400",
"services": [{
"name": "PART1_REPLY_INVALID_RETVAL_CONNECT",
"identifier": "0x00001A25",
"signal": "PART1_REPLY_INVALID_RETVAL_CONNECT_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART1_REPLY_INVALID_RETVAL_CALL",
"identifier": "0x00001A26",
"signal": "PART1_REPLY_INVALID_RETVAL_CALL_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART1_CLEAR_NO_DOORBELL",
"identifier": "0x00001A27",
"signal": "PART1_CLEAR_NO_DOORBELL_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART1_WRITE_OUTVEC_IX_SIZE_0",
"identifier": "0x00001A28",
"signal": "PART1_WRITE_OUTVEC_IX_SIZE_0_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
}
],
"source_files": [
"server1.c"
]
}

View File

@ -1,221 +0,0 @@
{
"name": "NEG_SERVER_PART2",
"type": "APPLICATION-ROT",
"priority": "NORMAL",
"id": "0x00000008",
"entry_point": "server_main2",
"stack_size": "0x280",
"heap_size": "0x400",
"services": [{
"name": "PART2_INT_MASK",
"identifier": "0x00001A0B",
"signal": "PART2_INT_MASK_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_GET_MSG_NULL",
"identifier": "0x00001A0C",
"signal": "PART2_GET_MSG_NULL_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_GET_SIGNUM_MULTIPLE_BIT",
"identifier": "0x00001A0D",
"signal": "PART2_GET_SIGNUM_MULTIPLE_BIT_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_GET_SIGNUM_NOT_SUBSET",
"identifier": "0x00001A0E",
"signal": "PART2_GET_SIGNUM_NOT_SUBSET_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_GET_SIGNUM_NOT_ACTIVE",
"identifier": "0x00001A0F",
"signal": "PART2_GET_SIGNUM_NOT_ACTIVE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_GET_SIGNUM_TWICE",
"identifier": "0x00001A10",
"signal": "PART2_GET_SIGNUM_TWICE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_READ_INVALID_HANDLE",
"identifier": "0x00001A11",
"signal": "PART2_READ_INVALID_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_READ_NULL_HANDLE",
"identifier": "0x00001A12",
"signal": "PART2_READ_NULL_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_READ_TX_SIZE_ZERO",
"identifier": "0x00001A13",
"signal": "PART2_READ_TX_SIZE_ZERO_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_BUFFER_NULL",
"identifier": "0x00001A14",
"signal": "PART2_WRITE_BUFFER_NULL_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_RX_BUFF_NULL",
"identifier": "0x00001A15",
"signal": "PART2_WRITE_RX_BUFF_NULL_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_INVALID_HANDLE",
"identifier": "0x00001A16",
"signal": "PART2_WRITE_INVALID_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_NULL_HANDLE",
"identifier": "0x00001A17",
"signal": "PART2_WRITE_NULL_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_REPLY_INVALID_HANDLE",
"identifier": "0x00001A18",
"signal": "PART2_REPLY_INVALID_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_REPLY_NULL_HANDLE",
"identifier": "0x00001A19",
"signal": "PART2_REPLY_NULL_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_NOTIFY_PART_ID_INVALID",
"identifier": "0x00001A1A",
"signal": "PART2_NOTIFY_PART_ID_INVALID_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_IDENTITY_INVALID_HANDLE",
"identifier": "0x00001A1B",
"signal": "PART2_IDENTITY_INVALID_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_IDENTITY_NULL_HANDLE",
"identifier": "0x00001A1C",
"signal": "PART2_IDENTITY_NULL_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_SET_RHANDLE_INVALID_HANDLE",
"identifier": "0x00001A1D",
"signal": "PART2_SET_RHANDLE_INVALID_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_SET_RHANDLE_NULL_HANDLE",
"identifier": "0x00001A1E",
"signal": "PART2_SET_RHANDLE_NULL_HANDLE_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_READ_WRAPAROUND",
"identifier": "0x00001A1F",
"signal": "PART2_READ_WRAPAROUND_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_READ_EXCESS_INVEC",
"identifier": "0x00001A20",
"signal": "PART2_READ_EXCESS_INVEC_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_WRAPAROUND",
"identifier": "0x00001A21",
"signal": "PART2_WRITE_WRAPAROUND_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_EXCESS_OUTVEC",
"identifier": "0x00001A22",
"signal": "PART2_WRITE_EXCESS_OUTVEC_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_WRITE_SIZE_OVERFLOW",
"identifier": "0x00001A23",
"signal": "PART2_WRITE_SIZE_OVERFLOW_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
},
{
"name": "PART2_READ_NULL_BUFFER",
"identifier": "0x00001A24",
"signal": "PART2_READ_NULL_BUFFER_MSK",
"non_secure_clients": true,
"minor_version": 5,
"minor_policy": "RELAXED"
}
],
"source_files": [
"server2.c"
]
}

View File

@ -1,78 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
**********************************************************************************************************************/
#include "spm_panic.h"
#include "spm_internal.h"
#include "handles_manager.h"
#include "cmsis.h"
#include "psa_neg_server_part1_partition.h"
#include "psa_neg_server_part2_partition.h"
spm_partition_t g_partitions[2] = {
{
.partition_id = NEG_SERVER_PART1_ID,
.thread_id = 0,
.flags_rot_srv = NEG_SERVER_PART1_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = NEG_SERVER_PART1_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = NEG_SERVER_PART1_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
{
.partition_id = NEG_SERVER_PART2_ID,
.thread_id = 0,
.flags_rot_srv = NEG_SERVER_PART2_WAIT_ANY_SID_MSK,
.flags_interrupts = 0,
.rot_services = NULL,
.rot_services_count = NEG_SERVER_PART2_ROT_SRV_COUNT,
.extern_sids = NULL,
.extern_sids_count = NEG_SERVER_PART2_EXT_ROT_SRV_COUNT,
.irq_mapper = NULL,
},
};
/* Check all the defined memory regions for overlapping. */
/* A list of all the memory regions. */
const mem_region_t *mem_regions = NULL;
const uint32_t mem_region_count = 0;
// forward declaration of partition initializers
void neg_server_part1_init(spm_partition_t *partition);
void neg_server_part2_init(spm_partition_t *partition);
uint32_t init_partitions(spm_partition_t **partitions)
{
if (NULL == partitions) {
SPM_PANIC("partitions is NULL!\n");
}
neg_server_part1_init(&(g_partitions[0]));
neg_server_part2_init(&(g_partitions[1]));
*partitions = g_partitions;
return 2;
}

View File

@ -1,89 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <stdbool.h>
#include <string.h>
#include "unity.h"
#include "spm_panic.h"
#include "spm_server.h"
#include "psa_neg_server_part1_partition.h"
void server_main1(void *ptr)
{
psa_msg_t msg = {0};
uint32_t signals = 0;
while (true) {
signals = psa_wait_any(PSA_BLOCK);
if (signals & PART1_CLEAR_NO_DOORBELL_MSK) {
psa_get(PART1_CLEAR_NO_DOORBELL_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_clear();
TEST_FAIL_MESSAGE("server_clear_no_doorbell negative test failed");
}
default: {
TEST_FAIL_MESSAGE("server_clear_no_doorbell msg type failure");
}
}
} else if (signals & PART1_REPLY_INVALID_RETVAL_CONNECT_MSK) {
psa_get(PART1_REPLY_INVALID_RETVAL_CONNECT_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_reply(msg.handle, PSA_CONNECTION_ACCEPTED + 1);
TEST_FAIL_MESSAGE("server_reply_invalid_retval_connect negative test failed");
}
default: {
TEST_FAIL_MESSAGE("server_reply_invalid_retval_connect msg type failure");
}
}
} else if (signals & PART1_REPLY_INVALID_RETVAL_CALL_MSK) {
psa_get(PART1_REPLY_INVALID_RETVAL_CALL_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_reply(msg.handle, PSA_CONNECTION_ACCEPTED);
break;
}
case PSA_IPC_CALL: {
psa_reply(msg.handle, PSA_DROP_CONNECTION + 1);
TEST_FAIL_MESSAGE("server_reply_invalid_retval_call negative test failed");
}
default: {
TEST_FAIL_MESSAGE("server_reply_invalid_retval_call msg type failure");
}
}
} else if (signals & PART1_WRITE_OUTVEC_IX_SIZE_0_MSK) {
psa_get(PART1_WRITE_OUTVEC_IX_SIZE_0_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_reply(msg.handle, PSA_CONNECTION_ACCEPTED);
break;
}
case PSA_IPC_CALL: {
uint32_t val = 0;
psa_write(msg.handle, 1, &val, sizeof(val));
TEST_FAIL_MESSAGE("server_write_from_outvec_index_size_0 negative test failed");
}
default: {
TEST_FAIL_MESSAGE("server_write_from_outvec_index_size_0 msg type failure");
}
}
} else {
SPM_ASSERT(false);
}
}
}

View File

@ -1,385 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <stdbool.h>
#include <string.h>
#include "unity.h"
#include "spm_panic.h"
#include "spm_server.h"
#include "psa_neg_server_part2_partition.h"
#define MSG_BUF_SIZE 128
#define CLIENT_RSP_BUF_SIZE 128
#define INVALID_INT_MASK 0xFFFFFFFF
#define MULTIPLE_SIGNUM 0x00000003
#define NUM_OF_FLAGS 24
#define INVALID_PARTION_ID 10
char msg_buf[MSG_BUF_SIZE];
char res_buff[MSG_BUF_SIZE];
void server_main2(void *ptr)
{
psa_msg_t msg = {0};
uint32_t signals = 0;
memset(msg_buf, 0, sizeof(msg_buf));
memset(res_buff, 0, sizeof(res_buff));
while (true) {
signals = psa_wait_any(PSA_BLOCK);
if (signals & PART2_INT_MASK_MSK) {
psa_wait_interrupt(INVALID_INT_MASK, PSA_BLOCK);
TEST_FAIL_MESSAGE("server_interrupt_mask_invalid negative test failed");
} else if (signals & PART2_GET_MSG_NULL_MSK) {
psa_get(PART2_GET_MSG_NULL_MSK, NULL);
TEST_FAIL_MESSAGE("server_get_msg_null negative test failed");
} else if (signals & PART2_GET_SIGNUM_MULTIPLE_BIT_MSK) {
psa_get(MULTIPLE_SIGNUM, &msg);
TEST_FAIL_MESSAGE("server_get_multiple_bit_signum negative test failed");
} else if (signals & PART2_GET_SIGNUM_NOT_SUBSET_MSK) {
psa_get(PART2_GET_SIGNUM_NOT_SUBSET_MSK << NUM_OF_FLAGS, &msg);
TEST_FAIL_MESSAGE("server_get_signum_not_subset negative test failed");
} else if (signals & PART2_GET_SIGNUM_NOT_ACTIVE_MSK) {
psa_get(PART2_GET_MSG_NULL_MSK, &msg); //send wrong flag
TEST_FAIL_MESSAGE("server_get_signum_not_active negative test failed");
} else if (signals & PART2_GET_SIGNUM_TWICE_MSK) {
psa_get(PART2_GET_SIGNUM_TWICE_MSK, &msg);
psa_get(PART2_GET_SIGNUM_TWICE_MSK, &msg);
TEST_FAIL_MESSAGE("server_get_signum_twice negative test failed");
} else if (signals & PART2_READ_INVALID_HANDLE_MSK) {
psa_get(PART2_READ_INVALID_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
psa_handle_t invalid_handle = msg.handle + 10;
psa_read(invalid_handle, 0, msg_buf, msg.in_size[0]);
TEST_FAIL_MESSAGE("server_read_invalid_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_read_invalid_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_READ_NULL_HANDLE_MSK) {
psa_get(PART2_READ_NULL_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
psa_read(PSA_NULL_HANDLE, 0, msg_buf, msg.in_size[0]);
TEST_FAIL_MESSAGE("server_read_null_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_read_null_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_READ_NULL_BUFFER_MSK) {
psa_get(PART2_READ_NULL_BUFFER_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
psa_read(msg.handle, 0, NULL, msg.in_size[0]);
TEST_FAIL_MESSAGE("server_read_null_buffer negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_read_null_buffer msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_BUFFER_NULL_MSK) {
psa_get(PART2_WRITE_BUFFER_NULL_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
size_t read_bytes = 0;
for (size_t i = 0; i < PSA_MAX_IOVEC - 1; i++) {
read_bytes += psa_read(msg.handle, i, msg_buf + read_bytes, msg.in_size[i]);
}
psa_write(msg.handle, 0, NULL, read_bytes);
TEST_FAIL_MESSAGE("server_write_null_buffer negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_null_buffer msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_RX_BUFF_NULL_MSK) {
psa_get(PART2_WRITE_RX_BUFF_NULL_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
size_t read_bytes = 0;
for (size_t i = 0; i < PSA_MAX_IOVEC; i++) {
read_bytes += psa_read(msg.handle, i, msg_buf + read_bytes, msg.in_size[i]);
}
psa_write(msg.handle, 0, res_buff, read_bytes);
TEST_FAIL_MESSAGE("server_write_rx_buff_null negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_rx_buff_null msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_INVALID_HANDLE_MSK) {
psa_get(PART2_WRITE_INVALID_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
size_t read_bytes = 0;
for (size_t i = 0; i < PSA_MAX_IOVEC - 1; i++) {
read_bytes += psa_read(msg.handle, i, msg_buf + read_bytes, msg.in_size[i]);
}
psa_handle_t invalid_handle = msg.handle + 10;
psa_write(invalid_handle, 0, res_buff, read_bytes);
TEST_FAIL_MESSAGE("server_write_invalid_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_invalid_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_NULL_HANDLE_MSK) {
psa_get(PART2_WRITE_NULL_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
size_t read_bytes = 0;
for (size_t i = 0; i < PSA_MAX_IOVEC - 1; i++) {
read_bytes += psa_read(msg.handle, i, msg_buf + read_bytes, msg.in_size[i]);
}
psa_write(PSA_NULL_HANDLE, 0, res_buff, read_bytes);
TEST_FAIL_MESSAGE("server_write_null_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_null_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_REPLY_INVALID_HANDLE_MSK) {
psa_get(PART2_REPLY_INVALID_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
default: {
TEST_FAIL_MESSAGE("server_reply_invalid_handle msg type failure");
}
}
psa_handle_t invalid_handle = msg.handle + 10;
psa_reply(invalid_handle, PSA_SUCCESS);
TEST_FAIL_MESSAGE("server_reply_invalid_handle negative test failed");
} else if (signals & PART2_REPLY_NULL_HANDLE_MSK) {
psa_get(PART2_REPLY_NULL_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_reply(PSA_NULL_HANDLE, PSA_CONNECTION_ACCEPTED);
TEST_FAIL_MESSAGE("server_reply_null_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_reply_null_handle msg type failure");
}
}
} else if (signals & PART2_NOTIFY_PART_ID_INVALID_MSK) {
psa_get(PART2_NOTIFY_PART_ID_INVALID_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_notify(INVALID_PARTION_ID);
TEST_FAIL_MESSAGE("server_notify_part_id_invalid negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_notify_part_id_invalid msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_IDENTITY_INVALID_HANDLE_MSK) {
psa_get(PART2_IDENTITY_INVALID_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
int32_t ret = 0;
psa_handle_t invalid_handle = msg.handle + 10;
ret = psa_identity(invalid_handle);
PSA_UNUSED(ret);
TEST_FAIL_MESSAGE("server_psa_identity_invalid_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_psa_identity_invalid_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_IDENTITY_NULL_HANDLE_MSK) {
psa_get(PART2_IDENTITY_NULL_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
int32_t ret = 0;
ret = psa_identity(PSA_NULL_HANDLE);
PSA_UNUSED(ret);
TEST_FAIL_MESSAGE("server_psa_identity_null_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_psa_identity_null_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_SET_RHANDLE_INVALID_HANDLE_MSK) {
psa_get(PART2_SET_RHANDLE_INVALID_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_handle_t invalid_handle = msg.handle + 10;
psa_set_rhandle(invalid_handle, NULL);
TEST_FAIL_MESSAGE("server_set_rhandle_invalid_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_set_rhandle_invalid_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_SET_RHANDLE_NULL_HANDLE_MSK) {
psa_get(PART2_SET_RHANDLE_NULL_HANDLE_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
psa_set_rhandle(PSA_NULL_HANDLE, NULL);
TEST_FAIL_MESSAGE("server_set_rhandle_null_handle negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_set_rhandle_null_handle msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_READ_WRAPAROUND_MSK) {
psa_get(PART2_READ_WRAPAROUND_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
psa_read(msg.handle, 0, (void *)0x80000000, UINT32_MAX);
TEST_FAIL_MESSAGE("server_read_on_wraparound_msg_ptr negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_read_on_wraparound_msg_ptr msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_READ_EXCESS_INVEC_MSK) {
psa_get(PART2_READ_EXCESS_INVEC_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
uint32_t val = 0;
psa_read(msg.handle, PSA_MAX_IOVEC, &val, sizeof(val));
TEST_FAIL_MESSAGE("server_read_on_wraparound_msg_ptr negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_read_on_wraparound_msg_ptr msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_WRAPAROUND_MSK) {
psa_get(PART2_WRITE_WRAPAROUND_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
psa_write(msg.handle, 0, (void *)0x80000000, UINT32_MAX);
TEST_FAIL_MESSAGE("server_write_on_wraparound_msg_ptr negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_on_wraparound_msg_ptr msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_SIZE_OVERFLOW_MSK) {
psa_get(PART2_WRITE_SIZE_OVERFLOW_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
uint8_t write_buf[CLIENT_RSP_BUF_SIZE + 1] = {0};
psa_write(msg.handle, 0, write_buf, sizeof(write_buf));
TEST_FAIL_MESSAGE("server_write_with_size_overflow negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_with_size_overflow msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else if (signals & PART2_WRITE_EXCESS_OUTVEC_MSK) {
psa_get(PART2_WRITE_EXCESS_OUTVEC_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CONNECT: {
break;
}
case PSA_IPC_CALL: {
uint32_t val = 0;
psa_write(msg.handle, PSA_MAX_IOVEC, &val, sizeof(val));
TEST_FAIL_MESSAGE("server_write_from_excess_outvec negative test failed");
break;
}
default: {
TEST_FAIL_MESSAGE("server_write_from_excess_outvec msg type failure");
}
}
psa_reply(msg.handle, PSA_SUCCESS);
} else {
SPM_PANIC("Unknown signal (0x%08x)", signals);
}
}
}

View File

@ -1,67 +0,0 @@
/* Copyright (c) 2017-2018 ARM Limited
*
* 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.
*/
#include <string.h>
#include "spm_internal.h"
extern spm_db_t g_spm;
extern psa_handle_item_t g_channels_handle_storage[];
extern psa_handle_item_t g_messages_handle_storage[];
extern spm_ipc_channel_t g_channel_data[];
extern spm_active_msg_t g_active_messages_data[];
void psa_spm_init(void);
void spm_reboot(void)
{
osStatus_t status;
for (uint32_t i = 0; i < g_spm.partition_count; ++i) {
status = osThreadTerminate(g_spm.partitions[i].thread_id);
MBED_ASSERT(status == osOK);
status = osMutexDelete(g_spm.partitions[i].mutex);
MBED_ASSERT(status == osOK);
for (uint32_t j = 0; j < g_spm.partitions[i].rot_services_count; ++j) {
g_spm.partitions[i].rot_services[j].partition = NULL;
g_spm.partitions[i].rot_services[j].queue.head = NULL;
g_spm.partitions[i].rot_services[j].queue.tail = NULL;
}
g_spm.partitions[i].rot_services = NULL;
g_spm.partitions[i].mutex = NULL;
g_spm.partitions[i].thread_id = NULL;
}
status = osMemoryPoolDelete(g_spm.channel_mem_pool);
MBED_ASSERT(status == osOK);
status = osMemoryPoolDelete(g_spm.active_messages_mem_pool);
MBED_ASSERT(status == osOK);
memset(g_channels_handle_storage, 0, (sizeof(psa_handle_item_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS));
memset(g_messages_handle_storage, 0, (sizeof(psa_handle_item_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES));
memset(g_channel_data, 0, (sizeof(spm_ipc_channel_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS));
memset(g_active_messages_data, 0, (sizeof(spm_active_msg_t) * MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES));
memset(&g_spm, 0, sizeof(g_spm));
g_spm.channels_handle_mgr.handle_generator = PSA_HANDLE_MGR_INVALID_HANDLE;
g_spm.channels_handle_mgr.pool_size = MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS;
g_spm.channels_handle_mgr.handles_pool = g_channels_handle_storage;
g_spm.messages_handle_mgr.handle_generator = PSA_HANDLE_MGR_INVALID_HANDLE;
g_spm.messages_handle_mgr.pool_size = MBED_CONF_SPM_IPC_MAX_NUM_OF_MESSAGES;
g_spm.messages_handle_mgr.handles_pool = g_messages_handle_storage;
psa_spm_init();
PSA_UNUSED(status);
}