Home | History | Annotate | Line # | Download | only in siop
siop.ss revision 1.3
      1  1.3  bouyer ;	$NetBSD: siop.ss,v 1.3 2000/04/27 14:08:09 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.2  bouyer ABSOLUTE t_id = 20;
     36  1.2  bouyer ABSOLUTE t_msg_in = 28;
     37  1.2  bouyer ABSOLUTE t_ext_msg_in = 36;
     38  1.2  bouyer ABSOLUTE t_ext_msg_data = 44;
     39  1.2  bouyer ABSOLUTE t_ext_msg_tag = 52;
     40  1.2  bouyer ABSOLUTE t_msg_out = 60;
     41  1.2  bouyer ABSOLUTE t_cmd = 68;
     42  1.2  bouyer ABSOLUTE t_status = 76;
     43  1.2  bouyer ABSOLUTE t_data = 84;
     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.1  bouyer 
     59  1.1  bouyer ENTRY waitphase;
     60  1.2  bouyer ENTRY send_msgout;
     61  1.1  bouyer ENTRY msgout;
     62  1.1  bouyer ENTRY msgin;
     63  1.2  bouyer ENTRY msgin_ack;
     64  1.1  bouyer ENTRY dataout;
     65  1.1  bouyer ENTRY datain;
     66  1.1  bouyer ENTRY cmdout;
     67  1.1  bouyer ENTRY status;
     68  1.1  bouyer ENTRY disconnect;
     69  1.1  bouyer ENTRY reselect;
     70  1.2  bouyer ENTRY selected;
     71  1.2  bouyer ENTRY get_extmsgdata;
     72  1.2  bouyer ENTRY sheduler;
     73  1.2  bouyer ENTRY slot;
     74  1.2  bouyer ENTRY idsa0;
     75  1.2  bouyer ENTRY idsa1;
     76  1.2  bouyer ENTRY idsa2;
     77  1.2  bouyer ENTRY idsa3;
     78  1.2  bouyer ENTRY slotdata;
     79  1.2  bouyer ENTRY nextslot;
     80  1.2  bouyer ENTRY endslot;
     81  1.2  bouyer 
     82  1.2  bouyer EXTERN slot_nextp;
     83  1.2  bouyer EXTERN slot_shed_addrsrc;
     84  1.2  bouyer EXTERN slot_abs_reselect;
     85  1.2  bouyer EXTERN slot_abs_selected;
     86  1.2  bouyer 
     87  1.2  bouyer EXTERN endslot_abs_reselect;
     88  1.1  bouyer 
     89  1.1  bouyer PROC  siop_script:
     90  1.1  bouyer 
     91  1.2  bouyer selected:
     92  1.1  bouyer ; starting a new session, init 'local variables'
     93  1.1  bouyer 	MOVE 0 to SCRATCHA0	; flags
     94  1.1  bouyer 	MOVE 0 to SCRATCHA1	; DSA offset (for S/G save data pointer)
     95  1.1  bouyer waitphase:
     96  1.1  bouyer 	JUMP REL(msgout), WHEN MSG_OUT;
     97  1.1  bouyer 	JUMP REL(msgin), WHEN MSG_IN;
     98  1.1  bouyer 	JUMP REL(dataout), WHEN DATA_OUT;
     99  1.1  bouyer 	JUMP REL(datain), WHEN DATA_IN;
    100  1.1  bouyer 	JUMP REL(cmdout), WHEN CMD;
    101  1.1  bouyer 	JUMP REL(status), WHEN STATUS;
    102  1.1  bouyer err:
    103  1.1  bouyer 	INT int_err;
    104  1.1  bouyer 
    105  1.1  bouyer reselect:
    106  1.1  bouyer 	WAIT RESELECT REL(reselect_fail)
    107  1.1  bouyer 	MOVE SSID & 0x8f to SFBR
    108  1.1  bouyer 	MOVE SFBR to SCRATCHA0 ; save reselect ID
    109  1.1  bouyer 	INT int_err, WHEN NOT MSG_IN;
    110  1.1  bouyer 	MOVE FROM t_msg_in, WHEN MSG_IN;
    111  1.1  bouyer 	CLEAR ACK;
    112  1.1  bouyer 	INT int_resel;
    113  1.1  bouyer 
    114  1.1  bouyer reselect_fail:
    115  1.2  bouyer 	; check that host asserted SIGP, this'll clear SIGP in ISTAT
    116  1.2  bouyer 	MOVE CTEST2 & 0x40 TO SFBR;
    117  1.2  bouyer 	INT int_resfail,  IF 0x00;
    118  1.2  bouyer 	JUMP REL(sheduler);
    119  1.1  bouyer 
    120  1.1  bouyer msgin:
    121  1.1  bouyer 	CLEAR ATN
    122  1.1  bouyer 	MOVE FROM t_msg_in, WHEN MSG_IN;
    123  1.1  bouyer 	JUMP REL(handle_dis), IF 0x04         ; disconnect message
    124  1.1  bouyer 	JUMP REL(handle_cmpl), IF 0x00        ; command complete message
    125  1.1  bouyer 	JUMP REL(handle_sdp), IF 0x02	      ; save data pointer message
    126  1.2  bouyer 	JUMP REL(handle_extin), IF 0x01	      ; extended message
    127  1.1  bouyer 	INT int_msgin;
    128  1.2  bouyer msgin_ack:
    129  1.2  bouyer 	CLEAR ACK;
    130  1.2  bouyer 	JUMP REL(waitphase);
    131  1.2  bouyer 
    132  1.2  bouyer ; entry point for msgout after a msgin or status phase
    133  1.2  bouyer send_msgout:
    134  1.2  bouyer 	SET ATN;
    135  1.2  bouyer 	CLEAR ACK;
    136  1.1  bouyer msgout:
    137  1.1  bouyer 	MOVE FROM t_msg_out, WHEN MSG_OUT;
    138  1.1  bouyer 	CLEAR ATN;
    139  1.1  bouyer 	JUMP REL(waitphase);
    140  1.1  bouyer cmdout:
    141  1.1  bouyer 	MOVE FROM t_cmd, WHEN CMD;
    142  1.1  bouyer 	JUMP REL(waitphase);
    143  1.1  bouyer status:
    144  1.1  bouyer 	MOVE FROM t_status, WHEN STATUS;
    145  1.1  bouyer 	JUMP REL(waitphase);
    146  1.1  bouyer datain:
    147  1.1  bouyer 	CALL REL(savedsa);
    148  1.1  bouyer datain_loop:
    149  1.1  bouyer 	MOVE FROM t_data, WHEN DATA_IN;
    150  1.1  bouyer 	MOVE SCRATCHA1 + 1 TO SCRATCHA1	; adjust offset
    151  1.1  bouyer 	MOVE DSA0 + 8 to DSA0;
    152  1.1  bouyer 	MOVE DSA1 + 0 to DSA1 WITH CARRY;
    153  1.1  bouyer 	MOVE DSA2 + 0 to DSA2 WITH CARRY;
    154  1.1  bouyer 	MOVE DSA3 + 0 to DSA3 WITH CARRY;
    155  1.1  bouyer 	JUMP REL(datain_loop), WHEN DATA_IN;
    156  1.1  bouyer 	CALL REL(restoredsa);
    157  1.1  bouyer 	JUMP REL(waitphase);
    158  1.1  bouyer 
    159  1.1  bouyer dataout:
    160  1.1  bouyer 	CALL REL(savedsa);
    161  1.1  bouyer dataout_loop:
    162  1.1  bouyer 	MOVE FROM t_data, WHEN DATA_OUT;
    163  1.1  bouyer 	MOVE SCRATCHA1 + 1 TO SCRATCHA1	; adjust offset
    164  1.1  bouyer 	MOVE DSA0 + 8 to DSA0;
    165  1.1  bouyer 	MOVE DSA1 + 0 to DSA1 WITH CARRY;
    166  1.1  bouyer 	MOVE DSA2 + 0 to DSA2 WITH CARRY;
    167  1.1  bouyer 	MOVE DSA3 + 0 to DSA3 WITH CARRY;
    168  1.1  bouyer 	JUMP REL(dataout_loop), WHEN DATA_OUT;
    169  1.1  bouyer 	CALL REL(restoredsa);
    170  1.1  bouyer 	JUMP REL(waitphase);
    171  1.1  bouyer 
    172  1.1  bouyer savedsa:
    173  1.1  bouyer 	MOVE DSA0 to SFBR;
    174  1.1  bouyer 	MOVE SFBR to SCRATCHB0;
    175  1.1  bouyer 	MOVE DSA1 to SFBR;
    176  1.1  bouyer 	MOVE SFBR to SCRATCHB1;
    177  1.1  bouyer 	MOVE DSA2 to SFBR;
    178  1.1  bouyer 	MOVE SFBR to SCRATCHB2;
    179  1.1  bouyer 	MOVE DSA3 to SFBR;
    180  1.1  bouyer 	MOVE SFBR to SCRATCHB3;
    181  1.1  bouyer 	RETURN;
    182  1.1  bouyer 
    183  1.1  bouyer restoredsa:
    184  1.1  bouyer 	MOVE SCRATCHB0 TO SFBR;
    185  1.1  bouyer 	MOVE SFBR TO DSA0;
    186  1.1  bouyer 	MOVE SCRATCHB1 TO SFBR;
    187  1.1  bouyer 	MOVE SFBR TO DSA1;
    188  1.1  bouyer 	MOVE SCRATCHB2 TO SFBR;
    189  1.1  bouyer 	MOVE SFBR TO DSA2;
    190  1.1  bouyer 	MOVE SCRATCHB3 TO SFBR;
    191  1.1  bouyer 	MOVE SFBR TO DSA3;
    192  1.1  bouyer 	RETURN;
    193  1.1  bouyer 
    194  1.1  bouyer disconnect:
    195  1.1  bouyer 	MOVE SCNTL2 & 0x7f TO SCNTL2;
    196  1.1  bouyer 	CLEAR ATN;
    197  1.1  bouyer 	CLEAR ACK;
    198  1.1  bouyer 	WAIT DISCONNECT;
    199  1.1  bouyer 	RETURN;
    200  1.1  bouyer 
    201  1.1  bouyer handle_dis:
    202  1.1  bouyer 	CALL REL(disconnect);
    203  1.1  bouyer ; if we didn't get sdp, or if offset is 0, no need to interrupt
    204  1.1  bouyer 	MOVE SCRATCHA0 & flag_sdp TO SFBR;
    205  1.2  bouyer 	JUMP REL(sheduler), if 0x00; 
    206  1.1  bouyer 	MOVE SCRATCHA1 TO SFBR;
    207  1.2  bouyer 	JUMP REL(sheduler), if 0x00; 
    208  1.1  bouyer ; Ok, we need to save data pointers
    209  1.1  bouyer 	INT int_disc;
    210  1.1  bouyer 
    211  1.1  bouyer handle_cmpl:
    212  1.1  bouyer 	CALL REL(disconnect);
    213  1.1  bouyer 	INT int_done;
    214  1.1  bouyer handle_sdp:
    215  1.1  bouyer 	CLEAR ACK;
    216  1.1  bouyer 	MOVE SCRATCHA0 | flag_sdp TO SCRATCHA0;
    217  1.1  bouyer 	JUMP REL(msgin) ; should get a disconnect message now
    218  1.2  bouyer 
    219  1.2  bouyer handle_extin:
    220  1.2  bouyer 	CLEAR ACK;
    221  1.2  bouyer 	INT int_err, IF NOT MSG_IN;
    222  1.2  bouyer 	MOVE FROM t_ext_msg_in, WHEN MSG_IN;
    223  1.2  bouyer 	INT int_extmsgin; /* let host fill in t_ext_msg_data */
    224  1.2  bouyer get_extmsgdata:
    225  1.2  bouyer 	CLEAR ACK;
    226  1.2  bouyer 	INT int_err, IF NOT MSG_IN;
    227  1.2  bouyer 	MOVE FROM t_ext_msg_data, WHEN MSG_IN;
    228  1.2  bouyer 	INT int_extmsgdata;
    229  1.2  bouyer 
    230  1.2  bouyer sheduler:
    231  1.2  bouyer 	NOP; /* will be changed by the slot scripts */
    232  1.2  bouyer 
    233  1.2  bouyer ; script used for the sheduler: when a slot is free the JUMP points to
    234  1.2  bouyer ; the next slot so that instructions for this slot are not run.
    235  1.2  bouyer ; once the CPU has set up the slot variables (DSA address) it changes
    236  1.2  bouyer ; the JUMP address to 0 (so that it'll jump to the next instruction) and
    237  1.2  bouyer ; this command will be processed next time the sheduler is executed.
    238  1.2  bouyer ; When the target has been successfully selected the script changes the jump
    239  1.2  bouyer ; addr back to the next slot, so that it's ignored the next time.
    240  1.2  bouyer ;
    241  1.2  bouyer 
    242  1.2  bouyer PROC  slot_script:
    243  1.2  bouyer slot:
    244  1.2  bouyer         JUMP REL(nextslot);
    245  1.2  bouyer idsa0:
    246  1.2  bouyer 	MOVE 0x00 to dsa0;
    247  1.2  bouyer idsa1:
    248  1.2  bouyer 	MOVE 0x01 to dsa1;
    249  1.2  bouyer idsa2:
    250  1.2  bouyer 	MOVE 0x02 to dsa2;
    251  1.2  bouyer idsa3:
    252  1.2  bouyer 	MOVE 0x03 to dsa3;
    253  1.2  bouyer 	SELECT ATN FROM t_id, slot_abs_reselect;
    254  1.2  bouyer 	MOVE MEMORY 4, slot_shed_addrsrc, slot_nextp;
    255  1.2  bouyer 	JUMP slot_abs_selected;  
    256  1.2  bouyer slotdata:
    257  1.2  bouyer 	NOP; slot variables: dsa & jumppatchp
    258  1.2  bouyer nextslot:	NOP; /* will be changed to the next slot entry
    259  1.2  bouyer 
    260  1.2  bouyer PROC  endslot_script:
    261  1.2  bouyer 	JUMP endslot_abs_reselect;
    262