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