Compare commits

...

3 Commits

Author SHA1 Message Date
inmarket 4b502c0178 Fix Cortex m0 Raw32 scheduler.
Ensure 8 byte alignment of the stack for all ARM specific scheduler code.
2016-12-30 18:58:15 +10:00
inmarket 1d5d889529 Updates to Keil RAW32 CPU specific scheduler.
Tested working on CortexM7 and CortexM7 with FP.
2016-12-23 08:57:01 +10:00
Joel Bodenmann 8d760acc0c Removing obsolete color parameters from gwinFillDualCircle()
Fixes T27
2016-12-15 11:34:01 +01:00
5 changed files with 54 additions and 25 deletions

View File

@ -27,8 +27,10 @@
"mov r6, r10 \n\t" "mov r6, r10 \n\t"
"mov r7, r11 \n\t" "mov r7, r11 \n\t"
"push {r4, r5, r6, r7} \n\t" "push {r4, r5, r6, r7} \n\t"
"str sp, %[oldtcxt] \n\t" "mov r4, sp \n\t"
"ldr sp, %[newtcxt] \n\t" "str r4, %[oldtcxt] \n\t"
"ldr r4, %[newtcxt] \n\t"
"mov sp, r4 \n\t"
"pop {r4, r5, r6, r7} \n\t" "pop {r4, r5, r6, r7} \n\t"
"mov r8, r4 \n\t" "mov r8, r4 \n\t"
"mov r9, r5 \n\t" "mov r9, r5 \n\t"
@ -41,15 +43,17 @@
} }
static __attribute__((pcs("aapcs"),naked)) void _gfxStartThread(thread *oldt, thread *newt) { 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, lr} \n\t" __asm__ volatile ( "push {r4, r5, r6, r7, lr} \n\t"
"mov r4, r8 \n\t" "mov r4, r8 \n\t"
"mov r5, r9 \n\t" "mov r5, r9 \n\t"
"mov r6, r10 \n\t" "mov r6, r10 \n\t"
"mov r7, r11 \n\t" "mov r7, r11 \n\t"
"push {r4, r5, r6, r7} \n\t" "push {r4, r5, r6, r7} \n\t"
"str sp, %[oldtcxt] \n\t" "mov r4, sp \n\t"
"ldr sp, %[newtcxt] \n\t" "str r4, %[oldtcxt] \n\t"
"ldr r4, %[newtcxt] \n\t"
"mov sp, r4 \n\t"
: [newtcxt] "=m" (newt->cxt) : [newtcxt] "=m" (newt->cxt)
: [oldtcxt] "m" (oldt->cxt) : [oldtcxt] "m" (oldt->cxt)
: "memory"); : "memory");
@ -59,8 +63,12 @@
} }
#elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC
#define GFX_THREADS_DONE
#define _gfxThreadsInit()
static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) { static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) {
PRESERVE8
// Save the old context // Save the old context
push {r4, r5, r6, r7, lr} push {r4, r5, r6, r7, lr}
mov r4, r8 mov r4, r8
@ -68,10 +76,12 @@
mov r6, r10 mov r6, r10
mov r7, r11 mov r7, r11
push {r4, r5, r6, r7} push {r4, r5, r6, r7}
str sp, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt mov r4, sp
str r4, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt
// Load the new context // Load the new context
ldr sp, [r1,#__cpp(offsetof(thread,cxt))] // newt->cxt ldr r4, [r1,#__cpp(offsetof(thread,cxt))] // newt->cxt
mov sp, r4
pop {r4, r5, r6, r7} pop {r4, r5, r6, r7}
mov r8, r4 mov r8, r4
mov r9, r5 mov r9, r5
@ -81,10 +91,13 @@
} }
static __asm void _gfxStartThread(thread *oldt, thread *newt) { static __asm void _gfxStartThread(thread *oldt, thread *newt) {
PRESERVE8
// Calculate where to generate the new context // 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))] ldr r2,[r1,#__cpp(offsetof(thread,size))]
add r2,r2,r1 add r2,r2,r1
and r2, r2, #0xFFFFFFF8
str r2,[r1,#__cpp(offsetof(thread,cxt))] str r2,[r1,#__cpp(offsetof(thread,cxt))]
// Save the old context // Save the old context
@ -94,20 +107,24 @@
mov r6, r10 mov r6, r10
mov r7, r11 mov r7, r11
push {r4, r5, r6, r7} push {r4, r5, r6, r7}
str sp, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt mov r4, sp
str r4, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt
// Load the new (imcomplete) context // Load the new (imcomplete) context
ldr sp, [r1,#__cpp(offsetof(thread,cxt))] // newt->cxt ldr r4, [r1,#__cpp(offsetof(thread,cxt))] // newt->cxt
mov sp, r4
// Run the users function - we save some code because gfxThreadExit() never returns // Run the users function - we save some code because gfxThreadExit() never returns
// gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param)); // gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param));
ldr r2,__cpp(&_gfxCurrentThread) ldr r2,=__cpp(&_gfxCurrentThread)
ldr r2,[r2,#0] ldr r2,[r2,#0]
ldr r0,[r2,#__cpp(offsetof(thread,param))] ldr r0,[r2,#__cpp(offsetof(thread,param))]
ldr r1,[r2,#__cpp(offsetof(thread,fn))] ldr r1,[r2,#__cpp(offsetof(thread,fn))]
blx r1 blx r1
mov r4,r0 mov r4,r0
bl __cpp(gfxThreadExit) bl __cpp(gfxThreadExit)
ALIGN
} }
#else #else

View File

@ -32,7 +32,7 @@
} }
static __attribute__((pcs("aapcs"),naked)) void _gfxStartThread(thread *oldt, thread *newt) { 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" __asm__ volatile ( "push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
"str sp, %[oldtcxt] \n\t" "str sp, %[oldtcxt] \n\t"
"ldr sp, %[newtcxt] \n\t" "ldr sp, %[newtcxt] \n\t"
@ -45,8 +45,12 @@
} }
#elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC
#define GFX_THREADS_DONE
#define _gfxThreadsInit()
static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) { static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) {
PRESERVE8
// Save the old context // Save the old context
push {r4, r5, r6, r7, r8, r9, r10, r11, lr} push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
str sp, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt str sp, [r0,#__cpp(offsetof(thread,cxt))] // oldt->cxt
@ -57,10 +61,13 @@
} }
static __asm void _gfxStartThread(thread *oldt, thread *newt) { static __asm void _gfxStartThread(thread *oldt, thread *newt) {
PRESERVE8
// Calculate where to generate the new context // 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))] ldr r2,[r1,#__cpp(offsetof(thread,size))]
add r2,r2,r1 add r2,r2,r1
and r2, r2, #0xFFFFFFF8
str r2,[r1,#__cpp(offsetof(thread,cxt))] str r2,[r1,#__cpp(offsetof(thread,cxt))]
// Save the old context // Save the old context
@ -72,13 +79,15 @@
// Run the users function - we save some code because gfxThreadExit() never returns // Run the users function - we save some code because gfxThreadExit() never returns
// gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param)); // gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param));
ldr r2,__cpp(&_gfxCurrentThread) ldr r2,=__cpp(&_gfxCurrentThread)
ldr r2,[r2,#0] ldr r2,[r2,#0]
ldr r0,[r2,#__cpp(offsetof(thread,param))] ldr r0,[r2,#__cpp(offsetof(thread,param))]
ldr r1,[r2,#__cpp(offsetof(thread,fn))] ldr r1,[r2,#__cpp(offsetof(thread,fn))]
blx r1 blx r1
mov r4,r0 mov r4,r0
bl __cpp(gfxThreadExit) bl __cpp(gfxThreadExit)
ALIGN
} }
#else #else

View File

@ -12,10 +12,6 @@
* The context is saved at the current stack location and a pointer is maintained in the thread structure. * The context is saved at the current stack location and a pointer is maintained in the thread structure.
*/ */
#if !CORTEX_USE_FPU
#warning "GOS Threads: You have specified GFX_CPU=GFX_CPU_CORTX_M?_FP with hardware floating point support but CORTEX_USE_FPU is FALSE. Try using GFX_CPU_GFX_CPU_CORTEX_M? instead"
#endif
#if GFX_COMPILER == GFX_COMPILER_GCC || GFX_COMPILER == GFX_COMPILER_CYGWIN || GFX_COMPILER == GFX_COMPILER_MINGW32 || GFX_COMPILER == GFX_COMPILER_MINGW64 #if GFX_COMPILER == GFX_COMPILER_GCC || GFX_COMPILER == GFX_COMPILER_CYGWIN || GFX_COMPILER == GFX_COMPILER_MINGW32 || GFX_COMPILER == GFX_COMPILER_MINGW64
#define GFX_THREADS_DONE #define GFX_THREADS_DONE
#define _gfxThreadsInit() #define _gfxThreadsInit()
@ -33,7 +29,7 @@
} }
static __attribute__((pcs("aapcs-vfp"),naked)) void _gfxStartThread(thread *oldt, thread *newt) { static __attribute__((pcs("aapcs-vfp"),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" __asm__ volatile ( "push {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t"
"vpush {s16-s31} \n\t" "vpush {s16-s31} \n\t"
"str sp, %[oldtcxt] \n\t" "str sp, %[oldtcxt] \n\t"
@ -47,8 +43,12 @@
} }
#elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC #elif GFX_COMPILER == GFX_COMPILER_KEIL || GFX_COMPILER == GFX_COMPILER_ARMCC
#define GFX_THREADS_DONE
#define _gfxThreadsInit()
static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) { static __asm void _gfxTaskSwitch(thread *oldt, thread *newt) {
PRESERVE8
// Save the old context // Save the old context
push {r4, r5, r6, r7, r8, r9, r10, r11, lr} push {r4, r5, r6, r7, r8, r9, r10, r11, lr}
vpush {s16-s31} vpush {s16-s31}
@ -61,10 +61,13 @@
} }
static __asm void _gfxStartThread(thread *oldt, thread *newt) { static __asm void _gfxStartThread(thread *oldt, thread *newt) {
PRESERVE8
// Calculate where to generate the new context // 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))] ldr r2,[r1,#__cpp(offsetof(thread,size))]
add r2,r2,r1 add r2,r2,r1
and r2, r2, #0xFFFFFFF8
str r2,[r1,#__cpp(offsetof(thread,cxt))] str r2,[r1,#__cpp(offsetof(thread,cxt))]
// Save the old context // Save the old context
@ -77,13 +80,15 @@
// Run the users function - we save some code because gfxThreadExit() never returns // Run the users function - we save some code because gfxThreadExit() never returns
// gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param)); // gfxThreadExit(_gfxCurrentThread->fn(_gfxCurrentThread->param));
ldr r2,__cpp(&_gfxCurrentThread) ldr r2,=__cpp(&_gfxCurrentThread)
ldr r2,[r2,#0] ldr r2,[r2,#0]
ldr r0,[r2,#__cpp(offsetof(thread,param))] ldr r0,[r2,#__cpp(offsetof(thread,param))]
ldr r1,[r2,#__cpp(offsetof(thread,fn))] ldr r1,[r2,#__cpp(offsetof(thread,fn))]
blx r1 blx r1
mov r4,r0 mov r4,r0
bl __cpp(gfxThreadExit) bl __cpp(gfxThreadExit)
ALIGN
} }
#else #else

View File

@ -282,7 +282,7 @@ void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coor
#endif #endif
#if GDISP_NEED_DUALCIRCLE #if GDISP_NEED_DUALCIRCLE
void gwinFillDualCircle(GHandle gh, coord_t x, coord_t y, coord_t radius1, color_t color1, coord_t radius2, color_t color2) { void gwinFillDualCircle(GHandle gh, coord_t x, coord_t y, coord_t radius1, coord_t radius2) {
if (!_gwinDrawStart(gh)) return; if (!_gwinDrawStart(gh)) return;
gdispGFillDualCircle(gh->display, gh->x+x, gh->y+y, radius1, gh->bgcolor, radius2, gh->color); gdispGFillDualCircle(gh->display, gh->x+x, gh->y+y, radius1, gh->bgcolor, radius2, gh->color);
_gwinDrawEnd(gh); _gwinDrawEnd(gh);

View File

@ -729,13 +729,11 @@ extern "C" {
* @param[in] gh The window handle * @param[in] gh The window handle
* @param[in] x,y The center of the circle * @param[in] x,y The center of the circle
* @param[in] radius1 The radius of the larger circle * @param[in] radius1 The radius of the larger circle
* @param[in] color1 The color to use for the larger circle
* @param[in] radius2 The radius of the smaller circle * @param[in] radius2 The radius of the smaller circle
* @param[in] color2 The color to use for the smaller circle
* *
* @api * @api
*/ */
void gwinFillDualCircle(GHandle gh, coord_t x, coord_t y, coord_t radius1, color_t color1, coord_t radius2, color_t color2); void gwinFillDualCircle(GHandle gh, coord_t x, coord_t y, coord_t radius1, coord_t radius2);
#endif #endif
#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__) #if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)