sdb00t.ahdi.S revision 1.1 1 /* $NetBSD: sdb00t.ahdi.S,v 1.1 2003/10/28 11:34:59 he Exp $ */
2
3 /*
4 * Copyright (c) 1995 Waldi Ravens
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Waldi Ravens.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include "xxboot.h"
34
35 #ifdef __ELF__
36 .globl _start, main, fill
37
38 .text
39
40 _start: bras main
41 #else
42 .globl start, main, fill
43
44 .text
45
46 start: bras main
47 #endif
48 bra rds0
49
50 main: bclr #2,(_drvbits+3):w
51 clrl pun_ptr:w
52 movml %d3/%d5,%sp@-
53 movw #-1,%sp@-
54 movw #Kbshift,%sp@-
55 trap #BIOS
56 addql #4,%sp
57 btst #3,%d0 | Alternate?
58 bnes exit
59 movq #3,%d0
60 lea %pc@(p0_dsc),%a0
61 cmpl #0x444d4172,%d3 | SCSI bootdev?
62 beqs 0f
63 movq #-1,%d4 | no, ACSI
64 movq #0,%d5
65 0: movb %d5,%d1 | NVRAM bootpref
66 bnes 1f
67
68 | The Hades bios does not provide a bootprev. In case
69 | of doubt, we fetch it ourselves.
70 moveml %d0-%d2/%a0-%a2,%sp@-
71 pea bpref
72 movw #1, %sp@-
73 movw #1, %sp@-
74 movw #0, %sp@-
75 movw #NVMaccess, %sp@-
76 trap #XBIOS
77 lea %sp@(12),%sp
78 moveml %sp@+,%d0-%d2/%a0-%a2
79 movb bpref:w,%d1
80 bnes 1f
81 movq #-8,%d1 | bootpref = any
82
83 1: movb %a0@,%d2 | bootflags
84 btst #0,%d2
85 beqs 2f
86 andb %d1,%d2
87 bnes boot
88 2: lea %a0@(12),%a0
89 dbra %d0,1b
90
91 exit: movml %sp@+,%d3/%d5
92 tostst: clrw _bootdev:w
93 movl _sysbase:w,%a0
94 movl %a0@(24),%d0
95 swap %d0
96 cmpl #0x19870422,%d0 | old TOS?
97 bccs 0f | no
98 movw #0xe0,%d7
99 0: rts
100
101 boot: movl %a0@(4),%d6
102 movq #1,%d5
103 lea %pc@(end),%a4
104 bsrs rds0
105 tstw %d0
106 bnes exit
107 movl %a4,%a0
108 movw #0xff,%d0
109 movq #0,%d1
110 0: addw %a0@+,%d1
111 dbra %d0,0b
112 cmpw #0x1234,%d1
113 bnes exit
114 lea %pc@(rds0),%a3
115 lea %pc@(tostst),%a5
116 movml %sp@+,%d3/%d5
117 jmp %a4@ | start bootsector code
118 /*
119 * in: d4/d7 (target) d5 (count), d6 (offset), a4 (buffer)
120 * out: d0 (<= 0)
121 * mod: d0, d1, d2, a0, a1, a5, a6
122 */
123 rds0: tstl %d4
124 bmis 0f
125 movw %d4,%sp@- | device
126 pea %a4@ | buffer
127 movw %d5,%sp@- | count
128 movl %d6,%sp@- | offset
129 movw #DMAread,%sp@-
130 trap #XBIOS
131 lea %sp@(14),%sp
132 rts
133
134 0: st flock:w
135 movl _hz_200:w,%d0
136 addql #2,%d0
137 1: cmpl _hz_200:w,%d0
138 bccs 1b
139 movml %d6/%a4,%sp@-
140 lea dmahi:w,%a6
141 movb %sp@(7),%a6@(4)
142 movb %sp@(6),%a6@(2)
143 movb %sp@(5),%a6@
144 lea %pc@(r0com),%a6
145 movb %sp@(1),%a6@(1)
146 movb %sp@(2),%a6@(5)
147 movb %sp@(3),%a6@(9)
148 movb %d5,%a6@(13)
149 addql #8,%sp
150 lea dmodus:w,%a6
151 lea daccess:w,%a5
152 movw #0x198,%a6@
153 movw #0x098,%a6@
154 movw %d5,%a5@
155 movw #0x88,%a6@
156 movq #0,%d0
157 movb %d7,%d0
158 orb #0x08,%d0
159 swap %d0
160 movw #0x8a,%d0
161 bsrs shake
162 lea %pc@(r0com),%a0
163 movq #3,%d2
164 2: movl %a0@+,%d0
165 bsrs shake
166 dbra %d2,2b
167 movq #0x0a,%d0
168 movl %d0,%a5@
169 movl #0x190,%d1
170 bsrs wait
171 movw #0x8a,%a6@
172 movw %a5@,%d0
173 andw #0xff,%d0
174 beqs 0f
175 r0err: movq #-1,%d0
176 0: movw #0x80,%a6@
177 clrb flock:w
178 r0ret: rts
179
180 shake: movl %d0,%a5@
181 movq #0x0a,%d1
182 wait: addl _hz_200:w,%d1
183 0: btst #5,gpip:w
184 beqs r0ret
185 cmpl _hz_200:w,%d1
186 bccs 0b
187 addql #4,%sp
188 bras r0err
189
190 r0com: .long 0x0000008a
191 .long 0x0000008a
192 .long 0x0000008a
193 .long 0x0001008a
194 bpref: .word 0
195
196 fill: .space 16
197
198 .ascii "NetBSD"
199 hd_siz: .long 0
200 p0_dsc: .long 0, 0, 0
201 p1_dsc: .long 0, 0, 0
202 p2_dsc: .long 0, 0, 0
203 p3_dsc: .long 0, 0, 0
204 bsl_st: .long 0
205 bsl_sz: .long 0
206 .word 0
207 end:
208