xref: /netbsd/sys/arch/amiga/dev/siop_script.ss (revision 5bf26296)
1*5bf26296Smaya;	$NetBSD: siop_script.ss,v 1.6 2016/12/12 15:58:44 maya Exp $
2f1e1796cSchopps
3f1e1796cSchopps;
4f1e1796cSchopps; Copyright (c) 1995 Michael L. Hitch
5f1e1796cSchopps; All rights reserved.
6f1e1796cSchopps;
7f1e1796cSchopps; Redistribution and use in source and binary forms, with or without
8f1e1796cSchopps; modification, are permitted provided that the following conditions
9f1e1796cSchopps; are met:
10f1e1796cSchopps; 1. Redistributions of source code must retain the above copyright
11f1e1796cSchopps;    notice, this list of conditions and the following disclaimer.
12f1e1796cSchopps; 2. Redistributions in binary form must reproduce the above copyright
13f1e1796cSchopps;    notice, this list of conditions and the following disclaimer in the
14f1e1796cSchopps;    documentation and/or other materials provided with the distribution.
15f1e1796cSchopps;
16f1e1796cSchopps; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17f1e1796cSchopps; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18f1e1796cSchopps; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19f1e1796cSchopps; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20f1e1796cSchopps; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21f1e1796cSchopps; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22f1e1796cSchopps; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23f1e1796cSchopps; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24f1e1796cSchopps; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25f1e1796cSchopps; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26f1e1796cSchopps;
27f1e1796cSchopps
284726ce28Schopps; NCR 53c710 script
294726ce28Schopps;
3091d0eb55SmhitchARCH 710
3191d0eb55Smhitch;
324726ce28SchoppsABSOLUTE ds_Device	= 0
334726ce28SchoppsABSOLUTE ds_MsgOut 	= ds_Device + 4
344726ce28SchoppsABSOLUTE ds_Cmd		= ds_MsgOut + 8
354726ce28SchoppsABSOLUTE ds_Status	= ds_Cmd + 8
364726ce28SchoppsABSOLUTE ds_Msg		= ds_Status + 8
374726ce28SchoppsABSOLUTE ds_MsgIn	= ds_Msg + 8
384726ce28SchoppsABSOLUTE ds_ExtMsg	= ds_MsgIn + 8
394726ce28SchoppsABSOLUTE ds_SyncMsg	= ds_ExtMsg + 8
404726ce28SchoppsABSOLUTE ds_Data1	= ds_SyncMsg + 8
414726ce28SchoppsABSOLUTE ds_Data2	= ds_Data1 + 8
424726ce28SchoppsABSOLUTE ds_Data3	= ds_Data2 + 8
434726ce28SchoppsABSOLUTE ds_Data4	= ds_Data3 + 8
444726ce28SchoppsABSOLUTE ds_Data5	= ds_Data4 + 8
454726ce28SchoppsABSOLUTE ds_Data6	= ds_Data5 + 8
464726ce28SchoppsABSOLUTE ds_Data7	= ds_Data6 + 8
474726ce28SchoppsABSOLUTE ds_Data8	= ds_Data7 + 8
484726ce28SchoppsABSOLUTE ds_Data9	= ds_Data8 + 8
494726ce28Schopps
504726ce28SchoppsABSOLUTE ok		= 0xff00
514726ce28SchoppsABSOLUTE err1		= 0xff01
524726ce28SchoppsABSOLUTE err2		= 0xff02
534726ce28SchoppsABSOLUTE err3		= 0xff03
544726ce28SchoppsABSOLUTE err4		= 0xff04
554726ce28SchoppsABSOLUTE err5		= 0xff05
564726ce28SchoppsABSOLUTE err6		= 0xff06
574726ce28SchoppsABSOLUTE err7		= 0xff07
584726ce28SchoppsABSOLUTE err8		= 0xff08
594726ce28SchoppsABSOLUTE err9		= 0xff09
604726ce28SchoppsABSOLUTE err10		= 0xff0a
6191d0eb55SmhitchABSOLUTE err11		= 0xff0b
624726ce28Schopps
634726ce28SchoppsENTRY	scripts
644726ce28SchoppsENTRY	switch
654726ce28SchoppsENTRY	wait_reselect
6622087826SchoppsENTRY	dataout
6722087826SchoppsENTRY	datain
6891d0eb55SmhitchENTRY	clear_ack
694726ce28Schopps
704726ce28SchoppsPROC	scripts:
714726ce28Schopps
724726ce28Schoppsscripts:
734726ce28Schopps
744726ce28Schopps	SELECT ATN FROM ds_Device, REL(reselect)
754726ce28Schopps;
764726ce28Schoppsswitch:
774726ce28Schopps	JUMP REL(msgin), WHEN MSG_IN
784726ce28Schopps	JUMP REL(msgout), IF MSG_OUT
794726ce28Schopps	JUMP REL(command_phase), IF CMD
804726ce28Schopps	JUMP REL(dataout), IF DATA_OUT
814726ce28Schopps	JUMP REL(datain), IF DATA_IN
824726ce28Schopps	JUMP REL(end), IF STATUS
834726ce28Schopps
8422087826Schopps	INT err5			; Unrecognized phase
854726ce28Schopps
864726ce28Schoppsmsgin:
874726ce28Schopps	MOVE FROM ds_MsgIn, WHEN MSG_IN
884726ce28Schopps	JUMP REL(ext_msg), IF 0x01	; extended message
894726ce28Schopps	JUMP REL(disc), IF 0x04		; disconnect message
9022087826Schopps	JUMP REL(msg_sdp), IF 0x02	; save data pointers
9122087826Schopps	JUMP REL(msg_rej), IF 0x07	; message reject
9222087826Schopps	JUMP REL(msg_rdp), IF 0x03	; restore data pointers
9322087826Schopps	INT err6			; unrecognized message
944726ce28Schopps
954726ce28Schoppsmsg_rej:
9691d0eb55Smhitch; Do we need to interrupt host here to let it handle the reject?
9791d0eb55Smhitchmsg_rdp:
9891d0eb55Smhitchclear_ack:
9922087826Schopps	CLEAR ACK
1004726ce28Schopps	CLEAR ATN
1014726ce28Schopps	JUMP REL(switch)
1024726ce28Schopps
1034726ce28Schoppsext_msg:
10422087826Schopps	CLEAR ACK
1054726ce28Schopps	MOVE FROM ds_ExtMsg, WHEN MSG_IN
1064726ce28Schopps	JUMP REL(sync_msg), IF 0x03
10722087826Schopps	int err7			; extended message not SDTR
1084726ce28Schopps
1094726ce28Schoppssync_msg:
1104726ce28Schopps	CLEAR ACK
1114726ce28Schopps	MOVE FROM ds_SyncMsg, WHEN MSG_IN
11291d0eb55Smhitch	int err11			; Let host handle the message
11391d0eb55Smhitch; If we continue from the interrupt, the host has set up a response
11491d0eb55Smhitch; message to be sent.  Set ATN, clear ACK, and continue.
11591d0eb55Smhitch	SET ATN
1164726ce28Schopps	CLEAR ACK
1174726ce28Schopps	JUMP REL(switch)
1184726ce28Schopps
1194726ce28Schoppsdisc:
12022087826Schopps	CLEAR ACK
1214726ce28Schopps	WAIT DISCONNECT
1224726ce28Schopps
12322087826Schopps	int err2			; signal disconnect w/o save DP
1244726ce28Schopps
12522087826Schoppsmsg_sdp:
12622087826Schopps	CLEAR ACK			; acknowledge message
12722087826Schopps	JUMP REL(switch), WHEN NOT MSG_IN
12822087826Schopps	MOVE FROM ds_ExtMsg, WHEN MSG_IN
12922087826Schopps	INT err8, IF NOT 0x04		; interrupt if not disconnect
13022087826Schopps	CLEAR ACK
13122087826Schopps	WAIT DISCONNECT
13222087826Schopps
13322087826Schopps	INT err1			; signal disconnect
13422087826Schopps
13522087826Schoppsreselect:
1364726ce28Schoppswait_reselect:
1374726ce28Schopps	WAIT RESELECT REL(select_adr)
13822087826Schopps	MOVE LCRC to SFBR		; Save reselect ID
13922087826Schopps	MOVE SFBR to SCRATCH0
1404726ce28Schopps
14122087826Schopps	INT err9, WHEN NOT MSG_IN	; didn't get IDENTIFY
1424726ce28Schopps	MOVE FROM ds_Msg, WHEN MSG_IN
14322087826Schopps	INT err3			; let host know about reconnect
144*5bf26296Smaya	CLEAR ACK			; acknowledge the message
1454726ce28Schopps	JUMP REL(switch)
1464726ce28Schopps
14722087826Schopps
14822087826Schoppsselect_adr:
14922087826Schopps	MOVE SCNTL1 & 0x10 to SFBR	; get connected status
15022087826Schopps	INT err4, IF 0x00		; tell host if not connected
15122087826Schopps	MOVE CTEST2 & 0x40 to SFBR	; clear Sig_P
15222087826Schopps	JUMP REL(wait_reselect)		; and try reselect again
15322087826Schopps
1544726ce28Schoppsmsgout:
1554726ce28Schopps	MOVE FROM ds_MsgOut, WHEN MSG_OUT
1564726ce28Schopps	JUMP REL(switch)
1574726ce28Schopps
1584726ce28Schoppscommand_phase:
1594726ce28Schopps	CLEAR ATN
1604726ce28Schopps	MOVE FROM ds_Cmd, WHEN CMD
1614726ce28Schopps	JUMP REL(switch)
1624726ce28Schopps
1634726ce28Schoppsdataout:
1644726ce28Schopps	MOVE FROM ds_Data1, WHEN DATA_OUT
1654726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1664726ce28Schopps	MOVE FROM ds_Data2, WHEN DATA_OUT
1674726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1684726ce28Schopps	MOVE FROM ds_Data3, WHEN DATA_OUT
1694726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1704726ce28Schopps	MOVE FROM ds_Data4, WHEN DATA_OUT
1714726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1724726ce28Schopps	MOVE FROM ds_Data5, WHEN DATA_OUT
1734726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1744726ce28Schopps	MOVE FROM ds_Data6, WHEN DATA_OUT
1754726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1764726ce28Schopps	MOVE FROM ds_Data7, WHEN DATA_OUT
1774726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1784726ce28Schopps	MOVE FROM ds_Data8, WHEN DATA_OUT
1794726ce28Schopps	CALL REL(switch), WHEN NOT DATA_OUT
1804726ce28Schopps	MOVE FROM ds_Data9, WHEN DATA_OUT
1814726ce28Schopps	CALL REL(switch)
1824726ce28Schopps
1834726ce28Schoppsdatain:
1844726ce28Schopps	MOVE FROM ds_Data1, WHEN DATA_IN
1854726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1864726ce28Schopps	MOVE FROM ds_Data2, WHEN DATA_IN
1874726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1884726ce28Schopps	MOVE FROM ds_Data3, WHEN DATA_IN
1894726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1904726ce28Schopps	MOVE FROM ds_Data4, WHEN DATA_IN
1914726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1924726ce28Schopps	MOVE FROM ds_Data5, WHEN DATA_IN
1934726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1944726ce28Schopps	MOVE FROM ds_Data6, WHEN DATA_IN
1954726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1964726ce28Schopps	MOVE FROM ds_Data7, WHEN DATA_IN
1974726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
1984726ce28Schopps	MOVE FROM ds_Data8, WHEN DATA_IN
1994726ce28Schopps	CALL REL(switch), WHEN NOT DATA_IN
2004726ce28Schopps	MOVE FROM ds_Data9, WHEN DATA_IN
2014726ce28Schopps	CALL REL(switch)
2024726ce28Schopps
2034726ce28Schoppsend:
2044726ce28Schopps	MOVE FROM ds_Status, WHEN STATUS
20522087826Schopps	int err10, WHEN NOT MSG_IN	; status not followed by msg
2064726ce28Schopps	MOVE FROM ds_Msg, WHEN MSG_IN
2074726ce28Schopps	CLEAR ACK
2084726ce28Schopps	WAIT DISCONNECT
20922087826Schopps	INT ok				; signal completion
2104726ce28Schopps	JUMP REL(wait_reselect)
211