Skip to content

Commit dd49382

Browse files
committed
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.
1 parent e422824 commit dd49382

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

core/mbed-rtos/rtos/Mutex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Mutex {
5757
osMutexId _osMutexId;
5858
osMutexDef_t _osMutexDef;
5959
#ifdef CMSIS_OS_RTX
60-
#ifdef __MBED_CMSIS_RTOS_CA9
60+
#if defined(__MBED_CMSIS_RTOS_CA9) || defined(__MBED_CMSIS_RTOS_CM)
6161
int32_t _mutex_data[4];
6262
#else
6363
int32_t _mutex_data[3];

core/mbed-rtos/rtos/RtosTimer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ class RtosTimer {
6161
private:
6262
osTimerId _timer_id;
6363
osTimerDef_t _timer;
64-
#ifdef CMSIS_OS_RTX
64+
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
6565
uint32_t _timer_data[5];
66+
#else
67+
uint32_t _timer_data[6];
6668
#endif
6769
};
6870

core/mbed-rtos/rtos/Thread.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace rtos {
2828

2929
Thread::Thread(void (*task)(void const *argument), void *argument,
3030
osPriority priority, uint32_t stack_size, unsigned char *stack_pointer) {
31-
#ifdef CMSIS_OS_RTX
31+
#ifdef __MBED_CMSIS_RTOS_CM
3232
_thread_def.pthread = task;
3333
_thread_def.tpriority = priority;
3434
_thread_def.stacksize = stack_size;
@@ -71,8 +71,10 @@ int32_t Thread::signal_clr(int32_t signals) {
7171
}
7272

7373
Thread::State Thread::get_state() {
74-
#ifndef __MBED_CMSIS_RTOS_CA9
74+
#if !defined(__MBED_CMSIS_RTOS_CA9) && !defined(__MBED_CMSIS_RTOS_CM)
75+
#ifdef CMSIS_OS_RTX
7576
return ((State)_thread_def.tcb.state);
77+
#endif
7678
#else
7779
uint8_t status;
7880
status = osThreadGetState(_tid);
@@ -82,39 +84,55 @@ Thread::State Thread::get_state() {
8284

8385
uint32_t Thread::stack_size() {
8486
#ifndef __MBED_CMSIS_RTOS_CA9
87+
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
8588
return _thread_def.tcb.priv_stack;
8689
#else
8790
return 0;
8891
#endif
92+
#else
93+
return 0;
94+
#endif
8995
}
9096

9197
uint32_t Thread::free_stack() {
9298
#ifndef __MBED_CMSIS_RTOS_CA9
99+
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
93100
uint32_t bottom = (uint32_t)_thread_def.tcb.stack;
94101
return _thread_def.tcb.tsk_stack - bottom;
95102
#else
96103
return 0;
97104
#endif
105+
#else
106+
return 0;
107+
#endif
98108
}
99109

100110
uint32_t Thread::used_stack() {
101111
#ifndef __MBED_CMSIS_RTOS_CA9
112+
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
102113
uint32_t top = (uint32_t)_thread_def.tcb.stack + _thread_def.tcb.priv_stack;
103114
return top - _thread_def.tcb.tsk_stack;
104115
#else
105116
return 0;
106117
#endif
118+
#else
119+
return 0;
120+
#endif
107121
}
108122

109123
uint32_t Thread::max_stack() {
110124
#ifndef __MBED_CMSIS_RTOS_CA9
125+
#if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
111126
uint32_t high_mark = 0;
112127
while (_thread_def.tcb.stack[high_mark] == 0xE25A2EA5)
113128
high_mark++;
114129
return _thread_def.tcb.priv_stack - (high_mark * 4);
115130
#else
116131
return 0;
117132
#endif
133+
#else
134+
return 0;
135+
#endif
118136
}
119137

120138
osEvent Thread::signal_wait(int32_t signals, uint32_t millisec) {
@@ -139,9 +157,11 @@ void Thread::attach_idle_hook(void (*fptr)(void)) {
139157

140158
Thread::~Thread() {
141159
terminate();
160+
#ifdef __MBED_CMSIS_RTOS_CM
142161
if (_dynamic_stack) {
143162
delete[] (_thread_def.stack_pointer);
144163
}
164+
#endif
145165
}
146166

147167
}

core/mbed-rtos/rtx/TARGET_CORTEX_M/RTX_CM_lib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ __attribute__((naked)) void software_init_hook (void) {
556556
"mov r0,r4\n"
557557
"mov r1,r5\n"
558558
"bl osKernelInitialize\n"
559-
#ifdef
559+
#ifdef __MBED_CMSIS_RTOS_CM
560560
"bl set_main_stack\n"
561561
#endif
562562
"ldr r0,=os_thread_def_main\n"

0 commit comments

Comments
 (0)