Deleted Added
full compact
aic7xxx.seq (41887) aic7xxx.seq (42652)
1/*
2 * Adaptec 274x/284x/294x device driver firmware for Linux and FreeBSD.
3 *
1/*
2 * Adaptec 274x/284x/294x device driver firmware for Linux and FreeBSD.
3 *
4 * Copyright (c) 1994-1998 Justin Gibbs.
4 * Copyright (c) 1994-1999 Justin Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification, immediately at the beginning of the file.

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

27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification, immediately at the beginning of the file.

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

27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * $Id: aic7xxx.seq,v 1.82 1998/12/15 08:22:42 gibbs Exp $
35 * $Id: aic7xxx.seq,v 1.83 1998/12/17 00:06:52 gibbs Exp $
36 */
37
38#include <dev/aic7xxx/aic7xxx.reg>
39#include <cam/scsi/scsi_message.h>
40
41/*
42 * A few words on the waiting SCB list:
43 * After starting the selection hardware, we check for reconnecting targets

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

210selection:
211 test SSTAT0,SELDO jnz select_out;
212 mvi CLRSINT0, CLRSELDI;
213select_in:
214 if ((ahc->flags & AHC_TARGETMODE) != 0) {
215 if ((ahc->flags & AHC_INITIATORMODE) != 0) {
216 test SSTAT0, TARGET jz initiator_reselect;
217 }
36 */
37
38#include <dev/aic7xxx/aic7xxx.reg>
39#include <cam/scsi/scsi_message.h>
40
41/*
42 * A few words on the waiting SCB list:
43 * After starting the selection hardware, we check for reconnecting targets

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

210selection:
211 test SSTAT0,SELDO jnz select_out;
212 mvi CLRSINT0, CLRSELDI;
213select_in:
214 if ((ahc->flags & AHC_TARGETMODE) != 0) {
215 if ((ahc->flags & AHC_INITIATORMODE) != 0) {
216 test SSTAT0, TARGET jz initiator_reselect;
217 }
218
218 /*
219 * We've just been selected. Assert BSY and
220 * setup the phase for receiving messages
221 * from the target.
222 */
219 /*
220 * We've just been selected. Assert BSY and
221 * setup the phase for receiving messages
222 * from the target.
223 */
223
224 mvi SCSISIGO, P_MESGOUT|BSYO;
225 mvi CLRSINT1, CLRBUSFREE;
226
227 /*
224 mvi SCSISIGO, P_MESGOUT|BSYO;
225 mvi CLRSINT1, CLRBUSFREE;
226
227 /*
228 * LAST_MSG gives an indication to the host of what
229 * went wrong should we need to terminate this selection
230 * before doing real work. Initialize it to SCB_LIST_NULL to
231 * indicate an improper initiator selection.
232 */
233 mvi LAST_MSG, SCB_LIST_NULL;
234
235 /*
236 * Setup the DMA for sending the identify and
237 * command information.
238 */
239 or SEQ_FLAGS, CMDPHASE_PENDING;
240
241 /* XXX If ring buffer is full, return busy or queue full */
242 mov A, TQINPOS;
243 if ((ahc->features & AHC_CMD_CHAN) != 0) {

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

268 } else {
269 if ((ahc->features & AHC_CMD_CHAN) != 0) {
270 and CCSCBRAM, OID, SCSIID;
271 } else {
272 and DFDAT, OID, SCSIID;
273 }
274 }
275
228 * Setup the DMA for sending the identify and
229 * command information.
230 */
231 or SEQ_FLAGS, CMDPHASE_PENDING;
232
233 /* XXX If ring buffer is full, return busy or queue full */
234 mov A, TQINPOS;
235 if ((ahc->features & AHC_CMD_CHAN) != 0) {

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

260 } else {
261 if ((ahc->features & AHC_CMD_CHAN) != 0) {
262 and CCSCBRAM, OID, SCSIID;
263 } else {
264 and DFDAT, OID, SCSIID;
265 }
266 }
267
268 /* No tag yet */
269 mvi INITIATOR_TAG, SCB_LIST_NULL;
270
276 /*
277 * If ATN isn't asserted, the target isn't interested
278 * in talking to us. Go directly to bus free.
279 */
280 test SCSISIGI, ATNI jz target_busfree;
281
282 /*
283 * Watch ATN closely now as we pull in messages from the
284 * initiator. We follow the guidlines from section 6.5
285 * of the SCSI-2 spec for what messages are allowed when.
286 */
287 call target_inb;
288
289 /*
290 * Our first message must be one of IDENTIFY, ABORT, or
291 * BUS_DEVICE_RESET.
292 */
293 /* XXX May need to be more lax here for older initiators... */
271 /*
272 * If ATN isn't asserted, the target isn't interested
273 * in talking to us. Go directly to bus free.
274 */
275 test SCSISIGI, ATNI jz target_busfree;
276
277 /*
278 * Watch ATN closely now as we pull in messages from the
279 * initiator. We follow the guidlines from section 6.5
280 * of the SCSI-2 spec for what messages are allowed when.
281 */
282 call target_inb;
283
284 /*
285 * Our first message must be one of IDENTIFY, ABORT, or
286 * BUS_DEVICE_RESET.
287 */
288 /* XXX May need to be more lax here for older initiators... */
294 test DINDEX, MSG_IDENTIFYFLAG jz more_first_messages;
289 test DINDEX, MSG_IDENTIFYFLAG jz host_target_message_loop;
295 /* Store for host */
296 if ((ahc->features & AHC_CMD_CHAN) != 0) {
297 mov CCSCBRAM, DINDEX;
298 } else {
299 mov DFDAT, DINDEX;
300 }
301
302 /* Remember for disconnection decision */

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

