1996-01-03 06:25:32 +00:00
|
|
|
/*+M***********************************************************************
|
|
|
|
*Adaptec 274x/284x/294x device driver for Linux and FreeBSD.
|
|
|
|
*
|
|
|
|
*Copyright (c) 1994 John Aycock
|
|
|
|
* The University of Calgary Department of Computer Science.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1996-04-20 21:20:31 +00:00
|
|
|
*FreeBSD, Twin, Wide, 2 command per target support, tagged queuing,
|
|
|
|
*SCB paging and other optimizations:
|
|
|
|
*Copyright (c) 1994, 1995, 1996 Justin Gibbs. All rights reserved.
|
1996-01-03 06:25:32 +00:00
|
|
|
*
|
|
|
|
*Redistribution and use in source and binary forms, with or without
|
|
|
|
*modification, are permitted provided that the following conditions
|
|
|
|
*are met:
|
|
|
|
*1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer.
|
|
|
|
*2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of Calgary
|
|
|
|
* Department of Computer Science and its contributors.
|
|
|
|
*4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
*THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
*ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
*IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
*ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
*FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
*DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
*OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
*HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
*OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
*SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*-M************************************************************************/
|
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
VERSION AIC7XXX_SEQ_VER "$Id: aic7xxx.seq,v 1.42.2.2 1996/10/06 01:24:09 gibbs Exp $"
|
1996-01-03 06:25:32 +00:00
|
|
|
|
1996-05-30 07:18:39 +00:00
|
|
|
#if defined(__NetBSD__)
|
|
|
|
#include "../../../../dev/ic/aic7xxxreg.h"
|
1996-10-06 16:38:45 +00:00
|
|
|
#include "../../../../scsi/scsi_message.h"
|
1996-05-30 07:18:39 +00:00
|
|
|
#elif defined(__FreeBSD__)
|
1996-01-03 06:25:32 +00:00
|
|
|
#include "../../dev/aic7xxx/aic7xxx_reg.h"
|
1996-10-06 16:38:45 +00:00
|
|
|
#include "../../scsi/scsi_message.h"
|
1996-05-30 07:18:39 +00:00
|
|
|
#endif
|
1996-01-03 06:25:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We can't just use ACCUM in the sequencer code because it
|
|
|
|
* must be treated specially by the assembler, and it currently
|
1996-01-29 03:12:06 +00:00
|
|
|
* looks for the symbol 'A'. This is the only register defined in
|
1996-01-03 06:25:32 +00:00
|
|
|
* the assembler's symbol space.
|
|
|
|
*/
|
|
|
|
A = ACCUM
|
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
/*
|
|
|
|
* A few words on the waiting SCB list:
|
|
|
|
* After starting the selection hardware, we check for reconnecting targets
|
1996-01-29 03:12:06 +00:00
|
|
|
* as well as for our selection to complete just in case the reselection wins
|
|
|
|
* bus arbitration. The problem with this is that we must keep track of the
|
|
|
|
* SCB that we've already pulled from the QINFIFO and started the selection
|
|
|
|
* on just in case the reselection wins so that we can retry the selection at
|
|
|
|
* a later time. This problem cannot be resolved by holding a single entry
|
|
|
|
* in scratch ram since a reconnecting target can request sense and this will
|
|
|
|
* create yet another SCB waiting for selection. The solution used here is to
|
|
|
|
* use byte 27 of the SCB as a psuedo-next pointer and to thread a list
|
1996-10-25 06:34:59 +00:00
|
|
|
* of SCBs that are awaiting selection. Since 0-0xfe are valid SCB indexes,
|
|
|
|
* SCB_LIST_NULL is 0xff which is out of range. An entry is also added to
|
|
|
|
* this list everytime a request sense occurs or after completing a non-tagged
|
|
|
|
* command for which a second SCB has been queued. The sequencer will
|
|
|
|
* automatically consume the entries.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1996-03-10 07:02:32 +00:00
|
|
|
* We assume that the kernel driver may reset us at any time, even in the
|
|
|
|
* middle of a DMA, so clear DFCNTRL too.
|
|
|
|
*/
|
|
|
|
reset:
|
|
|
|
clr DFCNTRL
|
|
|
|
clr SCSISIGO /* De-assert BSY */
|
|
|
|
/*
|
|
|
|
* We jump to start after every bus free.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
|
|
|
start:
|
1996-10-25 06:34:59 +00:00
|
|
|
and FLAGS,0x07 /* clear target specific flags */
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi SCSISEQ,ENRSELI /* Always allow reselection */
|
1996-06-08 06:54:06 +00:00
|
|
|
clr SCSIRATE /*
|
|
|
|
* We don't know the target we will
|
|
|
|
* connect to, so default to narrow
|
|
|
|
* transfers to avoid parity problems.
|
|
|
|
*/
|
1995-04-27 17:44:27 +00:00
|
|
|
poll_for_work:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Are we a twin channel device?
|
|
|
|
* For fairness, we check the other bus first,
|
|
|
|
* since we just finished a transaction on the
|
|
|
|
* current channel.
|
|
|
|
*/
|
|
|
|
test FLAGS,TWIN_BUS jz start2
|
|
|
|
xor SBLKCTL,SELBUSB /* Toggle to the other bus */
|
1995-04-27 17:44:27 +00:00
|
|
|
test SSTAT0,SELDI jnz reselect
|
1996-01-03 06:25:32 +00:00
|
|
|
xor SBLKCTL,SELBUSB /* Toggle to the original bus */
|
1994-12-31 19:26:54 +00:00
|
|
|
start2:
|
1995-04-27 17:44:27 +00:00
|
|
|
test SSTAT0,SELDI jnz reselect
|
1996-10-25 06:34:59 +00:00
|
|
|
cmp WAITING_SCBH,SCB_LIST_NULL je test_queue
|
|
|
|
start_waiting:
|
|
|
|
/*
|
|
|
|
* Pull the first entry off of the waiting SCB list
|
|
|
|
* We don't have to "test_busy" because only transactions that
|
|
|
|
* have passed that test can be in the WAITING_SCB list.
|
|
|
|
*/
|
|
|
|
mov SCBPTR,WAITING_SCBH
|
|
|
|
jmp start_scb2
|
|
|
|
test_queue:
|
|
|
|
/* Has the driver posted any work for us? */
|
1996-03-31 03:02:37 +00:00
|
|
|
mov A, QCNTMASK
|
|
|
|
test QINCNT,A jz poll_for_work
|
1996-01-03 06:25:32 +00:00
|
|
|
|
1996-01-29 03:12:06 +00:00
|
|
|
/*
|
|
|
|
* We have at least one queued SCB now and we don't have any
|
1996-10-25 06:34:59 +00:00
|
|
|
* SCBs in the list of SCBs awaiting selection. If we have
|
|
|
|
* any SCBs availible for use, pull the tag from the QINFIFO
|
|
|
|
* and get to work on it.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
test FLAGS, PAGESCBS jz dequeue_scb
|
|
|
|
call get_free_or_disc_scb
|
|
|
|
cmp SINDEX, SCB_LIST_NULL je poll_for_work
|
|
|
|
dequeue_scb:
|
|
|
|
mov CUR_SCBID,QINFIFO
|
|
|
|
test FLAGS, PAGESCBS jnz dma_queued_scb
|
|
|
|
/* In the non-paging case, the SCBID == hardware SCB index */
|
|
|
|
mov SCBPTR, CUR_SCBID
|
|
|
|
dma_queued_scb:
|
|
|
|
/*
|
|
|
|
* DMA the SCB from host ram into the current SCB location.
|
|
|
|
*/
|
|
|
|
mvi DMAPARAMS, 0xd /* HDMAEN|DIRECTION|FIFORESET */
|
|
|
|
mov CUR_SCBID call dma_scb
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* See if there is not already an active SCB for this target. This code
|
|
|
|
* locks out on a per target basis instead of target/lun. Although this
|
|
|
|
* is not ideal for devices that have multiple luns active at the same
|
|
|
|
* time, it is faster than looping through all SCB's looking for active
|
1996-10-25 06:34:59 +00:00
|
|
|
* commands. We also don't have enough spare SCB space for to store the
|
|
|
|
* SCBID of the currently busy transaction for each target/lun making it
|
|
|
|
* impossible to link up the SCBs.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1995-01-16 16:31:21 +00:00
|
|
|
test_busy:
|
1996-10-25 06:34:59 +00:00
|
|
|
test SCB_CONTROL, TAG_ENB jnz start_scb
|
|
|
|
mov SAVED_SCBPTR, SCBPTR
|
|
|
|
call index_untagged_scb
|
|
|
|
mov ARG_1, SINDIR /*
|
|
|
|
* ARG_1 should
|
|
|
|
* now have the SCB ID of
|
|
|
|
* any active, non-tagged,
|
|
|
|
* command for this target.
|
|
|
|
*/
|
|
|
|
cmp ARG_1, SCB_LIST_NULL je make_busy
|
|
|
|
test FLAGS, PAGESCBS jz simple_busy_link
|
|
|
|
/*
|
|
|
|
* Put this SCB back onto the free list. It
|
|
|
|
* may be necessary to satisfy the search for
|
|
|
|
* the active SCB.
|
|
|
|
*/
|
|
|
|
call add_scb_to_free_list
|
|
|
|
/* Find the active SCB */
|
|
|
|
mov ALLZEROS call findSCB
|
|
|
|
/* Link us in */
|
|
|
|
mov SCB_LINKED_NEXT, CUR_SCBID
|
|
|
|
/* Put it back on the disconnected list */
|
|
|
|
call add_scb_to_disc_list
|
1995-04-27 17:44:27 +00:00
|
|
|
jmp poll_for_work
|
1996-10-25 06:34:59 +00:00
|
|
|
simple_busy_link:
|
|
|
|
mov SCBPTR, ARG_1
|
|
|
|
mov SCB_LINKED_NEXT, CUR_SCBID
|
|
|
|
jmp poll_for_work
|
|
|
|
make_busy:
|
|
|
|
mov DINDIR, CUR_SCBID
|
|
|
|
mov SCBPTR, SAVED_SCBPTR
|
1994-12-31 19:26:54 +00:00
|
|
|
|
|
|
|
start_scb:
|
1996-10-25 06:34:59 +00:00
|
|
|
/*
|
|
|
|
* Place us on the waiting list in case our selection
|
|
|
|
* doesn't win during bus arbitration.
|
|
|
|
*/
|
1996-04-20 21:20:31 +00:00
|
|
|
mov SCB_NEXT,WAITING_SCBH
|
1995-04-27 17:44:27 +00:00
|
|
|
mov WAITING_SCBH, SCBPTR
|
1996-01-03 06:25:32 +00:00
|
|
|
start_scb2:
|
|
|
|
and SINDEX,0xf7,SBLKCTL /* Clear the channel select bit */
|
|
|
|
and A,0x08,SCB_TCL /* Get new channel bit */
|
|
|
|
or SINDEX,A
|
|
|
|
mov SBLKCTL,SINDEX /* select channel */
|
|
|
|
mov SCB_TCL call initialize_scsiid
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable selection phase as an initiator, and do automatic ATN
|
|
|
|
* after the selection. We do this now so that we can overlap the
|
|
|
|
* rest of our work to set up this target with the arbitration and
|
|
|
|
* selection bus phases.
|
|
|
|
*/
|
|
|
|
start_selection:
|
|
|
|
mvi SCSISEQ,0x58 /* ENSELO|ENAUTOATNO|ENRSELI */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As soon as we get a successful selection, the target should go
|
|
|
|
* into the message out phase since we have ATN asserted. Prepare
|
|
|
|
* the message to send.
|
|
|
|
*
|
|
|
|
* Messages are stored in scratch RAM starting with a length byte
|
|
|
|
* followed by the message itself.
|
|
|
|
*/
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
mk_identify:
|
1996-01-29 03:12:06 +00:00
|
|
|
and MSG0,0x7,SCB_TCL /* lun */
|
1996-10-25 06:34:59 +00:00
|
|
|
and A,DISCENB,SCB_CONTROL /* mask off disconnect privledge */
|
1996-01-29 03:12:06 +00:00
|
|
|
or MSG0,A /* or in disconnect privledge */
|
1996-10-06 16:38:45 +00:00
|
|
|
or MSG0,MSG_IDENTIFYFLAG
|
1996-01-29 03:12:06 +00:00
|
|
|
mvi MSG_LEN, 1
|
1995-02-22 01:37:52 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-04-20 21:20:31 +00:00
|
|
|
* Send a tag message if TAG_ENB is set in the SCB control block.
|
|
|
|
* Use SCB_TAG (the position in the kernel's SCB array) as the tag value.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1995-02-22 01:37:52 +00:00
|
|
|
mk_tag:
|
1996-10-06 16:38:45 +00:00
|
|
|
test SCB_CONTROL,TAG_ENB jz mk_message
|
1996-10-25 06:34:59 +00:00
|
|
|
and MSG1,0x23,SCB_CONTROL
|
|
|
|
mov MSG2,SCB_TAG
|
|
|
|
add MSG_LEN,2 /* update message length */
|
1995-02-22 01:37:52 +00:00
|
|
|
|
1996-10-06 16:38:45 +00:00
|
|
|
/*
|
|
|
|
* Interrupt the driver, and allow it to tweak the message buffer
|
|
|
|
* if it asks.
|
|
|
|
*/
|
|
|
|
mk_message:
|
|
|
|
test SCB_CONTROL,MK_MESSAGE jz wait_for_selection
|
1995-02-22 01:37:52 +00:00
|
|
|
|
1996-10-06 16:38:45 +00:00
|
|
|
mvi INTSTAT,AWAITING_MSG
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1995-08-05 06:59:17 +00:00
|
|
|
wait_for_selection:
|
1996-01-03 06:25:32 +00:00
|
|
|
test SSTAT0,SELDO jnz select
|
|
|
|
test SSTAT0,SELDI jz wait_for_selection
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reselection has been initiated by a target. Make a note that we've been
|
1996-10-25 06:34:59 +00:00
|
|
|
* reselected, but haven't seen an IDENTIFY message from the target yet.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
reselect:
|
1996-01-03 06:25:32 +00:00
|
|
|
clr MSG_LEN /* Don't have anything in the mesg buffer */
|
1995-04-27 17:44:27 +00:00
|
|
|
mov SELID call initialize_scsiid
|
1996-01-03 06:25:32 +00:00
|
|
|
or FLAGS,RESELECTED
|
|
|
|
jmp select2
|
|
|
|
|
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* After the selection, remove this SCB from the "waiting SCB"
|
1996-01-03 06:25:32 +00:00
|
|
|
* list. This is achieved by simply moving our "next" pointer into
|
|
|
|
* WAITING_SCBH. Our next pointer will be set to null the next time this
|
|
|
|
* SCB is used, so don't bother with it now.
|
|
|
|
*/
|
1995-04-27 17:44:27 +00:00
|
|
|
select:
|
1996-04-20 21:20:31 +00:00
|
|
|
mov WAITING_SCBH,SCB_NEXT
|
1995-04-27 17:44:27 +00:00
|
|
|
select2:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Initialize SCSIRATE with the appropriate value for this target.
|
1996-10-25 06:34:59 +00:00
|
|
|
* The SCSIRATE settings for each target are stored in an array
|
|
|
|
* based at TARG_SCRATCH.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
ndx_dtr:
|
|
|
|
shr A,SCSIID,4
|
|
|
|
test SBLKCTL,SELBUSB jz ndx_dtr_2
|
|
|
|
or SAVED_TCL, SELBUSB /* Add the channel bit while we're here */
|
|
|
|
or A,0x08 /* Channel B entries add 8 */
|
|
|
|
ndx_dtr_2:
|
|
|
|
add SINDEX,TARG_SCRATCH,A
|
1996-01-03 06:25:32 +00:00
|
|
|
mov SCSIRATE,SINDIR
|
|
|
|
|
1996-05-21 18:32:23 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* Initialize Ultra mode setting and clear the SCSI channel.
|
1996-05-21 18:32:23 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
ultra:
|
|
|
|
and DINDEX,0xdf,SXFRCTL0 /* default to Ultra disabled */
|
|
|
|
/*
|
|
|
|
* Set CLRCHN here before the target has entered a data transfer mode -
|
|
|
|
* with synchronous SCSI, if you do it later, you blow away some
|
|
|
|
* data in the SCSI FIFO that the target has already sent to you.
|
|
|
|
*/
|
|
|
|
or DINDEX, CLRCHN
|
|
|
|
mvi SINDEX, ULTRA_ENB_B
|
|
|
|
test SCSIID, 0x80 jnz ultra_2 /* Target ID > 7 */
|
|
|
|
test SBLKCTL, SELBUSB jnz ultra_2 /* Second channel device */
|
|
|
|
dec SINDEX
|
|
|
|
ultra_2:
|
|
|
|
mov FUNCTION1,SCSIID
|
|
|
|
mov A,FUNCTION1
|
|
|
|
test SINDIR, A jz set_sxfrctl0
|
|
|
|
or DINDEX, ULTRAEN
|
|
|
|
|
1996-05-21 18:32:23 +00:00
|
|
|
set_sxfrctl0:
|
1996-10-25 06:34:59 +00:00
|
|
|
mov SXFRCTL0,DINDEX
|
1996-05-21 18:32:23 +00:00
|
|
|
|
1996-06-08 06:54:06 +00:00
|
|
|
mvi SCSISEQ,ENAUTOATNP /*
|
|
|
|
* ATN on parity errors
|
|
|
|
* for "in" phases
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
|
|
|
mvi CLRSINT1,CLRBUSFREE
|
|
|
|
mvi CLRSINT0,0x60 /* CLRSELDI|CLRSELDO */
|
|
|
|
/*
|
|
|
|
* Main loop for information transfer phases. If BSY is false, then
|
|
|
|
* we have a bus free condition, expected or not. Otherwise, wait
|
|
|
|
* for the target to assert REQ before checking MSG, C/D and I/O
|
|
|
|
* for the bus phase.
|
|
|
|
*
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
ITloop:
|
1996-01-03 06:25:32 +00:00
|
|
|
test SSTAT1,BUSFREE jnz p_busfree
|
|
|
|
test SSTAT1,REQINIT jz ITloop
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
and A,PHASE_MASK,SCSISIGI
|
1996-01-29 03:12:06 +00:00
|
|
|
mov LASTPHASE,A
|
|
|
|
mov SCSISIGO,A
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
cmp ALLZEROS,A je p_dataout
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp A,P_DATAIN je p_datain
|
|
|
|
cmp A,P_COMMAND je p_command
|
|
|
|
cmp A,P_MESGOUT je p_mesgout
|
|
|
|
cmp A,P_STATUS je p_status
|
|
|
|
cmp A,P_MESGIN je p_mesgin
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi INTSTAT,BAD_PHASE /* unknown phase - signal driver */
|
1996-05-21 18:32:23 +00:00
|
|
|
jmp ITloop /* Try reading the bus again. */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
p_dataout:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi DMAPARAMS,0x7d /*
|
|
|
|
* WIDEODD|SCSIEN|SDMAEN|HDMAEN|
|
|
|
|
* DIRECTION|FIFORESET
|
|
|
|
*/
|
1995-08-05 17:31:39 +00:00
|
|
|
jmp data_phase_init
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* If we re-enter the data phase after going through another phase, the
|
|
|
|
* STCNT may have been cleared, so restore it from the residual field.
|
|
|
|
*/
|
1995-08-05 17:31:39 +00:00
|
|
|
data_phase_reinit:
|
1996-01-29 03:12:06 +00:00
|
|
|
mov STCNT0,SCB_RESID_DCNT0
|
|
|
|
mov STCNT1,SCB_RESID_DCNT1
|
|
|
|
mov STCNT2,SCB_RESID_DCNT2
|
1995-08-05 17:31:39 +00:00
|
|
|
jmp data_phase_loop
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1995-08-05 17:31:39 +00:00
|
|
|
p_datain:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi DMAPARAMS,0x79 /*
|
|
|
|
* WIDEODD|SCSIEN|SDMAEN|HDMAEN|
|
|
|
|
* !DIRECTION|FIFORESET
|
|
|
|
*/
|
1995-08-05 17:31:39 +00:00
|
|
|
data_phase_init:
|
1996-10-25 06:34:59 +00:00
|
|
|
call assert /*
|
|
|
|
* Ensure entering a data
|
|
|
|
* phase is okay - seen identify, etc.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1995-08-05 17:31:39 +00:00
|
|
|
test FLAGS, DPHASE jnz data_phase_reinit
|
1996-10-25 06:34:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the DMA address and counter from the SCB.
|
|
|
|
* Also set SG_COUNT and SG_NEXT in memory since we cannot
|
|
|
|
* modify the values in the SCB itself until we see a
|
|
|
|
* save data pointers message.
|
|
|
|
*/
|
|
|
|
mvi DINDEX, HADDR0
|
|
|
|
mvi SCB_DATAPTR call bcopy_7
|
|
|
|
|
|
|
|
call set_stcnt_from_hcnt
|
|
|
|
|
|
|
|
mov SG_COUNT,SCB_SGCOUNT
|
|
|
|
|
|
|
|
mvi DINDEX, SG_NEXT
|
|
|
|
mvi SCB_SGPTR call bcopy_4
|
|
|
|
|
|
|
|
/* We have seen a data phase */
|
|
|
|
or FLAGS, DPHASE
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1995-08-05 17:31:39 +00:00
|
|
|
data_phase_loop:
|
1996-06-09 17:33:18 +00:00
|
|
|
/* Guard against overruns */
|
|
|
|
test SG_COUNT, 0xff jnz data_phase_inbounds
|
|
|
|
/*
|
|
|
|
* Turn on 'Bit Bucket' mode, set the transfer count to
|
|
|
|
* 16meg and let the target run until it changes phase.
|
|
|
|
* When the transfer completes, notify the host that we
|
|
|
|
* had an overrun.
|
|
|
|
*/
|
|
|
|
or SXFRCTL1,BITBUCKET
|
|
|
|
mvi STCNT0,0xff
|
|
|
|
mvi STCNT1,0xff
|
|
|
|
mvi STCNT2,0xff
|
|
|
|
|
|
|
|
data_phase_inbounds:
|
1996-10-25 06:34:59 +00:00
|
|
|
/* If we are the last SG block, ensure wideodd is off. */
|
1995-08-05 17:31:39 +00:00
|
|
|
cmp SG_COUNT,0x01 jne data_phase_wideodd
|
1996-01-03 06:25:32 +00:00
|
|
|
and DMAPARAMS, 0xbf /* Turn off WIDEODD */
|
1995-08-05 17:31:39 +00:00
|
|
|
data_phase_wideodd:
|
|
|
|
mov DMAPARAMS call dma
|
1995-03-31 14:06:02 +00:00
|
|
|
|
1996-06-09 17:33:18 +00:00
|
|
|
/* Go tell the host about any overruns */
|
|
|
|
test SXFRCTL1,BITBUCKET jnz data_phase_overrun
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/* Exit if we had an underrun */
|
|
|
|
test SSTAT0,SDONE jz data_phase_finish /* underrun STCNT != 0 */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Advance the scatter-gather pointers if needed
|
|
|
|
*/
|
1995-08-05 17:31:39 +00:00
|
|
|
sg_advance:
|
1996-01-03 06:25:32 +00:00
|
|
|
dec SG_COUNT /* one less segment to go */
|
|
|
|
|
|
|
|
test SG_COUNT, 0xff jz data_phase_finish /* Are we done? */
|
|
|
|
|
|
|
|
clr A /* add sizeof(struct scatter) */
|
|
|
|
add SG_NEXT0,SG_SIZEOF,SG_NEXT0
|
|
|
|
adc SG_NEXT1,A,SG_NEXT1
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load a struct scatter and set up the data address and length.
|
|
|
|
* If the working value of the SG count is nonzero, then
|
|
|
|
* we need to load a new set of values.
|
|
|
|
*
|
1996-04-20 21:20:31 +00:00
|
|
|
* This, like all DMA's, assumes little-endian host data storage.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1995-08-05 17:31:39 +00:00
|
|
|
sg_load:
|
1996-01-03 06:25:32 +00:00
|
|
|
clr HCNT2
|
|
|
|
clr HCNT1
|
|
|
|
mvi HCNT0,SG_SIZEOF
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
mvi DINDEX, HADDR0
|
|
|
|
mvi SG_NEXT0 call bcopy_4
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-29 03:12:06 +00:00
|
|
|
or DFCNTRL,0xd /* HDMAEN|DIRECTION|FIFORESET */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
call dma_finish
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Copy data from FIFO into SCB data pointer and data count. This assumes
|
1996-10-25 06:34:59 +00:00
|
|
|
* that the SG segments are of the form:
|
1996-01-03 06:25:32 +00:00
|
|
|
*
|
|
|
|
* struct ahc_dma_seg {
|
1996-10-25 06:34:59 +00:00
|
|
|
* u_int32_t addr; four bytes, little-endian order
|
|
|
|
* u_int32_t len; four bytes, little endian order
|
1996-01-03 06:25:32 +00:00
|
|
|
* };
|
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
mvi HADDR0 call dfdat_in_7
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/* Load STCNT as well. It is a mirror of HCNT */
|
1996-10-25 06:34:59 +00:00
|
|
|
call set_stcnt_from_hcnt
|
|
|
|
test SSTAT1,PHASEMIS jz data_phase_loop
|
1995-08-05 17:31:39 +00:00
|
|
|
|
|
|
|
data_phase_finish:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* After a DMA finishes, save the SG and STCNT residuals back into the SCB
|
|
|
|
* We use STCNT instead of HCNT, since it's a reflection of how many bytes
|
|
|
|
* were transferred on the SCSI (as opposed to the host) bus.
|
|
|
|
*/
|
1996-01-29 03:12:06 +00:00
|
|
|
mov SCB_RESID_DCNT0,STCNT0
|
|
|
|
mov SCB_RESID_DCNT1,STCNT1
|
|
|
|
mov SCB_RESID_DCNT2,STCNT2
|
1996-01-03 06:25:32 +00:00
|
|
|
mov SCB_RESID_SGCNT, SG_COUNT
|
1994-11-17 20:19:10 +00:00
|
|
|
jmp ITloop
|
|
|
|
|
1996-06-09 17:33:18 +00:00
|
|
|
data_phase_overrun:
|
|
|
|
/*
|
|
|
|
* Turn off BITBUCKET mode and notify the host
|
|
|
|
*/
|
|
|
|
and SXFRCTL1,0x7f /* ~BITBUCKET */
|
|
|
|
mvi INTSTAT,DATA_OVERRUN
|
|
|
|
jmp ITloop
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-04-20 21:20:31 +00:00
|
|
|
* Command phase. Set up the DMA registers and let 'er rip.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
p_command:
|
|
|
|
call assert
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-04-20 21:20:31 +00:00
|
|
|
* Load HADDR and HCNT.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
mvi DINDEX, HADDR0
|
|
|
|
mvi SCB_CMDPTR call bcopy_5
|
1996-01-29 03:12:06 +00:00
|
|
|
clr HCNT1
|
|
|
|
clr HCNT2
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
call set_stcnt_from_hcnt
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
mvi 0x3d call dma # SCSIEN|SDMAEN|HDMAEN|
|
|
|
|
# DIRECTION|FIFORESET
|
|
|
|
jmp ITloop
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Status phase. Wait for the data byte to appear, then read it
|
|
|
|
* and store it into the SCB.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
p_status:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi SCB_TARGET_STATUS call inb_first
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-04-20 21:20:31 +00:00
|
|
|
* Message out phase. If there is not an active message, but the target
|
1996-01-03 06:25:32 +00:00
|
|
|
* took us into this phase anyway, build a no-op message and send it.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
p_mesgout:
|
1996-01-03 06:25:32 +00:00
|
|
|
test MSG_LEN, 0xff jnz p_mesgout_start
|
1996-10-06 16:38:45 +00:00
|
|
|
mvi MSG_NOOP call mk_mesg /* build NOP message */
|
1996-01-03 06:25:32 +00:00
|
|
|
p_mesgout_start:
|
|
|
|
/*
|
|
|
|
* Set up automatic PIO transfer from MSG0. Bit 3 in
|
|
|
|
* SXFRCTL0 (SPIOEN) is already on.
|
|
|
|
*/
|
|
|
|
mvi SINDEX,MSG0
|
1994-11-17 20:19:10 +00:00
|
|
|
mov DINDEX,MSG_LEN
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* When target asks for a byte, drop ATN if it's the last one in
|
|
|
|
* the message. Otherwise, keep going until the message is exhausted.
|
|
|
|
*
|
|
|
|
* Keep an eye out for a phase change, in case the target issues
|
|
|
|
* a MESSAGE REJECT.
|
|
|
|
*/
|
|
|
|
p_mesgout_loop:
|
1996-06-08 06:54:06 +00:00
|
|
|
test SSTAT1,PHASEMIS jnz p_mesgout_phasemis
|
1996-01-03 06:25:32 +00:00
|
|
|
test SSTAT0,SPIORDY jz p_mesgout_loop
|
1996-06-08 06:54:06 +00:00
|
|
|
test SSTAT1,PHASEMIS jnz p_mesgout_phasemis
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp DINDEX,1 jne p_mesgout_outb /* last byte? */
|
|
|
|
mvi CLRSINT1,CLRATNO /* drop ATN */
|
|
|
|
p_mesgout_outb:
|
|
|
|
dec DINDEX
|
1996-01-11 06:17:49 +00:00
|
|
|
or CLRSINT0, CLRSPIORDY
|
1994-11-17 20:19:10 +00:00
|
|
|
mov SCSIDATL,SINDIR
|
1996-01-07 19:18:28 +00:00
|
|
|
|
1994-11-17 20:19:10 +00:00
|
|
|
p_mesgout4:
|
1996-01-03 06:25:32 +00:00
|
|
|
test DINDEX,0xff jnz p_mesgout_loop
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the next bus phase after ATN drops is a message out, it means
|
|
|
|
* that the target is requesting that the last message(s) be resent.
|
|
|
|
*/
|
|
|
|
p_mesgout_snoop:
|
|
|
|
test SSTAT1,BUSFREE jnz p_mesgout_done
|
|
|
|
test SSTAT1,REQINIT jz p_mesgout_snoop
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
test SSTAT1,PHASEMIS jnz p_mesgout_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-29 03:12:06 +00:00
|
|
|
or SCSISIGO,ATNO /* turn on ATNO */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
jmp ITloop
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
p_mesgout_phasemis:
|
1996-04-20 21:20:31 +00:00
|
|
|
mvi CLRSINT1,CLRATNO /* Be sure to turn ATNO off */
|
1996-01-03 06:25:32 +00:00
|
|
|
p_mesgout_done:
|
|
|
|
clr MSG_LEN /* no active msg */
|
1994-11-17 20:19:10 +00:00
|
|
|
jmp ITloop
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Message in phase. Bytes are read using Automatic PIO mode.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
p_mesgin:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi A call inb_first /* read the 1st message byte */
|
|
|
|
mov REJBYTE,A /* save it for the driver */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-06 16:38:45 +00:00
|
|
|
test A,MSG_IDENTIFYFLAG jnz mesgin_identify
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp A,MSG_DISCONNECT je mesgin_disconnect
|
1996-10-06 16:38:45 +00:00
|
|
|
cmp A,MSG_SAVEDATAPOINTER je mesgin_sdptrs
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp ALLZEROS,A je mesgin_complete
|
1996-10-06 16:38:45 +00:00
|
|
|
cmp A,MSG_RESTOREPOINTERS je mesgin_rdptrs
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp A,MSG_EXTENDED je mesgin_extended
|
1996-10-06 16:38:45 +00:00
|
|
|
cmp A,MSG_MESSAGE_REJECT je mesgin_reject
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1995-08-06 05:15:45 +00:00
|
|
|
rej_mesgin:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* We have no idea what this message in is, so we issue a message reject
|
|
|
|
* and hope for the best. In any case, rejection should be a rare
|
|
|
|
* occurrence - signal the driver when it happens.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-01-29 03:12:06 +00:00
|
|
|
or SCSISIGO,ATNO /* turn on ATNO */
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi INTSTAT,SEND_REJECT /* let driver know */
|
1995-08-06 05:15:45 +00:00
|
|
|
|
1996-10-06 16:38:45 +00:00
|
|
|
mvi MSG_MESSAGE_REJECT call mk_mesg
|
1995-08-06 05:15:45 +00:00
|
|
|
|
|
|
|
mesgin_done:
|
1996-01-03 06:25:32 +00:00
|
|
|
call inb_last /*ack & turn auto PIO back on*/
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp ITloop
|
|
|
|
|
|
|
|
|
|
|
|
mesgin_complete:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* We got a "command complete" message, so put the SCB_TAG into the QOUTFIFO,
|
|
|
|
* and trigger a completion interrupt. Before doing so, check to see if there
|
|
|
|
* is a residual or the status byte is something other than NO_ERROR (0). In
|
|
|
|
* either of these conditions, we upload the SCB back to the host so it can
|
|
|
|
* process this information. In the case of a non zero status byte, we
|
|
|
|
* additionally interrupt the kernel driver synchronously, allowing it to
|
|
|
|
* decide if sense should be retrieved. If the kernel driver wishes to request
|
|
|
|
* sense, it will fill the kernel SCB with a request sense command and set
|
|
|
|
* RETURN_1 to SEND_SENSE. If RETURN_1 is set to SEND_SENSE we redownload
|
|
|
|
* the SCB, and process it as the next command by adding it to the waiting list.
|
|
|
|
* If the kernel driver does not wish to request sense, it need only clear
|
|
|
|
* RETURN_1, and the command is allowed to complete normally. We don't bother
|
|
|
|
* to post to the QOUTFIFO in the error cases since it would require extra
|
|
|
|
* work in the kernel driver to ensure that the entry was removed before the
|
|
|
|
* command complete code tried processing it.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* First check for residuals
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
test SCB_RESID_SGCNT,0xff jnz upload_scb
|
1996-01-03 06:25:32 +00:00
|
|
|
test SCB_TARGET_STATUS,0xff jz status_ok /* Good Status? */
|
1996-10-25 06:34:59 +00:00
|
|
|
upload_scb:
|
|
|
|
mvi DMAPARAMS, 0x9 /* HDMAEN | FIFORESET*/
|
|
|
|
mov SCB_TAG call dma_scb
|
|
|
|
check_status:
|
|
|
|
test SCB_TARGET_STATUS,0xff jz status_ok /* Just a residual? */
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi INTSTAT,BAD_STATUS /* let driver know */
|
|
|
|
cmp RETURN_1, SEND_SENSE jne status_ok
|
1996-10-25 06:34:59 +00:00
|
|
|
/* This SCB becomes the next to execute as it will retrieve sense */
|
|
|
|
mov SCB_LINKED_NEXT, SCB_TAG
|
|
|
|
jmp dma_next_scb
|
1994-12-31 19:26:54 +00:00
|
|
|
|
1994-11-17 20:19:10 +00:00
|
|
|
status_ok:
|
1996-01-03 06:25:32 +00:00
|
|
|
/* First, mark this target as free. */
|
|
|
|
test SCB_CONTROL,TAG_ENB jnz test_immediate /*
|
|
|
|
* Tagged commands
|
|
|
|
* don't busy the
|
|
|
|
* target.
|
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
mov SAVED_SCBPTR, SCBPTR
|
|
|
|
mov SAVED_LINKPTR, SCB_LINKED_NEXT
|
|
|
|
call index_untagged_scb
|
|
|
|
mov DINDIR, SAVED_LINKPTR
|
|
|
|
mov SCBPTR, SAVED_SCBPTR
|
1994-12-31 19:26:54 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
test_immediate:
|
|
|
|
test SCB_CMDLEN,0xff jnz complete /* Immediate message complete */
|
|
|
|
/*
|
|
|
|
* Pause the sequencer until the driver gets around to handling the command
|
|
|
|
* complete. This is so that any action that might require carefull timing
|
|
|
|
* with the completion of this command can occur.
|
|
|
|
*/
|
1995-07-31 08:21:59 +00:00
|
|
|
mvi INTSTAT,IMMEDDONE
|
1996-10-25 06:34:59 +00:00
|
|
|
jmp dma_next_scb
|
1994-12-31 19:26:54 +00:00
|
|
|
complete:
|
1996-10-25 06:34:59 +00:00
|
|
|
test FLAGS, PAGESCBS jz complete_post
|
|
|
|
/* Wait for a free slot - we may need to wait only in the paging case */
|
|
|
|
mov A, QOUTCNT
|
|
|
|
cmp QFULLCNT, A je complete
|
|
|
|
complete_post:
|
|
|
|
/* Post the SCB and issue an interrupt */
|
1996-04-20 21:20:31 +00:00
|
|
|
mov QOUTFIFO,SCB_TAG
|
1995-03-31 14:06:02 +00:00
|
|
|
mvi INTSTAT,CMDCMPLT
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
dma_next_scb:
|
|
|
|
cmp SCB_LINKED_NEXT, SCB_LIST_NULL je mesgin_done
|
|
|
|
test FLAGS, PAGESCBS jnz dma_next_scb2
|
|
|
|
/* Only DMA on top of ourselves if we are the SCB to download */
|
|
|
|
mov A, SCB_LINKED_NEXT
|
|
|
|
cmp SCB_TAG, A je dma_next_scb2
|
|
|
|
mov SCBPTR, A
|
|
|
|
jmp add_to_waiting_list
|
|
|
|
dma_next_scb2:
|
|
|
|
mvi DMAPARAMS, 0xd /* HDMAEN|DIRECTION|FIFORESET */
|
|
|
|
mov SCB_TAG call dma_scb
|
|
|
|
add_to_waiting_list:
|
|
|
|
mov SCB_NEXT,WAITING_SCBH
|
|
|
|
mov WAITING_SCBH, SCBPTR
|
|
|
|
or FLAGS, SCB_LISTED
|
|
|
|
jmp mesgin_done
|
1995-03-31 14:06:02 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-06 16:38:45 +00:00
|
|
|
* Is it an extended message? Copy the message to our message buffer and
|
|
|
|
* notify the host. The host will tell us whether to reject this message,
|
|
|
|
* respond to it with the message that the host placed in our message buffer,
|
|
|
|
* or simply to do nothing.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
mesgin_extended:
|
1996-10-06 16:38:45 +00:00
|
|
|
mvi MSGIN_EXT_LEN call inb_next
|
|
|
|
mov A, MSGIN_EXT_LEN
|
|
|
|
mesgin_extended_loop:
|
1996-10-25 06:34:59 +00:00
|
|
|
mov DINDEX call inb_next
|
1996-10-06 16:38:45 +00:00
|
|
|
dec A
|
1996-10-25 06:34:59 +00:00
|
|
|
cmp DINDEX, MSGIN_EXT_LASTBYTE jne mesgin_extended_loop_test
|
|
|
|
dec DINDEX /* dump by repeatedly filling the last byte */
|
|
|
|
mesgin_extended_loop_test:
|
|
|
|
test A, 0xFF jnz mesgin_extended_loop
|
1996-10-06 16:38:45 +00:00
|
|
|
mesgin_extended_intr:
|
|
|
|
mvi INTSTAT,EXTENDED_MSG /* let driver know */
|
|
|
|
cmp RETURN_1,SEND_REJ je rej_mesgin
|
|
|
|
cmp RETURN_1,SEND_MSG jne mesgin_done
|
|
|
|
/* The kernel has setup a message to be sent */
|
1996-01-29 03:12:06 +00:00
|
|
|
or SCSISIGO,ATNO /* turn on ATNO */
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Is it a disconnect message? Set a flag in the SCB to remind us
|
|
|
|
* and await the bus going free.
|
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
mesgin_disconnect:
|
1996-01-03 06:25:32 +00:00
|
|
|
or SCB_CONTROL,DISCONNECTED
|
1996-04-20 21:20:31 +00:00
|
|
|
test FLAGS, PAGESCBS jz mesgin_done
|
1996-10-25 06:34:59 +00:00
|
|
|
call add_scb_to_disc_list
|
|
|
|
or FLAGS, SCB_LISTED
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* Save data pointers message:
|
|
|
|
* Copying RAM values back to SCB, for Save Data Pointers message, but
|
|
|
|
* only if we've actually been into a data phase to change them. This
|
|
|
|
* protects against bogus data in scratch ram and the residual counts
|
|
|
|
* since they are only initialized when we go into data_in or data_out.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
mesgin_sdptrs:
|
1996-10-25 06:34:59 +00:00
|
|
|
test FLAGS, DPHASE jz mesgin_done
|
|
|
|
mov SCB_SGCOUNT,SG_COUNT
|
|
|
|
|
|
|
|
/* The SCB SGPTR becomes the next one we'll download */
|
|
|
|
mvi DINDEX, SCB_SGPTR
|
|
|
|
mvi SG_NEXT0 call bcopy_4
|
|
|
|
|
|
|
|
/* The SCB DATAPTR0 becomes the current SHADDR */
|
|
|
|
mvi DINDEX, SCB_DATAPTR0
|
|
|
|
mvi SHADDR0 call bcopy_4
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use the residual number since STCNT is corrupted by any message transfer.
|
|
|
|
*/
|
|
|
|
mvi SCB_RESID_DCNT0 call bcopy_3
|
|
|
|
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Restore pointers message? Data pointers are recopied from the
|
|
|
|
* SCB anytime we enter a data phase for the first time, so all
|
|
|
|
* we need to do is clear the DPHASE flag and let the data phase
|
|
|
|
* code do the rest.
|
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
mesgin_rdptrs:
|
1996-04-20 21:20:31 +00:00
|
|
|
and FLAGS,0xef /*
|
1996-01-03 06:25:32 +00:00
|
|
|
* !DPHASE we'll reload them
|
|
|
|
* the next time through
|
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Identify message? For a reconnecting target, this tells us the lun
|
|
|
|
* that the reconnection is for - find the correct SCB and switch to it,
|
|
|
|
* clearing the "disconnected" bit so we don't "find" it by accident later.
|
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
mesgin_identify:
|
1996-01-03 06:25:32 +00:00
|
|
|
test A,0x78 jnz rej_mesgin /*!DiscPriv|!LUNTAR|!Reserved*/
|
|
|
|
and A,0x07 /* lun in lower three bits */
|
1996-10-25 06:34:59 +00:00
|
|
|
or SAVED_TCL,A /* SAVED_TCL should be complete now */
|
1996-01-03 06:25:32 +00:00
|
|
|
call inb_last /* ACK */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here we "snoop" the bus looking for a SIMPLE QUEUE TAG message.
|
1996-04-20 21:20:31 +00:00
|
|
|
* If we get one, we use the tag returned to switch to find the proper
|
|
|
|
* SCB. With SCB paging, this requires using findSCB for both tagged
|
|
|
|
* and non-tagged transactions since the SCB may exist in any slot.
|
|
|
|
* If we're not using SCB paging, we can use the tag as the direct
|
|
|
|
* index to the SCB.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-04-20 21:20:31 +00:00
|
|
|
mvi ARG_1,SCB_LIST_NULL /* Default to no-tag */
|
1996-01-03 06:25:32 +00:00
|
|
|
snoop_tag_loop:
|
1996-10-06 16:38:45 +00:00
|
|
|
test SSTAT1,BUSFREE jnz use_findSCB
|
|
|
|
test SSTAT1,REQINIT jz snoop_tag_loop
|
|
|
|
test SSTAT1,PHASEMIS jnz use_findSCB
|
|
|
|
mvi A call inb_first
|
|
|
|
cmp A,MSG_SIMPLE_Q_TAG jne use_findSCB
|
1995-02-22 01:37:52 +00:00
|
|
|
get_tag:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi ARG_1 call inb_next /* tag value */
|
|
|
|
/*
|
|
|
|
* See if the tag is in range. The tag is < SCBCOUNT if we add
|
|
|
|
* the complement of SCBCOUNT to the incomming tag and there is
|
|
|
|
* no carry.
|
|
|
|
*/
|
|
|
|
mov A,COMP_SCBCOUNT
|
|
|
|
add SINDEX,A,ARG_1
|
|
|
|
jc abort_tag
|
|
|
|
|
|
|
|
/*
|
1996-04-20 21:20:31 +00:00
|
|
|
* Ensure that the SCB the tag points to is for an SCB transaction
|
1996-01-03 06:25:32 +00:00
|
|
|
* to the reconnecting target.
|
|
|
|
*/
|
1996-04-20 21:20:31 +00:00
|
|
|
test FLAGS, PAGESCBS jz index_by_tag
|
|
|
|
use_findSCB:
|
|
|
|
mov ALLZEROS call findSCB /* Have to search */
|
|
|
|
setup_SCB:
|
|
|
|
and SCB_CONTROL,0xfb /* clear disconnect bit in SCB */
|
|
|
|
or FLAGS,IDENTIFY_SEEN /* make note of IDENTIFY */
|
1996-10-25 06:34:59 +00:00
|
|
|
test SCB_CONTROL,TAG_ENB jnz mesgin_done /* Ack Tag */
|
1996-04-20 21:20:31 +00:00
|
|
|
jmp ITloop
|
|
|
|
index_by_tag:
|
1996-01-03 06:25:32 +00:00
|
|
|
mov SCBPTR,ARG_1
|
1995-02-22 01:37:52 +00:00
|
|
|
mov A,SAVED_TCL
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp SCB_TCL,A jne abort_tag
|
|
|
|
test SCB_CONTROL,TAG_ENB jz abort_tag
|
|
|
|
jmp setup_SCB
|
1996-04-20 21:20:31 +00:00
|
|
|
|
1995-04-09 06:40:16 +00:00
|
|
|
abort_tag:
|
1996-01-29 03:12:06 +00:00
|
|
|
or SCSISIGO,ATNO /* turn on ATNO */
|
1996-10-25 06:34:59 +00:00
|
|
|
abort_tag_msg:
|
1996-04-20 21:20:31 +00:00
|
|
|
mvi MSG_ABORT_TAG call mk_mesg /* ABORT TAG message */
|
1996-01-03 06:25:32 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Message reject? Let the kernel driver handle this. If we have an
|
|
|
|
* outstanding WDTR or SDTR negotiation, assume that it's a response from
|
|
|
|
* the target selecting 8bit or asynchronous transfer, otherwise just ignore
|
|
|
|
* it since we have no clue what it pertains to.
|
|
|
|
*/
|
1995-08-06 05:15:45 +00:00
|
|
|
mesgin_reject:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi INTSTAT, REJECT_MSG
|
1995-08-06 05:15:45 +00:00
|
|
|
jmp mesgin_done
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* [ ADD MORE MESSAGE HANDLING HERE ]
|
|
|
|
*/
|
1995-02-22 01:37:52 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Bus free phase. It might be useful to interrupt the device
|
|
|
|
* driver if we aren't expecting this. For now, make sure that
|
|
|
|
* ATN isn't being asserted and look for a new command.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
p_busfree:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi CLRSINT1,CLRATNO
|
1996-03-10 07:02:32 +00:00
|
|
|
clr LASTPHASE
|
1996-01-03 06:25:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* if this is an immediate command, perform a psuedo command complete to
|
|
|
|
* notify the driver.
|
|
|
|
*/
|
|
|
|
test SCB_CMDLEN,0xff jz status_ok
|
1996-10-25 06:34:59 +00:00
|
|
|
test FLAGS, SCB_LISTED jnz start
|
|
|
|
/*
|
|
|
|
* This SCB didn't disconnect or have a command complete,
|
|
|
|
* so put it on the free queue. It was probably the
|
|
|
|
* result of an abort of some sort. This prevents us
|
|
|
|
* from "leaking" SCBs.
|
|
|
|
*/
|
|
|
|
call add_scb_to_free_list
|
1996-01-03 06:25:32 +00:00
|
|
|
jmp start
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Locking the driver out, build a one-byte message passed in SINDEX
|
|
|
|
* if there is no active message already. SINDEX is returned intact.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
mk_mesg:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi SEQCTL,0x50 /* PAUSEDIS|FASTMODE */
|
|
|
|
test MSG_LEN,0xff jz mk_mesg1 /* Should always succeed */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hmmm. For some reason the mesg buffer is in use.
|
|
|
|
* Tell the driver. It should look at SINDEX to find
|
|
|
|
* out what we wanted to use the buffer for and resolve
|
|
|
|
* the conflict.
|
|
|
|
*/
|
|
|
|
mvi SEQCTL,0x10 /* !PAUSEDIS|FASTMODE */
|
1996-01-29 03:12:06 +00:00
|
|
|
mvi INTSTAT,MSG_BUFFER_BUSY
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
mk_mesg1:
|
1996-01-03 06:25:32 +00:00
|
|
|
mvi MSG_LEN,1 /* length = 1 */
|
|
|
|
mov MSG0,SINDEX /* 1-byte message */
|
|
|
|
mvi SEQCTL,0x10 ret /* !PAUSEDIS|FASTMODE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions to read data in Automatic PIO mode.
|
|
|
|
*
|
|
|
|
* According to Adaptec's documentation, an ACK is not sent on input from
|
|
|
|
* the target until SCSIDATL is read from. So we wait until SCSIDATL is
|
|
|
|
* latched (the usual way), then read the data byte directly off the bus
|
|
|
|
* using SCSIBUSL. When we have pulled the ATN line, or we just want to
|
|
|
|
* acknowledge the byte, then we do a dummy read from SCISDATL. The SCSI
|
|
|
|
* spec guarantees that the target will hold the data byte on the bus until
|
|
|
|
* we send our ACK.
|
|
|
|
*
|
|
|
|
* The assumption here is that these are called in a particular sequence,
|
|
|
|
* and that REQ is already set when inb_first is called. inb_{first,next}
|
|
|
|
* use the same calling convention as inb.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
inb_next:
|
1996-01-11 06:17:49 +00:00
|
|
|
or CLRSINT0, CLRSPIORDY
|
1996-01-09 16:14:03 +00:00
|
|
|
mov NONE,SCSIDATL /*dummy read from latch to ACK*/
|
|
|
|
inb_next_wait:
|
1996-06-08 06:54:06 +00:00
|
|
|
test SSTAT1,PHASEMIS jnz mesgin_phasemis
|
1996-01-09 16:14:03 +00:00
|
|
|
test SSTAT0,SPIORDY jz inb_next_wait /* wait for next byte */
|
|
|
|
inb_first:
|
1996-01-03 06:25:32 +00:00
|
|
|
mov DINDEX,SINDEX
|
1996-05-30 14:31:08 +00:00
|
|
|
test SSTAT1,PHASEMIS jnz mesgin_phasemis
|
1996-01-03 06:25:32 +00:00
|
|
|
mov DINDIR,SCSIBUSL ret /*read byte directly from bus*/
|
|
|
|
inb_last:
|
1996-01-09 16:14:03 +00:00
|
|
|
mov NONE,SCSIDATL ret /*dummy read from latch to ACK*/
|
1996-01-05 16:11:49 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
mesgin_phasemis:
|
|
|
|
/*
|
|
|
|
* We expected to receive another byte, but the target changed phase
|
|
|
|
*/
|
|
|
|
mvi INTSTAT, MSGIN_PHASEMIS
|
|
|
|
jmp ITloop
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* DMA data transfer. HADDR and HCNT must be loaded first, and
|
|
|
|
* SINDEX should contain the value to load DFCNTRL with - 0x3d for
|
|
|
|
* host->scsi, or 0x39 for scsi->host. The SCSI channel is cleared
|
|
|
|
* during initialization.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
dma:
|
|
|
|
mov DFCNTRL,SINDEX
|
|
|
|
dma1:
|
1996-01-03 06:25:32 +00:00
|
|
|
test SSTAT0,DMADONE jnz dma3
|
|
|
|
test SSTAT1,PHASEMIS jz dma1 /* ie. underrun */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We will be "done" DMAing when the transfer count goes to zero, or
|
|
|
|
* the target changes the phase (in light of this, it makes sense that
|
|
|
|
* the DMA circuitry doesn't ACK when PHASEMIS is active). If we are
|
|
|
|
* doing a SCSI->Host transfer, the data FIFO should be flushed auto-
|
|
|
|
* magically on STCNT=0 or a phase change, so just wait for FIFO empty
|
|
|
|
* status.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
dma3:
|
1996-01-03 06:25:32 +00:00
|
|
|
test SINDEX,DIRECTION jnz dma5
|
1994-11-17 20:19:10 +00:00
|
|
|
dma4:
|
1996-01-03 06:25:32 +00:00
|
|
|
test DFSTATUS,FIFOEMP jz dma4
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Now shut the DMA enables off and make sure that the DMA enables are
|
|
|
|
* actually off first lest we get an ILLSADDR.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
dma5:
|
1996-01-03 06:25:32 +00:00
|
|
|
/* disable DMA, but maintain WIDEODD */
|
1996-01-29 03:12:06 +00:00
|
|
|
and DFCNTRL,WIDEODD
|
1994-11-17 20:19:10 +00:00
|
|
|
dma6:
|
1996-01-03 06:25:32 +00:00
|
|
|
test DFCNTRL,0x38 jnz dma6 /* SCSIENACK|SDMAENACK|HDMAENACK */
|
1996-10-06 16:38:45 +00:00
|
|
|
return:
|
1994-11-17 20:19:10 +00:00
|
|
|
ret
|
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Common SCSI initialization for selection and reselection. Expects
|
|
|
|
* the target SCSI ID to be in the upper four bits of SINDEX, and A's
|
|
|
|
* contents are stomped on return.
|
|
|
|
*/
|
1995-04-27 17:44:27 +00:00
|
|
|
initialize_scsiid:
|
1996-01-03 06:25:32 +00:00
|
|
|
and SINDEX,0xf0 /* Get target ID */
|
1996-10-25 06:34:59 +00:00
|
|
|
mov SAVED_TCL, SINDEX /* Update the target portion of this */
|
1995-01-22 00:46:53 +00:00
|
|
|
and A,0x0f,SCSIID
|
|
|
|
or SINDEX,A
|
1995-04-27 17:44:27 +00:00
|
|
|
mov SCSIID,SINDEX ret
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
|
|
|
* Assert that if we've been reselected, then we've seen an IDENTIFY
|
|
|
|
* message.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
assert:
|
1996-01-03 06:25:32 +00:00
|
|
|
test FLAGS,RESELECTED jz return /* reselected? */
|
|
|
|
test FLAGS,IDENTIFY_SEEN jnz return /* seen IDENTIFY? */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
mvi INTSTAT,NO_IDENT ret /* no - tell the kernel */
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-04-20 21:20:31 +00:00
|
|
|
* Locate the SCB matching the target ID/channel/lun in SAVED_TCL, and the tag
|
|
|
|
* value in ARG_1. If ARG_1 == SCB_LIST_NULL, we're looking for a non-tagged
|
|
|
|
* SCB. Have the kernel print a warning message if it can't be found, and
|
|
|
|
* generate an ABORT/ABORT_TAG message to the target. SINDEX should be
|
1996-01-03 06:25:32 +00:00
|
|
|
* cleared on call.
|
|
|
|
*/
|
1994-11-17 20:19:10 +00:00
|
|
|
findSCB:
|
1995-02-22 01:37:52 +00:00
|
|
|
mov A,SAVED_TCL
|
1996-04-20 21:20:31 +00:00
|
|
|
mov SCBPTR,SINDEX /* switch to next SCB */
|
1996-01-03 06:25:32 +00:00
|
|
|
cmp SCB_TCL,A jne findSCB1 /* target ID/channel/lun match? */
|
|
|
|
test SCB_CONTROL,DISCONNECTED jz findSCB1 /*should be disconnected*/
|
1996-04-20 21:20:31 +00:00
|
|
|
test SCB_CONTROL,TAG_ENB jnz findTaggedSCB
|
|
|
|
cmp ARG_1,SCB_LIST_NULL je foundSCB
|
1996-10-25 06:34:59 +00:00
|
|
|
findSCB1:
|
|
|
|
inc SINDEX
|
|
|
|
mov A,SCBCOUNT
|
|
|
|
cmp SINDEX,A jne findSCB
|
|
|
|
/*
|
|
|
|
* We didn't find it. If we're paging, pull an SCB and DMA down the
|
|
|
|
* one we want. If we aren't paging or the SCB we dma down has the
|
|
|
|
* abort flag set, alert the kernel and send an abort message.
|
|
|
|
*/
|
|
|
|
test FLAGS, PAGESCBS jz find_abort
|
|
|
|
call get_free_or_disc_scb
|
|
|
|
mov CUR_SCBID, ARG_1
|
|
|
|
cmp CUR_SCBID, SCB_LIST_NULL jne find_dma_scb
|
|
|
|
call index_untagged_scb
|
|
|
|
mov CUR_SCBID, SINDIR
|
|
|
|
find_dma_scb:
|
|
|
|
mvi DMAPARAMS, 0xd /* HDMAEN|DIRECTION|FIFORESET */
|
|
|
|
mov CUR_SCBID call dma_scb
|
|
|
|
test SCB_CONTROL, ABORT_SCB jz return
|
|
|
|
find_abort:
|
|
|
|
mvi INTSTAT,NO_MATCH /* not found - signal kernel */
|
|
|
|
or SCSISIGO,ATNO /* assert ATNO */
|
|
|
|
cmp ARG_1,SCB_LIST_NULL jne abort_tag_msg
|
|
|
|
mvi MSG_ABORT call mk_mesg
|
|
|
|
jmp ITloop
|
1996-04-20 21:20:31 +00:00
|
|
|
findTaggedSCB:
|
|
|
|
mov A, ARG_1 /* Tag passed in ARG_1 */
|
|
|
|
cmp SCB_TAG,A jne findSCB1 /* Found it? */
|
|
|
|
foundSCB:
|
1996-10-25 06:34:59 +00:00
|
|
|
test SCB_CONTROL, ABORT_SCB jnz find_abort
|
|
|
|
test FLAGS,PAGESCBS jz return
|
|
|
|
rem_scb_from_disc_list:
|
1996-04-20 21:20:31 +00:00
|
|
|
/* Remove this SCB from the disconnection list */
|
|
|
|
cmp SCB_NEXT,SCB_LIST_NULL je unlink_prev
|
|
|
|
mov SAVED_LINKPTR, SCB_PREV
|
|
|
|
mov SCBPTR, SCB_NEXT
|
|
|
|
mov SCB_PREV, SAVED_LINKPTR
|
|
|
|
mov SCBPTR, SINDEX
|
|
|
|
unlink_prev:
|
|
|
|
cmp SCB_PREV,SCB_LIST_NULL je rHead/* At the head of the list */
|
|
|
|
mov SAVED_LINKPTR, SCB_NEXT
|
|
|
|
mov SCBPTR, SCB_PREV
|
|
|
|
mov SCB_NEXT, SAVED_LINKPTR
|
1996-10-25 06:34:59 +00:00
|
|
|
mov SCBPTR, SINDEX ret
|
1996-04-20 21:20:31 +00:00
|
|
|
rHead:
|
1996-10-25 06:34:59 +00:00
|
|
|
mov DISCONNECTED_SCBH,SCB_NEXT ret
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
set_stcnt_from_hcnt:
|
|
|
|
mov STCNT0, HCNT0
|
|
|
|
mov STCNT1, HCNT1
|
|
|
|
mov STCNT2, HCNT2 ret
|
|
|
|
|
|
|
|
bcopy_7:
|
|
|
|
mov DINDIR, SINDIR
|
|
|
|
mov DINDIR, SINDIR
|
|
|
|
bcopy_5:
|
|
|
|
mov DINDIR, SINDIR
|
|
|
|
bcopy_4:
|
|
|
|
mov DINDIR, SINDIR
|
|
|
|
bcopy_3:
|
|
|
|
mov DINDIR, SINDIR
|
|
|
|
mov DINDIR, SINDIR
|
|
|
|
mov DINDIR, SINDIR ret
|
|
|
|
|
|
|
|
dma_scb:
|
|
|
|
/*
|
|
|
|
* SCB index is in SINDEX. Determine the physical address in
|
|
|
|
* the host where this SCB is located and load HADDR with it.
|
|
|
|
*/
|
|
|
|
shr DINDEX, SINDEX, 3
|
|
|
|
shl A, SINDEX, 5
|
|
|
|
add HADDR0, A, HSCB_ADDR0
|
|
|
|
mov A, DINDEX
|
|
|
|
adc HADDR1, A, HSCB_ADDR1
|
|
|
|
clr A
|
|
|
|
adc HADDR2, A, HSCB_ADDR2
|
|
|
|
adc HADDR3, A, HSCB_ADDR3
|
|
|
|
/* Setup Count */
|
|
|
|
mvi HCNT0, 28
|
|
|
|
clr HCNT1
|
|
|
|
clr HCNT2
|
|
|
|
mov DFCNTRL, DMAPARAMS
|
|
|
|
test DMAPARAMS, DIRECTION jnz dma_scb_fromhost
|
|
|
|
/* Fill it with the SCB data */
|
|
|
|
call copy_scb_tofifo
|
|
|
|
mvi DFCNTRL, 0xa /* HDMAEN | FIFOFLUSH */
|
|
|
|
dma_scb_fromhost:
|
|
|
|
call dma_finish
|
|
|
|
/* If we were putting the SCB, we are done */
|
|
|
|
test DMAPARAMS, DIRECTION jz return
|
|
|
|
mvi SCBARRAY call dfdat_in_7
|
|
|
|
call dfdat_in_7_continued
|
|
|
|
call dfdat_in_7_continued
|
|
|
|
jmp dfdat_in_7_continued
|
|
|
|
dfdat_in_7:
|
|
|
|
mov DINDEX,SINDEX
|
|
|
|
dfdat_in_7_continued:
|
|
|
|
mov DINDIR,DFDAT
|
|
|
|
mov DINDIR,DFDAT
|
|
|
|
mov DINDIR,DFDAT
|
|
|
|
mov DINDIR,DFDAT
|
|
|
|
mov DINDIR,DFDAT
|
|
|
|
mov DINDIR,DFDAT
|
|
|
|
mov DINDIR,DFDAT ret
|
|
|
|
|
|
|
|
copy_scb_tofifo:
|
|
|
|
mvi SCBARRAY call dfdat_out_7
|
|
|
|
call dfdat_out_7
|
|
|
|
call dfdat_out_7
|
|
|
|
dfdat_out_7:
|
|
|
|
mov DFDAT,SINDIR
|
|
|
|
mov DFDAT,SINDIR
|
|
|
|
mov DFDAT,SINDIR
|
|
|
|
mov DFDAT,SINDIR
|
|
|
|
mov DFDAT,SINDIR
|
|
|
|
mov DFDAT,SINDIR
|
|
|
|
mov DFDAT,SINDIR ret
|
1996-01-29 03:12:06 +00:00
|
|
|
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* Wait for DMA from host memory to data FIFO to complete, then disable
|
|
|
|
* DMA and wait for it to acknowledge that it's off.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
dma_finish:
|
|
|
|
test DFSTATUS,HDONE jz dma_finish
|
|
|
|
/* Turn off DMA preserving WIDEODD */
|
|
|
|
and DFCNTRL,WIDEODD
|
|
|
|
dma_finish2:
|
|
|
|
test DFCNTRL,HDMAENACK jnz dma_finish2
|
|
|
|
ret
|
1995-08-05 17:31:39 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
index_untagged_scb:
|
|
|
|
shr SINDEX, SCB_TCL, 4
|
|
|
|
and SINDEX, 0x03 /* Bottom two bits of tid */
|
|
|
|
add SINDEX, SCB_ACTIVE0
|
|
|
|
shr A, SCB_TCL, 6 /* Target ID divided by 4 */
|
|
|
|
test SCB_TCL, SELBUSB jz index_untagged_scb2
|
|
|
|
or A, 2 /* Add 2 positions */
|
|
|
|
index_untagged_scb2:
|
|
|
|
mov SCBPTR, A /*
|
|
|
|
* Select the SCB with this
|
|
|
|
* target's information.
|
|
|
|
*/
|
|
|
|
mov DINDEX, SINDEX ret
|
1994-11-17 20:19:10 +00:00
|
|
|
|
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
get_free_or_disc_scb:
|
|
|
|
mov SINDEX, ALLZEROS
|
|
|
|
cmp FREE_SCBH, SCB_LIST_NULL jne get_free_scb
|
|
|
|
cmp DISCONNECTED_SCBH, SCB_LIST_NULL je return_error
|
|
|
|
mov SCBPTR, DISCONNECTED_SCBH
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* If we are starting a new transaction, we have to ensure that
|
|
|
|
* there is at least one SCB left in case a reselection wins out.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
test FLAGS, RESELECTED jnz dequeue_disc_scb
|
|
|
|
cmp SCB_NEXT, SCB_LIST_NULL je return_error
|
|
|
|
dequeue_disc_scb:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* If we have a residual, then we are in the middle of some I/O
|
|
|
|
* and we have to send this SCB back up to the kernel so that the
|
|
|
|
* saved data pointers and residual information isn't lost.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
test SCB_RESID_SGCNT,0xff jz unlink_disc_scb
|
|
|
|
mvi DMAPARAMS, 0x9 /* HDMAEN | FIFORESET*/
|
|
|
|
mov SCB_TAG call dma_scb
|
|
|
|
unlink_disc_scb:
|
|
|
|
call rem_scb_from_disc_list
|
|
|
|
ret
|
|
|
|
get_free_scb:
|
|
|
|
/*
|
|
|
|
* If we are starting a new transaction, we have to ensure that
|
|
|
|
* there is at least one SCB left in case a reselection wins out.
|
|
|
|
*/
|
|
|
|
test FLAGS, RESELECTED jnz dequeue_free_scb
|
|
|
|
cmp SCB_NEXT, SCB_LIST_NULL jne dequeue_free_scb
|
|
|
|
cmp DISCONNECTED_SCBH, SCB_LIST_NULL je return_error
|
|
|
|
dequeue_free_scb:
|
|
|
|
mov SCBPTR, FREE_SCBH
|
|
|
|
mov FREE_SCBH, SCB_NEXT ret
|
|
|
|
return_error:
|
|
|
|
mvi SINDEX, SCB_LIST_NULL ret
|
|
|
|
|
|
|
|
add_scb_to_free_list:
|
|
|
|
mov SCB_NEXT, FREE_SCBH
|
|
|
|
mov FREE_SCBH, SCBPTR ret
|
1994-11-17 20:19:10 +00:00
|
|
|
|
1996-10-25 06:34:59 +00:00
|
|
|
add_scb_to_disc_list:
|
1996-01-03 06:25:32 +00:00
|
|
|
/*
|
1996-10-25 06:34:59 +00:00
|
|
|
* Link this SCB into the DISCONNECTED list. This list holds the
|
|
|
|
* candidates for paging out an SCB if one is needed for a new command.
|
|
|
|
* Modifying the disconnected list is a critical(pause dissabled) section.
|
1996-01-03 06:25:32 +00:00
|
|
|
*/
|
1996-10-25 06:34:59 +00:00
|
|
|
mvi SCB_PREV, SCB_LIST_NULL
|
|
|
|
mov SCB_NEXT, DISCONNECTED_SCBH
|
|
|
|
mov DISCONNECTED_SCBH, SCBPTR
|
|
|
|
cmp SCB_NEXT,SCB_LIST_NULL je return
|
|
|
|
mov SCBPTR,SCB_NEXT
|
|
|
|
mov SCB_PREV,DISCONNECTED_SCBH
|
|
|
|
mov SCBPTR,DISCONNECTED_SCBH ret
|
|
|
|
|