siop.ss revision 1.4 1 1.4 bouyer ; $NetBSD: siop.ss,v 1.4 2000/05/04 15:42:42 bouyer Exp $
2 1.3 bouyer
3 1.3 bouyer ;
4 1.3 bouyer ; Copyright (c) 2000 Manuel Bouyer.
5 1.3 bouyer ;
6 1.3 bouyer ; Redistribution and use in source and binary forms, with or without
7 1.3 bouyer ; modification, are permitted provided that the following conditions
8 1.3 bouyer ; are met:
9 1.3 bouyer ; 1. Redistributions of source code must retain the above copyright
10 1.3 bouyer ; notice, this list of conditions and the following disclaimer.
11 1.3 bouyer ; 2. Redistributions in binary form must reproduce the above copyright
12 1.3 bouyer ; notice, this list of conditions and the following disclaimer in the
13 1.3 bouyer ; documentation and/or other materials provided with the distribution.
14 1.3 bouyer ; 3. All advertising materials mentioning features or use of this software
15 1.3 bouyer ; must display the following acknowledgement:
16 1.3 bouyer ; This product includes software developed by Manuel Bouyer
17 1.3 bouyer ; 4. The name of the author may not be used to endorse or promote products
18 1.3 bouyer ; derived from this software without specific prior written permission.
19 1.3 bouyer ;
20 1.3 bouyer ; THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21 1.3 bouyer ; INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22 1.3 bouyer ; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 1.3 bouyer ; AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24 1.3 bouyer ; OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.3 bouyer ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.3 bouyer ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.3 bouyer ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.3 bouyer ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.3 bouyer ; POSSIBILITY OF SUCH DAMAGE.
30 1.3 bouyer ;
31 1.3 bouyer
32 1.1 bouyer ARCH 720
33 1.1 bouyer
34 1.2 bouyer ; offsets in sym_xfer
35 1.4 bouyer ABSOLUTE t_id = 24;
36 1.4 bouyer ABSOLUTE t_msg_in = 32;
37 1.4 bouyer ABSOLUTE t_ext_msg_in = 40;
38 1.4 bouyer ABSOLUTE t_ext_msg_data = 48;
39 1.4 bouyer ABSOLUTE t_ext_msg_tag = 56;
40 1.4 bouyer ABSOLUTE t_msg_out = 64;
41 1.4 bouyer ABSOLUTE t_cmd = 72;
42 1.4 bouyer ABSOLUTE t_status = 80;
43 1.4 bouyer ABSOLUTE t_data = 88;
44 1.1 bouyer
45 1.1 bouyer ;; interrupt codes
46 1.1 bouyer ABSOLUTE int_done = 0xff00;
47 1.1 bouyer ABSOLUTE int_msgin = 0xff01;
48 1.2 bouyer ABSOLUTE int_extmsgin = 0xff02;
49 1.2 bouyer ABSOLUTE int_extmsgdata = 0xff03;
50 1.2 bouyer ABSOLUTE int_resel = 0xff04;
51 1.2 bouyer ABSOLUTE int_reseltag = 0xff05;
52 1.2 bouyer ABSOLUTE int_resfail = 0xff06;
53 1.2 bouyer ABSOLUTE int_disc = 0xff07;
54 1.1 bouyer ABSOLUTE int_err = 0xffff;
55 1.1 bouyer
56 1.1 bouyer ; flags for scratcha0
57 1.1 bouyer ABSOLUTE flag_sdp = 0x01 ; got save data pointer
58 1.4 bouyer ABSOLUTE flag_data = 0x02 ; we're in data phase
59 1.4 bouyer ABSOLUTE flag_data_mask = 0xfd ; ~flag_data
60 1.1 bouyer
61 1.1 bouyer ENTRY waitphase;
62 1.2 bouyer ENTRY send_msgout;
63 1.1 bouyer ENTRY msgout;
64 1.1 bouyer ENTRY msgin;
65 1.2 bouyer ENTRY msgin_ack;
66 1.1 bouyer ENTRY dataout;
67 1.1 bouyer ENTRY datain;
68 1.1 bouyer ENTRY cmdout;
69 1.1 bouyer ENTRY status;
70 1.1 bouyer ENTRY disconnect;
71 1.1 bouyer ENTRY reselect;
72 1.2 bouyer ENTRY selected;
73 1.2 bouyer ENTRY get_extmsgdata;
74 1.2 bouyer ENTRY sheduler;
75 1.2 bouyer ENTRY slot;
76 1.2 bouyer ENTRY idsa0;
77 1.2 bouyer ENTRY idsa1;
78 1.2 bouyer ENTRY idsa2;
79 1.2 bouyer ENTRY idsa3;
80 1.2 bouyer ENTRY slotdata;
81 1.2 bouyer ENTRY nextslot;
82 1.2 bouyer ENTRY endslot;
83 1.2 bouyer
84 1.2 bouyer EXTERN slot_nextp;
85 1.2 bouyer EXTERN slot_shed_addrsrc;
86 1.2 bouyer EXTERN slot_abs_reselect;
87 1.2 bouyer EXTERN slot_abs_selected;
88 1.2 bouyer
89 1.2 bouyer EXTERN endslot_abs_reselect;
90 1.1 bouyer
91 1.1 bouyer PROC siop_script:
92 1.1 bouyer
93 1.2 bouyer selected:
94 1.1 bouyer ; starting a new session, init 'local variables'
95 1.1 bouyer MOVE 0 to SCRATCHA0 ; flags
96 1.1 bouyer MOVE 0 to SCRATCHA1 ; DSA offset (for S/G save data pointer)
97 1.1 bouyer waitphase:
98 1.1 bouyer JUMP REL(msgout), WHEN MSG_OUT;
99 1.1 bouyer JUMP REL(msgin), WHEN MSG_IN;
100 1.1 bouyer JUMP REL(dataout), WHEN DATA_OUT;
101 1.1 bouyer JUMP REL(datain), WHEN DATA_IN;
102 1.1 bouyer JUMP REL(cmdout), WHEN CMD;
103 1.1 bouyer JUMP REL(status), WHEN STATUS;
104 1.1 bouyer err:
105 1.1 bouyer INT int_err;
106 1.1 bouyer
107 1.1 bouyer reselect:
108 1.1 bouyer WAIT RESELECT REL(reselect_fail)
109 1.1 bouyer MOVE SSID & 0x8f to SFBR
110 1.1 bouyer MOVE SFBR to SCRATCHA0 ; save reselect ID
111 1.1 bouyer INT int_err, WHEN NOT MSG_IN;
112 1.1 bouyer MOVE FROM t_msg_in, WHEN MSG_IN;
113 1.1 bouyer CLEAR ACK;
114 1.1 bouyer INT int_resel;
115 1.1 bouyer
116 1.1 bouyer reselect_fail:
117 1.2 bouyer ; check that host asserted SIGP, this'll clear SIGP in ISTAT
118 1.2 bouyer MOVE CTEST2 & 0x40 TO SFBR;
119 1.2 bouyer INT int_resfail, IF 0x00;
120 1.2 bouyer JUMP REL(sheduler);
121 1.1 bouyer
122 1.1 bouyer msgin:
123 1.1 bouyer CLEAR ATN
124 1.1 bouyer MOVE FROM t_msg_in, WHEN MSG_IN;
125 1.1 bouyer JUMP REL(handle_dis), IF 0x04 ; disconnect message
126 1.1 bouyer JUMP REL(handle_cmpl), IF 0x00 ; command complete message
127 1.1 bouyer JUMP REL(handle_sdp), IF 0x02 ; save data pointer message
128 1.2 bouyer JUMP REL(handle_extin), IF 0x01 ; extended message
129 1.1 bouyer INT int_msgin;
130 1.2 bouyer msgin_ack:
131 1.2 bouyer CLEAR ACK;
132 1.2 bouyer JUMP REL(waitphase);
133 1.2 bouyer
134 1.2 bouyer ; entry point for msgout after a msgin or status phase
135 1.2 bouyer send_msgout:
136 1.2 bouyer SET ATN;
137 1.2 bouyer CLEAR ACK;
138 1.1 bouyer msgout:
139 1.1 bouyer MOVE FROM t_msg_out, WHEN MSG_OUT;
140 1.1 bouyer CLEAR ATN;
141 1.1 bouyer JUMP REL(waitphase);
142 1.1 bouyer cmdout:
143 1.1 bouyer MOVE FROM t_cmd, WHEN CMD;
144 1.1 bouyer JUMP REL(waitphase);
145 1.1 bouyer status:
146 1.1 bouyer MOVE FROM t_status, WHEN STATUS;
147 1.1 bouyer JUMP REL(waitphase);
148 1.1 bouyer datain:
149 1.1 bouyer CALL REL(savedsa);
150 1.4 bouyer MOVE SCRATCHA0 | flag_data TO SCRATCHA0;
151 1.1 bouyer datain_loop:
152 1.1 bouyer MOVE FROM t_data, WHEN DATA_IN;
153 1.1 bouyer MOVE SCRATCHA1 + 1 TO SCRATCHA1 ; adjust offset
154 1.1 bouyer MOVE DSA0 + 8 to DSA0;
155 1.1 bouyer MOVE DSA1 + 0 to DSA1 WITH CARRY;
156 1.1 bouyer MOVE DSA2 + 0 to DSA2 WITH CARRY;
157 1.1 bouyer MOVE DSA3 + 0 to DSA3 WITH CARRY;
158 1.1 bouyer JUMP REL(datain_loop), WHEN DATA_IN;
159 1.1 bouyer CALL REL(restoredsa);
160 1.4 bouyer MOVE SCRATCHA0 & flag_data_mask TO SCRATCHA0;
161 1.1 bouyer JUMP REL(waitphase);
162 1.1 bouyer
163 1.1 bouyer dataout:
164 1.1 bouyer CALL REL(savedsa);
165 1.4 bouyer MOVE SCRATCHA0 | flag_data TO SCRATCHA0;
166 1.1 bouyer dataout_loop:
167 1.1 bouyer MOVE FROM t_data, WHEN DATA_OUT;
168 1.1 bouyer MOVE SCRATCHA1 + 1 TO SCRATCHA1 ; adjust offset
169 1.1 bouyer MOVE DSA0 + 8 to DSA0;
170 1.1 bouyer MOVE DSA1 + 0 to DSA1 WITH CARRY;
171 1.1 bouyer MOVE DSA2 + 0 to DSA2 WITH CARRY;
172 1.1 bouyer MOVE DSA3 + 0 to DSA3 WITH CARRY;
173 1.1 bouyer JUMP REL(dataout_loop), WHEN DATA_OUT;
174 1.1 bouyer CALL REL(restoredsa);
175 1.4 bouyer MOVE SCRATCHA0 & flag_data_mask TO SCRATCHA0;
176 1.1 bouyer JUMP REL(waitphase);
177 1.1 bouyer
178 1.1 bouyer savedsa:
179 1.1 bouyer MOVE DSA0 to SFBR;
180 1.1 bouyer MOVE SFBR to SCRATCHB0;
181 1.1 bouyer MOVE DSA1 to SFBR;
182 1.1 bouyer MOVE SFBR to SCRATCHB1;
183 1.1 bouyer MOVE DSA2 to SFBR;
184 1.1 bouyer MOVE SFBR to SCRATCHB2;
185 1.1 bouyer MOVE DSA3 to SFBR;
186 1.1 bouyer MOVE SFBR to SCRATCHB3;
187 1.1 bouyer RETURN;
188 1.1 bouyer
189 1.1 bouyer restoredsa:
190 1.1 bouyer MOVE SCRATCHB0 TO SFBR;
191 1.1 bouyer MOVE SFBR TO DSA0;
192 1.1 bouyer MOVE SCRATCHB1 TO SFBR;
193 1.1 bouyer MOVE SFBR TO DSA1;
194 1.1 bouyer MOVE SCRATCHB2 TO SFBR;
195 1.1 bouyer MOVE SFBR TO DSA2;
196 1.1 bouyer MOVE SCRATCHB3 TO SFBR;
197 1.1 bouyer MOVE SFBR TO DSA3;
198 1.1 bouyer RETURN;
199 1.1 bouyer
200 1.1 bouyer disconnect:
201 1.1 bouyer MOVE SCNTL2 & 0x7f TO SCNTL2;
202 1.1 bouyer CLEAR ATN;
203 1.1 bouyer CLEAR ACK;
204 1.1 bouyer WAIT DISCONNECT;
205 1.1 bouyer RETURN;
206 1.1 bouyer
207 1.1 bouyer handle_dis:
208 1.1 bouyer CALL REL(disconnect);
209 1.1 bouyer ; if we didn't get sdp, or if offset is 0, no need to interrupt
210 1.1 bouyer MOVE SCRATCHA0 & flag_sdp TO SFBR;
211 1.2 bouyer JUMP REL(sheduler), if 0x00;
212 1.1 bouyer MOVE SCRATCHA1 TO SFBR;
213 1.2 bouyer JUMP REL(sheduler), if 0x00;
214 1.1 bouyer ; Ok, we need to save data pointers
215 1.1 bouyer INT int_disc;
216 1.1 bouyer
217 1.1 bouyer handle_cmpl:
218 1.1 bouyer CALL REL(disconnect);
219 1.1 bouyer INT int_done;
220 1.1 bouyer handle_sdp:
221 1.1 bouyer CLEAR ACK;
222 1.1 bouyer MOVE SCRATCHA0 | flag_sdp TO SCRATCHA0;
223 1.1 bouyer JUMP REL(msgin) ; should get a disconnect message now
224 1.2 bouyer
225 1.2 bouyer handle_extin:
226 1.2 bouyer CLEAR ACK;
227 1.2 bouyer INT int_err, IF NOT MSG_IN;
228 1.2 bouyer MOVE FROM t_ext_msg_in, WHEN MSG_IN;
229 1.2 bouyer INT int_extmsgin; /* let host fill in t_ext_msg_data */
230 1.2 bouyer get_extmsgdata:
231 1.2 bouyer CLEAR ACK;
232 1.2 bouyer INT int_err, IF NOT MSG_IN;
233 1.2 bouyer MOVE FROM t_ext_msg_data, WHEN MSG_IN;
234 1.2 bouyer INT int_extmsgdata;
235 1.2 bouyer
236 1.2 bouyer sheduler:
237 1.2 bouyer NOP; /* will be changed by the slot scripts */
238 1.2 bouyer
239 1.2 bouyer ; script used for the sheduler: when a slot is free the JUMP points to
240 1.2 bouyer ; the next slot so that instructions for this slot are not run.
241 1.2 bouyer ; once the CPU has set up the slot variables (DSA address) it changes
242 1.2 bouyer ; the JUMP address to 0 (so that it'll jump to the next instruction) and
243 1.2 bouyer ; this command will be processed next time the sheduler is executed.
244 1.2 bouyer ; When the target has been successfully selected the script changes the jump
245 1.2 bouyer ; addr back to the next slot, so that it's ignored the next time.
246 1.2 bouyer ;
247 1.2 bouyer
248 1.2 bouyer PROC slot_script:
249 1.2 bouyer slot:
250 1.2 bouyer JUMP REL(nextslot);
251 1.2 bouyer idsa0:
252 1.2 bouyer MOVE 0x00 to dsa0;
253 1.2 bouyer idsa1:
254 1.2 bouyer MOVE 0x01 to dsa1;
255 1.2 bouyer idsa2:
256 1.2 bouyer MOVE 0x02 to dsa2;
257 1.2 bouyer idsa3:
258 1.2 bouyer MOVE 0x03 to dsa3;
259 1.2 bouyer SELECT ATN FROM t_id, slot_abs_reselect;
260 1.2 bouyer MOVE MEMORY 4, slot_shed_addrsrc, slot_nextp;
261 1.2 bouyer JUMP slot_abs_selected;
262 1.2 bouyer slotdata:
263 1.2 bouyer NOP; slot variables: dsa & jumppatchp
264 1.2 bouyer nextslot: NOP; /* will be changed to the next slot entry
265 1.2 bouyer
266 1.2 bouyer PROC endslot_script:
267 1.2 bouyer JUMP endslot_abs_reselect;
268