324 }
325
326 /*
327 * If the initiator doesn't feel like providing a tag number,
328 * we've got a failed selection and must transition to bus
329 * free.
330 */
331 test SCSISIGI, ATNI jz target_busfree;
290 /* Store for host */
291 if ((ahc->features & AHC_CMD_CHAN) != 0) {
292 mov CCSCBRAM, DINDEX;
293 } else {
294 mov DFDAT, DINDEX;
295 }
296
297 /* Remember for disconnection decision */

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

319 }
320
321 /*
322 * If the initiator doesn't feel like providing a tag number,
323 * we've got a failed selection and must transition to bus
324 * free.
325 */
326 test SCSISIGI, ATNI jz target_busfree;
327
332 /*
333 * Store the tag for the host.
334 */
335 call target_inb;
336 if ((ahc->features & AHC_CMD_CHAN) != 0) {
337 mov CCSCBRAM, DINDEX;
338 } else {
339 mov DFDAT, DINDEX;
340 }
328 /*
329 * Store the tag for the host.
330 */
331 call target_inb;
332 if ((ahc->features & AHC_CMD_CHAN) != 0) {
333 mov CCSCBRAM, DINDEX;
334 } else {
335 mov DFDAT, DINDEX;
336 }
337 mov INITIATOR_TAG, DINDEX;
341 jmp ident_messages_done;
342
343 /*
344 * Pushed message loop to allow the kernel to
338 jmp ident_messages_done;
339
340 /*
341 * Pushed message loop to allow the kernel to
345 * run it's own message state engine. To avoid an
346 * extra nop instruction after signaling the kernel,
347 * we perform the phase_lock before checking to see
348 * if we should exit the loop and skip the phase_lock
349 * in the ITloop. Performing back to back phase_locks
350 * shouldn't hurt, but why do it twice...
342 * run it's own target mode message state engine.
351 */
352host_target_message_loop:
353 mvi INTSTAT, HOST_MSG_LOOP;
354 nop;
355 cmp RETURN_1, EXIT_MSG_LOOP je target_ITloop;
356 test SSTAT0, SPIORDY jz .;
357 jmp host_target_message_loop;
358
343 */
344host_target_message_loop:
345 mvi INTSTAT, HOST_MSG_LOOP;
346 nop;
347 cmp RETURN_1, EXIT_MSG_LOOP je target_ITloop;
348 test SSTAT0, SPIORDY jz .;
349 jmp host_target_message_loop;
350
359more_first_messages:
360 /*
361 * Hmm. Now we're down to only accepting
362 * either an ABORT or BDR.
363 */
364 cmp DINDEX, MSG_ABORT je . + 2;
365 cmp DINDEX, MSG_BUS_DEV_RESET jne target_busfree;
366
367 /* Record the event and notify the host */
368 mov LAST_MSG, DINDEX;
369 jmp target_busfree;
370
371ident_messages_done:
351ident_messages_done:
372 mvi LAST_MSG, MSG_NOOP; /* We are so far successful */
373 /* Terminate the ident list */
374 if ((ahc->features & AHC_CMD_CHAN) != 0) {
375 mvi CCSCBRAM, SCB_LIST_NULL;
376 } else {
377 mvi DFDAT, SCB_LIST_NULL;
378 }
352 /* Terminate the ident list */
353 if ((ahc->features & AHC_CMD_CHAN) != 0) {
354 mvi CCSCBRAM, SCB_LIST_NULL;
355 } else {
356 mvi DFDAT, SCB_LIST_NULL;
357 }
379 or SEQ_FLAGS, TARG_CMD_PENDING;
358 or SEQ_FLAGS, TARG_CMD_PENDING|IDENTIFY_SEEN;
380 test SCSISIGI, ATNI jnz target_mesgout_pending_msg;
381 jmp target_ITloop;
382
383/*
384 * We carefully toggle SPIOEN to allow us to return the
385 * message byte we receive so it can be checked prior to
386 * driving REQ on the bus for the next byte.
387 */

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

