RTX5: uVisor: Use OsEventObserver

pull/6273/head
Jaeden Amero 2017-01-19 13:34:56 +00:00 committed by Bartek Szatkowski
parent 73a957997f
commit c250369803
2 changed files with 23 additions and 4 deletions

View File

@ -24,6 +24,7 @@
*/
#include "rtx_lib.h"
#include "rt_OsEventObserver.h"
// OS Runtime Information
@ -312,7 +313,7 @@ static int32_t svcRtxKernelLock (void) {
}
return lock;
}
/// Unlock the RTOS Kernel scheduler.
/// \note API identical to osKernelUnlock
static int32_t svcRtxKernelUnlock (void) {
@ -430,7 +431,7 @@ static void svcRtxKernelResume (uint32_t sleep_ticks) {
thread->delay = 1U;
do {
osRtxThreadDelayTick();
if (delay == 0U) {
if (delay == 0U) {
break;
}
delay--;
@ -578,6 +579,13 @@ osStatus_t osKernelStart (void) {
EvrRtxKernelError((int32_t)osErrorISR);
status = osErrorISR;
} else {
/* Call the pre-start event (from unprivileged mode) if the handler exists
* and the kernel is not running. */
/* FIXME osEventObs needs to be readable but not writable from unprivileged
* code. */
if (osKernelGetState() != osKernelRunning && osEventObs && osEventObs->pre_start) {
osEventObs->pre_start();
}
status = __svcKernelStart();
}
return status;
@ -596,7 +604,7 @@ int32_t osKernelLock (void) {
}
return lock;
}
/// Unlock the RTOS Kernel scheduler.
int32_t osKernelUnlock (void) {
int32_t lock;

View File

@ -24,7 +24,7 @@
*/
#include "rtx_lib.h"
#include "rt_OsEventObserver.h"
// OS Runtime Object Memory Usage
#if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)))
@ -816,6 +816,13 @@ static osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const
EvrRtxThreadError(NULL, (int32_t)osErrorNoMemory);
}
/* Notify the OS event observer of a new thread. */
if (osEventObs && osEventObs->thread_create) {
thread->context = osEventObs->thread_create((int)thread, context);
} else {
thread->context = context;
}
if (thread != NULL) {
osRtxThreadDispatch(thread);
}
@ -1325,6 +1332,10 @@ static osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
break;
}
if (osEventObs && osEventObs->thread_destroy) {
osEventObs->thread_destroy(thread->context);
}
if (status == osOK) {
// Release owned Mutexes
osRtxMutexOwnerRelease(thread->mutex_list);