38 #include "sys/cooja_mt.h"
46 #define ON_64BIT_ARCH 1
48 #define ON_64BIT_ARCH 0
71 unsigned long retaddr;
72 unsigned long retaddr2;
77 cooja_mtarch_init(
void)
82 cooja_mtarch_start(
struct cooja_mtarch_thread *t,
83 void (*
function)(
void *),
void *data)
85 struct frame *f = (
struct frame *)&t->stack[COOJA_MTARCH_STACKSIZE -
sizeof(
struct frame)/
sizeof(
unsigned long)];
88 for(i = 0; i < COOJA_MTARCH_STACKSIZE; ++i) {
92 memset(f, 0,
sizeof(
struct frame));
93 f->retaddr = (
unsigned long)
function;
94 f->data = (
unsigned long)data;
95 t->sp = (
unsigned long)&f->flags;
97 f->rbp = (
unsigned long)&f->rax;
99 f->ebp = (
unsigned long)&f->eax;
103 static struct cooja_mtarch_thread *cooja_running_thread;
132 __asm__ (
"movq %0, %%rax\n\t" : :
"m" (cooja_running_thread));
134 "movq (%rax), %rbx\n\t"
135 "movq %rsp, (%rax)\n\t"
136 "movq %rbx, %rsp\n\t"
139 __asm__ (
"movl %0, %%eax\n\t" : :
"m" (cooja_running_thread));
141 "movl (%eax), %ebx\n\t"
142 "movl %esp, (%eax)\n\t"
143 "movl %ebx, %esp\n\t"
182 cooja_mtarch_exec(
struct cooja_mtarch_thread *t)
184 cooja_running_thread = t;
186 cooja_running_thread =
NULL;
190 cooja_mtarch_remove(
void)
195 cooja_mtarch_yield(
void)
201 cooja_mtarch_pstop(
void)
206 cooja_mtarch_pstart(
void)
211 cooja_mtarch_stack_usage(
struct cooja_mt_thread *t)
214 for(i = 0; i < COOJA_MTARCH_STACKSIZE; ++i) {
215 if(t->thread.stack[i] != i) {
216 return COOJA_MTARCH_STACKSIZE - i;
#define NULL
The null pointer.