Skip to content

Commit ff90636

Browse files
author
Charley Chu
committed
psoc64: Add TF-M release package
Signed-off-by: Charley Chu <[email protected]>
1 parent 04d8c07 commit ff90636

File tree

13 files changed

+12875
-95
lines changed

13 files changed

+12875
-95
lines changed

features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_DUALCPU/src/platform_ns_mailbox.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include "cy_ipc_sema.h"
1717

1818
#include "ns_ipc_config.h"
19+
#include "os_wrapper/thread.h"
1920
#include "tfm_ns_mailbox.h"
2021
#include "platform_multicore.h"
21-
#include "cmsis_os2.h"
2222

2323
static uint8_t saved_irq_state = 1;
2424

@@ -54,6 +54,7 @@ int32_t tfm_ns_mailbox_hal_notify_peer(void)
5454

5555
static int32_t mailbox_sema_init(void)
5656
{
57+
#if defined(CY_IPC_DEFAULT_CFG_DISABLE)
5758
/* semaphore data */
5859
static uint32_t tfm_sema __attribute__((section("TFM_SHARED_DATA")));
5960

@@ -62,6 +63,7 @@ static int32_t mailbox_sema_init(void)
6263
&tfm_sema) != CY_IPC_SEMA_SUCCESS) {
6364
return PLATFORM_MAILBOX_INIT_ERROR;
6465
}
66+
#endif
6567
return PLATFORM_MAILBOX_SUCCESS;
6668
}
6769

@@ -118,16 +120,12 @@ int32_t tfm_ns_mailbox_hal_init(struct ns_mailbox_queue_t *queue)
118120

119121
const void *tfm_ns_mailbox_get_task_handle(void)
120122
{
121-
#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
122-
return osThreadGetId();
123-
#else
124-
return NULL;
125-
#endif
123+
return os_wrapper_thread_get_handle();
126124
}
127125

128126
void tfm_ns_mailbox_hal_wait_reply(mailbox_msg_handle_t handle)
129127
{
130-
osThreadFlagsWait(handle, osFlagsWaitAll, osWaitForever);
128+
os_wrapper_thread_wait_flag((uint32_t)handle, OS_WRAPPER_WAIT_FOREVER);
131129
}
132130

133131
static cy_en_ipcsema_status_t mailbox_raw_spin_lock(uint32_t ipc_channel,
@@ -181,10 +179,6 @@ static cy_en_ipcsema_status_t mailbox_raw_spin_lock(uint32_t ipc_channel,
181179
* notification event from secure core. However, it is more
182180
* complex and requires more code and more modifications.
183181
*/
184-
volatile uint32_t count = 1000;
185-
while(count > 0) {
186-
count--;
187-
}
188182
Cy_IPC_Sema_Status(sema_num);
189183
}
190184
}
@@ -279,11 +273,11 @@ static bool mailbox_clear_intr(void)
279273
return true;
280274
}
281275

282-
void cpuss_interrupts_ipc_5_IRQHandler(void)
276+
void cpuss_interrupts_ipc_8_IRQHandler(void)
283277
{
284278
uint32_t magic;
285279
mailbox_msg_handle_t handle;
286-
osThreadId_t task_handle;
280+
void *task_handle;
287281

288282
if (!mailbox_clear_intr())
289283
return;
@@ -297,12 +291,9 @@ void cpuss_interrupts_ipc_5_IRQHandler(void)
297291
break;
298292
}
299293

300-
task_handle = (osThreadId_t)tfm_ns_mailbox_get_msg_owner(handle);
294+
task_handle = (void *)tfm_ns_mailbox_get_msg_owner(handle);
301295
if (task_handle) {
302-
/* According to the description of CMSIS-RTOS v2 Thread Flags,
303-
* osThreadFlagsSet() can be called inside Interrupt Service
304-
* Routine. */
305-
osThreadFlagsSet(task_handle, handle);
296+
os_wrapper_thread_set_flag_isr(task_handle, (uint32_t)handle);
306297
}
307298
}
308299
}

features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_DUALCPU/src/tfm_multi_core_api.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@
55
*
66
*/
77

8+
#include "os_wrapper/semaphore.h"
9+
810
#include "tfm_api.h"
911
#include "tfm_mailbox.h"
1012
#include "tfm_multi_core_api.h"
11-
#include "cmsis_os2.h"
1213

1314
#define MAX_SEMAPHORE_COUNT NUM_MAILBOX_QUEUE_SLOT
1415

15-
static osSemaphoreId_t ns_lock_handle = NULL;
16+
static void *ns_lock_handle = NULL;
1617

