Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[9fans] kernel config changes

37 views
Skip to first unread message

Russ Cox

unread,
Dec 13, 2002, 3:33:26 AM12/13/02
to
There is a new kernel config file section called "bootdir" that lists
the files to be placed in #//boot. There are no binaries in #/ itself
anymore.

A typical bootdir section might look like

bootdir
bootpcdisk.out boot
/386/bin/ip/ipconfig
/386/bin/auth/factotum
/386/bin/disk/kfs
/386/bin/cfs

which says that /boot will contain four files: boot, ipconfig,
factotum, kfs, and cfs, copied from the paths listed.

The kernels have always special cased boot$CONF.out to get it listed
as /boot. It is now /boot/boot, and no longer a special case.

Now that everything is in /boot, initcode had to change for all the
kernels; /boot/boot itself had to change to exec /boot/ipconfig
(instead of /ipconfig), etc. Finally, auth_getkey changed. It looks
for /factotum and then /boot/factotum, to deal with either type of
kernel.

The boot file /386/bin/ip/ipconfig (e.g.) turns into
_386_bin_ip_ipconfig.root.s and then _386_bin_ip_ipconfig.root.8.
It's a bit of an ugly name, but mk clean will get rid of them. You
could imagine just using the last path element, but that might lead to
weird build inconsistencies if kernels were using two different files
with the same last element. One unfortunate consequence of the big
name is that _386_bin_auth_factotum.root.s is too long for the current
file servers to deal with. You could use lnfs to get around this, but
I didn't want to require lnfs for the kernel build, so we have a rule
in portmkfile that copies factotum and ipconfig to factotum.hack and
ipconfig.hack and then the bootdir section actually looks like:

bootdir
bootpcdisk.out boot
ipconfig.hack ipconfig
factotum.hack factotum
/386/bin/disk/kfs
/386/bin/cfs

sadly. That will go away when we get long file names.

The pc initcode is also changed. Whereas before it used to do

exec("/boot", ["boot", 0]);

in hand-coded assembly (pc/initcode.s), it now does

open("#c/cons", OREAD);
open("#c/cons", OWRITE);
open("#c/cons", OWRITE);
bind("#c", "/dev", MAFTER);
bind("#ec", "/env", MAFTER);
bind("#e", "/env", MCREATE|MAFTER);
bind("#s", "/srv", MREPL|MCREATE);
execl("/boot/boot", "/boot/boot", 0);

in C (port/initcode.c). The point is to set up enough of a namespace
that /boot/boot can be a shell script. Eventually the other
architectures should change too, though it's not urgent. If someone
wants to do the bitsy, send me mail and I'll let you know what it took
to get one of the old undistributed mips kernels changed over. (The
compiler setup is similar.)

As a much bigger example, I built a kernel called pcext the other
night. It uses rx and trampoline to connect through a Plan 9 gateway
machine to the root file server. It uses this bootdir:

bootdir
bootext boot
/386/bin/rc
/rc/lib/rcmain
/386/bin/bind
/386/bin/cat
/386/bin/cp
/386/bin/echo
/386/bin/mount
/386/bin/sleep
factotum.hack factotum
/386/bin/ip/ipconfig
/386/bin/cfs
/386/bin/aux/srvthru

(and does require lnfs to build).

Srvthru is the obvious program -- it connects to rx,
authenticates, starts trampoline to the real file server,
and then optionally pushes cfs onto the connection.

The point is that bootext is a shell script, which
makes it easier to tweak than when /boot was a
binary building out of /sys/src/9/boot.

#!/boot/rc -m /boot/rcmain

