Deleted Added
full compact
aic7xxx.seq (9954) aic7xxx.seq (11829)
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# Modifications/enhancements:

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

36# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37# SUCH DAMAGE.
38#
39# FreeBSD, Twin, Wide, 2 command per target support, tagged queuing and other
40# optimizations provided by Justin T. Gibbs (gibbs@FreeBSD.org)
41#
42##-M#########################################################################
43
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# Modifications/enhancements:

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

36# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37# SUCH DAMAGE.
38#
39# FreeBSD, Twin, Wide, 2 command per target support, tagged queuing and other
40# optimizations provided by Justin T. Gibbs (gibbs@FreeBSD.org)
41#
42##-M#########################################################################
43
44VERSION AIC7XXX_SEQ_VER "$Id: aic7xxx.seq,v 1.18 1995/07/31 08:21:59 gibbs Exp $"
44VERSION AIC7XXX_SEQ_VER "$Id: aic7xxx.seq,v 1.21 1995/08/06 05:15:45 gibbs Exp $"
45
46SCBMASK = 0xff
47
48SCSISEQ = 0x00
49ENRSELI = 0x10
50SXFRCTL0 = 0x01
45
46SCBMASK = 0xff
47
48SCSISEQ = 0x00
49ENRSELI = 0x10
50SXFRCTL0 = 0x01
51ULTRAEN = 0x20
51SXFRCTL1 = 0x02
52SCSISIGI = 0x03
53SCSISIGO = 0x03
54SCSIRATE = 0x04
55SCSIID = 0x05
56SCSIDATL = 0x06
57STCNT = 0x08
58STCNT+0 = 0x08

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

454# yet.
455#
456ITloop:
457 test SSTAT1,0x8 jnz p_busfree # BUSFREE
458 test SSTAT1,0x1 jz ITloop # REQINIT
459
460 and A,0xe0,SCSISIGI # CDI|IOI|MSGI
461
52SXFRCTL1 = 0x02
53SCSISIGI = 0x03
54SCSISIGO = 0x03
55SCSIRATE = 0x04
56SCSIID = 0x05
57SCSIDATL = 0x06
58STCNT = 0x08
59STCNT+0 = 0x08

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

455# yet.
456#
457ITloop:
458 test SSTAT1,0x8 jnz p_busfree # BUSFREE
459 test SSTAT1,0x1 jz ITloop # REQINIT
460
461 and A,0xe0,SCSISIGI # CDI|IOI|MSGI
462
463 mov A call scsisig
462 cmp ALLZEROS,A je p_dataout
463 cmp A,0x40 je p_datain
464 cmp A,0x80 je p_command
465 cmp A,0xc0 je p_status
466 cmp A,0xa0 je p_mesgout
467 cmp A,0xe0 je p_mesgin
468
469 mvi INTSTAT,BAD_PHASE # unknown - signal driver
470
471p_dataout:
464 cmp ALLZEROS,A je p_dataout
465 cmp A,0x40 je p_datain
466 cmp A,0x80 je p_command
467 cmp A,0xc0 je p_status
468 cmp A,0xa0 je p_mesgout
469 cmp A,0xe0 je p_mesgin
470
471 mvi INTSTAT,BAD_PHASE # unknown - signal driver
472
473p_dataout:
472 mvi 0 call scsisig # !CDO|!IOO|!MSGO
473 mvi DMAPARAMS,0x7d # WIDEODD|SCSIEN|SDMAEN|HDMAEN|
474 # DIRECTION|FIFORESET
475 jmp data_phase_init
476
477# If we re-enter the data phase after going through another phase, the
478# STCNT may have been cleared, so restore it from the residual field.
479data_phase_reinit:
480 mvi DINDEX, STCNT
481 mvi SCBARRAY+15 call bcopy_3
482 jmp data_phase_loop
483
484# Reads should not use WIDEODD since it may make the last byte for a SG segment
485# go to the next segment.
486p_datain:
474 mvi DMAPARAMS,0x7d # WIDEODD|SCSIEN|SDMAEN|HDMAEN|
475 # DIRECTION|FIFORESET
476 jmp data_phase_init
477
478# If we re-enter the data phase after going through another phase, the
479# STCNT may have been cleared, so restore it from the residual field.
480data_phase_reinit:
481 mvi DINDEX, STCNT
482 mvi SCBARRAY+15 call bcopy_3
483 jmp data_phase_loop
484
485# Reads should not use WIDEODD since it may make the last byte for a SG segment
486# go to the next segment.
487p_datain:
487 mvi 0x40 call scsisig # !CDO|IOO|!MSGO
488 mvi DMAPARAMS,0x39 # SCSIEN|SDMAEN|HDMAEN|
489 # !DIRECTION|FIFORESET
490data_phase_init:
491 call assert
492
493 test FLAGS, DPHASE jnz data_phase_reinit
494 call sg_scb2ram
495 or FLAGS, DPHASE # We have seen a data phase

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

