diff options
Diffstat (limited to 'ports/MSP430')
-rw-r--r-- | ports/MSP430/chcore.c | 10 | ||||
-rw-r--r-- | ports/MSP430/chcore.h | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/ports/MSP430/chcore.c b/ports/MSP430/chcore.c index 86765c675..b87953ef0 100644 --- a/ports/MSP430/chcore.c +++ b/ports/MSP430/chcore.c @@ -46,10 +46,12 @@ void chSysHalt(void) { /**
* Context switch.
*/
+__attribute__((naked))
void chSysSwitchI(Thread *otp, Thread *ntp) {
register struct intctx *sp asm("r1");
- asm volatile ("push r11 \n\t" \
+ asm volatile ("push r2 \n\t" \
+ "push r11 \n\t" \
"push r10 \n\t" \
"push r9 \n\t" \
"push r8 \n\t" \
@@ -66,7 +68,8 @@ void chSysSwitchI(Thread *otp, Thread *ntp) { "pop r8 \n\t" \
"pop r9 \n\t" \
"pop r10 \n\t" \
- "pop r11" : : "r" (sp));
+ "pop r11 \n\t" \
+ "reti" : : "r" (sp));
}
/**
@@ -77,8 +80,7 @@ void chSysPuts(char *msg) { void threadstart(void) {
- asm volatile ("eint \n\t" \
- "mov r11, r15 \n\t" \
+ asm volatile ("mov r11, r15 \n\t" \
"call r10 \n\t" \
"call #chThdExit");
}
diff --git a/ports/MSP430/chcore.h b/ports/MSP430/chcore.h index b6991baa2..3a9d587b8 100644 --- a/ports/MSP430/chcore.h +++ b/ports/MSP430/chcore.h @@ -20,6 +20,9 @@ #ifndef _CHCORE_H_
#define _CHCORE_H_
+#include <iomacros.h>
+#include <msp430/common.h>
+
#define CH_ARCHITECTURE_MSP430
typedef void *regmsp;
@@ -48,6 +51,7 @@ struct intctx { regmsp r9;
regmsp r10;
regmsp r11;
+ regmsp sr;
regmsp pc;
};
@@ -61,6 +65,7 @@ typedef struct { sizeof(struct intctx)); \
tp->p_ctx.sp->r10 = pf; \
tp->p_ctx.sp->r11 = arg; \
+ tp->p_ctx.sp->sr = (regmsp)GIE; \
tp->p_ctx.sp->pc = threadstart; \
}
|