diff --git a/cpu/msp430/mtarch.c b/cpu/msp430/mtarch.c index 3bbafc829..0a184ab2f 100644 --- a/cpu/msp430/mtarch.c +++ b/cpu/msp430/mtarch.c @@ -28,18 +28,27 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: mtarch.c,v 1.5 2008/08/27 13:10:29 fros4943 Exp $ + * @(#)$Id: mtarch.c,v 1.6 2008/11/21 10:28:32 fros4943 Exp $ */ #include #include "sys/mt.h" +static unsigned short *sptmp; +static struct mtarch_thread *running; /*--------------------------------------------------------------------------*/ void mtarch_init(void) { +} +/*--------------------------------------------------------------------------*/ +static void +mtarch_wrapper(void) +{ + /* Call thread function with argument */ + ((void (*)(void *))running->function)((void*)running->data); } /*--------------------------------------------------------------------------*/ void @@ -57,15 +66,17 @@ mtarch_start(struct mtarch_thread *t, *t->sp = (unsigned short)mt_exit; --t->sp; - *t->sp = (unsigned short)function; + *t->sp = (unsigned short)mtarch_wrapper; --t->sp; /* Space for registers. */ t->sp -= 11; + + /* Store function and argument (used in mtarch_wrapper) */ + t->data = data; + t->function = function; } /*--------------------------------------------------------------------------*/ -static unsigned short *sptmp; -static struct mtarch_thread *running; static void sw(void) diff --git a/cpu/msp430/mtarch.h b/cpu/msp430/mtarch.h index 13d34b22c..fd9cc9557 100644 --- a/cpu/msp430/mtarch.h +++ b/cpu/msp430/mtarch.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: mtarch.h,v 1.2 2006/09/26 20:56:56 adamdunkels Exp $ + * @(#)$Id: mtarch.h,v 1.3 2008/11/21 10:28:32 fros4943 Exp $ */ #ifndef __MTARCH_H__ #define __MTARCH_H__ @@ -38,6 +38,8 @@ struct mtarch_thread { unsigned short stack[MTARCH_STACKSIZE]; unsigned short *sp; + void *data; + void *function; }; struct mt_thread; @@ -46,4 +48,4 @@ int mtarch_stack_usage(struct mt_thread *t); #endif /* __MTARCH_H__ */ - +