#include <9pm/u.h> #include <9pm/libc.h> #include <9pm/ns.h> #include <9pm/thread.h> /* * On MIPS, the first argument is passed in R1. * So that we only have to mung the stack, * we ignore the first argument. */ void launchermips(ulong, void (*f)(void *arg), void *arg) { Thread *t; t = _threadgetthr(); if(t->garbage){ _freethread(t->garbage); t->garbage = nil; } (*f)(arg); threadexits(nil); } void _threadinitstack(Thread *t, void (*f)(void*), void *arg) { ulong *tos; tos = (ulong*)&t->stack[t->stacksize&~7]; *--tos = (ulong)arg; *--tos = (ulong)f; t->env[JMPBUFPC] = (ulong)launchermips+JMPBUFDPC; t->env[JMPBUFSP] = (ulong)tos - 8; /* old PC and new PC */ }