39 #include <avr/interrupt.h>
42 #include "dev/rs232.h"
53 void (*
function)(
void *),
void *data)
59 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
77 t->stack[MTARCH_STACKSIZE - 1] = (
unsigned char)((
unsigned short)
mt_exit) & 0xff;
78 t->stack[MTARCH_STACKSIZE - 2] = (
unsigned char)((
unsigned short)
mt_exit >> 8) & 0xff;
81 t->stack[MTARCH_STACKSIZE - 3] = (
unsigned char)((
unsigned short)
function) & 0xff;
82 t->stack[MTARCH_STACKSIZE - 4] = (
unsigned char)((
unsigned short)
function >> 8) & 0xff;
90 t->stack[MTARCH_STACKSIZE - 29] = (
unsigned char)((
unsigned short)data) & 0xff;
91 t->stack[MTARCH_STACKSIZE - 30] = (
unsigned char)((
unsigned short)data >> 8) & 0xff;
95 t->sp = &t->stack[MTARCH_STACKSIZE - 1 - 4 - 32];
99 static unsigned char *sptmp;
100 static struct mtarch_thread *running;
144 running->sp = (
unsigned char*)SP;
145 SP = (
unsigned short)sptmp;
225 mtarch_stack_usage(
struct mt_thread *t)
228 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
229 if(t->thread.stack[i] != i) {
233 return MTARCH_STACKSIZE - i;