Skip to content

Commit 24c60f6

Browse files
Patater0xc0170
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 756e0ca commit 24c60f6

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

rtos/rtx2/TARGET_CORTEX_M/cmsis_os2.h

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

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

rtos/rtx2/TARGET_CORTEX_M/rtx_kernel.c

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

254254
// Create Idle Thread
255255
if (osRtxInfo.thread.idle == NULL) {
256-
osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr);
256+
osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr, NULL);
257257
if (osRtxInfo.thread.idle == NULL) {
258258
EvrRtxKernelError(osError);
259259
return osError;
@@ -263,7 +263,7 @@ osStatus_t svcRtxKernelStart (void) {
263263
// Create Timer Thread
264264
if (osRtxConfig.timer_mq_mcnt != 0U) {
265265
if (osRtxInfo.timer.thread == NULL) {
266-
osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr);
266+
osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr, NULL);
267267
if (osRtxInfo.timer.thread == NULL) {
268268
EvrRtxKernelError(osError);
269269
return osError;

rtos/rtx2/TARGET_CORTEX_M/rtx_lib.h

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

130130
// Thread Service Calls
131-
extern osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
131+
extern osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
132132
extern const char * svcRtxThreadGetName (osThreadId_t thread_id);
133133
extern osThreadId_t svcRtxThreadGetId (void);
134134
extern osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id);

rtos/rtx2/TARGET_CORTEX_M/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/rtx2/TARGET_CORTEX_M/rtx_thread.c

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

550550
// Service Calls definitions
551-
SVC0_3M(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *)
551+
SVC0_4M(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *, void *)
552552
SVC0_1 (ThreadGetName, const char *, osThreadId_t)
553553
SVC0_0 (ThreadGetId, osThreadId_t)
554554
SVC0_1 (ThreadGetState, osThreadState_t, osThreadId_t)
@@ -571,8 +571,8 @@ SVC0_0 (ThreadFlagsGet, uint32_t)
571571
SVC0_3 (ThreadFlagsWait, uint32_t, uint32_t, uint32_t, uint32_t)
572572

573573
/// Create a thread and add it to Active Threads.
574-
/// \note API identical to osThreadNew
575-
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
574+
/// \note API identical to osThreadContextNew
575+
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
576576
os_thread_t *thread;
577577
uint32_t attr_bits;
578578
void *stack_mem;
@@ -1501,12 +1501,16 @@ uint32_t isrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
15011501

15021502
/// Create a thread and add it to Active Threads.
15031503
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
1504+
return osThreadContextNew(func, argument, attr, NULL);
1505+
}
1506+
1507+
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
15041508
EvrRtxThreadNew(func, argument, attr);
15051509
if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
15061510
EvrRtxThreadError(NULL, osErrorISR);
15071511
return NULL;
15081512
}
1509-
return __svcThreadNew(func, argument, attr);
1513+
return __svcThreadNew(func, argument, attr, context);
15101514
}
15111515

15121516
/// Get name of a thread.

0 commit comments

Comments
 (0)