1 ; $NetBSD: siop2_script.ss,v 1.6 2005/12/11 12:16:28 christos Exp $
4 ; Copyright (c) 1998 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_NegMsg = ds_ExtMsg + 8
40 ABSOLUTE ds_Data1 = ds_NegMsg + 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 MOVE GPREG | 0x10 TO GPREG
78 JUMP REL(msgin), WHEN MSG_IN
79 JUMP REL(msgout), IF MSG_OUT
80 JUMP REL(command_phase), IF CMD
81 JUMP REL(dataout), IF DATA_OUT
82 JUMP REL(datain), IF DATA_IN
83 JUMP REL(end), IF STATUS
85 INT err5 ; Unrecognized phase
88 MOVE FROM ds_MsgIn, WHEN MSG_IN
89 JUMP REL(ext_msg), IF 0x01 ; extended message
90 JUMP REL(disc), IF 0x04 ; disconnect message
91 JUMP REL(msg_sdp), IF 0x02 ; save data pointers
92 JUMP REL(msg_rej), IF 0x07 ; message reject
93 JUMP REL(msg_rdp), IF 0x03 ; restore data pointers
94 INT err6 ; unrecognized message
97 ; Do we need to interrupt host here to let it handle the reject?
106 MOVE FROM ds_ExtMsg, WHEN MSG_IN
107 JUMP REL(neg_msg), IF 0x03 ; extended message might be SDTR
108 JUMP REL(neg_msg), IF 0x02 ; extended message might be WDTR
109 INT err7 ; extended message not SDTR
113 MOVE FROM ds_NegMsg, WHEN MSG_IN
114 INT err11 ; Let host handle the message
115 ; If we continue from the interrupt, the host has set up a response
116 ; message to be sent. Set ATN, clear ACK, and continue.
122 MOVE SCNTL2 & 0x7f TO SCNTL2
123 MOVE GPREG & 0xEF TO GPREG
127 INT err2 ; signal disconnect w/o save DP
130 CLEAR ACK ; acknowledge message
131 JUMP REL(switch), WHEN NOT MSG_IN
132 MOVE FROM ds_ExtMsg, WHEN MSG_IN
133 INT err8, IF NOT 0x04 ; interrupt if not disconnect
134 MOVE SCNTL2 & 0x7f TO SCNTL2
138 INT err1 ; signal disconnect
142 WAIT RESELECT REL(select_adr)
143 MOVE SSID & 0x8f to SFBR ; Save reselect ID
144 MOVE SFBR to SCRATCHA0
146 INT err9, WHEN NOT MSG_IN ; didn't get IDENTIFY
147 MOVE FROM ds_Msg, WHEN MSG_IN
148 INT err3 ; let host know about reconnect
149 CLEAR ACK ; acknowlege the message
154 MOVE SCNTL1 & 0x10 to SFBR ; get connected status
155 INT err4, IF 0x00 ; tell host if not connected
156 MOVE CTEST2 & 0x40 to SFBR ; clear Sig_P
157 JUMP REL(wait_reselect) ; and try reselect again
160 MOVE FROM ds_MsgOut, WHEN MSG_OUT
165 MOVE FROM ds_Cmd, WHEN CMD
169 MOVE FROM ds_Data1, WHEN DATA_OUT
170 CALL REL(switch), WHEN NOT DATA_OUT
171 MOVE FROM ds_Data2, WHEN DATA_OUT
172 CALL REL(switch), WHEN NOT DATA_OUT
173 MOVE FROM ds_Data3, WHEN DATA_OUT
174 CALL REL(switch), WHEN NOT DATA_OUT
175 MOVE FROM ds_Data4, WHEN DATA_OUT
176 CALL REL(switch), WHEN NOT DATA_OUT
177 MOVE FROM ds_Data5, WHEN DATA_OUT
178 CALL REL(switch), WHEN NOT DATA_OUT
179 MOVE FROM ds_Data6, WHEN DATA_OUT
180 CALL REL(switch), WHEN NOT DATA_OUT
181 MOVE FROM ds_Data7, WHEN DATA_OUT
182 CALL REL(switch), WHEN NOT DATA_OUT
183 MOVE FROM ds_Data8, WHEN DATA_OUT
184 CALL REL(switch), WHEN NOT DATA_OUT
185 MOVE FROM ds_Data9, WHEN DATA_OUT
189 MOVE FROM ds_Data1, WHEN DATA_IN
190 CALL REL(switch), WHEN NOT DATA_IN
191 MOVE FROM ds_Data2, WHEN DATA_IN
192 CALL REL(switch), WHEN NOT DATA_IN
193 MOVE FROM ds_Data3, WHEN DATA_IN
194 CALL REL(switch), WHEN NOT DATA_IN
195 MOVE FROM ds_Data4, WHEN DATA_IN
196 CALL REL(switch), WHEN NOT DATA_IN
197 MOVE FROM ds_Data5, WHEN DATA_IN
198 CALL REL(switch), WHEN NOT DATA_IN
199 MOVE FROM ds_Data6, WHEN DATA_IN
200 CALL REL(switch), WHEN NOT DATA_IN
201 MOVE FROM ds_Data7, WHEN DATA_IN
202 CALL REL(switch), WHEN NOT DATA_IN
203 MOVE FROM ds_Data8, WHEN DATA_IN
204 CALL REL(switch), WHEN NOT DATA_IN
205 MOVE FROM ds_Data9, WHEN DATA_IN
209 MOVE FROM ds_Status, WHEN STATUS
210 INT err10, WHEN NOT MSG_IN ; status not followed by msg
211 MOVE FROM ds_Msg, WHEN MSG_IN
212 MOVE SCNTL2 & 0x7f TO SCNTL2
215 MOVE GPREG & 0xEF TO GPREG
216 INT ok ; signal completion
217 JUMP REL(wait_reselect)