ref: 94a064bda2c7aee2c78e8b90fc0e205a628cb664
parent: 6d69f6fba35087686f79adb2ea0d67944a62ca7b
author: 9ferno <[email protected]>
date: Mon Oct 18 04:24:26 EDT 2021
added tcp booting
--- a/dis/init
+++ b/dis/init
@@ -11,7 +11,6 @@
load std
mount {mntgen} /n
-mount {mntgen} /mnt
# checked these to get this working
# /n/m/home/j/local/plan9/plan9front/sys/src/9/boot/bootrc
@@ -22,19 +21,28 @@
# and, after booting the specified device, use /os/init/$sysname
# for machine specific booting
-# read the ether0 from plan9.ini TODO
-# bind it
# read bootargs (plan9.ini)
-# could be tcp, tls or local disk
+# could be tcp or local disk
# if local, use the specified disk
-# if tcp, TODO
-# get the sysname
-# figure out the sysname from /lib/ndb/local
-# ndb/query ether 50e549e5f938 sys
+# if tcp,
+# tcp!dhcp
+# dhcp server provides fs=
+# if not, get fs= from plan9.ini
+# use tcp!$fs!styx as root
+# tcp!add address mask gateway
+# get fs= from plan9.ini
+# use tcp!$fs!styx as root
+# getting the sysname
# sys= in plan9.ini
-# run /os/init/$sysname, if it exists
+# for tcp!dhcp
+# get the sys= from dhcp
+# for local disk and tcp!address mask gateway
+# figure out the sysname from /lib/ndb/local
+# ndb/query ether 50e549e5f938 sys
#
-# for options to disk/kfs:
+# run /os/init/$sysname, if it exists
+#
+# for options to disk/kfs:
# bootargs=local!any other disk/kfs args /dev/sdG0/fs
#TODO
@@ -126,9 +134,7 @@
}
}
-fn confignet {
- # the correct /net/ether0 can be set in plan9.ini
- echo binding /net/ether0
+fn bindether0 {
<>/net/ipifc/clone {
x=`{read}
echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl
@@ -135,7 +141,13 @@
}
}
-fn mountnet {
+fn usedhcp {
+ # the correct /net/ether0 can be set in plan9.ini
+ echo binding /net/ether0
+ <>/net/ipifc/clone {
+ x=`{read}
+ echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl
+ }
ip/dhcp -p /net/ipifc/$x
for tuple in `{cat /net/ndb}{
(name value)=${split '=' $tuple}
@@ -145,6 +157,8 @@
sysname=$value
}{~ $name ip}{
ip=$value
+ }{~ $name fs}{
+ fs=$value
}
}
echo $sysname
@@ -151,10 +165,14 @@
cat /dev/sysname
cat /net/ndb
cat /dev/sysname
+}
- mount -A -c $"bootargs /n/remote
- bind /n/remote/dis /dis
- bind -c -a /n/remote/ /
+fn mountfs {
+ if{! ~ $"fs ''}{
+ mount -v -c tcp!$"fs!6666 /n/remote
+ bind /n/remote/dis /dis
+ bind -c -a /n/remote/ /
+ }
}
sysname=$sys
@@ -169,19 +187,30 @@
if { ~ $"connectmethod local }{
sh /dis/diskparts
mountlocal $localdevice
- if {~ $"sysname ''}{
- sysname=`{ndb/query ether `{cat '#l0/ether0/addr'} sys}
+ } {~ $"connectmethod tcp}{
+ if{~ $"localdevice dhcp}{
+ usedhcp
+ mountfs
+ }{
+ echo binding /net/ether0
+ <>/net/ipifc/clone {
+ x=`{read}
+ echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl
+ echo $localdevice > /net/ipifc/^$x^/ctl
+ }
+ mountfs
}
- } { ~ $"connectmethod tcp }{
- confignet
- mountnet
} {
echo unsupported connect method: $connectmethod
}
+ if {~ $"sysname ''}{
+ sysname=`{ndb/query ether `{cat '#l0/ether0/addr'} sys}
+ }
+
and {! ~ $"sysname ''} {
- ftest -x /os/init/$sysname }{
- @ /os/init/$sysname
+ ftest -f /os/init/$sysname }{
+ @{sh /os/init/$sysname}
}
}
--- a/lib/proto/inferno
+++ b/lib/proto/inferno
@@ -1549,6 +1549,7 @@
install
+
iostats.dis
+ init
ip
+
itest.dis
--- a/lib/proto/os
+++ b/lib/proto/os
@@ -705,6 +705,7 @@
shell.b
srvinit.b
wminit.b
+ bootcd 755
ip
*
ipaq1110
--- a/mkfile
+++ b/mkfile
@@ -255,6 +255,7 @@
#echo '*apicdebug=1'
#echo '*nomp=1'
echo 'cdboot=1'
+ echo 'sys=bootcd'
grep -v '^bootfile=' /n/src9/os/pc/plan9.ini
#echo 'bootfile='^`{echo $kernel | sed 's!^/n/src9!!'}
#echo 'bootfile=9pc64'
--- /dev/null
+++ b/os/init/bootcd
@@ -1,0 +1,20 @@
+#!/bin/sh
+
+load std
+# machine specific initialization
+# called by /dis/init when sysname=bootcd
+# special networking setup, disk setup
+# avoids putting machine specific stuff in devroot
+
+<>/net/ipifc/clone {
+ x=`{read}
+ echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl
+}
+ip/dhcp -p /net/ipifc/$x
+
+# Networking
+ndb/dns -r
+ndb/cs
+#bind -a '#scs' /net
+
+
--- a/os/init/vmx9ferno
+++ b/os/init/vmx9ferno
@@ -2,14 +2,15 @@
load std
# machine specific initialization
+# called by /dis/init when sysname=vmx9ferno
# special networking setup, disk setup
# avoids putting machine specific stuff in devroot
-echo binding /net/ether0
<>/net/ipifc/clone {
x=`{read}
echo bind ether /net/ether0 > /net/ipifc/^$x^/ctl
}
+ip/dhcp -p /net/ipifc/$x
# Networking
ndb/dns -r
@@ -18,13 +19,13 @@
# refresh disk contents from the master
and {ndb/csquery tcp!master!styx}{ftest -d /n/rootdisk/dis}{
- mount -A tcp!master!styx /n/master
- #disk/mkfs -v -s /n/master/ -d /n/rootdisk/ <{ cat /n/master/lib/proto/^(9boot inferno os src utils) }
+ mount tcp!master!styx /n/master
+ disk/mkfs -v -s /n/master/ -d /n/rootdisk/ <{ cat /n/master/lib/proto/^(9boot inferno os src utils) }
- ## sync the boot executables
- #dossrv -f /dev/sdG0/9fat -m /n/9fat
- #cp /n/9fat/ipc64 /n/9fat/ipc64.0
- #cp /n/master/Inferno/amd64/ipc64 /n/9fat/ipc64
- #cp /n/master/Inferno/386/9bootfat /n/9fat/9bootfat
+ # sync the boot executables
+ dossrv -f /dev/sdG0/9fat -m /n/9fat
+ cp /n/9fat/ipc64 /n/9fat/ipc64.0
+ cp /n/master/Inferno/amd64/ipc64 /n/9fat/ipc64
+ cp /n/master/Inferno/386/9bootfat /n/9fat/9bootfat
}