38 #include "sys/cooja_mt.h" 40 #if INTPTR_MAX == INT32_MAX 41 #define ON_64BIT_ARCH 0 42 #elif INTPTR_MAX == INT64_MAX 43 #define ON_64BIT_ARCH 1 45 #error "Could not detect 32/64-bit environment." 74 cooja_mtarch_start(
struct cooja_mtarch_thread *t,
75 void (*
function)(
void *),
void *data)
77 struct frame *f = (
struct frame *)&t->stack[COOJA_MTARCH_STACKSIZE -
sizeof(
struct frame)/
sizeof(uintptr_t)];
80 for(i = 0; i < COOJA_MTARCH_STACKSIZE; ++i) {
84 memset(f, 0,
sizeof(
struct frame));
85 f->retaddr = (uintptr_t)
function;
86 f->data = (uintptr_t)data;
87 t->sp = (uintptr_t)&f->flags;
89 f->rbp = (uintptr_t)&f->rax;
91 f->ebp = (uintptr_t)&f->eax;
95 static struct cooja_mtarch_thread *cooja_running_thread;
124 __asm__ (
"movq %0, %%rax\n\t" : :
"m" (cooja_running_thread));
126 "movq (%rax), %rbx\n\t" 127 "movq %rsp, (%rax)\n\t" 128 "movq %rbx, %rsp\n\t" 131 __asm__ (
"movl %0, %%eax\n\t" : :
"m" (cooja_running_thread));
133 "movl (%eax), %ebx\n\t" 134 "movl %esp, (%eax)\n\t" 135 "movl %ebx, %esp\n\t" 174 cooja_mtarch_exec(
struct cooja_mtarch_thread *t)
176 cooja_running_thread = t;
178 cooja_running_thread = NULL;
182 cooja_mtarch_yield(
void)