From 83bbc0a6c61cabde630dfb08d69e4d6a29657dd2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 8 May 2008 10:12:19 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@285 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- ports/MSP430/chcore.c | 10 ++++++---- ports/MSP430/chcore.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'ports/MSP430') 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 +#include + #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; \ } -- cgit v1.2.3