11 #define ON_64BIT_ARCH 1
13 #define ON_64BIT_ARCH 0
36 unsigned long retaddr;
37 unsigned long retaddr2;
48 void (*
function)(
void *),
void *data)
50 struct frame *f = (
struct frame *)&t->stack[MTARCH_STACKSIZE -
sizeof(
struct frame)/
sizeof(
unsigned long)];
53 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
57 memset(f, 0,
sizeof(
struct frame));
58 f->retaddr = (
unsigned long)
function;
59 f->data = (
unsigned long)data;
60 t->sp = (
unsigned long)&f->flags;
62 f->rbp = (
unsigned long)&f->rax;
64 f->ebp = (
unsigned long)&f->eax;
98 __asm__ (
"movq %0, %%rax\n\t" : :
"m" (running_thread));
100 "movq (%rax), %rbx\n\t"
101 "movq %rsp, (%rax)\n\t"
102 "movq %rbx, %rsp\n\t"
105 __asm__ (
"movl %0, %%eax\n\t" : :
"m" (running_thread));
107 "movl (%eax), %ebx\n\t"
108 "movl %esp, (%eax)\n\t"
109 "movl %ebx, %esp\n\t"
152 running_thread =
NULL;
177 mtarch_stack_usage(
struct mt_thread *t)
180 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
181 if(t->thread.stack[i] != i) {
182 return MTARCH_STACKSIZE - i;
void mtarch_init(void)
Initialize the architecture specific support functions for the multi-thread library.
void mtarch_yield(void)
Yield the processor.
Header file for the preemptive multitasking library for Contiki.
void mtarch_remove(void)
Uninstall library and clean up.
void mtarch_start(struct mtarch_thread *thread, void(*function)(void *data), void *data)
Setup the stack frame for a thread that is being started.
#define NULL
The null pointer.
void mtarch_exec(struct mtarch_thread *thread)
Start executing a thread.
Copyright (c) 2014, Analog Devices, Inc.