Skip to content

Commit a1bc65a

Browse files
Charley ChuRaymond Ngun
authored andcommitted
psoc64: Update TF-M for MBedOS
Signed-off-by: Charley Chu <[email protected]>
1 parent f7e60be commit a1bc65a

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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,11 +120,7 @@ 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 osThreadGetId();;
126124
}
127125

128126
void tfm_ns_mailbox_hal_wait_reply(mailbox_msg_handle_t handle)
@@ -279,7 +277,7 @@ static bool mailbox_clear_intr(void)
279277
return true;
280278
}
281279

282-
void cpuss_interrupts_ipc_5_IRQHandler(void)
280+
void cpuss_interrupts_ipc_8_IRQHandler(void)
283281
{
284282
uint32_t magic;
285283
mailbox_msg_handle_t handle;
@@ -299,9 +297,6 @@ void cpuss_interrupts_ipc_5_IRQHandler(void)
299297

300298
task_handle = (osThreadId_t)tfm_ns_mailbox_get_msg_owner(handle);
301299
if (task_handle) {
302-
/* According to the description of CMSIS-RTOS v2 Thread Flags,
303-
* osThreadFlagsSet() can be called inside Interrupt Service
304-
* Routine. */
305300
osThreadFlagsSet(task_handle, handle);
306301
}
307302
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@
99
#include "tfm_mailbox.h"
1010
#include "tfm_multi_core_api.h"
1111
#include "cmsis_os2.h"
12+
#include "mbed_rtos_storage.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;
17+
static mbed_rtos_storage_semaphore_t tfm_ns_sema_obj;
1618

1719
__attribute__((weak))
1820
enum tfm_status_e tfm_ns_interface_init(void)
1921
{
20-
osSemaphoreAttr_t sema_attrib = {0};
22+
osSemaphoreAttr_t sema_attrib = {
23+
.name = "tfm_ns_lock",
24+
.attr_bits = 0,
25+
.cb_size = sizeof(tfm_ns_sema_obj),
26+
.cb_mem = &tfm_ns_sema_obj
27+
};
2128

2229
ns_lock_handle = osSemaphoreNew(MAX_SEMAPHORE_COUNT,
2330
MAX_SEMAPHORE_COUNT,

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/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)