aic79xx.seq (292dd876ee765c478b27c93cc51e93a558ed58bf) aic79xx.seq (53467e636b7beb350c307cc88323aae4676577f2)
1/*
2 * Adaptec U320 device driver firmware for Linux and FreeBSD.
3 *
1/*
2 * Adaptec U320 device driver firmware for Linux and FreeBSD.
3 *
4 * Copyright (c) 1994-2001 Justin T. Gibbs.
4 * Copyright (c) 1994-2001, 2004 Justin T. Gibbs.
5 * Copyright (c) 2000-2002 Adaptec Inc.
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,

--- 22 unchanged lines hidden (view full) ---

35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES.
39 *
40 * $FreeBSD$
41 */
42
5 * Copyright (c) 2000-2002 Adaptec Inc.
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,

--- 22 unchanged lines hidden (view full) ---

35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
37 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGES.
39 *
40 * $FreeBSD$
41 */
42
43VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#119 $"
43VERSION = "$Id: //depot/aic7xxx/aic7xxx/aic79xx.seq#120 $"
44PATCH_ARG_LIST = "struct ahd_softc *ahd"
45PREFIX = "ahd_"
46
47#include "aic79xx.reg"
48#include "scsi_message.h"
49
50restart:
51if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {

--- 53 unchanged lines hidden (view full) ---

105 jmp idle_loop_checkbus;
106check_waiting_list:
107 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je idle_loop_checkbus;
108 /*
109 * ENSELO is cleared by a SELDO, so we must test for SELDO
110 * one last time.
111 */
112 test SSTAT0, SELDO jnz select_out;
44PATCH_ARG_LIST = "struct ahd_softc *ahd"
45PREFIX = "ahd_"
46
47#include "aic79xx.reg"
48#include "scsi_message.h"
49
50restart:
51if ((ahd->bugs & AHD_INTCOLLISION_BUG) != 0) {

--- 53 unchanged lines hidden (view full) ---

105 jmp idle_loop_checkbus;
106check_waiting_list:
107 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je idle_loop_checkbus;
108 /*
109 * ENSELO is cleared by a SELDO, so we must test for SELDO
110 * one last time.
111 */
112 test SSTAT0, SELDO jnz select_out;
113END_CRITICAL;
114 call start_selection;
115idle_loop_checkbus:
113 call start_selection;
114idle_loop_checkbus:
116BEGIN_CRITICAL;
117 test SSTAT0, SELDO jnz select_out;
118END_CRITICAL;
119 test SSTAT0, SELDI jnz select_in;
120 test SCSIPHASE, ~DATA_PHASE_MASK jz idle_loop_check_nonpackreq;
121 test SCSISIGO, ATNO jz idle_loop_check_nonpackreq;
122 call unexpected_nonpkt_phase_find_ctxt;
123idle_loop_check_nonpackreq:
124 test SSTAT2, NONPACKREQ jz . + 2;

--- 164 unchanged lines hidden (view full) ---

289 clr INT_COALESCING_CMDCOUNT;
290 or INTCTL, SWTMINTMASK ret;
291
292BEGIN_CRITICAL;
293fetch_new_scb_inprog:
294 test CCSCBCTL, ARRDONE jz return;
295fetch_new_scb_done:
296 and CCSCBCTL, ~(CCARREN|CCSCBEN);
115 test SSTAT0, SELDO jnz select_out;
116END_CRITICAL;
117 test SSTAT0, SELDI jnz select_in;
118 test SCSIPHASE, ~DATA_PHASE_MASK jz idle_loop_check_nonpackreq;
119 test SCSISIGO, ATNO jz idle_loop_check_nonpackreq;
120 call unexpected_nonpkt_phase_find_ctxt;
121idle_loop_check_nonpackreq:
122 test SSTAT2, NONPACKREQ jz . + 2;

--- 164 unchanged lines hidden (view full) ---

287 clr INT_COALESCING_CMDCOUNT;
288 or INTCTL, SWTMINTMASK ret;
289
290BEGIN_CRITICAL;
291fetch_new_scb_inprog:
292 test CCSCBCTL, ARRDONE jz return;
293fetch_new_scb_done:
294 and CCSCBCTL, ~(CCARREN|CCSCBEN);
297 bmov REG0, SCBPTR, 2;
298 clr A;
299 add CMDS_PENDING, 1;
300 adc CMDS_PENDING[1], A;
301 if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
302 /*
303 * "Short Luns" are not placed into outgoing LQ
304 * packets in the correct byte order. Use a full
305 * sized lun field instead and fill it with the

--- 5 unchanged lines hidden (view full) ---

311 * The FIFO use count field is shared with the
312 * tag set by the host so that our SCB dma engine
313 * knows the correct location to store the SCB.
314 * Set it to zero before processing the SCB.
315 */
316 clr SCB_FIFO_USE_COUNT;
317 /* Update the next SCB address to download. */
318 bmov NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
295 clr A;
296 add CMDS_PENDING, 1;
297 adc CMDS_PENDING[1], A;
298 if ((ahd->bugs & AHD_PKT_LUN_BUG) != 0) {
299 /*
300 * "Short Luns" are not placed into outgoing LQ
301 * packets in the correct byte order. Use a full
302 * sized lun field instead and fill it with the

--- 5 unchanged lines hidden (view full) ---

308 * The FIFO use count field is shared with the
309 * tag set by the host so that our SCB dma engine
310 * knows the correct location to store the SCB.
311 * Set it to zero before processing the SCB.
312 */
313 clr SCB_FIFO_USE_COUNT;
314 /* Update the next SCB address to download. */
315 bmov NEXT_QUEUED_SCB_ADDR, SCB_NEXT_SCB_BUSADDR, 4;
316 /*
317 * NULL out the SCB links since these fields
318 * occupy the same location as SCB_NEXT_SCB_BUSADDR.
319 */
319 mvi SCB_NEXT[1], SCB_LIST_NULL;
320 mvi SCB_NEXT2[1], SCB_LIST_NULL;
321 /* Increment our position in the QINFIFO. */
322 mov NONE, SNSCB_QOFF;
320 mvi SCB_NEXT[1], SCB_LIST_NULL;
321 mvi SCB_NEXT2[1], SCB_LIST_NULL;
322 /* Increment our position in the QINFIFO. */
323 mov NONE, SNSCB_QOFF;
324
323 /*
325 /*
324 * SCBs that want to send messages are always
325 * queued independently. This ensures that they
326 * are at the head of the SCB list to select out
327 * to a target and we will see the MK_MESSAGE flag.
326 * Save SCBID of this SCB in REG0 since
327 * SCBPTR will be clobbered during target
328 * list updates. We also record the SCB's
329 * flags so that we can refer to them even
330 * after SCBPTR has been changed.
328 */
331 */
329 test SCB_CONTROL, MK_MESSAGE jnz first_new_target_scb;
332 bmov REG0, SCBPTR, 2;
333 mov A, SCB_CONTROL;
334
335 /*
336 * Find the tail SCB of the execution queue
337 * for this target.
338 */
330 shr SINDEX, 3, SCB_SCSIID;
331 and SINDEX, ~0x1;
332 mvi SINDEX[1], (WAITING_SCB_TAILS >> 8);
333 bmov DINDEX, SINDEX, 2;
334 bmov SCBPTR, SINDIR, 2;
339 shr SINDEX, 3, SCB_SCSIID;
340 and SINDEX, ~0x1;
341 mvi SINDEX[1], (WAITING_SCB_TAILS >> 8);
342 bmov DINDEX, SINDEX, 2;
343 bmov SCBPTR, SINDIR, 2;
344
345 /*
346 * Update the tail to point to the new SCB.
347 */
335 bmov DINDIR, REG0, 2;
348 bmov DINDIR, REG0, 2;
349
350 /*
351 * If the queue was empty, queue this SCB as
352 * the first for this target.
353 */
336 cmp SCBPTR[1], SCB_LIST_NULL je first_new_target_scb;
354 cmp SCBPTR[1], SCB_LIST_NULL je first_new_target_scb;
355
356 /*
357 * SCBs that want to send messages must always be
358 * at the head of their per-target queue so that
359 * ATN can be asserted even if the current
360 * negotiation agreement is packetized. If the
361 * target queue is empty, the SCB can be queued
362 * immediately. If the queue is not empty, we must
363 * wait for it to empty before entering this SCB
364 * into the waiting for selection queue. Otherwise
365 * our batching and round-robin selection scheme
366 * could allow commands to be queued out of order.
367 * To simplify the implementation, we stop pulling
368 * new commands from the host until the MK_MESSAGE
369 * SCB can be queued to the waiting for selection
370 * list.
371 */
372 test A, MK_MESSAGE jz batch_scb;
373
374 /*
375 * If the last SCB is also a MK_MESSAGE SCB, then
376 * order is preserved even if we batch.
377 */
378 test SCB_CONTROL, MK_MESSAGE jz batch_scb;
379
380 /*
381 * Defer this SCB and stop fetching new SCBs until
382 * it can be queued. Since the SCB_SCSIID of the
383 * tail SCB must be the same as that of the newly
384 * queued SCB, there is no need to restore the SCBID
385 * here.
386 */
387 or SEQ_FLAGS2, PENDING_MK_MESSAGE;
388 bmov MK_MESSAGE_SCB, REG0, 2;
389 mov MK_MESSAGE_SCSIID, SCB_SCSIID ret;
390
391batch_scb:
392 /*
393 * Otherwise just update the previous tail SCB to
394 * point to the new tail.
395 */
337 bmov SCB_NEXT, REG0, 2 ret;
396 bmov SCB_NEXT, REG0, 2 ret;
397
338first_new_target_scb:
398first_new_target_scb:
399 /*
400 * Append SCB to the tail of the waiting for
401 * selection list.
402 */
339 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je first_new_scb;
340 bmov SCBPTR, WAITING_TID_TAIL, 2;
341 bmov SCB_NEXT2, REG0, 2;
342 bmov WAITING_TID_TAIL, REG0, 2 ret;
343first_new_scb:
403 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL je first_new_scb;
404 bmov SCBPTR, WAITING_TID_TAIL, 2;
405 bmov SCB_NEXT2, REG0, 2;
406 bmov WAITING_TID_TAIL, REG0, 2 ret;
407first_new_scb:
408 /*
409 * Whole list is empty, so the head of
410 * the list must be initialized too.
411 */
344 bmov WAITING_TID_HEAD, REG0, 2;
345 bmov WAITING_TID_TAIL, REG0, 2 ret;
346END_CRITICAL;
347
348scbdma_idle:
349 /*
412 bmov WAITING_TID_HEAD, REG0, 2;
413 bmov WAITING_TID_TAIL, REG0, 2 ret;
414END_CRITICAL;
415
416scbdma_idle:
417 /*
350 * Give precedence to downloading new SCBs to execute
351 * unless select-outs are currently frozen.
418 * Don't bother downloading new SCBs to execute
419 * if select-outs are currently frozen or we have
420 * a MK_MESSAGE SCB waiting to enter the queue.
352 */
421 */
353 test SEQ_FLAGS2, SELECTOUT_QFROZEN jnz . + 2;
422 test SEQ_FLAGS2, SELECTOUT_QFROZEN|PENDING_MK_MESSAGE
423 jnz scbdma_no_new_scbs;
354BEGIN_CRITICAL;
355 test QOFF_CTLSTA, NEW_SCB_AVAIL jnz fetch_new_scb;
424BEGIN_CRITICAL;
425 test QOFF_CTLSTA, NEW_SCB_AVAIL jnz fetch_new_scb;
426scbdma_no_new_scbs:
356 cmp COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne dma_complete_scb;
357 cmp COMPLETE_SCB_HEAD[1], SCB_LIST_NULL je return;
358 /* FALLTHROUGH */
359fill_qoutfifo:
360 /*
361 * Keep track of the SCBs we are dmaing just
362 * in case the DMA fails or is aborted.
363 */

--- 302 unchanged lines hidden (view full) ---

666found_last_sent_scb:
667 bmov CURRSCB, SCBPTR, 2;
668curscb_ww_done:
669 } else {
670 bmov SCBPTR, CURRSCB, 2;
671 }
672
673 /*
427 cmp COMPLETE_DMA_SCB_HEAD[1], SCB_LIST_NULL jne dma_complete_scb;
428 cmp COMPLETE_SCB_HEAD[1], SCB_LIST_NULL je return;
429 /* FALLTHROUGH */
430fill_qoutfifo:
431 /*
432 * Keep track of the SCBs we are dmaing just
433 * in case the DMA fails or is aborted.
434 */

--- 302 unchanged lines hidden (view full) ---

737found_last_sent_scb:
738 bmov CURRSCB, SCBPTR, 2;
739curscb_ww_done:
740 } else {
741 bmov SCBPTR, CURRSCB, 2;
742 }
743
744 /*
674 * Requeue any SCBs not sent, to the tail of the waiting Q.
745 * The whole list made it. Clear our tail pointer to indicate
746 * that the per-target selection queue is now empty.
675 */
747 */
676 cmp SCB_NEXT[1], SCB_LIST_NULL je select_out_list_done;
748 cmp SCB_NEXT[1], SCB_LIST_NULL je select_out_clear_tail;
677
678 /*
749
750 /*
751 * Requeue any SCBs not sent, to the tail of the waiting Q.
679 * We know that neither the per-TID list nor the list of
752 * We know that neither the per-TID list nor the list of
680 * TIDs is empty. Use this knowledge to our advantage.
753 * TIDs is empty. Use this knowledge to our advantage and
754 * queue the remainder to the tail of the global execution
755 * queue.
681 */
682 bmov REG0, SCB_NEXT, 2;
756 */
757 bmov REG0, SCB_NEXT, 2;
758select_out_queue_remainder:
683 bmov SCBPTR, WAITING_TID_TAIL, 2;
684 bmov SCB_NEXT2, REG0, 2;
685 bmov WAITING_TID_TAIL, REG0, 2;
686 jmp select_out_inc_tid_q;
687
759 bmov SCBPTR, WAITING_TID_TAIL, 2;
760 bmov SCB_NEXT2, REG0, 2;
761 bmov WAITING_TID_TAIL, REG0, 2;
762 jmp select_out_inc_tid_q;
763
688select_out_list_done:
764select_out_clear_tail:
689 /*
765 /*
690 * The whole list made it. Just clear our TID's tail pointer
691 * unless we were queued independently due to our need to
692 * send a message.
766 * Queue any pending MK_MESSAGE SCB for this target now
767 * that the queue is empty.
693 */
768 */
694 test SCB_CONTROL, MK_MESSAGE jnz select_out_inc_tid_q;
769 test SEQ_FLAGS2, PENDING_MK_MESSAGE jz select_out_no_mk_message_scb;
770 mov A, MK_MESSAGE_SCSIID;
771 cmp SCB_SCSIID, A jne select_out_no_mk_message_scb;
772 and SEQ_FLAGS2, ~PENDING_MK_MESSAGE;
773 bmov REG0, MK_MESSAGE_SCB, 2;
774 jmp select_out_queue_remainder;
775
776select_out_no_mk_message_scb:
777 /*
778 * Clear this target's execution tail and increment the queue.
779 */
695 shr DINDEX, 3, SCB_SCSIID;
696 or DINDEX, 1; /* Want only the second byte */
697 mvi DINDEX[1], ((WAITING_SCB_TAILS) >> 8);
698 mvi DINDIR, SCB_LIST_NULL;
699select_out_inc_tid_q:
700 bmov SCBPTR, WAITING_TID_HEAD, 2;
701 bmov WAITING_TID_HEAD, SCB_NEXT2, 2;
702 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL jne . + 2;
703 mvi WAITING_TID_TAIL[1], SCB_LIST_NULL;
704 bmov SCBPTR, CURRSCB, 2;
705 mvi CLRSINT0, CLRSELDO;
780 shr DINDEX, 3, SCB_SCSIID;
781 or DINDEX, 1; /* Want only the second byte */
782 mvi DINDEX[1], ((WAITING_SCB_TAILS) >> 8);
783 mvi DINDIR, SCB_LIST_NULL;
784select_out_inc_tid_q:
785 bmov SCBPTR, WAITING_TID_HEAD, 2;
786 bmov WAITING_TID_HEAD, SCB_NEXT2, 2;
787 cmp WAITING_TID_HEAD[1], SCB_LIST_NULL jne . + 2;
788 mvi WAITING_TID_TAIL[1], SCB_LIST_NULL;
789 bmov SCBPTR, CURRSCB, 2;
790 mvi CLRSINT0, CLRSELDO;
706 test LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_phase;
707 test LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_phase;
791 test LQOSTAT2, LQOPHACHGOUTPKT jnz unexpected_nonpkt_mode_cleared;
792 test LQOSTAT1, LQOPHACHGINPKT jnz unexpected_nonpkt_mode_cleared;
708
709 /*
710 * If this is a packetized connection, return to our
711 * idle_loop and let our interrupt handler deal with
712 * any connection setup/teardown issues. The only
713 * exceptions are the case of MK_MESSAGE and task management
714 * SCBs.
715 */

--- 1406 unchanged lines hidden (view full) ---

2122 jnz unexpected_nonpkt_mode_cleared;
2123SET_SRC_MODE M_DFF0;
2124SET_DST_MODE M_DFF0;
2125 or LONGJMP_ADDR[1], INVALID_ADDR;
2126 dec SCB_FIFO_USE_COUNT;
2127 mvi DFFSXFRCTL, CLRCHN;
2128unexpected_nonpkt_mode_cleared:
2129 mvi CLRSINT2, CLRNONPACKREQ;
793
794 /*
795 * If this is a packetized connection, return to our
796 * idle_loop and let our interrupt handler deal with
797 * any connection setup/teardown issues. The only
798 * exceptions are the case of MK_MESSAGE and task management
799 * SCBs.
800 */

--- 1406 unchanged lines hidden (view full) ---

2207 jnz unexpected_nonpkt_mode_cleared;
2208SET_SRC_MODE M_DFF0;
2209SET_DST_MODE M_DFF0;
2210 or LONGJMP_ADDR[1], INVALID_ADDR;
2211 dec SCB_FIFO_USE_COUNT;
2212 mvi DFFSXFRCTL, CLRCHN;
2213unexpected_nonpkt_mode_cleared:
2214 mvi CLRSINT2, CLRNONPACKREQ;
2215 if ((ahd->bugs & AHD_BUSFREEREV_BUG) != 0) {
2216 /*
2217 * Test to ensure that the bus has not
2218 * already gone free prior to clearing
2219 * any stale busfree status. This avoids
2220 * a window whereby a busfree just after
2221 * a selection could be missed.
2222 */
2223 test SCSISIGI, BSYI jz . + 2;
2224 mvi CLRSINT1,CLRBUSFREE;
2225 or SIMODE1, ENBUSFREE;
2226 }
2130 test SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase;
2131 SET_SEQINTCODE(ENTERING_NONPACK)
2132 jmp ITloop;
2133
2134illegal_phase:
2135 SET_SEQINTCODE(ILLEGAL_PHASE)
2136 jmp ITloop;
2137

--- 56 unchanged lines hidden ---
2227 test SCSIPHASE, ~(MSG_IN_PHASE|MSG_OUT_PHASE) jnz illegal_phase;
2228 SET_SEQINTCODE(ENTERING_NONPACK)
2229 jmp ITloop;
2230
2231illegal_phase:
2232 SET_SEQINTCODE(ILLEGAL_PHASE)
2233 jmp ITloop;
2234

--- 56 unchanged lines hidden ---