37 #ifdef __IAR_SYSTEMS_ICC__
41 static unsigned short *sptmp;
42 static struct mtarch_thread *running;
55 ((void (*)(
void *))running->function)((
void*)running->data);
60 void (*
function)(
void *),
void *data)
64 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
68 t->sp = &t->stack[MTARCH_STACKSIZE - 1];
70 *t->sp = (
unsigned short)
mt_exit;
73 *t->sp = (
unsigned short)mtarch_wrapper;
81 t->function =
function;
104 #ifdef __IAR_SYSTEMS_ICC__
106 running->sp = (
unsigned short *) __get_SP_register();
107 __set_SP_register((
unsigned short) sptmp);
109 __asm__(
"mov.w r1,%0" :
"=r" (running->sp));
110 __asm__(
"mov.w %0,r1" : :
"m" (sptmp));
166 mtarch_stack_usage(
struct mt_thread *t)
170 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
171 if(t->thread.stack[i] != (
unsigned short)i) {
172 return MTARCH_STACKSIZE - i;
176 return MTARCH_STACKSIZE;