584 mov SCBARRAY+18, SG_COUNT
585 jmp ITloop
586
587# Command phase. Set up the DMA registers and let 'er rip - the
588# two bytes after the SCB SCSI_cmd_length are zeroed by the driver,
589# so we can copy those three bytes directly into HCNT.
590#
591p_command:
488 mvi DMAPARAMS,0x39 # SCSIEN|SDMAEN|HDMAEN|
489 # !DIRECTION|FIFORESET
490data_phase_init:
491 call assert
492
493 test FLAGS, DPHASE jnz data_phase_reinit
494 call sg_scb2ram
495 or FLAGS, DPHASE # We have seen a data phase

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

584 mov SCBARRAY+18, SG_COUNT
585 jmp ITloop
586
587# Command phase. Set up the DMA registers and let 'er rip - the
588# two bytes after the SCB SCSI_cmd_length are zeroed by the driver,
589# so we can copy those three bytes directly into HCNT.
590#
591p_command:
592 mvi 0x80 call scsisig # CDO|!IOO|!MSGO
593 call assert
594
595# Load HADDR and HCNT. We can do this in one bcopy since they are neighbors
596 mvi DINDEX,HADDR
597 mvi SCBARRAY+7 call bcopy_7
598
599 mvi DINDEX,STCNT
600 mvi SCBARRAY+11 call bcopy_3
601
602 mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN|
603 # DIRECTION|FIFORESET
604 jmp ITloop
605
606# Status phase. Wait for the data byte to appear, then read it
607# and store it into the SCB.
608#
609p_status:
592 call assert
593
594# Load HADDR and HCNT. We can do this in one bcopy since they are neighbors
595 mvi DINDEX,HADDR
596 mvi SCBARRAY+7 call bcopy_7
597
598 mvi DINDEX,STCNT
599 mvi SCBARRAY+11 call bcopy_3
600
601 mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN|
602 # DIRECTION|FIFORESET
603 jmp ITloop
604
605# Status phase. Wait for the data byte to appear, then read it
606# and store it into the SCB.
607#
608p_status:
610 mvi 0xc0 call scsisig # CDO|IOO|!MSGO
611
612 mvi SCBARRAY+14 call inb_first
613 jmp mesgin_done
614
615# Message out phase. If there is no active message, but the target
616# took us into this phase anyway, build a no-op message and send it.
617#
618p_mesgout:
609
610 mvi SCBARRAY+14 call inb_first
611 jmp mesgin_done
612
613# Message out phase. If there is no active message, but the target
614# took us into this phase anyway, build a no-op message and send it.
615#
616p_mesgout:
619 mvi 0xa0 call scsisig # CDO|!IOO|MSGO
620 mvi 0x8 call mk_mesg # build NOP message
621
622 clr STCNT+2
623 clr STCNT+1
624
625# Set up automatic PIO transfer from MSG_START. Bit 3 in
626# SXFRCTL0 (SPIOEN) is already on.
627#

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

671# that the target is requesting that the last message(s) be resent.
672#
673p_mesgout5:
674 test SSTAT1,0x8 jnz p_mesgout6 # BUSFREE
675 test SSTAT1,0x1 jz p_mesgout5 # REQINIT
676
677 and A,0xe0,SCSISIGI # CDI|IOI|MSGI
678 cmp A,0xa0 jne p_mesgout6
617 mvi 0x8 call mk_mesg # build NOP message
618
619 clr STCNT+2
620 clr STCNT+1
621
622# Set up automatic PIO transfer from MSG_START. Bit 3 in
623# SXFRCTL0 (SPIOEN) is already on.
624#

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

668# that the target is requesting that the last message(s) be resent.
669#
670p_mesgout5:
671 test SSTAT1,0x8 jnz p_mesgout6 # BUSFREE
672 test SSTAT1,0x1 jz p_mesgout5 # REQINIT
673
674 and A,0xe0,SCSISIGI # CDI|IOI|MSGI
675 cmp A,0xa0 jne p_mesgout6
679 mvi 0x10 call scsisig # ATNO - re-assert ATN
676 or SINDEX,0x10,SIGSTATE # turn on ATNO
677 call scsisig # ATNO - re-assert ATN
680
681 jmp ITloop
682
683p_mesgout6:
684 mvi CLRSINT1,0x40 # CLRATNO - in case of PHASEMIS
685 and FLAGS,0xdf # no active msg
686 jmp ITloop
687
688# Message in phase. Bytes are read using Automatic PIO mode, but not
689# using inb. This alleviates a race condition, namely that if ATN had
690# to be asserted under Automatic PIO mode, it had to beat the SCSI
691# circuitry sending an ACK to the target. This showed up under heavy
692# loads and really confused things, since ABORT commands wouldn't be
693# seen by the drive after an IDENTIFY message in until it had changed
694# to a data I/O phase.
695#
696p_mesgin:
678
679 jmp ITloop
680
681p_mesgout6:
682 mvi CLRSINT1,0x40 # CLRATNO - in case of PHASEMIS
683 and FLAGS,0xdf # no active msg
684 jmp ITloop
685
686# Message in phase. Bytes are read using Automatic PIO mode, but not
687# using inb. This alleviates a race condition, namely that if ATN had
688# to be asserted under Automatic PIO mode, it had to beat the SCSI
689# circuitry sending an ACK to the target. This showed up under heavy
690# loads and really confused things, since ABORT commands wouldn't be
691# seen by the drive after an IDENTIFY message in until it had changed
692# to a data I/O phase.
693#
694p_mesgin:
697 mvi 0xe0 call scsisig # CDO|IOO|MSGO
698 mvi A call inb_first # read the 1st message byte
699 mvi REJBYTE,A # save it for the driver
700
701 test A,0x80 jnz mesgin_identify # identify message?
702 cmp A,4 je mesgin_disconnect # disconnect?
703 cmp A,2 je mesgin_sdptrs # save data pointers?
704 cmp ALLZEROS,A je mesgin_complete # command complete?
705 cmp A,3 je mesgin_rdptrs # restore pointers code?

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