453 or A, MSG_IDENTIFYFLAG call target_outb;
454
455 /*
456 * If we are the result of a tagged command, send
457 * a simple Q tag and the tag id.
458 */
459 test SCB_CONTROL, TAG_ENB jz . + 3;
460 mvi MSG_SIMPLE_Q_TAG call target_outb;
359 test SCSISIGI, ATNI jnz target_mesgout_pending_msg;
360 jmp target_ITloop;
361
362/*
363 * We carefully toggle SPIOEN to allow us to return the
364 * message byte we receive so it can be checked prior to
365 * driving REQ on the bus for the next byte.
366 */

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

432 or A, MSG_IDENTIFYFLAG call target_outb;
433
434 /*
435 * If we are the result of a tagged command, send
436 * a simple Q tag and the tag id.
437 */
438 test SCB_CONTROL, TAG_ENB jz . + 3;
439 mvi MSG_SIMPLE_Q_TAG call target_outb;
461 mov SCB_TAG call target_outb;
440 mov SCB_INITIATOR_TAG call target_outb;
441 mov INITIATOR_TAG, SCB_INITIATOR_TAG;
462target_synccmd:
463 /*
464 * Now determine what phases the host wants us
465 * to go through.
466 */
467 mov SEQ_FLAGS, SCB_TARGET_PHASES;
442target_synccmd:
443 /*
444 * Now determine what phases the host wants us
445 * to go through.
446 */
447 mov SEQ_FLAGS, SCB_TARGET_PHASES;
448
468
469target_ITloop:
470 /*
471 * Start honoring ATN signals now that
472 * we properly identified ourself.
473 */
474 test SCSISIGI, ATNI jnz target_mesgout;
475 test SEQ_FLAGS, CMDPHASE_PENDING jnz target_cmdphase;

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

502 mvi P_MESGIN|BSYO call change_phase;
503 test SEQ_FLAGS, DPHASE jz . + 2;
504 mvi MSG_SAVEDATAPOINTER call target_outb;
505 mvi MSG_DISCONNECT call target_outb;
506
507target_busfree:
508 clr SCSISIGO;
509 call complete_target_cmd;
449
450target_ITloop:
451 /*
452 * Start honoring ATN signals now that
453 * we properly identified ourself.
454 */
455 test SCSISIGI, ATNI jnz target_mesgout;
456 test SEQ_FLAGS, CMDPHASE_PENDING jnz target_cmdphase;

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

