16 #if defined(CORTEX_USE_FPU) && CORTEX_USE_FPU
17 #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
18 #warning "GOS Threads: You have specified GFX_CPU=GFX_CPU_CORTX_M? with no hardware floating point support but CORTEX_USE_FPU is GFXON. Try using GFX_CPU_GFX_CPU_CORTEX_M?_FP instead"
19 #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
20 COMPILER_WARNING(
"GOS Threads: You have specified GFX_CPU=GFX_CPU_CORTX_M? with no hardware floating point support but CORTEX_USE_FPU is GFXON. Try using GFX_CPU_GFX_CPU_CORTEX_M?_FP instead")
24 #if GFX_COMPILER == GFX_COMPILER_GCC || GFX_COMPILER == GFX_COMPILER_CYGWIN || GFX_COMPILER == GFX_COMPILER_MINGW32 || GFX_COMPILER == GFX_COMPILER_MINGW64
25 #define GFX_THREADS_DONE
26 #define _gfxThreadsInit()
28 static __attribute__((pcs(
"aapcs"),naked))
void _gfxTaskSwitch(thread *oldt, thread *newt) {
29 __asm__
volatile (
"push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
30 "str sp, %[oldtcxt] \n\t"
31 "ldr sp, %[newtcxt] \n\t"
32 "pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} \n\t"
33 : [newtcxt]
"=m" (newt->cxt)
34 : [oldtcxt]
"m" (oldt->cxt)
38 static __attribute__((pcs(
"aapcs"),naked))
void _gfxStartThread(thread *oldt, thread *newt) {
39 newt->cxt = (
void *)(((
unsigned)newt + newt->size) & ~7);
40 __asm__
volatile (
"push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
41 "str sp, %[oldtcxt] \n\t"
42 "ldr sp, %[newtcxt] \n\t"
43 : [newtcxt]
"=m" (newt->cxt)
44 : [oldtcxt]
"m" (oldt->cxt)
48 gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param));
51 #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC
52 #define GFX_THREADS_DONE
53 #define _gfxThreadsInit()
55 static __asm
void _gfxTaskSwitch(thread *oldt, thread *newt) {
59 push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
60 str sp, [r0,#__cpp(offsetof(thread,cxt))]
63 ldr sp, [r1,#__cpp(offsetof(thread,cxt))]
64 pop {r4, r5, r6, r7, r8, r9, r10, r11, pc}
67 static __asm
void _gfxStartThread(thread *oldt, thread *newt) {
72 ldr r2,[r1,#__cpp(offsetof(thread,size))]
74 and r2, r2, #0xFFFFFFF8
75 str r2,[r1,#__cpp(offsetof(thread,cxt))]
78 push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
79 str sp, [r0,#__cpp(offsetof(thread,cxt))]
82 ldr sp, [r1,#__cpp(offsetof(thread,cxt))]
86 ldr r2,=__cpp(&_gfxCurrentThread)
88 ldr r0,[r2,#__cpp(offsetof(thread,param))]
89 ldr r1,[r2,#__cpp(offsetof(thread,fn))]
92 bl __cpp(gfxThreadExit)
98 #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
99 #warning "GOS Threads: You have specified a specific CPU but your compiler is not supported. Defaulting to CLIB switching"
100 #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
101 COMPILER_WARNING(
"GOS Threads: You have specified a specific CPU but your compiler is not supported. Defaulting to CLIB switching")