Skip to content

Commit 99a8467

Browse files
Merge pull request #4817 from c1728p9/move_rtx_handlers
Move RTX error handlers into RTX handler file
2 parents 95f635f + 46f6f52 commit 99a8467

File tree

2 files changed

+70
-69
lines changed

2 files changed

+70
-69
lines changed

platform/mbed_retarget.cpp

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -978,72 +978,3 @@ void operator delete[](void *ptr)
978978
free(ptr);
979979
}
980980
}
981-
982-
#if defined(MBED_CONF_RTOS_PRESENT) && defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
983-
984-
static const char* error_msg(int32_t status)
985-
{
986-
switch (status) {
987-
case osError:
988-
return "Unspecified RTOS error";
989-
case osErrorTimeout:
990-
return "Operation not completed within the timeout period";
991-
case osErrorResource:
992-
return "Resource not available";
993-
case osErrorParameter:
994-
return "Parameter error";
995-
case osErrorNoMemory:
996-
return "System is out of memory";
997-
case osErrorISR:
998-
return "Not allowed in ISR context";
999-
default:
1000-
return "Unknown";
1001-
}
1002-
}
1003-
1004-
extern "C" void EvrRtxKernelError (int32_t status)
1005-
{
1006-
error("Kernel error %i: %s\r\n", status, error_msg(status));
1007-
}
1008-
1009-
extern "C" void EvrRtxThreadError (osThreadId_t thread_id, int32_t status)
1010-
{
1011-
error("Thread %p error %i: %s\r\n", thread_id, status, error_msg(status));
1012-
}
1013-
1014-
extern "C" void EvrRtxTimerError (osTimerId_t timer_id, int32_t status)
1015-
{
1016-
error("Timer %p error %i: %s\r\n", timer_id, status, error_msg(status));
1017-
}
1018-
1019-
extern "C" void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status)
1020-
{
1021-
error("Event %p error %i: %s\r\n", ef_id, status, error_msg(status));
1022-
}
1023-
1024-
extern "C" void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status)
1025-
{
1026-
error("Mutex %p error %i: %s\r\n", mutex_id, status, error_msg(status));
1027-
}
1028-
1029-
extern "C" void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
1030-
{
1031-
// Ignore semaphore overflow, the count will saturate with a returned error
1032-
if (status == osRtxErrorSemaphoreCountLimit) {
1033-
return;
1034-
}
1035-
1036-
error("Semaphore %p error %i\r\n", semaphore_id, status);
1037-
}
1038-
1039-
extern "C" void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status)
1040-
{
1041-
error("Memory Pool %p error %i\r\n", mp_id, status);
1042-
}
1043-
1044-
extern "C" void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status)
1045-
{
1046-
error("Message Queue %p error %i\r\n", mq_id, status);
1047-
}
1048-
1049-
#endif

rtos/rtx5/mbed_rtx_handlers.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "cmsis_compiler.h"
1818
#include "rtx_os.h"
19+
#include "rtx_evr.h"
1920
#include "mbed_rtx.h"
2021
#include "mbed_error.h"
2122

@@ -66,3 +67,72 @@ __NO_RETURN uint32_t osRtxErrorNotify (uint32_t code, void *object_id)
6667
/* That shouldn't be reached */
6768
for (;;) {}
6869
}
70+
71+
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED
72+
73+
static const char* error_msg(int32_t status)
74+
{
75+
switch (status) {
76+
case osError:
77+
return "Unspecified RTOS error";
78+
case osErrorTimeout:
79+
return "Operation not completed within the timeout period";
80+
case osErrorResource:
81+
return "Resource not available";
82+
case osErrorParameter:
83+
return "Parameter error";
84+
case osErrorNoMemory:
85+
return "System is out of memory";
86+
case osErrorISR:
87+
return "Not allowed in ISR context";
88+
default:
89+
return "Unknown";
90+
}
91+
}
92+
93+
void EvrRtxKernelError (int32_t status)
94+
{
95+
error("Kernel error %i: %s\r\n", status, error_msg(status));
96+
}
97+
98+
void EvrRtxThreadError (osThreadId_t thread_id, int32_t status)
99+
{
100+
error("Thread %p error %i: %s\r\n", thread_id, status, error_msg(status));
101+
}
102+
103+
void EvrRtxTimerError (osTimerId_t timer_id, int32_t status)
104+
{
105+
error("Timer %p error %i: %s\r\n", timer_id, status, error_msg(status));
106+
}
107+
108+
void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status)
109+
{
110+
error("Event %p error %i: %s\r\n", ef_id, status, error_msg(status));
111+
}
112+
113+
void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status)
114+
{
115+
error("Mutex %p error %i: %s\r\n", mutex_id, status, error_msg(status));
116+
}
117+
118+
void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
119+
{
120+
// Ignore semaphore overflow, the count will saturate with a returned error
121+
if (status == osRtxErrorSemaphoreCountLimit) {
122+
return;
123+
}
124+
125+
error("Semaphore %p error %i\r\n", semaphore_id, status);
126+
}
127+
128+
void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status)
129+
{
130+
error("Memory Pool %p error %i\r\n", mp_id, status);
131+
}
132+
133+
void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status)
134+
{
135+
error("Message Queue %p error %i\r\n", mq_id, status);
136+
}
137+
138+
#endif

0 commit comments

Comments
 (0)