Skip to content

Commit 659fb92

Browse files
Pataterbulislaw
authored andcommitted
RTX5: uVisor: Use OsEventObserver
1 parent ab74f77 commit 659fb92

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_kernel.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525

2626
#include "rtx_lib.h"
27+
#include "rt_OsEventObserver.h"
2728

2829

2930
// OS Runtime Information
@@ -543,6 +544,15 @@ osStatus_t osKernelStart (void) {
543544
EvrRtxKernelError(osErrorISR);
544545
return osErrorISR;
545546
}
547+
548+
/* Call the pre-start event (from unprivileged mode) if the handler exists
549+
* and the kernel is not running. */
550+
/* FIXME osEventObs needs to be readable but not writable from unprivileged
551+
* code. */
552+
if (osKernelGetState() != osKernelRunning && osEventObs && osEventObs->pre_start) {
553+
osEventObs->pre_start();
554+
}
555+
546556
return __svcKernelStart();
547557
}
548558

rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_thread.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
#include "rtx_lib.h"
27-
27+
#include "rt_OsEventObserver.h"
2828

2929
// ==== Helper functions ====
3030

@@ -413,6 +413,10 @@ void osRtxThreadSwitch (os_thread_t *thread) {
413413
osRtxInfo.thread.run.next = thread;
414414
osRtxThreadStackCheck();
415415
EvrRtxThreadSwitch(thread);
416+
417+
if (osEventObs && osEventObs->thread_switch) {
418+
osEventObs->thread_switch(thread->context);
419+
}
416420
}
417421

418422
/// Dispatch specified Thread or Ready Thread with Highest Priority.
@@ -766,6 +770,13 @@ osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThrea
766770

767771
EvrRtxThreadCreated(thread);
768772

773+
/* Notify the OS event observer of a new thread. */
774+
if (osEventObs && osEventObs->thread_create) {
775+
thread->context = osEventObs->thread_create((int)thread, context);
776+
} else {
777+
thread->context = context;
778+
}
779+
769780
osRtxThreadDispatch(thread);
770781

771782
return thread;
@@ -1212,6 +1223,10 @@ osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
12121223
return osErrorResource;
12131224
}
12141225

1226+
if (osEventObs && osEventObs->thread_destroy) {
1227+
osEventObs->thread_destroy(thread->context);
1228+
}
1229+
12151230
// Release owned Mutexes
12161231
osRtxMutexOwnerRelease(thread->mutex_list);
12171232

0 commit comments

Comments
 (0)