Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / i386 / boot / biosboot / README.MACH
1 /*
2  * Mach Operating System
3  * Copyright (c) 1992, 1991 Carnegie Mellon University
4  * All Rights Reserved.
5  * 
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  * 
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  * 
16  * Carnegie Mellon requests users of this software to return to
17  * 
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  * 
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  *
26  *      from: Mach, Revision 2.2  92/04/04  11:33:55  rpd
27  * $FreeBSD: src/sys/i386/boot/biosboot/README.MACH,v 1.7 1999/08/28 00:43:10 peter Exp $
28  * $DragonFly: src/sys/i386/boot/biosboot/Attic/README.MACH,v 1.2 2003/06/17 04:28:34 dillon Exp $
29  */
30
31 ********NOTE: This is not all relevant to the 386BSD version**********
32
33                 AT386 Protected Mode Bootstrap Loader
34                 =====================================
35
36 1. Overview of Startup
37    -------------------
38
39         After the system is rebooted, the BIOS bootstrap routine reads Sector
40         1, Track 0 into memory at location 0000:7C00H.  If location 0000:7DFEH
41         (last two bytes of that sector) contains the value AA55H, the BIOS
42         bootstrap routine will transfer control to 0000:7C00H.  Otherwise, the
43         boot code in that sector is bad and the boot routine stops.
44         
45         For DOS compatibility reason, one extra stage of boot is required if
46         the boot device is a hard disk.  The first sector of the hard disk will
47         contain the MOS-DOS boot code and a boot record partition table.
48         When this sector is loaded into 0000:7C00H, it will relocate itself
49         to somewhere else and then load the first sector of the active
50         partition into 0000:7C00H.  Both UNIX and DOS use the command "fdisk"
51 [ 386bsd does not have an 'fdisk' (yet) ]
52         to install this first sector into the hard disk and to manipulate
53         the hard disk partitions.
54
55         
56
57 2. The First Stage Bootstrap Loader
58    --------------------------------
59
60         After startup, the first stage boot is loaded at 0000:7C00H.  This
61         first stage boot will load itself and the second stage boot into
62         memory at location 0000:1000H.  For floppy disks, the first cylinder
63         is reserved as the boot cylinder, and the boot code (first and second)
64         will be loaded from there.  Currently, only double sided, high density
65         (15 sectors per track) floppies are supported.  For hard disks, the
66         first 29 sectors of the active partition is reserved for boot code
67         which will be loaded by the first stage boot.  All the disk types
68         recognized by BIOS are supported by this bootstrap loader. 
69 [for 386bsd we load the second stage booter to 9000:0]
70
71
72
73 3. The Second Stage Bootstrap Loader
74    --------------------------------
75
76         After the boot code is loaded, the control is passed to the second
77         stage bootstrap loader "boot2()".  In order to be able to load the
78         big kernel image (bigger than 512K or 640K, depends on the memory
79         configuration), the second stage boot loader will run on the protected
80         mode.  This bootstarp loader does not have any stand alone device
81         drivers, all the I/O's are through the BIOS calls.  Since the first
82         stage boot code will no longer be used at this moment, the memory
83         location of the first stage boot code (0000:1000H to 0000:1200H) will
84         be used as an internal buffer for BIOS calls.  Immediately after this 
85         internal buffer is the GDT table for the second stage boot loader. 
86         Since this boot loader needs to switch back and forth between protected
87         and real mode in order to use BIOS calls, the limit of the boot code
88         and boot data segments must not be greater than 64K.
89         
90         The boot loader loads the kernel image at memory location above 1 MB
91         to skip the memory hole between 521K/640K and 1MB.  After the kernel
92         is loaded, the boot loader stores the information in the stack and
93         then passes control to kernel.  Currently, the three information passed
94         fromm the boot loader to the kernel are type of the boot device, size
95         of the base memory and size of the extended memory.
96
97 [ 386bsd receives: howto, bootdev]
98
99 [ 386bsd is loaded where-ever the "MByte" bits of the load address specify,
100 so if you link it for FE100000 it will load to 1MB, but if you link
101 it for FE000000 it will load ad 0MB]
102
103 [for machines with only 512KB normal ram the kernel will need to  be linked
104 for 1MB and the bootblocks modified to run below 512KB. (8000:0)]
105
106
107 4. The UNIX Startup
108    ----------------
109
110         Since the boot loader loads the kernel image at memory location above
111         1MB, the kernel has to start as protected mode.  In addition, the
112         link editor description file (vuifile) has to indicate that
113         the text and data segments start above 1MB.  Also, the boot loader
114         passes the infomation to the kernel through the stack.
115
116 [MOST of what is mentionned below is NOT relevant to 386bsd]
117
118 5. Disk Layout and Bad Block Handling
119    ---------------------------------
120         
121     The System V/386 Release 3.2 (AT) disk layout will be used as the disk
122     layout for the MACH System on the AT platform.
123
124     This disk layout is as follows:
125
126         * Reserve the first sector of cylinder 0 for the DOS boot record which
127           contains the master boot code (446 bytes) and the partition table.
128           (Refer to DOS Technical Reference Manual page 9-6 to 9-10).
129
130         * Reserve the first 29 sectors of the UNIX partition for the first
131           and the second stage bootstrap.
132
133         * Reserve the 30th sector of the UNIX partition for the pdinfo and
134           the vtoc tables.
135
136         * Reserve the 31st to the 34th sectors of the UNIX partition for the
137           bad track and the bad block mapping tables.
138
139         * Reserve up to 253 consecutive tracks when required, beginning with
140           the 35th sector of the UNIX partition, for alternate tracks.
141
142         * Reserve up to 253 consecutive blocks, beginning with the first
143           sector after the alternate tracks area, for alternate blocks.
144
145          SEC
146           1
147         ----------------------------------------------------
148         | X |                                              | CYL 0, TRK 0
149         ----------------  ..........    --------------------
150         |                 ..........                       |
151         ----------------  ..........    --------------------
152         |                 ..........                       |
153    ===============================================================
154     ^   |               BOOTSTRAP                          | CYL N, TRK M
155     |   ----------------------------------------------------
156     |   |                              |30 |31 |32 |33 |34 |
157         ----------------------------------------------------  ---
158     U   |                 ..........                       |   ^
159     N   ----------------  ..........   ---------------------   |
160     I   |                 ..........                       | Alternate Tracks
161     X   ----------------  ..........   ---------------------   |
162         |                 ..........                       |   V
163     P   ----------------------------------------------------  --- 
164     A   |                 ..........                       |   ^
165     R   ----------------  ..........   ---------------------   |
166     T   |                 ..........                       | Alternate Blocks
167     I   ----------------  ..........   --------------------    |
168     T   |                 ..........                       |   V
169     I   ----------------------------------------------------  ---
170     O   |  Unix root partition starts from here            |
171     N   ----------------                   -----------------
172         |                                                  |
173         ----------------------------------------------------
174         |                                                  |
175         ----------------------------------------------------
176         |                                                  |
177     |   ---------------------------------------------------
178     |   |                                                  |
179     |   ----------------------------------------------------
180     V   |                                                  |
181    ===============================================================
182         |                   ........                       |
183         ---------------     ........          --------------
184         |                   ........                       |
185         ----------------------------------------------------
186
187
188         The bad block handling mechanism is as follows:
189
190         * Use the alternate track in the alternate tracks area if the
191           track containing the target sector is bad.
192
193         * Use the alternate block in the alternate blocks area if the
194           target sector is bad.
195
196
197
198
199 6. How to make:
200    -----------
201
202         Since the kernel image is loaded above 1 MB, the kernel must start
203         as protected mode.  This means that this bootstrap loader will work
204         only when the corresponding changes on the kernel startup code are done.
205
206         The make command to generate this bootstrap loader is:
207
208         make -f boot.mk fdboot      (floppy boot loader)
209         make -f boot.mk hdboot      (wini boot loader)
210 [to make 386bsd bootblocks  "make da wd" (warning: they will be installed
211 in /dev/mdec.. take backups)]