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/bcm | |
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/bcm')
-rw-r--r-- | sys/src/9/bcm/init9.s | 1 | ||||
-rw-r--r-- | sys/src/9/bcm/main.c | 83 | ||||
-rw-r--r-- | sys/src/9/bcm/mkfile | 41 |
3 files changed, 15 insertions, 110 deletions
diff --git a/sys/src/9/bcm/init9.s b/sys/src/9/bcm/init9.s deleted file mode 100644 index 751ad84fc..000000000 --- a/sys/src/9/bcm/init9.s +++ /dev/null @@ -1 +0,0 @@ -#include "../omap/init9.s" diff --git a/sys/src/9/bcm/main.c b/sys/src/9/bcm/main.c index 4099d67f2..ba289ad08 100644 --- a/sys/src/9/bcm/main.c +++ b/sys/src/9/bcm/main.c @@ -6,10 +6,9 @@ #include "fns.h" #include "io.h" -#include "init.h" #include <pool.h> -#include "reboot.h" +#include "rebootcode.i" /* Firmware compatibility */ #define Minfirmrev 326770 @@ -131,19 +130,6 @@ init0(void) { char buf[2*KNAMELEN], **sp; - up->nerrlab = 0; - coherence(); - 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); - chandevinit(); if(!waserror()){ @@ -166,74 +152,7 @@ init0(void) sp = (char**)(USTKTOP - sizeof(Tos) - 8 - sizeof(sp[0])*4); sp[3] = sp[2] = sp[1] = nil; strcpy(sp[0] = (char*)&sp[4], "boot"); - touser((uintptr)sp); - assert(0); /* shouldn't have returned */ -} - -/* - * create the first process - */ -void -userinit(void) -{ - Proc *p; - Segment *s; - KMap *k; - Page *pg; - - /* no processes yet */ - up = nil; - - 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); - - /* - * Kernel Stack - */ - p->sched.pc = (uintptr)init0; - p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr); - p->sched.sp = STACKALIGN(p->sched.sp); - - /* - * User Stack - * - * Technically, newpage can't be called here because it - * should only be called when in a user context as it may - * try to sleep if there are no pages available, but that - * shouldn't be the case here. - */ - s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); - s->flushme++; - p->seg[SSEG] = s; - pg = newpage(1, 0, USTKTOP-BY2PG); - segpage(s, pg); - k = kmap(pg); - memset((void*)VA(k), 0, BY2PG); - kunmap(k); - - /* - * Text - */ - s = newseg(SG_TEXT, UTZERO, 1); - p->seg[TSEG] = s; - pg = newpage(1, 0, UTZERO); - pg->txtflush = ~0; - segpage(s, pg); - k = kmap(s->map[0]->pages[0]); - memmove((void*)VA(k), initcode, sizeof initcode); - kunmap(k); - - ready(p); } void diff --git a/sys/src/9/bcm/mkfile b/sys/src/9/bcm/mkfile index eb7cad035..495dd659f 100644 --- a/sys/src/9/bcm/mkfile +++ b/sys/src/9/bcm/mkfile @@ -39,6 +39,7 @@ PORT=\ taslock.$O\ tod.$O\ xalloc.$O\ + userinit.$O\ OBJ=\ l.$O\ @@ -104,36 +105,22 @@ install:V: /$objtype/$p$CONF arch.$O clock.$O fpiarm.$O main.$O mmu.$O screen.$O syscall.$O trap.$O: \ /$objtype/include/ureg.h - +arch.$O trap.$O main.$O: /sys/include/tos.h fpi.$O fpiarm.$O fpimem.$O: fpi.h l.$O lexception.$O lproc.$O mmu.$O: mem.h l.$O lexception.$O lproc.$O armv6.$O armv7.$O: arm.s armv7.$O: cache.v7.s -main.$O: errstr.h init.h reboot.h +main.$O: errstr.h rebootcode.i devmouse.$O mouse.$O screen.$O: screen.h usbdwc.$O: dwcotg.h ../port/usb.h -arch.$O archbcm.$O archbcm2.$O clock.$O coproc.$O fpiarn.$O mmu.$O trap.$O vfp3.$O: arm.h mem.h - -init.h:D: ../port/initcode.c init9.s - $CC ../port/initcode.c - $AS init9.s - $LD -l -R1 -s -o init.out init9.$O initcode.$O /$objtype/lib/libc.a - {echo 'uchar initcode[]={' - xd -1x <init.out | - sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g' - echo '};'} > init.h - -reboot.h:D: rebootcode.s arm.s arm.h mem.h - $AS rebootcode.s - # -T arg is REBOOTADDR - $LD -l -s -T0x1c00 -R4 -o reboot.out rebootcode.$O - {echo 'uchar rebootcode[]={' - xd -1x reboot.out | - sed -e '1,2d' -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g' - echo '};'} > reboot.h - -errstr.h:D: ../port/mkerrstr ../port/error.h - rc ../port/mkerrstr > errstr.h - -$CONF.clean: - rm -rf $p$CONF s$p$CONF errstr.h reboot.h $CONF.c boot$CONF.c +arch.$O archbcm.$O archbcm2.$O clock.$O coproc.$O fpiarn.$O mmu.$O trap.$O vfp3.$O rebootcode.$O: arm.h mem.h +rebootcode.$O: arm.s cache.v7.s + +init9.$O: ../omap/init9.s + $AS ../omap/init9.s + +initcode.out: init9.$O initcode.$O /$objtype/lib/libc.a + $LD -l -R1 -s -o $target $prereq + +rebootcode.out: rebootcode.$O + $LD -l -R4 -T0x1c00 -s -o $target $prereq |