483 mvi P_MESGIN|BSYO call change_phase;
484 test SEQ_FLAGS, DPHASE jz . + 2;
485 mvi MSG_SAVEDATAPOINTER call target_outb;
486 mvi MSG_DISCONNECT call target_outb;
487
488target_busfree:
489 clr SCSISIGO;
490 call complete_target_cmd;
510 cmp LAST_MSG, MSG_NOOP je . + 2;
511 mvi INTSTAT, TARGET_MSG_HELP;
512 call clear_target_state;
513 jmp poll_for_work;
514
515target_cmdphase:
516 mvi P_COMMAND|BSYO call change_phase;
517 call target_inb;
518 mov A, DINDEX;
519 /* Store for host */

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

553 and SEQ_FLAGS, ~CMDPHASE_PENDING;
554 jmp target_ITloop;
555
556target_dphase:
557 /*
558 * Data direction flags are from the
559 * perspective of the initiator.
560 */
491 call clear_target_state;
492 jmp poll_for_work;
493
494target_cmdphase:
495 mvi P_COMMAND|BSYO call change_phase;
496 call target_inb;
497 mov A, DINDEX;
498 /* Store for host */

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

532 and SEQ_FLAGS, ~CMDPHASE_PENDING;
533 jmp target_ITloop;
534
535target_dphase:
536 /*
537 * Data direction flags are from the
538 * perspective of the initiator.
539 */
561 mov ALLZEROS call initialize_channel;
562 test SCB_TARGET_PHASES[1], TARGET_DATA_IN jz . + 4;
563 mvi LASTPHASE, P_DATAOUT;
564 mvi P_DATAIN|BSYO call change_phase;
540 test SCB_TARGET_PHASES[1], TARGET_DATA_IN jz . + 4;
541 mvi LASTPHASE, P_DATAOUT;
542 mvi P_DATAIN|BSYO call change_phase;
565 jmp p_data;
543 jmp . + 3;
566 mvi LASTPHASE, P_DATAIN;
567 mvi P_DATAOUT|BSYO call change_phase;
544 mvi LASTPHASE, P_DATAIN;
545 mvi P_DATAOUT|BSYO call change_phase;
546 mov ALLZEROS call initialize_channel;
568 jmp p_data;
569
570target_sphase:
571 mvi P_STATUS|BSYO call change_phase;
572 mvi LASTPHASE, P_STATUS;
573 mov SCB_TARGET_STATUS call target_outb;
574 /* XXX Watch for ATN or parity errors??? */
575 mvi SCSISIGO, P_MESGIN|BSYO;

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

680 */
681data_phase_reinit:
682 if ((ahc->features & AHC_CMD_CHAN) != 0) {
683 bmov STCNT, SCB_RESID_DCNT, 3;
684 } else {
685 mvi DINDEX, STCNT;
686 mvi SCB_RESID_DCNT call bcopy_3;
687 }
547 jmp p_data;
548
549target_sphase:
550 mvi P_STATUS|BSYO call change_phase;
551 mvi LASTPHASE, P_STATUS;
552 mov SCB_TARGET_STATUS call target_outb;
553 /* XXX Watch for ATN or parity errors??? */
554 mvi SCSISIGO, P_MESGIN|BSYO;

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

659 */
660data_phase_reinit:
661 if ((ahc->features & AHC_CMD_CHAN) != 0) {
662 bmov STCNT, SCB_RESID_DCNT, 3;
663 } else {
664 mvi DINDEX, STCNT;
665 mvi SCB_RESID_DCNT call bcopy_3;
666 }
667 and DATA_COUNT_ODD, 0x1, SCB_RESID_DCNT[0];
688 jmp data_phase_loop;
689
690p_data:
691 if ((ahc->features & AHC_ULTRA2) != 0) {
692 mvi DMAPARAMS, PRELOADEN|SCSIEN|HDMAEN;
693 } else {
694 mvi DMAPARAMS, WIDEODD|SCSIEN|SDMAEN|HDMAEN|FIFORESET;
695 }

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

714 * save data pointers message.
715 */
716 if ((ahc->features & AHC_CMD_CHAN) != 0) {
717 bmov HADDR, SCB_DATAPTR, 7;
718 } else {
719 mvi DINDEX, HADDR;
720 mvi SCB_DATAPTR call bcopy_7;
721 }
668 jmp data_phase_loop;
669
670p_data:
671 if ((ahc->features & AHC_ULTRA2) != 0) {
672 mvi DMAPARAMS, PRELOADEN|SCSIEN|HDMAEN;
673 } else {
674 mvi DMAPARAMS, WIDEODD|SCSIEN|SDMAEN|HDMAEN|FIFORESET;
675 }

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