752
753status_ok:
754# First, mark this target as free.
755 test SCBARRAY+0,TAG_ENB jnz complete # Tagged command
756 and FUNCTION1,0x70,SCBARRAY+1
757 mov A,FUNCTION1
758 test SCBARRAY+1,0x88 jz clear_a
759 xor ACTIVE_B,A
695 mvi A call inb_first # read the 1st message byte
696 mvi REJBYTE,A # save it for the driver
697
698 test A,0x80 jnz mesgin_identify # identify message?
699 cmp A,4 je mesgin_disconnect # disconnect?
700 cmp A,2 je mesgin_sdptrs # save data pointers?
701 cmp ALLZEROS,A je mesgin_complete # command complete?
702 cmp A,3 je mesgin_rdptrs # restore pointers code?

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

749
750status_ok:
751# First, mark this target as free.
752 test SCBARRAY+0,TAG_ENB jnz complete # Tagged command
753 and FUNCTION1,0x70,SCBARRAY+1
754 mov A,FUNCTION1
755 test SCBARRAY+1,0x88 jz clear_a
756 xor ACTIVE_B,A
760 jmp complete
757 jmp immediate
761
762clear_a:
763 xor ACTIVE_A,A
764
758
759clear_a:
760 xor ACTIVE_A,A
761
762immediate:
765 test SCBARRAY+11,0xff jnz complete # Immediate message complete
766# Pause the sequencer until the driver gets around to handling the command
767# complete. This is so that any action that might require carefull timing
768# with the completion of this command can occur.
769 mvi INTSTAT,IMMEDDONE
770 jmp poll_for_work
771complete:
772 mov QOUTFIFO,SCBPTR

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

1054# Turn on Automatic PIO mode now, before we expect to see a REQ
1055# from the target. It shouldn't hurt anything to leave it on. Set
1056# CLRCHN here before the target has entered a data transfer mode -
1057# with synchronous SCSI, if you do it later, you blow away some
1058# data in the SCSI FIFO that the target has already sent to you.
1059#
1060 clr SIGSTATE
1061
763 test SCBARRAY+11,0xff jnz complete # Immediate message complete
764# Pause the sequencer until the driver gets around to handling the command
765# complete. This is so that any action that might require carefull timing
766# with the completion of this command can occur.
767 mvi INTSTAT,IMMEDDONE
768 jmp poll_for_work
769complete:
770 mov QOUTFIFO,SCBPTR

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

1052# Turn on Automatic PIO mode now, before we expect to see a REQ
1053# from the target. It shouldn't hurt anything to leave it on. Set
1054# CLRCHN here before the target has entered a data transfer mode -
1055# with synchronous SCSI, if you do it later, you blow away some
1056# data in the SCSI FIFO that the target has already sent to you.
1057#
1058 clr SIGSTATE
1059
1062 mvi SXFRCTL0,0x8a # DFON|SPIOEN|CLRCHN
1060 or SXFRCTL0,0x8a # DFON|SPIOEN|CLRCHN
1063
1064# Make sure that the system knows we have not been through a DATA
1065# phase.
1066 and FLAGS, 0xfb # !DPHASE
1067
1068# Initialize SCSIRATE with the appropriate value for this target.
1069#
1070 call ndx_dtr

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

1215 clr RETURN_1
1216sdtr_to_rate_loop:
1217 test A,0x0f jz sdtr_to_rate_done
1218 add RETURN_1,0x18
1219 dec A
1220 jmp sdtr_to_rate_loop
1221sdtr_to_rate_done:
1222 shr RETURN_1,0x2
1061
1062# Make sure that the system knows we have not been through a DATA
1063# phase.
1064 and FLAGS, 0xfb # !DPHASE
1065
1066# Initialize SCSIRATE with the appropriate value for this target.
1067#
1068 call ndx_dtr

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

1213 clr RETURN_1
1214sdtr_to_rate_loop:
1215 test A,0x0f jz sdtr_to_rate_done
1216 add RETURN_1,0x18
1217 dec A
1218 jmp sdtr_to_rate_loop
1219sdtr_to_rate_done:
1220 shr RETURN_1,0x2
1223 add RETURN_1,0x18 ret
1224
1221 add RETURN_1,0x18
1222 test SXFRCTL0,ULTRAEN jz return
1223 shr RETURN_1,0x1
1225return:
1226 ret
1224return:
1225 ret