Skip to content

Commit 86b91be

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 c250369 commit 86b91be

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-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
@@ -366,6 +366,7 @@ uint32_t osKernelGetSysTimerFreq (void);
366366
/// \param[in] attr thread attributes; NULL: default values.
367367
/// \return thread ID for reference by other functions or NULL in case of error.
368368
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
369+
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
369370

370371
/// Get name of a thread.
371372
/// \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_thread.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ static void osRtxThreadPostProcess (os_thread_t *thread) {
581581
// ==== Service Calls ====
582582

583583
/// Create a thread and add it to Active Threads.
584-
/// \note API identical to osThreadNew
585-
static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
584+
/// \note API identical to osThreadContextNew
585+
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
586586
os_thread_t *thread;
587587
uint32_t attr_bits;
588588
void *stack_mem;
@@ -1608,7 +1608,7 @@ static uint32_t svcRtxThreadFlagsWait (uint32_t flags, uint32_t options, uint32_
16081608

16091609
// Service Calls definitions
16101610
//lint ++flb "Library Begin" [MISRA Note 11]
1611-
SVC0_3 (ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *)
1611+
SVC0_4 (ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *, void *)
16121612
SVC0_1 (ThreadGetName, const char *, osThreadId_t)
16131613
SVC0_0 (ThreadGetId, osThreadId_t)
16141614
SVC0_1 (ThreadGetState, osThreadState_t, osThreadId_t)
@@ -1679,7 +1679,7 @@ bool_t osRtxThreadStartup (void) {
16791679
// Create Idle Thread
16801680
if (osRtxInfo.thread.idle == NULL) {
16811681
osRtxInfo.thread.idle = osRtxThreadId(
1682-
svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr)
1682+
svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr, NULL)
16831683
);
16841684
if (osRtxInfo.thread.idle == NULL) {
16851685
ret = FALSE;
@@ -1690,7 +1690,7 @@ bool_t osRtxThreadStartup (void) {
16901690
if (osRtxConfig.timer_mq_mcnt != 0U) {
16911691
if (osRtxInfo.timer.thread == NULL) {
16921692
osRtxInfo.timer.thread = osRtxThreadId(
1693-
svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr)
1693+
svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr, NULL)
16941694
);
16951695
if (osRtxInfo.timer.thread == NULL) {
16961696
ret = FALSE;
@@ -1706,14 +1706,17 @@ bool_t osRtxThreadStartup (void) {
17061706

17071707
/// Create a thread and add it to Active Threads.
17081708
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
1709-
osThreadId_t thread_id;
1709+
return osThreadContextNew(func, argument, attr, NULL);
1710+
}
17101711

1712+
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
1713+
osThreadId_t thread_id;
17111714
EvrRtxThreadNew(func, argument, attr);
17121715
if (IsIrqMode() || IsIrqMasked()) {
17131716
EvrRtxThreadError(NULL, (int32_t)osErrorISR);
17141717
thread_id = NULL;
17151718
} else {
1716-
thread_id = __svcThreadNew(func, argument, attr);
1719+
thread_id = __svcThreadNew(func, argument, attr, context);
17171720
}
17181721
return thread_id;
17191722
}

0 commit comments

Comments
 (0)