2 * Mach Operating System
3 * Copyright (c) 1992, 1991 Carnegie Mellon University
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.
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.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
26 * from: Mach, Revision 2.2 92/04/04 11:36:29 rpd
31 Copyright 1988, 1989, 1990, 1991, 1992
32 by Intel Corporation, Santa Clara, California.
36 Permission to use, copy, modify, and distribute this software and
37 its documentation for any purpose and without fee is hereby
38 granted, provided that the above copyright notice appears in all
39 copies and that both the copyright notice and this permission notice
40 appear in supporting documentation, and that the name of Intel
41 not be used in advertising or publicity pertaining to distribution
42 of the software without specific, written prior permission.
44 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
45 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
46 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
47 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
48 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
49 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
50 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
56 BOOTSEG = 0x9000 # boot will be loaded here (below 640K)
57 BOOTSTACK = 0xe000 # boot stack
59 LOADSZ = 15 # size of unix boot
60 PARTSTART = 0x1be # starting address of partition table
61 NUMPART = 4 # number of partitions in partition table
62 PARTSZ = 16 # each partition table entry is 16 bytes
63 BSDPART = 0xA5 # value of boot_ind, means bootable partition
64 BOOTABLE = 0x80 # value of boot_ind, means bootable partition
69 # start (aka boot1) is loaded at 0x0:0x7c00 but we want 0x7c0:0
70 # ljmp to the next instruction to adjust %cs
86 /*** set up %es, (where we will load boot2 to) ***/
96 # bootstrap passes us drive number in %dl
102 # reset the disk system
112 mov $0x0001, %ecx # cyl 0, sector 1
123 hd: /**** load sector 0 into the BOOTSEG ****/
132 xor %ebx, %ebx # %bx = 0
143 /*mov $0x0080, %edx*/
148 /***# find the first 386BSD partition *****/
155 movb %es:4(%ebx), %al
170 # BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
171 # Call with %ah = 0x2
172 # %al = number of sectors
176 # %dl = drive (0x80 for hard disk, 0x0 for floppy disk)
177 # %es:%bx = segment:offset of buffer
179 # %al = 0x0 on success; err code on failure
184 movb %es:1(%ebx), %dh /* head */
186 movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */
189 movb $0x2, %ah /* function 2 */
190 movb $LOADSZ, %al /* number of blocks */
191 xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */
196 # ljmp to the second stage boot loader (boot2).
197 # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used
198 # as an internal buffer "intbuf".
207 ljmp $BOOTSEG, $ EXT(boot2)
223 # message: write the error message in %ds:%esi to console
228 # Use BIOS "int 10H Function 0Eh" to write character in teletype mode
229 # %ah = 0xe %al = character
230 # %bh = page %bl = foreground color (graphics modes)
242 lodsb # load a byte into %al
247 int $0x10 # display a byte
260 jmp stop # halt doesnt actually halt forever
265 one: String "1\r\n\0"
266 two: String "2\r\n\0"
267 three: String "3\r\n\0"
268 four: String "4\r\n\0"
269 five: String "5\r\n\0"
270 six: String "6\r\n\0"
271 seven: String "7\r\n\0"
273 eread: String "Read error\r\n\0"
274 enoboot: String "No bootable partition\r\n\0"
276 /* throw in a partition in case we are block0 as well */
277 /* flag, head, sec, cyl, typ, ehead, esect, ecyl, start, len */
278 . = EXT(boot1) + PARTSTART
279 .byte 0x0,0,0,0,0,0,0,0
281 .byte 0x0,0,0,0,0,0,0,0
283 .byte 0x0,0,0,0,0,0,0,0
285 .byte BOOTABLE,0,1,0,BSDPART,255,255,255
287 /* the last 2 bytes in the sector 0 contain the signature */
288 . = EXT(boot1) + 0x1fe
291 . = EXT(boot1) + 0x400