Skip to content

Remove use of internal RTX types #4776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions events/equeue/equeue_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern "C" {
#include <pthread.h>
#elif defined(EQUEUE_PLATFORM_MBED)
#include "cmsis_os2.h"
#include "rtx_lib.h"
#include "mbed_rtos_storage.h"
#endif


Expand Down Expand Up @@ -117,7 +117,7 @@ typedef struct equeue_sema {
#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;
Expand Down
2 changes: 1 addition & 1 deletion rtos/Mail.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions rtos/RtosTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <stdint.h>
#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"
Expand Down Expand Up @@ -150,7 +150,7 @@ class RtosTimer : private mbed::NonCopyable<RtosTimer> {

osTimerId_t _id;
osTimerAttr_t _attr;
os_timer_t _obj_mem;
mbed_rtos_storage_timer_t _obj_mem;
mbed::Callback<void()> _function;
};

Expand Down
1 change: 1 addition & 0 deletions rtos/TARGET_CORTEX/mbed_rtos_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern "C" {
*/

#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;
Expand Down
3 changes: 3 additions & 0 deletions rtos/TARGET_CORTEX/mbed_rtx_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions rtos/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ Thread::State Thread::get_state() {
_mutex.lock();

if (_tid != NULL) {
#if defined(MBED_OS_BACKEND_RTX5)
state = _obj_mem.state;
#else
state = osThreadGetState(_tid);
#endif
}

_mutex.unlock();
Expand All @@ -185,6 +189,7 @@ Thread::State Thread::get_state() {
case osThreadRunning:
user_state = Running;
break;
#if defined(MBED_OS_BACKEND_RTX5)
case osRtxThreadWaitingDelay:
user_state = WaitingDelay;
break;
Expand Down Expand Up @@ -212,6 +217,7 @@ Thread::State Thread::get_state() {
case osRtxThreadWaitingMessagePut:
user_state = WaitingMessagePut;
break;
#endif
case osThreadTerminated:
default:
user_state = Deleted;
Expand All @@ -226,8 +232,7 @@ uint32_t Thread::stack_size() {
_mutex.lock();

if (_tid != NULL) {
os_thread_t *thread = (os_thread_t *)_tid;
size = thread->stack_size;
size = osThreadGetStackSize(_tid);
}

_mutex.unlock();
Expand All @@ -238,10 +243,12 @@ uint32_t Thread::free_stack() {
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;
Expand All @@ -251,10 +258,12 @@ uint32_t Thread::used_stack() {
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;
Expand All @@ -265,11 +274,15 @@ uint32_t Thread::max_stack() {
_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();
Expand Down
1 change: 0 additions & 1 deletion rtos/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions rtos/rtos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down