694 * save data pointers message.
695 */
696 if ((ahc->features & AHC_CMD_CHAN) != 0) {
697 bmov HADDR, SCB_DATAPTR, 7;
698 } else {
699 mvi DINDEX, HADDR;
700 mvi SCB_DATAPTR call bcopy_7;
701 }
702 and DATA_COUNT_ODD, 0x1, SCB_DATACNT[0];
722
723 if ((ahc->features & AHC_ULTRA2) == 0) {
724 if ((ahc->features & AHC_CMD_CHAN) != 0) {
725 bmov STCNT, HCNT, 3;
726 } else {
727 call set_stcnt_from_hcnt;
728 }
729 }

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

840 * struct ahc_dma_seg {
841 * u_int32_t addr; four bytes, little-endian order
842 * u_int32_t len; four bytes, little endian order
843 * };
844 */
845 mvi HADDR call dfdat_in_7;
846 }
847
703
704 if ((ahc->features & AHC_ULTRA2) == 0) {
705 if ((ahc->features & AHC_CMD_CHAN) != 0) {
706 bmov STCNT, HCNT, 3;
707 } else {
708 call set_stcnt_from_hcnt;
709 }
710 }

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

821 * struct ahc_dma_seg {
822 * u_int32_t addr; four bytes, little-endian order
823 * u_int32_t len; four bytes, little endian order
824 * };
825 */
826 mvi HADDR call dfdat_in_7;
827 }
828
829 /* Track odd'ness */
830 test HCNT[0], 0x1 jz . + 2;
831 xor DATA_COUNT_ODD, 0x1;
832
848 if ((ahc->features & AHC_ULTRA2) == 0) {
849 /* Load STCNT as well. It is a mirror of HCNT */
850 if ((ahc->features & AHC_CMD_CHAN) != 0) {
851 bmov STCNT, HCNT, 3;
852 } else {
853 call set_stcnt_from_hcnt;
854 }
855 }

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

890
891 if ((ahc->features & AHC_ULTRA2) != 0) {
892 or SXFRCTL0, CLRSTCNT|CLRCHN;
893 }
894
895 if ((ahc->flags & AHC_TARGETMODE) != 0) {
896 test SEQ_FLAGS, DPHASE_PENDING jz ITloop;
897 and SEQ_FLAGS, ~DPHASE_PENDING;
833 if ((ahc->features & AHC_ULTRA2) == 0) {
834 /* Load STCNT as well. It is a mirror of HCNT */
835 if ((ahc->features & AHC_CMD_CHAN) != 0) {
836 bmov STCNT, HCNT, 3;
837 } else {
838 call set_stcnt_from_hcnt;
839 }
840 }

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

875
876 if ((ahc->features & AHC_ULTRA2) != 0) {
877 or SXFRCTL0, CLRSTCNT|CLRCHN;
878 }
879
880 if ((ahc->flags & AHC_TARGETMODE) != 0) {
881 test SEQ_FLAGS, DPHASE_PENDING jz ITloop;
882 and SEQ_FLAGS, ~DPHASE_PENDING;
883 /*
884 * For data-in phases, wait for any pending acks from the
885 * initiator before changing phase.
886 */
887 test DFCNTRL, DIRECTION jz target_ITloop;
888 test SSTAT1, REQINIT jnz .;
898 jmp target_ITloop;
899 }
900 jmp ITloop;
901
902data_phase_overrun:
903 if ((ahc->features & AHC_ULTRA2) != 0) {
904 call ultra2_dmafinish;
905 or SXFRCTL0, CLRSTCNT|CLRCHN;

--- 869 unchanged lines hidden ---
889 jmp target_ITloop;
890 }
891 jmp ITloop;
892
893data_phase_overrun:
894 if ((ahc->features & AHC_ULTRA2) != 0) {
895 call ultra2_dmafinish;
896 or SXFRCTL0, CLRSTCNT|CLRCHN;

--- 869 unchanged lines hidden ---