1 # Copyright (c) KATO Takenori, 1999, 2000.
3 # All rights reserved. Unpublished rights reserved under the copyright
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer as
12 # the first lines of this file unmodified.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 # $FreeBSD: src/sys/boot/pc98/boot0.5/boot.s,v 1.2 2000/08/03 13:01:45 kato Exp $
29 # $DragonFly: src/sys/boot/pc98/boot0.5/Attic/boot.s,v 1.3 2003/11/10 06:08:38 dillon Exp $
37 # Read bootstrap program and jump to it.
40 # Step 1: Save parameters
45 movw secsize(%si), %ax
48 movw curpartition, %si
49 movb partnum(%si), %al # %al = real partition number
51 movw %ax, b_partn # save real parttion number
53 shlw %cl, %si # %si = offset to parttable
55 movb parttable(%si), %al # IPLS
58 movb parttable(%si), %al # IPLH
61 movw parttable(%si), %ax
64 # Step 2: Calculate egment address of bootstrap routine
73 # Step 3: Read bootstrap code
86 # Step 4: Set DA/UA into BIOS work area
89 movw $0x584, %bx # DISK_BOOT
94 # Step 5: Set registers
97 # %bx: Sector size * 2
98 # %cx: cylinder number of boot partition
99 # %si: pointer to partition table
102 shl %cl, %ax # %ax = partition number * 32
104 movw %ax, %si # %si = pointer to partition table
105 movw b_cylinder, %cx # %cx = cylinder
106 movb b_head, %dh # %dh = head
107 movb b_sector, %dl # %dl = sector
108 movw b_bootseg, %es # %es = boot segment
109 movb b_daua, %al # %al = DA/UA
111 shlw %bx # %bx = sector size * 2
113 movw %cs:iniss, %ss # Restore stack pointer
115 push %es # Boot segment
118 movw %ax, %di # Save %ax
120 movw %ax, %ds # %ds = 0
121 movw %di, %ax # Restore %ax
122 xorb %ah, %ah # %ah = 0
123 xorw %di, %di # %di = 0
126 # Jump to bootstrap code
134 # Try to boot from default partition.
147 cmpb $0x80, defpartflag
149 # Default partition is defined.
155 movb defpartnum, %al # %al = real partition number
156 cmpb partnum(%bx), %al
158 movw %bx, curpartition # Store partition number
169 b_daua: .byte 0 # DA/UA
170 b_head: .byte 0 # SYSH
171 b_sector: .byte 0 # SYSS
172 b_cylinder: .word 0 # SYSC
175 b_partn: .word 0 # Real partition number