Skip to content

Commit 6116687

Browse files
niklarmmeriac
authored andcommitted
RTX: Add context to osThreadCreate/Terminate
1 parent 259bd28 commit 6116687

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

rtos/rtx/TARGET_CORTEX_M/cmsis_os.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ const osThreadDef_t os_thread_def_##name = \
317317
/// \return thread ID for reference by other functions or NULL in case of error.
318318
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument);
319319

320+
osThreadId osThreadContextCreate (const osThreadDef_t *thread_def, void *argument, void *context);
321+
320322
/// Return the thread ID of the current running thread.
321323
/// \return thread ID for reference by other functions or NULL in case of error.
322324
osThreadId osThreadGetId (void);

rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ SVC_0_1(svcKernelRunning, int32_t, RET_int32_t)
459459
SVC_0_1(svcKernelSysTick, uint32_t, RET_uint32_t)
460460

461461
static void sysThreadError (osStatus status);
462-
osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument);
462+
osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument, void *context);
463463
osMessageQId svcMessageCreate (const osMessageQDef_t *queue_def, osThreadId thread_id);
464464

465465
// Kernel Control Service Calls
@@ -489,7 +489,7 @@ osStatus svcKernelInitialize (void) {
489489
if (os_initialized == 0U) {
490490
// Create OS Timers resources (Message Queue & Thread)
491491
osMessageQId_osTimerMessageQ = svcMessageCreate (&os_messageQ_def_osTimerMessageQ, NULL);
492-
osThreadId_osTimerThread = svcThreadCreate(&os_thread_def_osTimerThread, NULL);
492+
osThreadId_osTimerThread = svcThreadCreate(&os_thread_def_osTimerThread, NULL, NULL);
493493
}
494494

495495
sysThreadError(osOK);
@@ -621,7 +621,7 @@ static void sysThreadError (osStatus status) {
621621
__NO_RETURN void osThreadExit (void);
622622

623623
// Thread Service Calls declarations
624-
SVC_2_1(svcThreadCreate, osThreadId, const osThreadDef_t *, void *, RET_pointer)
624+
SVC_3_1(svcThreadCreate, osThreadId, const osThreadDef_t *, void *, void *, RET_pointer)
625625
SVC_0_1(svcThreadGetId, osThreadId, RET_pointer)
626626
SVC_1_1(svcThreadTerminate, osStatus, osThreadId, RET_osStatus)
627627
SVC_0_1(svcThreadYield, osStatus, RET_osStatus)
@@ -631,7 +631,7 @@ SVC_1_1(svcThreadGetPriority, osPriority, osThreadId, RET
631631
// Thread Service Calls
632632

633633
/// Create a thread and add it to Active Threads and set it to state READY
634-
osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument) {
634+
osThreadId svcThreadCreate (const osThreadDef_t *thread_def, void *argument, void *context) {
635635
P_TCB ptcb;
636636
OS_TID tsk;
637637
void *stk;
@@ -791,14 +791,17 @@ osPriority svcThreadGetPriority (osThreadId thread_id) {
791791

792792
/// Create a thread and add it to Active Threads and set it to state READY
793793
osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument) {
794-
if (__get_IPSR() != 0U) {
794+
return osThreadContextCreate(thread_def, argument, NULL);
795+
}
796+
osThreadId osThreadContextCreate (const osThreadDef_t *thread_def, void *argument, void *context) {
797+
if (__get_IPSR() != 0U) {
795798
return NULL; // Not allowed in ISR
796799
}
797800
if (((__get_CONTROL() & 1U) == 0U) && (os_running == 0U)) {
798801
// Privileged and not running
799-
return svcThreadCreate(thread_def, argument);
802+
return svcThreadCreate(thread_def, argument, context);
800803
} else {
801-
return __svcThreadCreate(thread_def, argument);
804+
return __svcThreadCreate(thread_def, argument, context);
802805
}
803806
}
804807

0 commit comments

Comments
 (0)