From: dirkst@rama.informatik.rwth-aachen.de (Dirk Steinberg)
Newsgroups: comp.unix.bsd
Subject: boot code binary to make 386BSD coexist with DOS
Keywords: boot 386BSD
Date: 10 Apr 92 13:52:50 GMT
Organization: RBI - RWTH Aachen

This is an early alpha port of the bsd-boot code that is available on
many ftp sites. It allows you to boot 386BSD out of a DOS partition,
so 386BSD *can* coexist with DOS and other OSes on the *same* harddisk.
Currently I have DOS, Linux and 386BSD nicely side-by-side on the same
harddisk. A boot menu allows me to choose at boot time which OS to run.

Following the copyright:

/*
 * Copyright (C) 1992 Wolfgang Solfrank.
 * Copyright (C) 1992 TooLs GmbH.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by TooLs GmbH.
 * 4. The name of TooLs GmbH may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/*
 * Copyright (C) 1992 Wolfgang Solfrank.
 * Copyright (C) 1992 TooLs GmbH.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by TooLs GmbH.
 * 4. The name of TooLs GmbH may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

I had to do some hacking to get it to work (I used Linux as a platform).
For one thing, gas produces a lot of loosing code for the primary bootstrap.
I used a DOS debugger to patch the binary and make it work. This is also
the reason why I don't post the source: I don't have source that compiles
to a working binary.

The second bug I fixed was in the directory scanning routine when reading
directories longer than 512 bytes. That bug is also present in the bsdfs
utility.

You need to install a regular DOS master boot block in sector 0 of your
harddisk. The BSD disklabel goes into sector 1. Sectors 2-15 contain
the code that is included in this posting (actually the code is shorter,
but I don't remember just how long, and I grabbed the code from my 
/dev/wd0c with dd; anyway the first 8K of a partition are reserved in BSD,
so you can still start your first partition on sector 0).

You can put it there with 'dd if=bootwd of=/dev/wd0c seek=2'. Note that
the disklabel program writes to sector 0 of your disk, destroying your
DOS master boot. You can *first* grab your DOS master boot with
'dd if=/dev/wd0c of=wdboot count=1', then move wdboot and bootwd to
/etc/mdec, and then run disklabel. That should do the work.

WARNING: When you use Norton NU to patch your harddisk, note that it counts
         sectors starting from 1, i.e. the first sector on the disk is
	 sector 1, not 0.

Create a DOS partition that starts on sector 2 (or sector 3 in Norton).
The Length does not matter, but you may want it to include all of BSD.
Mark the partition as active. Reboot...

If all is well, you will get prompted by the boot program.
Now enter the name of the kernel to boot. When you just hit return the
default bootstring will be used. It is placed behind the disklabel in
sector 1 (offset 532 in sector 1). I use NU to patch it.

After the kernel is loaded, you will be prompted again. Note that the
boot loader resides at 0x90000, so you cannot boot a kernel larger than
0x8ffff (size vmunix). The kernels I build with NFS are larger than that
so I cannot boot them. Since the original boot code that comes with
386BSD resides at 0x70000, I wonder how anyone booted such a thing????

Now you can enter hex numbers. The contents of that address will be
displayed. At address 0 should be something like 0x1234....
Type a capital 'C' at the start of a line to kick of BSD.

Have fun.

PS.: This is alpha code. It is full of debugging output. You have been
     warned. So please don't flame me.

Dirk Steinberg
dirkst@messua.informatik.rwth-aachen.de

------------- cut here ----------------
begin 644 bootwd.Z
M'YV0,8`Q4N9(FR-ACJ0E(D8+4;,*ZP8`F`BEF00HOB3P:86H&"P&D$)&0S<2
M43!6B(R9P34Q`0`SP=`1<`3,$;88VV@)@.4@)"19@)I-T"='![]?#@!@6;7T
M00`+O``X!<<@@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