RTX5: uVisor: Use OsEventObserver

pull/4294/head
Jaeden Amero 2017-01-19 13:34:56 +00:00 committed by Martin Kojtal
parent 24c60f6cc7
commit 7ae2e6e9ec
2 changed files with 26 additions and 0 deletions

View File

@ -24,6 +24,7 @@
*/
#include "rtx_lib.h"
#include "rt_OsEventObserver.h"
// OS Runtime Information
@ -541,6 +542,15 @@ osStatus_t osKernelStart (void) {
EvrRtxKernelError(osErrorISR);
return osErrorISR;
}
/* 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();
}
return __svcKernelStart();
}

View File

@ -24,6 +24,7 @@
*/
#include "rtx_lib.h"
#include "rt_OsEventObserver.h"
// ==== Helper functions ====
@ -425,6 +426,10 @@ void osRtxThreadSwitch (os_thread_t *thread) {
osRtxInfo.thread.run.next = thread;
osRtxThreadStackCheck();
EvrRtxThreadSwitch(thread);
if (osEventObs && osEventObs->thread_switch) {
osEventObs->thread_switch(thread->context);
}
}
/// Dispatch specified Thread or Ready Thread with Highest Priority.
@ -769,6 +774,13 @@ osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThrea
EvrRtxThreadCreated(thread);
/* 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;
}
osRtxThreadDispatch(thread);
return thread;
@ -1215,6 +1227,10 @@ osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
return osErrorResource;
}
if (osEventObs && osEventObs->thread_destroy) {
osEventObs->thread_destroy(thread->context);
}
// Release owned Mutexes
osRtxMutexOwnerRelease(thread->mutex_list);