1 ; $NetBSD: siop_script.ss,v 1.4 1999/03/26 22:50:26 mhitch 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 + 4
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
51 ABSOLUTE err1 = 0xff01
52 ABSOLUTE err2 = 0xff02
53 ABSOLUTE err3 = 0xff03
54 ABSOLUTE err4 = 0xff04
55 ABSOLUTE err5 = 0xff05
56 ABSOLUTE err6 = 0xff06
57 ABSOLUTE err7 = 0xff07
58 ABSOLUTE err8 = 0xff08
59 ABSOLUTE err9 = 0xff09
60 ABSOLUTE err10 = 0xff0a
61 ABSOLUTE err11 = 0xff0b
74 SELECT ATN FROM ds_Device, REL(reselect)
77 JUMP REL(msgin), WHEN MSG_IN
78 JUMP REL(msgout), IF MSG_OUT
79 JUMP REL(command_phase), IF CMD
80 JUMP REL(dataout), IF DATA_OUT
81 JUMP REL(datain), IF DATA_IN
82 JUMP REL(end), IF STATUS
84 INT err5 ; Unrecognized phase
87 MOVE FROM ds_MsgIn, WHEN MSG_IN
88 JUMP REL(ext_msg), IF 0x01 ; extended message
89 JUMP REL(disc), IF 0x04 ; disconnect message
90 JUMP REL(msg_sdp), IF 0x02 ; save data pointers
91 JUMP REL(msg_rej), IF 0x07 ; message reject
92 JUMP REL(msg_rdp), IF 0x03 ; restore data pointers
93 INT err6 ; unrecognized message
96 ; Do we need to interrupt host here to let it handle the reject?
105 MOVE FROM ds_ExtMsg, WHEN MSG_IN
106 JUMP REL(sync_msg), IF 0x03
107 int err7 ; extended message not SDTR
111 MOVE FROM ds_SyncMsg, WHEN MSG_IN
112 int err11 ; Let host handle the message
113 ; If we continue from the interrupt, the host has set up a response
114 ; message to be sent. Set ATN, clear ACK, and continue.
123 int err2 ; signal disconnect w/o save DP
126 CLEAR ACK ; acknowledge message
127 JUMP REL(switch), WHEN NOT MSG_IN
128 MOVE FROM ds_ExtMsg, WHEN MSG_IN
129 INT err8, IF NOT 0x04 ; interrupt if not disconnect
133 INT err1 ; signal disconnect
137 WAIT RESELECT REL(select_adr)
138 MOVE LCRC to SFBR ; Save reselect ID
139 MOVE SFBR to SCRATCH0
141 INT err9, WHEN NOT MSG_IN ; didn't get IDENTIFY
142 MOVE FROM ds_Msg, WHEN MSG_IN
143 INT err3 ; let host know about reconnect
144 CLEAR ACK ; acknowlege the message
149 MOVE SCNTL1 & 0x10 to SFBR ; get connected status
150 INT err4, IF 0x00 ; tell host if not connected
151 MOVE CTEST2 & 0x40 to SFBR ; clear Sig_P
152 JUMP REL(wait_reselect) ; and try reselect again
155 MOVE FROM ds_MsgOut, WHEN MSG_OUT
160 MOVE FROM ds_Cmd, WHEN CMD
164 MOVE FROM ds_Data1, WHEN DATA_OUT
165 CALL REL(switch), WHEN NOT DATA_OUT
166 MOVE FROM ds_Data2, WHEN DATA_OUT
167 CALL REL(switch), WHEN NOT DATA_OUT
168 MOVE FROM ds_Data3, WHEN DATA_OUT
169 CALL REL(switch), WHEN NOT DATA_OUT
170 MOVE FROM ds_Data4, WHEN DATA_OUT
171 CALL REL(switch), WHEN NOT DATA_OUT
172 MOVE FROM ds_Data5, WHEN DATA_OUT
173 CALL REL(switch), WHEN NOT DATA_OUT
174 MOVE FROM ds_Data6, WHEN DATA_OUT
175 CALL REL(switch), WHEN NOT DATA_OUT
176 MOVE FROM ds_Data7, WHEN DATA_OUT
177 CALL REL(switch), WHEN NOT DATA_OUT
178 MOVE FROM ds_Data8, WHEN DATA_OUT
179 CALL REL(switch), WHEN NOT DATA_OUT
180 MOVE FROM ds_Data9, WHEN DATA_OUT
184 MOVE FROM ds_Data1, WHEN DATA_IN
185 CALL REL(switch), WHEN NOT DATA_IN
186 MOVE FROM ds_Data2, WHEN DATA_IN
187 CALL REL(switch), WHEN NOT DATA_IN
188 MOVE FROM ds_Data3, WHEN DATA_IN
189 CALL REL(switch), WHEN NOT DATA_IN
190 MOVE FROM ds_Data4, WHEN DATA_IN
191 CALL REL(switch), WHEN NOT DATA_IN
192 MOVE FROM ds_Data5, WHEN DATA_IN
193 CALL REL(switch), WHEN NOT DATA_IN
194 MOVE FROM ds_Data6, WHEN DATA_IN
195 CALL REL(switch), WHEN NOT DATA_IN
196 MOVE FROM ds_Data7, WHEN DATA_IN
197 CALL REL(switch), WHEN NOT DATA_IN
198 MOVE FROM ds_Data8, WHEN DATA_IN
199 CALL REL(switch), WHEN NOT DATA_IN
200 MOVE FROM ds_Data9, WHEN DATA_IN
204 MOVE FROM ds_Status, WHEN STATUS
205 int err10, WHEN NOT MSG_IN ; status not followed by msg
206 MOVE FROM ds_Msg, WHEN MSG_IN
209 INT ok ; signal completion
210 JUMP REL(wait_reselect)