1997-10-06 23:49:17 +04:00
|
|
|
|
/* $NetBSD: aic6360.c,v 1.54 1997/10/06 19:49:17 christos Exp $ */
|
1996-03-30 19:13:24 +03:00
|
|
|
|
|
1996-06-18 20:13:05 +04:00
|
|
|
|
#ifdef DDB
|
|
|
|
|
#define integrate
|
|
|
|
|
#else
|
1996-03-30 19:13:24 +03:00
|
|
|
|
#define integrate static inline
|
1996-06-18 20:13:05 +04:00
|
|
|
|
#endif
|
1994-10-27 07:14:23 +03:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/*
|
1996-03-30 19:13:24 +03:00
|
|
|
|
* Copyright (c) 1994, 1995, 1996 Charles M. Hannum. All rights reserved.
|
1994-11-29 20:50:39 +03: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:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
* This product includes software developed by Charles M. Hannum.
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* Copyright (c) 1994 Jarle Greipsland
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Acknowledgements: Many of the algorithms used in this driver are
|
|
|
|
|
* inspired by the work of Julian Elischer (julian@tfs.com) and
|
|
|
|
|
* Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million!
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* TODO list:
|
|
|
|
|
* 1) Get the DMA stuff working.
|
|
|
|
|
* 2) Get the iov/uio stuff working. Is this a good thing ???
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* 3) Get the synch stuff working.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* 4) Rewrite it to use malloc for the acb structs instead of static alloc.?
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A few customizable items:
|
|
|
|
|
*/
|
|
|
|
|
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/* Use doubleword transfers to/from SCSI chip. Note: This requires
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* motherboard support. Basicly, some motherboard chipsets are able to
|
|
|
|
|
* split a 32 bit I/O operation into two 16 bit I/O operations,
|
|
|
|
|
* transparently to the processor. This speeds up some things, notably long
|
|
|
|
|
* data transfers.
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
#define AIC_USE_DWORDS 0
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Synchronous data transfers? */
|
1996-06-18 20:13:05 +04:00
|
|
|
|
#define AIC_USE_SYNCHRONOUS 0
|
1995-02-02 00:49:37 +03:00
|
|
|
|
#define AIC_SYNC_REQ_ACK_OFS 8
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Wide data transfers? */
|
|
|
|
|
#define AIC_USE_WIDE 0
|
|
|
|
|
#define AIC_MAX_WIDTH 0
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* Max attempts made to transmit a message */
|
|
|
|
|
#define AIC_MSG_MAX_ATTEMPT 3 /* Not used now XXX */
|
|
|
|
|
|
|
|
|
|
/* Use DMA (else we do programmed I/O using string instructions) (not yet!)*/
|
|
|
|
|
#define AIC_USE_EISA_DMA 0
|
|
|
|
|
#define AIC_USE_ISA_DMA 0
|
|
|
|
|
|
|
|
|
|
/* How to behave on the (E)ISA bus when/if DMAing (on<<4) + off in us */
|
|
|
|
|
#define EISA_BRST_TIM ((15<<4) + 1) /* 15us on, 1us off */
|
|
|
|
|
|
|
|
|
|
/* Some spin loop parameters (essentially how long to wait some places)
|
|
|
|
|
* The problem(?) is that sometimes we expect either to be able to transmit a
|
|
|
|
|
* byte or to get a new one from the SCSI bus pretty soon. In order to avoid
|
|
|
|
|
* returning from the interrupt just to get yanked back for the next byte we
|
|
|
|
|
* may spin in the interrupt routine waiting for this byte to come. How long?
|
|
|
|
|
* This is really (SCSI) device and processor dependent. Tuneable, I guess.
|
|
|
|
|
*/
|
1994-12-28 22:42:47 +03:00
|
|
|
|
#define AIC_MSGIN_SPIN 1 /* Will spinwait upto ?ms for a new msg byte */
|
|
|
|
|
#define AIC_MSGOUT_SPIN 1
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/* Include debug functions? At the end of this file there are a bunch of
|
|
|
|
|
* functions that will print out various information regarding queued SCSI
|
|
|
|
|
* commands, driver state and chip contents. You can call them from the
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* kernel debugger. If you set AIC_DEBUG to 0 they are not included (the
|
|
|
|
|
* kernel uses less memory) but you lose the debugging facilities.
|
|
|
|
|
*/
|
1994-12-28 22:42:47 +03:00
|
|
|
|
#define AIC_DEBUG 1
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#define AIC_ABORT_TIMEOUT 2000 /* time to wait for abort */
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* End of customizable parameters */
|
|
|
|
|
|
|
|
|
|
#if AIC_USE_EISA_DMA || AIC_USE_ISA_DMA
|
|
|
|
|
#error "I said not yet! Start paying attention... grumble"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
#include <sys/errno.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
#include <sys/buf.h>
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
#include <sys/user.h>
|
|
|
|
|
#include <sys/queue.h>
|
|
|
|
|
|
1996-05-13 03:51:23 +04:00
|
|
|
|
#include <machine/intr.h>
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#include <machine/pio.h>
|
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
|
#include <dev/scsipi/scsi_message.h>
|
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
|
#include <dev/isa/isavar.h>
|
1997-10-06 23:49:17 +04:00
|
|
|
|
#include <dev/ic/aic6360reg.h>
|
|
|
|
|
#include <dev/ic/aic6360var.h>
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
|
1995-09-26 22:31:15 +03:00
|
|
|
|
#ifndef DDB
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#define Debugger() panic("should call debugger here (aic6360.c)")
|
1995-09-26 22:31:15 +03:00
|
|
|
|
#endif /* ! DDB */
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
#if AIC_DEBUG
|
1996-04-30 00:02:32 +04:00
|
|
|
|
int aic_debug = 0x00; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; */
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
void aicattach __P((struct aic_softc *));
|
1995-08-13 00:30:45 +04:00
|
|
|
|
void aic_minphys __P((struct buf *));
|
1997-10-06 23:49:17 +04:00
|
|
|
|
void aic_init __P((struct aic_softc *));
|
1994-12-28 22:42:47 +03:00
|
|
|
|
void aic_done __P((struct aic_softc *, struct aic_acb *));
|
|
|
|
|
void aic_dequeue __P((struct aic_softc *, struct aic_acb *));
|
1997-08-27 15:22:52 +04:00
|
|
|
|
int aic_scsi_cmd __P((struct scsipi_xfer *));
|
|
|
|
|
int aic_poll __P((struct aic_softc *, struct scsipi_xfer *, int));
|
1996-03-30 19:13:24 +03:00
|
|
|
|
integrate void aic_sched_msgout __P((struct aic_softc *, u_char));
|
|
|
|
|
integrate void aic_setsync __P((struct aic_softc *, struct aic_tinfo *));
|
1995-01-07 04:51:07 +03:00
|
|
|
|
void aic_select __P((struct aic_softc *, struct aic_acb *));
|
1995-02-01 19:11:43 +03:00
|
|
|
|
void aic_timeout __P((void *));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
void aic_sched __P((struct aic_softc *));
|
|
|
|
|
void aic_scsi_reset __P((struct aic_softc *));
|
1995-02-01 19:11:43 +03:00
|
|
|
|
void aic_reset __P((struct aic_softc *));
|
1996-04-30 00:02:32 +04:00
|
|
|
|
void aic_free_acb __P((struct aic_softc *, struct aic_acb *, int));
|
|
|
|
|
struct aic_acb* aic_get_acb __P((struct aic_softc *, int));
|
|
|
|
|
int aic_reselect __P((struct aic_softc *, int));
|
|
|
|
|
void aic_sense __P((struct aic_softc *, struct aic_acb *));
|
|
|
|
|
void aic_msgin __P((struct aic_softc *));
|
|
|
|
|
void aic_abort __P((struct aic_softc *, struct aic_acb *));
|
|
|
|
|
void aic_msgout __P((struct aic_softc *));
|
|
|
|
|
int aic_dataout_pio __P((struct aic_softc *, u_char *, int));
|
|
|
|
|
int aic_datain_pio __P((struct aic_softc *, u_char *, int));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#if AIC_DEBUG
|
1996-04-30 00:02:32 +04:00
|
|
|
|
void aic_print_acb __P((struct aic_acb *));
|
|
|
|
|
void aic_dump_driver __P((struct aic_softc *));
|
|
|
|
|
void aic_dump6360 __P((struct aic_softc *));
|
|
|
|
|
void aic_show_scsi_cmd __P((struct aic_acb *));
|
|
|
|
|
void aic_print_active_acb __P((void));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
1996-03-17 03:43:52 +03:00
|
|
|
|
struct cfdriver aic_cd = {
|
|
|
|
|
NULL, "aic", DV_DULL
|
1994-04-26 04:05:56 +04:00
|
|
|
|
};
|
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_adapter aic_switch = {
|
1994-04-26 04:05:56 +04:00
|
|
|
|
aic_scsi_cmd,
|
|
|
|
|
aic_minphys,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
};
|
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_device aic_dev = {
|
1994-04-26 04:05:56 +04:00
|
|
|
|
NULL, /* Use default error handler */
|
|
|
|
|
NULL, /* have a queue, served by this */
|
|
|
|
|
NULL, /* have no async handler */
|
|
|
|
|
NULL, /* Use default 'done' routine */
|
|
|
|
|
};
|
|
|
|
|
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/*
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* INITIALIZATION ROUTINES (probe, attach ++)
|
|
|
|
|
*/
|
|
|
|
|
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/* Do the real search-for-device.
|
1995-01-07 04:51:07 +03:00
|
|
|
|
* Prerequisite: sc->sc_iobase should be set to the proper value
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
|
|
|
|
int
|
1997-10-06 23:49:17 +04:00
|
|
|
|
aic_find(iot, ioh)
|
|
|
|
|
bus_space_tag_t iot;
|
|
|
|
|
bus_space_handle_t ioh;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
{
|
1994-04-26 04:05:56 +04:00
|
|
|
|
char chip_id[sizeof(IDSTRING)]; /* For chips that support it */
|
|
|
|
|
int i;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* Remove aic6360 from possible powerdown mode */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, 0);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/* Thanks to mark@aggregate.com for the new method for detecting
|
|
|
|
|
* whether the chip is present or not. Bonus: may also work for
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* the AIC-6260!
|
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
AIC_TRACE(("aic: probing for aic-chip\n"));
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/*
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* Linux also init's the stack to 1-16 and then clears it,
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* 6260's don't appear to have an ID reg - mpg
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
|
|
|
|
/* Push the sequence 0,1,..,15 on the stack */
|
|
|
|
|
#define STSIZE 16
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL1, 0); /* Reset stack pointer */
|
1994-04-26 07:43:26 +04:00
|
|
|
|
for (i = 0; i < STSIZE; i++)
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, STACK, i);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
/* See if we can pull out the same sequence */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL1, 0);
|
|
|
|
|
for (i = 0; i < STSIZE && bus_space_read_1(iot, ioh, STACK) == i; i++)
|
1994-04-26 04:05:56 +04:00
|
|
|
|
;
|
|
|
|
|
if (i != STSIZE) {
|
|
|
|
|
AIC_START(("STACK futzed at %d.\n", i));
|
1997-10-06 23:49:17 +04:00
|
|
|
|
return 0;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* See if we can pull the id string out of the ID register,
|
|
|
|
|
* now only used for informational purposes.
|
|
|
|
|
*/
|
|
|
|
|
bzero(chip_id, sizeof(chip_id));
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_multi_1(iot, ioh, ID, chip_id, sizeof(IDSTRING) - 1);
|
|
|
|
|
AIC_START(("AIC found ID: %s ",chip_id));
|
|
|
|
|
AIC_START(("chip revision %d\n",
|
|
|
|
|
(int)bus_space_read_1(iot, ioh, REV)));
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Attach the AIC6360, fill out some high and low level data structures
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
aicattach(sc)
|
|
|
|
|
struct aic_softc *sc;
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
AIC_TRACE(("aicattach "));
|
|
|
|
|
sc->sc_state = AIC_INIT;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
|
|
|
|
sc->sc_initiator = 7;
|
|
|
|
|
sc->sc_freq = 20; /* XXXX Assume 20 MHz. */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* These are the bounds of the sync period, based on the frequency of
|
|
|
|
|
* the chip's clock input and the size and offset of the sync period
|
|
|
|
|
* register.
|
|
|
|
|
*
|
|
|
|
|
* For a 20Mhz clock, this gives us 25, or 100nS, or 10MB/s, as a
|
|
|
|
|
* maximum transfer rate, and 112.5, or 450nS, or 2.22MB/s, as a
|
|
|
|
|
* minimum transfer rate.
|
|
|
|
|
*/
|
|
|
|
|
sc->sc_minsync = (2 * 250) / sc->sc_freq;
|
|
|
|
|
sc->sc_maxsync = (9 * 250) / sc->sc_freq;
|
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_init(sc); /* Init chip and driver */
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
/*
|
1997-08-27 15:22:52 +04:00
|
|
|
|
* Fill in the prototype scsipi_link
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc->sc_link.scsipi_scsi.channel = SCSI_CHANNEL_ONLY_ONE;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_link.adapter_softc = sc;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc->sc_link.scsipi_scsi.adapter_target = sc->sc_initiator;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_link.adapter = &aic_switch;
|
|
|
|
|
sc->sc_link.device = &aic_dev;
|
|
|
|
|
sc->sc_link.openings = 2;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc->sc_link.scsipi_scsi.max_target = 7;
|
|
|
|
|
sc->sc_link.type = BUS_SCSI;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/*
|
|
|
|
|
* ask the adapter what subunits are present
|
|
|
|
|
*/
|
|
|
|
|
config_found(&sc->sc_dev, &sc->sc_link, scsiprint);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize AIC6360 chip itself
|
|
|
|
|
* The following conditions should hold:
|
1997-10-06 23:49:17 +04:00
|
|
|
|
* aic_isa_probe should have succeeded, i.e. the iobase address in aic_softc
|
|
|
|
|
* must be valid.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1995-02-01 19:11:43 +03:00
|
|
|
|
void
|
|
|
|
|
aic_reset(sc)
|
1995-01-07 04:51:07 +03:00
|
|
|
|
struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/*
|
|
|
|
|
* Doc. recommends to clear these two registers before
|
|
|
|
|
* operations commence
|
|
|
|
|
*/
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSITEST, 0);
|
|
|
|
|
bus_space_write_1(iot, ioh, TEST, 0);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
/* Reset SCSI-FIFO and abort any transfers */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | CLRCH | CLRSTCNT);
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* Reset DMA-FIFO */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, RSTFIFO);
|
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL1, 0);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* Disable all selection features */
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, 0);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, 0);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* Disable some interrupts */
|
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE0, 0x00);
|
|
|
|
|
/* Clear a slew of interrupts */
|
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT0, 0x7f);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* Disable some more interrupts */
|
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1, 0x00);
|
|
|
|
|
/* Clear another slew of interrupts */
|
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1, 0xef);
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* Disable synchronous transfers */
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSIRATE, 0);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* Haven't seen ant errors (yet) */
|
|
|
|
|
bus_space_write_1(iot, ioh, CLRSERR, 0x07);
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* Set our SCSI-ID */
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSIID, sc->sc_initiator << OID_S);
|
|
|
|
|
bus_space_write_1(iot, ioh, BRSTCNTRL, EISA_BRST_TIM);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pull the SCSI RST line for 500 us */
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_scsi_reset(sc)
|
|
|
|
|
struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, SCSIRSTO);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
delay(500);
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, 0);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
delay(50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
1995-02-01 19:11:43 +03:00
|
|
|
|
* Initialize aic SCSI driver.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_init(sc)
|
|
|
|
|
struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
int r;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
aic_reset(sc);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_scsi_reset(sc);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
aic_reset(sc);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state == AIC_INIT) {
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/* First time through; initialize. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
TAILQ_INIT(&sc->ready_list);
|
|
|
|
|
TAILQ_INIT(&sc->nexus_list);
|
|
|
|
|
TAILQ_INIT(&sc->free_list);
|
|
|
|
|
sc->sc_nexus = NULL;
|
|
|
|
|
acb = sc->sc_acb;
|
|
|
|
|
bzero(acb, sizeof(sc->sc_acb));
|
|
|
|
|
for (r = 0; r < sizeof(sc->sc_acb) / sizeof(*acb); r++) {
|
|
|
|
|
TAILQ_INSERT_TAIL(&sc->free_list, acb, chain);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
acb++;
|
|
|
|
|
}
|
1995-01-07 04:51:07 +03:00
|
|
|
|
bzero(&sc->sc_tinfo, sizeof(sc->sc_tinfo));
|
1994-04-26 07:43:26 +04:00
|
|
|
|
} else {
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/* Cancel any active commands. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state = AIC_CLEANING;
|
|
|
|
|
if ((acb = sc->sc_nexus) != NULL) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
acb->xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
|
untimeout(aic_timeout, acb);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_done(sc, acb);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1996-04-30 00:02:32 +04:00
|
|
|
|
while ((acb = sc->nexus_list.tqh_first) != NULL) {
|
1994-04-26 04:05:56 +04:00
|
|
|
|
acb->xs->error = XS_DRIVER_STUFFUP;
|
1994-05-05 09:35:42 +04:00
|
|
|
|
untimeout(aic_timeout, acb);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_done(sc, acb);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_prevphase = PH_INVALID;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
for (r = 0; r < 8; r++) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
struct aic_tinfo *ti = &sc->sc_tinfo[r];
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
ti->flags = 0;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
|
|
|
|
ti->flags |= DO_SYNC;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->period = sc->sc_minsync;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
ti->offset = AIC_SYNC_REQ_ACK_OFS;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
#else
|
|
|
|
|
ti->period = ti->offset = 0;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
#endif
|
|
|
|
|
#if AIC_USE_WIDE
|
|
|
|
|
ti->flags |= DO_WIDE;
|
|
|
|
|
ti->width = AIC_MAX_WIDTH;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
#else
|
|
|
|
|
ti->width = 0;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
#endif
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state = AIC_IDLE;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(sc->sc_iot, sc->sc_ioh, DMACNTRL0, INTEN);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_free_acb(sc, acb, flags)
|
|
|
|
|
struct aic_softc *sc;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int flags;
|
|
|
|
|
{
|
|
|
|
|
int s;
|
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
s = splbio();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
acb->flags = 0;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
TAILQ_INSERT_HEAD(&sc->free_list, acb, chain);
|
1995-10-03 23:58:56 +03:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If there were none, wake anybody waiting for one to come free,
|
|
|
|
|
* starting with queued entries.
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if (acb->chain.tqe_next == 0)
|
1995-01-07 04:51:07 +03:00
|
|
|
|
wakeup(&sc->free_list);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
splx(s);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_get_acb(sc, flags)
|
|
|
|
|
struct aic_softc *sc;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int flags;
|
|
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1995-10-03 23:58:56 +03:00
|
|
|
|
int s;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
s = splbio();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
while ((acb = sc->free_list.tqh_first) == NULL &&
|
1994-11-29 20:50:39 +03:00
|
|
|
|
(flags & SCSI_NOSLEEP) == 0)
|
1995-01-07 04:51:07 +03:00
|
|
|
|
tsleep(&sc->free_list, PRIBIO, "aicacb", 0);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if (acb) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
TAILQ_REMOVE(&sc->free_list, acb, chain);
|
1996-04-01 11:24:37 +04:00
|
|
|
|
acb->flags |= ACB_ALLOC;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
splx(s);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
return acb;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* DRIVER FUNCTIONS CALLABLE FROM HIGHER LEVEL DRIVERS
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Expected sequence:
|
|
|
|
|
* 1) Command inserted into ready list
|
|
|
|
|
* 2) Command selected for execution
|
|
|
|
|
* 3) Command won arbitration and has selected target device
|
|
|
|
|
* 4) Send message out (identify message, eventually also sync.negotiations)
|
|
|
|
|
* 5) Send command
|
|
|
|
|
* 5a) Receive disconnect message, disconnect.
|
|
|
|
|
* 5b) Reselected by target
|
|
|
|
|
* 5c) Receive identify message from target.
|
|
|
|
|
* 6) Send or receive data
|
|
|
|
|
* 7) Receive status
|
|
|
|
|
* 8) Receive message (command complete etc.)
|
|
|
|
|
* 9) If status == SCSI_CHECK construct a synthetic request sense SCSI cmd.
|
|
|
|
|
* Repeat 2-8 (no disconnects please...)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Start a SCSI-command
|
|
|
|
|
* This function is called by the higher level SCSI-driver to queue/run
|
|
|
|
|
* SCSI-commands.
|
|
|
|
|
*/
|
1995-08-13 00:30:45 +04:00
|
|
|
|
int
|
1994-04-26 04:05:56 +04:00
|
|
|
|
aic_scsi_cmd(xs)
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_xfer *xs;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_link *sc_link = xs->sc_link;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
struct aic_softc *sc = sc_link->adapter_softc;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
int s, flags;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_TRACE(("aic_scsi_cmd "));
|
1995-08-13 00:30:45 +04:00
|
|
|
|
AIC_CMDS(("[0x%x, %d]->%d ", (int)xs->cmd->opcode, xs->cmdlen,
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc_link->scsipi_scsi.target));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
flags = xs->flags;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if ((acb = aic_get_acb(sc, flags)) == NULL) {
|
1994-04-26 04:05:56 +04:00
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
|
return TRY_AGAIN_LATER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Initialize acb */
|
|
|
|
|
acb->xs = xs;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
acb->timeout = xs->timeout;
|
|
|
|
|
|
|
|
|
|
if (xs->flags & SCSI_RESET) {
|
|
|
|
|
acb->flags |= ACB_RESET;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
acb->scsipi_cmd_length = 0;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
acb->data_length = 0;
|
|
|
|
|
} else {
|
1997-08-27 15:22:52 +04:00
|
|
|
|
bcopy(xs->cmd, &acb->scsipi_cmd, xs->cmdlen);
|
|
|
|
|
acb->scsipi_cmd_length = xs->cmdlen;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
acb->data_addr = xs->data;
|
|
|
|
|
acb->data_length = xs->datalen;
|
|
|
|
|
}
|
1994-12-28 22:42:47 +03:00
|
|
|
|
acb->target_stat = 0;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
s = splbio();
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
TAILQ_INSERT_TAIL(&sc->ready_list, acb, chain);
|
|
|
|
|
if (sc->sc_state == AIC_IDLE)
|
|
|
|
|
aic_sched(sc);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
splx(s);
|
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((flags & SCSI_POLL) == 0)
|
|
|
|
|
return SUCCESSFULLY_QUEUED;
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* Not allowed to use interrupts, use polling instead */
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (aic_poll(sc, xs, acb->timeout)) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
aic_timeout(acb);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (aic_poll(sc, xs, acb->timeout))
|
1994-12-28 22:42:47 +03:00
|
|
|
|
aic_timeout(acb);
|
|
|
|
|
}
|
|
|
|
|
return COMPLETE;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Adjust transfer size in buffer structure
|
|
|
|
|
*/
|
1995-08-13 00:30:45 +04:00
|
|
|
|
void
|
1994-04-26 04:05:56 +04:00
|
|
|
|
aic_minphys(bp)
|
|
|
|
|
struct buf *bp;
|
|
|
|
|
{
|
1994-04-26 07:43:26 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_TRACE(("aic_minphys "));
|
1994-04-26 07:43:26 +04:00
|
|
|
|
if (bp->b_bcount > (AIC_NSEG << PGSHIFT))
|
|
|
|
|
bp->b_bcount = (AIC_NSEG << PGSHIFT);
|
1995-08-13 00:30:45 +04:00
|
|
|
|
minphys(bp);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Used when interrupt driven I/O isn't allowed, e.g. during boot.
|
|
|
|
|
*/
|
|
|
|
|
int
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_poll(sc, xs, count)
|
|
|
|
|
struct aic_softc *sc;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_xfer *xs;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
int count;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_TRACE(("aic_poll "));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
while (count) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/*
|
|
|
|
|
* If we had interrupts enabled, would we
|
|
|
|
|
* have got an interrupt?
|
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
if ((bus_space_read_1(iot, ioh, DMASTAT) & INTSTAT) != 0)
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aicintr(sc);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((xs->flags & ITSDONE) != 0)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
return 0;
|
|
|
|
|
delay(1000);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
count--;
|
|
|
|
|
}
|
1994-12-28 22:42:47 +03:00
|
|
|
|
return 1;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/*
|
|
|
|
|
* LOW LEVEL SCSI UTILITIES
|
|
|
|
|
*/
|
|
|
|
|
|
1996-03-30 19:13:24 +03:00
|
|
|
|
integrate void
|
|
|
|
|
aic_sched_msgout(sc, m)
|
|
|
|
|
struct aic_softc *sc;
|
|
|
|
|
u_char m;
|
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1996-03-30 19:13:24 +03:00
|
|
|
|
|
|
|
|
|
if (sc->sc_msgpriq == 0)
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSISIG, sc->sc_phase | ATNO);
|
1996-03-30 19:13:24 +03:00
|
|
|
|
sc->sc_msgpriq |= m;
|
|
|
|
|
}
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
1995-02-01 19:56:42 +03:00
|
|
|
|
/*
|
|
|
|
|
* Set synchronous transfer offset and period.
|
|
|
|
|
*/
|
1996-03-30 19:13:24 +03:00
|
|
|
|
integrate void
|
1995-02-01 19:56:42 +03:00
|
|
|
|
aic_setsync(sc, ti)
|
|
|
|
|
struct aic_softc *sc;
|
|
|
|
|
struct aic_tinfo *ti;
|
|
|
|
|
{
|
1996-03-30 19:13:24 +03:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
|
|
|
|
|
if (ti->offset != 0)
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSIRATE,
|
1995-02-01 19:56:42 +03:00
|
|
|
|
((ti->period * sc->sc_freq) / 250 - 2) << 4 | ti->offset);
|
|
|
|
|
else
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSIRATE, 0);
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1996-03-30 19:13:24 +03:00
|
|
|
|
}
|
1995-02-01 19:56:42 +03:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/*
|
|
|
|
|
* Start a selection. This is used by aic_sched() to select an idle target,
|
|
|
|
|
* and by aic_done() to immediately reselect a target to get sense information.
|
|
|
|
|
*/
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_select(sc, acb)
|
|
|
|
|
struct aic_softc *sc;
|
|
|
|
|
struct aic_acb *acb;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_link *sc_link = acb->xs->sc_link;
|
|
|
|
|
int target = sc_link->scsipi_scsi.target;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
struct aic_tinfo *ti = &sc->sc_tinfo[target];
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSIID,
|
|
|
|
|
sc->sc_initiator << OID_S | target);
|
1995-02-01 19:56:42 +03:00
|
|
|
|
aic_setsync(sc, ti);
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, STIMO_256ms | ENSTIMER);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Always enable reselections. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE0, ENSELDI | ENSELDO);
|
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1, ENSCSIRST | ENSELTIMO);
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, ENRESELI | ENSELO | ENAUTOATNO);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state = AIC_SELECTING;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
aic_reselect(sc, message)
|
|
|
|
|
struct aic_softc *sc;
|
1996-04-30 00:02:32 +04:00
|
|
|
|
int message;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
{
|
|
|
|
|
u_char selid, target, lun;
|
|
|
|
|
struct aic_acb *acb;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_link *sc_link;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
struct aic_tinfo *ti;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The SCSI chip made a snapshot of the data bus while the reselection
|
|
|
|
|
* was being negotiated. This enables us to determine which target did
|
|
|
|
|
* the reselect.
|
|
|
|
|
*/
|
|
|
|
|
selid = sc->sc_selid & ~(1 << sc->sc_initiator);
|
|
|
|
|
if (selid & (selid - 1)) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: reselect with invalid selid %02x; "
|
|
|
|
|
"sending DEVICE RESET\n", sc->sc_dev.dv_xname, selid);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
AIC_BREAK();
|
|
|
|
|
goto reset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Search wait queue for disconnected cmd
|
|
|
|
|
* The list should be short, so I haven't bothered with
|
|
|
|
|
* any more sophisticated structures than a simple
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* singly linked list.
|
1995-02-01 19:11:43 +03:00
|
|
|
|
*/
|
|
|
|
|
target = ffs(selid) - 1;
|
|
|
|
|
lun = message & 0x07;
|
|
|
|
|
for (acb = sc->nexus_list.tqh_first; acb != NULL;
|
|
|
|
|
acb = acb->chain.tqe_next) {
|
|
|
|
|
sc_link = acb->xs->sc_link;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
if (sc_link->scsipi_scsi.target == target && sc_link->scsipi_scsi.lun == lun)
|
1995-02-01 19:11:43 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (acb == NULL) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: reselect from target %d lun %d with no nexus; "
|
|
|
|
|
"sending ABORT\n", sc->sc_dev.dv_xname, target, lun);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
AIC_BREAK();
|
|
|
|
|
goto abort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make this nexus active again. */
|
|
|
|
|
TAILQ_REMOVE(&sc->nexus_list, acb, chain);
|
|
|
|
|
sc->sc_state = AIC_CONNECTED;
|
|
|
|
|
sc->sc_nexus = acb;
|
|
|
|
|
ti = &sc->sc_tinfo[target];
|
|
|
|
|
ti->lubusy |= (1 << lun);
|
1995-02-01 19:56:42 +03:00
|
|
|
|
aic_setsync(sc, ti);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (acb->flags & ACB_RESET)
|
|
|
|
|
aic_sched_msgout(sc, SEND_DEV_RESET);
|
|
|
|
|
else if (acb->flags & ACB_ABORT)
|
|
|
|
|
aic_sched_msgout(sc, SEND_ABORT);
|
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/* Do an implicit RESTORE POINTERS. */
|
|
|
|
|
sc->sc_dp = acb->data_addr;
|
|
|
|
|
sc->sc_dleft = acb->data_length;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc->sc_cp = (u_char *)&acb->scsipi_cmd;
|
|
|
|
|
sc->sc_cleft = acb->scsipi_cmd_length;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
|
|
reset:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_DEV_RESET);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
|
|
abort:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_ABORT);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
return (1);
|
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/*
|
|
|
|
|
* Schedule a SCSI operation. This has now been pulled out of the interrupt
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* handler so that we may call it from aic_scsi_cmd and aic_done. This may
|
|
|
|
|
* save us an unecessary interrupt just to get things going. Should only be
|
|
|
|
|
* called when state == AIC_IDLE and at bio pl.
|
|
|
|
|
*/
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_sched(sc)
|
|
|
|
|
register struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_link *sc_link;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
struct aic_tinfo *ti;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/*
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* Find first acb in ready queue that is for a target/lunit pair that
|
|
|
|
|
* is not busy.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1,
|
|
|
|
|
CLRSELTIMO | CLRBUSFREE | CLRSCSIPERR);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
for (acb = sc->ready_list.tqh_first; acb != NULL;
|
1994-11-30 00:29:56 +03:00
|
|
|
|
acb = acb->chain.tqe_next) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc_link = acb->xs->sc_link;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti = &sc->sc_tinfo[sc_link->scsipi_scsi.target];
|
|
|
|
|
if ((ti->lubusy & (1 << sc_link->scsipi_scsi.lun)) == 0) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_MISC(("selecting %d:%d ",
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc_link->scsipi_scsi.target, sc_link->scsipi_scsi.lun));
|
1995-01-07 04:51:07 +03:00
|
|
|
|
TAILQ_REMOVE(&sc->ready_list, acb, chain);
|
|
|
|
|
sc->sc_nexus = acb;
|
|
|
|
|
aic_select(sc, acb);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
return;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
} else
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_MISC(("%d:%d busy\n",
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc_link->scsipi_scsi.target, sc_link->scsipi_scsi.lun));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_MISC(("idle "));
|
|
|
|
|
/* Nothing to start; just enable reselections and wait. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE0, ENSELDI);
|
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1, ENSCSIRST);
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, ENRESELI);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
void
|
|
|
|
|
aic_sense(sc, acb)
|
|
|
|
|
struct aic_softc *sc;
|
|
|
|
|
struct aic_acb *acb;
|
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_xfer *xs = acb->xs;
|
|
|
|
|
struct scsipi_link *sc_link = xs->sc_link;
|
|
|
|
|
struct aic_tinfo *ti = &sc->sc_tinfo[sc_link->scsipi_scsi.target];
|
|
|
|
|
struct scsipi_sense *ss = (void *)&acb->scsipi_cmd;
|
1996-04-01 11:24:37 +04:00
|
|
|
|
|
|
|
|
|
AIC_MISC(("requesting sense "));
|
|
|
|
|
/* Next, setup a request sense command block */
|
|
|
|
|
bzero(ss, sizeof(*ss));
|
|
|
|
|
ss->opcode = REQUEST_SENSE;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ss->byte2 = sc_link->scsipi_scsi.lun << 5;
|
|
|
|
|
ss->length = sizeof(struct scsipi_sense_data);
|
|
|
|
|
acb->scsipi_cmd_length = sizeof(*ss);
|
|
|
|
|
acb->data_addr = (char *)&xs->sense.scsi_sense;
|
|
|
|
|
acb->data_length = sizeof(struct scsipi_sense_data);
|
1996-04-01 11:24:37 +04:00
|
|
|
|
acb->flags |= ACB_SENSE;
|
|
|
|
|
ti->senses++;
|
|
|
|
|
if (acb->flags & ACB_NEXUS)
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti->lubusy &= ~(1 << sc_link->scsipi_scsi.lun);
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb == sc->sc_nexus) {
|
|
|
|
|
aic_select(sc, acb);
|
|
|
|
|
} else {
|
|
|
|
|
aic_dequeue(sc, acb);
|
|
|
|
|
TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
|
|
|
|
|
if (sc->sc_state == AIC_IDLE)
|
|
|
|
|
aic_sched(sc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/*
|
|
|
|
|
* POST PROCESSING OF SCSI_CMD (usually current)
|
|
|
|
|
*/
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_done(sc, acb)
|
|
|
|
|
struct aic_softc *sc;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_xfer *xs = acb->xs;
|
|
|
|
|
struct scsipi_link *sc_link = xs->sc_link;
|
|
|
|
|
struct aic_tinfo *ti = &sc->sc_tinfo[sc_link->scsipi_scsi.target];
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_TRACE(("aic_done "));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
/*
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* Now, if we've come here with no error code, i.e. we've kept the
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* initial XS_NOERROR, and the status code signals that we should
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* check sense, we'll need to set up a request sense cmd block and
|
|
|
|
|
* push the command back into the ready queue *before* any other
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* commands for this target/lunit, else we lose the sense info.
|
|
|
|
|
* We don't support chk sense conditions for the request sense cmd.
|
|
|
|
|
*/
|
1994-12-28 22:42:47 +03:00
|
|
|
|
if (xs->error == XS_NOERROR) {
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb->flags & ACB_ABORT) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
1996-04-01 11:24:37 +04:00
|
|
|
|
} else if (acb->flags & ACB_SENSE) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
xs->error = XS_SENSE;
|
|
|
|
|
} else if (acb->target_stat == SCSI_CHECK) {
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* First, save the return values */
|
1994-12-28 22:42:47 +03:00
|
|
|
|
xs->resid = acb->data_length;
|
|
|
|
|
xs->status = acb->target_stat;
|
1996-04-01 11:24:37 +04:00
|
|
|
|
aic_sense(sc, acb);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
return;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
} else {
|
|
|
|
|
xs->resid = acb->data_length;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
xs->flags |= ITSDONE;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#if AIC_DEBUG
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
|
|
|
|
if (xs->resid != 0)
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("resid=%d ", xs->resid);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
if (xs->error == XS_SENSE)
|
1997-08-27 15:22:52 +04:00
|
|
|
|
printf("sense=0x%02x\n", xs->sense.scsi_sense.error_code);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
else
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("error=%d\n", xs->error);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
1996-04-01 11:24:37 +04:00
|
|
|
|
* Remove the ACB from whatever queue it happens to be on.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb->flags & ACB_NEXUS)
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti->lubusy &= ~(1 << sc_link->scsipi_scsi.lun);
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb == sc->sc_nexus) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_nexus = NULL;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
sc->sc_state = AIC_IDLE;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_sched(sc);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
} else
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_dequeue(sc, acb);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_free_acb(sc, acb, xs->flags);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
ti->cmds++;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
scsipi_done(xs);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_dequeue(sc, acb)
|
|
|
|
|
struct aic_softc *sc;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
|
|
|
|
{
|
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb->flags & ACB_NEXUS) {
|
|
|
|
|
TAILQ_REMOVE(&sc->nexus_list, acb, chain);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
} else {
|
1996-04-01 11:24:37 +04:00
|
|
|
|
TAILQ_REMOVE(&sc->ready_list, acb, chain);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* INTERRUPT/PROTOCOL ENGINE
|
|
|
|
|
*/
|
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
#define IS1BYTEMSG(m) (((m) != 0x01 && (m) < 0x20) || (m) >= 0x80)
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#define IS2BYTEMSG(m) (((m) & 0xf0) == 0x20)
|
1994-11-29 20:50:39 +03:00
|
|
|
|
#define ISEXTMSG(m) ((m) == 0x01)
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/*
|
|
|
|
|
* Precondition:
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* The SCSI bus is already in the MSGI phase and there is a message byte
|
|
|
|
|
* on the bus, along with an asserted REQ signal.
|
|
|
|
|
*/
|
1996-04-01 11:24:37 +04:00
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_msgin(sc)
|
|
|
|
|
register struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
u_char sstat1;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
AIC_TRACE(("aic_msgin "));
|
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_prevphase == PH_MSGIN) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* This is a continuation of the previous message. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
n = sc->sc_imp - sc->sc_imess;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto nextbyte;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* This is a new MESSAGE IN phase. Clean up our state. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_flags &= ~AIC_DROP_MSGIN;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
nextmsg:
|
|
|
|
|
n = 0;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_imp = &sc->sc_imess[n];
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
nextbyte:
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/*
|
|
|
|
|
* Read a whole message, but don't ack the last byte. If we reject the
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* message, we have to assert ATN during the message transfer phase
|
|
|
|
|
* itself.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1994-04-26 07:43:26 +04:00
|
|
|
|
for (;;) {
|
1994-11-29 23:08:27 +03:00
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
sstat1 = bus_space_read_1(iot, ioh, SSTAT1);
|
1996-04-03 19:58:13 +04:00
|
|
|
|
if ((sstat1 & (REQINIT | PHASECHG | BUSFREE)) != 0)
|
1995-02-01 19:11:43 +03:00
|
|
|
|
break;
|
|
|
|
|
/* Wait for REQINIT. XXX Need timeout. */
|
|
|
|
|
}
|
1996-03-30 19:13:24 +03:00
|
|
|
|
if ((sstat1 & (PHASECHG | BUSFREE)) != 0) {
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/*
|
|
|
|
|
* Target left MESSAGE IN, probably because it
|
|
|
|
|
* a) noticed our ATN signal, or
|
|
|
|
|
* b) ran out of messages.
|
|
|
|
|
*/
|
1996-04-01 11:24:37 +04:00
|
|
|
|
goto out;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If parity error, just dump everything on the floor. */
|
|
|
|
|
if ((sstat1 & SCSIPERR) != 0) {
|
|
|
|
|
sc->sc_flags |= AIC_DROP_MSGIN;
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_PARITY_ERROR);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Gather incoming message bytes if needed. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if ((sc->sc_flags & AIC_DROP_MSGIN) == 0) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if (n >= AIC_MAX_MSG_LEN) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
(void) bus_space_read_1(iot, ioh, SCSIDAT);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_flags |= AIC_DROP_MSGIN;
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_REJECT);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
} else {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
*sc->sc_imp++ = bus_space_read_1(iot, ioh,
|
|
|
|
|
SCSIDAT);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n++;
|
|
|
|
|
/*
|
|
|
|
|
* This testing is suboptimal, but most
|
|
|
|
|
* messages will be of the one byte variety, so
|
|
|
|
|
* it should not affect performance
|
|
|
|
|
* significantly.
|
|
|
|
|
*/
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (n == 1 && IS1BYTEMSG(sc->sc_imess[0]))
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (n == 2 && IS2BYTEMSG(sc->sc_imess[0]))
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (n >= 3 && ISEXTMSG(sc->sc_imess[0]) &&
|
|
|
|
|
n == sc->sc_imess[1] + 2)
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1995-02-01 19:11:43 +03:00
|
|
|
|
} else
|
1997-10-06 23:49:17 +04:00
|
|
|
|
(void) bus_space_read_1(iot, ioh, SCSIDAT);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
/*
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* If we reach this spot we're either:
|
|
|
|
|
* a) in the middle of a multi-byte message, or
|
|
|
|
|
* b) dropping bytes.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | SPIOEN);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Ack the last byte read. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
(void) bus_space_read_1(iot, ioh, SCSIDAT);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
|
|
|
|
while ((bus_space_read_1(iot, ioh, SCSISIG) & ACKI) != 0)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_MISC(("n=%d imess=0x%02x ", n, sc->sc_imess[0]));
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* We now have a complete message. Parse it. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
switch (sc->sc_state) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_link *sc_link;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
struct aic_tinfo *ti;
|
|
|
|
|
|
|
|
|
|
case AIC_CONNECTED:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti = &sc->sc_tinfo[acb->xs->sc_link->scsipi_scsi.target];
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
switch (sc->sc_imess[0]) {
|
1994-04-26 04:05:56 +04:00
|
|
|
|
case MSG_CMDCOMPLETE:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_dleft < 0) {
|
|
|
|
|
sc_link = acb->xs->sc_link;
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: %d extra bytes from %d:%d\n",
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_dev.dv_xname, -sc->sc_dleft,
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc_link->scsipi_scsi.target, sc_link->scsipi_scsi.lun);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
acb->data_length = 0;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1995-01-07 04:51:07 +03:00
|
|
|
|
acb->xs->resid = acb->data_length = sc->sc_dleft;
|
|
|
|
|
sc->sc_state = AIC_CMDCOMPLETE;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
case MSG_PARITY_ERROR:
|
|
|
|
|
/* Resend the last message. */
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, sc->sc_lastmsg);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
case MSG_MESSAGE_REJECT:
|
1995-02-02 00:49:37 +03:00
|
|
|
|
AIC_MISC(("message rejected %02x ", sc->sc_lastmsg));
|
|
|
|
|
switch (sc->sc_lastmsg) {
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS + AIC_USE_WIDE
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_IDENTIFY:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
ti->flags &= ~(DO_SYNC | DO_WIDE);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->period = ti->offset = 0;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
aic_setsync(sc, ti);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->width = 0;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_SDTR:
|
|
|
|
|
ti->flags &= ~DO_SYNC;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->period = ti->offset = 0;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
aic_setsync(sc, ti);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
|
|
|
|
#if AIC_USE_WIDE
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_WDTR:
|
|
|
|
|
ti->flags &= ~DO_WIDE;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->width = 0;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_INIT_DET_ERR:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_ABORT);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MSG_NOOP:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MSG_DISCONNECT:
|
1994-04-26 04:05:56 +04:00
|
|
|
|
ti->dconns++;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state = AIC_DISCONNECT;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
case MSG_SAVEDATAPOINTER:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
acb->data_addr = sc->sc_dp;
|
|
|
|
|
acb->data_length = sc->sc_dleft;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
case MSG_RESTOREPOINTERS:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_dp = acb->data_addr;
|
|
|
|
|
sc->sc_dleft = acb->data_length;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc->sc_cp = (u_char *)&acb->scsipi_cmd;
|
|
|
|
|
sc->sc_cleft = acb->scsipi_cmd_length;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
case MSG_EXTENDED:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
switch (sc->sc_imess[2]) {
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
1994-04-26 04:05:56 +04:00
|
|
|
|
case MSG_EXT_SDTR:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_imess[1] != 3)
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reject;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->period = sc->sc_imess[3];
|
|
|
|
|
ti->offset = sc->sc_imess[4];
|
1995-02-01 19:56:42 +03:00
|
|
|
|
ti->flags &= ~DO_SYNC;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
if (ti->offset == 0) {
|
|
|
|
|
} else if (ti->period < sc->sc_minsync ||
|
|
|
|
|
ti->period > sc->sc_maxsync ||
|
1995-02-02 00:49:37 +03:00
|
|
|
|
ti->offset > 8) {
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->period = ti->offset = 0;
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_SDTR);
|
1994-04-26 07:43:26 +04:00
|
|
|
|
} else {
|
1997-08-27 15:22:52 +04:00
|
|
|
|
scsi_print_addr(acb->xs->sc_link);
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("sync, offset %d, "
|
|
|
|
|
"period %dnsec\n",
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->offset, ti->period * 4);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1995-02-01 19:56:42 +03:00
|
|
|
|
aic_setsync(sc, ti);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#if AIC_USE_WIDE
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case MSG_EXT_WDTR:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_imess[1] != 2)
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reject;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
ti->width = sc->sc_imess[3];
|
1995-02-01 19:56:42 +03:00
|
|
|
|
ti->flags &= ~DO_WIDE;
|
1995-02-01 19:11:43 +03:00
|
|
|
|
if (ti->width == 0) {
|
|
|
|
|
} else if (ti->width > AIC_MAX_WIDTH) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
ti->width = 0;
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_WDTR);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
} else {
|
1997-08-27 15:22:52 +04:00
|
|
|
|
scsi_print_addr(acb->xs->sc_link);
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("wide, width %d\n",
|
1995-02-01 19:11:43 +03:00
|
|
|
|
1 << (3 + ti->width));
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
default:
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: unrecognized MESSAGE EXTENDED; "
|
|
|
|
|
"sending REJECT\n", sc->sc_dev.dv_xname);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reject;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
break;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
default:
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: unrecognized MESSAGE; sending REJECT\n",
|
1995-01-07 09:49:35 +03:00
|
|
|
|
sc->sc_dev.dv_xname);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
reject:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_REJECT);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case AIC_RESELECTED:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (!MSG_ISIDENTIFY(sc->sc_imess[0])) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: reselect without IDENTIFY; "
|
|
|
|
|
"sending DEVICE RESET\n", sc->sc_dev.dv_xname);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reset;
|
|
|
|
|
}
|
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
(void) aic_reselect(sc, sc->sc_imess[0]);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: unexpected MESSAGE IN; sending DEVICE RESET\n",
|
1995-01-07 09:49:35 +03:00
|
|
|
|
sc->sc_dev.dv_xname);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
reset:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_DEV_RESET);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1996-04-30 00:02:32 +04:00
|
|
|
|
#ifdef notdef
|
1994-12-28 22:42:47 +03:00
|
|
|
|
abort:
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_ABORT);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
break;
|
1996-04-30 00:02:32 +04:00
|
|
|
|
#endif
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | SPIOEN);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Ack the last message byte. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
(void) bus_space_read_1(iot, ioh, SCSIDAT);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
|
|
|
|
while ((bus_space_read_1(iot, ioh, SCSISIG) & ACKI) != 0)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* Go get the next message, if any. */
|
|
|
|
|
goto nextmsg;
|
|
|
|
|
|
|
|
|
|
out:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_MISC(("n=%d imess=0x%02x ", n, sc->sc_imess[0]));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/*
|
|
|
|
|
* Send the highest priority, scheduled message.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_msgout(sc)
|
|
|
|
|
register struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1996-04-30 00:02:32 +04:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
1994-11-29 20:50:39 +03:00
|
|
|
|
struct aic_tinfo *ti;
|
1996-04-30 00:02:32 +04:00
|
|
|
|
#endif
|
1995-02-02 00:49:37 +03:00
|
|
|
|
u_char sstat1;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
AIC_TRACE(("aic_msgout "));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Reset the FIFO. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, RSTFIFO);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Enable REQ/ACK protocol. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | SPIOEN);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_prevphase == PH_MSGOUT) {
|
|
|
|
|
if (sc->sc_omp == sc->sc_omess) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/*
|
|
|
|
|
* This is a retransmission.
|
|
|
|
|
*
|
|
|
|
|
* We get here if the target stayed in MESSAGE OUT
|
|
|
|
|
* phase. Section 5.1.9.2 of the SCSI 2 spec indicates
|
|
|
|
|
* that all of the previously transmitted messages must
|
|
|
|
|
* be sent again, in the same order. Therefore, we
|
|
|
|
|
* requeue all the previously transmitted messages, and
|
|
|
|
|
* start again from the top. Our simple priority
|
|
|
|
|
* scheme keeps the messages in the right order.
|
|
|
|
|
*/
|
|
|
|
|
AIC_MISC(("retransmitting "));
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_msgpriq |= sc->sc_msgoutq;
|
1996-04-03 19:58:13 +04:00
|
|
|
|
/*
|
|
|
|
|
* Set ATN. If we're just sending a trivial 1-byte
|
|
|
|
|
* message, we'll clear ATN later on anyway.
|
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSISIG, PH_MSGOUT | ATNO);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
} else {
|
|
|
|
|
/* This is a continuation of the previous message. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
n = sc->sc_omp - sc->sc_omess;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto nextbyte;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* No messages transmitted so far. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_msgoutq = 0;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_lastmsg = 0;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
nextmsg:
|
|
|
|
|
/* Pick up highest priority message. */
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_currmsg = sc->sc_msgpriq & -sc->sc_msgpriq;
|
|
|
|
|
sc->sc_msgpriq &= ~sc->sc_currmsg;
|
|
|
|
|
sc->sc_msgoutq |= sc->sc_currmsg;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* Build the outgoing message data. */
|
1995-02-02 00:49:37 +03:00
|
|
|
|
switch (sc->sc_currmsg) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_IDENTIFY:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
1996-04-01 11:24:37 +04:00
|
|
|
|
sc->sc_omess[0] =
|
1997-08-27 15:22:52 +04:00
|
|
|
|
MSG_IDENTIFY(sc->sc_nexus->xs->sc_link->scsipi_scsi.lun, 1);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_SDTR:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti = &sc->sc_tinfo[sc->sc_nexus->xs->sc_link->scsipi_scsi.target];
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[4] = MSG_EXTENDED;
|
|
|
|
|
sc->sc_omess[3] = 3;
|
|
|
|
|
sc->sc_omess[2] = MSG_EXT_SDTR;
|
|
|
|
|
sc->sc_omess[1] = ti->period >> 2;
|
|
|
|
|
sc->sc_omess[0] = ti->offset;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 5;
|
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#if AIC_USE_WIDE
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case SEND_WDTR:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti = &sc->sc_tinfo[sc->sc_nexus->xs->sc_link->scsipi_scsi.target];
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[3] = MSG_EXTENDED;
|
|
|
|
|
sc->sc_omess[2] = 2;
|
|
|
|
|
sc->sc_omess[1] = MSG_EXT_WDTR;
|
|
|
|
|
sc->sc_omess[0] = ti->width;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 4;
|
|
|
|
|
break;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
case SEND_DEV_RESET:
|
1996-04-01 11:24:37 +04:00
|
|
|
|
sc->sc_flags |= AIC_ABORTING;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[0] = MSG_BUS_DEV_RESET;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEND_REJECT:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[0] = MSG_MESSAGE_REJECT;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEND_PARITY_ERROR:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[0] = MSG_PARITY_ERROR;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEND_INIT_DET_ERR:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[0] = MSG_INITIATOR_DET_ERR;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEND_ABORT:
|
1996-04-01 11:24:37 +04:00
|
|
|
|
sc->sc_flags |= AIC_ABORTING;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[0] = MSG_ABORT;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
default:
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: unexpected MESSAGE OUT; sending NOOP\n",
|
1995-01-07 09:49:35 +03:00
|
|
|
|
sc->sc_dev.dv_xname);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
AIC_BREAK();
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omess[0] = MSG_NOOP;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
n = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_omp = &sc->sc_omess[n];
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
nextbyte:
|
|
|
|
|
/* Send message bytes. */
|
1994-11-29 23:08:27 +03:00
|
|
|
|
for (;;) {
|
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
sstat1 = bus_space_read_1(iot, ioh, SSTAT1);
|
1996-04-03 19:58:13 +04:00
|
|
|
|
if ((sstat1 & (REQINIT | PHASECHG | BUSFREE)) != 0)
|
1995-02-02 00:49:37 +03:00
|
|
|
|
break;
|
|
|
|
|
/* Wait for REQINIT. XXX Need timeout. */
|
|
|
|
|
}
|
1996-03-30 19:13:24 +03:00
|
|
|
|
if ((sstat1 & (PHASECHG | BUSFREE)) != 0) {
|
1995-02-02 00:49:37 +03:00
|
|
|
|
/*
|
|
|
|
|
* Target left MESSAGE OUT, possibly to reject
|
|
|
|
|
* our message.
|
1996-04-01 11:24:37 +04:00
|
|
|
|
*
|
|
|
|
|
* If this is the last message being sent, then we
|
|
|
|
|
* deassert ATN, since either the target is going to
|
|
|
|
|
* ignore this message, or it's going to ask for a
|
|
|
|
|
* retransmission via MESSAGE PARITY ERROR (in which
|
|
|
|
|
* case we reassert ATN anyway).
|
1995-02-02 00:49:37 +03:00
|
|
|
|
*/
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (sc->sc_msgpriq == 0)
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1, CLRATNO);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
goto out;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Clear ATN before last byte if this is the last message. */
|
1995-02-02 00:49:37 +03:00
|
|
|
|
if (n == 1 && sc->sc_msgpriq == 0)
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1, CLRATNO);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Send message byte. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSIDAT, *--sc->sc_omp);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
--n;
|
|
|
|
|
/* Keep track of the last message we've sent any bytes of. */
|
|
|
|
|
sc->sc_lastmsg = sc->sc_currmsg;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
/* Wait for ACK to be negated. XXX Need timeout. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
while ((bus_space_read_1(iot, ioh, SCSISIG) & ACKI) != 0)
|
1994-04-26 04:05:56 +04:00
|
|
|
|
;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
|
break;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* We get here only if the entire message has been transmitted. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_msgpriq != 0) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* There are more outgoing messages. */
|
|
|
|
|
goto nextmsg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The last message has been transmitted. We need to remember the last
|
|
|
|
|
* message transmitted (in case the target switches to MESSAGE IN phase
|
|
|
|
|
* and sends a MESSAGE REJECT), and the list of messages transmitted
|
|
|
|
|
* this time around (in case the target stays in MESSAGE OUT phase to
|
|
|
|
|
* request a retransmit).
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
out:
|
|
|
|
|
/* Disable REQ/ACK protocol. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* aic_dataout_pio: perform a data transfer using the FIFO datapath in the
|
|
|
|
|
* aic6360
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* Precondition: The SCSI bus should be in the DOUT phase, with REQ asserted
|
|
|
|
|
* and ACK deasserted (i.e. waiting for a data byte)
|
|
|
|
|
* This new revision has been optimized (I tried) to make the common case fast,
|
|
|
|
|
* and the rarer cases (as a result) somewhat more comlex
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_dataout_pio(sc, p, n)
|
|
|
|
|
register struct aic_softc *sc;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
u_char *p;
|
|
|
|
|
int n;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1996-04-30 00:02:32 +04:00
|
|
|
|
register u_char dmastat = 0;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int out = 0;
|
1994-08-07 14:51:40 +04:00
|
|
|
|
#define DOUTAMOUNT 128 /* Full FIFO */
|
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
AIC_MISC(("%02x%02x ", bus_space_read_1(iot, ioh, FIFOSTAT),
|
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT2)));
|
1996-06-18 20:13:05 +04:00
|
|
|
|
|
1995-02-02 00:49:37 +03:00
|
|
|
|
/* Clear host FIFO and counter. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, RSTFIFO | WRITE);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
/* Enable FIFOs. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, ENDMA | DWORDPIO | WRITE);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, SCSIEN | DMAEN | CHEN);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/* Turn off ENREQINIT for now. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1,
|
1996-03-30 19:13:24 +03:00
|
|
|
|
ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENPHASECHG);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
/* I have tried to make the main loop as tight as possible. This
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* means that some of the code following the loop is a bit more
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* complex than otherwise.
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
while (n > 0) {
|
1994-08-07 14:51:40 +04:00
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
dmastat = bus_space_read_1(iot, ioh, DMASTAT);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((dmastat & (DFIFOEMP | INTSTAT)) != 0)
|
1994-08-07 14:51:40 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((dmastat & INTSTAT) != 0)
|
|
|
|
|
goto phasechange;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (n >= DOUTAMOUNT) {
|
|
|
|
|
n -= DOUTAMOUNT;
|
|
|
|
|
out += DOUTAMOUNT;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#if AIC_USE_DWORDS
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_multi_4(iot, ioh, DMADATALONG, p,
|
|
|
|
|
DOUTAMOUNT >> 2);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#else
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_multi_2(iot, ioh, DMADATA, p,
|
|
|
|
|
DOUTAMOUNT >> 1);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
p += DOUTAMOUNT;
|
|
|
|
|
} else {
|
|
|
|
|
register int xfer;
|
|
|
|
|
|
|
|
|
|
xfer = n;
|
|
|
|
|
AIC_MISC(("%d> ", xfer));
|
|
|
|
|
|
|
|
|
|
n -= xfer;
|
|
|
|
|
out += xfer;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
#if AIC_USE_DWORDS
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (xfer >= 12) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_multi_4(iot, ioh, DMADATALONG,
|
|
|
|
|
p, xfer >> 2);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += xfer & ~3;
|
|
|
|
|
xfer &= 3;
|
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#else
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (xfer >= 8) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_multi_2(iot, ioh, DMADATA,
|
|
|
|
|
p, xfer >> 1);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += xfer & ~1;
|
|
|
|
|
xfer &= 1;
|
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (xfer > 0) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0,
|
|
|
|
|
ENDMA | B8MODE | WRITE);
|
|
|
|
|
bus_space_write_multi_1(iot, ioh, DMADATA,
|
|
|
|
|
p, xfer);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += xfer;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0,
|
|
|
|
|
ENDMA | DWORDPIO | WRITE);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
}
|
1994-08-07 14:51:40 +04:00
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-08-07 14:51:40 +04:00
|
|
|
|
|
1995-02-02 00:49:37 +03:00
|
|
|
|
if (out == 0) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, BITBUCKET);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
if ((bus_space_read_1(iot, ioh, DMASTAT) & INTSTAT)
|
|
|
|
|
!= 0)
|
1995-02-02 00:49:37 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, 0);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
AIC_MISC(("extra data "));
|
|
|
|
|
} else {
|
|
|
|
|
/* See the bytes off chip */
|
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
dmastat = bus_space_read_1(iot, ioh, DMASTAT);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((dmastat & INTSTAT) != 0)
|
|
|
|
|
goto phasechange;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
if ((dmastat & DFIFOEMP) != 0 &&
|
1997-10-06 23:49:17 +04:00
|
|
|
|
(bus_space_read_1(iot, ioh, SSTAT2) & SEMPTY) != 0)
|
1995-02-02 00:49:37 +03:00
|
|
|
|
break;
|
|
|
|
|
}
|
1994-08-07 14:51:40 +04:00
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-08-07 14:51:40 +04:00
|
|
|
|
phasechange:
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((dmastat & INTSTAT) != 0) {
|
|
|
|
|
/* Some sort of phase change. */
|
|
|
|
|
int amount;
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* Stop transfers, do some accounting */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
amount = bus_space_read_1(iot, ioh, FIFOSTAT)
|
|
|
|
|
+ (bus_space_read_1(iot, ioh, SSTAT2) & 15);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
if (amount > 0) {
|
|
|
|
|
out -= amount;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0,
|
|
|
|
|
RSTFIFO | WRITE);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | CLRCH);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
AIC_MISC(("+%d ", amount));
|
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/* Turn on ENREQINIT again. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1,
|
1996-03-30 19:13:24 +03:00
|
|
|
|
ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENREQINIT | ENPHASECHG);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1996-06-18 20:13:05 +04:00
|
|
|
|
/* Stop the FIFO data path. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, 0);
|
1996-06-18 20:13:05 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
/* aic_datain_pio: perform data transfers using the FIFO datapath in the
|
|
|
|
|
* aic6360
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* Precondition: The SCSI bus should be in the DIN phase, with REQ asserted
|
|
|
|
|
* and ACK deasserted (i.e. at least one byte is ready).
|
|
|
|
|
* For now, uses a pretty dumb algorithm, hangs around until all data has been
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* transferred. This, is OK for fast targets, but not so smart for slow
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* targets which don't disconnect or for huge transfers.
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_datain_pio(sc, p, n)
|
|
|
|
|
register struct aic_softc *sc;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
u_char *p;
|
|
|
|
|
int n;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
register u_char dmastat;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int in = 0;
|
|
|
|
|
#define DINAMOUNT 128 /* Full FIFO */
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
AIC_MISC(("%02x%02x ", bus_space_read_1(iot, ioh, FIFOSTAT),
|
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT2)));
|
1996-06-18 20:13:05 +04:00
|
|
|
|
|
1995-02-02 00:49:37 +03:00
|
|
|
|
/* Clear host FIFO and counter. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, RSTFIFO);
|
1996-04-01 11:24:37 +04:00
|
|
|
|
/* Enable FIFOs. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, ENDMA | DWORDPIO);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, SCSIEN | DMAEN | CHEN);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/* Turn off ENREQINIT for now. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1,
|
1996-03-30 19:13:24 +03:00
|
|
|
|
ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENPHASECHG);
|
1994-08-07 14:51:40 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* We leave this loop if one or more of the following is true:
|
1994-12-28 22:42:47 +03:00
|
|
|
|
* a) phase != PH_DATAIN && FIFOs are empty
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* b) SCSIRSTI is set (a reset has occurred) or busfree is detected.
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
while (n > 0) {
|
1994-08-07 14:51:40 +04:00
|
|
|
|
/* Wait for fifo half full or phase mismatch */
|
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
dmastat = bus_space_read_1(iot, ioh, DMASTAT);
|
1996-03-30 19:13:24 +03:00
|
|
|
|
if ((dmastat & (DFIFOFULL | INTSTAT)) != 0)
|
1994-08-07 14:51:40 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((dmastat & DFIFOFULL) != 0) {
|
|
|
|
|
n -= DINAMOUNT;
|
|
|
|
|
in += DINAMOUNT;
|
1994-08-07 14:51:40 +04:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#if AIC_USE_DWORDS
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_multi_4(iot, ioh, DMADATALONG, p,
|
|
|
|
|
DINAMOUNT >> 2);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#else
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_multi_2(iot, ioh, DMADATA, p,
|
|
|
|
|
DINAMOUNT >> 1);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
#endif
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += DINAMOUNT;
|
|
|
|
|
} else {
|
|
|
|
|
register int xfer;
|
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
xfer = min(bus_space_read_1(iot, ioh, FIFOSTAT), n);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
AIC_MISC((">%d ", xfer));
|
|
|
|
|
|
|
|
|
|
n -= xfer;
|
|
|
|
|
in += xfer;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
|
|
|
|
#if AIC_USE_DWORDS
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (xfer >= 12) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_multi_4(iot, ioh, DMADATALONG,
|
|
|
|
|
p, xfer >> 2);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += xfer & ~3;
|
|
|
|
|
xfer &= 3;
|
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#else
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (xfer >= 8) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_multi_2(iot, ioh, DMADATA, p,
|
|
|
|
|
xfer >> 1);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += xfer & ~1;
|
|
|
|
|
xfer &= 1;
|
|
|
|
|
}
|
1994-04-26 04:05:56 +04:00
|
|
|
|
#endif
|
1994-08-07 14:51:40 +04:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (xfer > 0) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0,
|
|
|
|
|
ENDMA | B8MODE);
|
|
|
|
|
bus_space_read_multi_1(iot, ioh, DMADATA,
|
|
|
|
|
p, xfer);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
p += xfer;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0,
|
|
|
|
|
ENDMA | DWORDPIO);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
}
|
1994-08-07 14:51:40 +04:00
|
|
|
|
}
|
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((dmastat & INTSTAT) != 0)
|
1995-02-02 00:49:37 +03:00
|
|
|
|
goto phasechange;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-08-07 14:51:40 +04:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* Some SCSI-devices are rude enough to transfer more data than what
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* was requested, e.g. 2048 bytes from a CD-ROM instead of the
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* requested 512. Test for progress, i.e. real transfers. If no real
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* transfers have been performed (n is probably already zero) and the
|
|
|
|
|
* FIFO is not empty, waste some bytes....
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if (in == 0) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, BITBUCKET);
|
1994-08-07 14:51:40 +04:00
|
|
|
|
for (;;) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
if ((bus_space_read_1(iot, ioh, DMASTAT) & INTSTAT)
|
|
|
|
|
!= 0)
|
1994-08-07 14:51:40 +04:00
|
|
|
|
break;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, 0);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
AIC_MISC(("extra data "));
|
1995-02-01 19:11:43 +03:00
|
|
|
|
}
|
1994-08-07 14:51:40 +04:00
|
|
|
|
|
1995-02-02 00:49:37 +03:00
|
|
|
|
phasechange:
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/* Turn on ENREQINIT again. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1,
|
1996-03-30 19:13:24 +03:00
|
|
|
|
ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENREQINIT | ENPHASECHG);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1996-06-18 20:13:05 +04:00
|
|
|
|
/* Stop the FIFO data path. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, 0);
|
1996-06-18 20:13:05 +04:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/*
|
|
|
|
|
* This is the workhorse routine of the driver.
|
|
|
|
|
* Deficiencies (for now):
|
|
|
|
|
* 1) always uses programmed I/O
|
|
|
|
|
*/
|
1995-08-13 00:30:45 +04:00
|
|
|
|
int
|
1995-04-17 16:06:30 +04:00
|
|
|
|
aicintr(arg)
|
|
|
|
|
void *arg;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1995-04-17 16:06:30 +04:00
|
|
|
|
register struct aic_softc *sc = arg;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
u_char sstat0, sstat1;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
register struct aic_acb *acb;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
register struct scsipi_link *sc_link;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
struct aic_tinfo *ti;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int n;
|
|
|
|
|
|
|
|
|
|
/*
|
1995-02-01 19:11:43 +03:00
|
|
|
|
* Clear INTEN. We enable it again before returning. This makes the
|
|
|
|
|
* interrupt esssentially level-triggered.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, 0);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_TRACE(("aicintr "));
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1995-02-02 00:49:37 +03:00
|
|
|
|
loop:
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/*
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* First check for abnormal conditions, such as reset.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
sstat1 = bus_space_read_1(iot, ioh, SSTAT1);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_MISC(("sstat1:0x%02x ", sstat1));
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((sstat1 & SCSIRSTI) != 0) {
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: SCSI bus reset\n", sc->sc_dev.dv_xname);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reset;
|
|
|
|
|
}
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for less serious errors.
|
|
|
|
|
*/
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((sstat1 & SCSIPERR) != 0) {
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: SCSI bus parity error\n", sc->sc_dev.dv_xname);
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1, CLRSCSIPERR);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_prevphase == PH_MSGIN) {
|
|
|
|
|
sc->sc_flags |= AIC_DROP_MSGIN;
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_PARITY_ERROR);
|
1995-08-13 00:30:45 +04:00
|
|
|
|
} else
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_INIT_DET_ERR);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
1995-08-13 00:30:45 +04:00
|
|
|
|
/*
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* If we're not already busy doing something test for the following
|
|
|
|
|
* conditions:
|
|
|
|
|
* 1) We have been reselected by something
|
|
|
|
|
* 2) We have selected something successfully
|
|
|
|
|
* 3) Our selection process has timed out
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* 4) This is really a bus free interrupt just to get a new command
|
1994-04-26 04:05:56 +04:00
|
|
|
|
* going?
|
|
|
|
|
* 5) Spurious interrupt?
|
|
|
|
|
*/
|
1995-01-07 04:51:07 +03:00
|
|
|
|
switch (sc->sc_state) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
case AIC_IDLE:
|
|
|
|
|
case AIC_SELECTING:
|
1997-10-06 23:49:17 +04:00
|
|
|
|
sstat0 = bus_space_read_1(iot, ioh, SSTAT0);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
AIC_MISC(("sstat0:0x%02x ", sstat0));
|
|
|
|
|
|
|
|
|
|
if ((sstat0 & TARGET) != 0) {
|
|
|
|
|
/*
|
|
|
|
|
* We don't currently support target mode.
|
|
|
|
|
*/
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: target mode selected; going to BUS FREE\n",
|
1995-01-07 09:49:35 +03:00
|
|
|
|
sc->sc_dev.dv_xname);
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SCSISIG, 0);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
goto sched;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
} else if ((sstat0 & SELDI) != 0) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_MISC(("reselected "));
|
|
|
|
|
|
|
|
|
|
/*
|
1995-08-13 00:30:45 +04:00
|
|
|
|
* If we're trying to select a target ourselves,
|
1994-11-29 20:50:39 +03:00
|
|
|
|
* push our command back into the ready list.
|
1994-04-26 04:05:56 +04:00
|
|
|
|
*/
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_state == AIC_SELECTING) {
|
1994-11-29 20:50:39 +03:00
|
|
|
|
AIC_MISC(("backoff selector "));
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
|
|
|
|
sc->sc_nexus = NULL;
|
|
|
|
|
TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
/* Save reselection ID. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
sc->sc_selid = bus_space_read_1(iot, ioh, SELID);
|
1995-02-01 19:11:43 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state = AIC_RESELECTED;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
} else if ((sstat0 & SELDO) != 0) {
|
|
|
|
|
AIC_MISC(("selected "));
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
/* We have selected a target. Things to do:
|
|
|
|
|
* a) Determine what message(s) to send.
|
|
|
|
|
* b) Verify that we're still selecting the target.
|
|
|
|
|
* c) Mark device as busy.
|
|
|
|
|
*/
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_state != AIC_SELECTING) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: selection out while idle; "
|
|
|
|
|
"resetting\n", sc->sc_dev.dv_xname);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reset;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
|
|
|
|
sc_link = acb->xs->sc_link;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti = &sc->sc_tinfo[sc_link->scsipi_scsi.target];
|
1996-04-03 14:33:45 +04:00
|
|
|
|
|
|
|
|
|
sc->sc_msgpriq = SEND_IDENTIFY;
|
|
|
|
|
if (acb->flags & ACB_RESET)
|
|
|
|
|
sc->sc_msgpriq |= SEND_DEV_RESET;
|
|
|
|
|
else if (acb->flags & ACB_ABORT)
|
|
|
|
|
sc->sc_msgpriq |= SEND_ABORT;
|
|
|
|
|
else {
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((ti->flags & DO_SYNC) != 0)
|
|
|
|
|
sc->sc_msgpriq |= SEND_SDTR;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
|
|
|
|
#if AIC_USE_WIDE
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if ((ti->flags & DO_WIDE) != 0)
|
|
|
|
|
sc->sc_msgpriq |= SEND_WDTR;
|
1995-02-01 19:56:42 +03:00
|
|
|
|
#endif
|
1996-04-03 14:33:45 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
acb->flags |= ACB_NEXUS;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti->lubusy |= (1 << sc_link->scsipi_scsi.lun);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
|
|
|
|
/* Do an implicit RESTORE POINTERS. */
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_dp = acb->data_addr;
|
|
|
|
|
sc->sc_dleft = acb->data_length;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
sc->sc_cp = (u_char *)&acb->scsipi_cmd;
|
|
|
|
|
sc->sc_cleft = acb->scsipi_cmd_length;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
/* On our first connection, schedule a timeout. */
|
|
|
|
|
if ((acb->xs->flags & SCSI_POLL) == 0)
|
1997-10-06 23:49:17 +04:00
|
|
|
|
timeout(aic_timeout, acb,
|
|
|
|
|
(acb->timeout * hz) / 1000);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state = AIC_CONNECTED;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
} else if ((sstat1 & SELTO) != 0) {
|
|
|
|
|
AIC_MISC(("selection timeout "));
|
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_state != AIC_SELECTING) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: selection timeout while idle; "
|
|
|
|
|
"resetting\n", sc->sc_dev.dv_xname);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
goto reset;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, 0);
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, ENRESELI);
|
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1, CLRSELTIMO);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
delay(250);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
acb->xs->error = XS_SELTIMEOUT;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
goto finish;
|
1994-04-26 07:43:26 +04:00
|
|
|
|
} else {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_state != AIC_IDLE) {
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: BUS FREE while not idle; "
|
|
|
|
|
"state=%d\n",
|
1995-01-07 09:49:35 +03:00
|
|
|
|
sc->sc_dev.dv_xname, sc->sc_state);
|
1994-11-29 20:56:49 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 23:08:27 +03:00
|
|
|
|
goto out;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
goto sched;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/*
|
|
|
|
|
* Turn off selection stuff, and prepare to catch bus free
|
|
|
|
|
* interrupts, parity errors, and phase changes.
|
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | CLRSTCNT | CLRCH);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL1, 0);
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSISEQ, ENAUTOATNP);
|
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT0, CLRSELDI | CLRSELDO);
|
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1,
|
|
|
|
|
CLRBUSFREE | CLRPHASECHG);
|
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE0, 0);
|
|
|
|
|
bus_space_write_1(iot, ioh, SIMODE1,
|
|
|
|
|
ENSCSIRST | ENSCSIPERR | ENBUSFREE | ENREQINIT |
|
|
|
|
|
ENPHASECHG);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_flags = 0;
|
|
|
|
|
sc->sc_prevphase = PH_INVALID;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
goto dophase;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
if ((sstat1 & BUSFREE) != 0) {
|
|
|
|
|
/* We've gone to BUS FREE phase. */
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1,
|
|
|
|
|
CLRBUSFREE | CLRPHASECHG);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
switch (sc->sc_state) {
|
1994-11-29 23:08:27 +03:00
|
|
|
|
case AIC_RESELECTED:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
goto sched;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
|
|
|
|
case AIC_CONNECTED:
|
1996-04-01 11:24:37 +04:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
#if AIC_USE_SYNCHRONOUS + AIC_USE_WIDE
|
|
|
|
|
if (sc->sc_prevphase == PH_MSGOUT) {
|
|
|
|
|
/*
|
|
|
|
|
* If the target went to BUS FREE phase during
|
|
|
|
|
* or immediately after sending a SDTR or WDTR
|
|
|
|
|
* message, disable negotiation.
|
|
|
|
|
*/
|
|
|
|
|
sc_link = acb->xs->sc_link;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
ti = &sc->sc_tinfo[sc_link->scsipi_scsi.target];
|
1996-04-01 11:24:37 +04:00
|
|
|
|
switch (sc->sc_lastmsg) {
|
|
|
|
|
#if AIC_USE_SYNCHRONOUS
|
|
|
|
|
case SEND_SDTR:
|
|
|
|
|
ti->flags &= ~DO_SYNC;
|
|
|
|
|
ti->period = ti->offset = 0;
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
#if AIC_USE_WIDE
|
|
|
|
|
case SEND_WDTR:
|
|
|
|
|
ti->flags &= ~DO_WIDE;
|
|
|
|
|
ti->width = 0;
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1996-04-03 14:33:45 +04:00
|
|
|
|
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if ((sc->sc_flags & AIC_ABORTING) == 0) {
|
1996-04-01 11:24:37 +04:00
|
|
|
|
/*
|
|
|
|
|
* Section 5.1.1 of the SCSI 2 spec suggests
|
|
|
|
|
* issuing a REQUEST SENSE following an
|
|
|
|
|
* unexpected disconnect. Some devices go into
|
|
|
|
|
* a contingent allegiance condition when
|
|
|
|
|
* disconnecting, and this is necessary to
|
|
|
|
|
* clean up their state.
|
|
|
|
|
*/
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("%s: unexpected disconnect; "
|
|
|
|
|
"sending REQUEST SENSE\n",
|
1995-01-07 09:49:35 +03:00
|
|
|
|
sc->sc_dev.dv_xname);
|
1994-11-29 23:08:27 +03:00
|
|
|
|
AIC_BREAK();
|
1996-04-01 11:24:37 +04:00
|
|
|
|
aic_sense(sc, acb);
|
|
|
|
|
goto out;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
}
|
1996-04-03 14:33:45 +04:00
|
|
|
|
|
1994-11-29 23:08:27 +03:00
|
|
|
|
acb->xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
|
goto finish;
|
|
|
|
|
|
|
|
|
|
case AIC_DISCONNECT:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1996-06-18 20:13:05 +04:00
|
|
|
|
#if 1 /* XXXX */
|
|
|
|
|
acb->data_addr = sc->sc_dp;
|
|
|
|
|
acb->data_length = sc->sc_dleft;
|
|
|
|
|
#endif
|
1996-04-01 11:24:37 +04:00
|
|
|
|
TAILQ_INSERT_HEAD(&sc->nexus_list, acb, chain);
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_nexus = NULL;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
goto sched;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
|
|
|
|
case AIC_CMDCOMPLETE:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1996-04-03 14:33:45 +04:00
|
|
|
|
goto finish;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
}
|
1994-12-28 22:42:47 +03:00
|
|
|
|
}
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, CLRSINT1, CLRPHASECHG);
|
1996-04-03 14:33:45 +04:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
dophase:
|
|
|
|
|
if ((sstat1 & REQINIT) == 0) {
|
1994-11-29 23:08:27 +03:00
|
|
|
|
/* Wait for REQINIT. */
|
|
|
|
|
goto out;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
}
|
|
|
|
|
|
1997-10-06 23:49:17 +04:00
|
|
|
|
sc->sc_phase = bus_space_read_1(iot, ioh, SCSISIG) & PH_MASK;
|
|
|
|
|
bus_space_write_1(iot, ioh, SCSISIG, sc->sc_phase);
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
switch (sc->sc_phase) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
case PH_MSGOUT:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state != AIC_CONNECTED &&
|
|
|
|
|
sc->sc_state != AIC_RESELECTED)
|
1994-11-29 20:50:39 +03:00
|
|
|
|
break;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_msgout(sc);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_prevphase = PH_MSGOUT;
|
|
|
|
|
goto loop;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
case PH_MSGIN:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state != AIC_CONNECTED &&
|
|
|
|
|
sc->sc_state != AIC_RESELECTED)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
break;
|
1996-04-01 11:24:37 +04:00
|
|
|
|
aic_msgin(sc);
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_prevphase = PH_MSGIN;
|
|
|
|
|
goto loop;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1995-02-01 19:11:43 +03:00
|
|
|
|
case PH_CMD:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state != AIC_CONNECTED)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
break;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
#if AIC_DEBUG
|
1994-12-28 22:42:47 +03:00
|
|
|
|
if ((aic_debug & AIC_SHOWMISC) != 0) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("cmd=0x%02x+%d ",
|
1997-08-27 15:22:52 +04:00
|
|
|
|
acb->scsipi_cmd.opcode, acb->scsipi_cmd_length-1);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-12-28 22:42:47 +03:00
|
|
|
|
#endif
|
1995-01-07 04:51:07 +03:00
|
|
|
|
n = aic_dataout_pio(sc, sc->sc_cp, sc->sc_cleft);
|
|
|
|
|
sc->sc_cp += n;
|
|
|
|
|
sc->sc_cleft -= n;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_prevphase = PH_CMD;
|
|
|
|
|
goto loop;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
|
|
case PH_DATAOUT:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state != AIC_CONNECTED)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
break;
|
1996-06-18 20:13:05 +04:00
|
|
|
|
AIC_MISC(("dataout %d ", sc->sc_dleft));
|
1995-01-07 04:51:07 +03:00
|
|
|
|
n = aic_dataout_pio(sc, sc->sc_dp, sc->sc_dleft);
|
|
|
|
|
sc->sc_dp += n;
|
|
|
|
|
sc->sc_dleft -= n;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_prevphase = PH_DATAOUT;
|
|
|
|
|
goto loop;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
|
|
case PH_DATAIN:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state != AIC_CONNECTED)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
break;
|
1996-06-18 20:13:05 +04:00
|
|
|
|
AIC_MISC(("datain %d ", sc->sc_dleft));
|
1995-01-07 04:51:07 +03:00
|
|
|
|
n = aic_datain_pio(sc, sc->sc_dp, sc->sc_dleft);
|
|
|
|
|
sc->sc_dp += n;
|
|
|
|
|
sc->sc_dleft -= n;
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_prevphase = PH_DATAIN;
|
|
|
|
|
goto loop;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
|
|
|
|
|
case PH_STAT:
|
1996-04-03 14:33:45 +04:00
|
|
|
|
if (sc->sc_state != AIC_CONNECTED)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
break;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
AIC_ASSERT(sc->sc_nexus != NULL);
|
|
|
|
|
acb = sc->sc_nexus;
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN | SPIOEN);
|
|
|
|
|
acb->target_stat = bus_space_read_1(iot, ioh, SCSIDAT);
|
|
|
|
|
bus_space_write_1(iot, ioh, SXFRCTL0, CHEN);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
AIC_MISC(("target_stat=0x%02x ", acb->target_stat));
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_prevphase = PH_STAT;
|
|
|
|
|
goto loop;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("%s: unexpected bus phase; resetting\n", sc->sc_dev.dv_xname);
|
1994-11-29 23:08:27 +03:00
|
|
|
|
AIC_BREAK();
|
1994-11-29 20:50:39 +03:00
|
|
|
|
reset:
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_init(sc);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
return 1;
|
1994-11-29 23:08:27 +03:00
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
finish:
|
|
|
|
|
untimeout(aic_timeout, acb);
|
|
|
|
|
aic_done(sc, acb);
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
sched:
|
|
|
|
|
sc->sc_state = AIC_IDLE;
|
|
|
|
|
aic_sched(sc);
|
|
|
|
|
goto out;
|
|
|
|
|
|
1994-11-29 23:08:27 +03:00
|
|
|
|
out:
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_write_1(iot, ioh, DMACNTRL0, INTEN);
|
1994-11-29 23:08:27 +03:00
|
|
|
|
return 1;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_abort(sc, acb)
|
|
|
|
|
struct aic_softc *sc;
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
|
|
|
|
{
|
|
|
|
|
|
1996-04-03 14:33:45 +04:00
|
|
|
|
/* 2 secs for the abort */
|
|
|
|
|
acb->timeout = AIC_ABORT_TIMEOUT;
|
|
|
|
|
acb->flags |= ACB_ABORT;
|
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb == sc->sc_nexus) {
|
|
|
|
|
/*
|
|
|
|
|
* If we're still selecting, the message will be scheduled
|
|
|
|
|
* after selection is complete.
|
|
|
|
|
*/
|
|
|
|
|
if (sc->sc_state == AIC_CONNECTED)
|
1996-03-30 19:13:24 +03:00
|
|
|
|
aic_sched_msgout(sc, SEND_ABORT);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
} else {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_dequeue(sc, acb);
|
|
|
|
|
TAILQ_INSERT_HEAD(&sc->ready_list, acb, chain);
|
|
|
|
|
if (sc->sc_state == AIC_IDLE)
|
|
|
|
|
aic_sched(sc);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
void
|
|
|
|
|
aic_timeout(arg)
|
1994-05-05 09:35:42 +04:00
|
|
|
|
void *arg;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb = arg;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
struct scsipi_xfer *xs = acb->xs;
|
|
|
|
|
struct scsipi_link *sc_link = xs->sc_link;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
struct aic_softc *sc = sc_link->adapter_softc;
|
1994-11-29 20:50:39 +03:00
|
|
|
|
int s;
|
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
|
scsi_print_addr(sc_link);
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("timed out");
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1994-12-28 22:42:47 +03:00
|
|
|
|
s = splbio();
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1996-04-01 11:24:37 +04:00
|
|
|
|
if (acb->flags & ACB_ABORT) {
|
1994-12-28 22:42:47 +03:00
|
|
|
|
/* abort timed out */
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf(" AGAIN\n");
|
1996-04-03 14:33:45 +04:00
|
|
|
|
/* XXX Must reset! */
|
1994-12-28 22:42:47 +03:00
|
|
|
|
} else {
|
|
|
|
|
/* abort the operation that has timed out */
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("\n");
|
1994-12-28 22:42:47 +03:00
|
|
|
|
acb->xs->error = XS_TIMEOUT;
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_abort(sc, acb);
|
1994-12-28 22:42:47 +03:00
|
|
|
|
}
|
1994-11-29 20:50:39 +03:00
|
|
|
|
|
1994-04-26 04:05:56 +04:00
|
|
|
|
splx(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef AIC_DEBUG
|
|
|
|
|
/*
|
|
|
|
|
* The following functions are mostly used for debugging purposes, either
|
|
|
|
|
* directly called from the driver or from the kernel debugger.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
aic_show_scsi_cmd(acb)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-08-27 15:22:52 +04:00
|
|
|
|
u_char *b = (u_char *)&acb->scsipi_cmd;
|
|
|
|
|
struct scsipi_link *sc_link = acb->xs->sc_link;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
int i;
|
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
|
scsi_print_addr(sc_link);
|
1994-11-29 20:50:39 +03:00
|
|
|
|
if ((acb->xs->flags & SCSI_RESET) == 0) {
|
1997-08-27 15:22:52 +04:00
|
|
|
|
for (i = 0; i < acb->scsipi_cmd_length; i++) {
|
1994-04-26 07:43:26 +04:00
|
|
|
|
if (i)
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf(",");
|
|
|
|
|
printf("%x", b[i]);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("\n");
|
1994-04-26 07:43:26 +04:00
|
|
|
|
} else
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("RESET\n");
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
aic_print_acb(acb)
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1994-04-26 07:43:26 +04:00
|
|
|
|
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("acb@%p xs=%p flags=%x", acb, acb->xs, acb->flags);
|
|
|
|
|
printf(" dp=%p dleft=%d target_stat=%x\n",
|
1996-04-30 00:02:32 +04:00
|
|
|
|
acb->data_addr, acb->data_length, acb->target_stat);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
aic_show_scsi_cmd(acb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
aic_print_active_acb()
|
|
|
|
|
{
|
1994-12-28 22:42:47 +03:00
|
|
|
|
struct aic_acb *acb;
|
1996-03-17 03:43:52 +03:00
|
|
|
|
struct aic_softc *sc = aic_cd.cd_devs[0];
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("ready list:\n");
|
1995-01-07 04:51:07 +03:00
|
|
|
|
for (acb = sc->ready_list.tqh_first; acb != NULL;
|
1994-11-30 00:29:56 +03:00
|
|
|
|
acb = acb->chain.tqe_next)
|
1994-04-26 04:05:56 +04:00
|
|
|
|
aic_print_acb(acb);
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("nexus:\n");
|
1995-01-07 04:51:07 +03:00
|
|
|
|
if (sc->sc_nexus != NULL)
|
|
|
|
|
aic_print_acb(sc->sc_nexus);
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("nexus list:\n");
|
1995-01-07 04:51:07 +03:00
|
|
|
|
for (acb = sc->nexus_list.tqh_first; acb != NULL;
|
1994-11-30 00:29:56 +03:00
|
|
|
|
acb = acb->chain.tqe_next)
|
1994-04-26 04:05:56 +04:00
|
|
|
|
aic_print_acb(acb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_dump6360(sc)
|
|
|
|
|
struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_tag_t iot = sc->sc_iot;
|
|
|
|
|
bus_space_handle_t ioh = sc->sc_ioh;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("aic6360: SCSISEQ=%x SXFRCTL0=%x SXFRCTL1=%x SCSISIG=%x\n",
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_1(iot, ioh, SCSISEQ),
|
|
|
|
|
bus_space_read_1(iot, ioh, SXFRCTL0),
|
|
|
|
|
bus_space_read_1(iot, ioh, SXFRCTL1),
|
|
|
|
|
bus_space_read_1(iot, ioh, SCSISIG));
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf(" SSTAT0=%x SSTAT1=%x SSTAT2=%x SSTAT3=%x SSTAT4=%x\n",
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT0),
|
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT1),
|
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT2),
|
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT3),
|
|
|
|
|
bus_space_read_1(iot, ioh, SSTAT4));
|
|
|
|
|
printf(" SIMODE0=%x SIMODE1=%x DMACNTRL0=%x DMACNTRL1=%x "
|
|
|
|
|
"DMASTAT=%x\n",
|
|
|
|
|
bus_space_read_1(iot, ioh, SIMODE0),
|
|
|
|
|
bus_space_read_1(iot, ioh, SIMODE1),
|
|
|
|
|
bus_space_read_1(iot, ioh, DMACNTRL0),
|
|
|
|
|
bus_space_read_1(iot, ioh, DMACNTRL1),
|
|
|
|
|
bus_space_read_1(iot, ioh, DMASTAT));
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf(" FIFOSTAT=%d SCSIBUS=0x%x\n",
|
1997-10-06 23:49:17 +04:00
|
|
|
|
bus_space_read_1(iot, ioh, FIFOSTAT),
|
|
|
|
|
bus_space_read_1(iot, ioh, SCSIBUS));
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1995-01-07 04:51:07 +03:00
|
|
|
|
aic_dump_driver(sc)
|
|
|
|
|
struct aic_softc *sc;
|
1994-04-26 04:05:56 +04:00
|
|
|
|
{
|
|
|
|
|
struct aic_tinfo *ti;
|
|
|
|
|
int i;
|
1995-08-13 00:30:45 +04:00
|
|
|
|
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("nexus=%p prevphase=%x\n", sc->sc_nexus, sc->sc_prevphase);
|
1997-10-06 23:49:17 +04:00
|
|
|
|
printf("state=%x msgin=%x msgpriq=%x msgoutq=%x lastmsg=%x "
|
|
|
|
|
"currmsg=%x\n",
|
1995-01-07 04:51:07 +03:00
|
|
|
|
sc->sc_state, sc->sc_imess[0],
|
1995-02-02 00:49:37 +03:00
|
|
|
|
sc->sc_msgpriq, sc->sc_msgoutq, sc->sc_lastmsg, sc->sc_currmsg);
|
1994-04-26 07:43:26 +04:00
|
|
|
|
for (i = 0; i < 7; i++) {
|
1995-01-07 04:51:07 +03:00
|
|
|
|
ti = &sc->sc_tinfo[i];
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf("tinfo%d: %d cmds %d disconnects %d timeouts",
|
1994-04-26 07:43:26 +04:00
|
|
|
|
i, ti->cmds, ti->dconns, ti->touts);
|
1996-10-13 05:37:04 +04:00
|
|
|
|
printf(" %d senses flags=%x\n", ti->senses, ti->flags);
|
1994-04-26 04:05:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|