mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
756e0cae99
commit
24c60f6cc7
|
@ -358,6 +358,7 @@ uint32_t osKernelGetSysTimerFreq (void);
|
|||
/// \param[in] attr thread attributes; NULL: default values.
|
||||
/// \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 osThreadContextNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context);
|
||||
|
||||
/// Get name of a thread.
|
||||
/// \param[in] thread_id thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
|
||||
|
|
|
@ -253,7 +253,7 @@ osStatus_t svcRtxKernelStart (void) {
|
|||
|
||||
// Create Idle Thread
|
||||
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) {
|
||||
EvrRtxKernelError(osError);
|
||||
return osError;
|
||||
|
@ -263,7 +263,7 @@ osStatus_t svcRtxKernelStart (void) {
|
|||
// Create Timer Thread
|
||||
if (osRtxConfig.timer_mq_mcnt != 0U) {
|
||||
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) {
|
||||
EvrRtxKernelError(osError);
|
||||
return osError;
|
||||
|
|
|
@ -128,7 +128,7 @@ extern uint32_t svcRtxKernelGetSysTimerCount (void);
|
|||
extern uint32_t svcRtxKernelGetSysTimerFreq (void);
|
||||
|
||||
// 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 osThreadId_t svcRtxThreadGetId (void);
|
||||
extern osThreadState_t svcRtxThreadGetState (osThreadId_t thread_id);
|
||||
|
|
|
@ -127,6 +127,7 @@ typedef struct osRtxThread_s {
|
|||
uint32_t sp; ///< Current Stack Pointer
|
||||
uint32_t thread_addr; ///< Thread entry address
|
||||
uint32_t tz_memory; ///< TrustZone Memory Identifier
|
||||
void *context; ///< Context for OsEventObserver objects
|
||||
} osRtxThread_t;
|
||||
|
||||
|
||||
|
|
|
@ -548,7 +548,7 @@ void osRtxThreadPostProcess (os_thread_t *thread) {
|
|||
// ==== Service Calls ====
|
||||
|
||||
// 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_0 (ThreadGetId, 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)
|
||||
|
||||
/// Create a thread and add it to Active Threads.
|
||||
/// \note API identical to osThreadNew
|
||||
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr) {
|
||||
/// \note API identical to osThreadContextNew
|
||||
osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThreadAttr_t *attr, void *context) {
|
||||
os_thread_t *thread;
|
||||
uint32_t attr_bits;
|
||||
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.
|
||||
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);
|
||||
if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
|
||||
EvrRtxThreadError(NULL, osErrorISR);
|
||||
return NULL;
|
||||
}
|
||||
return __svcThreadNew(func, argument, attr);
|
||||
return __svcThreadNew(func, argument, attr, context);
|
||||
}
|
||||
|
||||
/// Get name of a thread.
|
||||
|
|
Loading…
Reference in New Issue