mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
sun support
This commit is contained in:
parent
cd7ddc9b5f
commit
8a708fb239
3 changed files with 76 additions and 11 deletions
51
src/libthread/asm-SunOS-sun4u.s
Normal file
51
src/libthread/asm-SunOS-sun4u.s
Normal file
|
@ -0,0 +1,51 @@
|
|||
.globl _setlabel
|
||||
.type _setlabel,#function
|
||||
|
||||
_setlabel:
|
||||
ta 3
|
||||
st %i0, [%o0]
|
||||
st %i1, [%o0+4]
|
||||
st %i2, [%o0+8]
|
||||
st %i3, [%o0+12]
|
||||
st %i4, [%o0+16]
|
||||
st %i5, [%o0+20]
|
||||
st %i6, [%o0+24]
|
||||
st %i7, [%o0+28]
|
||||
st %l0, [%o0+32]
|
||||
st %l1, [%o0+36]
|
||||
st %l2, [%o0+40]
|
||||
st %l3, [%o0+44]
|
||||
st %l4, [%o0+48]
|
||||
st %l5, [%o0+52]
|
||||
st %l6, [%o0+56]
|
||||
st %l7, [%o0+60]
|
||||
st %sp, [%o0+64]
|
||||
st %o7, [%o0+68]
|
||||
jmpl %o7+8, %g0
|
||||
or %g0, %g0, %o0
|
||||
|
||||
.globl _gotolabel
|
||||
.type _gotolabel,#function
|
||||
|
||||
_gotolabel:
|
||||
ta 3
|
||||
ld [%o0], %i0
|
||||
ld [%o0+4], %i1
|
||||
ld [%o0+8], %i2
|
||||
ld [%o0+12], %i3
|
||||
ld [%o0+16], %i4
|
||||
ld [%o0+20], %i5
|
||||
ld [%o0+24], %i6
|
||||
ld [%o0+28], %i7
|
||||
ld [%o0+32], %l0
|
||||
ld [%o0+36], %l1
|
||||
ld [%o0+40], %l2
|
||||
ld [%o0+44], %l3
|
||||
ld [%o0+48], %l4
|
||||
ld [%o0+52], %l5
|
||||
ld [%o0+56], %l6
|
||||
ld [%o0+60], %l7
|
||||
ld [%o0+64], %sp
|
||||
ld [%o0+68], %o7
|
||||
jmpl %o7+8, %g0
|
||||
or %g0, 1, %o0
|
|
@ -9,13 +9,11 @@ procexec(Channel *pidc, char *prog, char *args[])
|
|||
Proc *p;
|
||||
Thread *t;
|
||||
|
||||
print("procexec\n");
|
||||
_threaddebug(DBGEXEC, "procexec %s", prog);
|
||||
/* must be only thread in proc */
|
||||
p = _threadgetproc();
|
||||
t = p->thread;
|
||||
if(p->threads.head != t || p->threads.head->nextt != nil){
|
||||
print("not only thread\n");
|
||||
werrstr("not only thread in proc");
|
||||
Bad:
|
||||
if(pidc)
|
||||
|
@ -36,35 +34,26 @@ print("not only thread\n");
|
|||
* pipe to us.
|
||||
*/
|
||||
if(pipe(p->exec.fd) < 0)
|
||||
{
|
||||
print("pipe\n");
|
||||
goto Bad;
|
||||
}
|
||||
if(fcntl(p->exec.fd[1], F_SETFD, 1) < 0)
|
||||
{
|
||||
print("fcntl\n");
|
||||
goto Bad;
|
||||
}
|
||||
|
||||
/* exec in parallel via the scheduler */
|
||||
assert(p->needexec==0);
|
||||
p->exec.prog = prog;
|
||||
p->exec.args = args;
|
||||
p->needexec = 1;
|
||||
print("sched\n");
|
||||
_sched();
|
||||
|
||||
close(p->exec.fd[1]);
|
||||
if((n = read(p->exec.fd[0], p->exitstr, ERRMAX-1)) > 0){ /* exec failed */
|
||||
p->exitstr[n] = '\0';
|
||||
print("read got %s\n", p->exitstr);
|
||||
errstr(p->exitstr, ERRMAX);
|
||||
close(p->exec.fd[0]);
|
||||
goto Bad;
|
||||
}
|
||||
close(p->exec.fd[0]);
|
||||
|
||||
print("exec %d\n", pidc);
|
||||
if(pidc)
|
||||
sendul(pidc, t->ret);
|
||||
|
||||
|
|
25
src/libthread/sun4u.c
Normal file
25
src/libthread/sun4u.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "threadimpl.h"
|
||||
|
||||
static void
|
||||
launchersparc(int o0, int o1, int o2, int o3, int o4,
|
||||
void (*f)(void *arg), void *arg)
|
||||
{
|
||||
(*f)(arg);
|
||||
threadexits(nil);
|
||||
}
|
||||
|
||||
void
|
||||
_threadinitstack(Thread *t, void (*f)(void*), void *arg)
|
||||
{
|
||||
ulong *tos, *stk;
|
||||
|
||||
tos = (ulong*)&t->stk[t->stksize&~7];
|
||||
stk = tos;
|
||||
--stk;
|
||||
*--stk = (ulong)arg;
|
||||
*--stk = (ulong)f;
|
||||
t->sched.link = (ulong)launchersparc - 8;
|
||||
t->sched.input[6] = 0;
|
||||
t->sched.sp = (ulong)stk - 0x5c;
|
||||
}
|
||||
|
Loading…
Reference in a new issue