From f563ad9387e132cece6634811a89aa450c60a176 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Apr 2008 13:27:05 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@271 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-GCC/Makefile | 4 ++-- ports/ARMCM3/chcore.c | 8 -------- ports/ARMCM3/chcore.h | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/demos/ARMCM3-STM32F103-GCC/Makefile b/demos/ARMCM3-STM32F103-GCC/Makefile index 4cb6c7a4a..465e405b2 100644 --- a/demos/ARMCM3-STM32F103-GCC/Makefile +++ b/demos/ARMCM3-STM32F103-GCC/Makefile @@ -89,9 +89,9 @@ ULIBS = # chconf.h. # NOTE: -falign-functions=16 may improve the performance, not always, but # increases the code size. -OPT = -O2 -ggdb -fomit-frame-pointer +OPT = -O2 -ggdb -fomit-frame-pointer -mabi=apcs-gnu #OPT += -ffixed-r7 -#OPT += -falign-functions=16 +OPT += -falign-functions=16 # Define warning options here WARN = -Wall -Wstrict-prototypes diff --git a/ports/ARMCM3/chcore.c b/ports/ARMCM3/chcore.c index bf0cdc0d9..8c4c74315 100644 --- a/ports/ARMCM3/chcore.c +++ b/ports/ARMCM3/chcore.c @@ -38,14 +38,6 @@ __attribute__((weak)) void chSysPuts(char *msg) { } -/* - * Context switch. - */ -void chSysSwitchI(Thread *otp, Thread *ntp) { - - asm volatile ("svc #0"); -} - /* * System halt. */ diff --git a/ports/ARMCM3/chcore.h b/ports/ARMCM3/chcore.h index 6c80fdc09..5b9a0915b 100644 --- a/ports/ARMCM3/chcore.h +++ b/ports/ARMCM3/chcore.h @@ -78,16 +78,19 @@ typedef struct { } #define chSysLock() { \ - asm volatile ("push {r3}"); \ - asm volatile ("movs r3, #0x10"); \ - asm volatile ("msr BASEPRI, r3"); \ - asm volatile ("pop {r3}"); \ + register uint32_t tmp asm ("r3"); \ + asm volatile ("movs %0, #0x10" : "=r" (tmp): ); \ + asm volatile ("msr BASEPRI, %0" : : "r" (tmp)); \ } #define chSysUnlock() { \ - asm volatile ("push {r3}"); \ - asm volatile ("movs r3, #0"); \ - asm volatile ("msr BASEPRI, r3"); \ - asm volatile ("pop {r3}"); \ + register uint32_t tmp asm ("r3"); \ + asm volatile ("movs %0, #0" : "=r" (tmp): ); \ + asm volatile ("msr BASEPRI, %0" : : "r" (tmp)); \ +} +#define chSysSwitchI(otp, ntp) { \ + register Thread *_otp asm ("r0") = (otp); \ + register Thread *_ntp asm ("r1") = (ntp); \ + asm volatile ("svc #0" : : "r" (_otp), "r" (_ntp)); \ } #define INT_REQUIRED_STACK 0 @@ -109,7 +112,6 @@ typedef struct { void _IdleThread(void *p) __attribute__((noreturn)); void chSysHalt(void); -void chSysSwitchI(Thread *otp, Thread *ntp); void chSysPuts(char *msg); void threadstart(void); -- cgit v1.2.3