ref: 225b573624549303609411ab87a6e923964a50c1
parent: c911310a8b731d20a603d7710003e44b7ff7c8b8
author: cinap_lenrek <[email protected]>
date: Thu May 19 14:48:06 EDT 2016
9boot: add iso hybrid loader 9boothyb
--- a/sys/src/boot/pc/iso.c
+++ b/sys/src/boot/pc/iso.c
@@ -39,6 +39,23 @@
int readsect(ulong drive, ulong lba, void *buf);
+#ifdef FAT
+int
+readsect4(ulong drive, ulong lba, void *buf)
+{
+ int i;
+
+ lba *= Sectsz/512;
+ for(i = 0; i<Sectsz/512; i++){
+ if(readsect(drive, lba++, buf))
+ return -1;
+ buf = (uchar*)buf + 512;
+ }
+ return 0;
+}
+#define readsect readsect4
+#endif
+
void
unload(void)
{
@@ -145,6 +162,7 @@
/* drive passed in DL */
drive = ((ushort*)sp)[5] & 0xFF;
+#ifndef FAT
/*
* load full bootblock as only the frist 2K get
* loaded from bios. the code is specially arranged
@@ -159,6 +177,7 @@
}
readn(&ex, origin, ex.len);
close(&ex);
+#endif
if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){
print("no config\n");
--- a/sys/src/boot/pc/mkfile
+++ b/sys/src/boot/pc/mkfile
@@ -2,11 +2,11 @@
</$objtype/mkfile
BIN=/386
-TARG=9bootiso 9bootpxe 9bootfat mbr pbs
+TARG=9bootiso 9bootpxe 9bootfat 9boothyb mbr pbs
HFILES=mem.h fns.h x16.h
-all: 9bootiso 9bootpxe 9bootfat mbr pbs
+all: 9bootiso 9bootpxe 9bootfat 9boothyb mbr pbs
clean:V:
rm -rf $TARG *.$O test.* tmp
@@ -20,6 +20,12 @@
lfat.$O: l.s
$AS -DFAT -o $target l.s
+lhyb.$O: l.s
+ $AS -DFAT -o $target l.s
+
+hyb.$O: iso.c
+ $CC $CFLAGS -DFAT -o $target iso.c
+
%.$O: %.s
$AS $stem.s
@@ -50,8 +56,7 @@
$BIN/%: %
cp $stem $BIN/$stem
-
-test.iso: 9bootiso
+test.iso: 9bootiso 9boothyb 9bootfat mbr pbs
rm -fr tmp $target
mkdir tmp
mkdir tmp/386
@@ -60,7 +65,20 @@
cp /386/9pcf tmp/386
cp /sys/lib/dist/cfg/plan9.ini tmp/cfg/plan9.ini
echo wait >>tmp/cfg/plan9.ini
- disk/mk9660 -B 386/9bootiso -p /sys/lib/sysconfig/proto/allproto -s tmp $target
+ disk/mk9660 -B 386/9bootiso -p <{echo +} -s tmp $target
+ @{rfork n
+ bind 9boothyb 9bootfat
+ dd -if /dev/zero -bs 512 -count 4096 >> $target
+ disk/partfs -m /n/partfs $target
+ disk=/n/partfs/sdXX
+ disk/mbr -m mbr $disk/data
+ @{echo a p1 '$-1' '$'
+ echo t p1 FAT16
+ echo A p1
+ echo w
+ echo q} | disk/fdisk -b $disk/data
+ disk/format -b pbs -d -r 1 $disk/dos 9bootfat
+ }
rm -fr tmp
test.dsk: 9bootfat mbr pbs test.iso