1 ; $NetBSD: osiop.ss,v 1.1 2001/04/30 04:47:51 tsutsui Exp $
4 ; Copyright (c) 1995 Michael L. Hitch
7 ; Redistribution and use in source and binary forms, with or without
8 ; 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.
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.
16 ; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ABSOLUTE ds_Device = 0
33 ABSOLUTE ds_MsgOut = ds_Device + 8
34 ABSOLUTE ds_Cmd = ds_MsgOut + 8
35 ABSOLUTE ds_Status = ds_Cmd + 8
36 ABSOLUTE ds_Msg = ds_Status + 8
37 ABSOLUTE ds_MsgIn = ds_Msg + 8
38 ABSOLUTE ds_ExtMsg = ds_MsgIn + 8
39 ABSOLUTE ds_SyncMsg = ds_ExtMsg + 8
40 ABSOLUTE ds_Data1 = ds_SyncMsg + 8
41 ABSOLUTE ds_Data2 = ds_Data1 + 8
42 ABSOLUTE ds_Data3 = ds_Data2 + 8
43 ABSOLUTE ds_Data4 = ds_Data3 + 8
44 ABSOLUTE ds_Data5 = ds_Data4 + 8
45 ABSOLUTE ds_Data6 = ds_Data5 + 8
46 ABSOLUTE ds_Data7 = ds_Data6 + 8
47 ABSOLUTE ds_Data8 = ds_Data7 + 8
48 ABSOLUTE ds_Data9 = ds_Data8 + 8
49 ABSOLUTE ds_Data10 = ds_Data9 + 8
50 ABSOLUTE ds_Data11 = ds_Data10 + 8
51 ABSOLUTE ds_Data12 = ds_Data11 + 8
52 ABSOLUTE ds_Data13 = ds_Data12 + 8
53 ABSOLUTE ds_Data14 = ds_Data13 + 8
54 ABSOLUTE ds_Data15 = ds_Data14 + 8
55 ABSOLUTE ds_Data16 = ds_Data15 + 8
56 ABSOLUTE ds_Data17 = ds_Data16 + 8
60 ABSOLUTE int_disc = 0xff01
61 ABSOLUTE int_disc_wodp = 0xff02
62 ABSOLUTE int_reconnect = 0xff03
63 ABSOLUTE int_connect = 0xff04
64 ABSOLUTE int_phase = 0xff05
65 ABSOLUTE int_msgin = 0xff06
66 ABSOLUTE int_extmsg = 0xff07
67 ABSOLUTE int_msgsdp = 0xff08
68 ABSOLUTE int_identify = 0xff09
69 ABSOLUTE int_status = 0xff0a
70 ABSOLUTE int_syncmsg = 0xff0b
83 SELECT ATN FROM ds_Device, REL(reselect)
86 JUMP REL(msgin), WHEN MSG_IN
87 JUMP REL(msgout), IF MSG_OUT
88 JUMP REL(command_phase), IF CMD
89 JUMP REL(dataout), IF DATA_OUT
90 JUMP REL(datain), IF DATA_IN
91 JUMP REL(end), IF STATUS
93 INT int_phase ; Unrecognized phase
96 MOVE FROM ds_MsgIn, WHEN MSG_IN
97 JUMP REL(ext_msg), IF 0x01 ; extended message
98 JUMP REL(disc), IF 0x04 ; disconnect message
99 JUMP REL(msg_sdp), IF 0x02 ; save data pointers
100 JUMP REL(msg_rej), IF 0x07 ; message reject
101 JUMP REL(msg_rdp), IF 0x03 ; restore data pointers
102 INT int_msgin ; unrecognized message
105 ; Do we need to interrupt host here to let it handle the reject?
114 MOVE FROM ds_ExtMsg, WHEN MSG_IN
115 JUMP REL(sync_msg), IF 0x03
116 int int_extmsg ; extended message not SDTR
120 MOVE FROM ds_SyncMsg, WHEN MSG_IN
121 int int_syncmsg ; Let host handle the message
122 ; If we continue from the interrupt, the host has set up a response
123 ; message to be sent. Set ATN, clear ACK, and continue.
132 int int_disc_wodp ; signal disconnect w/o save DP
135 CLEAR ACK ; acknowledge message
136 JUMP REL(switch), WHEN NOT MSG_IN
137 MOVE FROM ds_ExtMsg, WHEN MSG_IN
138 INT int_msgsdp, IF NOT 0x04 ; interrupt if not disconnect
142 INT int_disc ; signal disconnect
146 WAIT RESELECT REL(select_adr)
147 MOVE LCRC to SFBR ; Save reselect ID
148 MOVE SFBR to SCRATCH0
150 INT int_identify, WHEN NOT MSG_IN
151 MOVE FROM ds_Msg, WHEN MSG_IN
152 INT int_reconnect ; let host know about reconnect
153 CLEAR ACK ; acknowlege the message
157 MOVE SCNTL1 & 0x10 to SFBR ; get connected status
158 INT int_connect, IF 0x00 ; tell host if not connected
159 MOVE CTEST2 & 0x40 to SFBR ; clear Sig_P
160 JUMP REL(wait_reselect) ; and try reselect again
163 MOVE FROM ds_MsgOut, WHEN MSG_OUT
168 MOVE FROM ds_Cmd, WHEN CMD
172 MOVE FROM ds_Data1, WHEN DATA_OUT
173 CALL REL(switch), WHEN NOT DATA_OUT
174 MOVE FROM ds_Data2, WHEN DATA_OUT
175 CALL REL(switch), WHEN NOT DATA_OUT
176 MOVE FROM ds_Data3, WHEN DATA_OUT
177 CALL REL(switch), WHEN NOT DATA_OUT
178 MOVE FROM ds_Data4, WHEN DATA_OUT
179 CALL REL(switch), WHEN NOT DATA_OUT
180 MOVE FROM ds_Data5, WHEN DATA_OUT
181 CALL REL(switch), WHEN NOT DATA_OUT
182 MOVE FROM ds_Data6, WHEN DATA_OUT
183 CALL REL(switch), WHEN NOT DATA_OUT
184 MOVE FROM ds_Data7, WHEN DATA_OUT
185 CALL REL(switch), WHEN NOT DATA_OUT
186 MOVE FROM ds_Data8, WHEN DATA_OUT
187 CALL REL(switch), WHEN NOT DATA_OUT
188 MOVE FROM ds_Data9, WHEN DATA_OUT
189 CALL REL(switch), WHEN NOT DATA_OUT
190 MOVE FROM ds_Data10, WHEN DATA_OUT
191 CALL REL(switch), WHEN NOT DATA_OUT
192 MOVE FROM ds_Data11, WHEN DATA_OUT
193 CALL REL(switch), WHEN NOT DATA_OUT
194 MOVE FROM ds_Data12, WHEN DATA_OUT
195 CALL REL(switch), WHEN NOT DATA_OUT
196 MOVE FROM ds_Data13, WHEN DATA_OUT
197 CALL REL(switch), WHEN NOT DATA_OUT
198 MOVE FROM ds_Data14, WHEN DATA_OUT
199 CALL REL(switch), WHEN NOT DATA_OUT
200 MOVE FROM ds_Data15, WHEN DATA_OUT
201 CALL REL(switch), WHEN NOT DATA_OUT
202 MOVE FROM ds_Data16, WHEN DATA_OUT
203 CALL REL(switch), WHEN NOT DATA_OUT
204 MOVE FROM ds_Data17, WHEN DATA_OUT
208 MOVE FROM ds_Data1, WHEN DATA_IN
209 CALL REL(switch), WHEN NOT DATA_IN
210 MOVE FROM ds_Data2, WHEN DATA_IN
211 CALL REL(switch), WHEN NOT DATA_IN
212 MOVE FROM ds_Data3, WHEN DATA_IN
213 CALL REL(switch), WHEN NOT DATA_IN
214 MOVE FROM ds_Data4, WHEN DATA_IN
215 CALL REL(switch), WHEN NOT DATA_IN
216 MOVE FROM ds_Data5, WHEN DATA_IN
217 CALL REL(switch), WHEN NOT DATA_IN
218 MOVE FROM ds_Data6, WHEN DATA_IN
219 CALL REL(switch), WHEN NOT DATA_IN
220 MOVE FROM ds_Data7, WHEN DATA_IN
221 CALL REL(switch), WHEN NOT DATA_IN
222 MOVE FROM ds_Data8, WHEN DATA_IN
223 CALL REL(switch), WHEN NOT DATA_IN
224 MOVE FROM ds_Data9, WHEN DATA_IN
225 CALL REL(switch), WHEN NOT DATA_IN
226 MOVE FROM ds_Data10, WHEN DATA_IN
227 CALL REL(switch), WHEN NOT DATA_IN
228 MOVE FROM ds_Data11, WHEN DATA_IN
229 CALL REL(switch), WHEN NOT DATA_IN
230 MOVE FROM ds_Data12, WHEN DATA_IN
231 CALL REL(switch), WHEN NOT DATA_IN
232 MOVE FROM ds_Data13, WHEN DATA_IN
233 CALL REL(switch), WHEN NOT DATA_IN
234 MOVE FROM ds_Data14, WHEN DATA_IN
235 CALL REL(switch), WHEN NOT DATA_IN
236 MOVE FROM ds_Data15, WHEN DATA_IN
237 CALL REL(switch), WHEN NOT DATA_IN
238 MOVE FROM ds_Data16, WHEN DATA_IN
239 CALL REL(switch), WHEN NOT DATA_IN
240 MOVE FROM ds_Data17, WHEN DATA_IN
244 MOVE FROM ds_Status, WHEN STATUS
245 int int_status, WHEN NOT MSG_IN ; status not followed by msg
246 MOVE FROM ds_Msg, WHEN MSG_IN
249 INT ok ; signal completion
250 JUMP REL(wait_reselect)