Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | This Boot code is different from the original boot code that came with |
2 | 386BSD in that it uses the BIOS to load the kernel and to provide all i/o | |
3 | services. The advantage ofthis is that the same boot code exactly, can run | |
4 | on any device that is supported by the BIOS. (That's most of them) | |
5 | This is important for the 'generic scsi' project because it means we can | |
6 | write drivers for new scsi adapters without having to develop an new | |
7 | set of boot blocks for each. | |
8 | ||
9 | At this point you should read the first part of README.MACH... come back here | |
10 | when you have done that: | |
11 | ||
12 | In normal operation, when co-existing with other operating systems, the | |
13 | following operations occur: | |
14 | ||
15 | 1/ the BIOS loads the first block of the disk (called the Master Boot Record | |
16 | or MBR) and if it has the correct magic numbers, jumps into it: | |
17 | ||
18 | 2/ The MBR code, looks at the Partition table that is embedded within it, | |
19 | to detirmine which is the partition to boot from. If you are using the os-bs | |
20 | bootblocks (highly recommended) then it will give you a menu to choose from. | |
21 | ||
22 | 3/ The MBR will load the first record of the selected partition and | |
23 | if it has (the same) magic numbers, jumps into it. In 386bsd this is the | |
24 | first stage boot, (or boot1) it is represented in /usr/mdec by | |
25 | wdboot, asboot and sdboot. If the disk has been set up without DOS partitioning | |
26 | then this block will be at block zero, and will have been loaded directly by | |
27 | the BIOS. | |
28 | ||
29 | 4/ Boot1 will look at block0 (which might be itself if there are no DOS | |
30 | partitions) and will find the 386bsd partition, and using the information | |
31 | regarding the start position of that partition, will load the next 13 sectors | |
32 | or so, to around 90000 (640k - 64k). and will jump into it at the appropriate | |
33 | entry point. Since boot1 and boot2 were compiled together as one file | |
34 | and then split later, boot1 knows the exact position within boot2 of the | |
35 | entry point. | |
36 | ||
37 | Boot 1 also contains a compiled in DOS partition table | |
38 | (in case it is at block 0), which contains a 386bsd partition starting | |
39 | at 0. This ensures that the same code can work whether or not | |
40 | boot1 is at block 0. | |
41 | ||
42 | 5/ Boot2 asks the user for a boot device, partition and filename, and then | |
43 | loads the MBR of the selected device. This may or may not be the device | |
44 | which was originally used to boot the first MBR. The partition table | |
45 | of the new MBR is searched for a 386bsd partition, and if one is found, | |
46 | that is then in turn searched for the disklabel. This could all be on the | |
47 | second disk at this point, if the user selected it. | |
48 | ||
49 | 6/On finding the disklabel, boot2 can find the correct unix partition | |
50 | within the 386bsd partition, and using cutdown filesystem code, | |
51 | look for the file to boot (e.g. 386bsd). | |
52 | ||
53 | 7/ Boot2 loads this file starting at the location specified by the a.out header, | |
54 | (see later) and leaps into it at the location specified in he header. | |
55 | ||
56 | if the file does not exist or cannot be loaded, boot2 goes back to step 5. | |
57 | ||
58 | 386bsd is now running and will hopefully start vm etc. and get to multi-user | |
59 | mode. | |
60 | ||
61 | ########################################################################## | |
62 | During all these steps, all i/o is performed using the BIOS. This has a number | |
63 | of side effects: | |
64 | ||
65 | 1/ Since BIOS disk calls are specified in terms of cylinder,head and sector, | |
66 | and the BIOS read the disk information from either the CMOS or from some other | |
67 | location which is un-available to us, we must use the cyl,head,sec information | |
68 | that is given in the MBR, rather than the start address in the MBR, because | |
69 | we cannot guarentee that we can corectly calculate C,H,S from the start address. | |
70 | ||
71 | Therefore, the C,H,S information in the MBR must be as correct for this boot | |
72 | to work as it would be for DOS to boot. For example, adaptec BIOS routines | |
73 | assume a layout of 64 heads and 32 sectors giving 1MB per ficticious cylinder. | |
74 | You must use these figures to calculate the correct values. Luckily, the DOS | |
75 | fdisk program will do all this for you if you tell it to give you a DOS | |
76 | partition, and you can change it to a 386BSD partition later. If you use | |
77 | no DOS partitioning, then the compiled in table in Boot1 will do just fine. | |
78 | ||
79 | If you want to do it by hand remember that BIOS counts sectors starting at 1. | |
80 | (cylinders and heads start at 0 (??)) | |
81 | ||
82 | 2/ you cannot overwrite the bottom 4k of ram until you have finished ALL | |
83 | bios calls, as BIOS uses this area as scratch memory. | |
84 | ||
85 | 3/ Since BIOS runs in REAL mode, and Boot2 runs in protected mode, | |
86 | Boot 2 switches back to real mode just before each BIOS call and then | |
87 | back to protected mode on each return. Touch this at your peril.! | |
88 | ||
89 | ######################################################################### | |
90 | In answering the prompt from Boot2: | |
91 | you can, | |
92 | 1/ leave it alone.. it will boot the indicated file from the first | |
93 | partition of the first drive seen by the BIOS (C:) | |
94 | ||
95 | 2/ enter only "-s" to boot the default to single user mode | |
96 | ||
97 | 3/ enter only a filename (optionally with -s) to boot that kernel, | |
98 | ||
99 | 4/ enter a whole line of the form shown in the prompt. This allows you to | |
100 | boot some other partition, possibly on the second drive, as root. | |
101 | ||
102 | ||
103 | ########################################################################## | |
104 | In the case you have two drives the same type (both scsi or bith IDE/ESDI), | |
105 | wd(0,a)xxx | |
106 | will boot xxx from drive 0, a partition. | |
107 | wd(1,a)xxx | |
108 | will boot xxx from drive 1, a partition. | |
109 | ||
110 | similarly for sd. | |
111 | ||
112 | if you have one wd drive and one scsi drive, then you MUST | |
113 | use device 'hd' | |
114 | ||
115 | otherwise the following will happen: | |
116 | ||
117 | with wd0 and sd0, you specify sd1 or wd1 to indicate the 2nd drive. | |
118 | it boots the kernel correctly, then tells the kernel to use sd1 as root. | |
119 | you however may not have an sd1, and problems arise. | |
120 | ||
121 | hd is special in that the kernel is always told to use unit 0, | |
122 | The correct TYPE of device will be specified too, so the kernel | |
123 | will be told either sd0 or wd0. | |
124 | ||
125 | Whether sd or wd is specified to the kernel is read from the disklabel, | |
126 | so ensure that all SCSI disks have type SCSI in their disklabel or the | |
127 | boot code will assume they are ESDI or IDE. (Remember, because it is | |
128 | working through the BIOS it has ho idea what kind of disk it is. | |
129 | ||
130 | ########################################################################## | |
131 | Installing: | |
132 | The makefile supplied has a target install which will create the | |
133 | files wdboot,bootwd ,sdboot and bootsd in /usr/mdec. | |
134 | BEWARE these will overwrite the existing wdboot and bootwd. (so back | |
135 | them up) | |
136 | ||
137 | there are also targets wd and sd which wil only do one of them | |
138 | ||
139 | The commented out targets wd0 and sd0 are examples of how to | |
140 | load the new bootblocks, however,make sure you change the | |
141 | device type and label to suit your drive if you uncomment them. | |
142 | (see 'man disklabel') | |
143 | ||
144 | If you already have made partitions using the old bootblocks | |
145 | these should install painlessly. | |
146 | ||
147 | Before you do this ensure you have a booting floppy with correct | |
148 | disktab and bootblock files on it so that if it doesn't work, you can | |
149 | re-disklabel from the floppy. | |
78ed81a3 | 150 | |
151 | $Id$ |