diff options
author | inmarket <andrewh@inmarket.com.au> | 2016-12-06 13:47:33 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2016-12-06 13:47:33 +1000 |
commit | ad29f4fee01af58b69d5e0d3b379600c6beba119 (patch) | |
tree | a725a597f4dbe3b07a31d595d388884c5226cfe3 /src/gos/gos_x_threads_cortexm47fp.h | |
parent | c1e2863078baaa0afbfbd31af5cc9f9978778dda (diff) | |
download | uGFX-ad29f4fee01af58b69d5e0d3b379600c6beba119.tar.gz uGFX-ad29f4fee01af58b69d5e0d3b379600c6beba119.tar.bz2 uGFX-ad29f4fee01af58b69d5e0d3b379600c6beba119.zip |
Support for Keil compiler RAW32 CPU specific task switching for Cortex M0,1,3,4,7
Diffstat (limited to 'src/gos/gos_x_threads_cortexm47fp.h')
-rw-r--r-- | src/gos/gos_x_threads_cortexm47fp.h | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/gos/gos_x_threads_cortexm47fp.h b/src/gos/gos_x_threads_cortexm47fp.h index 0d4d0d89..2fc15d3c 100644 --- a/src/gos/gos_x_threads_cortexm47fp.h +++ b/src/gos/gos_x_threads_cortexm47fp.h @@ -48,30 +48,42 @@ #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC - static /*__arm*/ void _gfxTaskSwitch(thread *oldt, thread *newt) { -/* push {r4, r5, r6, r7, r8, r9, r10, r11, lr} + static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) { + // Save the old context + push {r4, r5, r6, r7, r8, r9, r10, r11, lr} vpush {s16-s31} - str sp, %[oldtcxt] - ldr sp, %[newtcxt] + str sp, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt + + // Load the new context + ldr sp, [r1,#__cpp(offsetof(thread,cxt))] // newt->cxt vpop {s16-s31} pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} - : [newtcxt] "=m" (newt->cxt) - : [oldtcxt] "m" (oldt->cxt) - : "memory"); -*/ } + } - static /* __arm */ void _gfxStartThread(thread *oldt, thread *newt) { - newt->cxt = (char *)newt + newt->size; -/* push {r4, r5, r6, r7, r8, r9, r10, r11, lr} + static __asm void _gfxStartThread(thread *oldt, thread *newt) { + // Calculate where to generate the new context + // newt->cxt = (char *)newt + newt->size; + ldr r2,[r1,#__cpp(offsetof(thread,size))] + add r2,r2,r1 + str r2,[r1,#__cpp(offsetof(thread,cxt))] + + // Save the old context + push {r4, r5, r6, r7, r8, r9, r10, r11, lr} vpush {s16-s31} - str sp, %[oldtcxt] - ldr sp, %[newtcxt] - : [newtcxt] "=m" (newt->cxt) - : [oldtcxt] "m" (oldt->cxt) - : "memory"); -*/ - // Run the users function - gfxThreadExit(current->fn(current->param)); + str sp, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt + + // Load the new (imcomplete) context + ldr sp, [r1,#__cpp(offsetof(thread,cxt))] // newt->cxt + + // Run the users function - we save some code because gfxThreadExit() never returns + // gfxThreadExit(current->fn(current->param)); + LDR r2,__cpp(&_gfxCurrentThread) + LDR r2,[r2,#0] + LDR r0,[r2,#__cpp(offsetof(thread,param))] + LDR r1,[r2,#__cpp(offsetof(thread,fn))] + BLX r1 + MOV r4,r0 + BL gfxThreadExit } #else |