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