Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / platform / pc32 / boot / biosboot / README.386BSD
1 Note: all my original references to 386BSD also refer to freeBSD and NetBSD
2 which in some ways are derived from 386BSD.  --julian@freebsd.org
3
4 This Boot code is different from the original boot code that came with
5 386BSD in that it uses the BIOS to load the kernel and to provide all i/o
6 services. The advantage ofthis is that the same boot code exactly, can run
7 on any device that is supported by the BIOS. (That's most of them)
8 This is important for the 'generic scsi' project because it means we can
9 write drivers for new scsi adapters without having to develop an new
10 set of boot blocks for each.
11
12 At this point you should read the first part of README.MACH... come back here
13 when you have done that:
14
15 In normal operation, when co-existing with other operating systems, the
16 following operations occur:
17
18 1/ the BIOS loads the first block of the disk (called the Master Boot Record
19 or MBR) and if it has the correct magic numbers, jumps into it:
20
21 2/ The MBR code, looks at the Partition table that is embedded within it,
22 to determine which is the partition to boot from.  If you install the
23 boot manager when FreeBSD is first installed, it will also give you a nice
24 menu for switching between operating systems.
25
26 3/ The MBR will load the first record of the selected partition and
27 if it has (the same) magic numbers, jumps into it. In 386bsd this is the
28 first stage boot, (or boot1) it is represented in /usr/mdec by
29 wdboot, asboot and daboot. If the disk has been set up without DOS partitioning
30 then this block will be at block zero, and will have been loaded directly by
31 the BIOS. This is the usual case with floppies.
32
33 4/ Boot1 will look at block0 (which might be itself if there are no DOS
34 partitions) and will find the 386bsd partition,
35
36 Boot 1 also contains a compiled in DOS partition table
37 (in case it is at block 0), which contains a 386bsd partition starting
38 at 0. This ensures that the same code can work whether or not
39 boot1 is at block 0.
40
41 4A/ IF the NAMEBLOCK option is compiled into the bootcode, then the 
42 boot1 code will load and examine block1 (usually unused) and
43 look for a default boot string to use later (if the correct magic number
44 is present). If the option NAMEBLOCK_WRITEBACK is also defined, then
45 it will zero out that name after finding it, and write the block back,
46 having "used up" that name. The block may contain multiple different
47 boot strings which will be "used up" one after the other (one per boot)
48 They are set using the "nextboot" utility.
49
50 4B/ Using the information found in step 4, regarding the start position
51 of the BSD partition, boot1 will load the first 16 sectors of that partition,
52 to around 0x10000 (64k) and will jump into it at the appropriate entry point.
53 Since boot1 and boot2 were compiled together as one file and then split
54 later, boot1 knows the exact position within boot2 of the entry point.
55
56 5/ Boot2 asks the user for a boot device, partition and filename, and then
57 loads the MBR of the selected device. This may or may not be the device
58 which was originally used to boot the first MBR. The partition table
59 of the new MBR is searched for a 386bsd partition, and if one is found,
60 that is then in turn searched for the disklabel. This could all be on the
61 second disk at this point, if the user selected it. If the user makes no
62 actions then a default string will be used.
63
64 If the NAMEBLOCK option is used, then the default string may have been
65 loaded from block2. If none was found then a compiled in default will be used.
66
67 6/On finding the disklabel, on the disk the user spacified, boot2 can find
68 the correct unix partition within the 386bsd partition, and using cutdown
69 filesystem code, look for the file to boot (e.g., 386bsd).
70
71 7/ Boot2 loads this file starting at the location specified by the a.out header,
72 (see later) and leaps into it at the location specified in he header.
73
74 if the file does not exist or cannot be loaded, boot2 goes back to step 5.
75
76 386bsd is now running and will hopefully start vm etc. and get to multi-user
77 mode.
78
79 ##########################################################################
80 During all these steps, all i/o is performed using the BIOS. This has a number
81 of side effects:
82
83 1/ Since BIOS disk calls are specified in terms of cylinder,head and sector,
84 and the BIOS read the disk information from either the CMOS or from some other
85 location which is un-available to us, we must use the cyl,head,sec information
86 that is given in the MBR, rather than the start address in the MBR, because
87 we cannot guarentee that we can corectly calculate C,H,S from the start address.
88
89 Therefore, the C,H,S information in the MBR must be as correct for this boot
90 to work as it would be for DOS to boot. For example, adaptec BIOS routines
91 assume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder.
92 You must use these figures to calculate the correct values. Luckily, the DOS
93 fdisk program will do all this for you if you tell it to give you a DOS
94 partition, and you can change it to a 386BSD partition later. If you use 
95 no DOS partitioning, then the compiled in table in Boot1 will do just fine.
96
97 If you want to do it by hand remember that BIOS counts sectors starting at 1.
98 (cylinders and heads start at 0 (??))
99
100 2/ you cannot overwrite the bottom 4k of ram until you have finished ALL
101 bios calls, as BIOS uses this area as scratch memory.
102 This is no longer really a problem as we no-longer support loading the kernel
103 at location 0.
104
105 3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode,
106 Boot 2 switches back to real mode just before each BIOS call and then
107 back to protected mode on each return. Touch this at your peril.!
108
109 #########################################################################
110 In answering the prompt from Boot2:
111 you can, 
112 1/ leave it alone. It will boot the indicated file from the first 
113 partition of the first drive seen by the BIOS (C:)
114 If the NAMEBLOCK option is in use, the default name might be taken from block1
115 (2nd block) on that drive (the drive on which boot 1 was loaded).
116
117 2/ enter only "-s" to boot the default to single user mode
118
119 3/ enter only a filename (optionally with -s) to boot that kernel,
120
121 4/ enter a whole line of the form shown in the prompt. This allows you to
122 boot some other partition, possibly on the second drive, as root.
123
124
125 ##########################################################################
126 In the case you have several drives the same type (all scsi or all IDE/ESDI),
127         wd(0,a)xxx
128 will boot xxx from drive 0, a partition.
129         wd(1,a)xxx
130 will boot xxx from drive 1, a partition.
131
132 similarly for da and for higher drive numbers (if the BIOS supports them).
133
134 if you have one or more wd drives and one or more scsi drives, then you
135 MUST specify the BIOS drive number for booting the scsi drives:
136         2:da(0,a)xxx
137 will boot xxx from scsi drive 0, a partition, provided `2' is the correct
138 BIOS drive number for da0.
139
140 otherwise the following will happen:
141
142 with wd0 and da0, you specify da1 or wd1 to indicate the 2nd drive.
143 it boots the kernel correctly, then tells the kernel to use da1 as root.
144 you however may not have an da1, and problems arise.
145
146 Whether da or wd is specified to the kernel is read from the disklabel,
147 so ensure that all SCSI disks have type SCSI in their disklabel or the
148 boot code will assume they are ESDI or IDE. (Remember, because it is
149 working through the BIOS it has ho idea what kind of disk it is.
150
151 ##########################################################################
152 Installing:
153 The makefile supplied has a target install which will create the
154 files wdboot,bootwd ,daboot and bootda in /usr/mdec.
155 BEWARE these will overwrite the existing wdboot and bootwd. (so back
156 them up)
157
158 there are also targets wd and da which wil only do one of them
159
160 The commented out targets wd0 and da0 are examples of how to 
161 load the new bootblocks, however,make sure you change the 
162 device type and label to suit your drive if you uncomment them.
163 (see 'man disklabel')
164
165 If you already have made partitions using the old bootblocks
166 these should install painlessly.
167
168 Before you do this ensure you have a booting floppy with correct
169 disktab and bootblock files on it so that if it doesn't work, you can
170 re-disklabel from the floppy.
171
172 $FreeBSD: src/sys/i386/boot/biosboot/README.386BSD,v 1.11 1999/08/28 00:43:10 peter Exp $
173 $DragonFly: src/sys/platform/pc32/boot/biosboot/Attic/README.386BSD,v 1.2 2003/06/17 04:28:34 dillon Exp $