Skip to content

Commit 8c29cf3

Browse files
committed
Introduce STK_TLS macro to enable TLS (off by default).
Introduce STK_TLS_PREFER_REGISTER macro to use R9 register for ARM Cortex-M arch. Add TLS example for emulator arch.
1 parent 14156cd commit 8c29cf3

16 files changed

Lines changed: 721 additions & 35 deletions

File tree

build/example/project/eclipse/risc-v/tls/src/stk_config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212

1313
#include "risc-v/encoding.h"
1414

15-
// Risc-V
15+
// RISC-V arch.
1616
#define _STK_ARCH_RISC_V
1717

18+
// Use TLS.
19+
#define STK_TLS (1)
20+
1821
// Minimal stack size depending on the configured architecture (STK default is 32).
1922
#if (__riscv_32e != 1)
2023
#if (__riscv_flen == 0)
@@ -24,6 +27,7 @@
2427
#endif
2528
#endif
2629

30+
// Override ISR handlers if your BSP are using other names.
2731
#ifdef _STK_ARCH_RISC_V
2832
// Redefine if SysTick handler name is different from SysTick_Handler
2933
//#define STK_SYSTICK_HANDLER SysTick_Handler

build/example/project/eclipse/stm/tls-stm32f407g-disc1/.project

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@
125125
<type>2</type>
126126
<locationURI>virtual:/virtual</locationURI>
127127
</link>
128+
<link>
129+
<name>deps/stk/include/sync</name>
130+
<type>2</type>
131+
<locationURI>virtual:/virtual</locationURI>
132+
</link>
133+
<link>
134+
<name>deps/stk/include/time</name>
135+
<type>2</type>
136+
<locationURI>virtual:/virtual</locationURI>
137+
</link>
128138
<link>
129139
<name>deps/stk/src/arch</name>
130140
<type>2</type>
@@ -220,11 +230,111 @@
220230
<type>2</type>
221231
<locationURI>virtual:/virtual</locationURI>
222232
</link>
233+
<link>
234+
<name>deps/stk/include/strategy/stk_strategy_edf.h</name>
235+
<type>1</type>
236+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/strategy/stk_strategy_edf.h</locationURI>
237+
</link>
238+
<link>
239+
<name>deps/stk/include/strategy/stk_strategy_fpriority.h</name>
240+
<type>1</type>
241+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/strategy/stk_strategy_fpriority.h</locationURI>
242+
</link>
243+
<link>
244+
<name>deps/stk/include/strategy/stk_strategy_monotonic.h</name>
245+
<type>1</type>
246+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/strategy/stk_strategy_monotonic.h</locationURI>
247+
</link>
223248
<link>
224249
<name>deps/stk/include/strategy/stk_strategy_rrobin.h</name>
225250
<type>1</type>
226251
<locationURI>PARENT-6-PROJECT_LOC/stk/include/strategy/stk_strategy_rrobin.h</locationURI>
227252
</link>
253+
<link>
254+
<name>deps/stk/include/strategy/stk_strategy_swrrobin.h</name>
255+
<type>1</type>
256+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/strategy/stk_strategy_swrrobin.h</locationURI>
257+
</link>
258+
<link>
259+
<name>deps/stk/include/sync/README.md</name>
260+
<type>1</type>
261+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/README.md</locationURI>
262+
</link>
263+
<link>
264+
<name>deps/stk/include/sync/stk_sync.h</name>
265+
<type>1</type>
266+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync.h</locationURI>
267+
</link>
268+
<link>
269+
<name>deps/stk/include/sync/stk_sync_cs.h</name>
270+
<type>1</type>
271+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_cs.h</locationURI>
272+
</link>
273+
<link>
274+
<name>deps/stk/include/sync/stk_sync_cv.h</name>
275+
<type>1</type>
276+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_cv.h</locationURI>
277+
</link>
278+
<link>
279+
<name>deps/stk/include/sync/stk_sync_event.h</name>
280+
<type>1</type>
281+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_event.h</locationURI>
282+
</link>
283+
<link>
284+
<name>deps/stk/include/sync/stk_sync_eventflags.h</name>
285+
<type>1</type>
286+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_eventflags.h</locationURI>
287+
</link>
288+
<link>
289+
<name>deps/stk/include/sync/stk_sync_msgqueue.h</name>
290+
<type>1</type>
291+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_msgqueue.h</locationURI>
292+
</link>
293+
<link>
294+
<name>deps/stk/include/sync/stk_sync_mutex.h</name>
295+
<type>1</type>
296+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_mutex.h</locationURI>
297+
</link>
298+
<link>
299+
<name>deps/stk/include/sync/stk_sync_pipe.h</name>
300+
<type>1</type>
301+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_pipe.h</locationURI>
302+
</link>
303+
<link>
304+
<name>deps/stk/include/sync/stk_sync_rwmutex.h</name>
305+
<type>1</type>
306+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_rwmutex.h</locationURI>
307+
</link>
308+
<link>
309+
<name>deps/stk/include/sync/stk_sync_semaphore.h</name>
310+
<type>1</type>
311+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_semaphore.h</locationURI>
312+
</link>
313+
<link>
314+
<name>deps/stk/include/sync/stk_sync_spinlock.h</name>
315+
<type>1</type>
316+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/sync/stk_sync_spinlock.h</locationURI>
317+
</link>
318+
<link>
319+
<name>deps/stk/include/time/README.md</name>
320+
<type>1</type>
321+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/time/README.md</locationURI>
322+
</link>
323+
<link>
324+
<name>deps/stk/include/time/stk_time.h</name>
325+
<type>1</type>
326+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/time/stk_time.h</locationURI>
327+
</link>
328+
<link>
329+
<name>deps/stk/include/time/stk_time_timer.h</name>
330+
<type>1</type>
331+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/time/stk_time_timer.h</locationURI>
332+
</link>
333+
<link>
334+
<name>deps/stk/include/time/stk_time_util.h</name>
335+
<type>1</type>
336+
<locationURI>PARENT-6-PROJECT_LOC/stk/include/time/stk_time_util.h</locationURI>
337+
</link>
228338
<link>
229339
<name>deps/stk/src/arch/arm</name>
230340
<type>2</type>

build/example/project/eclipse/stm/tls-stm32f407g-disc1/src/stk_config.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
#define STK_CONFIG_H_
1212

1313
#include "cmsis_device.h"
14-
#include "core_cm4.h"
1514

16-
// Undefine if MCU is Arm Cortex-M4
15+
// MCU is Arm Cortex-M.
1716
#define _STK_ARCH_ARM_CORTEX_M
1817

19-
// Low-power scenario, use (0) for a high-performance processing when consumed power does not matter
18+
// Low-power scenario, use (0) for a high-performance processing when consumed power does not matter.
2019
#define STK_TICKLESS_IDLE (1)
2120

21+
// Use TLS.
22+
#define STK_TLS (1)
23+
24+
// Use fast inline TLS based on CPU register (-ffixed-r9 compiler flag is used to preserve R9 for TLS).
25+
#define STK_TLS_PREFER_REGISTER (1)
26+
27+
// Override ISR handlers if your BSP are using other names.
2228
#ifdef _STK_ARCH_ARM_CORTEX_M
2329
// Redefine if SysTick handler name is different from SysTick_Handler
2430
//#define STK_SYSTICK_HANDLER SysTick_Handler

0 commit comments

Comments
 (0)