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.
36 # Read bootstrap program and jump to it.
39 # Step 1: Save parameters
44 movw secsize(%si), %ax
47 movw curpartition, %si
48 movb partnum(%si), %al # %al = real partition number
50 movw %ax, b_partn # save real parttion number
52 shlw %cl, %si # %si = offset to parttable
54 movb parttable(%si), %al # IPLS
57 movb parttable(%si), %al # IPLH
60 movw parttable(%si), %ax
63 # Step 2: Calculate the segment address of the bootstrap routine
72 # Step 3: Read bootstrap code
85 # Step 4: Set DA/UA into BIOS work area
88 movw $0x584, %bx # DISK_BOOT
93 # Step 5: Set registers
96 # %bx: Sector size * 2
97 # %cx: cylinder number of boot partition
98 # %si: pointer to partition table
101 shl %cl, %ax # %ax = partition number * 32
103 movw %ax, %si # %si = pointer to partition table
104 movw b_cylinder, %cx # %cx = cylinder
105 movb b_head, %dh # %dh = head
106 movb b_sector, %dl # %dl = sector
107 movw b_bootseg, %es # %es = boot segment
108 movb b_daua, %al # %al = DA/UA
110 shlw %bx # %bx = sector size * 2
112 movw %cs:iniss, %ss # Restore stack pointer
114 push %es # Boot segment
117 movw %ax, %di # Save %ax
119 movw %ax, %ds # %ds = 0
120 movw %di, %ax # Restore %ax
121 xorb %ah, %ah # %ah = 0
122 xorw %di, %di # %di = 0
125 # Jump to bootstrap code
133 # Try to boot from default partition.
146 cmpb $0x80, defpartflag
148 # Default partition is defined.
154 movb defpartnum, %al # %al = real partition number
155 cmpb partnum(%bx), %al
157 movw %bx, curpartition # Store partition number
168 b_daua: .byte 0 # DA/UA
169 b_head: .byte 0 # SYSH
170 b_sector: .byte 0 # SYSS
171 b_cylinder: .word 0 # SYSC
174 b_partn: .word 0 # Real partition number