Merge from vendor branch ZLIB:
[dragonfly.git] / sys / boot / pc98 / boot0 / boot0.s
1 # Copyright (c) KATO Takenori, 1999, 2000.
2
3 # All rights reserved.  Unpublished rights reserved under the copyright
4 # laws of Japan.
5
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9
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.
16 # 3. The name of the author may not be used to endorse or promote products
17 #    derived from this software without specific prior written permission.
18
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #
30 # $FreeBSD: src/sys/boot/pc98/boot0/boot0.s,v 1.1 2000/08/02 08:46:08 kato Exp $
31 # $DragonFly: src/sys/boot/pc98/boot0/Attic/boot0.s,v 1.3 2003/11/10 06:08:37 dillon Exp $
32
33         .globl start
34         .code16
35 start:
36         jmp     main
37
38         .org    4
39         .ascii  "IPL1"
40         .byte   0, 0, 0
41
42         .globl start
43 main:
44         xor     %ax, %ax
45         mov     %ax, %ds
46         mov     (0x584), %al            # DA/UA
47         mov     %al, %ah
48         and     $0xf0, %ah
49         cmp     $0x90, %ah
50         je      fdd
51
52         # hdd
53         mov     $6, %ah
54         mov     $0x3000, %bx
55         mov     %bx, %es
56         mov     $0x2000, %bx
57         xor     %cx, %cx
58         xor     %dx, %dx
59         xor     %bp, %bp
60         int     $0x1b
61         jc      error_hdd
62
63         push    %ax
64         mov     %es, %ax
65         add     $0x40, %ax
66         mov     %ax, %es
67         pop     %ax
68         push    %es
69         push    %bp
70         lret
71
72         # fdd
73 fdd:
74         xor     %di, %di
75 fdd_retry:
76         mov     $0xd6, %ah
77         mov     $0x3000, %bx
78         mov     %bx, %es
79         mov     $0x2000, %bx
80         mov     $0x0200, %cx
81         mov     $0x0001, %dx
82         xor     %bp, %bp
83         int     $0x1b
84         jc      error
85         push    %ax
86         mov     %es, %ax
87         add     $0x40, %ax
88         mov     %ax, %es
89         pop     %ax
90         push    %es
91         push    %bp
92         lret
93
94 error:
95         or      %di, %di
96         jnz     error_hdd
97         and     $0x0f, %al
98         or      $0x30, %al
99         jmp     fdd_retry
100         
101 error_hdd:
102         jmp     error
103
104         .org    0x1fa
105         .byte   0                       # defflag_off
106         .byte   0                       # defpart_off
107         .byte   1                       # menu version
108         .byte   0
109         .word   0xaa55