2 #include "../port/lib.h"
6 #include "../port/error.h"
9 * The initcode array contains the binary text of the first
10 * user process. Its job is to invoke the exec system call
12 * Initcode does not link with standard plan9 libc _main()
13 * trampoline due to size constrains. Instead it is linked
14 * with a small machine specific trampoline init9.s that
15 * only sets the base address register and passes arguments
16 * to startboot() (see port/initcode.c).
21 * The first process kernel process starts here.
32 up->egrp = smalloc(sizeof(Egrp));
34 up->fgrp = dupfgrp(nil);
38 * These are o.k. because rootinit is null.
39 * Then early kproc's will have a root and dot.
41 up->slash = namec("#/", Atodir, 0, 0);
42 pathclose(up->slash->path);
43 up->slash->path = newpath("/");
44 up->dot = cclone(up->slash);
47 * Setup Text and Stack segments for initcode.
49 up->seg[SSEG] = newseg(SG_STACK | SG_NOEXEC, USTKTOP-USTKSIZE, USTKSIZE / BY2PG);
50 up->seg[TSEG] = newseg(SG_TEXT | SG_RONLY, UTZERO, 1);
51 p = newpage(1, 0, UTZERO);
53 memmove((void*)VA(k), initcode, sizeof(initcode));
56 segpage(up->seg[TSEG], p);
57 up->seg[TSEG]->flushme = 1;
60 * Become a user process.
65 procpriority(up, PriNormal, 0);
73 * setup environment variables
74 * prepare the stack for initcode
75 * switch to usermode to run initcode
79 /* init0 will never return */
88 kproc("*init*", proc0, nil);