37 #include "sys/mtarch.h"
39 unsigned char mtarch_asm_threadspreg;
40 unsigned char *mtarch_asm_threadzp;
41 unsigned char *mtarch_asm_threadstack;
43 void mtarch_asm_start(
void);
44 void mtarch_asm_yield(
void);
45 void mtarch_asm_exec(
void);
60 void (*
function)(
void *data),
63 memset(thread->cpustack, 0,
sizeof(thread->cpustack));
64 memset(thread->cstack, 0,
sizeof(thread->cstack));
67 mtarch_asm_threadzp = thread->zp;
71 thread->cpustack[MTARCH_CPUSTACKSIZE - 2] = ((
unsigned short)
function) / 0x100;
72 thread->cpustack[MTARCH_CPUSTACKSIZE - 3] = ((
unsigned short)
function) % 0x100;
73 thread->cpustack[MTARCH_CPUSTACKSIZE - 4] = 0x21;
74 thread->cpustack[MTARCH_CPUSTACKSIZE - 5] =
75 thread->cpustack[MTARCH_CPUSTACKSIZE - 6] =
76 thread->cpustack[MTARCH_CPUSTACKSIZE - 7] = 0x00;
77 thread->spreg = MTARCH_CPUSTACKSIZE - 8;
80 thread->cstack[MTARCH_CSTACKSIZE - 2] = ((
unsigned short)data) / 0x100;
81 thread->cstack[MTARCH_CSTACKSIZE - 3] = ((
unsigned short)data) % 0x100;
84 thread->zp[1] = ((size_t)&thread->cstack[MTARCH_CSTACKSIZE - 3]) / 0x100;
85 thread->zp[0] = ((size_t)&thread->cstack[MTARCH_CSTACKSIZE - 3]) % 0x100;
99 mtarch_asm_threadspreg = thread->spreg;
101 mtarch_asm_threadstack = thread->cpustack;
102 mtarch_asm_threadzp = thread->zp;
106 thread->spreg = mtarch_asm_threadspreg;
void mtarch_init(void)
Initialize the architecture specific support functions for the multi-thread library.
void mtarch_yield(void)
Yield the processor.
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.
void mtarch_exec(struct mtarch_thread *thread)
Start executing a thread.
void mtarch_stop(struct mtarch_thread *thread)
Clean up the stack of a thread.
Copyright (c) 2014, Analog Devices, Inc.