39 #include "sys/cooja_mt.h"
47 #define ON_64BIT_ARCH 1
49 #define ON_64BIT_ARCH 0
72 unsigned long retaddr;
73 unsigned long retaddr2;
78 cooja_mtarch_init(
void)
83 cooja_mtarch_start(
struct cooja_mtarch_thread *t,
84 void (*
function)(
void *),
void *data)
86 struct frame *f = (
struct frame *)&t->stack[COOJA_MTARCH_STACKSIZE -
sizeof(
struct frame)/
sizeof(
unsigned long)];
89 for(i = 0; i < COOJA_MTARCH_STACKSIZE; ++i) {
93 memset(f, 0,
sizeof(
struct frame));
94 f->retaddr = (
unsigned long)
function;
95 f->data = (
unsigned long)data;
96 t->sp = (
unsigned long)&f->flags;
98 f->rbp = (
unsigned long)&f->rax;
100 f->ebp = (
unsigned long)&f->eax;
104 static struct cooja_mtarch_thread *cooja_running_thread;
133 __asm__ (
"movq %0, %%rax\n\t" : :
"m" (cooja_running_thread));
135 "movq (%rax), %rbx\n\t"
136 "movq %rsp, (%rax)\n\t"
137 "movq %rbx, %rsp\n\t"
140 __asm__ (
"movl %0, %%eax\n\t" : :
"m" (cooja_running_thread));
142 "movl (%eax), %ebx\n\t"
143 "movl %esp, (%eax)\n\t"
144 "movl %ebx, %esp\n\t"
183 cooja_mtarch_exec(
struct cooja_mtarch_thread *t)
185 cooja_running_thread = t;
187 cooja_running_thread =
NULL;
191 cooja_mtarch_remove(
void)
196 cooja_mtarch_yield(
void)
202 cooja_mtarch_pstop(
void)
207 cooja_mtarch_pstart(
void)
212 cooja_mtarch_stack_usage(
struct cooja_mt_thread *t)
215 for(i = 0; i < COOJA_MTARCH_STACKSIZE; ++i) {
216 if(t->thread.stack[i] != i) {
217 return COOJA_MTARCH_STACKSIZE - i;