Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/doc/README

1/*
2 * Mach Operating System
3 * Copyright (c) 1990 Carnegie-Mellon University
4 * Copyright (c) 1989 Carnegie-Mellon University
5 * All rights reserved. The CMU software License Agreement specifies
6 * the terms and conditions for use and redistribution.
7 */
8
9AT386 Protected Mode Bootstrap Loader
10=====================================
11
121. Overview of Startup
13 -------------------
14
15After the system is rebooted, the BIOS bootstrap routine reads Sector
161, Track 0 into memory at location 0000:7C00H. If location 0000:7DFEH
17(last two bytes of that sector) contains the value AA55H, the BIOS
18bootstrap routine will transfer control to 0000:7C00H. Otherwise, the
19boot code in that sector is bad and the boot routine stops.
20
21For DOS compatibility reason, one extra stage of boot is required if
22the boot device is a hard disk. The first sector of the hard disk will
23contain the MOS-DOS boot code and a boot record partition table.
24When this sector is loaded into 0000:7C00H, it will relocate itself
25to somewhere else and then load the first sector of the active
26partition into 0000:7C00H. Both UNIX and DOS use the command "fdisk"
27to install this first sector into the hard disk and to manipulate
28the hard disk partitions.
29
30
31
322. The First Stage Bootstrap Loader
33 --------------------------------
34
35After startup, the first stage boot is loaded at 0000:7C00H. This
36first stage boot will load itself and the second stage boot into
37memory at location 0000:1000H. For floppy disks, the first cylinder
38is reserved as the boot cylinder, and the boot code (first and second)
39will be loaded from there. Currently, only double sided, high density
40(15 sectors per track) floppies are supported. For hard disks, the
41first 29 sectors of the active partition is reserved for boot code
42which will be loaded by the first stage boot. All the disk types
43recognized by BIOS are supported by this bootstrap loader.
44
45
46
473. The Second Stage Bootstrap Loader
48 --------------------------------
49
50After the boot code is loaded, the control is passed to the second
51stage bootstrap loader "boot2()". In order to be able to load the
52big kernel image (bigger than 512K or 640K, depends on the memory
53configuration), the second stage boot loader will run on the protected
54mode. This bootstarp loader does not have any stand alone device
55drivers, all the I/O's are through the BIOS calls. Since the first
56stage boot code will no longer be used at this moment, the memory
57location of the first stage boot code (0000:1000H to 0000:1200H) will
58be used as an internal buffer for BIOS calls. Immediately after this
59internal buffer is the GDT table for the second stage boot loader.
60Since this boot loader needs to switch back and forth between protected
61and real mode in order to use BIOS calls, the limit of the boot code
62and boot data segments must not be greater than 64K.
63
64The boot loader loads the kernel image at memory location above 1 MB
65to skip the memory hole between 521K/640K and 1MB. After the kernel
66is loaded, the boot loader stores the information in the stack and
67then passes control to kernel. Currently, the three information passed
68fromm the boot loader to the kernel are type of the boot device, size
69of the base memory and size of the extended memory.
70
71
724. The UNIX Startup
73 ----------------
74
75Since the boot loader loads the kernel image at memory location above
761MB, the kernel has to start as protected mode. In addition, the
77link editor description file (vuifile) has to indicate that
78the text and data segments start above 1MB. Also, the boot loader
79passes the infomation to the kernel through the stack.
80
81
825. Disk Layout and Bad Block Handling
83 ---------------------------------
84
85 The System V/386 Release 3.2 (AT) disk layout will be used as the disk
86 layout for the MACH System on the AT platform.
87
88 This disk layout is as follows:
89
90* Reserve the first sector of cylinder 0 for the DOS boot record which
91 contains the master boot code (446 bytes) and the partition table.
92 (Refer to DOS Technical Reference Manual page 9-6 to 9-10).
93
94* Reserve the first 29 sectors of the UNIX partition for the first
95 and the second stage bootstrap.
96
97* Reserve the 30th sector of the UNIX partition for the pdinfo and
98 the vtoc tables.
99
100* Reserve the 31st to the 34th sectors of the UNIX partition for the
101 bad track and the bad block mapping tables.
102
103* Reserve up to 253 consecutive tracks when required, beginning with
104 the 35th sector of the UNIX partition, for alternate tracks.
105
106* Reserve up to 253 consecutive blocks, beginning with the first
107 sector after the alternate tracks area, for alternate blocks.
108
109 SEC
110 1
111----------------------------------------------------
112| X | | CYL 0, TRK 0
113---------------- .......... --------------------
114| .......... |
115---------------- .......... --------------------
116| .......... |
117 ===============================================================
118 ^ | BOOTSTRAP | CYL N, TRK M
119 | ----------------------------------------------------
120 | | |30 |31 |32 |33 |34 |
121---------------------------------------------------- ---
122 U | .......... | ^
123 N ---------------- .......... --------------------- |
124 I | .......... | Alternate Tracks
125 X ---------------- .......... --------------------- |
126 | .......... | V
127 P ---------------------------------------------------- ---
128 A | .......... | ^
129 R ---------------- .......... --------------------- |
130 T | .......... | Alternate Blocks
131 I ---------------- .......... -------------------- |
132 T | .......... | V
133 I ---------------------------------------------------- ---
134 O | Unix root partition starts from here |
135 N ---------------- -----------------
136 | |
137 ----------------------------------------------------
138 | |
139----------------------------------------------------
140| |
141 | ---------------------------------------------------
142 | | |
143 | ----------------------------------------------------
144 V | |
145 ===============================================================
146 | ........ |
147--------------- ........ --------------
148| ........ |
149----------------------------------------------------
150
151
152The bad block handling mechanism is as follows:
153
154* Use the alternate track in the alternate tracks area if the
155 track containing the target sector is bad.
156
157* Use the alternate block in the alternate blocks area if the
158 target sector is bad.
159
160
161
162
1636. How to make:
164 -----------
165
166Since the kernel image is loaded above 1 MB, the kernel must start
167as protected mode. This means that this bootstrap loader will work
168only when the corresponding changes on the kernel startup code are done.
169
170The make command to generate this bootstrap loader is:
171
172make -f boot.mk fdboot (floppy boot loader)
173make -f boot.mk hdboot (wini boot loader)
174

Archive Download this file

Revision: 2006