Home | History | Annotate | Line # | Download | only in siop
siop.ss revision 1.6.2.1
      1  1.6.2.1  minoura ;	$NetBSD: siop.ss,v 1.6.2.1 2000/06/22 17:07:14 minoura 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.5   bouyer ;  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21      1.5   bouyer ;  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22      1.5   bouyer ;  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23      1.5   bouyer ;  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,     
     24      1.5   bouyer ;  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25      1.5   bouyer ;  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26      1.5   bouyer ;  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27      1.5   bouyer ;  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28      1.5   bouyer ;  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29      1.5   bouyer ;  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30      1.3   bouyer 
     31      1.1   bouyer ARCH 720
     32      1.1   bouyer 
     33      1.2   bouyer ; offsets in sym_xfer
     34      1.4   bouyer ABSOLUTE t_id = 24;
     35      1.4   bouyer ABSOLUTE t_msg_in = 32;
     36      1.4   bouyer ABSOLUTE t_ext_msg_in = 40;
     37      1.4   bouyer ABSOLUTE t_ext_msg_data = 48;
     38      1.5   bouyer ABSOLUTE t_msg_tag = 56;
     39      1.4   bouyer ABSOLUTE t_msg_out = 64;
     40      1.4   bouyer ABSOLUTE t_cmd = 72;
     41      1.4   bouyer ABSOLUTE t_status = 80;
     42      1.4   bouyer ABSOLUTE t_data = 88;
     43      1.1   bouyer 
     44      1.1   bouyer ;; interrupt codes
     45      1.1   bouyer ABSOLUTE int_done	= 0xff00;
     46      1.1   bouyer ABSOLUTE int_msgin	= 0xff01;
     47      1.2   bouyer ABSOLUTE int_extmsgin	= 0xff02;
     48      1.2   bouyer ABSOLUTE int_extmsgdata	= 0xff03;
     49      1.2   bouyer ABSOLUTE int_resel	= 0xff04;
     50      1.2   bouyer ABSOLUTE int_reseltag	= 0xff05;
     51      1.2   bouyer ABSOLUTE int_resfail	= 0xff06;
     52      1.2   bouyer ABSOLUTE int_disc	= 0xff07;
     53      1.1   bouyer ABSOLUTE int_err 	= 0xffff;
     54      1.1   bouyer 
     55      1.1   bouyer ; flags for scratcha0
     56      1.1   bouyer ABSOLUTE flag_sdp 	= 0x01 ; got save data pointer
     57      1.4   bouyer ABSOLUTE flag_data 	= 0x02 ; we're in data phase
     58      1.4   bouyer ABSOLUTE flag_data_mask	= 0xfd ; ~flag_data
     59      1.1   bouyer 
     60      1.1   bouyer ENTRY waitphase;
     61      1.2   bouyer ENTRY send_msgout;
     62      1.1   bouyer ENTRY msgout;
     63      1.1   bouyer ENTRY msgin;
     64      1.2   bouyer ENTRY msgin_ack;
     65      1.1   bouyer ENTRY dataout;
     66      1.1   bouyer ENTRY datain;
     67      1.1   bouyer ENTRY cmdout;
     68      1.1   bouyer ENTRY status;
     69      1.1   bouyer ENTRY disconnect;
     70      1.1   bouyer ENTRY reselect;
     71      1.2   bouyer ENTRY selected;
     72      1.2   bouyer ENTRY get_extmsgdata;
     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.6   bouyer EXTERN script_abs_shed;
     83      1.2   bouyer EXTERN slot_nextp;
     84      1.2   bouyer EXTERN slot_shed_addrsrc;
     85      1.2   bouyer EXTERN slot_abs_reselect;
     86      1.2   bouyer EXTERN slot_abs_selected;
     87      1.2   bouyer 
     88      1.2   bouyer EXTERN endslot_abs_reselect;
     89      1.1   bouyer 
     90      1.1   bouyer PROC  siop_script:
     91      1.1   bouyer 
     92      1.2   bouyer selected:
     93      1.1   bouyer ; starting a new session, init 'local variables'
     94      1.1   bouyer 	MOVE 0 to SCRATCHA0	; flags
     95      1.1   bouyer 	MOVE 0 to SCRATCHA1	; DSA offset (for S/G save data pointer)
     96      1.5   bouyer 	CLEAR ACK;
     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 	INT int_resel;
    114      1.1   bouyer 
    115      1.1   bouyer reselect_fail:
    116      1.2   bouyer 	; check that host asserted SIGP, this'll clear SIGP in ISTAT
    117      1.2   bouyer 	MOVE CTEST2 & 0x40 TO SFBR;
    118      1.2   bouyer 	INT int_resfail,  IF 0x00;
    119      1.6   bouyer 	JUMP script_abs_shed;
    120      1.1   bouyer 
    121      1.1   bouyer msgin:
    122      1.1   bouyer 	CLEAR ATN
    123      1.1   bouyer 	MOVE FROM t_msg_in, WHEN MSG_IN;
    124      1.1   bouyer 	JUMP REL(handle_dis), IF 0x04         ; disconnect message
    125      1.1   bouyer 	JUMP REL(handle_cmpl), IF 0x00        ; command complete message
    126      1.1   bouyer 	JUMP REL(handle_sdp), IF 0x02	      ; save data pointer message
    127      1.2   bouyer 	JUMP REL(handle_extin), IF 0x01	      ; extended message
    128      1.1   bouyer 	INT int_msgin;
    129      1.2   bouyer msgin_ack:
    130      1.2   bouyer 	CLEAR ACK;
    131      1.2   bouyer 	JUMP REL(waitphase);
    132      1.2   bouyer 
    133      1.2   bouyer ; entry point for msgout after a msgin or status phase
    134      1.2   bouyer send_msgout:
    135      1.2   bouyer 	SET ATN;
    136      1.2   bouyer 	CLEAR ACK;
    137      1.1   bouyer msgout:
    138      1.1   bouyer 	MOVE FROM t_msg_out, WHEN MSG_OUT;
    139      1.1   bouyer 	CLEAR ATN;
    140      1.1   bouyer 	JUMP REL(waitphase);
    141      1.1   bouyer cmdout:
    142      1.1   bouyer 	MOVE FROM t_cmd, WHEN CMD;
    143      1.1   bouyer 	JUMP REL(waitphase);
    144      1.1   bouyer status:
    145      1.1   bouyer 	MOVE FROM t_status, WHEN STATUS;
    146      1.1   bouyer 	JUMP REL(waitphase);
    147      1.1   bouyer datain:
    148      1.1   bouyer 	CALL REL(savedsa);
    149      1.4   bouyer 	MOVE SCRATCHA0 | flag_data TO SCRATCHA0;
    150      1.1   bouyer datain_loop:
    151      1.1   bouyer 	MOVE FROM t_data, WHEN DATA_IN;
    152      1.1   bouyer 	MOVE SCRATCHA1 + 1 TO SCRATCHA1	; adjust offset
    153      1.1   bouyer 	MOVE DSA0 + 8 to DSA0;
    154      1.1   bouyer 	MOVE DSA1 + 0 to DSA1 WITH CARRY;
    155      1.1   bouyer 	MOVE DSA2 + 0 to DSA2 WITH CARRY;
    156      1.1   bouyer 	MOVE DSA3 + 0 to DSA3 WITH CARRY;
    157      1.1   bouyer 	JUMP REL(datain_loop), WHEN DATA_IN;
    158      1.1   bouyer 	CALL REL(restoredsa);
    159      1.4   bouyer 	MOVE SCRATCHA0 & flag_data_mask TO SCRATCHA0;
    160      1.1   bouyer 	JUMP REL(waitphase);
    161      1.1   bouyer 
    162      1.1   bouyer dataout:
    163      1.1   bouyer 	CALL REL(savedsa);
    164      1.4   bouyer 	MOVE SCRATCHA0 | flag_data TO SCRATCHA0;
    165      1.1   bouyer dataout_loop:
    166      1.1   bouyer 	MOVE FROM t_data, WHEN DATA_OUT;
    167      1.1   bouyer 	MOVE SCRATCHA1 + 1 TO SCRATCHA1	; adjust offset
    168      1.1   bouyer 	MOVE DSA0 + 8 to DSA0;
    169      1.1   bouyer 	MOVE DSA1 + 0 to DSA1 WITH CARRY;
    170      1.1   bouyer 	MOVE DSA2 + 0 to DSA2 WITH CARRY;
    171      1.1   bouyer 	MOVE DSA3 + 0 to DSA3 WITH CARRY;
    172      1.1   bouyer 	JUMP REL(dataout_loop), WHEN DATA_OUT;
    173      1.1   bouyer 	CALL REL(restoredsa);
    174      1.4   bouyer 	MOVE SCRATCHA0 & flag_data_mask TO SCRATCHA0;
    175      1.1   bouyer 	JUMP REL(waitphase);
    176      1.1   bouyer 
    177      1.1   bouyer savedsa:
    178      1.1   bouyer 	MOVE DSA0 to SFBR;
    179      1.1   bouyer 	MOVE SFBR to SCRATCHB0;
    180      1.1   bouyer 	MOVE DSA1 to SFBR;
    181      1.1   bouyer 	MOVE SFBR to SCRATCHB1;
    182      1.1   bouyer 	MOVE DSA2 to SFBR;
    183      1.1   bouyer 	MOVE SFBR to SCRATCHB2;
    184      1.1   bouyer 	MOVE DSA3 to SFBR;
    185      1.1   bouyer 	MOVE SFBR to SCRATCHB3;
    186      1.1   bouyer 	RETURN;
    187      1.1   bouyer 
    188      1.1   bouyer restoredsa:
    189      1.1   bouyer 	MOVE SCRATCHB0 TO SFBR;
    190      1.1   bouyer 	MOVE SFBR TO DSA0;
    191      1.1   bouyer 	MOVE SCRATCHB1 TO SFBR;
    192      1.1   bouyer 	MOVE SFBR TO DSA1;
    193      1.1   bouyer 	MOVE SCRATCHB2 TO SFBR;
    194      1.1   bouyer 	MOVE SFBR TO DSA2;
    195      1.1   bouyer 	MOVE SCRATCHB3 TO SFBR;
    196      1.1   bouyer 	MOVE SFBR TO DSA3;
    197      1.1   bouyer 	RETURN;
    198      1.1   bouyer 
    199      1.1   bouyer disconnect:
    200      1.1   bouyer 	MOVE SCNTL2 & 0x7f TO SCNTL2;
    201      1.1   bouyer 	CLEAR ATN;
    202      1.1   bouyer 	CLEAR ACK;
    203      1.1   bouyer 	WAIT DISCONNECT;
    204      1.1   bouyer 	RETURN;
    205      1.1   bouyer 
    206      1.1   bouyer handle_dis:
    207      1.1   bouyer 	CALL REL(disconnect);
    208      1.1   bouyer ; if we didn't get sdp, or if offset is 0, no need to interrupt
    209      1.1   bouyer 	MOVE SCRATCHA0 & flag_sdp TO SFBR;
    210      1.6   bouyer 	JUMP script_abs_shed, if 0x00; 
    211      1.1   bouyer 	MOVE SCRATCHA1 TO SFBR;
    212      1.6   bouyer 	JUMP script_abs_shed, if 0x00; 
    213      1.1   bouyer ; Ok, we need to save data pointers
    214      1.1   bouyer 	INT int_disc;
    215      1.1   bouyer 
    216      1.1   bouyer handle_cmpl:
    217      1.1   bouyer 	CALL REL(disconnect);
    218      1.1   bouyer 	INT int_done;
    219      1.1   bouyer handle_sdp:
    220      1.1   bouyer 	CLEAR ACK;
    221      1.1   bouyer 	MOVE SCRATCHA0 | flag_sdp TO SCRATCHA0;
    222      1.1   bouyer 	JUMP REL(msgin) ; should get a disconnect message now
    223      1.2   bouyer 
    224      1.2   bouyer handle_extin:
    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_in, WHEN MSG_IN;
    228      1.2   bouyer 	INT int_extmsgin; /* let host fill in t_ext_msg_data */
    229      1.2   bouyer get_extmsgdata:
    230      1.2   bouyer 	CLEAR ACK;
    231      1.2   bouyer 	INT int_err, IF NOT MSG_IN;
    232      1.2   bouyer 	MOVE FROM t_ext_msg_data, WHEN MSG_IN;
    233      1.2   bouyer 	INT int_extmsgdata;
    234      1.2   bouyer 
    235  1.6.2.1  minoura ; script used for the scheduler: when a slot is free the JUMP points to
    236      1.2   bouyer ; the next slot so that instructions for this slot are not run.
    237      1.2   bouyer ; once the CPU has set up the slot variables (DSA address) it changes
    238      1.2   bouyer ; the JUMP address to 0 (so that it'll jump to the next instruction) and
    239  1.6.2.1  minoura ; this command will be processed next time the scheduler is executed.
    240      1.2   bouyer ; When the target has been successfully selected the script changes the jump
    241      1.2   bouyer ; addr back to the next slot, so that it's ignored the next time.
    242      1.2   bouyer ;
    243      1.2   bouyer 
    244      1.2   bouyer PROC  slot_script:
    245      1.2   bouyer slot:
    246      1.2   bouyer         JUMP REL(nextslot);
    247      1.2   bouyer idsa0:
    248      1.2   bouyer 	MOVE 0x00 to dsa0;
    249      1.2   bouyer idsa1:
    250      1.2   bouyer 	MOVE 0x01 to dsa1;
    251      1.2   bouyer idsa2:
    252      1.2   bouyer 	MOVE 0x02 to dsa2;
    253      1.2   bouyer idsa3:
    254      1.2   bouyer 	MOVE 0x03 to dsa3;
    255      1.2   bouyer 	SELECT ATN FROM t_id, slot_abs_reselect;
    256      1.2   bouyer 	MOVE MEMORY 4, slot_shed_addrsrc, slot_nextp;
    257      1.2   bouyer 	JUMP slot_abs_selected;  
    258      1.2   bouyer slotdata:
    259      1.2   bouyer 	NOP; slot variables: dsa & jumppatchp
    260      1.2   bouyer nextslot:	NOP; /* will be changed to the next slot entry
    261      1.2   bouyer 
    262      1.2   bouyer PROC  endslot_script:
    263      1.2   bouyer 	JUMP endslot_abs_reselect;
    264