1; $OpenBSD: osiop.ss,v 1.3 2023/01/04 10:05:44 jsg Exp $ 2; $NetBSD: osiop.ss,v 1.1 2001/04/30 04:47:51 tsutsui Exp $ 3 4; 5; Copyright (c) 1995 Michael L. Hitch 6; All rights reserved. 7; 8; Redistribution and use in source and binary forms, with or without 9; modification, are permitted provided that the following conditions 10; are met: 11; 1. Redistributions of source code must retain the above copyright 12; notice, this list of conditions and the following disclaimer. 13; 2. Redistributions in binary form must reproduce the above copyright 14; notice, this list of conditions and the following disclaimer in the 15; documentation and/or other materials provided with the distribution. 16; 17; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27; 28 29; NCR 53c710 script 30; 31ARCH 710 32; 33ABSOLUTE ds_Device = 0 34ABSOLUTE ds_MsgOut = ds_Device + 8 35ABSOLUTE ds_Cmd = ds_MsgOut + 8 36ABSOLUTE ds_Status = ds_Cmd + 8 37ABSOLUTE ds_Msg = ds_Status + 8 38ABSOLUTE ds_MsgIn = ds_Msg + 8 39ABSOLUTE ds_ExtMsg = ds_MsgIn + 8 40ABSOLUTE ds_SyncMsg = ds_ExtMsg + 8 41ABSOLUTE ds_Data1 = ds_SyncMsg + 8 42ABSOLUTE ds_Data2 = ds_Data1 + 8 43ABSOLUTE ds_Data3 = ds_Data2 + 8 44ABSOLUTE ds_Data4 = ds_Data3 + 8 45ABSOLUTE ds_Data5 = ds_Data4 + 8 46ABSOLUTE ds_Data6 = ds_Data5 + 8 47ABSOLUTE ds_Data7 = ds_Data6 + 8 48ABSOLUTE ds_Data8 = ds_Data7 + 8 49ABSOLUTE ds_Data9 = ds_Data8 + 8 50ABSOLUTE ds_Data10 = ds_Data9 + 8 51ABSOLUTE ds_Data11 = ds_Data10 + 8 52ABSOLUTE ds_Data12 = ds_Data11 + 8 53ABSOLUTE ds_Data13 = ds_Data12 + 8 54ABSOLUTE ds_Data14 = ds_Data13 + 8 55ABSOLUTE ds_Data15 = ds_Data14 + 8 56ABSOLUTE ds_Data16 = ds_Data15 + 8 57ABSOLUTE ds_Data17 = ds_Data16 + 8 58 59 60ABSOLUTE ok = 0xff00 61ABSOLUTE int_disc = 0xff01 62ABSOLUTE int_disc_wodp = 0xff02 63ABSOLUTE int_reconnect = 0xff03 64ABSOLUTE int_connect = 0xff04 65ABSOLUTE int_phase = 0xff05 66ABSOLUTE int_msgin = 0xff06 67ABSOLUTE int_extmsg = 0xff07 68ABSOLUTE int_msgsdp = 0xff08 69ABSOLUTE int_identify = 0xff09 70ABSOLUTE int_status = 0xff0a 71ABSOLUTE int_syncmsg = 0xff0b 72 73ENTRY scripts 74ENTRY switch 75ENTRY wait_reselect 76ENTRY dataout 77ENTRY datain 78ENTRY clear_ack 79 80PROC osiop_script: 81 82scripts: 83 84 SELECT ATN FROM ds_Device, REL(reselect) 85; 86switch: 87 JUMP REL(msgin), WHEN MSG_IN 88 JUMP REL(msgout), IF MSG_OUT 89 JUMP REL(command_phase), IF CMD 90 JUMP REL(dataout), IF DATA_OUT 91 JUMP REL(datain), IF DATA_IN 92 JUMP REL(end), IF STATUS 93 94 INT int_phase ; Unrecognized phase 95 96msgin: 97 MOVE FROM ds_MsgIn, WHEN MSG_IN 98 JUMP REL(ext_msg), IF 0x01 ; extended message 99 JUMP REL(disc), IF 0x04 ; disconnect message 100 JUMP REL(msg_sdp), IF 0x02 ; save data pointers 101 JUMP REL(msg_rej), IF 0x07 ; message reject 102 JUMP REL(msg_rdp), IF 0x03 ; restore data pointers 103 INT int_msgin ; unrecognized message 104 105msg_rej: 106; Do we need to interrupt host here to let it handle the reject? 107msg_rdp: 108clear_ack: 109 CLEAR ACK 110 CLEAR ATN 111 JUMP REL(switch) 112 113ext_msg: 114 CLEAR ACK 115 MOVE FROM ds_ExtMsg, WHEN MSG_IN 116 JUMP REL(sync_msg), IF 0x03 117 int int_extmsg ; extended message not SDTR 118 119sync_msg: 120 CLEAR ACK 121 MOVE FROM ds_SyncMsg, WHEN MSG_IN 122 int int_syncmsg ; Let host handle the message 123; If we continue from the interrupt, the host has set up a response 124; message to be sent. Set ATN, clear ACK, and continue. 125 SET ATN 126 CLEAR ACK 127 JUMP REL(switch) 128 129disc: 130 CLEAR ACK 131 WAIT DISCONNECT 132 133 int int_disc_wodp ; signal disconnect w/o save DP 134 135msg_sdp: 136 CLEAR ACK ; acknowledge message 137 JUMP REL(switch), WHEN NOT MSG_IN 138 MOVE FROM ds_ExtMsg, WHEN MSG_IN 139 INT int_msgsdp, IF NOT 0x04 ; interrupt if not disconnect 140 CLEAR ACK 141 WAIT DISCONNECT 142 143 INT int_disc ; signal disconnect 144 145reselect: 146wait_reselect: 147 WAIT RESELECT REL(select_adr) 148 MOVE LCRC to SFBR ; Save reselect ID 149 MOVE SFBR to SCRATCH0 150 151 INT int_identify, WHEN NOT MSG_IN 152 MOVE FROM ds_Msg, WHEN MSG_IN 153 INT int_reconnect ; let host know about reconnect 154 CLEAR ACK ; acknowledge the message 155 JUMP REL(switch) 156 157select_adr: 158 MOVE SCNTL1 & 0x10 to SFBR ; get connected status 159 INT int_connect, IF 0x00 ; tell host if not connected 160 MOVE CTEST2 & 0x40 to SFBR ; clear Sig_P 161 JUMP REL(wait_reselect) ; and try reselect again 162 163msgout: 164 MOVE FROM ds_MsgOut, WHEN MSG_OUT 165 JUMP REL(switch) 166 167command_phase: 168 CLEAR ATN 169 MOVE FROM ds_Cmd, WHEN CMD 170 JUMP REL(switch) 171 172dataout: 173 MOVE FROM ds_Data1, WHEN DATA_OUT 174 CALL REL(switch), WHEN NOT DATA_OUT 175 MOVE FROM ds_Data2, WHEN DATA_OUT 176 CALL REL(switch), WHEN NOT DATA_OUT 177 MOVE FROM ds_Data3, WHEN DATA_OUT 178 CALL REL(switch), WHEN NOT DATA_OUT 179 MOVE FROM ds_Data4, WHEN DATA_OUT 180 CALL REL(switch), WHEN NOT DATA_OUT 181 MOVE FROM ds_Data5, WHEN DATA_OUT 182 CALL REL(switch), WHEN NOT DATA_OUT 183 MOVE FROM ds_Data6, WHEN DATA_OUT 184 CALL REL(switch), WHEN NOT DATA_OUT 185 MOVE FROM ds_Data7, WHEN DATA_OUT 186 CALL REL(switch), WHEN NOT DATA_OUT 187 MOVE FROM ds_Data8, WHEN DATA_OUT 188 CALL REL(switch), WHEN NOT DATA_OUT 189 MOVE FROM ds_Data9, WHEN DATA_OUT 190 CALL REL(switch), WHEN NOT DATA_OUT 191 MOVE FROM ds_Data10, WHEN DATA_OUT 192 CALL REL(switch), WHEN NOT DATA_OUT 193 MOVE FROM ds_Data11, WHEN DATA_OUT 194 CALL REL(switch), WHEN NOT DATA_OUT 195 MOVE FROM ds_Data12, WHEN DATA_OUT 196 CALL REL(switch), WHEN NOT DATA_OUT 197 MOVE FROM ds_Data13, WHEN DATA_OUT 198 CALL REL(switch), WHEN NOT DATA_OUT 199 MOVE FROM ds_Data14, WHEN DATA_OUT 200 CALL REL(switch), WHEN NOT DATA_OUT 201 MOVE FROM ds_Data15, WHEN DATA_OUT 202 CALL REL(switch), WHEN NOT DATA_OUT 203 MOVE FROM ds_Data16, WHEN DATA_OUT 204 CALL REL(switch), WHEN NOT DATA_OUT 205 MOVE FROM ds_Data17, WHEN DATA_OUT 206 CALL REL(switch) 207 208datain: 209 MOVE FROM ds_Data1, WHEN DATA_IN 210 CALL REL(switch), WHEN NOT DATA_IN 211 MOVE FROM ds_Data2, WHEN DATA_IN 212 CALL REL(switch), WHEN NOT DATA_IN 213 MOVE FROM ds_Data3, WHEN DATA_IN 214 CALL REL(switch), WHEN NOT DATA_IN 215 MOVE FROM ds_Data4, WHEN DATA_IN 216 CALL REL(switch), WHEN NOT DATA_IN 217 MOVE FROM ds_Data5, WHEN DATA_IN 218 CALL REL(switch), WHEN NOT DATA_IN 219 MOVE FROM ds_Data6, WHEN DATA_IN 220 CALL REL(switch), WHEN NOT DATA_IN 221 MOVE FROM ds_Data7, WHEN DATA_IN 222 CALL REL(switch), WHEN NOT DATA_IN 223 MOVE FROM ds_Data8, WHEN DATA_IN 224 CALL REL(switch), WHEN NOT DATA_IN 225 MOVE FROM ds_Data9, WHEN DATA_IN 226 CALL REL(switch), WHEN NOT DATA_IN 227 MOVE FROM ds_Data10, WHEN DATA_IN 228 CALL REL(switch), WHEN NOT DATA_IN 229 MOVE FROM ds_Data11, WHEN DATA_IN 230 CALL REL(switch), WHEN NOT DATA_IN 231 MOVE FROM ds_Data12, WHEN DATA_IN 232 CALL REL(switch), WHEN NOT DATA_IN 233 MOVE FROM ds_Data13, WHEN DATA_IN 234 CALL REL(switch), WHEN NOT DATA_IN 235 MOVE FROM ds_Data14, WHEN DATA_IN 236 CALL REL(switch), WHEN NOT DATA_IN 237 MOVE FROM ds_Data15, WHEN DATA_IN 238 CALL REL(switch), WHEN NOT DATA_IN 239 MOVE FROM ds_Data16, WHEN DATA_IN 240 CALL REL(switch), WHEN NOT DATA_IN 241 MOVE FROM ds_Data17, WHEN DATA_IN 242 CALL REL(switch) 243 244end: 245 MOVE FROM ds_Status, WHEN STATUS 246 int int_status, WHEN NOT MSG_IN ; status not followed by msg 247 MOVE FROM ds_Msg, WHEN MSG_IN 248 CLEAR ACK 249 WAIT DISCONNECT 250 INT ok ; signal completion 251 JUMP REL(wait_reselect) 252