Removed all patch kit headers, sccsid and rcsid strings, put $Id$ in, some
[unix-history] / sys / i386 / boot / README.MACH
CommitLineData
15637ed4 1/*
15637ed4
RG
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.
e4270b63
RG
25 *
26 * from: Mach, Revision 2.2 92/04/04 11:33:55 rpd
27 * $Id$
15637ed4
RG
28 */
29
30********NOTE: This is not all relevant to the 386BSD version**********
31
32 AT386 Protected Mode Bootstrap Loader
33 =====================================
34
351. Overview of Startup
36 -------------------
37
38 After the system is rebooted, the BIOS bootstrap routine reads Sector
39 1, Track 0 into memory at location 0000:7C00H. If location 0000:7DFEH
40 (last two bytes of that sector) contains the value AA55H, the BIOS
41 bootstrap routine will transfer control to 0000:7C00H. Otherwise, the
42 boot code in that sector is bad and the boot routine stops.
43
44 For DOS compatibility reason, one extra stage of boot is required if
45 the boot device is a hard disk. The first sector of the hard disk will
46 contain the MOS-DOS boot code and a boot record partition table.
47 When this sector is loaded into 0000:7C00H, it will relocate itself
48 to somewhere else and then load the first sector of the active
49 partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk"
50[ 386bsd does not have an 'fdisk' (yet) ]
51 to install this first sector into the hard disk and to manipulate
52 the hard disk partitions.
53
54
55
562. The First Stage Bootstrap Loader
57 --------------------------------
58
59 After startup, the first stage boot is loaded at 0000:7C00H. This
60 first stage boot will load itself and the second stage boot into
61 memory at location 0000:1000H. For floppy disks, the first cylinder
62 is reserved as the boot cylinder, and the boot code (first and second)
63 will be loaded from there. Currently, only double sided, high density
64 (15 sectors per track) floppies are supported. For hard disks, the
65 first 29 sectors of the active partition is reserved for boot code
66 which will be loaded by the first stage boot. All the disk types
67 recognized by BIOS are supported by this bootstrap loader.
68[for 386bsd we load the second stage booter to 9000:0]
69
70
71
723. The Second Stage Bootstrap Loader
73 --------------------------------
74
75 After the boot code is loaded, the control is passed to the second
76 stage bootstrap loader "boot2()". In order to be able to load the
77 big kernel image (bigger than 512K or 640K, depends on the memory
78 configuration), the second stage boot loader will run on the protected
79 mode. This bootstarp loader does not have any stand alone device
80 drivers, all the I/O's are through the BIOS calls. Since the first
81 stage boot code will no longer be used at this moment, the memory
82 location of the first stage boot code (0000:1000H to 0000:1200H) will
83 be used as an internal buffer for BIOS calls. Immediately after this
84 internal buffer is the GDT table for the second stage boot loader.
85 Since this boot loader needs to switch back and forth between protected
86 and real mode in order to use BIOS calls, the limit of the boot code
87 and boot data segments must not be greater than 64K.
88
89 The boot loader loads the kernel image at memory location above 1 MB
90 to skip the memory hole between 521K/640K and 1MB. After the kernel
91 is loaded, the boot loader stores the information in the stack and
92 then passes control to kernel. Currently, the three information passed
93 fromm the boot loader to the kernel are type of the boot device, size
94 of the base memory and size of the extended memory.
95
96[ 386bsd receives: howto, bootdev]
97
98[ 386bsd is loaded where-ever the "MByte" bits of the load address specify,
99so if you link it for FE100000 it will load to 1MB, but if you link
100it for FE000000 it will load ad 0MB]
101
102[for machines with only 512KB normal ram the kernel will need to be linked
103for 1MB and the bootblocks modified to run below 512KB. (8000:0)]
104
105
1064. The UNIX Startup
107 ----------------
108
109 Since the boot loader loads the kernel image at memory location above
110 1MB, the kernel has to start as protected mode. In addition, the
111 link editor description file (vuifile) has to indicate that
112 the text and data segments start above 1MB. Also, the boot loader
113 passes the infomation to the kernel through the stack.
114
115[MOST of what is mentionned below is NOT relevant to 386bsd]
116
1175. Disk Layout and Bad Block Handling
118 ---------------------------------
119
120 The System V/386 Release 3.2 (AT) disk layout will be used as the disk
121 layout for the MACH System on the AT platform.
122
123 This disk layout is as follows:
124
125 * Reserve the first sector of cylinder 0 for the DOS boot record which
126 contains the master boot code (446 bytes) and the partition table.
127 (Refer to DOS Technical Reference Manual page 9-6 to 9-10).
128
129 * Reserve the first 29 sectors of the UNIX partition for the first
130 and the second stage bootstrap.
131
132 * Reserve the 30th sector of the UNIX partition for the pdinfo and
133 the vtoc tables.
134
135 * Reserve the 31st to the 34th sectors of the UNIX partition for the
136 bad track and the bad block mapping tables.
137
138 * Reserve up to 253 consecutive tracks when required, beginning with
139 the 35th sector of the UNIX partition, for alternate tracks.
140
141 * Reserve up to 253 consecutive blocks, beginning with the first
142 sector after the alternate tracks area, for alternate blocks.
143
144 SEC
145 1
146 ----------------------------------------------------
147 | X | | CYL 0, TRK 0
148 ---------------- .......... --------------------
149 | .......... |
150 ---------------- .......... --------------------
151 | .......... |
152 ===============================================================
153 ^ | BOOTSTRAP | CYL N, TRK M
154 | ----------------------------------------------------
155 | | |30 |31 |32 |33 |34 |
156 ---------------------------------------------------- ---
157 U | .......... | ^
158 N ---------------- .......... --------------------- |
159 I | .......... | Alternate Tracks
160 X ---------------- .......... --------------------- |
161 | .......... | V
162 P ---------------------------------------------------- ---
163 A | .......... | ^
164 R ---------------- .......... --------------------- |
165 T | .......... | Alternate Blocks
166 I ---------------- .......... -------------------- |
167 T | .......... | V
168 I ---------------------------------------------------- ---
169 O | Unix root partition starts from here |
170 N ---------------- -----------------
171 | |
172 ----------------------------------------------------
173 | |
174 ----------------------------------------------------
175 | |
176 | ---------------------------------------------------
177 | | |
178 | ----------------------------------------------------
179 V | |
180 ===============================================================
181 | ........ |
182 --------------- ........ --------------
183 | ........ |
184 ----------------------------------------------------
185
186
187 The bad block handling mechanism is as follows:
188
189 * Use the alternate track in the alternate tracks area if the
190 track containing the target sector is bad.
191
192 * Use the alternate block in the alternate blocks area if the
193 target sector is bad.
194
195
196
197
1986. How to make:
199 -----------
200
201 Since the kernel image is loaded above 1 MB, the kernel must start
202 as protected mode. This means that this bootstrap loader will work
203 only when the corresponding changes on the kernel startup code are done.
204
205 The make command to generate this bootstrap loader is:
206
207 make -f boot.mk fdboot (floppy boot loader)
208 make -f boot.mk hdboot (wini boot loader)
209[to make 386bsd bootblocks "make sd wd" (warning: they will be installed
210in /dev/mdec.. take backups)]