15 #if defined(CORTEX_USE_FPU) && CORTEX_USE_FPU
16 #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
17 #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"
18 #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
19 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")
23 #if GFX_COMPILER == GFX_COMPILER_GCC || GFX_COMPILER == GFX_COMPILER_CYGWIN || GFX_COMPILER == GFX_COMPILER_MINGW32 || GFX_COMPILER == GFX_COMPILER_MINGW64
24 #define GFX_THREADS_DONE
25 #define _gfxThreadsInit()
27 static __attribute__((pcs(
"aapcs"),naked))
void _gfxTaskSwitch(thread *oldt, thread *newt) {
28 __asm__
volatile (
"push {r4, r5, r6, r7, lr} \n\t"
33 "push {r4, r5, r6, r7} \n\t"
35 "str r4, %[oldtcxt] \n\t"
36 "ldr r4, %[newtcxt] \n\t"
38 "pop {r4, r5, r6, r7} \n\t"
43 "pop {r4, r5, r6, r7, pc} \n\t"
44 : [newtcxt]
"=m" (newt->cxt)
45 : [oldtcxt]
"m" (oldt->cxt)
49 static __attribute__((pcs(
"aapcs"),naked))
void _gfxStartThread(thread *oldt, thread *newt) {
50 newt->cxt = (
void *)(((
unsigned)newt + newt->size) & ~7);
51 __asm__
volatile (
"push {r4, r5, r6, r7, lr} \n\t"
56 "push {r4, r5, r6, r7} \n\t"
58 "str r4, %[oldtcxt] \n\t"
59 "ldr r4, %[newtcxt] \n\t"
61 : [newtcxt]
"=m" (newt->cxt)
62 : [oldtcxt]
"m" (oldt->cxt)
66 gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param));
69 #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC
70 #define GFX_THREADS_DONE
71 #define _gfxThreadsInit()
73 static __asm
void _gfxTaskSwitch(thread *oldt, thread *newt) {
77 push {r4, r5, r6, r7, lr}
84 str r4, [r0,#__cpp(offsetof(thread,cxt))]
87 ldr r4, [r1,#__cpp(offsetof(thread,cxt))]
94 pop {r4, r5, r6, r7, pc}
97 static __asm
void _gfxStartThread(thread *oldt, thread *newt) {
102 ldr r2,[r1,#__cpp(offsetof(thread,size))]
104 and r2, r2, #0xFFFFFFF8
105 str r2,[r1,#__cpp(offsetof(thread,cxt))]
108 push {r4, r5, r6, r7, lr}
113 push {r4, r5, r6, r7}
115 str r4, [r0,#__cpp(offsetof(thread,cxt))]
118 ldr r4, [r1,#__cpp(offsetof(thread,cxt))]
123 ldr r2,=__cpp(&_gfxCurrentThread)
125 ldr r0,[r2,#__cpp(offsetof(thread,param))]
126 ldr r1,[r2,#__cpp(offsetof(thread,fn))]
129 bl __cpp(gfxThreadExit)
135 #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
136 #warning "GOS Threads: You have specified a specific CPU but your compiler is not supported. Defaulting to CLIB switching"
137 #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
138 COMPILER_WARNING(
"GOS Threads: You have specified a specific CPU but your compiler is not supported. Defaulting to CLIB switching")