1718
__attribute__((weak))
1819
enum tfm_status_e tfm_ns_interface_init(void)
1920
{
20-
osSemaphoreAttr_t sema_attrib = {0};
21-
22-
ns_lock_handle = osSemaphoreNew(MAX_SEMAPHORE_COUNT,
23-
MAX_SEMAPHORE_COUNT,
24-
&sema_attrib);
21+
ns_lock_handle = os_wrapper_semaphore_create(MAX_SEMAPHORE_COUNT,
22+
MAX_SEMAPHORE_COUNT,
23+
NULL);
2524
if (!ns_lock_handle) {
2625
return TFM_ERROR_GENERIC;
2726
}
@@ -36,10 +35,11 @@ int32_t tfm_ns_wait_for_s_cpu_ready(void)
3635

3736
uint32_t tfm_ns_multi_core_lock_acquire(void)
3837
{
39-
return osSemaphoreAcquire(ns_lock_handle, osWaitForever);
38+
return os_wrapper_semaphore_acquire(ns_lock_handle,
39+
OS_WRAPPER_WAIT_FOREVER);
4040
}
4141

4242
uint32_t tfm_ns_multi_core_lock_release(void)
4343
{
44-
return osSemaphoreRelease(ns_lock_handle);
44+
return os_wrapper_semaphore_release(ns_lock_handle);
4545
}

features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_DUALCPU/src/tfm_multi_core_psa_ns_api.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <stdint.h>
99
#include <stdbool.h>
1010

11+
#include "os_wrapper/mutex.h"
12+
1113
#include "psa/client.h"
1214
#include "psa/error.h"
1315
#include "tfm_api.h"
@@ -62,7 +64,7 @@ uint32_t psa_framework_version(void)
6264
uint32_t version;
6365
int32_t ret;
6466

65-
if (tfm_ns_multi_core_lock_acquire() != TFM_SUCCESS) {
67+
if (tfm_ns_multi_core_lock_acquire() != OS_WRAPPER_SUCCESS) {
6668
return PSA_VERSION_NONE;
6769
}
6870

@@ -80,7 +82,7 @@ uint32_t psa_framework_version(void)
8082
version = PSA_VERSION_NONE;
8183
}
8284

83-
if (tfm_ns_multi_core_lock_release() != TFM_SUCCESS) {
85+
if (tfm_ns_multi_core_lock_release() != OS_WRAPPER_SUCCESS) {
8486
return PSA_VERSION_NONE;
8587
}
8688

@@ -96,7 +98,7 @@ uint32_t psa_version(uint32_t sid)
9698

9799
params.psa_version_params.sid = sid;
98100

99-
if (tfm_ns_multi_core_lock_acquire() != TFM_SUCCESS) {
101+
if (tfm_ns_multi_core_lock_acquire() != OS_WRAPPER_SUCCESS) {
100102
return PSA_VERSION_NONE;
101103
}
102104

@@ -114,7 +116,7 @@ uint32_t psa_version(uint32_t sid)
114116
version = PSA_VERSION_NONE;
115117
}
116118

117-
if (tfm_ns_multi_core_lock_release() != TFM_SUCCESS) {
119+
if (tfm_ns_multi_core_lock_release() != OS_WRAPPER_SUCCESS) {
118120
return PSA_VERSION_NONE;
119121
}
120122

@@ -131,7 +133,7 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t version)
131133
params.psa_connect_params.sid = sid;
132134
params.psa_connect_params.version = version;
133135

134-
if (tfm_ns_multi_core_lock_acquire() != TFM_SUCCESS) {
136+
if (tfm_ns_multi_core_lock_acquire() != OS_WRAPPER_SUCCESS) {
135137
return PSA_NULL_HANDLE;
136138
}
137139

@@ -149,7 +151,7 @@ psa_handle_t psa_connect(uint32_t sid, uint32_t version)
149151
psa_handle = PSA_NULL_HANDLE;
150152
}
151153

152-
if (tfm_ns_multi_core_lock_release() != TFM_SUCCESS) {
154+
if (tfm_ns_multi_core_lock_release() != OS_WRAPPER_SUCCESS) {
153155
return PSA_NULL_HANDLE;
154156
}
155157

@@ -172,7 +174,7 @@ psa_status_t psa_call(psa_handle_t handle, int32_t type,
172174
params.psa_call_params.out_vec = out_vec;
173175
params.psa_call_params.out_len = out_len;
174176

175-
if (tfm_ns_multi_core_lock_acquire() != TFM_SUCCESS) {
177+
if (tfm_ns_multi_core_lock_acquire() != OS_WRAPPER_SUCCESS) {
176178
return PSA_ERROR_GENERIC_ERROR;
177179
}
178180

@@ -190,7 +192,7 @@ psa_status_t psa_call(psa_handle_t handle, int32_t type,
190192
status = PSA_INTER_CORE_COMM_ERR;
191193
}
192194

193-
if (tfm_ns_multi_core_lock_release() != TFM_SUCCESS) {
195+
if (tfm_ns_multi_core_lock_release() != OS_WRAPPER_SUCCESS) {
194196
return PSA_ERROR_GENERIC_ERROR;
195197
}
196198

@@ -205,7 +207,7 @@ void psa_close(psa_handle_t handle)
205207

206208
params.psa_close_params.handle = handle;
207209

208-
if (tfm_ns_multi_core_lock_acquire() != TFM_SUCCESS) {
210+
if (tfm_ns_multi_core_lock_acquire() != OS_WRAPPER_SUCCESS) {
209211
return;
210212
}
211213

features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/include/platform_multicore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#define IPC_PSA_CLIENT_CALL_IPC_INTR cpuss_interrupts_ipc_6_IRQn
2020

2121
#define IPC_PSA_CLIENT_REPLY_CHAN (9)
22-
#define IPC_PSA_CLIENT_REPLY_INTR_STRUCT (5)
22+
#define IPC_PSA_CLIENT_REPLY_INTR_STRUCT (8)
2323
#define IPC_PSA_CLIENT_REPLY_INTR_MASK (1 << IPC_PSA_CLIENT_REPLY_CHAN)
2424
#define IPC_PSA_CLIENT_REPLY_NOTIFY_MASK (1 << IPC_PSA_CLIENT_REPLY_INTR_STRUCT)
25-
#define IPC_PSA_CLIENT_REPLY_IPC_INTR cpuss_interrupts_ipc_5_IRQn
25+
#define IPC_PSA_CLIENT_REPLY_IPC_INTR cpuss_interrupts_ipc_8_IRQn
2626

2727
#define IPC_RX_RELEASE_MASK (0)
2828

features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/include/psa_manifest/sid.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ extern "C" {
6161
#define SPM_CORE_TEST_INIT_SUCCESS_VERSION (1U)
6262
#define SPM_CORE_TEST_DIRECT_RECURSION_SID (0x0000F021U)
6363
#define SPM_CORE_TEST_DIRECT_RECURSION_VERSION (1U)
64+
#define SPM_CORE_TEST_MPU_ACCESS_SID (0x0000F022U)
65+
#define SPM_CORE_TEST_MPU_ACCESS_VERSION (1U)
66+
#define SPM_CORE_TEST_MEMORY_PERMISSIONS_SID (0x0000F023U)
67+
#define SPM_CORE_TEST_MEMORY_PERMISSIONS_VERSION (1U)
6468
#define SPM_CORE_TEST_SS_TO_SS_SID (0x0000F024U)
6569
#define SPM_CORE_TEST_SS_TO_SS_VERSION (1U)
6670
#define SPM_CORE_TEST_SS_TO_SS_BUFFER_SID (0x0000F025U)
@@ -130,6 +134,24 @@ extern "C" {
130134
#define TFM_PS_TEST_PREPARE_SID (0x0000F0C0U)
131135
#define TFM_PS_TEST_PREPARE_VERSION (1U)
132136

137+
/******** TFM_SP_PSOC_SERVICE_TEST ********/
138+
#define PSOC_SERVICE_TEST_PSA_INIT_WD_SID (0x00002001U)
139+
#define PSOC_SERVICE_TEST_PSA_INIT_WD_VERSION (1U)
140+
#define PSOC_SERVICE_TEST_PSA_POKE_WD_SID (0x00002002U)
141+
#define PSOC_SERVICE_TEST_PSA_POKE_WD_VERSION (1U)
142+
#define PSOC_SERVICE_TEST_PSA_KILL_WD_SID (0x00002003U)
143+
#define PSOC_SERVICE_TEST_PSA_KILL_WD_VERSION (1U)
144+
#define PSOC_SERVICE_TEST_PSA_WRITE_FLASH_SID (0x00002004U)
145+
#define PSOC_SERVICE_TEST_PSA_WRITE_FLASH_VERSION (1U)
146+
#define PSOC_SERVICE_TEST_PSA_READ_FLASH_SID (0x00002005U)
147+
#define PSOC_SERVICE_TEST_PSA_READ_FLASH_VERSION (1U)
148+
#define PSOC_SERVICE_TEST_PSA_GET_REBOOT_REASON_SID (0x00002006U)
149+
#define PSOC_SERVICE_TEST_PSA_GET_REBOOT_REASON_VERSION (1U)
150+
151+
/******** TFM_PSOC_CLIENT_TEST ********/
152+
#define PSOC_CLIENT_TEST_LVL2_SID (0x00002000U)
153+
#define PSOC_CLIENT_TEST_LVL2_VERSION (1U)
154+
133155
/******** TFM_SP_SECURE_CLIENT_2 ********/
134156
#define TFM_SECURE_CLIENT_2_SID (0x0000F0E0U)
135157
#define TFM_SECURE_CLIENT_2_VERSION (1U)

features/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/include/tfm_ns_mailbox.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ bool tfm_ns_mailbox_is_msg_replied(mailbox_msg_handle_t handle);
8484
*/
8585
int32_t tfm_ns_mailbox_init(struct ns_mailbox_queue_t *queue);
8686

87+
#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
8788
/**
8889
* \brief Get the handle of the current non-secure task executing mailbox
8990
* functionalities
@@ -96,6 +97,12 @@ int32_t tfm_ns_mailbox_init(struct ns_mailbox_queue_t *queue);
9697
* \return Return the handle of task.
9798
*/
9899
const void *tfm_ns_mailbox_get_task_handle(void);
100+
#else
101+
static inline const void *tfm_ns_mailbox_get_task_handle(void)
102+
{
103+
return NULL;
104+
}
105+
#endif
99106

100107
/**
101108
* \brief Fetch the handle to the first replied mailbox message in the NSPE

0 commit comments

Comments
 (0)