aic7xxx.seq (24914) | aic7xxx.seq (25005) |
---|---|
1/*+M*********************************************************************** 2 *Adaptec 274x/284x/294x device driver for Linux and FreeBSD. 3 * 4 *Copyright (c) 1994 John Aycock 5 * The University of Calgary Department of Computer Science. 6 * All rights reserved. 7 * 8 *FreeBSD, Twin, Wide, 2 command per target support, tagged queuing, --- 23 unchanged lines hidden (view full) --- 32 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 *DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 *OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 *HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 *OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 *SUCH DAMAGE. 39 * | 1/*+M*********************************************************************** 2 *Adaptec 274x/284x/294x device driver for Linux and FreeBSD. 3 * 4 *Copyright (c) 1994 John Aycock 5 * The University of Calgary Department of Computer Science. 6 * All rights reserved. 7 * 8 *FreeBSD, Twin, Wide, 2 command per target support, tagged queuing, --- 23 unchanged lines hidden (view full) --- 32 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 *DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 *OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 *HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 *OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 *SUCH DAMAGE. 39 * |
40 * $Id: aic7xxx.seq,v 1.70 1997/04/10 19:13:05 gibbs Exp $ | 40 * $Id: aic7xxx.seq,v 1.71 1997/04/14 02:26:59 gibbs Exp $ |
41 * 42 *-M************************************************************************/ 43 44#include <dev/aic7xxx/aic7xxx.reg> 45#include <scsi/scsi_message.h> 46 47/* 48 * A few words on the waiting SCB list: --- 17 unchanged lines hidden (view full) --- 66 * We assume that the kernel driver may reset us at any time, even in the 67 * middle of a DMA, so clear DFCNTRL too. 68 */ 69reset: 70 clr SCSISIGO; /* De-assert BSY */ 71 /* Always allow reselection */ 72 mvi SCSISEQ, ENRSELI|ENAUTOATNP; 73 call clear_target_state; | 41 * 42 *-M************************************************************************/ 43 44#include <dev/aic7xxx/aic7xxx.reg> 45#include <scsi/scsi_message.h> 46 47/* 48 * A few words on the waiting SCB list: --- 17 unchanged lines hidden (view full) --- 66 * We assume that the kernel driver may reset us at any time, even in the 67 * middle of a DMA, so clear DFCNTRL too. 68 */ 69reset: 70 clr SCSISIGO; /* De-assert BSY */ 71 /* Always allow reselection */ 72 mvi SCSISEQ, ENRSELI|ENAUTOATNP; 73 call clear_target_state; |
74repoll_for_work: 75 and SIMODE1, ~ENBUSFREE; | |
76poll_for_work: 77 test SSTAT0,SELDO jnz select; 78 test SSTAT0,SELDI jnz reselect; 79 test SCSISEQ, ENSELO jnz poll_for_work; 80.if ( TWIN_CHANNEL ) 81 /* 82 * Twin channel devices cannot handle things like SELTO 83 * interrupts on the "background" channel. So, if we --- 74 unchanged lines hidden (view full) --- 158 mvi INTSTAT, NO_MATCH_BUSY; 159paged_busy_link: 160 /* Link us in */ 161 mov SCB_LINKED_NEXT, CUR_SCBID; 162 /* Put it back on the disconnected list */ 163 call add_scb_to_disc_list; 164 mvi SEQCTL, FASTMODE; 165 jmp poll_for_work; | 74poll_for_work: 75 test SSTAT0,SELDO jnz select; 76 test SSTAT0,SELDI jnz reselect; 77 test SCSISEQ, ENSELO jnz poll_for_work; 78.if ( TWIN_CHANNEL ) 79 /* 80 * Twin channel devices cannot handle things like SELTO 81 * interrupts on the "background" channel. So, if we --- 74 unchanged lines hidden (view full) --- 156 mvi INTSTAT, NO_MATCH_BUSY; 157paged_busy_link: 158 /* Link us in */ 159 mov SCB_LINKED_NEXT, CUR_SCBID; 160 /* Put it back on the disconnected list */ 161 call add_scb_to_disc_list; 162 mvi SEQCTL, FASTMODE; 163 jmp poll_for_work; |
166.endif | 164.else |
167simple_busy_link: 168 mov SCBPTR, ARG_1; 169 mov SCB_LINKED_NEXT, CUR_SCBID; 170 mvi SEQCTL, FASTMODE; 171 jmp poll_for_work; | 165simple_busy_link: 166 mov SCBPTR, ARG_1; 167 mov SCB_LINKED_NEXT, CUR_SCBID; 168 mvi SEQCTL, FASTMODE; 169 jmp poll_for_work; |
170.endif |
|
172make_busy: 173 mov DINDIR, CUR_SCBID; 174 mov SCBPTR, SAVED_SCBPTR; 175 mvi SEQCTL, FASTMODE; 176 177start_scb: 178 /* 179 * Place us on the waiting list in case our selection --- 24 unchanged lines hidden (view full) --- 204 or SCSIID, A; 205 mvi SCSISEQ, ENSELO|ENAUTOATNO|ENRSELI|ENAUTOATNP ret; 206/* 207 * Reselection has been initiated by a target. Make a note that we've been 208 * reselected, but haven't seen an IDENTIFY message from the target yet. 209 */ 210reselect: 211 clr MSG_LEN; /* Don't have anything in the mesg buffer */ | 171make_busy: 172 mov DINDIR, CUR_SCBID; 173 mov SCBPTR, SAVED_SCBPTR; 174 mvi SEQCTL, FASTMODE; 175 176start_scb: 177 /* 178 * Place us on the waiting list in case our selection --- 24 unchanged lines hidden (view full) --- 203 or SCSIID, A; 204 mvi SCSISEQ, ENSELO|ENAUTOATNO|ENRSELI|ENAUTOATNP ret; 205/* 206 * Reselection has been initiated by a target. Make a note that we've been 207 * reselected, but haven't seen an IDENTIFY message from the target yet. 208 */ 209reselect: 210 clr MSG_LEN; /* Don't have anything in the mesg buffer */ |
212 mvi CLRSINT1,CLRBUSFREE; 213 or SIMODE1, ENBUSFREE; /* 214 * We aren't expecting a 215 * bus free, so interrupt 216 * the kernel driver if it 217 * happens. 218 */ 219 test SSTAT0, SELDI jz repoll_for_work;/* False alarm? */ | |
220 mvi CLRSINT0, CLRSELDI; 221 /* XXX test for and handle ONE BIT condition */ 222 and SAVED_TCL, SELID_MASK, SELID; 223 or SEQ_FLAGS,RESELECTED; 224 jmp select2; 225 226/* 227 * After the selection, remove this SCB from the "waiting SCB" 228 * list. This is achieved by simply moving our "next" pointer into 229 * WAITING_SCBH. Our next pointer will be set to null the next time this 230 * SCB is used, so don't bother with it now. 231 */ 232select: | 211 mvi CLRSINT0, CLRSELDI; 212 /* XXX test for and handle ONE BIT condition */ 213 and SAVED_TCL, SELID_MASK, SELID; 214 or SEQ_FLAGS,RESELECTED; 215 jmp select2; 216 217/* 218 * After the selection, remove this SCB from the "waiting SCB" 219 * list. This is achieved by simply moving our "next" pointer into 220 * WAITING_SCBH. Our next pointer will be set to null the next time this 221 * SCB is used, so don't bother with it now. 222 */ 223select: |
233 mov SCBPTR, WAITING_SCBH; 234 mvi CLRSINT1,CLRBUSFREE; | 224 /* Turn off the selection hardware */ |
235 mvi SCSISEQ, ENRSELI|ENAUTOATNP; /* 236 * ATN on parity errors 237 * for "in" phases 238 */ | 225 mvi SCSISEQ, ENRSELI|ENAUTOATNP; /* 226 * ATN on parity errors 227 * for "in" phases 228 */ |
239 or SIMODE1, ENBUSFREE; /* 240 * We aren't expecting a 241 * bus free, so interrupt 242 * the kernel driver if it 243 * happens. 244 */ 245 test SSTAT0, SELDO jnz select_good; 246 mvi SCSISEQ, ENSELO|ENAUTOATNO|ENRSELI|ENAUTOATNP; 247 jmp repoll_for_work; 248select_good: 249 mov WAITING_SCBH,SCB_NEXT; 250 /* Turn off the selection hardware */ | |
251 mvi CLRSINT0, CLRSELDO; | 229 mvi CLRSINT0, CLRSELDO; |
230 mov SCBPTR, WAITING_SCBH; 231 mov WAITING_SCBH,SCB_NEXT; |
|
252 mov SAVED_TCL, SCB_TCL; 253/* 254 * As soon as we get a successful selection, the target should go 255 * into the message out phase since we have ATN asserted. Prepare 256 * the message to send. 257 * 258 * Messages are stored in scratch RAM starting with a length byte 259 * followed by the message itself. --- 20 unchanged lines hidden (view full) --- 280 * Interrupt the driver, and allow it to tweak the message buffer 281 * if it asks. 282 */ 283mk_message: 284 test SCB_CONTROL,MK_MESSAGE jz select2; 285 mvi INTSTAT,AWAITING_MSG; 286 287select2: | 232 mov SAVED_TCL, SCB_TCL; 233/* 234 * As soon as we get a successful selection, the target should go 235 * into the message out phase since we have ATN asserted. Prepare 236 * the message to send. 237 * 238 * Messages are stored in scratch RAM starting with a length byte 239 * followed by the message itself. --- 20 unchanged lines hidden (view full) --- 260 * Interrupt the driver, and allow it to tweak the message buffer 261 * if it asks. 262 */ 263mk_message: 264 test SCB_CONTROL,MK_MESSAGE jz select2; 265 mvi INTSTAT,AWAITING_MSG; 266 267select2: |
268 mvi CLRSINT1,CLRBUSFREE; 269 or SIMODE1, ENBUSFREE; /* 270 * We aren't expecting a 271 * bus free, so interrupt 272 * the kernel driver if it 273 * happens. 274 */ |
|
288/* 289 * Initialize Ultra mode setting and clear the SCSI channel. 290 */ 291 or SXFRCTL0, CLRSTCNT|SPIOEN|CLRCHN; 292.if ( ULTRA ) 293ultra: 294 mvi SINDEX, ULTRA_ENB+1; 295 test SAVED_TCL, 0x80 jnz ultra_2; /* Target ID > 7 */ --- 256 unchanged lines hidden (view full) --- 552 * Keep an eye out for a phase change, in case the target issues 553 * a MESSAGE REJECT. 554 */ 555p_mesgout_loop: 556 test SSTAT1, REQINIT jz p_mesgout_loop; 557 test SSTAT1, SCSIPERR jnz p_mesgout_loop; 558 and LASTPHASE, PHASE_MASK, SCSISIGI; 559 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done; | 275/* 276 * Initialize Ultra mode setting and clear the SCSI channel. 277 */ 278 or SXFRCTL0, CLRSTCNT|SPIOEN|CLRCHN; 279.if ( ULTRA ) 280ultra: 281 mvi SINDEX, ULTRA_ENB+1; 282 test SAVED_TCL, 0x80 jnz ultra_2; /* Target ID > 7 */ --- 256 unchanged lines hidden (view full) --- 539 * Keep an eye out for a phase change, in case the target issues 540 * a MESSAGE REJECT. 541 */ 542p_mesgout_loop: 543 test SSTAT1, REQINIT jz p_mesgout_loop; 544 test SSTAT1, SCSIPERR jnz p_mesgout_loop; 545 and LASTPHASE, PHASE_MASK, SCSISIGI; 546 cmp LASTPHASE, P_MESGOUT jne p_mesgout_done; |
560/* 561 * If the next bus phase after ATN drops is a message out, it means 562 * that the target is requesting that the last message(s) be resent. 563 */ | |
564p_mesgout_testretry: 565 test DINDEX,0xff jnz p_mesgout_dropatn; 566 or SCSISIGO,ATNO,LASTPHASE;/* turn on ATN for the retry */ 567 jmp p_mesgout_start; | 547p_mesgout_testretry: 548 test DINDEX,0xff jnz p_mesgout_dropatn; 549 or SCSISIGO,ATNO,LASTPHASE;/* turn on ATN for the retry */ 550 jmp p_mesgout_start; |
551/* 552 * If the next bus phase after ATN drops is a message out, it means 553 * that the target is requesting that the last message(s) be resent. 554 */ |
|
568p_mesgout_dropatn: 569 cmp DINDEX,1 jne p_mesgout_outb; /* last byte? */ 570 mvi CLRSINT1,CLRATNO; /* drop ATN */ 571p_mesgout_outb: 572 dec DINDEX; 573 mov SCSIDATL,SINDIR; 574 jmp p_mesgout_loop; 575 --- 89 unchanged lines hidden (view full) --- 665 mvi INTSTAT, ABORT_CMDCMPLT; 666 667dma_next_scb: 668 cmp SCB_LINKED_NEXT, SCB_LIST_NULL je add_to_free_list; 669.if !( SCB_PAGING ) 670 /* Only DMA on top of ourselves if we are the SCB to download */ 671 mov A, SCB_LINKED_NEXT; 672 cmp SCB_TAG, A je dma_next_scb2; | 555p_mesgout_dropatn: 556 cmp DINDEX,1 jne p_mesgout_outb; /* last byte? */ 557 mvi CLRSINT1,CLRATNO; /* drop ATN */ 558p_mesgout_outb: 559 dec DINDEX; 560 mov SCSIDATL,SINDIR; 561 jmp p_mesgout_loop; 562 --- 89 unchanged lines hidden (view full) --- 652 mvi INTSTAT, ABORT_CMDCMPLT; 653 654dma_next_scb: 655 cmp SCB_LINKED_NEXT, SCB_LIST_NULL je add_to_free_list; 656.if !( SCB_PAGING ) 657 /* Only DMA on top of ourselves if we are the SCB to download */ 658 mov A, SCB_LINKED_NEXT; 659 cmp SCB_TAG, A je dma_next_scb2; |
660 call add_scb_to_free_list; |
|
673 mov SCBPTR, A; 674 jmp add_to_waiting_list; 675.endif 676dma_next_scb2: 677 mvi DMAPARAMS, HDMAEN|DIRECTION|FIFORESET; 678 mov SCB_LINKED_NEXT call dma_scb; 679add_to_waiting_list: 680 mov SCB_NEXT,WAITING_SCBH; --- 149 unchanged lines hidden (view full) --- 830.endif 831setup_SCB: 832 and SCB_CONTROL,~DISCONNECTED; 833 or SEQ_FLAGS,IDENTIFY_SEEN; /* make note of IDENTIFY */ 834 jmp mesgin_done; 835 836not_found: 837 mvi INTSTAT, NO_MATCH; | 661 mov SCBPTR, A; 662 jmp add_to_waiting_list; 663.endif 664dma_next_scb2: 665 mvi DMAPARAMS, HDMAEN|DIRECTION|FIFORESET; 666 mov SCB_LINKED_NEXT call dma_scb; 667add_to_waiting_list: 668 mov SCB_NEXT,WAITING_SCBH; --- 149 unchanged lines hidden (view full) --- 818.endif 819setup_SCB: 820 and SCB_CONTROL,~DISCONNECTED; 821 or SEQ_FLAGS,IDENTIFY_SEEN; /* make note of IDENTIFY */ 822 jmp mesgin_done; 823 824not_found: 825 mvi INTSTAT, NO_MATCH; |
838send_abort_msg: 839 test SEQ_FLAGS, TAGGED_SCB jnz send_abort_tag_msg; 840 mvi MSG_ABORT call mk_mesg; 841 jmp send_abort_done; 842send_abort_tag_msg: 843 mvi MSG_ABORT_TAG call mk_mesg; /* ABORT TAG message */ 844send_abort_done: 845 /* If we don't have the tag ID yet, we're "looking ahead" at state 846 * that hasn't been processed, so don't ack. 847 */ 848 cmp ARG_1, SCB_LIST_NULL je ITloop; | 826 mvi MSG_BUS_DEV_RESET call mk_mesg; |
849 jmp mesgin_done; 850 851/* 852 * Message reject? Let the kernel driver handle this. If we have an 853 * outstanding WDTR or SDTR negotiation, assume that it's a response from 854 * the target selecting 8bit or asynchronous transfer, otherwise just ignore 855 * it since we have no clue what it pertains to. 856 */ --- 311 unchanged lines hidden --- | 827 jmp mesgin_done; 828 829/* 830 * Message reject? Let the kernel driver handle this. If we have an 831 * outstanding WDTR or SDTR negotiation, assume that it's a response from 832 * the target selecting 8bit or asynchronous transfer, otherwise just ignore 833 * it since we have no clue what it pertains to. 834 */ --- 311 unchanged lines hidden --- |