diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-01-26 19:01:36 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-01-26 19:01:36 +0100 |
commit | 8d51e7fa1a1dbcbde513c2b756d504c879598907 (patch) | |
tree | 4cd1a3aaab346ac990bc9058e8cc4928258be6ae /sys/src/9/ppc | |
parent | 60bb408acca3b48b17f9158132849b894ad9f234 (diff) |
kernel: implement portable userinit() and simplify process creation
replace machine specific userinit() by a portable
implemntation that uses kproc() to create the first
process. the initcode text is mapped using kmap(),
so there is no need for machine specific tmpmap()
functions.
initcode stack preparation should be done in init0()
where the stack is mapped and can be accessed directly.
replacing the machine specific userinit() allows some
big simplifications as sysrfork() and kproc() are now
the only callers of newproc() and we can avoid initializing
fields that we know are being initialized by these
callers.
rename autogenerated init.h and reboot.h headers.
the initcode[] and rebootcode[] blobs are now in *.i
files and hex generation was moved to portmkfile. the
machine specific mkfile only needs to specify how to
build rebootcode.out and initcode.out.
Diffstat (limited to 'sys/src/9/ppc')
-rw-r--r-- | sys/src/9/ppc/initcode | 25 | ||||
-rw-r--r-- | sys/src/9/ppc/main.c | 75 | ||||
-rw-r--r-- | sys/src/9/ppc/mkfile | 12 | ||||
-rw-r--r-- | sys/src/9/ppc/trap.c | 4 |
4 files changed, 6 insertions, 110 deletions
diff --git a/sys/src/9/ppc/initcode b/sys/src/9/ppc/initcode deleted file mode 100644 index 1d846abe5..000000000 --- a/sys/src/9/ppc/initcode +++ /dev/null @@ -1,25 +0,0 @@ -#include "/sys/src/libc/9syscall/sys.h" - -/* - * we pass in the argument of the exec parameters as 0(FP) - */ - -TEXT main(SB),$8 - - MOVW $setSB(SB), R2 - MOVW $boot(SB), R3 - ADD $12, R1, R4 /* get a pointer to 0(FP) */ - MOVW R3, 4(R1) - MOVW R4, 8(R1) - MOVW $EXEC, R3 - SYSCALL - - /* should never get here */ -loop: - BR loop - -DATA boot+0(SB)/5,$"/boot" -DATA boot+5(SB)/5,$"/boot" -DATA bootv+0(SB)/4,$boot+6(SB) -GLOBL boot+0(SB),$11 -GLOBL bootv+0(SB),$8 diff --git a/sys/src/9/ppc/main.c b/sys/src/9/ppc/main.c index e2ab259cd..1eaabe8f7 100644 --- a/sys/src/9/ppc/main.c +++ b/sys/src/9/ppc/main.c @@ -1,12 +1,11 @@ #include "u.h" +#include "tos.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" -#include "init.h" #include "pool.h" -#include "tos.h" #define MAXCONF 64 @@ -147,21 +146,8 @@ plan9iniinit(void) void init0(void) { -// char **p, *q, name[KNAMELEN]; - int i; char buf[2*KNAMELEN]; - - up->nerrlab = 0; - spllo(); - - /* - * These are o.k. because rootinit is null. - * Then early kproc's will have a root and dot. - */ - up->slash = namec("#/", Atodir, 0, 0); - pathclose(up->slash->path); - up->slash->path = newpath("/"); - up->dot = cclone(up->slash); + int i; chandevinit(); @@ -183,62 +169,7 @@ init0(void) } kproc("alarm", alarmkproc, 0); kproc("mmusweep", mmusweep, 0); - touser((void*)(USTKTOP-sizeof(Tos))); -} - -void -userinit(void) -{ - Proc *p; - Segment *s; - KMap *k; - Page *pg; - - p = newproc(); - p->pgrp = newpgrp(); - p->egrp = smalloc(sizeof(Egrp)); - p->egrp->ref = 1; - p->fgrp = dupfgrp(nil); - p->rgrp = newrgrp(); - p->procmode = 0640; - - kstrdup(&eve, ""); - kstrdup(&p->text, "*init*"); - kstrdup(&p->user, eve); - - p->fpstate = FPinit; - - /* - * Stack - * - * N.B. The -12 for the stack pointer is important. - * 4 bytes for gotolabel's return PC - */ - p->sched.pc = (ulong)init0; - p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD); - - /* - * User Stack - */ - s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); - p->seg[SSEG] = s; - pg = newpage(1, 0, USTKTOP-BY2PG); - segpage(s, pg); - - /* - * Text - */ - s = newseg(SG_TEXT, UTZERO, 1); - s->flushme++; - p->seg[TSEG] = s; - pg = newpage(1, 0, UTZERO); - pg->txtflush = ~0; - segpage(s, pg); - k = kmap(s->map[0]->pages[0]); - memmove((ulong*)VA(k), initcode, sizeof initcode); - kunmap(k); - - ready(p); + touser((void*)(USTKTOP - sizeof(Tos))); } void diff --git a/sys/src/9/ppc/mkfile b/sys/src/9/ppc/mkfile index 97457c142..8891f94e5 100644 --- a/sys/src/9/ppc/mkfile +++ b/sys/src/9/ppc/mkfile @@ -53,7 +53,6 @@ HFILES=\ dat.h\ errstr.h\ fns.h\ - init.h\ io.h\ mem.h\ @@ -90,16 +89,11 @@ install:V: $p$CONF <|../port/mkbootrules $CONF clock.$O devether.$O main.$O trap.$O: /$objtype/include/ureg.h +trap.$O main.$O: /sys/include/tos.h %.$O: $HFILES $ETHER: ../port/etherif.h ../port/netif.h -init.h: ../port/initcode.c init9.s - $CC ../port/initcode.c - $AS init9.s - $LD -l -s -R4 -o init.out init9.$O initcode.$O /power/lib/libc.a - {echo 'uchar initcode[]={' - <init.out xd -1x | - sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g' - echo '};'} > init.h +initcode.out: init9.$O initcode.$O /$objtype/lib/libc.a + $LD -l -R4 -s -o $target $prereq diff --git a/sys/src/9/ppc/trap.c b/sys/src/9/ppc/trap.c index ebfb87fe6..b11b9fa0d 100644 --- a/sys/src/9/ppc/trap.c +++ b/sys/src/9/ppc/trap.c @@ -553,10 +553,6 @@ forkchild(Proc *p, Ureg *ur) cur = (Ureg*)(p->sched.sp+2*BY2WD); memmove(cur, ur, sizeof(Ureg)); cur->r3 = 0; - - /* Things from bottom of syscall we never got to execute */ - p->psstate = 0; - p->insyscall = 0; } uintptr |