aboutsummaryrefslogtreecommitdiffstats
path: root/src/gos/gos_x_threads_cortexm347.h
diff options
context:
space:
mode:
authorinmarket <inmarket@ugfx.org>2016-12-30 18:57:09 +1000
committerinmarket <inmarket@ugfx.org>2016-12-30 18:57:09 +1000
commit6a30927a91497bc301a35c6260601eaf97cc9a76 (patch)
tree26f22baf314b028c6ecd203c5f84a15118154bec /src/gos/gos_x_threads_cortexm347.h
parent06de6f193132a61dbb5e9b8f9a37e56929f7643b (diff)
downloaduGFX-6a30927a91497bc301a35c6260601eaf97cc9a76.tar.gz
uGFX-6a30927a91497bc301a35c6260601eaf97cc9a76.tar.bz2
uGFX-6a30927a91497bc301a35c6260601eaf97cc9a76.zip
Fix Cortex m0 Raw32 scheduler.
Ensure 8 byte alignment of the stack for all ARM specific scheduler code.
Diffstat (limited to 'src/gos/gos_x_threads_cortexm347.h')
-rw-r--r--src/gos/gos_x_threads_cortexm347.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gos/gos_x_threads_cortexm347.h b/src/gos/gos_x_threads_cortexm347.h
index 5248508e..40d30138 100644
--- a/src/gos/gos_x_threads_cortexm347.h
+++ b/src/gos/gos_x_threads_cortexm347.h
@@ -32,7 +32,7 @@
}
static __attribute__((pcs("aapcs"),naked)) void _gfxStartThread(thread *oldt, thread *newt) {
- newt->cxt = (char *)newt + newt->size;
+ newt->cxt = (void *)(((unsigned)newt + newt->size) & ~7);
__asm__ volatile ( "push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
"str sp, %[oldtcxt] \n\t"
"ldr sp, %[newtcxt] \n\t"
@@ -64,9 +64,10 @@
PRESERVE8
// Calculate where to generate the new context
- // newt->cxt = (char *)newt + newt->size;
+ // newt->cxt = (void *)(((unsigned)newt + newt->size) & ~7);
ldr r2,[r1,#__cpp(offsetof(thread,size))]
add r2,r2,r1
+ and r2, r2, #0xFFFFFFF8
str r2,[r1,#__cpp(offsetof(thread,cxt))]
// Save the old context