* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
* Copyright (c) 1992, 1991 Carnegie Mellon University
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
* Carnegie Mellon requests users of this software to return to
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
* Revision 2.2 92/04/04 11:36:29 rpd
* Fix Intel Copyright as per B. Davies authorization.
* Need to zero dh on hd path; at least for an adaptec card.
* Fuse floppy and hd boot by using Int 21 to tell
* boot type (slightly dubious since Int 21 is DOS
* Revision 2.2 91/04/02 14:42:04 mbj
* Fix the BIG boot bug. We had missed a necessary data
* before a xor that was clearing a register used later
* Remember floppy type for swapgeneric
Copyright 1988, 1989, 1990, 1991, 1992
by Intel Corporation, Santa Clara, California.
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appears in all
copies and that both the copyright notice and this permission notice
appear in supporting documentation, and that the name of Intel
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
BOOTSEG = 0x9000 # boot will be loaded at 640k-64k
BOOTSTACK = 0xe000 # boot stack
LOADSZ = 14 # size of unix boot
PARTSTART = 0x1be # starting address of partition table
NUMPART = 4 # number of partitions in partition table
PARTSZ = 16 # each partition table entry is 16 bytes
BSDPART = 0xA5 # value of boot_ind, means bootable partition
BOOTABLE = 0x80 # value of boot_ind, means bootable partition
# boot1 is loaded at 0x0:0x7c00
# ljmp to the next instruction to set up %cs
/*** set up %es, (where we will load boot2 to) ***/
mov $0x0001, %ecx # cyl 0, sector 1
hd: /**** load sector 0 into the BOOTSEG ****/
/***# find the bootable partition *****/
# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
# %al = number of sectors
# %dl = drive (0x80 for hard disk, 0x0 for floppy disk)
# %es:%bx = segment:offset of buffer
# %al = 0x0 on success; err code on failure
movb %es:1(%ebx), %dh /* head */
movw %es:2(%ebx), %ecx /*sect,cyl (+ 2 bytes junk in top word )*/
movb $0x2, %ah /* function 2 */
movb $LOADSZ, %al /* number of blocks */
xor %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */
# ljmp to the second stage boot loader (boot2).
# After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used
# as an internal buffer "intbuf".
ljmp $BOOTSEG, $EXT(boot2)
# message: write the error message in %ds:%esi to console
# Use BIOS "int 10H Function 0Eh" to write character in teletype mode
# %ah = 0xe %al = character
# %bh = page %bl = foreground color (graphics modes)
lodsb # load a byte into %al
int $0x10 # display a byte
jmp stop # halt doesnt actually halt forever
eread: String "Read error\r\n\0"
enoboot: String "No bootable partition\r\n\0"
/* throw in a partition in case we are block0 as well */
/* flag,head,sec,cyl,typ,ehead,esect,ecyl,start,len */
. = EXT(boot1) + PARTSTART
.byte BOOTABLE,0,1,0,BSDPART,255,255,255
/* the last 2 bytes in the sector 0 contain the signature */