Blame


1 8a708fb2 2003-11-23 devnull #include "threadimpl.h"
2 8a708fb2 2003-11-23 devnull
3 8a708fb2 2003-11-23 devnull static void
4 64bcfff3 2003-11-25 devnull launchersparc(uint o0, uint o1, uint o2, uint o3,
5 64bcfff3 2003-11-25 devnull uint o4, uint o5, uint o6, uint o7,
6 8a708fb2 2003-11-23 devnull void (*f)(void *arg), void *arg)
7 8a708fb2 2003-11-23 devnull {
8 64bcfff3 2003-11-25 devnull if(0) print("ls %x %x %x %x %x %x %x %x %x %x at %x\n",
9 64bcfff3 2003-11-25 devnull o0, o1, o2, o3, o4, o5, o6, o7, f, arg, &o0);
10 8a708fb2 2003-11-23 devnull (*f)(arg);
11 8a708fb2 2003-11-23 devnull threadexits(nil);
12 8a708fb2 2003-11-23 devnull }
13 8a708fb2 2003-11-23 devnull
14 8a708fb2 2003-11-23 devnull void
15 8a708fb2 2003-11-23 devnull _threadinitstack(Thread *t, void (*f)(void*), void *arg)
16 8a708fb2 2003-11-23 devnull {
17 8a708fb2 2003-11-23 devnull ulong *tos, *stk;
18 8a708fb2 2003-11-23 devnull
19 64bcfff3 2003-11-25 devnull /*
20 64bcfff3 2003-11-25 devnull * This is a bit more complicated than it should be,
21 64bcfff3 2003-11-25 devnull * because we need to set things up so that gotolabel
22 64bcfff3 2003-11-25 devnull * (which executes a return) gets us into launchersparc.
23 64bcfff3 2003-11-25 devnull * So all the registers are going to be renamed before
24 64bcfff3 2003-11-25 devnull * we get there. The input registers here become the
25 64bcfff3 2003-11-25 devnull * output registers there, which is useless.
26 64bcfff3 2003-11-25 devnull * The input registers there are inaccessible, so we
27 64bcfff3 2003-11-25 devnull * have to give launchersparc enough arguments that
28 64bcfff3 2003-11-25 devnull * everything ends up in the stack.
29 64bcfff3 2003-11-25 devnull */
30 8a708fb2 2003-11-23 devnull tos = (ulong*)&t->stk[t->stksize&~7];
31 8a708fb2 2003-11-23 devnull stk = tos;
32 8a708fb2 2003-11-23 devnull --stk;
33 8a708fb2 2003-11-23 devnull *--stk = (ulong)arg;
34 8a708fb2 2003-11-23 devnull *--stk = (ulong)f;
35 64bcfff3 2003-11-25 devnull stk -= 25; /* would love to understand this */
36 8a708fb2 2003-11-23 devnull t->sched.link = (ulong)launchersparc - 8;
37 8a708fb2 2003-11-23 devnull t->sched.input[6] = 0;
38 64bcfff3 2003-11-25 devnull t->sched.sp = (ulong)stk;
39 64bcfff3 2003-11-25 devnull if(0) print("tis %x %x at %x\n", f, arg, t->sched.sp);
40 8a708fb2 2003-11-23 devnull }
41 8a708fb2 2003-11-23 devnull