Skip to content

Commit c250369

Browse files
Pataterbulislaw
authored andcommitted
RTX5: uVisor: Use OsEventObserver
1 parent 73a9579 commit c250369

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

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

Lines changed: 11 additions & 3 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
@@ -312,7 +313,7 @@ static int32_t svcRtxKernelLock (void) {
312313
}
313314
return lock;
314315
}
315-
316+
316317
/// Unlock the RTOS Kernel scheduler.
317318
/// \note API identical to osKernelUnlock
318319
static int32_t svcRtxKernelUnlock (void) {
@@ -430,7 +431,7 @@ static void svcRtxKernelResume (uint32_t sleep_ticks) {
430431
thread->delay = 1U;
431432
do {
432433
osRtxThreadDelayTick();
433-
if (delay == 0U) {
434+
if (delay == 0U) {
434435
break;
435436
}
436437
delay--;
@@ -578,6 +579,13 @@ osStatus_t osKernelStart (void) {
578579
EvrRtxKernelError((int32_t)osErrorISR);
579580
status = osErrorISR;
580581
} else {
582+
/* Call the pre-start event (from unprivileged mode) if the handler exists
583+
* and the kernel is not running. */
584+
/* FIXME osEventObs needs to be readable but not writable from unprivileged
585+
* code. */
586+
if (osKernelGetState() != osKernelRunning && osEventObs && osEventObs->pre_start) {
587+
osEventObs->pre_start();
588+
}
581589
status = __svcKernelStart();
582590
}
583591
return status;
@@ -596,7 +604,7 @@ int32_t osKernelLock (void) {
596604
}
597605
return lock;
598606
}
599-
607+
600608
/// Unlock the RTOS Kernel scheduler.
601609
int32_t osKernelUnlock (void) {
602610
int32_t lock;

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

Lines changed: 12 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
// OS Runtime Object Memory Usage
3030
#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
816816
EvrRtxThreadError(NULL, (int32_t)osErrorNoMemory);
817817
}
818818

819+
/* Notify the OS event observer of a new thread. */
820+
if (osEventObs && osEventObs->thread_create) {
821+
thread->context = osEventObs->thread_create((int)thread, context);
822+
} else {
823+
thread->context = context;
824+
}
825+
819826
if (thread != NULL) {
820827
osRtxThreadDispatch(thread);
821828
}
@@ -1325,6 +1332,10 @@ static osStatus_t svcRtxThreadTerminate (osThreadId_t thread_id) {
13251332
break;
13261333
}
13271334

1335+
if (osEventObs && osEventObs->thread_destroy) {
1336+
osEventObs->thread_destroy(thread->context);
1337+
}
1338+
13281339
if (status == osOK) {
13291340
// Release owned Mutexes
13301341
osRtxMutexOwnerRelease(thread->mutex_list);

0 commit comments

Comments
 (0)