aboutsummaryrefslogtreecommitdiffstats
path: root/ports/MSP430
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-05-08 10:12:19 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-05-08 10:12:19 +0000
commit83bbc0a6c61cabde630dfb08d69e4d6a29657dd2 (patch)
treead26357e5eddcf25bc13ec486983f4c94c56e4bb /ports/MSP430
parent3f9aac327ba999d67f9501ebf590d171e496b448 (diff)
downloadChibiOS-83bbc0a6c61cabde630dfb08d69e4d6a29657dd2.tar.gz
ChibiOS-83bbc0a6c61cabde630dfb08d69e4d6a29657dd2.tar.bz2
ChibiOS-83bbc0a6c61cabde630dfb08d69e4d6a29657dd2.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@285 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports/MSP430')
-rw-r--r--ports/MSP430/chcore.c10
-rw-r--r--ports/MSP430/chcore.h5
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; \
}