Skip to content

Commit ab74f77

Browse files
Pataterbulislaw
authored andcommitted
RTX5: uVisor: Extend thread control block with context
OsEventObserver objects expect a context to be maintained per thread on their behalf. Add this context to the thread control block and extend the thread creation functions with the ability to supply a context.
1 parent 8f0e7d5 commit ab74f77

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

rtos/TARGET_CORTEX/rtx5/Include/cmsis_os2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ uint32_t osKernelGetSysTimerFreq (void);
363363
/// \param[in] attr thread attributes; NULL: default values.
364364
/// \return thread ID for reference by other functions or NULL in case of error.
365365
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
366+
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
366367

367368
/// Get name of a thread.
368369
/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.

rtos/TARGET_CORTEX/rtx5/RTX/Include/rtx_os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ typedef struct osRtxThread_s {
127127
uint32_t sp; ///< Current Stack Pointer
128128
uint32_t thread_addr; ///< Thread entry address
129129
uint32_t tz_memory; ///< TrustZone Memory Identifier
130+
void *context; ///< Context for OsEventObserver objects
130131
} osRtxThread_t;
131132

132133

rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_kernel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ osStatus_t svcRtxKernelStart (void) {
245245

246246
// Create Idle Thread
247247
if (osRtxInfo.thread.idle == NULL) {
248-
osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr);
248+
osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr, NULL);
249249
if (osRtxInfo.thread.idle == NULL) {
250250
EvrRtxKernelError(osError);
251251
return osError;
@@ -255,7 +255,7 @@ osStatus_t svcRtxKernelStart (void) {
255255
// Create Timer Thread
256256
if (osRtxConfig.timer_mq_mcnt != 0U) {
257257
if (osRtxInfo.timer.thread == NULL) {
258-
osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr);
258+
osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr, NULL);
259259
if (osRtxInfo.timer.thread == NULL) {
260260
EvrRtxKernelError(osError);
261261
return osError;

rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ extern uint32_t svcRtxKernelGetSysTimerCount (void);
131131
extern uint32_t svcRtxKernelGetSysTimerFreq (void);
132132

133133
// Thread Service Calls
134-
extern osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
134+
extern osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
135135
extern const char * svcRtxThreadGetName (osThreadId_t thread_id);
136136
extern osThreadId_t svcRtxThreadGetId (void);
137137
extern osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id);

rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_thread.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ void osRtxThreadPostProcess (os_thread_t *thread) {
542542
// ==== Service Calls ====
543543

544544
// Service Calls definitions
545-
SVC0_3M(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *)
545+
SVC0_4M(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *, void *)
546546
SVC0_1 (ThreadGetName, const char *, osThreadId_t)
547547
SVC0_0 (ThreadGetId, osThreadId_t)
548548
SVC0_1 (ThreadGetState, osThreadState_t, osThreadId_t)
@@ -565,8 +565,8 @@ SVC0_0 (ThreadFlagsGet, uint32_t)
565565
SVC0_3 (ThreadFlagsWait, uint32_t, uint32_t, uint32_t, uint32_t)
566566

567567
/// Create a thread and add it to Active Threads.
568-
/// \note API identical to osThreadNew
569-
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
568+
/// \note API identical to osThreadContextNew
569+
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
570570
os_thread_t *thread;
571571
uint32_t attr_bits;
572572
void *stack_mem;
@@ -1498,12 +1498,16 @@ uint32_t isrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
14981498

14991499
/// Create a thread and add it to Active Threads.
15001500
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
1501+
return osThreadContextNew(func, argument, attr, NULL);
1502+
}
1503+
1504+
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
15011505
EvrRtxThreadNew(func, argument, attr);
15021506
if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
15031507
EvrRtxThreadError(NULL, osErrorISR);
15041508
return NULL;
15051509
}
1506-
return __svcThreadNew(func, argument, attr);
1510+
return __svcThreadNew(func, argument, attr, context);
15071511
}
15081512

15091513
/// Get name of a thread.

0 commit comments

Comments
 (0)