diff --git a/events/equeue/equeue_platform.h b/events/equeue/equeue_platform.h index 5a16e07..9c5bec2 100644 --- a/events/equeue/equeue_platform.h +++ b/events/equeue/equeue_platform.h @@ -51,7 +51,7 @@ #include #elif defined(EQUEUE_PLATFORM_MBED) #include "cmsis_os2.h" -#include "rtx_lib.h" +#include "mbed_rtos_storage.h" #endif @@ -117,7 +117,7 @@ #elif defined(EQUEUE_PLATFORM_MBED) && defined(MBED_CONF_RTOS_PRESENT) typedef struct equeue_sema { osEventFlagsId_t id; - os_event_flags_t mem; + mbed_rtos_storage_event_flags_t mem; } equeue_sema_t; #elif defined(EQUEUE_PLATFORM_MBED) typedef volatile int equeue_sema_t; diff --git a/rtos/Mail.h b/rtos/Mail.h index b4a0289..602907e 100644 --- a/rtos/Mail.h +++ b/rtos/Mail.h @@ -28,7 +28,7 @@ #include "Queue.h" #include "MemoryPool.h" #include "cmsis_os2.h" -#include "rtx_lib.h" +#include "mbed_rtos_storage.h" #include "mbed_rtos1_types.h" #include "platform/NonCopyable.h" diff --git a/rtos/RtosTimer.h b/rtos/RtosTimer.h index b490fd3..3abef47 100644 --- a/rtos/RtosTimer.h +++ b/rtos/RtosTimer.h @@ -24,7 +24,7 @@ #include #include "cmsis_os2.h" -#include "rtx_lib.h" +#include "mbed_rtos_storage.h" #include "platform/Callback.h" #include "platform/NonCopyable.h" #include "platform/mbed_toolchain.h" @@ -150,7 +150,7 @@ osTimerId_t _id; osTimerAttr_t _attr; - os_timer_t _obj_mem; + mbed_rtos_storage_timer_t _obj_mem; mbed::Callback _function; }; diff --git a/rtos/TARGET_CORTEX/mbed_rtos_storage.h b/rtos/TARGET_CORTEX/mbed_rtos_storage.h index 50e9227..11ebc43 100644 --- a/rtos/TARGET_CORTEX/mbed_rtos_storage.h +++ b/rtos/TARGET_CORTEX/mbed_rtos_storage.h @@ -41,6 +41,7 @@ */ #include "rtx_lib.h" +#include "mbed_rtx_conf.h" typedef os_mutex_t mbed_rtos_storage_mutex_t; typedef os_semaphore_t mbed_rtos_storage_semaphore_t; diff --git a/rtos/TARGET_CORTEX/mbed_rtx_conf.h b/rtos/TARGET_CORTEX/mbed_rtx_conf.h index b4fe1d4..304c2a1 100644 --- a/rtos/TARGET_CORTEX/mbed_rtx_conf.h +++ b/rtos/TARGET_CORTEX/mbed_rtx_conf.h @@ -24,6 +24,9 @@ #include "mbed_rtx.h" +/** Any access to RTX5 specific data structures used in common code should be wrapped in ifdef MBED_OS_BACKEND_RTX5 */ +#define MBED_OS_BACKEND_RTX5 + /** The thread's stack size can be configured by the application, if not explicitly specified it'll default to 4K */ #ifndef MBED_CONF_APP_THREAD_STACK_SIZE #define MBED_CONF_APP_THREAD_STACK_SIZE 4096 diff --git a/rtos/Thread.cpp b/rtos/Thread.cpp index 2db5ecc..f01f1b1 100644 --- a/rtos/Thread.cpp +++ b/rtos/Thread.cpp @@ -168,7 +168,11 @@ _mutex.lock(); if (_tid != NULL) { +#if defined(MBED_OS_BACKEND_RTX5) state = _obj_mem.state; +#else + state = osThreadGetState(_tid); +#endif } _mutex.unlock(); @@ -185,6 +189,7 @@ case osThreadRunning: user_state = Running; break; +#if defined(MBED_OS_BACKEND_RTX5) case osRtxThreadWaitingDelay: user_state = WaitingDelay; break; @@ -212,6 +217,7 @@ case osRtxThreadWaitingMessagePut: user_state = WaitingMessagePut; break; +#endif case osThreadTerminated: default: user_state = Deleted; @@ -226,8 +232,7 @@ _mutex.lock(); if (_tid != NULL) { - os_thread_t *thread = (os_thread_t *)_tid; - size = thread->stack_size; + size = osThreadGetStackSize(_tid); } _mutex.unlock(); @@ -238,10 +243,12 @@ uint32_t size = 0; _mutex.lock(); +#if defined(MBED_OS_BACKEND_RTX5) if (_tid != NULL) { os_thread_t *thread = (os_thread_t *)_tid; size = (uint32_t)thread->sp - (uint32_t)thread->stack_mem; } +#endif _mutex.unlock(); return size; @@ -251,10 +258,12 @@ uint32_t size = 0; _mutex.lock(); +#if defined(MBED_OS_BACKEND_RTX5) if (_tid != NULL) { os_thread_t *thread = (os_thread_t *)_tid; size = ((uint32_t)thread->stack_mem + thread->stack_size) - thread->sp; } +#endif _mutex.unlock(); return size; @@ -265,11 +274,15 @@ _mutex.lock(); if (_tid != NULL) { +#if defined(MBED_OS_BACKEND_RTX5) os_thread_t *thread = (os_thread_t *)_tid; uint32_t high_mark = 0; while (((uint32_t *)(thread->stack_mem))[high_mark] == 0xE25A2EA5) high_mark++; size = thread->stack_size - (high_mark * sizeof(uint32_t)); +#else + size = osThreadGetStackSize(_tid) - osThreadGetStackSpace(_tid); +#endif } _mutex.unlock(); diff --git a/rtos/Thread.h b/rtos/Thread.h index 3d921bd..7aa4faa 100644 --- a/rtos/Thread.h +++ b/rtos/Thread.h @@ -26,7 +26,6 @@ #include "cmsis_os2.h" #include "mbed_rtos1_types.h" #include "mbed_rtos_storage.h" -#include "mbed_rtx_conf.h" #include "platform/Callback.h" #include "platform/mbed_toolchain.h" #include "platform/NonCopyable.h" diff --git a/rtos/rtos.h b/rtos/rtos.h index cf81663..7a10c8e 100644 --- a/rtos/rtos.h +++ b/rtos/rtos.h @@ -25,8 +25,6 @@ #ifndef RTOS_H #define RTOS_H -#include "mbed_rtx.h" -#include "mbed_rtx_conf.h" #include "mbed_rtos_storage.h" #include "rtos/Thread.h" #include "rtos/Mutex.h"