commit 90536f1b87905c6aab9e116df8fea6205f46488a
parent 38cd867bc481a46a24dfc918583a00960ae235f1
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date: Sat, 18 Sep 2010 12:23:23 +0200
boot from iso files or embeded minimal system
Diffstat:
9 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/.hgignore b/.hgignore
@@ -29,8 +29,11 @@ src/9vx/boot/*.orig
src/9vx/boot/libboot.a8
src/9vx/boot/bootcode.9
src/9vx/bootcode.S
+src/9vx/9660srv.S
+src/9vx/bzfs.S
src/9vx/fossil.S
src/9vx/kfs.S
+src/9vx/rootfs.S
src/9vx/venti.S
src/9vx/data2s
src/9vx/a/errstr.h
diff --git a/src/9vx/9660srv.9 b/src/9vx/9660srv.9
Binary files differ.
diff --git a/src/9vx/Makefrag b/src/9vx/Makefrag
@@ -37,7 +37,9 @@ all: 9vx/9vx
PLAN9_OBJS = \
$(addprefix 9vx/, \
+ 9660srv.o \
bootcode.o \
+ bzfs.o \
conf.o \
devaudio.o \
devaudio-$(PLAN9AUDIO).o \
@@ -54,6 +56,7 @@ PLAN9_OBJS = \
load.o \
main.o \
mmu.o \
+ rootfs.o \
sched.o \
sdloop.o \
stub.o \
@@ -232,9 +235,15 @@ PLAN9_DEPS = \
9vx/data2s: 9vx/data2s.c
$(HOST_CC) -o $@ $<
+9vx/9660srv.S: 9vx/data2s 9vx/9660srv.9
+ ./9vx/data2s iso9660 < 9vx/9660srv.9 >$@_ && mv $@_ $@
+
9vx/bootcode.S: 9vx/data2s 9vx/bootcode.9
./9vx/data2s boot < 9vx/bootcode.9 >$@_ && mv $@_ $@
+9vx/bzfs.S: 9vx/data2s 9vx/bzfs.9
+ ./9vx/data2s bzfs < 9vx/bzfs.9 >$@_ && mv $@_ $@
+
9vx/factotum.S: 9vx/data2s 9vx/factotum.9
./9vx/data2s factotum < 9vx/factotum.9 >$@_ && mv $@_ $@
@@ -244,6 +253,9 @@ PLAN9_DEPS = \
9vx/kfs.S: 9vx/data2s 9vx/kfs.9
./9vx/data2s kfs < 9vx/kfs.9 >$@_ && mv $@_ $@
+9vx/rootfs.S: 9vx/data2s 9vx/rootfs.bz2
+ ./9vx/data2s rootfs < 9vx/rootfs.bz2 >$@_ && mv $@_ $@
+
9vx/venti.S: 9vx/data2s 9vx/venti.9
./9vx/data2s venti < 9vx/venti.9 > $@_ && mv $@_ $@
@@ -279,10 +291,13 @@ CLEAN_FILES += \
9vx/a/errstr.h \
9vx/9vx \
9vx/data2s \
+ 9vx/9660srv.S \
9vx/bootcode.S \
+ 9vx/bzfs.S \
9vx/factotum.S \
9vx/fossil.S \
9vx/kfs.S \
+ 9vx/rootfs.S \
9vx/venti.S
include 9vx/libdraw/Makefrag
diff --git a/src/9vx/boot/boot.c.ed b/src/9vx/boot/boot.c.ed
@@ -12,3 +12,10 @@ char* localroot;
Init:
cpuflag = (strcmp(getenv("service"), "cpu") == 0);
.
+/if\(cmd == nil\)/ a
+ sprint(cmdbuf, "/%s/init", cputype);
+ if(stat(cmdbuf, statbuf, sizeof statbuf) < 0)
+ sprint(cmdbuf, "/%s/bin/rc", cputype);
+ else
+.
++;/;$/ s/^/ /
diff --git a/src/9vx/boot/bootcode.9.kfs b/src/9vx/boot/bootcode.9.kfs
Binary files differ.
diff --git a/src/9vx/boot/local.c.ed b/src/9vx/boot/local.c.ed
@@ -1,3 +1,31 @@
+/^connectlocalkfs/+/^$/i
+ char buf[512];
+ char *argv0;
+ char *cmd = "/boot/bzfs";
+.
+/stat/;/^$/ d
+/dirfstat/ i
+ /* can do the check in 9vx -- kfs is kfs */
+ memset(buf, 0, sizeof buf);
+ pread(fd, buf, 512, 0);
+ if(memcmp(buf+256, "kfs wren device\n", 16) == 0)
+ cmd = "/boot/kfs";
+ else{
+ /* if an iso image, use 9660srv */
+ pread(fd, buf, 512, 17*0x800);
+ if(memcmp(buf, "\0CD001", 6) == 0)
+ cmd = "/boot/9660srv";
+ }
+ /* argv0 is basename(cmd) */
+ argv0 = strrchr(cmd, '/') + 1;
+ if(stat(cmd, statbuf, sizeof statbuf) < 0)
+ return -1;
+
+.
+/print\("kfs\.\.\."\)/ s/"kfs\.\.\."/"%s...", argv0/
+/"kfs"/ s/"kfs"/argv0/
+/exec/ s;"/boot/kfs";cmd;g
+g/fatal\(.*kfs.*\)/ s/ (for )?kfs//
/fatal\("open \/net\/ipifc\/clone for loopback"\)/s,[^ ],// &,
a
return;
diff --git a/src/9vx/bootcode.9 b/src/9vx/bootcode.9
Binary files differ.
diff --git a/src/9vx/bzfs.9 b/src/9vx/bzfs.9
Binary files differ.
diff --git a/src/9vx/main.c b/src/9vx/main.c
@@ -50,7 +50,7 @@ int abortonfault;
int nocpuload;
char* argv0;
char* conffile = "9vx";
-char* defaultroot = "local!#Z/usr/local/9vx";
+char* defaultroot = "local!/boot/rootfs.bz2";
Conf conf;
static Mach mach0;
@@ -336,26 +336,37 @@ bootinit(void)
* even if we don't execute it to provide a file system.
* Also, maybe /boot/boot needs it.
*
- * factotum, fossil and venti are the normal Plan9 binary.
- * bootcode.9 is the file bootpcf.out obtained applyng
- * the patch in a/bootboot.ed and compiling with:
- * mk 'CONF=pcf' bootpcf.out
+ * 9660srv, bzfs, factotum, fossil and venti are
+ * Plan9 386 executables.
+ * bootcode.9 is the file bootpcf.out obtained running
+ * mk in the ./boot/ directory from inside 9vx.
+ *
+ * TODO(yy): The boot methods should be optional
*/
+ extern uchar iso9660code[];
+ extern long iso9660len;
extern uchar bootcode[];
extern long bootlen;
+ extern uchar bzfscode[];
+ extern long bzfslen;
extern uchar factotumcode[];
extern long factotumlen;
extern uchar fossilcode[];
extern long fossillen;
extern uchar kfscode[];
extern long kfslen;
+ extern uchar rootfscode[];
+ extern long rootfslen;
extern uchar venticode[];
extern long ventilen;
+ addbootfile("9660srv", iso9660code, iso9660len);
addbootfile("boot", bootcode, bootlen);
+ addbootfile("bzfs", bzfscode, bzfslen);
addbootfile("factotum", factotumcode, factotumlen);
addbootfile("fossil", fossilcode, fossillen);
addbootfile("kfs", kfscode, kfslen);
+ addbootfile("rootfs.bz2", rootfscode, rootfslen);
addbootfile("venti", venticode, ventilen);
}