RTOS - update for RTX v4.79 for Cortex-M

Thread - stack methods are not available for now, as tcb pointer was removed from
internal structure. To obtain it, we could get it from the kernel, but this should be
reconsidered. Either RTOS should provide it, or these methods will become deprecated.
Martin Kojtal 2016-04-06 13:34:20 +01:00
parent 0c4a1674fe
commit 3bffe3d0f5
4 changed files with 27 additions and 5 deletions

View File

@ -57,7 +57,7 @@ private:
osMutexId _osMutexId;
osMutexDef_t _osMutexDef;
#ifdef CMSIS_OS_RTX
#ifdef __MBED_CMSIS_RTOS_CA9
#if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM)
int32_t _mutex_data[4];
#else
int32_t _mutex_data[3];

View File

@ -61,8 +61,10 @@ public:
private:
osTimerId _timer_id;
osTimerDef_t _timer;
#ifdef CMSIS_OS_RTX
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t _timer_data[5];
#else
uint32_t _timer_data[6];
#endif
};

View File

@ -28,7 +28,7 @@ namespace rtos {
Thread::Thread(void (*task)(void const *argument), void *argument,
osPriority priority, uint32_t stack_size, unsigned char *stack_pointer) {
#ifdef CMSIS_OS_RTX
#ifdef __MBED_CMSIS_RTOS_CM
_thread_def.pthread = task;
_thread_def.tpriority = priority;
_thread_def.stacksize = stack_size;
@ -71,8 +71,10 @@ int32_t Thread::signal_clr(int32_t signals) {
}
Thread::State Thread::get_state() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM)
#ifdef CMSIS_OS_RTX
return ((State)_thread_def.tcb.state);
#endif
#else
uint8_t status;
status = osThreadGetState(_tid);
@ -82,32 +84,45 @@ Thread::State Thread::get_state() {
uint32_t Thread::stack_size() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
return _thread_def.tcb.priv_stack;
#else
return 0;
#endif
#else
return 0;
#endif
}
uint32_t Thread::free_stack() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t bottom = (uint32_t)_thread_def.tcb.stack;
return _thread_def.tcb.tsk_stack - bottom;
#else
return 0;
#endif
#else
return 0;
#endif
}
uint32_t Thread::used_stack() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t top = (uint32_t)_thread_def.tcb.stack + _thread_def.tcb.priv_stack;
return top - _thread_def.tcb.tsk_stack;
#else
return 0;
#endif
#else
return 0;
#endif
}
uint32_t Thread::max_stack() {
#ifndef __MBED_CMSIS_RTOS_CA9
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
uint32_t high_mark = 0;
while (_thread_def.tcb.stack[high_mark] == 0xE25A2EA5)
high_mark++;
@ -115,6 +130,9 @@ uint32_t Thread::max_stack() {
#else
return 0;
#endif
#else
return 0;
#endif
}
osEvent Thread::signal_wait(int32_t signals, uint32_t millisec) {
@ -139,9 +157,11 @@ void Thread::attach_idle_hook(void (*fptr)(void)) {
Thread::~Thread() {
terminate();
#ifdef __MBED_CMSIS_RTOS_CM
if (_dynamic_stack) {
delete[] (_thread_def.stack_pointer);
}
#endif
}
}

View File

@ -556,7 +556,7 @@ __attribute__((naked)) void software_init_hook (void) {
"mov r0,r4\n"
"mov r1,r5\n"
"bl osKernelInitialize\n"
#ifdef
#ifdef __MBED_CMSIS_RTOS_CM
"bl set_main_stack\n"
#endif
"ldr r0,=os_thread_def_main\n"