diff options
-rw-r--r-- | demos/ARMCM3-STM32F103-GCC/Makefile | 4 | ||||
-rw-r--r-- | ports/ARMCM3/chcore.c | 8 | ||||
-rw-r--r-- | 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 @@ -39,14 +39,6 @@ void chSysPuts(char *msg) { }
/*
- * Context switch.
- */
-void chSysSwitchI(Thread *otp, Thread *ntp) {
-
- asm volatile ("svc #0");
-}
-
-/*
* System halt.
*/
__attribute__((naked, weak))
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);
|