cd /boot
cp '#r/rtc' '#c/time'
bind -a /boot /bin
bind -a '#I' /net
bind -a '#l0' /net
bind -a '#S' /dev
bind '#p' /proc
bind '#d' /fd
bind -a /boot /
ipconfig
echo 'authdom=cs.bell-labs.com auth=204.178.31.3' >>/net/ndb
factotum -sfactotum -u -a 204.178.31.3
cargs=()
if(~ $#cfs 1 && ! ~ $cfs off)
cargs=(-c $cfs)
srvthru $cargs tcp!204.178.31.2!17009 il!emelie!9fs boot emelie
mount -c /srv/boot /root
bind -ac /root /
bind -c /root/mnt /mnt
mount -a '#s/factotum' /mnt
rootdir=/root
rootspec=''
/386/init -t
/boot/rc -m/boot/rcmain -i # in case init fails

It takes care of everything /boot traditionally
does, using srvthru as the way to establish /srv/boot
(and also /srv/emelie, just for kicks).

Russ

Jack Johnson

unread,
Dec 13, 2002, 11:33:25 AM12/13/02
to
On Fri, 2002-12-13 at 00:32, Russ Cox wrote:
> The point is that bootext is a shell script, which
> makes it easier to tweak than when /boot was a
> binary building out of /sys/src/9/boot.

The stuff that can be accomplished in Plan 9 with shell scripts never
ceases to amaze me.

-Jack

John Packer

unread,
Jan 23, 2003, 9:45:25 PM1/23/03
to

On Friday, December 13, 2002, at 03:32 AM, Russ Cox wrote:

> The pc initcode is also changed. Whereas before it used to do
>
> exec("/boot", ["boot", 0]);
>
> in hand-coded assembly (pc/initcode.s), it now does
>
> open("#c/cons", OREAD);
> open("#c/cons", OWRITE);
> open("#c/cons", OWRITE);
> bind("#c", "/dev", MAFTER);
> bind("#ec", "/env", MAFTER);
> bind("#e", "/env", MCREATE|MAFTER);
> bind("#s", "/srv", MREPL|MCREATE);
> execl("/boot/boot", "/boot/boot", 0);
>
> in C (port/initcode.c). The point is to set up enough of a namespace
> that /boot/boot can be a shell script. Eventually the other
> architectures should change too, though it's not urgent. If someone
> wants to do the bitsy, send me mail and I'll let you know what it took
> to get one of the old undistributed mips kernels changed over. (The
> compiler setup is similar.)


Could you describe what you did for the mips kernels? I would
like to know, both for the bitsy kernel and for some mips
related work I've been planning to do.

John

Russ Cox

unread,
Jan 24, 2003, 11:53:24 AM1/24/03
to
There's now both port/initcode.c, which does almost
what I posted (I've since noticed that the exec cmd line
args get passed into the main function, now called startboot):

#include <u.h>
#include <libc.h>

char cons[] = "#c/cons";
char boot[] = "/boot/boot";
char dev[] = "/dev";
char c[] = "#c";
char e[] = "#e";
char ec[] = "#ec";
char s[] = "#s";
char srv[] = "/srv";
char env[] = "/env";

void
startboot(char *argv0, char **argv)
{
open(cons, OREAD);
open(cons, OWRITE);
open(cons, OWRITE);
bind(c, dev, MAFTER);
bind(ec, env, MAFTER);
bind(e, env, MCREATE|MAFTER);
bind(s, srv, MREPL|MCREATE);
exec(boot, argv);
for(;;);
}

On the MIPS there is still an assembly stub
that initializes R30 (SB).

TEXT _main(SB), $8
MOVW $setR30(SB), R30
MOVW $boot(SB), R1
ADD $12, R29, R2 /* get a pointer to 0(FP) */
MOVW R1, 4(R29)
MOVW R2, 8(R29)
JAL startboot(SB)

The 386 uses just the C code -- no assembly required.

You should be able to do almost exactly the same
thing for the bitsy -- SB is R12.

Russ

john

unread,
Jan 26, 2003, 5:41:27 PM1/26/03
to
Russ, Nemo:

I've updated the bitsy kernel. Attached is a diff and the file init9.s,
and the other modified files (as I think Nemo prefers). I had to make
a small change to wavelan.c, but the mkfile should probably be
changed to use ../port/wavelan.c instead.

I'm not sure the bootdir section needs anything other than
bootbitsy.out. Anything more than what I have makes the
kernel too large to boot.

John


diff /n/dump/2003/0118/sys/src/9/bitsy/bitsy /sys/src/9/bitsy/bitsy
41d40
< paqfs.root
49a49,52
>
> bootdir
> bootbitsy.out boot
> /arm/bin/paqfs paqfs
Only in /sys/src/9/bitsy: init9.s
diff /n/dump/2003/0118/sys/src/9/bitsy/mkfile /sys/src/9/bitsy/mkfile
50d49
< boot$CONF.root.$O\
93a93
> <|../port/mkbootrules $CONF
95,97c95,98
< init.h: initcode /sys/src/libc/9syscall/sys.h
< $AS initcode
< $LD -l -s -R4 -o init.out initcode.$O
---
> init.h: ../port/initcode.c init9.s
> $CC ../port/initcode.c
> $AS init9.s
> $LD -l -R1 -o init.out init9.$O initcode.$O /arm/lib/libc.a
99c100
< xd -r -1x init.out |
---
> strip < init.out | xd -1x |
Common subdirectories: /n/dump/2003/0118/sys/src/9/bitsy/paqfiles and
/sys/src/9/bitsy/paqfiles
diff /n/dump/2003/0118/sys/src/9/bitsy/wavelan.c
/sys/src/9/bitsy/wavelan.c
658c658
< w_cmd(ctlr, WCmdAskStats, WTyp_Stats);
---
> w_cmd(ctlr, WCmdEnquire, WTyp_Stats);

init9.s
mkfile
bitsy
wavelan.c
0 new messages