Skip to content

Commit 7ae2e6e

Browse files
Patater0xc0170
authored andcommitted
RTX5: uVisor: Use OsEventObserver
1 parent 24c60f6 commit 7ae2e6e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

rtos/rtx2/TARGET_CORTEX_M/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
@@ -541,6 +542,15 @@ osStatus_t osKernelStart (void) {
541542
EvrRtxKernelError(osErrorISR);
542543
return osErrorISR;
543544
}
545+
546+
/* Call the pre-start event (from unprivileged mode) if the handler exists
547+
* and the kernel is not running. */
548+
/* FIXME osEventObs needs to be readable but not writable from unprivileged
549+
* code. */
550+
if (osKernelGetState() != osKernelRunning && osEventObs && osEventObs->pre_start) {
551+
osEventObs->pre_start();
552+
}
553+
544554
return __svcKernelStart();
545555
}
546556

rtos/rtx2/TARGET_CORTEX_M/rtx_thread.c

Lines changed: 16 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
// ==== Helper functions ====
@@ -425,6 +426,10 @@ void osRtxThreadSwitch (os_thread_t *thread) {
425426
osRtxInfo.thread.run.next = thread;
426427
osRtxThreadStackCheck();
427428
EvrRtxThreadSwitch(thread);
429+
430+
if (osEventObs && osEventObs->thread_switch) {
431+
osEventObs->thread_switch(thread->context);
432+
}
428433
}
429434

430435
/// Dispatch specified Thread or Ready Thread with Highest Priority.
@@ -769,6 +774,13 @@ osThreadId_t svcRtxThreadNew (osThreadFunc_t func, void *argument, const osThrea
769774

770775
EvrRtxThreadCreated(thread);
771776

777+
/* Notify the OS event observer of a new thread. */
778+
if (osEventObs && osEventObs->thread_create) {
779+
thread->context = osEventObs->thread_create((int)thread, context);
780+
} else {
781+
thread->context = context;
782+
}
783+
772784
osRtxThreadDispatch(thread);
773785

774786
return thread;
@@ -1215,6 +1227,10 @@ osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
12151227
return osErrorResource;
12161228
}
12171229

1230+
if (osEventObs && osEventObs->thread_destroy) {
1231+
osEventObs->thread_destroy(thread->context);
1232+
}
1233+
12181234
// Release owned Mutexes
12191235
osRtxMutexOwnerRelease(thread->mutex_list);
12201236

0 commit comments

Comments
 (0)