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.
pull/4294/head
Jaeden Amero 2017-01-25 17:19:27 +00:00 committed by Martin Kojtal
parent 756e0cae99
commit 24c60f6cc7
5 changed files with 13 additions and 7 deletions

View File

@ -358,6 +358,7 @@ uint32_t osKernelGetSysTimerFreq (void);
/// \param[in] attr thread attributes; NULL: default values. /// \param[in] attr thread attributes; NULL: default values.
/// \return thread ID for reference by other functions or NULL in case of error. /// \return thread ID for reference by other functions or NULL in case of error.
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr); osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr);
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
/// Get name of a thread. /// Get name of a thread.
/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId. /// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.

View File

@ -253,7 +253,7 @@ osStatus_t svcRtxKernelStart (void) {
// Create Idle Thread // Create Idle Thread
if (osRtxInfo.thread.idle == NULL) { if (osRtxInfo.thread.idle == NULL) {
osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr); osRtxInfo.thread.idle = svcRtxThreadNew(osRtxIdleThread, NULL, osRtxConfig.idle_thread_attr, NULL);
if (osRtxInfo.thread.idle == NULL) { if (osRtxInfo.thread.idle == NULL) {
EvrRtxKernelError(osError); EvrRtxKernelError(osError);
return osError; return osError;
@ -263,7 +263,7 @@ osStatus_t svcRtxKernelStart (void) {
// Create Timer Thread // Create Timer Thread
if (osRtxConfig.timer_mq_mcnt != 0U) { if (osRtxConfig.timer_mq_mcnt != 0U) {
if (osRtxInfo.timer.thread == NULL) { if (osRtxInfo.timer.thread == NULL) {
osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr); osRtxInfo.timer.thread = svcRtxThreadNew(osRtxTimerThread, NULL, osRtxConfig.timer_thread_attr, NULL);
if (osRtxInfo.timer.thread == NULL) { if (osRtxInfo.timer.thread == NULL) {
EvrRtxKernelError(osError); EvrRtxKernelError(osError);
return osError; return osError;

View File

@ -128,7 +128,7 @@ extern uint32_t svcRtxKernelGetSysTimerCount (void);
extern uint32_t svcRtxKernelGetSysTimerFreq (void); extern uint32_t svcRtxKernelGetSysTimerFreq (void);
// Thread Service Calls // Thread Service Calls
extern osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr); extern osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
extern const char * svcRtxThreadGetName (osThreadId_t thread_id); extern const char * svcRtxThreadGetName (osThreadId_t thread_id);
extern osThreadId_t svcRtxThreadGetId (void); extern osThreadId_t svcRtxThreadGetId (void);
extern osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id); extern osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id);

View File

@ -127,6 +127,7 @@ typedef struct osRtxThread_s {
uint32_t sp; ///< Current Stack Pointer uint32_t sp; ///< Current Stack Pointer
uint32_t thread_addr; ///< Thread entry address uint32_t thread_addr; ///< Thread entry address
uint32_t tz_memory; ///< TrustZone Memory Identifier uint32_t tz_memory; ///< TrustZone Memory Identifier
void *context; ///< Context for OsEventObserver objects
} osRtxThread_t; } osRtxThread_t;

View File

@ -548,7 +548,7 @@ void osRtxThreadPostProcess (os_thread_t *thread) {
// ==== Service Calls ==== // ==== Service Calls ====
// Service Calls definitions // Service Calls definitions
SVC0_3M(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *) SVC0_4M(ThreadNew, osThreadId_t, osThreadFunc_t, void *, const osThreadAttr_t *, void *)
SVC0_1 (ThreadGetName, const char *, osThreadId_t) SVC0_1 (ThreadGetName, const char *, osThreadId_t)
SVC0_0 (ThreadGetId, osThreadId_t) SVC0_0 (ThreadGetId, osThreadId_t)
SVC0_1 (ThreadGetState, osThreadState_t, osThreadId_t) SVC0_1 (ThreadGetState, osThreadState_t, osThreadId_t)
@ -571,8 +571,8 @@ SVC0_0 (ThreadFlagsGet, uint32_t)
SVC0_3 (ThreadFlagsWait, uint32_t, uint32_t, uint32_t, uint32_t) SVC0_3 (ThreadFlagsWait, uint32_t, uint32_t, uint32_t, uint32_t)
/// Create a thread and add it to Active Threads. /// Create a thread and add it to Active Threads.
/// \note API identical to osThreadNew /// \note API identical to osThreadContextNew
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) { osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
os_thread_t *thread; os_thread_t *thread;
uint32_t attr_bits; uint32_t attr_bits;
void *stack_mem; void *stack_mem;
@ -1501,12 +1501,16 @@ uint32_t isrRtxThreadFlagsSet (osThreadId_t thread_id, uint32_t flags) {
/// Create a thread and add it to Active Threads. /// Create a thread and add it to Active Threads.
osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) { osThreadId_t osThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
return osThreadContextNew(func, argument, attr, NULL);
}
osThreadId_t osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
EvrRtxThreadNew(func, argument, attr); EvrRtxThreadNew(func, argument, attr);
if (IS_IRQ_MODE() || IS_IRQ_MASKED()) { if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
EvrRtxThreadError(NULL, osErrorISR); EvrRtxThreadError(NULL, osErrorISR);
return NULL; return NULL;
} }
return __svcThreadNew(func, argument, attr); return __svcThreadNew(func, argument, attr, context);
} }
/// Get name of a thread. /// Get name of a thread.