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