15 #if GFX_COMPILER == GFX_COMPILER_GCC || GFX_COMPILER == GFX_COMPILER_CYGWIN || GFX_COMPILER == GFX_COMPILER_MINGW32 || GFX_COMPILER == GFX_COMPILER_MINGW64
16 #define GFX_THREADS_DONE
17 #define _gfxThreadsInit()
19 static __attribute__((pcs(
"aapcs-vfp"),naked))
void _gfxTaskSwitch(thread *oldt, thread *newt) {
20 __asm__
volatile (
"push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
21 "vpush {s16-s31} \n\t"
22 "str sp, %[oldtcxt] \n\t"
23 "ldr sp, %[newtcxt] \n\t"
25 "pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} \n\t"
26 : [newtcxt]
"=m" (newt->cxt)
27 : [oldtcxt]
"m" (oldt->cxt)
31 static __attribute__((pcs(
"aapcs-vfp"),naked))
void _gfxStartThread(thread *oldt, thread *newt) {
32 newt->cxt = (
void *)(((
unsigned)newt + newt->size) & ~7);
33 __asm__
volatile (
"push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
34 "vpush {s16-s31} \n\t"
35 "str sp, %[oldtcxt] \n\t"
36 "ldr sp, %[newtcxt] \n\t"
37 : [newtcxt]
"=m" (newt->cxt)
38 : [oldtcxt]
"m" (oldt->cxt)
42 gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param));
45 #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC
46 #define GFX_THREADS_DONE
47 #define _gfxThreadsInit()
49 static __asm
void _gfxTaskSwitch(thread *oldt, thread *newt) {
53 push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
55 str sp, [r0,#__cpp(offsetof(thread,cxt))]
58 ldr sp, [r1,#__cpp(offsetof(thread,cxt))]
60 pop {r4, r5, r6, r7, r8, r9, r10, r11, pc}
63 static __asm
void _gfxStartThread(thread *oldt, thread *newt) {
68 ldr r2,[r1,#__cpp(offsetof(thread,size))]
70 and r2, r2, #0xFFFFFFF8
71 str r2,[r1,#__cpp(offsetof(thread,cxt))]
74 push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
76 str sp, [r0,#__cpp(offsetof(thread,cxt))]
79 ldr sp, [r1,#__cpp(offsetof(thread,cxt))]
83 ldr r2,=__cpp(&_gfxCurrentThread)
85 ldr r0,[r2,#__cpp(offsetof(thread,param))]
86 ldr r1,[r2,#__cpp(offsetof(thread,fn))]
89 bl __cpp(gfxThreadExit)
95 #if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
96 #warning "GOS Threads: You have specified a specific CPU but your compiler is not supported. Defaulting to CLIB switching"
97 #elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
98 COMPILER_WARNING(
"GOS Threads: You have specified a specific CPU but your compiler is not supported. Defaulting to CLIB switching")