2003-01-06 15:46:05 +03:00
|
|
|
/* $NetBSD: aic7xxx.c,v 1.92 2003/01/06 12:46:09 wiz Exp $ */
|
1996-05-20 04:56:39 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
|
|
|
* Generic driver for the aic7xxx based adaptec SCSI controllers
|
|
|
|
* Product specific probe and attach routines can be found in:
|
2000-03-15 05:08:28 +03:00
|
|
|
* i386/eisa/ahc_eisa.c 27/284X and aic7770 motherboard controllers
|
|
|
|
* pci/ahc_pci.c 3985, 3980, 3940, 2940, aic7895, aic7890,
|
|
|
|
* aic7880, aic7870, aic7860, and aic7850 controllers
|
2002-01-16 05:11:20 +03:00
|
|
|
* cardbus/ahc_cardbus.c aic7860 cardbus controllers
|
1995-10-09 12:49:30 +03:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
|
1996-05-16 07:59:03 +04:00
|
|
|
* All rights reserved.
|
1995-10-09 12:49:30 +03:00
|
|
|
*
|
1996-05-16 07:59:03 +04: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
|
2000-03-15 05:08:28 +03:00
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
1996-05-16 07:59:03 +04:00
|
|
|
* derived from this software without specific prior written permission.
|
1995-10-09 12:49:30 +03:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* the GNU Public License ("GPL").
|
|
|
|
*
|
1996-05-16 07:59:03 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1996-07-11 02:50:44 +04:00
|
|
|
*
|
2000-03-25 22:52:12 +03:00
|
|
|
* $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.42 2000/03/18 22:28:18 gibbs Exp $
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* A few notes on features of the driver.
|
1996-05-16 07:59:03 +04:00
|
|
|
*
|
|
|
|
* SCB paging takes advantage of the fact that devices stay disconnected
|
|
|
|
* from the bus a relatively long time and that while they're disconnected,
|
2000-03-15 05:08:28 +03:00
|
|
|
* having the SCBs for these transactions down on the host adapter is of
|
|
|
|
* little use. Instead of leaving this idle SCB down on the card we copy
|
|
|
|
* it back up into kernel memory and reuse the SCB slot on the card to
|
|
|
|
* schedule another transaction. This can be a real payoff when doing random
|
|
|
|
* I/O to tagged queueing devices since there are more transactions active at
|
|
|
|
* once for the device to sort for optimal seek reduction. The algorithm goes
|
|
|
|
* like this...
|
1996-05-16 07:59:03 +04:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* The sequencer maintains two lists of its hardware SCBs. The first is the
|
|
|
|
* singly linked free list which tracks all SCBs that are not currently in
|
|
|
|
* use. The second is the doubly linked disconnected list which holds the
|
|
|
|
* SCBs of transactions that are in the disconnected state sorted most
|
|
|
|
* recently disconnected first. When the kernel queues a transaction to
|
|
|
|
* the card, a hardware SCB to "house" this transaction is retrieved from
|
|
|
|
* either of these two lists. If the SCB came from the disconnected list,
|
|
|
|
* a check is made to see if any data transfer or SCB linking (more on linking
|
|
|
|
* in a bit) information has been changed since it was copied from the host
|
|
|
|
* and if so, DMAs the SCB back up before it can be used. Once a hardware
|
|
|
|
* SCB has been obtained, the SCB is DMAed from the host. Before any work
|
|
|
|
* can begin on this SCB, the sequencer must ensure that either the SCB is
|
|
|
|
* for a tagged transaction or the target is not already working on another
|
|
|
|
* non-tagged transaction. If a conflict arises in the non-tagged case, the
|
|
|
|
* sequencer finds the SCB for the active transactions and sets the SCB_LINKED
|
|
|
|
* field in that SCB to this next SCB to execute. To facilitate finding
|
|
|
|
* active non-tagged SCBs, the last four bytes of up to the first four hardware
|
|
|
|
* SCBs serve as a storage area for the currently active SCB ID for each
|
|
|
|
* target.
|
1996-05-16 07:59:03 +04:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* When a device reconnects, a search is made of the hardware SCBs to find
|
|
|
|
* the SCB for this transaction. If the search fails, a hardware SCB is
|
|
|
|
* pulled from either the free or disconnected SCB list and the proper
|
|
|
|
* SCB is DMAed from the host. If the MK_MESSAGE control bit is set
|
|
|
|
* in the control byte of the SCB while it was disconnected, the sequencer
|
|
|
|
* will assert ATN and attempt to issue a message to the host.
|
1996-05-16 07:59:03 +04:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* When a command completes, a check for non-zero status and residuals is
|
|
|
|
* made. If either of these conditions exists, the SCB is DMAed back up to
|
|
|
|
* the host so that it can interpret this information. Additionally, in the
|
|
|
|
* case of bad status, the sequencer generates a special interrupt and pauses
|
2000-06-30 03:12:19 +04:00
|
|
|
* itself. This allows the host to setup a request sense command if it
|
2000-03-15 05:08:28 +03:00
|
|
|
* chooses for this target synchronously with the error so that sense
|
|
|
|
* information isn't lost.
|
1996-05-16 07:59:03 +04:00
|
|
|
*
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
|
|
|
|
2001-11-13 16:14:31 +03:00
|
|
|
#include <sys/cdefs.h>
|
2003-01-06 15:46:05 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: aic7xxx.c,v 1.92 2003/01/06 12:46:09 wiz Exp $");
|
2001-11-13 16:14:31 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#include "opt_ddb.h"
|
2000-06-30 03:12:19 +04:00
|
|
|
#include "opt_ahc.h"
|
2000-03-15 05:08:28 +03:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
#include <sys/param.h>
|
2000-03-15 05:08:28 +03:00
|
|
|
#include <sys/kernel.h>
|
1995-10-09 12:49:30 +03:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
2000-05-28 01:58:15 +04:00
|
|
|
#include <sys/scsiio.h>
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.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/scsipi_debug.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-06-28 21:12:48 +04:00
|
|
|
#include <uvm/uvm_extern.h>
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
#include <dev/ic/aic7xxxvar.h>
|
2000-03-15 05:08:28 +03:00
|
|
|
#include <dev/microcode/aic7xxx/sequencer.h>
|
|
|
|
#include <dev/microcode/aic7xxx/aic7xxx_reg.h>
|
|
|
|
#include <dev/microcode/aic7xxx/aic7xxx_seq.h>
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#define ALL_CHANNELS '\0'
|
|
|
|
#define ALL_TARGETS_MASK 0xFFFF
|
|
|
|
#define INITIATOR_WILDCARD (~0)
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
#define SIM_IS_SCSIBUS_B(ahc, periph) \
|
|
|
|
((periph)->periph_channel->chan_channel == 1)
|
|
|
|
#define SIM_CHANNEL(ahc, periph) \
|
|
|
|
(SIM_IS_SCSIBUS_B(ahc, periph) ? 'B' : 'A')
|
|
|
|
#define SIM_SCSI_ID(ahc, periph) \
|
|
|
|
(SIM_IS_SCSIBUS_B(ahc, periph) ? ahc->our_id_b : ahc->our_id)
|
2000-03-15 05:08:28 +03:00
|
|
|
#define SCB_IS_SCSIBUS_B(scb) \
|
|
|
|
(((scb)->hscb->tcl & SELBUSB) != 0)
|
|
|
|
#define SCB_TARGET(scb) \
|
|
|
|
(((scb)->hscb->tcl & TID) >> 4)
|
|
|
|
#define SCB_CHANNEL(scb) \
|
|
|
|
(SCB_IS_SCSIBUS_B(scb) ? 'B' : 'A')
|
|
|
|
#define SCB_LUN(scb) \
|
|
|
|
((scb)->hscb->tcl & LID)
|
|
|
|
#define SCB_TARGET_OFFSET(scb) \
|
|
|
|
(SCB_TARGET(scb) + (SCB_IS_SCSIBUS_B(scb) ? 8 : 0))
|
|
|
|
#define SCB_TARGET_MASK(scb) \
|
|
|
|
(0x01 << (SCB_TARGET_OFFSET(scb)))
|
|
|
|
#define TCL_CHANNEL(ahc, tcl) \
|
|
|
|
((((ahc)->features & AHC_TWIN) && ((tcl) & SELBUSB)) ? 'B' : 'A')
|
|
|
|
#define TCL_SCSI_ID(ahc, tcl) \
|
|
|
|
(TCL_CHANNEL((ahc), (tcl)) == 'B' ? (ahc)->our_id_b : (ahc)->our_id)
|
|
|
|
#define TCL_TARGET(tcl) (((tcl) & TID) >> TCL_TARGET_SHIFT)
|
|
|
|
#define TCL_LUN(tcl) ((tcl) & LID)
|
|
|
|
|
|
|
|
#define XS_TCL(ahc, xs) \
|
2001-04-25 21:53:04 +04:00
|
|
|
((((xs)->xs_periph->periph_target << 4) & 0xF0) \
|
|
|
|
| (SIM_IS_SCSIBUS_B((ahc), (xs)->xs_periph) ? SELBUSB : 0) \
|
|
|
|
| ((xs)->xs_periph->periph_lun & 0x07))
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
const char * const ahc_chip_names[] =
|
2000-03-15 05:08:28 +03:00
|
|
|
{
|
|
|
|
"NONE",
|
|
|
|
"aic7770",
|
|
|
|
"aic7850",
|
|
|
|
"aic7855",
|
|
|
|
"aic7859",
|
|
|
|
"aic7860",
|
|
|
|
"aic7870",
|
|
|
|
"aic7880",
|
|
|
|
"aic7890/91",
|
|
|
|
"aic7892",
|
|
|
|
"aic7895",
|
|
|
|
"aic7896/97",
|
|
|
|
"aic7899"
|
|
|
|
};
|
1998-03-16 18:36:17 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
typedef enum {
|
|
|
|
ROLE_UNKNOWN,
|
|
|
|
ROLE_INITIATOR,
|
|
|
|
ROLE_TARGET
|
|
|
|
} role_t;
|
|
|
|
|
|
|
|
struct ahc_devinfo {
|
|
|
|
int our_scsiid;
|
|
|
|
int target_offset;
|
|
|
|
u_int16_t target_mask;
|
|
|
|
u_int8_t target;
|
|
|
|
u_int8_t lun;
|
|
|
|
char channel;
|
|
|
|
role_t role; /*
|
|
|
|
* Only guaranteed to be correct if not
|
|
|
|
* in the busfree state.
|
|
|
|
*/
|
|
|
|
};
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
typedef enum {
|
|
|
|
SEARCH_COMPLETE,
|
|
|
|
SEARCH_COUNT,
|
|
|
|
SEARCH_REMOVE
|
|
|
|
} ahc_search_action;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
#ifdef AHC_DEBUG
|
1996-07-11 02:50:44 +04:00
|
|
|
static int ahc_debug = AHC_DEBUG;
|
1996-05-16 07:59:03 +04:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static int ahcinitscbdata(struct ahc_softc *);
|
|
|
|
static void ahcfiniscbdata(struct ahc_softc *);
|
|
|
|
|
|
|
|
#if UNUSED
|
|
|
|
static void ahc_dump_targcmd(struct target_cmd *);
|
|
|
|
#endif
|
|
|
|
static void ahc_shutdown(void *arg);
|
2001-04-25 21:53:04 +04:00
|
|
|
static void ahc_action(struct scsipi_channel *,
|
|
|
|
scsipi_adapter_req_t, void *);
|
|
|
|
static int ahc_ioctl(struct scsipi_channel *, u_long, caddr_t, int,
|
2000-05-28 01:58:15 +04:00
|
|
|
struct proc *);
|
2001-04-25 21:53:04 +04:00
|
|
|
static void ahc_execute_scb(void *, bus_dma_segment_t *, int);
|
2000-03-15 05:08:28 +03:00
|
|
|
static int ahc_poll(struct ahc_softc *, int);
|
2001-04-25 21:53:04 +04:00
|
|
|
static void ahc_setup_data(struct ahc_softc *, struct scsipi_xfer *,
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb *);
|
2001-04-25 21:53:04 +04:00
|
|
|
static void ahc_freeze_devq(struct ahc_softc *, struct scsipi_periph *);
|
2000-03-15 05:08:28 +03:00
|
|
|
static void ahcallocscbs(struct ahc_softc *);
|
|
|
|
#if UNUSED
|
|
|
|
static void ahc_scb_devinfo(struct ahc_softc *, struct ahc_devinfo *,
|
|
|
|
struct scb *);
|
|
|
|
#endif
|
|
|
|
static void ahc_fetch_devinfo(struct ahc_softc *, struct ahc_devinfo *);
|
|
|
|
static void ahc_compile_devinfo(struct ahc_devinfo *, u_int, u_int, u_int,
|
|
|
|
char, role_t);
|
|
|
|
static u_int ahc_abort_wscb(struct ahc_softc *, u_int, u_int);
|
|
|
|
static void ahc_done(struct ahc_softc *, struct scb *);
|
|
|
|
static struct tmode_tstate *
|
|
|
|
ahc_alloc_tstate(struct ahc_softc *, u_int, char);
|
|
|
|
#if UNUSED
|
|
|
|
static void ahc_free_tstate(struct ahc_softc *, u_int, char, int);
|
|
|
|
#endif
|
|
|
|
static void ahc_handle_seqint(struct ahc_softc *, u_int);
|
|
|
|
static void ahc_handle_scsiint(struct ahc_softc *, u_int);
|
|
|
|
static void ahc_build_transfer_msg(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *);
|
|
|
|
static void ahc_setup_initiator_msgout(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *,
|
|
|
|
struct scb *);
|
|
|
|
static void ahc_setup_target_msgin(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *);
|
|
|
|
static void ahc_clear_msg_state(struct ahc_softc *);
|
|
|
|
static void ahc_handle_message_phase(struct ahc_softc *,
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_periph *);
|
2000-03-15 05:08:28 +03:00
|
|
|
static int ahc_sent_msg(struct ahc_softc *, u_int, int);
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
static int ahc_parse_msg(struct ahc_softc *, struct scsipi_periph *,
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_devinfo *);
|
|
|
|
static void ahc_handle_ign_wide_residue(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *);
|
|
|
|
static void ahc_handle_devreset(struct ahc_softc *, struct ahc_devinfo *,
|
|
|
|
int, char *, int);
|
|
|
|
#ifdef AHC_DUMP_SEQ
|
|
|
|
static void ahc_dumpseq(struct ahc_softc *);
|
|
|
|
#endif
|
|
|
|
static void ahc_loadseq(struct ahc_softc *);
|
2001-01-22 17:30:43 +03:00
|
|
|
static int ahc_check_patch(struct ahc_softc *, const struct patch **,
|
2000-03-15 05:08:28 +03:00
|
|
|
int, int *);
|
|
|
|
static void ahc_download_instr(struct ahc_softc *, int, u_int8_t *);
|
|
|
|
static int ahc_match_scb(struct scb *, int, char, int, u_int, role_t);
|
|
|
|
#if defined(AHC_DEBUG)
|
|
|
|
static void ahc_print_scb(struct scb *);
|
|
|
|
#endif
|
|
|
|
static int ahc_search_qinfifo(struct ahc_softc *, int, char, int, u_int,
|
|
|
|
role_t, scb_flag, ahc_search_action);
|
|
|
|
static int ahc_reset_channel(struct ahc_softc *, char, int);
|
|
|
|
static int ahc_abort_scbs(struct ahc_softc *, int, char, int, u_int,
|
|
|
|
role_t, int);
|
|
|
|
static int ahc_search_disc_list(struct ahc_softc *, int,
|
|
|
|
char, int, u_int, int, int, int);
|
|
|
|
static u_int ahc_rem_scb_from_disc_list(struct ahc_softc *, u_int, u_int);
|
|
|
|
static void ahc_add_curscb_to_free_list(struct ahc_softc *);
|
|
|
|
static void ahc_clear_intstat(struct ahc_softc *);
|
|
|
|
static void ahc_reset_current_bus(struct ahc_softc *);
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct ahc_syncrate *
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_devlimited_syncrate(struct ahc_softc *, u_int *);
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct ahc_syncrate *
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_find_syncrate(struct ahc_softc *, u_int *, u_int);
|
|
|
|
static u_int ahc_find_period(struct ahc_softc *, u_int, u_int);
|
2001-01-18 23:28:15 +03:00
|
|
|
static void ahc_validate_offset(struct ahc_softc *,
|
|
|
|
const struct ahc_syncrate *, u_int *, int);
|
2000-03-15 05:08:28 +03:00
|
|
|
static void ahc_update_target_msg_request(struct ahc_softc *,
|
|
|
|
struct ahc_devinfo *,
|
|
|
|
struct ahc_initiator_tinfo *,
|
|
|
|
int, int);
|
|
|
|
static void ahc_set_syncrate(struct ahc_softc *, struct ahc_devinfo *,
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *, u_int, u_int,
|
|
|
|
u_int, int, int);
|
2000-03-15 05:08:28 +03:00
|
|
|
static void ahc_set_width(struct ahc_softc *, struct ahc_devinfo *,
|
|
|
|
u_int, u_int, int, int);
|
2001-04-25 21:53:04 +04:00
|
|
|
static void ahc_set_tags(struct ahc_softc *, struct ahc_devinfo *, int);
|
2001-04-26 20:56:53 +04:00
|
|
|
static void ahc_update_xfer_mode(struct ahc_softc *, struct ahc_devinfo *);
|
2000-03-15 05:08:28 +03:00
|
|
|
static void ahc_construct_sdtr(struct ahc_softc *, u_int, u_int);
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void ahc_construct_wdtr(struct ahc_softc *, u_int);
|
|
|
|
|
|
|
|
static void ahc_calc_residual(struct scb *);
|
|
|
|
|
|
|
|
static void ahc_update_pending_syncrates(struct ahc_softc *);
|
|
|
|
|
|
|
|
static void ahc_set_recoveryscb(struct ahc_softc *, struct scb *);
|
|
|
|
|
|
|
|
static void ahc_timeout (void *);
|
|
|
|
static __inline int sequencer_paused(struct ahc_softc *);
|
|
|
|
static __inline void pause_sequencer(struct ahc_softc *);
|
|
|
|
static __inline void unpause_sequencer(struct ahc_softc *);
|
|
|
|
static void restart_sequencer(struct ahc_softc *);
|
|
|
|
static __inline u_int ahc_index_busy_tcl(struct ahc_softc *, u_int, int);
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static __inline void ahc_busy_tcl(struct ahc_softc *, struct scb *);
|
|
|
|
static __inline int ahc_isbusy_tcl(struct ahc_softc *, struct scb *);
|
|
|
|
|
|
|
|
static __inline void ahc_freeze_ccb(struct scb *);
|
|
|
|
static __inline void ahcsetccbstatus(struct scsipi_xfer *, int);
|
|
|
|
static void ahc_run_qoutfifo(struct ahc_softc *);
|
|
|
|
|
|
|
|
static __inline struct ahc_initiator_tinfo *
|
|
|
|
ahc_fetch_transinfo(struct ahc_softc *,
|
|
|
|
char, u_int, u_int,
|
|
|
|
struct tmode_tstate **);
|
|
|
|
static void ahcfreescb(struct ahc_softc *, struct scb *);
|
|
|
|
static __inline struct scb *ahcgetscb(struct ahc_softc *);
|
|
|
|
|
|
|
|
static int ahc_createdmamem(bus_dma_tag_t, int, int, bus_dmamap_t *,
|
|
|
|
caddr_t *, bus_addr_t *, bus_dma_segment_t *,
|
|
|
|
int *, const char *, const char *);
|
2000-06-30 03:12:19 +04:00
|
|
|
static void ahc_freedmamem(bus_dma_tag_t, int, bus_dmamap_t,
|
2000-03-15 05:08:28 +03:00
|
|
|
caddr_t, bus_dma_segment_t *, int);
|
|
|
|
static void ahcminphys(struct buf *);
|
|
|
|
|
|
|
|
static __inline void ahc_swap_hscb(struct hardware_scb *);
|
|
|
|
static __inline void ahc_swap_sg(struct ahc_dma_seg *);
|
2000-05-25 15:41:05 +04:00
|
|
|
static int ahc_istagged_device(struct ahc_softc *, struct scsipi_xfer *, int);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
#if defined(AHC_DEBUG) && 0
|
|
|
|
static void ahc_dumptinfo(struct ahc_softc *, struct ahc_initiator_tinfo *);
|
1998-11-20 00:43:00 +03:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static __inline void
|
|
|
|
ahc_swap_hscb(struct hardware_scb *hscb)
|
|
|
|
{
|
|
|
|
hscb->SG_pointer = htole32(hscb->SG_pointer);
|
|
|
|
hscb->data = htole32(hscb->data);
|
|
|
|
hscb->datalen = htole32(hscb->datalen);
|
|
|
|
/*
|
2000-05-19 08:34:39 +04:00
|
|
|
* No need to swap cmdpointer; it's either 0 or set to
|
2000-03-15 05:08:28 +03:00
|
|
|
* cmdstore_busaddr, which is already swapped.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_swap_sg(struct ahc_dma_seg *sg)
|
|
|
|
{
|
|
|
|
sg->addr = htole32(sg->addr);
|
|
|
|
sg->len = htole32(sg->len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahcminphys(bp)
|
|
|
|
struct buf *bp;
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Even though the card can transfer up to 16megs per command
|
|
|
|
* we are limited by the number of segments in the dma segment
|
|
|
|
* list that we can hold. The worst case is that all pages are
|
|
|
|
* discontinuous physically, hense the "page per segment" limit
|
|
|
|
* enforced here.
|
|
|
|
*/
|
|
|
|
if (bp->b_bcount > AHC_MAXTRANSFER_SIZE) {
|
|
|
|
bp->b_bcount = AHC_MAXTRANSFER_SIZE;
|
|
|
|
}
|
|
|
|
minphys(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static __inline u_int32_t
|
|
|
|
ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index)
|
|
|
|
{
|
|
|
|
return (ahc->scb_data->hscb_busaddr
|
|
|
|
+ (sizeof(struct hardware_scb) * index));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define AHC_BUSRESET_DELAY 25 /* Reset delay in us */
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
sequencer_paused(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
return ((ahc_inb(ahc, HCNTRL) & PAUSE) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
pause_sequencer(struct ahc_softc *ahc)
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, HCNTRL, ahc->pause);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Since the sequencer can disable pausing in a critical section, we
|
|
|
|
* must loop until it actually stops.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
while (sequencer_paused(ahc) == 0)
|
1996-05-16 07:59:03 +04:00
|
|
|
;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static __inline void
|
|
|
|
unpause_sequencer(struct ahc_softc *ahc)
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((ahc_inb(ahc, INTSTAT) & (SCSIINT | SEQINT | BRKADRINT)) == 0)
|
|
|
|
ahc_outb(ahc, HCNTRL, ahc->unpause);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
|
|
|
/*
|
1996-05-16 07:59:03 +04:00
|
|
|
* Restart the sequencer program from address zero
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
restart_sequencer(struct ahc_softc *ahc)
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int i;
|
|
|
|
|
|
|
|
pause_sequencer(ahc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Everytime we restart the sequencer, there
|
|
|
|
* is the possiblitity that we have restarted
|
|
|
|
* within a three instruction window where an
|
|
|
|
* SCB has been marked free but has not made it
|
|
|
|
* onto the free list. Since SCSI events(bus reset,
|
|
|
|
* unexpected bus free) will always freeze the
|
|
|
|
* sequencer, we cannot close this window. To
|
|
|
|
* avoid losing an SCB, we reconsitute the free
|
|
|
|
* list every time we restart the sequencer.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, FREE_SCBH, SCB_LIST_NULL);
|
|
|
|
for (i = 0; i < ahc->scb_data->maxhscbs; i++) {
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCBPTR, i);
|
|
|
|
if (ahc_inb(ahc, SCB_TAG) == SCB_LIST_NULL)
|
|
|
|
ahc_add_curscb_to_free_list(ahc);
|
|
|
|
}
|
|
|
|
ahc_outb(ahc, SEQCTL, FASTMODE|SEQRESET);
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_int
|
|
|
|
ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl, int unbusy)
|
|
|
|
{
|
|
|
|
u_int scbid;
|
|
|
|
|
|
|
|
scbid = ahc->untagged_scbs[tcl];
|
|
|
|
if (unbusy) {
|
|
|
|
ahc->untagged_scbs[tcl] = SCB_LIST_NULL;
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap,
|
|
|
|
UNTAGGEDSCB_OFFSET * 256, 256, BUS_DMASYNC_PREWRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (scbid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_busy_tcl(struct ahc_softc *ahc, struct scb *scb)
|
|
|
|
{
|
|
|
|
ahc->untagged_scbs[scb->hscb->tcl] = scb->hscb->tag;
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap,
|
|
|
|
UNTAGGEDSCB_OFFSET * 256, 256, BUS_DMASYNC_PREWRITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline int
|
|
|
|
ahc_isbusy_tcl(struct ahc_softc *ahc, struct scb *scb)
|
|
|
|
{
|
|
|
|
return ahc->untagged_scbs[scb->hscb->tcl] != SCB_LIST_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahc_freeze_ccb(struct scb *scb)
|
|
|
|
{
|
|
|
|
struct scsipi_xfer *xs = scb->xs;
|
|
|
|
|
|
|
|
if (!(scb->flags & SCB_FREEZE_QUEUE)) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_periph_freeze(xs->xs_periph, 1);
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->flags |= SCB_FREEZE_QUEUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void
|
|
|
|
ahcsetccbstatus(struct scsipi_xfer *xs, int status)
|
|
|
|
{
|
|
|
|
xs->error = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline struct ahc_initiator_tinfo *
|
|
|
|
ahc_fetch_transinfo(struct ahc_softc *ahc, char channel, u_int our_id,
|
|
|
|
u_int remote_id, struct tmode_tstate **tstate)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Transfer data structures are stored from the perspective
|
|
|
|
* of the target role. Since the parameters for a connection
|
|
|
|
* in the initiator role to a given target are the same as
|
|
|
|
* when the roles are reversed, we pretend we are the target.
|
|
|
|
*/
|
|
|
|
if (channel == 'B')
|
|
|
|
our_id += 8;
|
|
|
|
*tstate = ahc->enabled_targets[our_id];
|
|
|
|
return (&(*tstate)->transinfo[remote_id]);
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_run_qoutfifo(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
struct scb *scb;
|
|
|
|
u_int scb_index;
|
|
|
|
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap, 0,
|
|
|
|
256, BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
while (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL) {
|
|
|
|
scb_index = ahc->qoutfifo[ahc->qoutfifonext];
|
|
|
|
ahc->qoutfifo[ahc->qoutfifonext++] = SCB_LIST_NULL;
|
|
|
|
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
if (scb_index >= ahc->scb_data->numscbs
|
|
|
|
|| (scb->flags & SCB_ACTIVE) == 0) {
|
|
|
|
printf("%s: WARNING no command for scb %d "
|
|
|
|
"(cmdcmplt)\nQOUTPOS = %d\n",
|
|
|
|
ahc_name(ahc), scb_index,
|
|
|
|
ahc->qoutfifonext - 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save off the residual
|
|
|
|
* if there is one.
|
|
|
|
*/
|
|
|
|
if (scb->hscb->residual_SG_count != 0)
|
|
|
|
ahc_calc_residual(scb);
|
|
|
|
else
|
|
|
|
scb->xs->resid = 0;
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWSCBS) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("run_qoutfifo: SCB %x complete\n",
|
|
|
|
scb->hscb->tag);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
ahc_done(ahc, scb);
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* An scb (and hence an scb entry on the board) is put onto the
|
|
|
|
* free list.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahcfreescb(struct ahc_softc *ahc, struct scb *scb)
|
2000-06-30 03:12:19 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct hardware_scb *hscb;
|
|
|
|
int opri;
|
|
|
|
|
|
|
|
hscb = scb->hscb;
|
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWSCBALLOC)
|
|
|
|
printf("%s: free SCB tag %x\n", ahc_name(ahc), hscb->tag);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
opri = splbio();
|
|
|
|
|
|
|
|
if ((ahc->flags & AHC_RESOURCE_SHORTAGE) != 0 ||
|
|
|
|
(scb->flags & SCB_RECOVERY_SCB) != 0) {
|
|
|
|
ahc->flags &= ~AHC_RESOURCE_SHORTAGE;
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_channel_thaw(&ahc->sc_channel, 1);
|
|
|
|
if (ahc->features & AHC_TWIN)
|
|
|
|
scsipi_channel_thaw(&ahc->sc_channel_b, 1);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up for the next user */
|
|
|
|
scb->flags = SCB_FREE;
|
|
|
|
hscb->control = 0;
|
|
|
|
hscb->status = 0;
|
|
|
|
|
|
|
|
SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, scb, links);
|
|
|
|
|
|
|
|
splx(opri);
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Get a free scb, either one already assigned to a hardware slot
|
|
|
|
* on the adapter or one that will require an SCB to be paged out before
|
|
|
|
* use. If there are none, see if we can allocate a new SCB. Otherwise
|
|
|
|
* either return an error or sleep.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
static __inline struct scb *
|
|
|
|
ahcgetscb(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
struct scb *scbp;
|
|
|
|
int opri;;
|
|
|
|
|
|
|
|
opri = splbio();
|
|
|
|
if ((scbp = SLIST_FIRST(&ahc->scb_data->free_scbs))) {
|
|
|
|
SLIST_REMOVE_HEAD(&ahc->scb_data->free_scbs, links);
|
|
|
|
} else {
|
|
|
|
ahcallocscbs(ahc);
|
|
|
|
scbp = SLIST_FIRST(&ahc->scb_data->free_scbs);
|
|
|
|
if (scbp != NULL)
|
|
|
|
SLIST_REMOVE_HEAD(&ahc->scb_data->free_scbs, links);
|
|
|
|
}
|
|
|
|
|
|
|
|
splx(opri);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
#ifdef AHC_DEBUG
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_debug & AHC_SHOWSCBALLOC) {
|
|
|
|
if (scbp != NULL)
|
|
|
|
printf("%s: new SCB, tag %x\n", ahc_name(ahc),
|
|
|
|
scbp->hscb->tag);
|
|
|
|
else
|
|
|
|
printf("%s: failed to allocate new SCB\n",
|
|
|
|
ahc_name(ahc));
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
return (scbp);
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static int
|
|
|
|
ahc_createdmamem(tag, size, flags, mapp, vaddr, baddr, seg, nseg, myname, what)
|
|
|
|
bus_dma_tag_t tag;
|
|
|
|
int size;
|
|
|
|
int flags;
|
|
|
|
bus_dmamap_t *mapp;
|
|
|
|
caddr_t *vaddr;
|
|
|
|
bus_addr_t *baddr;
|
|
|
|
bus_dma_segment_t *seg;
|
|
|
|
int *nseg;
|
|
|
|
const char *myname, *what;
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
int error, level = 0;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-11-14 21:21:00 +03:00
|
|
|
if ((error = bus_dmamem_alloc(tag, size, PAGE_SIZE, 0,
|
2000-03-15 05:08:28 +03:00
|
|
|
seg, 1, nseg, BUS_DMA_NOWAIT)) != 0) {
|
|
|
|
printf("%s: failed to allocate DMA mem for %s, error = %d\n",
|
|
|
|
myname, what, error);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
level++;
|
|
|
|
|
|
|
|
if ((error = bus_dmamem_map(tag, seg, *nseg, size, vaddr,
|
|
|
|
BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
|
|
|
|
printf("%s: failed to map DMA mem for %s, error = %d\n",
|
|
|
|
myname, what, error);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
level++;
|
|
|
|
|
|
|
|
if ((error = bus_dmamap_create(tag, size, 1, size, 0,
|
|
|
|
BUS_DMA_NOWAIT | flags, mapp)) != 0) {
|
|
|
|
printf("%s: failed to create DMA map for %s, error = %d\n",
|
|
|
|
myname, what, error);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
level++;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((error = bus_dmamap_load(tag, *mapp, *vaddr, size, NULL,
|
|
|
|
BUS_DMA_NOWAIT)) != 0) {
|
|
|
|
printf("%s: failed to load DMA map for %s, error = %d\n",
|
|
|
|
myname, what, error);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
*baddr = (*mapp)->dm_segs[0].ds_addr;
|
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
printf("%s: dmamem for %s at busaddr %lx virt %lx nseg %d size %d\n",
|
|
|
|
myname, what, (unsigned long)*baddr, (unsigned long)*vaddr,
|
|
|
|
*nseg, size);
|
1996-05-16 07:59:03 +04:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
return 0;
|
|
|
|
out:
|
|
|
|
switch (level) {
|
|
|
|
case 3:
|
|
|
|
bus_dmamap_destroy(tag, *mapp);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 2:
|
|
|
|
bus_dmamem_unmap(tag, *vaddr, size);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 1:
|
|
|
|
bus_dmamem_free(tag, seg, *nseg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_freedmamem(tag, size, map, vaddr, seg, nseg)
|
|
|
|
bus_dma_tag_t tag;
|
|
|
|
int size;
|
|
|
|
bus_dmamap_t map;
|
|
|
|
caddr_t vaddr;
|
|
|
|
bus_dma_segment_t *seg;
|
|
|
|
int nseg;
|
|
|
|
{
|
|
|
|
|
|
|
|
bus_dmamap_unload(tag, map);
|
|
|
|
bus_dmamap_destroy(tag, map);
|
|
|
|
bus_dmamem_unmap(tag, vaddr, size);
|
|
|
|
bus_dmamem_free(tag, seg, nseg);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
ahc_name(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
return (ahc->sc_dev.dv_xname);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
static void
|
|
|
|
ahc_print_scb(struct scb *scb)
|
|
|
|
{
|
|
|
|
struct hardware_scb *hscb = scb->hscb;
|
|
|
|
|
|
|
|
printf("scb:%p tag %x control:0x%x tcl:0x%x cmdlen:%d cmdpointer:0x%lx\n",
|
|
|
|
scb,
|
|
|
|
hscb->tag,
|
|
|
|
hscb->control,
|
|
|
|
hscb->tcl,
|
|
|
|
hscb->cmdlen,
|
|
|
|
(unsigned long)le32toh(hscb->cmdpointer));
|
|
|
|
printf(" datlen:%u data:0x%lx segs:0x%x segp:0x%lx\n",
|
|
|
|
le32toh(hscb->datalen),
|
|
|
|
(unsigned long)(le32toh(hscb->data)),
|
|
|
|
hscb->SG_count,
|
|
|
|
(unsigned long)(le32toh(hscb->SG_pointer)));
|
|
|
|
printf(" sg_addr:%lx sg_len:%lu\n",
|
|
|
|
(unsigned long)(le32toh(scb->sg_list[0].addr)),
|
2000-05-23 07:50:12 +04:00
|
|
|
(unsigned long)(le32toh(scb->sg_list[0].len)));
|
2000-03-15 05:08:28 +03:00
|
|
|
printf(" cdb:%x %x %x %x %x %x %x %x %x %x %x %x\n",
|
|
|
|
hscb->cmdstore[0], hscb->cmdstore[1], hscb->cmdstore[2],
|
|
|
|
hscb->cmdstore[3], hscb->cmdstore[4], hscb->cmdstore[5],
|
|
|
|
hscb->cmdstore[6], hscb->cmdstore[7], hscb->cmdstore[8],
|
|
|
|
hscb->cmdstore[9], hscb->cmdstore[10], hscb->cmdstore[11]);
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
#endif
|
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct {
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int8_t errno;
|
2001-01-18 23:28:15 +03:00
|
|
|
const char *errmesg;
|
1995-10-09 12:49:30 +03:00
|
|
|
} hard_error[] = {
|
2000-03-15 05:08:28 +03:00
|
|
|
{ ILLHADDR, "Illegal Host Access" },
|
|
|
|
{ ILLSADDR, "Illegal Sequencer Address referrenced" },
|
|
|
|
{ ILLOPCODE, "Illegal Opcode in sequencer program" },
|
|
|
|
{ SQPARERR, "Sequencer Parity Error" },
|
|
|
|
{ DPARERR, "Data-path Parity Error" },
|
|
|
|
{ MPARERR, "Scratch or SCB Memory Parity Error" },
|
|
|
|
{ PCIERRSTAT, "PCI Error detected" },
|
|
|
|
{ CIOPARERR, "CIOBUS Parity Error" },
|
1995-10-09 12:49:30 +03:00
|
|
|
};
|
2000-03-15 05:08:28 +03:00
|
|
|
static const int num_errors = sizeof(hard_error)/sizeof(hard_error[0]);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct {
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int8_t phase;
|
|
|
|
u_int8_t mesg_out; /* Message response to parity errors */
|
2001-01-18 23:28:15 +03:00
|
|
|
const char *phasemsg;
|
2000-03-15 05:08:28 +03:00
|
|
|
} phase_table[] = {
|
|
|
|
{ P_DATAOUT, MSG_NOOP, "in Data-out phase" },
|
|
|
|
{ P_DATAIN, MSG_INITIATOR_DET_ERR, "in Data-in phase" },
|
|
|
|
{ P_COMMAND, MSG_NOOP, "in Command phase" },
|
|
|
|
{ P_MESGOUT, MSG_NOOP, "in Message-out phase" },
|
|
|
|
{ P_STATUS, MSG_INITIATOR_DET_ERR, "in Status phase" },
|
|
|
|
{ P_MESGIN, MSG_PARITY_ERROR, "in Message-in phase" },
|
|
|
|
{ P_BUSFREE, MSG_NOOP, "while idle" },
|
|
|
|
{ 0, MSG_NOOP, "in unknown phase" }
|
|
|
|
};
|
|
|
|
static const int num_phases = (sizeof(phase_table)/sizeof(phase_table[0])) - 1;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid SCSIRATE values. (p. 3-17)
|
2001-07-08 22:06:42 +04:00
|
|
|
* Provides a mapping of transfer periods in ns to the proper value to
|
1995-10-09 12:49:30 +03:00
|
|
|
* stick in the scsiscfr reg to use that transfer rate.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
#define AHC_SYNCRATE_DT 0
|
|
|
|
#define AHC_SYNCRATE_ULTRA2 1
|
2000-03-25 22:52:12 +03:00
|
|
|
#define AHC_SYNCRATE_ULTRA 3
|
|
|
|
#define AHC_SYNCRATE_FAST 6
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct ahc_syncrate ahc_syncrates[] = {
|
2000-03-15 05:08:28 +03:00
|
|
|
/* ultra2 fast/ultra period rate */
|
|
|
|
{ 0x42, 0x000, 9, "80.0" },
|
|
|
|
{ 0x03, 0x000, 10, "40.0" },
|
|
|
|
{ 0x04, 0x000, 11, "33.0" },
|
|
|
|
{ 0x05, 0x100, 12, "20.0" },
|
|
|
|
{ 0x06, 0x110, 15, "16.0" },
|
|
|
|
{ 0x07, 0x120, 18, "13.4" },
|
|
|
|
{ 0x08, 0x000, 25, "10.0" },
|
|
|
|
{ 0x19, 0x010, 31, "8.0" },
|
|
|
|
{ 0x1a, 0x020, 37, "6.67" },
|
|
|
|
{ 0x1b, 0x030, 43, "5.7" },
|
|
|
|
{ 0x1c, 0x040, 50, "5.0" },
|
|
|
|
{ 0x00, 0x050, 56, "4.4" },
|
|
|
|
{ 0x00, 0x060, 62, "4.0" },
|
|
|
|
{ 0x00, 0x070, 68, "3.6" },
|
|
|
|
{ 0x00, 0x000, 0, NULL }
|
1995-10-09 12:49:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
1997-03-09 09:10:32 +03:00
|
|
|
* Allocate a controller structure for a new device and initialize it.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
int
|
|
|
|
ahc_alloc(struct ahc_softc *ahc, bus_space_handle_t sh, bus_space_tag_t st,
|
|
|
|
bus_dma_tag_t parent_dmat, ahc_chip chip, ahc_feature features,
|
|
|
|
ahc_flag flags)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb_data *scb_data;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2002-01-12 19:03:11 +03:00
|
|
|
scb_data = malloc(sizeof (struct scb_data), M_DEVBUF, M_NOWAIT|M_ZERO);
|
2000-03-15 05:08:28 +03:00
|
|
|
if (scb_data == NULL) {
|
|
|
|
printf("%s: cannot malloc softc!\n", ahc_name(ahc));
|
|
|
|
return -1;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
LIST_INIT(&ahc->pending_ccbs);
|
|
|
|
ahc->tag = st;
|
|
|
|
ahc->bsh = sh;
|
|
|
|
ahc->parent_dmat = parent_dmat;
|
|
|
|
ahc->chip = chip;
|
|
|
|
ahc->features = features;
|
1996-05-16 07:59:03 +04:00
|
|
|
ahc->flags = flags;
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->scb_data = scb_data;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->unpause = (ahc_inb(ahc, HCNTRL) & IRQMS) | INTEN;
|
|
|
|
/* The IRQMS bit is only valid on VL and EISA chips */
|
|
|
|
if ((ahc->chip & AHC_PCI) != 0)
|
|
|
|
ahc->unpause &= ~IRQMS;
|
|
|
|
ahc->pause = ahc->unpause | PAUSE;
|
|
|
|
return (0);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
void
|
|
|
|
ahc_free(ahc)
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_softc *ahc;
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
ahcfiniscbdata(ahc);
|
|
|
|
if (ahc->init_level != 0)
|
|
|
|
ahc_freedmamem(ahc->parent_dmat, ahc->shared_data_size,
|
|
|
|
ahc->shared_data_dmamap, ahc->qoutfifo,
|
|
|
|
&ahc->shared_data_seg, ahc->shared_data_nseg);
|
|
|
|
|
|
|
|
if (ahc->scb_data != NULL)
|
|
|
|
free(ahc->scb_data, M_DEVBUF);
|
|
|
|
if (ahc->bus_data != NULL)
|
|
|
|
free(ahc->bus_data, M_DEVBUF);
|
1996-05-16 07:59:03 +04:00
|
|
|
return;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static int
|
|
|
|
ahcinitscbdata(struct ahc_softc *ahc)
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb_data *scb_data;
|
|
|
|
int i;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_data = ahc->scb_data;
|
|
|
|
SLIST_INIT(&scb_data->free_scbs);
|
|
|
|
SLIST_INIT(&scb_data->sg_maps);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Allocate SCB resources */
|
|
|
|
scb_data->scbarray =
|
|
|
|
(struct scb *)malloc(sizeof(struct scb) * AHC_SCB_MAX,
|
2002-01-12 19:03:11 +03:00
|
|
|
M_DEVBUF, M_NOWAIT|M_ZERO);
|
2000-03-15 05:08:28 +03:00
|
|
|
if (scb_data->scbarray == NULL)
|
|
|
|
return (ENOMEM);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Determine the number of hardware SCBs and initialize them */
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_data->maxhscbs = ahc_probe_scbs(ahc);
|
|
|
|
/* SCB 0 heads the free list */
|
|
|
|
ahc_outb(ahc, FREE_SCBH, 0);
|
|
|
|
for (i = 0; i < ahc->scb_data->maxhscbs; i++) {
|
|
|
|
ahc_outb(ahc, SCBPTR, i);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Clear the control byte. */
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, 0);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Set the next pointer */
|
|
|
|
ahc_outb(ahc, SCB_NEXT, i+1);
|
|
|
|
|
|
|
|
/* Make the tag number invalid */
|
|
|
|
ahc_outb(ahc, SCB_TAG, SCB_LIST_NULL);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Make sure that the last SCB terminates the free list */
|
|
|
|
ahc_outb(ahc, SCBPTR, i-1);
|
|
|
|
ahc_outb(ahc, SCB_NEXT, SCB_LIST_NULL);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Ensure we clear the 0 SCB's control byte. */
|
|
|
|
ahc_outb(ahc, SCBPTR, 0);
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, 0);
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_data->maxhscbs = i;
|
1998-11-20 00:43:00 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->scb_data->maxhscbs == 0)
|
|
|
|
panic("%s: No SCB space found", ahc_name(ahc));
|
1998-11-20 00:43:00 +03:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Create our DMA tags. These tags define the kinds of device
|
2001-06-19 16:52:20 +04:00
|
|
|
* accessible memory allocations and memory mappings we will
|
2000-03-15 05:08:28 +03:00
|
|
|
* need to perform during normal operation.
|
|
|
|
*
|
|
|
|
* Unless we need to further restrict the allocation, we rely
|
|
|
|
* on the restrictions of the parent dmat, hence the common
|
|
|
|
* use of MAXADDR and MAXSIZE.
|
1997-02-20 08:15:50 +03:00
|
|
|
*/
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_createdmamem(ahc->parent_dmat,
|
|
|
|
AHC_SCB_MAX * sizeof(struct hardware_scb), ahc->sc_dmaflags,
|
|
|
|
&scb_data->hscb_dmamap,
|
|
|
|
(caddr_t *)&scb_data->hscbs, &scb_data->hscb_busaddr,
|
|
|
|
&scb_data->hscb_seg, &scb_data->hscb_nseg, ahc_name(ahc),
|
|
|
|
"hardware SCB structures") < 0)
|
|
|
|
goto error_exit;
|
|
|
|
|
|
|
|
scb_data->init_level++;
|
|
|
|
|
|
|
|
if (ahc_createdmamem(ahc->parent_dmat,
|
|
|
|
AHC_SCB_MAX * sizeof(struct scsipi_sense_data), ahc->sc_dmaflags,
|
|
|
|
&scb_data->sense_dmamap, (caddr_t *)&scb_data->sense,
|
|
|
|
&scb_data->sense_busaddr, &scb_data->sense_seg,
|
|
|
|
&scb_data->sense_nseg, ahc_name(ahc), "sense buffers") < 0)
|
|
|
|
goto error_exit;
|
|
|
|
|
|
|
|
scb_data->init_level++;
|
|
|
|
|
|
|
|
/* Perform initial CCB allocation */
|
2001-07-07 20:13:44 +04:00
|
|
|
memset(scb_data->hscbs, 0, AHC_SCB_MAX * sizeof(struct hardware_scb));
|
2000-03-15 05:08:28 +03:00
|
|
|
ahcallocscbs(ahc);
|
|
|
|
|
|
|
|
if (scb_data->numscbs == 0) {
|
|
|
|
printf("%s: ahc_init_scb_data - "
|
|
|
|
"Unable to allocate initial scbs\n",
|
|
|
|
ahc_name(ahc));
|
|
|
|
goto error_exit;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_data->init_level++;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/*
|
2003-01-06 15:46:05 +03:00
|
|
|
* Note that we were successful
|
2000-03-15 05:08:28 +03:00
|
|
|
*/
|
2000-06-30 03:12:19 +04:00
|
|
|
return 0;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
error_exit:
|
|
|
|
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahcfiniscbdata(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
struct scb_data *scb_data;
|
|
|
|
|
|
|
|
scb_data = ahc->scb_data;
|
|
|
|
|
|
|
|
switch (scb_data->init_level) {
|
|
|
|
default:
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
struct sg_map_node *sg_map;
|
|
|
|
|
|
|
|
while ((sg_map = SLIST_FIRST(&scb_data->sg_maps))!= NULL) {
|
|
|
|
SLIST_REMOVE_HEAD(&scb_data->sg_maps, links);
|
|
|
|
ahc_freedmamem(ahc->parent_dmat, PAGE_SIZE,
|
|
|
|
sg_map->sg_dmamap, (caddr_t)sg_map->sg_vaddr,
|
|
|
|
&sg_map->sg_dmasegs, sg_map->sg_nseg);
|
|
|
|
free(sg_map, M_DEVBUF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
case 2:
|
|
|
|
ahc_freedmamem(ahc->parent_dmat,
|
|
|
|
AHC_SCB_MAX * sizeof(struct scsipi_sense_data),
|
|
|
|
scb_data->sense_dmamap, (caddr_t)scb_data->sense,
|
|
|
|
&scb_data->sense_seg, scb_data->sense_nseg);
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
case 1:
|
|
|
|
ahc_freedmamem(ahc->parent_dmat,
|
2000-06-30 03:12:19 +04:00
|
|
|
AHC_SCB_MAX * sizeof(struct hardware_scb),
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_data->hscb_dmamap, (caddr_t)scb_data->hscbs,
|
|
|
|
&scb_data->hscb_seg, scb_data->hscb_nseg);
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
}
|
|
|
|
if (scb_data->scbarray != NULL)
|
|
|
|
free(scb_data->scbarray, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ahc_reset(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
u_int sblkctl;
|
|
|
|
int wait;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#ifdef AHC_DUMP_SEQ
|
|
|
|
if (ahc->init_level == 0)
|
|
|
|
ahc_dumpseq(ahc);
|
|
|
|
#endif
|
|
|
|
ahc_outb(ahc, HCNTRL, CHIPRST | ahc->pause);
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Ensure that the reset has finished
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
wait = 1000;
|
|
|
|
do {
|
|
|
|
DELAY(1000);
|
|
|
|
} while (--wait && !(ahc_inb(ahc, HCNTRL) & CHIPRSTACK));
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (wait == 0) {
|
|
|
|
printf("%s: WARNING - Failed chip reset! "
|
|
|
|
"Trying to initialize anyway.\n", ahc_name(ahc));
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, HCNTRL, ahc->pause);
|
|
|
|
|
|
|
|
/* Determine channel configuration */
|
|
|
|
sblkctl = ahc_inb(ahc, SBLKCTL) & (SELBUSB|SELWIDE);
|
|
|
|
/* No Twin Channel PCI cards */
|
|
|
|
if ((ahc->chip & AHC_PCI) != 0)
|
|
|
|
sblkctl &= ~SELBUSB;
|
|
|
|
switch (sblkctl) {
|
|
|
|
case 0:
|
|
|
|
/* Single Narrow Channel */
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* Wide Channel */
|
|
|
|
ahc->features |= AHC_WIDE;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
/* Twin Channel */
|
|
|
|
ahc->features |= AHC_TWIN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" Unsupported adapter type. Ignoring\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Called when we have an active connection to a target on the bus,
|
|
|
|
* this function finds the nearest syncrate to the input period limited
|
|
|
|
* by the capabilities of the bus connectivity of the target.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct ahc_syncrate *
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_devlimited_syncrate(struct ahc_softc *ahc, u_int *period) {
|
|
|
|
u_int maxsync;
|
|
|
|
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0) {
|
|
|
|
if ((ahc_inb(ahc, SBLKCTL) & ENAB40) != 0
|
|
|
|
&& (ahc_inb(ahc, SSTAT2) & EXP_ACTIVE) == 0) {
|
|
|
|
maxsync = AHC_SYNCRATE_ULTRA2;
|
|
|
|
} else {
|
|
|
|
maxsync = AHC_SYNCRATE_ULTRA;
|
|
|
|
}
|
|
|
|
} else if ((ahc->features & AHC_ULTRA) != 0) {
|
|
|
|
maxsync = AHC_SYNCRATE_ULTRA;
|
|
|
|
} else {
|
|
|
|
maxsync = AHC_SYNCRATE_FAST;
|
|
|
|
}
|
|
|
|
return (ahc_find_syncrate(ahc, period, maxsync));
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Look up the valid period to SCSIRATE conversion in our table.
|
|
|
|
* Return the period and offset that should be sent to the target
|
|
|
|
* if this was the beginning of an SDTR.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2001-01-18 23:28:15 +03:00
|
|
|
static const struct ahc_syncrate *
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_find_syncrate(struct ahc_softc *ahc, u_int *period, u_int maxsync)
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *syncrate;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
syncrate = &ahc_syncrates[maxsync];
|
|
|
|
while ((syncrate->rate != NULL)
|
|
|
|
&& ((ahc->features & AHC_ULTRA2) == 0
|
|
|
|
|| (syncrate->sxfr_u2 != 0))) {
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (*period <= syncrate->period) {
|
|
|
|
/*
|
|
|
|
* When responding to a target that requests
|
|
|
|
* sync, the requested rate may fall between
|
|
|
|
* two rates that we can output, but still be
|
|
|
|
* a rate that we can receive. Because of this,
|
|
|
|
* we want to respond to the target with
|
|
|
|
* the same rate that it sent to us even
|
|
|
|
* if the period we use to send data to it
|
|
|
|
* is lower. Only lower the response period
|
|
|
|
* if we must.
|
|
|
|
*/
|
|
|
|
if (syncrate == &ahc_syncrates[maxsync])
|
|
|
|
*period = syncrate->period;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
syncrate++;
|
|
|
|
}
|
1998-04-16 11:12:43 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((*period == 0)
|
|
|
|
|| (syncrate->rate == NULL)
|
|
|
|
|| ((ahc->features & AHC_ULTRA2) != 0
|
|
|
|
&& (syncrate->sxfr_u2 == 0))) {
|
|
|
|
/* Use asynchronous transfers. */
|
|
|
|
*period = 0;
|
|
|
|
syncrate = NULL;
|
1998-04-16 11:12:43 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
return (syncrate);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static u_int
|
|
|
|
ahc_find_period(struct ahc_softc *ahc, u_int scsirate, u_int maxsync)
|
|
|
|
{
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *syncrate;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0)
|
|
|
|
scsirate &= SXFR_ULTRA2;
|
|
|
|
else
|
|
|
|
scsirate &= SXFR;
|
|
|
|
|
|
|
|
syncrate = &ahc_syncrates[maxsync];
|
|
|
|
while (syncrate->rate != NULL) {
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0) {
|
|
|
|
if (syncrate->sxfr_u2 == 0)
|
|
|
|
break;
|
|
|
|
else if (scsirate == (syncrate->sxfr_u2 & SXFR_ULTRA2))
|
|
|
|
return (syncrate->period);
|
|
|
|
} else if (scsirate == (syncrate->sxfr & SXFR)) {
|
|
|
|
return (syncrate->period);
|
|
|
|
}
|
|
|
|
syncrate++;
|
|
|
|
}
|
|
|
|
return (0); /* async */
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
2001-01-18 23:28:15 +03:00
|
|
|
ahc_validate_offset(struct ahc_softc *ahc, const struct ahc_syncrate *syncrate,
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int *offset, int wide)
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int maxoffset;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Limit offset to what we can do */
|
|
|
|
if (syncrate == NULL) {
|
|
|
|
maxoffset = 0;
|
|
|
|
} else if ((ahc->features & AHC_ULTRA2) != 0) {
|
|
|
|
maxoffset = MAX_OFFSET_ULTRA2;
|
|
|
|
} else {
|
|
|
|
if (wide)
|
|
|
|
maxoffset = MAX_OFFSET_16BIT;
|
|
|
|
else
|
|
|
|
maxoffset = MAX_OFFSET_8BIT;
|
|
|
|
}
|
|
|
|
*offset = MIN(*offset, maxoffset);
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_update_target_msg_request(struct ahc_softc *ahc,
|
|
|
|
struct ahc_devinfo *devinfo,
|
|
|
|
struct ahc_initiator_tinfo *tinfo,
|
|
|
|
int force, int paused)
|
|
|
|
{
|
|
|
|
u_int targ_msg_req_orig;
|
|
|
|
|
|
|
|
targ_msg_req_orig = ahc->targ_msg_req;
|
|
|
|
if (tinfo->current.period != tinfo->goal.period
|
|
|
|
|| tinfo->current.width != tinfo->goal.width
|
|
|
|
|| tinfo->current.offset != tinfo->goal.offset
|
|
|
|
|| (force
|
|
|
|
&& (tinfo->goal.period != 0
|
|
|
|
|| tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT))) {
|
|
|
|
ahc->targ_msg_req |= devinfo->target_mask;
|
|
|
|
} else {
|
|
|
|
ahc->targ_msg_req &= ~devinfo->target_mask;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->targ_msg_req != targ_msg_req_orig) {
|
|
|
|
/* Update the message request bit for this target */
|
|
|
|
if ((ahc->features & AHC_HS_MAILBOX) != 0) {
|
|
|
|
if (paused) {
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST,
|
|
|
|
ahc->targ_msg_req & 0xFF);
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST + 1,
|
|
|
|
(ahc->targ_msg_req >> 8) & 0xFF);
|
|
|
|
} else {
|
|
|
|
ahc_outb(ahc, HS_MAILBOX,
|
|
|
|
0x01 << HOST_MAILBOX_SHIFT);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!paused)
|
|
|
|
pause_sequencer(ahc);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST,
|
|
|
|
ahc->targ_msg_req & 0xFF);
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST + 1,
|
|
|
|
(ahc->targ_msg_req >> 8) & 0xFF);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (!paused)
|
|
|
|
unpause_sequencer(ahc);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *syncrate,
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int period, u_int offset, u_int type, int paused, int done)
|
|
|
|
{
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
u_int old_period;
|
|
|
|
u_int old_offset;
|
|
|
|
int active = (type & AHC_TRANS_ACTIVE) == AHC_TRANS_ACTIVE;
|
|
|
|
|
|
|
|
if (syncrate == NULL) {
|
|
|
|
period = 0;
|
|
|
|
offset = 0;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
old_period = tinfo->current.period;
|
|
|
|
old_offset = tinfo->current.offset;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((type & AHC_TRANS_CUR) != 0
|
|
|
|
&& (old_period != period || old_offset != offset)) {
|
|
|
|
u_int scsirate;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scsirate = tinfo->scsirate;
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0) {
|
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
/* Force single edge until DT is fully implemented */
|
|
|
|
scsirate &= ~(SXFR_ULTRA2|SINGLE_EDGE|ENABLE_CRC);
|
|
|
|
if (syncrate != NULL)
|
|
|
|
scsirate |= syncrate->sxfr_u2|SINGLE_EDGE;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (active)
|
|
|
|
ahc_outb(ahc, SCSIOFFSET, offset);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
scsirate &= ~(SXFR|SOFS);
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Ensure Ultra mode is set properly for
|
|
|
|
* this target.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
tstate->ultraenb &= ~devinfo->target_mask;
|
|
|
|
if (syncrate != NULL) {
|
|
|
|
if (syncrate->sxfr & ULTRA_SXFR) {
|
|
|
|
tstate->ultraenb |=
|
|
|
|
devinfo->target_mask;
|
|
|
|
}
|
|
|
|
scsirate |= syncrate->sxfr & SXFR;
|
|
|
|
scsirate |= offset & SOFS;
|
|
|
|
}
|
|
|
|
if (active) {
|
|
|
|
u_int sxfrctl0;
|
|
|
|
|
|
|
|
sxfrctl0 = ahc_inb(ahc, SXFRCTL0);
|
|
|
|
sxfrctl0 &= ~FAST20;
|
|
|
|
if (tstate->ultraenb & devinfo->target_mask)
|
|
|
|
sxfrctl0 |= FAST20;
|
|
|
|
ahc_outb(ahc, SXFRCTL0, sxfrctl0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (active)
|
|
|
|
ahc_outb(ahc, SCSIRATE, scsirate);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
tinfo->scsirate = scsirate;
|
|
|
|
tinfo->current.period = period;
|
|
|
|
tinfo->current.offset = offset;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Update the syncrates in any pending scbs */
|
|
|
|
ahc_update_pending_syncrates(ahc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type & AHC_TRANS_GOAL) != 0) {
|
|
|
|
tinfo->goal.period = period;
|
|
|
|
tinfo->goal.offset = offset;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((type & AHC_TRANS_USER) != 0) {
|
|
|
|
tinfo->user.period = period;
|
|
|
|
tinfo->user.offset = offset;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_update_target_msg_request(ahc, devinfo, tinfo,
|
|
|
|
/*force*/FALSE,
|
|
|
|
paused);
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
|
|
|
|
u_int width, u_int type, int paused, int done)
|
|
|
|
{
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
u_int oldwidth;
|
|
|
|
int active = (type & AHC_TRANS_ACTIVE) == AHC_TRANS_ACTIVE;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
oldwidth = tinfo->current.width;
|
|
|
|
|
|
|
|
if ((type & AHC_TRANS_CUR) != 0 && oldwidth != width) {
|
|
|
|
u_int scsirate;
|
|
|
|
|
|
|
|
scsirate = tinfo->scsirate;
|
|
|
|
scsirate &= ~WIDEXFER;
|
|
|
|
if (width == MSG_EXT_WDTR_BUS_16_BIT)
|
|
|
|
scsirate |= WIDEXFER;
|
|
|
|
|
|
|
|
tinfo->scsirate = scsirate;
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
ahc_outb(ahc, SCSIRATE, scsirate);
|
|
|
|
|
|
|
|
tinfo->current.width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type & AHC_TRANS_GOAL) != 0)
|
|
|
|
tinfo->goal.width = width;
|
|
|
|
if ((type & AHC_TRANS_USER) != 0)
|
|
|
|
tinfo->user.width = width;
|
|
|
|
|
|
|
|
ahc_update_target_msg_request(ahc, devinfo, tinfo,
|
|
|
|
/*force*/FALSE, paused);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_set_tags(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, int enable)
|
|
|
|
{
|
2002-08-31 01:54:10 +04:00
|
|
|
#ifndef AHC_NO_TAGS
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
if (enable) {
|
2000-03-15 05:08:28 +03:00
|
|
|
tstate->tagenable |= devinfo->target_mask;
|
2001-04-25 21:53:04 +04:00
|
|
|
} else {
|
2000-03-15 05:08:28 +03:00
|
|
|
tstate->tagenable &= ~devinfo->target_mask;
|
2000-05-23 01:14:24 +04:00
|
|
|
tstate->tagdisable |= devinfo->target_mask;
|
|
|
|
}
|
2002-08-31 01:54:10 +04:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
2001-04-26 20:56:53 +04:00
|
|
|
static void
|
|
|
|
ahc_update_xfer_mode(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
|
|
|
{
|
|
|
|
struct scsipi_xfer_mode xm;
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
|
|
|
|
if (ahc->inited_targets[devinfo->target] != 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
|
|
|
|
xm.xm_target = devinfo->target;
|
|
|
|
xm.xm_mode = 0;
|
|
|
|
xm.xm_period = tinfo->current.period;
|
|
|
|
xm.xm_offset = tinfo->current.offset;
|
|
|
|
if (tinfo->current.width == 1)
|
|
|
|
xm.xm_mode |= PERIPH_CAP_WIDE16;
|
|
|
|
if (tinfo->current.period)
|
|
|
|
xm.xm_mode |= PERIPH_CAP_SYNC;
|
|
|
|
if (tstate->tagenable & devinfo->target_mask)
|
|
|
|
xm.xm_mode |= PERIPH_CAP_TQING;
|
|
|
|
scsipi_async_event(
|
|
|
|
devinfo->channel == 'B' ? &ahc->sc_channel_b : &ahc->sc_channel,
|
|
|
|
ASYNC_EVENT_XFER_MODE, &xm);
|
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Attach all the sub-devices we can find
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
int
|
|
|
|
ahc_attach(struct ahc_softc *ahc)
|
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc->sc_adapter.adapt_dev = &ahc->sc_dev;
|
|
|
|
ahc->sc_adapter.adapt_nchannels = (ahc->features & AHC_TWIN) ? 2 : 1;
|
2001-04-27 18:49:11 +04:00
|
|
|
if (ahc->flags & AHC_PAGESCBS) {
|
|
|
|
ahc->sc_adapter.adapt_openings = AHC_SCB_MAX;
|
|
|
|
ahc->sc_adapter.adapt_max_periph = 16;
|
|
|
|
} else {
|
|
|
|
ahc->sc_adapter.adapt_openings = ahc->scb_data->maxhscbs;
|
|
|
|
if (ahc->scb_data->maxhscbs >= 16)
|
|
|
|
ahc->sc_adapter.adapt_max_periph = 16;
|
|
|
|
else
|
|
|
|
ahc->sc_adapter.adapt_max_periph = 4;
|
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc->sc_adapter.adapt_ioctl = ahc_ioctl;
|
|
|
|
ahc->sc_adapter.adapt_minphys = ahcminphys;
|
|
|
|
ahc->sc_adapter.adapt_request = ahc_action;
|
|
|
|
|
|
|
|
ahc->sc_channel.chan_adapter = &ahc->sc_adapter;
|
|
|
|
ahc->sc_channel.chan_bustype = &scsi_bustype;
|
|
|
|
ahc->sc_channel.chan_channel = 0;
|
|
|
|
ahc->sc_channel.chan_ntargets = (ahc->features & AHC_WIDE) ? 16 : 8;
|
|
|
|
ahc->sc_channel.chan_nluns = 8;
|
|
|
|
ahc->sc_channel.chan_id = ahc->our_id;
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->features & AHC_TWIN) {
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc->sc_channel_b = ahc->sc_channel;
|
|
|
|
ahc->sc_channel_b.chan_id = ahc->our_id_b;
|
|
|
|
ahc->sc_channel_b.chan_channel = 1;
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((ahc->flags & AHC_CHANNEL_B_PRIMARY) == 0) {
|
2002-01-16 05:11:20 +03:00
|
|
|
ahc->child = config_found((void *)ahc, &ahc->sc_channel, scsiprint);
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->features & AHC_TWIN)
|
2002-01-16 05:11:20 +03:00
|
|
|
ahc->child = config_found((void *)ahc, &ahc->sc_channel_b,
|
2001-04-25 21:53:04 +04:00
|
|
|
scsiprint);
|
2000-03-15 05:08:28 +03:00
|
|
|
} else {
|
2002-01-16 05:11:20 +03:00
|
|
|
ahc->child = config_found((void *)ahc, &ahc->sc_channel_b, scsiprint);
|
|
|
|
ahc->child = config_found((void *)ahc, &ahc->sc_channel, scsiprint);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-01-16 05:11:20 +03:00
|
|
|
int
|
|
|
|
ahc_detach(struct ahc_softc *ahc, int flags)
|
|
|
|
{
|
|
|
|
int rv = 0;
|
|
|
|
|
|
|
|
if (ahc->child != NULL)
|
|
|
|
rv = config_detach(ahc->child, flags);
|
2002-01-16 06:27:37 +03:00
|
|
|
|
|
|
|
ahc_free(ahc);
|
|
|
|
|
2002-01-16 05:11:20 +03:00
|
|
|
return (rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ahc_activate(struct device *self, enum devact act)
|
|
|
|
{
|
|
|
|
struct ahc_softc *ahc = (void *) self;
|
|
|
|
int s, rv = 0;
|
|
|
|
|
|
|
|
s = splhigh();
|
|
|
|
switch (act) {
|
|
|
|
case DVACT_ACTIVATE:
|
|
|
|
rv = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DVACT_DEACTIVATE:
|
|
|
|
if (ahc->child != NULL)
|
|
|
|
rv = config_deactivate(ahc->child);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return (rv);
|
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_fetch_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int saved_tcl;
|
|
|
|
role_t role;
|
|
|
|
int our_id;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_inb(ahc, SSTAT0) & TARGET)
|
|
|
|
role = ROLE_TARGET;
|
|
|
|
else
|
|
|
|
role = ROLE_INITIATOR;
|
|
|
|
|
|
|
|
if (role == ROLE_TARGET
|
|
|
|
&& (ahc->features & AHC_MULTI_TID) != 0
|
|
|
|
&& (ahc_inb(ahc, SEQ_FLAGS) & CMDPHASE_PENDING) != 0) {
|
|
|
|
/* We were selected, so pull our id from TARGIDIN */
|
|
|
|
our_id = ahc_inb(ahc, TARGIDIN) & OID;
|
|
|
|
} else if ((ahc->features & AHC_ULTRA2) != 0)
|
|
|
|
our_id = ahc_inb(ahc, SCSIID_ULTRA2) & OID;
|
|
|
|
else
|
|
|
|
our_id = ahc_inb(ahc, SCSIID) & OID;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
saved_tcl = ahc_inb(ahc, SAVED_TCL);
|
|
|
|
ahc_compile_devinfo(devinfo, our_id, TCL_TARGET(saved_tcl),
|
|
|
|
TCL_LUN(saved_tcl), TCL_CHANNEL(ahc, saved_tcl),
|
|
|
|
role);
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_compile_devinfo(struct ahc_devinfo *devinfo, u_int our_id, u_int target,
|
|
|
|
u_int lun, char channel, role_t role)
|
|
|
|
{
|
|
|
|
devinfo->our_scsiid = our_id;
|
|
|
|
devinfo->target = target;
|
|
|
|
devinfo->lun = lun;
|
|
|
|
devinfo->target_offset = target;
|
|
|
|
devinfo->channel = channel;
|
|
|
|
devinfo->role = role;
|
|
|
|
if (channel == 'B')
|
|
|
|
devinfo->target_offset += 8;
|
|
|
|
devinfo->target_mask = (0x01 << devinfo->target_offset);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1996-05-16 07:59:03 +04:00
|
|
|
* Catch an interrupt from the adapter
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
|
|
|
int
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_intr(void *arg)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_softc *ahc;
|
|
|
|
u_int intstat;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-06-30 03:12:19 +04:00
|
|
|
ahc = (struct ahc_softc *)arg;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
intstat = ahc_inb(ahc, INTSTAT);
|
2000-02-03 09:25:09 +03:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Any interrupts to process?
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((intstat & INT_PEND) == 0) {
|
2000-03-16 13:33:45 +03:00
|
|
|
if (ahc->bus_intr && ahc->bus_intr(ahc)) {
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
printf("%s: bus intr: CCHADDR %x HADDR %x SEQADDR %x\n",
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_name(ahc),
|
|
|
|
ahc_inb(ahc, CCHADDR) |
|
|
|
|
(ahc_inb(ahc, CCHADDR+1) << 8)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+2) << 16)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+3) << 24),
|
|
|
|
ahc_inb(ahc, HADDR) | (ahc_inb(ahc, HADDR+1) << 8)
|
|
|
|
| (ahc_inb(ahc, HADDR+2) << 16)
|
|
|
|
| (ahc_inb(ahc, HADDR+3) << 24),
|
|
|
|
ahc_inb(ahc, SEQADDR0) |
|
|
|
|
(ahc_inb(ahc, SEQADDR1) << 8));
|
1996-05-16 07:59:03 +04:00
|
|
|
#endif
|
2000-03-15 05:08:28 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWINTR) {
|
|
|
|
printf("%s: intstat %x\n", ahc_name(ahc), intstat);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (intstat & CMDCMPLT) {
|
|
|
|
ahc_outb(ahc, CLRINT, CLRCMDINT);
|
|
|
|
ahc_run_qoutfifo(ahc);
|
|
|
|
}
|
|
|
|
if (intstat & BRKADRINT) {
|
|
|
|
/*
|
|
|
|
* We upset the sequencer :-(
|
|
|
|
* Lookup the error message
|
|
|
|
*/
|
2002-05-31 21:31:15 +04:00
|
|
|
int i, error;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
error = ahc_inb(ahc, ERROR);
|
|
|
|
for (i = 0; error != 1 && i < num_errors; i++)
|
1995-10-09 12:49:30 +03:00
|
|
|
error >>= 1;
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("%s: brkadrint, %s at seqaddr = 0x%x",
|
1996-05-16 07:59:03 +04:00
|
|
|
ahc_name(ahc), hard_error[i].errmesg,
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_inb(ahc, SEQADDR0) |
|
|
|
|
(ahc_inb(ahc, SEQADDR1) << 8));
|
|
|
|
|
2001-07-05 00:34:03 +04:00
|
|
|
/* Tell everyone that this HBA is no longer available */
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_abort_scbs(ahc, AHC_TARGET_WILDCARD, ALL_CHANNELS,
|
|
|
|
AHC_LUN_WILDCARD, SCB_LIST_NULL, ROLE_UNKNOWN,
|
|
|
|
XS_DRIVER_STUFFUP);
|
|
|
|
}
|
|
|
|
if (intstat & SEQINT)
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
ahc_handle_seqint(ahc, intstat);
|
1996-07-11 02:50:44 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (intstat & SCSIINT)
|
|
|
|
ahc_handle_scsiint(ahc, intstat);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct tmode_tstate *
|
|
|
|
ahc_alloc_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel)
|
|
|
|
{
|
|
|
|
struct tmode_tstate *master_tstate;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
int i, s;
|
|
|
|
|
|
|
|
master_tstate = ahc->enabled_targets[ahc->our_id];
|
|
|
|
if (channel == 'B') {
|
|
|
|
scsi_id += 8;
|
|
|
|
master_tstate = ahc->enabled_targets[ahc->our_id_b + 8];
|
|
|
|
}
|
|
|
|
if (ahc->enabled_targets[scsi_id] != NULL
|
|
|
|
&& ahc->enabled_targets[scsi_id] != master_tstate)
|
|
|
|
panic("%s: ahc_alloc_tstate - Target already allocated",
|
|
|
|
ahc_name(ahc));
|
|
|
|
tstate = malloc(sizeof(*tstate), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (tstate == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have allocated a master tstate, copy user settings from
|
|
|
|
* the master tstate (taken from SRAM or the EEPROM) for this
|
|
|
|
* channel, but reset our current and goal settings to async/narrow
|
|
|
|
* until an initiator talks to us.
|
|
|
|
*/
|
|
|
|
if (master_tstate != NULL) {
|
2001-07-07 19:53:13 +04:00
|
|
|
memcpy(tstate, master_tstate, sizeof(*tstate));
|
2000-03-15 05:08:28 +03:00
|
|
|
tstate->ultraenb = 0;
|
|
|
|
for (i = 0; i < 16; i++) {
|
2001-07-07 20:13:44 +04:00
|
|
|
memset(&tstate->transinfo[i].current, 0,
|
2000-03-15 05:08:28 +03:00
|
|
|
sizeof(tstate->transinfo[i].current));
|
2001-07-07 20:13:44 +04:00
|
|
|
memset(&tstate->transinfo[i].goal, 0,
|
2000-03-15 05:08:28 +03:00
|
|
|
sizeof(tstate->transinfo[i].goal));
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
} else
|
2001-07-07 20:13:44 +04:00
|
|
|
memset(tstate, 0, sizeof(*tstate));
|
2000-03-15 05:08:28 +03:00
|
|
|
s = splbio();
|
|
|
|
ahc->enabled_targets[scsi_id] = tstate;
|
|
|
|
splx(s);
|
|
|
|
return (tstate);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if UNUSED
|
|
|
|
static void
|
|
|
|
ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force)
|
|
|
|
{
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
|
|
|
|
/* Don't clean up the entry for our initiator role */
|
|
|
|
if ((ahc->flags & AHC_INITIATORMODE) != 0
|
|
|
|
&& ((channel == 'B' && scsi_id == ahc->our_id_b)
|
|
|
|
|| (channel == 'A' && scsi_id == ahc->our_id))
|
|
|
|
&& force == FALSE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (channel == 'B')
|
|
|
|
scsi_id += 8;
|
|
|
|
tstate = ahc->enabled_targets[scsi_id];
|
|
|
|
if (tstate != NULL)
|
|
|
|
free(tstate, M_DEVBUF);
|
|
|
|
ahc->enabled_targets[scsi_id] = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat)
|
|
|
|
{
|
|
|
|
struct scb *scb;
|
|
|
|
struct ahc_devinfo devinfo;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_fetch_devinfo(ahc, &devinfo);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear the upper byte that holds SEQINT status
|
|
|
|
* codes and clear the SEQINT bit. We will unpause
|
|
|
|
* the sequencer, if appropriate, after servicing
|
|
|
|
* the request.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, CLRINT, CLRSEQINT);
|
|
|
|
switch (intstat & SEQINT_MASK) {
|
|
|
|
case NO_MATCH:
|
|
|
|
{
|
|
|
|
/* Ensure we don't leave the selection hardware on */
|
|
|
|
ahc_outb(ahc, SCSISEQ,
|
|
|
|
ahc_inb(ahc, SCSISEQ) & (ENSELI|ENRSELI|ENAUTOATNP));
|
|
|
|
|
|
|
|
printf("%s:%c:%d: no active SCB for reconnecting "
|
|
|
|
"target - issuing BUS DEVICE RESET\n",
|
|
|
|
ahc_name(ahc), devinfo.channel, devinfo.target);
|
|
|
|
printf("SAVED_TCL == 0x%x, ARG_1 == 0x%x, SEQ_FLAGS == 0x%x\n",
|
|
|
|
ahc_inb(ahc, SAVED_TCL), ahc_inb(ahc, ARG_1),
|
|
|
|
ahc_inb(ahc, SEQ_FLAGS));
|
|
|
|
ahc->msgout_buf[0] = MSG_BUS_DEV_RESET;
|
|
|
|
ahc->msgout_len = 1;
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
|
|
|
|
ahc_outb(ahc, MSG_OUT, HOST_MSG);
|
|
|
|
ahc_outb(ahc, SCSISIGO, ahc_inb(ahc, LASTPHASE) | ATNO);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UPDATE_TMSG_REQ:
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST, ahc->targ_msg_req & 0xFF);
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST + 1,
|
|
|
|
(ahc->targ_msg_req >> 8) & 0xFF);
|
|
|
|
ahc_outb(ahc, HS_MAILBOX, 0);
|
|
|
|
break;
|
2000-06-30 03:12:19 +04:00
|
|
|
case SEND_REJECT:
|
2000-03-15 05:08:28 +03:00
|
|
|
{
|
|
|
|
u_int rejbyte = ahc_inb(ahc, ACCUM);
|
|
|
|
printf("%s:%c:%d: Warning - unknown message received from "
|
2000-06-30 03:12:19 +04:00
|
|
|
"target (0x%x). Rejecting\n",
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_name(ahc), devinfo.channel, devinfo.target, rejbyte);
|
2000-06-30 03:12:19 +04:00
|
|
|
break;
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
2000-06-30 03:12:19 +04:00
|
|
|
case NO_IDENT:
|
2000-03-15 05:08:28 +03:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The reconnecting target either did not send an identify
|
|
|
|
* message, or did, but we didn't find and SCB to match and
|
|
|
|
* before it could respond to our ATN/abort, it hit a dataphase.
|
|
|
|
* The only safe thing to do is to blow it away with a bus
|
|
|
|
* reset.
|
|
|
|
*/
|
|
|
|
int found;
|
|
|
|
|
|
|
|
printf("%s:%c:%d: Target did not send an IDENTIFY message. "
|
|
|
|
"LASTPHASE = 0x%x, SAVED_TCL == 0x%x\n",
|
|
|
|
ahc_name(ahc), devinfo.channel, devinfo.target,
|
|
|
|
ahc_inb(ahc, LASTPHASE), ahc_inb(ahc, SAVED_TCL));
|
2000-06-30 03:12:19 +04:00
|
|
|
found = ahc_reset_channel(ahc, devinfo.channel,
|
2000-03-15 05:08:28 +03:00
|
|
|
/*initiate reset*/TRUE);
|
|
|
|
printf("%s: Issued Channel %c Bus Reset. "
|
|
|
|
"%d SCBs aborted\n", ahc_name(ahc), devinfo.channel,
|
|
|
|
found);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case BAD_PHASE:
|
|
|
|
{
|
|
|
|
u_int lastphase;
|
|
|
|
|
|
|
|
lastphase = ahc_inb(ahc, LASTPHASE);
|
|
|
|
if (lastphase == P_BUSFREE) {
|
|
|
|
printf("%s:%c:%d: Missed busfree. Curphase = 0x%x\n",
|
|
|
|
ahc_name(ahc), devinfo.channel, devinfo.target,
|
|
|
|
ahc_inb(ahc, SCSISIGI));
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
printf("%s:%c:%d: unknown scsi bus phase %x. "
|
|
|
|
"Attempting to continue\n",
|
|
|
|
ahc_name(ahc), devinfo.channel, devinfo.target,
|
|
|
|
ahc_inb(ahc, SCSISIGI));
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-06-30 03:12:19 +04:00
|
|
|
break;
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
case BAD_STATUS:
|
|
|
|
{
|
|
|
|
u_int scb_index;
|
|
|
|
struct hardware_scb *hscb;
|
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
/*
|
|
|
|
* The sequencer will notify us when a command
|
|
|
|
* has an error that would be of interest to
|
|
|
|
* the kernel. This allows us to leave the sequencer
|
|
|
|
* running in the common case of command completes
|
|
|
|
* without error. The sequencer will already have
|
|
|
|
* dma'd the SCB back up to us, so we can reference
|
|
|
|
* the in kernel copy directly.
|
|
|
|
*/
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
|
|
|
|
/* ahc_print_scb(scb); */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the default return value to 0 (don't
|
|
|
|
* send sense). The sense code will change
|
|
|
|
* this if needed.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, RETURN_1, 0);
|
|
|
|
if (!(scb_index < ahc->scb_data->numscbs
|
|
|
|
&& (scb->flags & SCB_ACTIVE) != 0)) {
|
|
|
|
printf("%s:%c:%d: ahc_intr - referenced scb "
|
|
|
|
"not valid during seqint 0x%x scb(%d)\n",
|
|
|
|
ahc_name(ahc), devinfo.channel,
|
|
|
|
devinfo.target, intstat, scb_index);
|
|
|
|
goto unpause;
|
|
|
|
}
|
|
|
|
|
2000-06-30 03:12:19 +04:00
|
|
|
hscb = scb->hscb;
|
2000-03-15 05:08:28 +03:00
|
|
|
xs = scb->xs;
|
|
|
|
|
|
|
|
/* Don't want to clobber the original sense code */
|
|
|
|
if ((scb->flags & SCB_SENSE) != 0) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Clear the SCB_SENSE Flag and have
|
|
|
|
* the sequencer do a normal command
|
|
|
|
* complete.
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->flags &= ~SCB_SENSE;
|
|
|
|
ahcsetccbstatus(xs, XS_DRIVER_STUFFUP);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Freeze the queue unit the client sees the error. */
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_freeze_devq(ahc, xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_freeze_ccb(scb);
|
|
|
|
xs->status = hscb->status;
|
|
|
|
switch (hscb->status) {
|
|
|
|
case SCSI_STATUS_OK:
|
|
|
|
printf("%s: Interrupted for status of 0???\n",
|
|
|
|
ahc_name(ahc));
|
|
|
|
break;
|
|
|
|
case SCSI_STATUS_CMD_TERMINATED:
|
|
|
|
case SCSI_STATUS_CHECK_COND:
|
|
|
|
#if defined(AHC_DEBUG)
|
|
|
|
if (ahc_debug & AHC_SHOWSENSE) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Check Status, resid %d datalen %d\n",
|
|
|
|
xs->resid, xs->datalen);
|
|
|
|
}
|
|
|
|
#endif
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (xs->error == XS_NOERROR &&
|
|
|
|
!(scb->flags & SCB_SENSE)) {
|
|
|
|
struct ahc_dma_seg *sg;
|
|
|
|
struct scsipi_sense *sc;
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
sg = scb->sg_list;
|
2000-06-30 03:12:19 +04:00
|
|
|
sc = (struct scsipi_sense *)(&hscb->cmdstore);
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Save off the residual if there is one.
|
|
|
|
*/
|
|
|
|
if (hscb->residual_SG_count != 0)
|
|
|
|
ahc_calc_residual(scb);
|
|
|
|
else
|
|
|
|
xs->resid = 0;
|
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWSENSE) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Sending Sense\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
sg->addr = ahc->scb_data->sense_busaddr +
|
|
|
|
(hscb->tag*sizeof(struct scsipi_sense_data));
|
|
|
|
sg->len = sizeof (struct scsipi_sense_data);
|
|
|
|
|
|
|
|
sc->opcode = REQUEST_SENSE;
|
|
|
|
sc->byte2 = SCB_LUN(scb) << 5;
|
|
|
|
sc->unused[0] = 0;
|
|
|
|
sc->unused[1] = 0;
|
|
|
|
sc->length = sg->len;
|
|
|
|
sc->control = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Would be nice to preserve DISCENB here,
|
|
|
|
* but due to the way we page SCBs, we can't.
|
|
|
|
*/
|
|
|
|
hscb->control = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This request sense could be because the
|
|
|
|
* the device lost power or in some other
|
|
|
|
* way has lost our transfer negotiations.
|
|
|
|
* Renegotiate if appropriate. Unit attention
|
|
|
|
* errors will be reported before any data
|
|
|
|
* phases occur.
|
|
|
|
*/
|
|
|
|
ahc_calc_residual(scb);
|
|
|
|
#if defined(AHC_DEBUG)
|
|
|
|
if (ahc_debug & AHC_SHOWSENSE) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Sense: datalen %d resid %d"
|
|
|
|
"chan %d id %d targ %d\n",
|
|
|
|
xs->datalen, xs->resid,
|
|
|
|
devinfo.channel, devinfo.our_scsiid,
|
|
|
|
devinfo.target);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (xs->datalen > 0 &&
|
|
|
|
xs->resid == xs->datalen) {
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc,
|
|
|
|
devinfo.channel,
|
|
|
|
devinfo.our_scsiid,
|
|
|
|
devinfo.target,
|
|
|
|
&tstate);
|
|
|
|
ahc_update_target_msg_request(ahc,
|
|
|
|
&devinfo,
|
|
|
|
tinfo,
|
|
|
|
/*force*/TRUE,
|
|
|
|
/*paused*/TRUE);
|
|
|
|
}
|
|
|
|
hscb->status = 0;
|
|
|
|
hscb->SG_count = 1;
|
|
|
|
hscb->SG_pointer = scb->sg_list_phys;
|
2000-06-30 03:12:19 +04:00
|
|
|
hscb->data = sg->addr;
|
2000-03-15 05:08:28 +03:00
|
|
|
hscb->datalen = sg->len;
|
|
|
|
hscb->cmdpointer = hscb->cmdstore_busaddr;
|
|
|
|
hscb->cmdlen = sizeof(*sc);
|
|
|
|
scb->sg_count = hscb->SG_count;
|
|
|
|
ahc_swap_hscb(hscb);
|
|
|
|
ahc_swap_sg(scb->sg_list);
|
|
|
|
scb->flags |= SCB_SENSE;
|
|
|
|
/*
|
|
|
|
* Ensure the target is busy since this
|
|
|
|
* will be an untagged request.
|
|
|
|
*/
|
|
|
|
ahc_busy_tcl(ahc, scb);
|
|
|
|
ahc_outb(ahc, RETURN_1, SEND_SENSE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure we have enough time to actually
|
|
|
|
* retrieve the sense.
|
|
|
|
*/
|
|
|
|
if (!(scb->xs->xs_control & XS_CTL_POLL)) {
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&scb->xs->xs_callout,
|
|
|
|
5 * hz, ahc_timeout, scb);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SCSI_STATUS_QUEUE_FULL:
|
2000-05-23 01:14:24 +04:00
|
|
|
case SCSI_STATUS_BUSY:
|
2000-05-28 04:19:59 +04:00
|
|
|
xs->error = XS_BUSY;
|
2000-03-15 05:08:28 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TRACE_POINT:
|
|
|
|
{
|
|
|
|
printf("SSTAT2 = 0x%x DFCNTRL = 0x%x\n", ahc_inb(ahc, SSTAT2),
|
|
|
|
ahc_inb(ahc, DFCNTRL));
|
|
|
|
printf("SSTAT3 = 0x%x DSTATUS = 0x%x\n", ahc_inb(ahc, SSTAT3),
|
|
|
|
ahc_inb(ahc, DFSTATUS));
|
|
|
|
printf("SSTAT0 = 0x%x, SCB_DATACNT = 0x%x\n",
|
|
|
|
ahc_inb(ahc, SSTAT0),
|
|
|
|
ahc_inb(ahc, SCB_DATACNT));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case HOST_MSG_LOOP:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The sequencer has encountered a message phase
|
|
|
|
* that requires host assistance for completion.
|
|
|
|
* While handling the message phase(s), we will be
|
|
|
|
* notified by the sequencer after each byte is
|
2001-07-08 22:06:42 +04:00
|
|
|
* transferred so we can track bus phases.
|
2000-03-15 05:08:28 +03:00
|
|
|
*
|
|
|
|
* If this is the first time we've seen a HOST_MSG_LOOP,
|
|
|
|
* initialize the state of the host message loop.
|
|
|
|
*/
|
|
|
|
if (ahc->msg_type == MSG_TYPE_NONE) {
|
|
|
|
u_int bus_phase;
|
|
|
|
|
|
|
|
bus_phase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK;
|
|
|
|
if (bus_phase != P_MESGIN
|
|
|
|
&& bus_phase != P_MESGOUT) {
|
|
|
|
printf("ahc_intr: HOST_MSG_LOOP bad "
|
|
|
|
"phase 0x%x\n",
|
|
|
|
bus_phase);
|
|
|
|
/*
|
|
|
|
* Probably transitioned to bus free before
|
|
|
|
* we got here. Just punt the message.
|
|
|
|
*/
|
|
|
|
ahc_clear_intstat(ahc);
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (devinfo.role == ROLE_INITIATOR) {
|
|
|
|
struct scb *scb;
|
|
|
|
u_int scb_index;
|
|
|
|
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
|
|
|
|
if (bus_phase == P_MESGOUT)
|
|
|
|
ahc_setup_initiator_msgout(ahc,
|
|
|
|
&devinfo,
|
|
|
|
scb);
|
|
|
|
else {
|
|
|
|
ahc->msg_type =
|
|
|
|
MSG_TYPE_INITIATOR_MSGIN;
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bus_phase == P_MESGOUT) {
|
|
|
|
ahc->msg_type =
|
|
|
|
MSG_TYPE_TARGET_MSGOUT;
|
|
|
|
ahc->msgin_index = 0;
|
2000-06-30 03:12:19 +04:00
|
|
|
} else
|
2000-03-15 05:08:28 +03:00
|
|
|
/* XXX Ever executed??? */
|
|
|
|
ahc_setup_target_msgin(ahc, &devinfo);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Pass a NULL path so that handlers generate their own */
|
|
|
|
ahc_handle_message_phase(ahc, /*path*/NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PERR_DETECTED:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we've cleared the parity error interrupt
|
|
|
|
* but the sequencer still believes that SCSIPERR
|
|
|
|
* is true, it must be that the parity error is
|
|
|
|
* for the currently presented byte on the bus,
|
|
|
|
* and we are not in a phase (data-in) where we will
|
|
|
|
* eventually ack this byte. Ack the byte and
|
|
|
|
* throw it away in the hope that the target will
|
|
|
|
* take us to message out to deliver the appropriate
|
|
|
|
* error message.
|
|
|
|
*/
|
|
|
|
if ((intstat & SCSIINT) == 0
|
|
|
|
&& (ahc_inb(ahc, SSTAT1) & SCSIPERR) != 0) {
|
|
|
|
u_int curphase;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* The hardware will only let you ack bytes
|
|
|
|
* if the expected phase in SCSISIGO matches
|
|
|
|
* the current phase. Make sure this is
|
|
|
|
* currently the case.
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK;
|
|
|
|
ahc_outb(ahc, LASTPHASE, curphase);
|
|
|
|
ahc_outb(ahc, SCSISIGO, curphase);
|
|
|
|
ahc_inb(ahc, SCSIDATL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DATA_OVERRUN:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* When the sequencer detects an overrun, it
|
|
|
|
* places the controller in "BITBUCKET" mode
|
|
|
|
* and allows the target to complete its transfer.
|
|
|
|
* Unfortunately, none of the counters get updated
|
|
|
|
* when the controller is in this mode, so we have
|
|
|
|
* no way of knowing how large the overrun was.
|
|
|
|
*/
|
|
|
|
u_int scbindex = ahc_inb(ahc, SCB_TAG);
|
|
|
|
u_int lastphase = ahc_inb(ahc, LASTPHASE);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
scb = &ahc->scb_data->scbarray[scbindex];
|
|
|
|
for (i = 0; i < num_phases; i++) {
|
|
|
|
if (lastphase == phase_table[i].phase)
|
|
|
|
break;
|
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("data overrun detected %s."
|
|
|
|
" Tag == 0x%x.\n",
|
|
|
|
phase_table[i].phasemsg,
|
|
|
|
scb->hscb->tag);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("%s seen Data Phase. Length = %d. NumSGs = %d.\n",
|
|
|
|
ahc_inb(ahc, SEQ_FLAGS) & DPHASE ? "Have" : "Haven't",
|
|
|
|
scb->xs->datalen, scb->sg_count);
|
|
|
|
if (scb->sg_count > 0) {
|
|
|
|
for (i = 0; i < scb->sg_count; i++) {
|
|
|
|
printf("sg[%d] - Addr 0x%x : Length %d\n",
|
|
|
|
i,
|
|
|
|
le32toh(scb->sg_list[i].addr),
|
|
|
|
le32toh(scb->sg_list[i].len));
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Set this and it will take affect when the
|
|
|
|
* target does a command complete.
|
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_freeze_devq(ahc, scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
ahcsetccbstatus(scb->xs, XS_DRIVER_STUFFUP);
|
|
|
|
ahc_freeze_ccb(scb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TRACEPOINT:
|
|
|
|
{
|
|
|
|
printf("TRACEPOINT: RETURN_1 = %d\n", ahc_inb(ahc, RETURN_1));
|
|
|
|
printf("TRACEPOINT: RETURN_2 = %d\n", ahc_inb(ahc, RETURN_2));
|
|
|
|
printf("TRACEPOINT: ARG_1 = %d\n", ahc_inb(ahc, ARG_1));
|
|
|
|
printf("TRACEPOINT: ARG_2 = %d\n", ahc_inb(ahc, ARG_2));
|
|
|
|
printf("TRACEPOINT: CCHADDR = %x\n",
|
|
|
|
ahc_inb(ahc, CCHADDR) | (ahc_inb(ahc, CCHADDR+1) << 8)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+2) << 16)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+3) << 24));
|
|
|
|
#if 0
|
|
|
|
printf("SSTAT1 == 0x%x\n", ahc_inb(ahc, SSTAT1));
|
|
|
|
printf("SSTAT0 == 0x%x\n", ahc_inb(ahc, SSTAT0));
|
|
|
|
printf(", SCSISIGI == 0x%x\n", ahc_inb(ahc, SCSISIGI));
|
|
|
|
printf("TRACEPOINT: CCHCNT = %d, SG_COUNT = %d\n",
|
|
|
|
ahc_inb(ahc, CCHCNT), ahc_inb(ahc, SG_COUNT));
|
|
|
|
printf("TRACEPOINT: SCB_TAG = %d\n", ahc_inb(ahc, SCB_TAG));
|
|
|
|
printf("TRACEPOINT1: CCHADDR = %d, CCHCNT = %d, SCBPTR = %d\n",
|
|
|
|
ahc_inb(ahc, CCHADDR)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+1) << 8)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+2) << 16)
|
|
|
|
| (ahc_inb(ahc, CCHADDR+3) << 24),
|
|
|
|
ahc_inb(ahc, CCHCNT)
|
|
|
|
| (ahc_inb(ahc, CCHCNT+1) << 8)
|
|
|
|
| (ahc_inb(ahc, CCHCNT+2) << 16),
|
|
|
|
ahc_inb(ahc, SCBPTR));
|
|
|
|
printf("TRACEPOINT: WAITING_SCBH = %d\n", ahc_inb(ahc, WAITING_SCBH));
|
|
|
|
printf("TRACEPOINT: SCB_TAG = %d\n", ahc_inb(ahc, SCB_TAG));
|
2001-11-28 08:45:27 +03:00
|
|
|
#ifdef DDB
|
2000-03-15 05:08:28 +03:00
|
|
|
cpu_Debugger();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#if NOT_YET
|
|
|
|
/* XXX Fill these in later */
|
|
|
|
case MESG_BUFFER_BUSY:
|
|
|
|
break;
|
|
|
|
case MSGIN_PHASEMIS:
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
printf("ahc_intr: seqint, "
|
|
|
|
"intstat == 0x%x, scsisigi = 0x%x\n",
|
|
|
|
intstat, ahc_inb(ahc, SCSISIGI));
|
|
|
|
break;
|
|
|
|
}
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
unpause:
|
|
|
|
/*
|
|
|
|
* The sequencer is paused immediately on
|
|
|
|
* a SEQINT, so we should restart it when
|
|
|
|
* we're done.
|
|
|
|
*/
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat)
|
|
|
|
{
|
|
|
|
u_int scb_index;
|
|
|
|
u_int status;
|
|
|
|
struct scb *scb;
|
|
|
|
char cur_channel;
|
|
|
|
char intr_channel;
|
|
|
|
|
|
|
|
if ((ahc->features & AHC_TWIN) != 0
|
|
|
|
&& ((ahc_inb(ahc, SBLKCTL) & SELBUSB) != 0))
|
|
|
|
cur_channel = 'B';
|
|
|
|
else
|
|
|
|
cur_channel = 'A';
|
|
|
|
intr_channel = cur_channel;
|
|
|
|
|
|
|
|
status = ahc_inb(ahc, SSTAT1);
|
|
|
|
if (status == 0) {
|
|
|
|
if ((ahc->features & AHC_TWIN) != 0) {
|
|
|
|
/* Try the other channel */
|
|
|
|
ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) ^ SELBUSB);
|
|
|
|
status = ahc_inb(ahc, SSTAT1);
|
|
|
|
ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) ^ SELBUSB);
|
|
|
|
intr_channel = (cur_channel == 'A') ? 'B' : 'A';
|
|
|
|
}
|
|
|
|
if (status == 0) {
|
|
|
|
printf("%s: Spurious SCSI interrupt\n", ahc_name(ahc));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
if (scb_index < ahc->scb_data->numscbs) {
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
if ((scb->flags & SCB_ACTIVE) == 0
|
|
|
|
|| (ahc_inb(ahc, SEQ_FLAGS) & IDENTIFY_SEEN) == 0)
|
|
|
|
scb = NULL;
|
|
|
|
} else
|
|
|
|
scb = NULL;
|
|
|
|
|
|
|
|
if ((status & SCSIRSTI) != 0) {
|
|
|
|
printf("%s: Someone reset channel %c\n",
|
|
|
|
ahc_name(ahc), intr_channel);
|
|
|
|
ahc_reset_channel(ahc, intr_channel, /* Initiate Reset */FALSE);
|
|
|
|
} else if ((status & SCSIPERR) != 0) {
|
|
|
|
/*
|
|
|
|
* Determine the bus phase and queue an appropriate message.
|
|
|
|
* SCSIPERR is latched true as soon as a parity error
|
|
|
|
* occurs. If the sequencer acked the transfer that
|
|
|
|
* caused the parity error and the currently presented
|
|
|
|
* transfer on the bus has correct parity, SCSIPERR will
|
|
|
|
* be cleared by CLRSCSIPERR. Use this to determine if
|
|
|
|
* we should look at the last phase the sequencer recorded,
|
|
|
|
* or the current phase presented on the bus.
|
|
|
|
*/
|
|
|
|
u_int mesg_out;
|
|
|
|
u_int curphase;
|
|
|
|
u_int errorphase;
|
|
|
|
u_int lastphase;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
lastphase = ahc_inb(ahc, LASTPHASE);
|
|
|
|
curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK;
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRSCSIPERR);
|
|
|
|
/*
|
|
|
|
* For all phases save DATA, the sequencer won't
|
|
|
|
* automatically ack a byte that has a parity error
|
|
|
|
* in it. So the only way that the current phase
|
|
|
|
* could be 'data-in' is if the parity error is for
|
|
|
|
* an already acked byte in the data phase. During
|
|
|
|
* synchronous data-in transfers, we may actually
|
|
|
|
* ack bytes before latching the current phase in
|
|
|
|
* LASTPHASE, leading to the discrepancy between
|
|
|
|
* curphase and lastphase.
|
|
|
|
*/
|
|
|
|
if ((ahc_inb(ahc, SSTAT1) & SCSIPERR) != 0
|
|
|
|
|| curphase == P_DATAIN)
|
|
|
|
errorphase = curphase;
|
|
|
|
else
|
|
|
|
errorphase = lastphase;
|
|
|
|
|
|
|
|
for (i = 0; i < num_phases; i++) {
|
|
|
|
if (errorphase == phase_table[i].phase)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mesg_out = phase_table[i].mesg_out;
|
|
|
|
if (scb != NULL)
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
else
|
|
|
|
printf("%s:%c:%d: ", ahc_name(ahc),
|
|
|
|
intr_channel,
|
|
|
|
TCL_TARGET(ahc_inb(ahc, SAVED_TCL)));
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("parity error detected %s. "
|
|
|
|
"SEQADDR(0x%x) SCSIRATE(0x%x)\n",
|
|
|
|
phase_table[i].phasemsg,
|
|
|
|
ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8),
|
|
|
|
ahc_inb(ahc, SCSIRATE));
|
|
|
|
|
|
|
|
/*
|
2000-06-30 03:12:19 +04:00
|
|
|
* We've set the hardware to assert ATN if we
|
|
|
|
* get a parity error on "in" phases, so all we
|
2000-03-15 05:08:28 +03:00
|
|
|
* need to do is stuff the message buffer with
|
|
|
|
* the appropriate message. "In" phases have set
|
|
|
|
* mesg_out to something other than MSG_NOP.
|
|
|
|
*/
|
|
|
|
if (mesg_out != MSG_NOOP) {
|
|
|
|
if (ahc->msg_type != MSG_TYPE_NONE)
|
|
|
|
ahc->send_msg_perror = TRUE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
else
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, MSG_OUT, mesg_out);
|
|
|
|
}
|
|
|
|
ahc_outb(ahc, CLRINT, CLRSCSIINT);
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
} else if ((status & BUSFREE) != 0
|
|
|
|
&& (ahc_inb(ahc, SIMODE1) & ENBUSFREE) != 0) {
|
|
|
|
/*
|
|
|
|
* First look at what phase we were last in.
|
|
|
|
* If its message out, chances are pretty good
|
|
|
|
* that the busfree was in response to one of
|
|
|
|
* our abort requests.
|
|
|
|
*/
|
|
|
|
u_int lastphase = ahc_inb(ahc, LASTPHASE);
|
|
|
|
u_int saved_tcl = ahc_inb(ahc, SAVED_TCL);
|
|
|
|
u_int target = TCL_TARGET(saved_tcl);
|
|
|
|
u_int initiator_role_id = TCL_SCSI_ID(ahc, saved_tcl);
|
|
|
|
char channel = TCL_CHANNEL(ahc, saved_tcl);
|
|
|
|
int printerror = 1;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCSISEQ,
|
|
|
|
ahc_inb(ahc, SCSISEQ) & (ENSELI|ENRSELI|ENAUTOATNP));
|
|
|
|
if (lastphase == P_MESGOUT) {
|
|
|
|
u_int message;
|
|
|
|
u_int tag;
|
|
|
|
|
|
|
|
message = ahc->msgout_buf[ahc->msgout_index - 1];
|
|
|
|
tag = SCB_LIST_NULL;
|
|
|
|
switch (message) {
|
|
|
|
case MSG_ABORT_TAG:
|
|
|
|
tag = scb->hscb->tag;
|
|
|
|
/* FALLTRHOUGH */
|
|
|
|
case MSG_ABORT:
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("SCB %x - Abort %s Completed.\n",
|
|
|
|
scb->hscb->tag, tag == SCB_LIST_NULL ?
|
|
|
|
"" : "Tag");
|
|
|
|
ahc_abort_scbs(ahc, target, channel,
|
|
|
|
TCL_LUN(saved_tcl), tag,
|
|
|
|
ROLE_INITIATOR,
|
|
|
|
XS_DRIVER_STUFFUP);
|
|
|
|
printerror = 0;
|
|
|
|
break;
|
|
|
|
case MSG_BUS_DEV_RESET:
|
|
|
|
{
|
|
|
|
struct ahc_devinfo devinfo;
|
|
|
|
|
|
|
|
if (scb != NULL &&
|
|
|
|
(scb->xs->xs_control & XS_CTL_RESET)
|
|
|
|
&& ahc_match_scb(scb, target, channel,
|
|
|
|
TCL_LUN(saved_tcl),
|
|
|
|
SCB_LIST_NULL,
|
|
|
|
ROLE_INITIATOR)) {
|
|
|
|
ahcsetccbstatus(scb->xs, XS_NOERROR);
|
|
|
|
}
|
|
|
|
ahc_compile_devinfo(&devinfo,
|
|
|
|
initiator_role_id,
|
|
|
|
target,
|
|
|
|
TCL_LUN(saved_tcl),
|
|
|
|
channel,
|
|
|
|
ROLE_INITIATOR);
|
|
|
|
ahc_handle_devreset(ahc, &devinfo,
|
|
|
|
XS_RESET,
|
|
|
|
"Bus Device Reset",
|
|
|
|
/*verbose_level*/0);
|
|
|
|
printerror = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (printerror != 0) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (scb != NULL) {
|
|
|
|
u_int tag;
|
|
|
|
|
|
|
|
if ((scb->hscb->control & TAG_ENB) != 0)
|
|
|
|
tag = scb->hscb->tag;
|
|
|
|
else
|
|
|
|
tag = SCB_LIST_NULL;
|
|
|
|
ahc_abort_scbs(ahc, target, channel,
|
|
|
|
SCB_LUN(scb), tag,
|
|
|
|
ROLE_INITIATOR,
|
|
|
|
XS_DRIVER_STUFFUP);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* We had not fully identified this connection,
|
|
|
|
* so we cannot abort anything.
|
|
|
|
*/
|
|
|
|
printf("%s: ", ahc_name(ahc));
|
|
|
|
}
|
|
|
|
for (i = 0; i < num_phases; i++) {
|
|
|
|
if (lastphase == phase_table[i].phase)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf("Unexpected busfree %s\n"
|
|
|
|
"SEQADDR == 0x%x\n",
|
|
|
|
phase_table[i].phasemsg, ahc_inb(ahc, SEQADDR0)
|
|
|
|
| (ahc_inb(ahc, SEQADDR1) << 8));
|
|
|
|
}
|
|
|
|
ahc_clear_msg_state(ahc);
|
|
|
|
ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENBUSFREE);
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRBUSFREE|CLRSCSIPERR);
|
|
|
|
ahc_outb(ahc, CLRINT, CLRSCSIINT);
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
} else if ((status & SELTO) != 0) {
|
|
|
|
u_int scbptr;
|
|
|
|
|
|
|
|
scbptr = ahc_inb(ahc, WAITING_SCBH);
|
|
|
|
ahc_outb(ahc, SCBPTR, scbptr);
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
|
|
|
|
if (scb_index < ahc->scb_data->numscbs) {
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
if ((scb->flags & SCB_ACTIVE) == 0)
|
|
|
|
scb = NULL;
|
|
|
|
} else
|
|
|
|
scb = NULL;
|
|
|
|
|
|
|
|
if (scb == NULL) {
|
|
|
|
printf("%s: ahc_intr - referenced scb not "
|
|
|
|
"valid during SELTO scb(%d, %d)\n",
|
|
|
|
ahc_name(ahc), scbptr, scb_index);
|
|
|
|
} else {
|
|
|
|
u_int tag;
|
|
|
|
|
|
|
|
tag = SCB_LIST_NULL;
|
2001-04-25 21:53:04 +04:00
|
|
|
if ((scb->hscb->control & TAG_ENB) != 0)
|
2000-03-15 05:08:28 +03:00
|
|
|
tag = scb->hscb->tag;
|
|
|
|
|
|
|
|
ahc_abort_scbs(ahc, SCB_TARGET(scb), SCB_CHANNEL(scb),
|
|
|
|
SCB_LUN(scb), tag,
|
|
|
|
ROLE_INITIATOR, XS_SELTIMEOUT);
|
|
|
|
}
|
|
|
|
/* Stop the selection */
|
|
|
|
ahc_outb(ahc, SCSISEQ, 0);
|
|
|
|
|
|
|
|
/* No more pending messages */
|
|
|
|
ahc_clear_msg_state(ahc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Although the driver does not care about the
|
|
|
|
* 'Selection in Progress' status bit, the busy
|
|
|
|
* LED does. SELINGO is only cleared by a sucessful
|
|
|
|
* selection, so we must manually clear it to ensure
|
|
|
|
* the LED turns off just incase no future successful
|
|
|
|
* selections occur (e.g. no devices on the bus).
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, CLRSINT0, CLRSELINGO);
|
|
|
|
|
|
|
|
/* Clear interrupt state */
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR);
|
|
|
|
ahc_outb(ahc, CLRINT, CLRSCSIINT);
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
} else {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Unknown SCSIINT. Status = 0x%x\n", status);
|
|
|
|
ahc_outb(ahc, CLRSINT1, status);
|
|
|
|
ahc_outb(ahc, CLRINT, CLRSCSIINT);
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_build_transfer_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We need to initiate transfer negotiations.
|
|
|
|
* If our current and goal settings are identical,
|
|
|
|
* we want to renegotiate due to a check condition.
|
|
|
|
*/
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
int dowide;
|
|
|
|
int dosync;
|
|
|
|
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
dowide = tinfo->current.width != tinfo->goal.width;
|
|
|
|
dosync = tinfo->current.period != tinfo->goal.period;
|
|
|
|
|
|
|
|
if (!dowide && !dosync) {
|
|
|
|
dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT;
|
|
|
|
dosync = tinfo->goal.period != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dowide) {
|
|
|
|
ahc_construct_wdtr(ahc, tinfo->goal.width);
|
|
|
|
} else if (dosync) {
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *rate;
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int period;
|
|
|
|
u_int offset;
|
|
|
|
|
|
|
|
period = tinfo->goal.period;
|
|
|
|
rate = ahc_devlimited_syncrate(ahc, &period);
|
|
|
|
offset = tinfo->goal.offset;
|
|
|
|
ahc_validate_offset(ahc, rate, &offset,
|
|
|
|
tinfo->current.width);
|
|
|
|
ahc_construct_sdtr(ahc, period, offset);
|
|
|
|
} else {
|
|
|
|
panic("ahc_intr: AWAITING_MSG for negotiation, "
|
2002-09-27 19:35:29 +04:00
|
|
|
"but no negotiation needed");
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_setup_initiator_msgout(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
|
|
|
|
struct scb *scb)
|
|
|
|
{
|
2000-06-30 03:12:19 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* To facilitate adding multiple messages together,
|
|
|
|
* each routine should increment the index and len
|
|
|
|
* variables instead of setting them explicitly.
|
2000-06-30 03:12:19 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
|
|
|
|
if ((scb->flags & SCB_DEVICE_RESET) == 0
|
|
|
|
&& ahc_inb(ahc, MSG_OUT) == MSG_IDENTIFYFLAG) {
|
|
|
|
u_int identify_msg;
|
|
|
|
|
|
|
|
identify_msg = MSG_IDENTIFYFLAG | SCB_LUN(scb);
|
|
|
|
if ((scb->hscb->control & DISCENB) != 0)
|
|
|
|
identify_msg |= MSG_IDENTIFY_DISCFLAG;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = identify_msg;
|
|
|
|
ahc->msgout_len++;
|
|
|
|
|
|
|
|
if ((scb->hscb->control & TAG_ENB) != 0) {
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc->msgout_buf[ahc->msgout_index++] =
|
|
|
|
scb->xs->xs_tag_type;
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = scb->hscb->tag;
|
|
|
|
ahc->msgout_len += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scb->flags & SCB_DEVICE_RESET) {
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_BUS_DEV_RESET;
|
|
|
|
ahc->msgout_len++;
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Bus Device Reset Message Sent\n");
|
|
|
|
} else if (scb->flags & SCB_ABORT) {
|
|
|
|
if ((scb->hscb->control & TAG_ENB) != 0)
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_ABORT_TAG;
|
|
|
|
else
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_ABORT;
|
|
|
|
ahc->msgout_len++;
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Abort Message Sent\n");
|
|
|
|
} else if ((ahc->targ_msg_req & devinfo->target_mask) != 0) {
|
|
|
|
ahc_build_transfer_msg(ahc, devinfo);
|
|
|
|
} else {
|
|
|
|
printf("ahc_intr: AWAITING_MSG for an SCB that "
|
|
|
|
"does not have a waiting message");
|
|
|
|
panic("SCB = %d, SCB Control = %x, MSG_OUT = %x "
|
|
|
|
"SCB flags = %x", scb->hscb->tag, scb->hscb->control,
|
|
|
|
ahc_inb(ahc, MSG_OUT), scb->flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear the MK_MESSAGE flag from the SCB so we aren't
|
|
|
|
* asked to send this message again.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, ahc_inb(ahc, SCB_CONTROL) & ~MK_MESSAGE);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_setup_target_msgin(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
|
|
|
{
|
2000-06-30 03:12:19 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* To facilitate adding multiple messages together,
|
|
|
|
* each routine should increment the index and len
|
|
|
|
* variables instead of setting them explicitly.
|
2000-06-30 03:12:19 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
|
|
|
|
if ((ahc->targ_msg_req & devinfo->target_mask) != 0)
|
|
|
|
ahc_build_transfer_msg(ahc, devinfo);
|
|
|
|
else
|
|
|
|
panic("ahc_intr: AWAITING target message with no message");
|
|
|
|
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msg_type = MSG_TYPE_TARGET_MSGIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* What we care about here is if we had an
|
|
|
|
* outstanding SDTR or WDTR message for this
|
|
|
|
* target. If we did, this is a signal that
|
|
|
|
* the target is refusing negotiation.
|
|
|
|
*/
|
|
|
|
struct scb *scb;
|
|
|
|
u_int scb_index;
|
|
|
|
u_int last_msg;
|
|
|
|
int response = 0;
|
|
|
|
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
|
|
|
|
/* Might be necessary */
|
|
|
|
last_msg = ahc_inb(ahc, LAST_MSG);
|
|
|
|
|
|
|
|
if (ahc_sent_msg(ahc, MSG_EXT_WDTR, /*full*/FALSE)) {
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
|
|
|
|
#ifdef AHC_DEBUG_NEG
|
|
|
|
/* note 8bit xfers */
|
|
|
|
printf("%s:%c:%d: refuses WIDE negotiation. Using "
|
|
|
|
"8bit transfers\n", ahc_name(ahc),
|
|
|
|
devinfo->channel, devinfo->target);
|
|
|
|
#endif
|
|
|
|
ahc_set_width(ahc, devinfo,
|
|
|
|
MSG_EXT_WDTR_BUS_8_BIT,
|
|
|
|
AHC_TRANS_ACTIVE|AHC_TRANS_GOAL,
|
|
|
|
/*paused*/TRUE, /*done*/TRUE);
|
|
|
|
/*
|
|
|
|
* No need to clear the sync rate. If the target
|
|
|
|
* did not accept the command, our syncrate is
|
|
|
|
* unaffected. If the target started the negotiation,
|
|
|
|
* but rejected our response, we already cleared the
|
|
|
|
* sync rate before sending our WDTR.
|
|
|
|
*/
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel,
|
|
|
|
devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
if (tinfo->goal.period) {
|
|
|
|
u_int period;
|
|
|
|
|
|
|
|
/* Start the sync negotiation */
|
|
|
|
period = tinfo->goal.period;
|
|
|
|
ahc_devlimited_syncrate(ahc, &period);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
ahc_construct_sdtr(ahc, period, tinfo->goal.offset);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
response = 1;
|
2001-04-26 20:56:53 +04:00
|
|
|
} else
|
|
|
|
ahc_update_xfer_mode(ahc, devinfo);
|
2000-03-15 05:08:28 +03:00
|
|
|
} else if (ahc_sent_msg(ahc, MSG_EXT_SDTR, /*full*/FALSE)) {
|
|
|
|
/* note asynch xfers and clear flag */
|
|
|
|
ahc_set_syncrate(ahc, devinfo, /*syncrate*/NULL, /*period*/0,
|
|
|
|
/*offset*/0, AHC_TRANS_ACTIVE|AHC_TRANS_GOAL,
|
|
|
|
/*paused*/TRUE, /*done*/TRUE);
|
|
|
|
#ifdef AHC_DEBUG_NEG
|
|
|
|
printf("%s:%c:%d: refuses synchronous negotiation. "
|
|
|
|
"Using asynchronous transfers\n",
|
|
|
|
ahc_name(ahc),
|
|
|
|
devinfo->channel, devinfo->target);
|
|
|
|
#endif
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc_update_xfer_mode(ahc, devinfo);
|
2001-04-25 21:53:04 +04:00
|
|
|
} else if ((scb->hscb->control & TAG_ENB) != 0) {
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("%s:%c:%d: refuses tagged commands. Performing "
|
|
|
|
"non-tagged I/O\n", ahc_name(ahc),
|
|
|
|
devinfo->channel, devinfo->target);
|
|
|
|
|
|
|
|
ahc_set_tags(ahc, devinfo, FALSE);
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc_update_xfer_mode(ahc, devinfo);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Resend the identify for this CCB as the target
|
|
|
|
* may believe that the selection is invalid otherwise.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, ahc_inb(ahc, SCB_CONTROL)
|
|
|
|
& ~MSG_SIMPLE_Q_TAG);
|
|
|
|
scb->hscb->control &= ~MSG_SIMPLE_Q_TAG;
|
|
|
|
ahc_outb(ahc, MSG_OUT, MSG_IDENTIFYFLAG);
|
|
|
|
ahc_outb(ahc, SCSISIGO, ahc_inb(ahc, SCSISIGO) | ATNO);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Requeue all tagged commands for this target
|
|
|
|
* currently in our posession so they can be
|
|
|
|
* converted to untagged commands.
|
|
|
|
*/
|
|
|
|
ahc_search_qinfifo(ahc, SCB_TARGET(scb), SCB_CHANNEL(scb),
|
|
|
|
SCB_LUN(scb), /*tag*/SCB_LIST_NULL,
|
|
|
|
ROLE_INITIATOR, SCB_REQUEUE,
|
|
|
|
SEARCH_COMPLETE);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Otherwise, we ignore it.
|
|
|
|
*/
|
|
|
|
printf("%s:%c:%d: Message reject for %x -- ignored\n",
|
|
|
|
ahc_name(ahc), devinfo->channel, devinfo->target,
|
|
|
|
last_msg);
|
|
|
|
}
|
|
|
|
return (response);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_clear_msg_state(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
ahc->msg_type = MSG_TYPE_NONE;
|
|
|
|
ahc_outb(ahc, MSG_OUT, MSG_NOOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_handle_message_phase(struct ahc_softc *ahc, struct scsipi_periph *periph)
|
2000-06-30 03:12:19 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_devinfo devinfo;
|
|
|
|
u_int bus_phase;
|
|
|
|
int end_session;
|
|
|
|
|
|
|
|
ahc_fetch_devinfo(ahc, &devinfo);
|
|
|
|
end_session = FALSE;
|
|
|
|
bus_phase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK;
|
|
|
|
|
|
|
|
reswitch:
|
|
|
|
switch (ahc->msg_type) {
|
|
|
|
case MSG_TYPE_INITIATOR_MSGOUT:
|
|
|
|
{
|
|
|
|
int lastbyte;
|
|
|
|
int phasemis;
|
|
|
|
int msgdone;
|
|
|
|
|
|
|
|
if (ahc->msgout_len == 0)
|
|
|
|
panic("REQINIT interrupt with no active message");
|
|
|
|
|
|
|
|
phasemis = bus_phase != P_MESGOUT;
|
|
|
|
if (phasemis) {
|
|
|
|
if (bus_phase == P_MESGIN) {
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Change gears and see if
|
|
|
|
* this messages is of interest to
|
|
|
|
* us or should be passed back to
|
|
|
|
* the sequencer.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, CLRSINT1, CLRATNO);
|
|
|
|
ahc->send_msg_perror = FALSE;
|
|
|
|
ahc->msg_type = MSG_TYPE_INITIATOR_MSGIN;
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
goto reswitch;
|
|
|
|
}
|
|
|
|
end_session = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ahc->send_msg_perror) {
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRATNO);
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRREQINIT);
|
|
|
|
ahc_outb(ahc, SCSIDATL, MSG_PARITY_ERROR);
|
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
msgdone = ahc->msgout_index == ahc->msgout_len;
|
|
|
|
if (msgdone) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* The target has requested a retry.
|
|
|
|
* Re-assert ATN, reset our message index to
|
|
|
|
* 0, and try again.
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc_outb(ahc, SCSISIGO, ahc_inb(ahc, SCSISIGO) | ATNO);
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
lastbyte = ahc->msgout_index == (ahc->msgout_len - 1);
|
|
|
|
if (lastbyte) {
|
|
|
|
/* Last byte is signified by dropping ATN */
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRATNO);
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Clear our interrupt status and present
|
|
|
|
* the next byte on the bus.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRREQINIT);
|
|
|
|
ahc_outb(ahc, SCSIDATL, ahc->msgout_buf[ahc->msgout_index++]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSG_TYPE_INITIATOR_MSGIN:
|
|
|
|
{
|
|
|
|
int phasemis;
|
|
|
|
int message_done;
|
|
|
|
|
|
|
|
phasemis = bus_phase != P_MESGIN;
|
|
|
|
|
|
|
|
if (phasemis) {
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
if (bus_phase == P_MESGOUT
|
|
|
|
&& (ahc->send_msg_perror == TRUE
|
|
|
|
|| (ahc->msgout_len != 0
|
|
|
|
&& ahc->msgout_index == 0))) {
|
|
|
|
ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT;
|
|
|
|
goto reswitch;
|
|
|
|
}
|
|
|
|
end_session = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Pull the byte in without acking it */
|
|
|
|
ahc->msgin_buf[ahc->msgin_index] = ahc_inb(ahc, SCSIBUSL);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
message_done = ahc_parse_msg(ahc, periph, &devinfo);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (message_done) {
|
|
|
|
/*
|
|
|
|
* Clear our incoming message buffer in case there
|
|
|
|
* is another message following this one.
|
|
|
|
*/
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this message illicited a response,
|
|
|
|
* assert ATN so the target takes us to the
|
|
|
|
* message out phase.
|
|
|
|
*/
|
|
|
|
if (ahc->msgout_len != 0)
|
|
|
|
ahc_outb(ahc, SCSISIGO,
|
|
|
|
ahc_inb(ahc, SCSISIGO) | ATNO);
|
2000-06-30 03:12:19 +04:00
|
|
|
} else
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgin_index++;
|
|
|
|
|
|
|
|
/* Ack the byte */
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRREQINIT);
|
|
|
|
ahc_inb(ahc, SCSIDATL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSG_TYPE_TARGET_MSGIN:
|
|
|
|
{
|
|
|
|
int msgdone;
|
|
|
|
int msgout_request;
|
|
|
|
|
|
|
|
if (ahc->msgout_len == 0)
|
|
|
|
panic("Target MSGIN with no active message");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we interrupted a mesgout session, the initiator
|
|
|
|
* will not know this until our first REQ. So, we
|
|
|
|
* only honor mesgout requests after we've sent our
|
|
|
|
* first byte.
|
|
|
|
*/
|
|
|
|
if ((ahc_inb(ahc, SCSISIGI) & ATNI) != 0
|
|
|
|
&& ahc->msgout_index > 0)
|
|
|
|
msgout_request = TRUE;
|
|
|
|
else
|
|
|
|
msgout_request = FALSE;
|
|
|
|
|
|
|
|
if (msgout_request) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Change gears and see if
|
|
|
|
* this messages is of interest to
|
|
|
|
* us or should be passed back to
|
|
|
|
* the sequencer.
|
|
|
|
*/
|
|
|
|
ahc->msg_type = MSG_TYPE_TARGET_MSGOUT;
|
|
|
|
ahc_outb(ahc, SCSISIGO, P_MESGOUT | BSYO);
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
/* Dummy read to REQ for first byte */
|
|
|
|
ahc_inb(ahc, SCSIDATL);
|
|
|
|
ahc_outb(ahc, SXFRCTL0,
|
|
|
|
ahc_inb(ahc, SXFRCTL0) | SPIOEN);
|
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
msgdone = ahc->msgout_index == ahc->msgout_len;
|
|
|
|
if (msgdone) {
|
|
|
|
ahc_outb(ahc, SXFRCTL0,
|
|
|
|
ahc_inb(ahc, SXFRCTL0) & ~SPIOEN);
|
|
|
|
end_session = TRUE;
|
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Present the next byte on the bus.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, SXFRCTL0, ahc_inb(ahc, SXFRCTL0) | SPIOEN);
|
|
|
|
ahc_outb(ahc, SCSIDATL, ahc->msgout_buf[ahc->msgout_index++]);
|
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
case MSG_TYPE_TARGET_MSGOUT:
|
|
|
|
{
|
|
|
|
int lastbyte;
|
|
|
|
int msgdone;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The initiator signals that this is
|
|
|
|
* the last byte by dropping ATN.
|
|
|
|
*/
|
|
|
|
lastbyte = (ahc_inb(ahc, SCSISIGI) & ATNI) == 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the latched byte, but turn off SPIOEN first
|
|
|
|
* so that we don't inadvertantly cause a REQ for the
|
|
|
|
* next byte.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, SXFRCTL0, ahc_inb(ahc, SXFRCTL0) & ~SPIOEN);
|
|
|
|
ahc->msgin_buf[ahc->msgin_index] = ahc_inb(ahc, SCSIDATL);
|
2001-04-25 21:53:04 +04:00
|
|
|
msgdone = ahc_parse_msg(ahc, periph, &devinfo);
|
2000-03-15 05:08:28 +03:00
|
|
|
if (msgdone == MSGLOOP_TERMINATED) {
|
|
|
|
/*
|
|
|
|
* The message is *really* done in that it caused
|
|
|
|
* us to go to bus free. The sequencer has already
|
|
|
|
* been reset at this point, so pull the ejection
|
|
|
|
* handle.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgin_index++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Read spec about initiator dropping ATN too soon
|
|
|
|
* and use msgdone to detect it.
|
|
|
|
*/
|
|
|
|
if (msgdone == MSGLOOP_MSGCOMPLETE) {
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this message illicited a response, transition
|
|
|
|
* to the Message in phase and send it.
|
|
|
|
*/
|
|
|
|
if (ahc->msgout_len != 0) {
|
|
|
|
ahc_outb(ahc, SCSISIGO, P_MESGIN | BSYO);
|
|
|
|
ahc_outb(ahc, SXFRCTL0,
|
|
|
|
ahc_inb(ahc, SXFRCTL0) | SPIOEN);
|
|
|
|
ahc->msg_type = MSG_TYPE_TARGET_MSGIN;
|
|
|
|
ahc->msgin_index = 0;
|
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (lastbyte)
|
|
|
|
end_session = TRUE;
|
|
|
|
else {
|
|
|
|
/* Ask for the next byte. */
|
|
|
|
ahc_outb(ahc, SXFRCTL0,
|
|
|
|
ahc_inb(ahc, SXFRCTL0) | SPIOEN);
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
default:
|
|
|
|
panic("Unknown REQINIT message type");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end_session) {
|
|
|
|
ahc_clear_msg_state(ahc);
|
|
|
|
ahc_outb(ahc, RETURN_1, EXIT_MSG_LOOP);
|
|
|
|
} else
|
|
|
|
ahc_outb(ahc, RETURN_1, CONT_MSG_LOOP);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* See if we sent a particular extended message to the target.
|
|
|
|
* If "full" is true, the target saw the full message.
|
|
|
|
* If "full" is false, the target saw at least the first
|
|
|
|
* byte of the message.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ahc_sent_msg(struct ahc_softc *ahc, u_int msgtype, int full)
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
int found;
|
|
|
|
int index;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
found = FALSE;
|
|
|
|
index = 0;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
while (index < ahc->msgout_len) {
|
|
|
|
if (ahc->msgout_buf[index] == MSG_EXTENDED) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Found a candidate */
|
|
|
|
if (ahc->msgout_buf[index+2] == msgtype) {
|
|
|
|
u_int end_index;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
end_index = index + 1
|
|
|
|
+ ahc->msgout_buf[index + 1];
|
|
|
|
if (full) {
|
|
|
|
if (ahc->msgout_index > end_index)
|
|
|
|
found = TRUE;
|
|
|
|
} else if (ahc->msgout_index > index)
|
|
|
|
found = TRUE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
break;
|
|
|
|
} else if (ahc->msgout_buf[index] >= MSG_SIMPLE_Q_TAG
|
|
|
|
&& ahc->msgout_buf[index] <= MSG_IGN_WIDE_RESIDUE) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Skip tag type and tag id or residue param*/
|
|
|
|
index += 2;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
} else {
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Single byte message */
|
|
|
|
index++;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
return (found);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_parse_msg(struct ahc_softc *ahc, struct scsipi_periph *periph,
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_devinfo *devinfo)
|
|
|
|
{
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
int reject;
|
|
|
|
int done;
|
|
|
|
int response;
|
|
|
|
u_int targ_scsirate;
|
|
|
|
|
|
|
|
done = MSGLOOP_IN_PROG;
|
|
|
|
response = FALSE;
|
|
|
|
reject = FALSE;
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid,
|
|
|
|
devinfo->target, &tstate);
|
|
|
|
targ_scsirate = tinfo->scsirate;
|
|
|
|
|
|
|
|
/*
|
2001-07-05 00:34:03 +04:00
|
|
|
* Parse as much of the message as is available,
|
2000-03-15 05:08:28 +03:00
|
|
|
* rejecting it if we don't support it. When
|
2001-07-05 00:34:03 +04:00
|
|
|
* the entire message is available and has been
|
2000-03-15 05:08:28 +03:00
|
|
|
* handled, return MSGLOOP_MSGCOMPLETE, indicating
|
|
|
|
* that we have parsed an entire message.
|
|
|
|
*
|
|
|
|
* In the case of extended messages, we accept the length
|
|
|
|
* byte outright and perform more checking once we know the
|
|
|
|
* extended message type.
|
|
|
|
*/
|
|
|
|
switch (ahc->msgin_buf[0]) {
|
|
|
|
case MSG_MESSAGE_REJECT:
|
|
|
|
response = ahc_handle_msg_reject(ahc, devinfo);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case MSG_NOOP:
|
|
|
|
done = MSGLOOP_MSGCOMPLETE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
2000-03-15 05:08:28 +03:00
|
|
|
case MSG_IGN_WIDE_RESIDUE:
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Wait for the whole message */
|
|
|
|
if (ahc->msgin_index >= 1) {
|
|
|
|
if (ahc->msgin_buf[1] != 1
|
|
|
|
|| tinfo->current.width == MSG_EXT_WDTR_BUS_8_BIT) {
|
|
|
|
reject = TRUE;
|
|
|
|
done = MSGLOOP_MSGCOMPLETE;
|
|
|
|
} else
|
|
|
|
ahc_handle_ign_wide_residue(ahc, devinfo);
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
case MSG_EXTENDED:
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Wait for enough of the message to begin validation */
|
|
|
|
if (ahc->msgin_index < 2)
|
|
|
|
break;
|
|
|
|
switch (ahc->msgin_buf[2]) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
case MSG_EXT_SDTR:
|
|
|
|
{
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *syncrate;
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int period;
|
|
|
|
u_int offset;
|
|
|
|
u_int saved_offset;
|
|
|
|
|
|
|
|
if (ahc->msgin_buf[1] != MSG_EXT_SDTR_LEN) {
|
|
|
|
reject = TRUE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Wait until we have both args before validating
|
|
|
|
* and acting on this message.
|
|
|
|
*
|
|
|
|
* Add one to MSG_EXT_SDTR_LEN to account for
|
|
|
|
* the extended message preamble.
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->msgin_index < (MSG_EXT_SDTR_LEN + 1))
|
|
|
|
break;
|
|
|
|
|
|
|
|
period = ahc->msgin_buf[3];
|
|
|
|
saved_offset = offset = ahc->msgin_buf[4];
|
|
|
|
syncrate = ahc_devlimited_syncrate(ahc, &period);
|
|
|
|
ahc_validate_offset(ahc, syncrate, &offset,
|
|
|
|
targ_scsirate & WIDEXFER);
|
|
|
|
ahc_set_syncrate(ahc, devinfo,
|
|
|
|
syncrate, period, offset,
|
|
|
|
AHC_TRANS_ACTIVE|AHC_TRANS_GOAL,
|
|
|
|
/*paused*/TRUE, /*done*/TRUE);
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc_update_xfer_mode(ahc, devinfo);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
|
|
|
* See if we initiated Sync Negotiation
|
|
|
|
* and didn't have to fall down to async
|
|
|
|
* transfers.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_sent_msg(ahc, MSG_EXT_SDTR, /*full*/TRUE)) {
|
|
|
|
/* We started it */
|
|
|
|
if (saved_offset != offset) {
|
|
|
|
/* Went too low - force async */
|
|
|
|
reject = TRUE;
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Send our own SDTR in reply
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
ahc_construct_sdtr(ahc, period, offset);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
response = TRUE;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
done = MSGLOOP_MSGCOMPLETE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSG_EXT_WDTR:
|
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int bus_width;
|
|
|
|
u_int sending_reply;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
sending_reply = FALSE;
|
|
|
|
if (ahc->msgin_buf[1] != MSG_EXT_WDTR_LEN) {
|
|
|
|
reject = TRUE;
|
1995-10-09 12:49:30 +03:00
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Wait until we have our arg before validating
|
|
|
|
* and acting on this message.
|
|
|
|
*
|
|
|
|
* Add one to MSG_EXT_WDTR_LEN to account for
|
|
|
|
* the extended message preamble.
|
|
|
|
*/
|
|
|
|
if (ahc->msgin_index < (MSG_EXT_WDTR_LEN + 1))
|
|
|
|
break;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
bus_width = ahc->msgin_buf[3];
|
|
|
|
if (ahc_sent_msg(ahc, MSG_EXT_WDTR, /*full*/TRUE)) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
|
|
|
* Don't send a WDTR back to the
|
|
|
|
* target, since we asked first.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
switch (bus_width){
|
|
|
|
default:
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* How can we do anything greater
|
|
|
|
* than 16bit transfers on a 16bit
|
|
|
|
* bus?
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
reject = TRUE;
|
|
|
|
printf("%s: target %d requested %dBit "
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
"transfers. Rejecting...\n",
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_name(ahc), devinfo->target,
|
|
|
|
8 * (0x01 << bus_width));
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case MSG_EXT_WDTR_BUS_8_BIT:
|
|
|
|
bus_width = MSG_EXT_WDTR_BUS_8_BIT;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
2000-03-15 05:08:28 +03:00
|
|
|
case MSG_EXT_WDTR_BUS_16_BIT:
|
1995-10-09 12:49:30 +03:00
|
|
|
break;
|
|
|
|
}
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
} else {
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
* Send our own WDTR in reply
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
switch (bus_width) {
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
default:
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->features & AHC_WIDE) {
|
|
|
|
/* Respond Wide */
|
|
|
|
bus_width =
|
|
|
|
MSG_EXT_WDTR_BUS_16_BIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case MSG_EXT_WDTR_BUS_8_BIT:
|
|
|
|
bus_width = MSG_EXT_WDTR_BUS_8_BIT;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
ahc_construct_wdtr(ahc, bus_width);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
response = TRUE;
|
|
|
|
sending_reply = TRUE;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_set_width(ahc, devinfo, bus_width,
|
|
|
|
AHC_TRANS_ACTIVE|AHC_TRANS_GOAL,
|
|
|
|
/*paused*/TRUE, /*done*/TRUE);
|
|
|
|
|
|
|
|
/* After a wide message, we are async */
|
|
|
|
ahc_set_syncrate(ahc, devinfo,
|
|
|
|
/*syncrate*/NULL, /*period*/0,
|
|
|
|
/*offset*/0, AHC_TRANS_ACTIVE,
|
|
|
|
/*paused*/TRUE, /*done*/FALSE);
|
|
|
|
if (sending_reply == FALSE && reject == FALSE) {
|
|
|
|
|
|
|
|
if (tinfo->goal.period) {
|
2001-01-18 23:28:15 +03:00
|
|
|
const struct ahc_syncrate *rate;
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int period;
|
|
|
|
u_int offset;
|
|
|
|
|
|
|
|
/* Start the sync negotiation */
|
|
|
|
period = tinfo->goal.period;
|
|
|
|
rate = ahc_devlimited_syncrate(ahc,
|
|
|
|
&period);
|
|
|
|
offset = tinfo->goal.offset;
|
|
|
|
ahc_validate_offset(ahc, rate, &offset,
|
|
|
|
tinfo->current.width);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 0;
|
|
|
|
ahc_construct_sdtr(ahc, period, offset);
|
|
|
|
ahc->msgout_index = 0;
|
|
|
|
response = TRUE;
|
2001-04-26 20:56:53 +04:00
|
|
|
} else
|
|
|
|
ahc_update_xfer_mode(ahc, devinfo);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
done = MSGLOOP_MSGCOMPLETE;
|
1995-10-09 12:49:30 +03:00
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
/* Unknown extended message. Reject it. */
|
2000-03-15 05:08:28 +03:00
|
|
|
reject = TRUE;
|
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
break;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
case MSG_BUS_DEV_RESET:
|
|
|
|
ahc_handle_devreset(ahc, devinfo,
|
|
|
|
XS_RESET, "Bus Device Reset Received",
|
|
|
|
/*verbose_level*/0);
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
done = MSGLOOP_TERMINATED;
|
|
|
|
break;
|
|
|
|
case MSG_ABORT_TAG:
|
|
|
|
case MSG_ABORT:
|
|
|
|
case MSG_CLEAR_QUEUE:
|
|
|
|
/* Target mode messages */
|
|
|
|
if (devinfo->role != ROLE_TARGET) {
|
|
|
|
reject = TRUE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
#if AHC_TARGET_MODE
|
|
|
|
ahc_abort_scbs(ahc, devinfo->target, devinfo->channel,
|
|
|
|
devinfo->lun,
|
|
|
|
ahc->msgin_buf[0] == MSG_ABORT_TAG
|
|
|
|
? SCB_LIST_NULL
|
|
|
|
: ahc_inb(ahc, INITIATOR_TAG),
|
|
|
|
ROLE_TARGET, XS_DRIVER_STUFFUP);
|
|
|
|
|
|
|
|
tstate = ahc->enabled_targets[devinfo->our_scsiid];
|
|
|
|
if (tstate != NULL) {
|
|
|
|
struct tmode_lstate* lstate;
|
|
|
|
|
|
|
|
lstate = tstate->enabled_luns[devinfo->lun];
|
|
|
|
if (lstate != NULL) {
|
|
|
|
ahc_queue_lstate_event(ahc, lstate,
|
|
|
|
devinfo->our_scsiid,
|
|
|
|
ahc->msgin_buf[0],
|
|
|
|
/*arg*/0);
|
|
|
|
ahc_send_lstate_events(ahc, lstate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done = MSGLOOP_MSGCOMPLETE;
|
|
|
|
#else
|
|
|
|
panic("ahc: got target mode message");
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case MSG_TERM_IO_PROC:
|
|
|
|
default:
|
|
|
|
reject = TRUE;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (reject) {
|
|
|
|
/*
|
|
|
|
* Setup to reject the message.
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_index = 0;
|
|
|
|
ahc->msgout_len = 1;
|
|
|
|
ahc->msgout_buf[0] = MSG_MESSAGE_REJECT;
|
|
|
|
done = MSGLOOP_MSGCOMPLETE;
|
|
|
|
response = TRUE;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (done != MSGLOOP_IN_PROG && !response)
|
|
|
|
/* Clear the outgoing message buffer */
|
|
|
|
ahc->msgout_len = 0;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
return (done);
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_handle_ign_wide_residue(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
|
|
|
|
{
|
|
|
|
u_int scb_index;
|
|
|
|
struct scb *scb;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
scb = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
if ((ahc_inb(ahc, SEQ_FLAGS) & DPHASE) == 0
|
|
|
|
|| !(scb->xs->xs_control & XS_CTL_DATA_IN)) {
|
|
|
|
/*
|
|
|
|
* Ignore the message if we haven't
|
|
|
|
* seen an appropriate data phase yet.
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If the residual occurred on the last
|
|
|
|
* transfer and the transfer request was
|
|
|
|
* expected to end on an odd count, do
|
|
|
|
* nothing. Otherwise, subtract a byte
|
|
|
|
* and update the residual count accordingly.
|
|
|
|
*/
|
|
|
|
u_int resid_sgcnt;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
resid_sgcnt = ahc_inb(ahc, SCB_RESID_SGCNT);
|
|
|
|
if (resid_sgcnt == 0
|
|
|
|
&& ahc_inb(ahc, DATA_COUNT_ODD) == 1) {
|
|
|
|
/*
|
|
|
|
* If the residual occurred on the last
|
|
|
|
* transfer and the transfer request was
|
|
|
|
* expected to end on an odd count, do
|
|
|
|
* nothing.
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
u_int data_cnt;
|
|
|
|
u_int32_t data_addr;
|
|
|
|
u_int sg_index;
|
1997-03-13 03:38:48 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
data_cnt = (ahc_inb(ahc, SCB_RESID_DCNT + 2) << 16)
|
|
|
|
| (ahc_inb(ahc, SCB_RESID_DCNT + 1) << 8)
|
|
|
|
| (ahc_inb(ahc, SCB_RESID_DCNT));
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
data_addr = (ahc_inb(ahc, SHADDR + 3) << 24)
|
|
|
|
| (ahc_inb(ahc, SHADDR + 2) << 16)
|
|
|
|
| (ahc_inb(ahc, SHADDR + 1) << 8)
|
|
|
|
| (ahc_inb(ahc, SHADDR));
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
data_cnt += 1;
|
|
|
|
data_addr -= 1;
|
1998-03-16 18:36:17 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
sg_index = scb->sg_count - resid_sgcnt;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (sg_index != 0
|
|
|
|
&& (le32toh(scb->sg_list[sg_index].len) < data_cnt)) {
|
|
|
|
u_int32_t sg_addr;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
sg_index--;
|
|
|
|
data_cnt = 1;
|
|
|
|
data_addr = le32toh(scb->sg_list[sg_index].addr)
|
|
|
|
+ le32toh(scb->sg_list[sg_index].len)
|
|
|
|
- 1;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* The physical address base points to the
|
|
|
|
* second entry as it is always used for
|
|
|
|
* calculating the "next S/G pointer".
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
sg_addr = scb->sg_list_phys
|
|
|
|
+ (sg_index* sizeof(*scb->sg_list));
|
|
|
|
ahc_outb(ahc, SG_NEXT + 3, sg_addr >> 24);
|
|
|
|
ahc_outb(ahc, SG_NEXT + 2, sg_addr >> 16);
|
|
|
|
ahc_outb(ahc, SG_NEXT + 1, sg_addr >> 8);
|
|
|
|
ahc_outb(ahc, SG_NEXT, sg_addr);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCB_RESID_DCNT + 2, data_cnt >> 16);
|
|
|
|
ahc_outb(ahc, SCB_RESID_DCNT + 1, data_cnt >> 8);
|
|
|
|
ahc_outb(ahc, SCB_RESID_DCNT, data_cnt);
|
1996-07-11 02:50:44 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SHADDR + 3, data_addr >> 24);
|
|
|
|
ahc_outb(ahc, SHADDR + 2, data_addr >> 16);
|
|
|
|
ahc_outb(ahc, SHADDR + 1, data_addr >> 8);
|
|
|
|
ahc_outb(ahc, SHADDR, data_addr);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
|
|
|
|
int status, char *message,
|
|
|
|
int verbose_level)
|
|
|
|
{
|
|
|
|
int found;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
found = ahc_abort_scbs(ahc, devinfo->target, devinfo->channel,
|
|
|
|
AHC_LUN_WILDCARD, SCB_LIST_NULL, devinfo->role,
|
|
|
|
status);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Go back to async/narrow transfers and renegotiate.
|
|
|
|
* ahc_set_width and ahc_set_syncrate can cope with NULL
|
|
|
|
* paths.
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_set_width(ahc, devinfo, MSG_EXT_WDTR_BUS_8_BIT,
|
|
|
|
AHC_TRANS_CUR, /*paused*/TRUE, /*done*/FALSE);
|
|
|
|
ahc_set_syncrate(ahc, devinfo, /*syncrate*/NULL,
|
|
|
|
/*period*/0, /*offset*/0, AHC_TRANS_CUR,
|
|
|
|
/*paused*/TRUE, /*done*/FALSE);
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc_update_xfer_mode(ahc, devinfo);
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (message != NULL && (verbose_level <= 0))
|
|
|
|
printf("%s: %s on %c:%d. %d SCBs aborted\n", ahc_name(ahc),
|
|
|
|
message, devinfo->channel, devinfo->target, found);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* We have an scb which has been processed by the
|
1995-10-09 12:49:30 +03:00
|
|
|
* adaptor, now we look to see how the operation
|
|
|
|
* went.
|
|
|
|
*/
|
1996-05-16 07:59:03 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_done(struct ahc_softc *ahc, struct scb *scb)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scsipi_xfer *xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_periph *periph;
|
2000-03-15 05:08:28 +03:00
|
|
|
int requeue = 0;
|
|
|
|
int target;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
xs = scb->xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
periph = xs->xs_periph;
|
2000-03-15 05:08:28 +03:00
|
|
|
LIST_REMOVE(scb, plinks);
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&scb->xs->xs_callout);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWCMDS) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("ahc_done opcode %d tag %x\n", xs->cmdstore.opcode,
|
|
|
|
scb->hscb->tag);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
target = periph->periph_target;
|
1998-03-16 18:36:17 +03:00
|
|
|
|
|
|
|
if (xs->datalen) {
|
2000-03-15 05:08:28 +03:00
|
|
|
int op;
|
|
|
|
|
|
|
|
if (xs->xs_control & XS_CTL_DATA_IN)
|
|
|
|
op = BUS_DMASYNC_POSTREAD;
|
|
|
|
else
|
|
|
|
op = BUS_DMASYNC_POSTWRITE;
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, scb->dmamap, 0,
|
|
|
|
scb->dmamap->dm_mapsize, op);
|
|
|
|
bus_dmamap_unload(ahc->parent_dmat, scb->dmamap);
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
1998-03-16 18:36:17 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Unbusy this target/channel/lun.
|
2000-06-30 03:12:19 +04:00
|
|
|
* XXX if we are holding two commands per lun,
|
2000-03-15 05:08:28 +03:00
|
|
|
* send the next command.
|
1998-03-16 18:36:17 +03:00
|
|
|
*/
|
2000-03-25 22:52:12 +03:00
|
|
|
if (!(scb->hscb->control & TAG_ENB))
|
|
|
|
ahc_index_busy_tcl(ahc, scb->hscb->tcl, /*unbusy*/TRUE);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* If the recovery SCB completes, we have to be
|
|
|
|
* out of our timeout.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
|
|
|
|
|
|
|
|
struct scb *scbp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We were able to complete the command successfully,
|
|
|
|
* so reinstate the timeouts for all other pending
|
|
|
|
* commands.
|
|
|
|
*/
|
|
|
|
scbp = ahc->pending_ccbs.lh_first;
|
|
|
|
while (scbp != NULL) {
|
|
|
|
struct scsipi_xfer *txs = scbp->xs;
|
|
|
|
|
|
|
|
if (!(txs->xs_control & XS_CTL_POLL)) {
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&scbp->xs->xs_callout,
|
2002-04-05 22:27:45 +04:00
|
|
|
mstohz(scbp->xs->timeout),
|
2000-03-23 10:01:25 +03:00
|
|
|
ahc_timeout, scbp);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
scbp = LIST_NEXT(scbp, plinks);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that we didn't put a second instance of this
|
|
|
|
* SCB into the QINFIFO.
|
|
|
|
*/
|
|
|
|
ahc_search_qinfifo(ahc, SCB_TARGET(scb), SCB_CHANNEL(scb),
|
|
|
|
SCB_LUN(scb), scb->hscb->tag,
|
|
|
|
ROLE_INITIATOR, /*status*/0,
|
|
|
|
SEARCH_REMOVE);
|
|
|
|
if (xs->error != XS_NOERROR)
|
|
|
|
ahcsetccbstatus(xs, XS_TIMEOUT);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("no longer in timeout, status = %x\n", xs->status);
|
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
if (xs->error != XS_NOERROR) {
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Don't clobber any existing error state */
|
|
|
|
} else if ((scb->flags & SCB_SENSE) != 0) {
|
|
|
|
/*
|
|
|
|
* We performed autosense retrieval.
|
|
|
|
*
|
2001-07-07 20:13:44 +04:00
|
|
|
* zero the sense data before having
|
2000-03-15 05:08:28 +03:00
|
|
|
* the drive fill it. The SCSI spec mandates
|
2001-07-08 22:06:42 +04:00
|
|
|
* that any untransferred data should be
|
2000-03-15 05:08:28 +03:00
|
|
|
* assumed to be zero. Complete the 'bounce'
|
|
|
|
* of sense information through buffers accessible
|
|
|
|
* via bus-space by copying it into the clients
|
|
|
|
* csio.
|
|
|
|
*/
|
2001-07-07 20:13:44 +04:00
|
|
|
memset(&xs->sense.scsi_sense, 0, sizeof(xs->sense.scsi_sense));
|
2001-07-07 19:53:13 +04:00
|
|
|
memcpy(&xs->sense.scsi_sense,
|
|
|
|
&ahc->scb_data->sense[scb->hscb->tag],
|
|
|
|
le32toh(scb->sg_list->len));
|
1996-05-16 07:59:03 +04:00
|
|
|
xs->error = XS_SENSE;
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
if (scb->flags & SCB_FREEZE_QUEUE) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_periph_thaw(periph, 1);
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->flags &= ~SCB_FREEZE_QUEUE;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
requeue = scb->flags & SCB_REQUEUE;
|
|
|
|
ahcfreescb(ahc, scb);
|
|
|
|
|
|
|
|
if (requeue) {
|
2001-04-25 21:53:04 +04:00
|
|
|
xs->error = XS_REQUEUE;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_done(xs);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine the number of SCBs available on the controller
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ahc_probe_scbs(struct ahc_softc *ahc) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < AHC_SCB_MAX; i++) {
|
|
|
|
ahc_outb(ahc, SCBPTR, i);
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, i);
|
|
|
|
if (ahc_inb(ahc, SCB_CONTROL) != i)
|
|
|
|
break;
|
|
|
|
ahc_outb(ahc, SCBPTR, 0);
|
|
|
|
if (ahc_inb(ahc, SCB_CONTROL) != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (i);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the board, ready for normal operation
|
|
|
|
*/
|
|
|
|
int
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_init(struct ahc_softc *ahc)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
int max_targ = 15;
|
2000-03-15 05:08:28 +03:00
|
|
|
int i;
|
|
|
|
int term;
|
|
|
|
u_int scsi_conf;
|
|
|
|
u_int scsiseq_template;
|
|
|
|
u_int ultraenb;
|
|
|
|
u_int discenable;
|
|
|
|
u_int tagenable;
|
|
|
|
size_t driver_data_size;
|
|
|
|
u_int32_t physaddr;
|
|
|
|
|
|
|
|
#ifdef AHC_PRINT_SRAM
|
|
|
|
printf("Scratch Ram:");
|
|
|
|
for (i = 0x20; i < 0x5f; i++) {
|
|
|
|
if (((i % 8) == 0) && (i != 0)) {
|
|
|
|
printf ("\n ");
|
|
|
|
}
|
|
|
|
printf (" 0x%x", ahc_inb(ahc, i));
|
|
|
|
}
|
|
|
|
if ((ahc->features & AHC_MORE_SRAM) != 0) {
|
|
|
|
for (i = 0x70; i < 0x7f; i++) {
|
|
|
|
if (((i % 8) == 0) && (i != 0)) {
|
|
|
|
printf ("\n ");
|
|
|
|
}
|
|
|
|
printf (" 0x%x", ahc_inb(ahc, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf ("\n");
|
1998-03-16 18:36:17 +03:00
|
|
|
#endif
|
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
1996-05-16 07:59:03 +04:00
|
|
|
* Assume we have a board at this stage and it has been reset.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((ahc->flags & AHC_USEDEFAULTS) != 0)
|
|
|
|
ahc->our_id = ahc->our_id_b = 7;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Default to allowing initiator operations.
|
|
|
|
*/
|
|
|
|
ahc->flags |= AHC_INITIATORMODE;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* DMA tag for our command fifos and other data in system memory
|
|
|
|
* the card's sequencer must be able to access. For initiator
|
|
|
|
* roles, we need to allocate space for the qinfifo, qoutfifo,
|
|
|
|
* and untagged_scb arrays each of which are composed of 256
|
|
|
|
* 1 byte elements. When providing for the target mode role,
|
|
|
|
* we additionally must provide space for the incoming target
|
|
|
|
* command fifo.
|
|
|
|
*/
|
|
|
|
driver_data_size = 3 * 256 * sizeof(u_int8_t);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_createdmamem(ahc->parent_dmat, driver_data_size,
|
|
|
|
ahc->sc_dmaflags,
|
|
|
|
&ahc->shared_data_dmamap, (caddr_t *)&ahc->qoutfifo,
|
|
|
|
&ahc->shared_data_busaddr, &ahc->shared_data_seg,
|
|
|
|
&ahc->shared_data_nseg, ahc_name(ahc), "shared data") < 0)
|
|
|
|
return (ENOMEM);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->init_level++;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Allocate SCB data now that parent_dmat is initialized */
|
|
|
|
if (ahc->scb_data->maxhscbs == 0)
|
|
|
|
if (ahcinitscbdata(ahc) != 0)
|
|
|
|
return (ENOMEM);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->qinfifo = &ahc->qoutfifo[256];
|
|
|
|
ahc->untagged_scbs = &ahc->qinfifo[256];
|
|
|
|
/* There are no untagged SCBs active yet. */
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
ahc->untagged_scbs[i] = SCB_LIST_NULL;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* All of our queues are empty */
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
ahc->qoutfifo[i] = SCB_LIST_NULL;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap, 0,
|
|
|
|
driver_data_size, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1998-03-16 18:36:17 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Allocate a tstate to house information for our
|
|
|
|
* initiator presence on the bus as well as the user
|
|
|
|
* data for any target mode initiator.
|
1998-03-16 18:36:17 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_alloc_tstate(ahc, ahc->our_id, 'A') == NULL) {
|
|
|
|
printf("%s: unable to allocate tmode_tstate. "
|
|
|
|
"Failing attach\n", ahc_name(ahc));
|
|
|
|
return (-1);
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
if ((ahc->features & AHC_TWIN) != 0) {
|
|
|
|
if (ahc_alloc_tstate(ahc, ahc->our_id_b, 'B') == NULL) {
|
|
|
|
printf("%s: unable to allocate tmode_tstate. "
|
|
|
|
"Failing attach\n", ahc_name(ahc));
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
printf("Twin Channel, A SCSI Id=%d, B SCSI Id=%d, primary %c, ",
|
|
|
|
ahc->our_id, ahc->our_id_b,
|
|
|
|
ahc->flags & AHC_CHANNEL_B_PRIMARY? 'B': 'A');
|
|
|
|
} else {
|
|
|
|
if ((ahc->features & AHC_WIDE) != 0) {
|
|
|
|
printf("Wide ");
|
|
|
|
} else {
|
|
|
|
printf("Single ");
|
|
|
|
}
|
|
|
|
printf("Channel %c, SCSI Id=%d, ", ahc->channel, ahc->our_id);
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
ahc_outb(ahc, SEQ_FLAGS, 0);
|
|
|
|
|
|
|
|
if (ahc->scb_data->maxhscbs < AHC_SCB_MAX) {
|
|
|
|
ahc->flags |= AHC_PAGESCBS;
|
|
|
|
printf("%d/%d SCBs\n", ahc->scb_data->maxhscbs, AHC_SCB_MAX);
|
|
|
|
} else {
|
|
|
|
ahc->flags &= ~AHC_PAGESCBS;
|
|
|
|
printf("%d SCBs\n", ahc->scb_data->maxhscbs);
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_debug & AHC_SHOWMISC) {
|
2001-09-22 03:54:57 +04:00
|
|
|
printf("%s: hardware scb %lu bytes; kernel scb %lu bytes; "
|
|
|
|
"ahc_dma %lu bytes\n",
|
1996-05-16 07:59:03 +04:00
|
|
|
ahc_name(ahc),
|
2001-09-22 03:54:57 +04:00
|
|
|
(unsigned long) sizeof(struct hardware_scb),
|
|
|
|
(unsigned long) sizeof(struct scb),
|
|
|
|
(unsigned long) sizeof(struct ahc_dma_seg));
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
#endif /* AHC_DEBUG */
|
|
|
|
|
|
|
|
/* Set the SCSI Id, SXFRCTL0, SXFRCTL1, and SIMODE1, for both channels*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->features & AHC_TWIN) {
|
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
|
|
|
* The device is gated to channel B after a chip reset,
|
|
|
|
* so set those values first
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
term = (ahc->flags & AHC_TERM_ENB_B) != 0 ? STPWEN : 0;
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0)
|
|
|
|
ahc_outb(ahc, SCSIID_ULTRA2, ahc->our_id_b);
|
1996-05-16 07:59:03 +04:00
|
|
|
else
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCSIID, ahc->our_id_b);
|
|
|
|
scsi_conf = ahc_inb(ahc, SCSICONF + 1);
|
|
|
|
ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
|
|
|
|
|term|ENSTIMER|ACTNEGEN);
|
|
|
|
ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
|
|
|
|
ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scsi_conf & RESET_SCSI) != 0
|
|
|
|
&& (ahc->flags & AHC_INITIATORMODE) != 0)
|
|
|
|
ahc->flags |= AHC_RESET_BUS_B;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/* Select Channel A */
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~SELBUSB);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
term = (ahc->flags & AHC_TERM_ENB_A) != 0 ? STPWEN : 0;
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0)
|
|
|
|
ahc_outb(ahc, SCSIID_ULTRA2, ahc->our_id);
|
|
|
|
else
|
|
|
|
ahc_outb(ahc, SCSIID, ahc->our_id);
|
|
|
|
scsi_conf = ahc_inb(ahc, SCSICONF);
|
|
|
|
ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL))
|
|
|
|
|term
|
|
|
|
|ENSTIMER|ACTNEGEN);
|
|
|
|
ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR);
|
|
|
|
ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN);
|
|
|
|
|
|
|
|
if ((scsi_conf & RESET_SCSI) != 0
|
|
|
|
&& (ahc->flags & AHC_INITIATORMODE) != 0)
|
|
|
|
ahc->flags |= AHC_RESET_BUS_A;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
|
|
|
* Look at the information that board initialization or
|
2000-03-15 05:08:28 +03:00
|
|
|
* the board bios has left us.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-06-30 03:12:19 +04:00
|
|
|
ultraenb = 0;
|
2000-03-15 05:08:28 +03:00
|
|
|
tagenable = ALL_TARGETS_MASK;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/* Grab the disconnection disable table and invert it for our needs */
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->flags & AHC_USEDEFAULTS) {
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: Host Adapter Bios disabled. Using default SCSI "
|
1996-05-16 07:59:03 +04:00
|
|
|
"device parameters\n", ahc_name(ahc));
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B|
|
|
|
|
AHC_TERM_ENB_A|AHC_TERM_ENB_B;
|
|
|
|
discenable = ALL_TARGETS_MASK;
|
|
|
|
if ((ahc->features & AHC_ULTRA) != 0)
|
|
|
|
ultraenb = ALL_TARGETS_MASK;
|
|
|
|
} else {
|
|
|
|
discenable = ~((ahc_inb(ahc, DISC_DSB + 1) << 8)
|
|
|
|
| ahc_inb(ahc, DISC_DSB));
|
|
|
|
if ((ahc->features & (AHC_ULTRA|AHC_ULTRA2)) != 0)
|
|
|
|
ultraenb = (ahc_inb(ahc, ULTRA_ENB + 1) << 8)
|
|
|
|
| ahc_inb(ahc, ULTRA_ENB);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
|
1996-05-16 07:59:03 +04:00
|
|
|
max_targ = 7;
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
for (i = 0; i <= max_targ; i++) {
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
u_int our_id;
|
|
|
|
u_int target_id;
|
|
|
|
char channel;
|
|
|
|
|
|
|
|
channel = 'A';
|
|
|
|
our_id = ahc->our_id;
|
|
|
|
target_id = i;
|
|
|
|
if (i > 7 && (ahc->features & AHC_TWIN) != 0) {
|
|
|
|
channel = 'B';
|
|
|
|
our_id = ahc->our_id_b;
|
|
|
|
target_id = i % 8;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
tinfo = ahc_fetch_transinfo(ahc, channel, our_id,
|
|
|
|
target_id, &tstate);
|
|
|
|
/* Default to async narrow across the board */
|
2001-07-07 20:13:44 +04:00
|
|
|
memset(tinfo, 0, sizeof(*tinfo));
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc->flags & AHC_USEDEFAULTS) {
|
|
|
|
if ((ahc->features & AHC_WIDE) != 0)
|
|
|
|
tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These will be truncated when we determine the
|
|
|
|
* connection type we have with the target.
|
|
|
|
*/
|
|
|
|
tinfo->user.period = ahc_syncrates->period;
|
|
|
|
tinfo->user.offset = ~0;
|
|
|
|
} else {
|
|
|
|
u_int scsirate;
|
|
|
|
u_int16_t mask;
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/* Take the settings leftover in scratch RAM. */
|
2000-03-15 05:08:28 +03:00
|
|
|
scsirate = ahc_inb(ahc, TARG_SCSIRATE + i);
|
|
|
|
mask = (0x01 << i);
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0) {
|
|
|
|
u_int offset;
|
|
|
|
u_int maxsync;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scsirate & SOFS) == 0x0F) {
|
|
|
|
/*
|
|
|
|
* Haven't negotiated yet,
|
|
|
|
* so the format is different.
|
|
|
|
*/
|
|
|
|
scsirate = (scsirate & SXFR) >> 4
|
|
|
|
| (ultraenb & mask)
|
|
|
|
? 0x08 : 0x0
|
|
|
|
| (scsirate & WIDEXFER);
|
|
|
|
offset = MAX_OFFSET_ULTRA2;
|
|
|
|
} else
|
|
|
|
offset = ahc_inb(ahc, TARG_OFFSET + i);
|
|
|
|
maxsync = AHC_SYNCRATE_ULTRA2;
|
|
|
|
if ((ahc->features & AHC_DT) != 0)
|
|
|
|
maxsync = AHC_SYNCRATE_DT;
|
|
|
|
tinfo->user.period =
|
|
|
|
ahc_find_period(ahc, scsirate, maxsync);
|
|
|
|
if (offset == 0)
|
|
|
|
tinfo->user.period = 0;
|
|
|
|
else
|
|
|
|
tinfo->user.offset = ~0;
|
|
|
|
} else if ((scsirate & SOFS) != 0) {
|
2000-06-30 03:12:19 +04:00
|
|
|
tinfo->user.period =
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_find_period(ahc, scsirate,
|
|
|
|
(ultraenb & mask)
|
|
|
|
? AHC_SYNCRATE_ULTRA
|
|
|
|
: AHC_SYNCRATE_FAST);
|
|
|
|
if (tinfo->user.period != 0)
|
|
|
|
tinfo->user.offset = ~0;
|
1996-07-11 02:50:44 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scsirate & WIDEXFER) != 0
|
|
|
|
&& (ahc->features & AHC_WIDE) != 0)
|
|
|
|
tinfo->user.width = MSG_EXT_WDTR_BUS_16_BIT;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
tinfo->goal = tinfo->user; /* force negotiation */
|
|
|
|
tstate->ultraenb = ultraenb;
|
|
|
|
tstate->discenable = discenable;
|
|
|
|
tstate->tagenable = 0; /* Wait until the XPT says its okay */
|
2000-05-23 01:14:24 +04:00
|
|
|
tstate->tagdisable = 0;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->user_discenable = discenable;
|
|
|
|
ahc->user_tagenable = tagenable;
|
1996-07-11 02:50:44 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Tell the sequencer where it can find our arrays in memory.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
physaddr = ahc->scb_data->hscb_busaddr;
|
|
|
|
ahc_outb(ahc, HSCB_ADDR, physaddr & 0xFF);
|
|
|
|
ahc_outb(ahc, HSCB_ADDR + 1, (physaddr >> 8) & 0xFF);
|
|
|
|
ahc_outb(ahc, HSCB_ADDR + 2, (physaddr >> 16) & 0xFF);
|
|
|
|
ahc_outb(ahc, HSCB_ADDR + 3, (physaddr >> 24) & 0xFF);
|
|
|
|
|
|
|
|
physaddr = ahc->shared_data_busaddr;
|
|
|
|
ahc_outb(ahc, SCBID_ADDR, physaddr & 0xFF);
|
|
|
|
ahc_outb(ahc, SCBID_ADDR + 1, (physaddr >> 8) & 0xFF);
|
|
|
|
ahc_outb(ahc, SCBID_ADDR + 2, (physaddr >> 16) & 0xFF);
|
|
|
|
ahc_outb(ahc, SCBID_ADDR + 3, (physaddr >> 24) & 0xFF);
|
|
|
|
|
|
|
|
/* Target mode incomding command fifo */
|
|
|
|
physaddr += 3 * 256 * sizeof(u_int8_t);
|
|
|
|
ahc_outb(ahc, TMODE_CMDADDR, physaddr & 0xFF);
|
|
|
|
ahc_outb(ahc, TMODE_CMDADDR + 1, (physaddr >> 8) & 0xFF);
|
|
|
|
ahc_outb(ahc, TMODE_CMDADDR + 2, (physaddr >> 16) & 0xFF);
|
|
|
|
ahc_outb(ahc, TMODE_CMDADDR + 3, (physaddr >> 24) & 0xFF);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Initialize the group code to command length table.
|
|
|
|
* This overrides the values in TARG_SCSIRATE, so only
|
|
|
|
* setup the table after we have processed that information.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE, 5);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 1, 9);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 2, 9);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 3, 0);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 4, 15);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 5, 11);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 6, 0);
|
|
|
|
ahc_outb(ahc, CMDSIZE_TABLE + 7, 0);
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* Tell the sequencer of our initial queue positions */
|
|
|
|
ahc_outb(ahc, KERNEL_QINPOS, 0);
|
|
|
|
ahc_outb(ahc, QINPOS, 0);
|
|
|
|
ahc_outb(ahc, QOUTPOS, 0);
|
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWMISC)
|
|
|
|
printf("DISCENABLE == 0x%x\nULTRAENB == 0x%x\n",
|
|
|
|
discenable, ultraenb);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Don't have any special messages to send to targets */
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST, 0);
|
|
|
|
ahc_outb(ahc, TARGET_MSG_REQUEST + 1, 0);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Use the built in queue management registers
|
|
|
|
* if they are available.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((ahc->features & AHC_QUEUE_REGS) != 0) {
|
|
|
|
ahc_outb(ahc, QOFF_CTLSTA, SCB_QSIZE_256);
|
|
|
|
ahc_outb(ahc, SDSCB_QOFF, 0);
|
|
|
|
ahc_outb(ahc, SNSCB_QOFF, 0);
|
|
|
|
ahc_outb(ahc, HNSCB_QOFF, 0);
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/* We don't have any waiting selections */
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, WAITING_SCBH, SCB_LIST_NULL);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/* Our disconnection list is empty too */
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, DISCONNECTED_SCBH, SCB_LIST_NULL);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/* Message out buffer starts empty */
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, MSG_OUT, MSG_NOOP);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup the allowed SCSI Sequences based on operational mode.
|
2000-06-30 03:12:19 +04:00
|
|
|
* If we are a target, we'll enable select in operations once
|
2000-03-15 05:08:28 +03:00
|
|
|
* we've had a lun enabled.
|
|
|
|
*/
|
|
|
|
scsiseq_template = ENSELO|ENAUTOATNO|ENAUTOATNP;
|
|
|
|
if ((ahc->flags & AHC_INITIATORMODE) != 0)
|
|
|
|
scsiseq_template |= ENRSELI;
|
|
|
|
ahc_outb(ahc, SCSISEQ_TEMPLATE, scsiseq_template);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
1996-05-16 07:59:03 +04:00
|
|
|
* Load the Sequencer program and Enable the adapter
|
|
|
|
* in "fast" mode.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
printf("%s: Downloading Sequencer Program...",
|
|
|
|
ahc_name(ahc));
|
1996-08-29 03:39:40 +04:00
|
|
|
#endif
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
ahc_loadseq(ahc);
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/* We have to wait until after any system dumps... */
|
|
|
|
shutdownhook_establish(ahc_shutdown, ahc);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2000-05-28 01:58:15 +04:00
|
|
|
static int
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_ioctl(struct scsipi_channel *channel, u_long cmd, caddr_t addr, int flag,
|
2000-05-28 01:58:15 +04:00
|
|
|
struct proc *p)
|
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct ahc_softc *ahc = (void *)channel->chan_adapter->adapt_dev;
|
2000-05-28 01:58:15 +04:00
|
|
|
int s, ret = ENOTTY;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SCBUSIORESET:
|
|
|
|
s = splbio();
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_reset_channel(ahc, channel->chan_channel == 1 ? 'B' : 'A',
|
|
|
|
TRUE);
|
2000-05-28 01:58:15 +04:00
|
|
|
splx(s);
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
default:
|
2001-02-24 03:01:22 +03:00
|
|
|
break;
|
2000-05-28 01:58:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* XXX fvdl the busy_tcl checks and settings should only be done
|
|
|
|
* for the non-tagged queueing case, but we don't do tagged queueing
|
|
|
|
* yet, so..
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
static void
|
|
|
|
ahc_action(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
struct scsipi_periph *periph;
|
|
|
|
struct ahc_softc *ahc = (void *)chan->chan_adapter->adapt_dev;
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb *scb;
|
2000-06-30 03:12:19 +04:00
|
|
|
struct hardware_scb *hscb;
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
u_int target_id;
|
|
|
|
u_int our_id;
|
|
|
|
int s, tcl;
|
|
|
|
u_int16_t mask;
|
2000-05-28 01:58:15 +04:00
|
|
|
char channel;
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
switch (req) {
|
|
|
|
case ADAPTER_REQ_RUN_XFER:
|
|
|
|
xs = arg;
|
|
|
|
periph = xs->xs_periph;
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2001-06-26 16:19:49 +04:00
|
|
|
SC_DEBUG(xs->xs_periph, SCSIPI_DB3, ("ahc_action\n"));
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
/* must protect the queue */
|
|
|
|
s = splbio();
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
tcl = XS_TCL(ahc, xs);
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
if (!ahc_istagged_device(ahc, xs, 0) &&
|
|
|
|
ahc_index_busy_tcl(ahc, tcl, FALSE) != SCB_LIST_NULL) {
|
|
|
|
panic("ahc_action: not tagged and device busy");
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
target_id = periph->periph_target;
|
|
|
|
our_id = SIM_SCSI_ID(ahc, periph);
|
1996-12-02 22:06:41 +03:00
|
|
|
|
|
|
|
/*
|
2001-04-25 21:53:04 +04:00
|
|
|
* get an scb to use.
|
1996-12-02 22:06:41 +03:00
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
if ((scb = ahcgetscb(ahc)) == NULL) {
|
|
|
|
xs->error = XS_RESOURCE_SHORTAGE;
|
|
|
|
scsipi_done(xs);
|
1996-12-02 22:06:41 +03:00
|
|
|
splx(s);
|
2001-04-25 21:53:04 +04:00
|
|
|
return;
|
1996-12-02 22:06:41 +03:00
|
|
|
}
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
tcl = XS_TCL(ahc, xs);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (!ahc_istagged_device(ahc, xs, 0) &&
|
|
|
|
ahc_index_busy_tcl(ahc, tcl, FALSE) != SCB_LIST_NULL)
|
|
|
|
panic("ahc: queuing for busy target");
|
|
|
|
#endif
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
scb->xs = xs;
|
|
|
|
hscb = scb->hscb;
|
|
|
|
hscb->tcl = tcl;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
if (xs->xs_tag_type) {
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (ahc_istagged_device(ahc, xs, 0) == 0)
|
|
|
|
panic("ahc_action: taggged command for untagged device");
|
|
|
|
#endif
|
|
|
|
scb->hscb->control |= TAG_ENB;
|
|
|
|
} else
|
|
|
|
ahc_busy_tcl(ahc, scb);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
splx(s);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
channel = SIM_CHANNEL(ahc, periph);
|
|
|
|
if (ahc->inited_channels[channel - 'A'] == 0) {
|
|
|
|
if ((channel == 'A' &&
|
|
|
|
(ahc->flags & AHC_RESET_BUS_A)) ||
|
|
|
|
(channel == 'B' &&
|
|
|
|
(ahc->flags & AHC_RESET_BUS_B))) {
|
|
|
|
s = splbio();
|
|
|
|
ahc_reset_channel(ahc, channel, TRUE);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
ahc->inited_channels[channel - 'A'] = 1;
|
1996-12-02 22:06:41 +03:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
2001-04-25 21:53:04 +04:00
|
|
|
* Put all the arguments for the xfer in the scb
|
2000-03-15 05:08:28 +03:00
|
|
|
*/
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
mask = SCB_TARGET_MASK(scb);
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc,
|
|
|
|
SIM_CHANNEL(ahc, periph),
|
|
|
|
our_id, target_id, &tstate);
|
|
|
|
if (ahc->inited_targets[target_id] == 0) {
|
|
|
|
struct ahc_devinfo devinfo;
|
2000-05-30 00:13:53 +04:00
|
|
|
s = splbio();
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_compile_devinfo(&devinfo, our_id, target_id,
|
|
|
|
periph->periph_lun,
|
|
|
|
SIM_CHANNEL(ahc, periph),
|
|
|
|
ROLE_INITIATOR);
|
|
|
|
ahc_update_target_msg_request(ahc, &devinfo, tinfo,
|
|
|
|
TRUE, FALSE);
|
|
|
|
ahc->inited_targets[target_id] = 1;
|
2000-05-30 00:13:53 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
hscb->scsirate = tinfo->scsirate;
|
|
|
|
hscb->scsioffset = tinfo->current.offset;
|
|
|
|
if ((tstate->ultraenb & mask) != 0)
|
|
|
|
hscb->control |= ULTRAENB;
|
|
|
|
|
|
|
|
if ((tstate->discenable & mask) != 0)
|
|
|
|
hscb->control |= DISCENB;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
if (xs->xs_control & XS_CTL_RESET) {
|
|
|
|
hscb->cmdpointer = 0;
|
|
|
|
scb->flags |= SCB_DEVICE_RESET;
|
|
|
|
hscb->control |= MK_MESSAGE;
|
|
|
|
ahc_execute_scb(scb, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ahc_setup_data(ahc, xs, scb);
|
|
|
|
return;
|
|
|
|
case ADAPTER_REQ_GROW_RESOURCES:
|
|
|
|
/* XXX not supported */
|
|
|
|
return;
|
|
|
|
case ADAPTER_REQ_SET_XFER_MODE:
|
|
|
|
{
|
|
|
|
struct scsipi_xfer_mode *xm = arg;
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_devinfo devinfo;
|
2001-04-25 21:53:04 +04:00
|
|
|
int target_id, our_id;
|
|
|
|
char channel;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
target_id = xm->xm_target;
|
|
|
|
our_id = chan->chan_id;
|
|
|
|
channel = (chan->chan_channel == 1) ? 'B' : 'A';
|
2000-03-15 05:08:28 +03:00
|
|
|
s = splbio();
|
2001-04-25 21:53:04 +04:00
|
|
|
tinfo = ahc_fetch_transinfo(ahc, channel, our_id, target_id,
|
|
|
|
&tstate);
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_compile_devinfo(&devinfo, our_id, target_id,
|
2001-04-25 21:53:04 +04:00
|
|
|
0, channel, ROLE_INITIATOR);
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc->inited_targets[target_id] = 2;
|
2001-04-25 21:53:04 +04:00
|
|
|
if (xm->xm_mode & PERIPH_CAP_TQING &&
|
|
|
|
(tstate->tagdisable & devinfo.target_mask) == 0) {
|
|
|
|
ahc_set_tags(ahc, &devinfo, TRUE);
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
splx(s);
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc_update_xfer_mode(ahc, &devinfo);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments)
|
|
|
|
{
|
|
|
|
struct scb *scb;
|
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
struct ahc_softc *ahc;
|
|
|
|
int s;
|
|
|
|
|
|
|
|
scb = (struct scb *)arg;
|
|
|
|
xs = scb->xs;
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc = (void *)xs->xs_periph->periph_channel->chan_adapter->adapt_dev;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
if (nsegments != 0) {
|
|
|
|
struct ahc_dma_seg *sg;
|
|
|
|
bus_dma_segment_t *end_seg;
|
|
|
|
int op;
|
|
|
|
|
|
|
|
end_seg = dm_segs + nsegments;
|
|
|
|
|
|
|
|
/* Copy the first SG into the data pointer area */
|
|
|
|
scb->hscb->data = dm_segs->ds_addr;
|
|
|
|
scb->hscb->datalen = dm_segs->ds_len;
|
|
|
|
|
|
|
|
/* Copy the segments into our SG list */
|
|
|
|
sg = scb->sg_list;
|
|
|
|
while (dm_segs < end_seg) {
|
|
|
|
sg->addr = dm_segs->ds_addr;
|
|
|
|
sg->len = dm_segs->ds_len;
|
|
|
|
ahc_swap_sg(sg);
|
|
|
|
sg++;
|
|
|
|
dm_segs++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note where to find the SG entries in bus space */
|
|
|
|
scb->hscb->SG_pointer = scb->sg_list_phys;
|
|
|
|
|
|
|
|
if (xs->xs_control & XS_CTL_DATA_IN)
|
|
|
|
op = BUS_DMASYNC_PREREAD;
|
1998-12-09 11:37:50 +03:00
|
|
|
else
|
2000-03-15 05:08:28 +03:00
|
|
|
op = BUS_DMASYNC_PREWRITE;
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
bus_dmamap_sync(ahc->parent_dmat, scb->dmamap, 0,
|
|
|
|
scb->dmamap->dm_mapsize, op);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
scb->hscb->SG_pointer = 0;
|
|
|
|
scb->hscb->data = 0;
|
|
|
|
scb->hscb->datalen = 0;
|
1996-07-11 02:50:44 +04:00
|
|
|
}
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->sg_count = scb->hscb->SG_count = nsegments;
|
1996-12-02 22:06:41 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
s = splbio();
|
1996-12-02 22:06:41 +03:00
|
|
|
|
1996-07-11 02:50:44 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Last time we need to check if this SCB needs to
|
|
|
|
* be aborted.
|
1996-07-11 02:50:44 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if (xs->xs_status & XS_STS_DONE) {
|
2000-05-25 15:41:05 +04:00
|
|
|
if (!ahc_istagged_device(ahc, xs, 0))
|
2000-03-25 22:52:12 +03:00
|
|
|
ahc_index_busy_tcl(ahc, scb->hscb->tcl, TRUE);
|
2000-03-15 05:08:28 +03:00
|
|
|
if (nsegments != 0)
|
|
|
|
bus_dmamap_unload(ahc->parent_dmat, scb->dmamap);
|
|
|
|
ahcfreescb(ahc, scb);
|
|
|
|
splx(s);
|
2001-04-25 21:53:04 +04:00
|
|
|
return;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (scb->sg_count > 255)
|
|
|
|
panic("ahc bad sg_count");
|
1998-04-16 11:12:43 +04:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_swap_hscb(scb->hscb);
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
LIST_INSERT_HEAD(&ahc->pending_ccbs, scb, plinks);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->flags |= SCB_ACTIVE;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (!(xs->xs_control & XS_CTL_POLL))
|
2002-04-05 22:27:45 +04:00
|
|
|
callout_reset(&scb->xs->xs_callout, mstohz(xs->timeout),
|
2000-03-23 10:01:25 +03:00
|
|
|
ahc_timeout, scb);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
|
|
|
|
#if 0
|
|
|
|
printf("Continueing Immediate Command %d:%d\n",
|
2001-04-25 21:53:04 +04:00
|
|
|
xs->xs_periph->periph_target,
|
|
|
|
xs->xs_periph->periph_lun);
|
1998-03-16 18:36:17 +03:00
|
|
|
#endif
|
2000-03-15 05:08:28 +03:00
|
|
|
pause_sequencer(ahc);
|
|
|
|
if ((ahc->flags & AHC_PAGESCBS) == 0)
|
|
|
|
ahc_outb(ahc, SCBPTR, scb->hscb->tag);
|
|
|
|
ahc_outb(ahc, SCB_TAG, scb->hscb->tag);
|
|
|
|
ahc_outb(ahc, RETURN_1, CONT_MSG_LOOP);
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
} else {
|
1998-03-16 18:36:17 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#if 0
|
|
|
|
printf("tag %x at qpos %u vaddr %p paddr 0x%lx\n",
|
|
|
|
scb->hscb->tag, ahc->qinfifonext,
|
|
|
|
&ahc->qinfifo[ahc->qinfifonext],
|
|
|
|
ahc->shared_data_busaddr + 1024 + ahc->qinfifonext);
|
1996-05-16 07:59:03 +04:00
|
|
|
#endif
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
|
|
|
|
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap,
|
|
|
|
QINFIFO_OFFSET * 256, 256, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
if ((ahc->features & AHC_QUEUE_REGS) != 0) {
|
|
|
|
ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext);
|
|
|
|
} else {
|
|
|
|
pause_sequencer(ahc);
|
|
|
|
ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext);
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
#ifdef AHC_DEBUG
|
2000-03-15 05:08:28 +03:00
|
|
|
if (ahc_debug & AHC_SHOWCMDS) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsi_print_addr(xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("opcode %d tag %x len %d flags %x control %x fpos %u"
|
|
|
|
" rate %x\n",
|
|
|
|
xs->cmdstore.opcode, scb->hscb->tag, scb->hscb->datalen,
|
|
|
|
scb->flags, scb->hscb->control, ahc->qinfifonext,
|
|
|
|
scb->hscb->scsirate);
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
#endif
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if (!(xs->xs_control & XS_CTL_POLL)) {
|
1996-05-16 07:59:03 +04:00
|
|
|
splx(s);
|
2001-04-25 21:53:04 +04:00
|
|
|
return;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
/*
|
1996-05-16 07:59:03 +04:00
|
|
|
* If we can't use interrupts, poll for completion
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2001-06-26 16:19:49 +04:00
|
|
|
SC_DEBUG(xs->xs_periph, SCSIPI_DB3, ("cmd_poll\n"));
|
1996-05-16 07:59:03 +04:00
|
|
|
do {
|
|
|
|
if (ahc_poll(ahc, xs->timeout)) {
|
1999-10-01 03:04:39 +04:00
|
|
|
if (!(xs->xs_control & XS_CTL_SILENT))
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("cmd fail\n");
|
1995-10-09 12:49:30 +03:00
|
|
|
ahc_timeout(scb);
|
1996-05-16 07:59:03 +04:00
|
|
|
break;
|
|
|
|
}
|
1999-10-01 03:04:39 +04:00
|
|
|
} while (!(xs->xs_status & XS_STS_DONE));
|
2000-03-15 05:08:28 +03:00
|
|
|
splx(s);
|
2001-04-25 21:53:04 +04:00
|
|
|
return;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static int
|
|
|
|
ahc_poll(struct ahc_softc *ahc, int wait)
|
|
|
|
{
|
|
|
|
while (--wait) {
|
|
|
|
DELAY(1000);
|
|
|
|
if (ahc_inb(ahc, INTSTAT) & INT_PEND)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wait == 0) {
|
|
|
|
printf("%s: board is not responding\n", ahc_name(ahc));
|
|
|
|
return (EIO);
|
|
|
|
}
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_intr((void *)ahc);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_setup_data(struct ahc_softc *ahc, struct scsipi_xfer *xs,
|
|
|
|
struct scb *scb)
|
|
|
|
{
|
|
|
|
struct hardware_scb *hscb;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
hscb = scb->hscb;
|
|
|
|
xs->resid = xs->status = 0;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
hscb->cmdlen = xs->cmdlen;
|
|
|
|
memcpy(hscb->cmdstore, xs->cmd, xs->cmdlen);
|
|
|
|
hscb->cmdpointer = hscb->cmdstore_busaddr;
|
|
|
|
|
|
|
|
/* Only use S/G if there is a transfer */
|
|
|
|
if (xs->datalen) {
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = bus_dmamap_load(ahc->parent_dmat,
|
|
|
|
scb->dmamap, xs->data,
|
|
|
|
xs->datalen, NULL,
|
2001-03-08 02:07:12 +03:00
|
|
|
((xs->xs_control & XS_CTL_NOSLEEP) ?
|
|
|
|
BUS_DMA_NOWAIT : BUS_DMA_WAITOK) |
|
2001-07-19 20:25:23 +04:00
|
|
|
BUS_DMA_STREAMING |
|
|
|
|
((xs->xs_control & XS_CTL_DATA_IN) ?
|
|
|
|
BUS_DMA_READ : BUS_DMA_WRITE));
|
2000-03-15 05:08:28 +03:00
|
|
|
if (error) {
|
2001-09-22 03:54:57 +04:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
printf("%s: in ahc_setup_data(): bus_dmamap_load() "
|
|
|
|
"= %d\n",
|
|
|
|
ahc_name(ahc),
|
|
|
|
error);
|
|
|
|
#endif
|
2000-05-25 15:41:05 +04:00
|
|
|
if (!ahc_istagged_device(ahc, xs, 0))
|
2000-03-25 22:52:12 +03:00
|
|
|
ahc_index_busy_tcl(ahc, hscb->tcl, TRUE);
|
2001-04-25 21:53:04 +04:00
|
|
|
xs->error = XS_RESOURCE_SHORTAGE; /* XXX fvdl */
|
|
|
|
scsipi_done(xs);
|
|
|
|
return;
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_execute_scb(scb,
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->dmamap->dm_segs,
|
|
|
|
scb->dmamap->dm_nsegs);
|
|
|
|
} else {
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_execute_scb(scb, NULL, 0);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_freeze_devq(struct ahc_softc *ahc, struct scsipi_periph *periph)
|
2000-03-15 05:08:28 +03:00
|
|
|
{
|
|
|
|
int target;
|
|
|
|
char channel;
|
|
|
|
int lun;
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
target = periph->periph_target;
|
|
|
|
lun = periph->periph_lun;
|
|
|
|
channel = periph->periph_channel->chan_channel;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_search_qinfifo(ahc, target, channel, lun,
|
|
|
|
/*tag*/SCB_LIST_NULL, ROLE_UNKNOWN,
|
|
|
|
SCB_REQUEUE, SEARCH_COMPLETE);
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahcallocscbs(struct ahc_softc *ahc)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb_data *scb_data;
|
|
|
|
struct scb *next_scb;
|
|
|
|
struct sg_map_node *sg_map;
|
|
|
|
bus_addr_t physaddr;
|
|
|
|
struct ahc_dma_seg *segs;
|
|
|
|
int newcount;
|
|
|
|
int i;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb_data = ahc->scb_data;
|
|
|
|
if (scb_data->numscbs >= AHC_SCB_MAX)
|
|
|
|
/* Can't allocate any more */
|
|
|
|
return;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
next_scb = &scb_data->scbarray[scb_data->numscbs];
|
1996-07-11 02:50:44 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
sg_map = malloc(sizeof(*sg_map), M_DEVBUF, M_NOWAIT);
|
|
|
|
|
|
|
|
if (sg_map == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ahc_createdmamem(ahc->parent_dmat, PAGE_SIZE, ahc->sc_dmaflags,
|
|
|
|
&sg_map->sg_dmamap,
|
|
|
|
(caddr_t *)&sg_map->sg_vaddr, &sg_map->sg_physaddr,
|
|
|
|
&sg_map->sg_dmasegs, &sg_map->sg_nseg, ahc_name(ahc),
|
|
|
|
"SG space") < 0) {
|
|
|
|
free(sg_map, M_DEVBUF);
|
|
|
|
return;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
SLIST_INSERT_HEAD(&scb_data->sg_maps, sg_map, links);
|
|
|
|
|
|
|
|
segs = sg_map->sg_vaddr;
|
|
|
|
physaddr = sg_map->sg_physaddr;
|
|
|
|
|
|
|
|
newcount = (PAGE_SIZE / (AHC_NSEG * sizeof(struct ahc_dma_seg)));
|
|
|
|
for (i = 0; scb_data->numscbs < AHC_SCB_MAX && i < newcount; i++) {
|
|
|
|
int error;
|
|
|
|
|
|
|
|
next_scb->sg_list = segs;
|
|
|
|
/*
|
|
|
|
* The sequencer always starts with the second entry.
|
|
|
|
* The first entry is embedded in the scb.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
next_scb->sg_list_phys = physaddr + sizeof(struct ahc_dma_seg);
|
|
|
|
next_scb->flags = SCB_FREE;
|
|
|
|
error = bus_dmamap_create(ahc->parent_dmat,
|
|
|
|
AHC_MAXTRANSFER_SIZE, AHC_NSEG, MAXBSIZE, 0,
|
|
|
|
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW|ahc->sc_dmaflags,
|
|
|
|
&next_scb->dmamap);
|
|
|
|
if (error != 0)
|
|
|
|
break;
|
|
|
|
next_scb->hscb = &scb_data->hscbs[scb_data->numscbs];
|
|
|
|
next_scb->hscb->tag = ahc->scb_data->numscbs;
|
2000-06-30 03:12:19 +04:00
|
|
|
next_scb->hscb->cmdstore_busaddr =
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_hscb_busaddr(ahc, next_scb->hscb->tag)
|
2000-06-30 03:12:19 +04:00
|
|
|
+ offsetof(struct hardware_scb, cmdstore);
|
2000-03-15 05:08:28 +03:00
|
|
|
next_scb->hscb->cmdstore_busaddr =
|
|
|
|
htole32(next_scb->hscb->cmdstore_busaddr);
|
|
|
|
SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, next_scb, links);
|
|
|
|
segs += AHC_NSEG;
|
|
|
|
physaddr += (AHC_NSEG * sizeof(struct ahc_dma_seg));
|
|
|
|
next_scb++;
|
|
|
|
ahc->scb_data->numscbs++;
|
|
|
|
}
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWSCBALLOC)
|
|
|
|
printf("%s: allocated %d new SCBs count now %d\n",
|
|
|
|
ahc_name(ahc), i - 1, ahc->scb_data->numscbs);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef AHC_DUMP_SEQ
|
|
|
|
static void
|
|
|
|
ahc_dumpseq(struct ahc_softc* ahc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int max_prog;
|
|
|
|
|
|
|
|
if ((ahc->chip & AHC_BUS_MASK) < AHC_PCI)
|
|
|
|
max_prog = 448;
|
|
|
|
else if ((ahc->features & AHC_ULTRA2) != 0)
|
|
|
|
max_prog = 768;
|
|
|
|
else
|
|
|
|
max_prog = 512;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
|
|
|
|
ahc_outb(ahc, SEQADDR0, 0);
|
|
|
|
ahc_outb(ahc, SEQADDR1, 0);
|
|
|
|
for (i = 0; i < max_prog; i++) {
|
|
|
|
u_int8_t ins_bytes[4];
|
|
|
|
|
|
|
|
ahc_insb(ahc, SEQRAM, ins_bytes, 4);
|
|
|
|
printf("0x%08x\n", ins_bytes[0] << 24
|
|
|
|
| ins_bytes[1] << 16
|
|
|
|
| ins_bytes[2] << 8
|
|
|
|
| ins_bytes[3]);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_loadseq(struct ahc_softc *ahc)
|
|
|
|
{
|
2001-01-22 17:30:43 +03:00
|
|
|
const struct patch *cur_patch;
|
2000-03-15 05:08:28 +03:00
|
|
|
int i;
|
|
|
|
int downloaded;
|
|
|
|
int skip_addr;
|
|
|
|
u_int8_t download_consts[4];
|
|
|
|
|
|
|
|
/* Setup downloadable constant table */
|
|
|
|
#if 0
|
|
|
|
/* No downloaded constants are currently defined. */
|
|
|
|
download_consts[TMODE_NUMCMDS] = ahc->num_targetcmds;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cur_patch = patches;
|
|
|
|
downloaded = 0;
|
|
|
|
skip_addr = 0;
|
|
|
|
ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE|LOADRAM);
|
|
|
|
ahc_outb(ahc, SEQADDR0, 0);
|
|
|
|
ahc_outb(ahc, SEQADDR1, 0);
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(seqprog)/4; i++) {
|
|
|
|
if (ahc_check_patch(ahc, &cur_patch, i, &skip_addr) == 0) {
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Don't download this instruction as it
|
|
|
|
* is in a patch that was removed.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ahc_download_instr(ahc, i, download_consts);
|
|
|
|
downloaded++;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
|
1996-07-11 02:50:44 +04:00
|
|
|
#ifdef AHC_DEBUG
|
2000-03-15 05:08:28 +03:00
|
|
|
printf(" %d instructions downloaded\n", downloaded);
|
1996-07-11 02:50:44 +04:00
|
|
|
#endif
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static int
|
2001-01-22 17:30:43 +03:00
|
|
|
ahc_check_patch(struct ahc_softc *ahc, const struct patch **start_patch,
|
2000-03-15 05:08:28 +03:00
|
|
|
int start_instr, int *skip_addr)
|
1998-03-16 18:36:17 +03:00
|
|
|
{
|
2001-01-22 17:30:43 +03:00
|
|
|
const struct patch *cur_patch;
|
|
|
|
const struct patch *last_patch;
|
2000-03-15 05:08:28 +03:00
|
|
|
int num_patches;
|
1998-03-16 18:36:17 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
num_patches = sizeof(patches)/sizeof(struct patch);
|
|
|
|
last_patch = &patches[num_patches];
|
|
|
|
cur_patch = *start_patch;
|
1998-03-16 18:36:17 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
while (cur_patch < last_patch && start_instr == cur_patch->begin) {
|
|
|
|
|
|
|
|
if (cur_patch->patch_func(ahc) == 0) {
|
|
|
|
|
|
|
|
/* Start rejecting code */
|
|
|
|
*skip_addr = start_instr + cur_patch->skip_instr;
|
|
|
|
cur_patch += cur_patch->skip_patch;
|
|
|
|
} else {
|
|
|
|
/* Accepted this patch. Advance to the next
|
|
|
|
* one and wait for our intruction pointer to
|
|
|
|
* hit this point.
|
|
|
|
*/
|
|
|
|
cur_patch++;
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
*start_patch = cur_patch;
|
|
|
|
if (start_instr < *skip_addr)
|
|
|
|
/* Still skipping */
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
1998-03-16 18:36:17 +03:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_download_instr(struct ahc_softc *ahc, int instrptr, u_int8_t *dconsts)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
union ins_formats instr;
|
|
|
|
struct ins_format1 *fmt1_ins;
|
|
|
|
struct ins_format3 *fmt3_ins;
|
|
|
|
u_int opcode;
|
|
|
|
|
|
|
|
/* Structure copy */
|
2001-04-14 23:37:17 +04:00
|
|
|
memcpy(&instr, &seqprog[instrptr * 4], sizeof instr);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
instr.integer = le32toh(instr.integer);
|
|
|
|
|
|
|
|
fmt1_ins = &instr.format1;
|
|
|
|
fmt3_ins = NULL;
|
|
|
|
|
|
|
|
/* Pull the opcode */
|
|
|
|
opcode = instr.format1.opcode;
|
|
|
|
switch (opcode) {
|
|
|
|
case AIC_OP_JMP:
|
|
|
|
case AIC_OP_JC:
|
|
|
|
case AIC_OP_JNC:
|
|
|
|
case AIC_OP_CALL:
|
|
|
|
case AIC_OP_JNE:
|
|
|
|
case AIC_OP_JNZ:
|
|
|
|
case AIC_OP_JE:
|
|
|
|
case AIC_OP_JZ:
|
|
|
|
{
|
2001-01-22 17:30:43 +03:00
|
|
|
const struct patch *cur_patch;
|
2000-03-15 05:08:28 +03:00
|
|
|
int address_offset;
|
|
|
|
u_int address;
|
|
|
|
int skip_addr;
|
|
|
|
int i;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
fmt3_ins = &instr.format3;
|
|
|
|
address_offset = 0;
|
|
|
|
address = fmt3_ins->address;
|
|
|
|
cur_patch = patches;
|
|
|
|
skip_addr = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < address;) {
|
|
|
|
|
|
|
|
ahc_check_patch(ahc, &cur_patch, i, &skip_addr);
|
|
|
|
|
|
|
|
if (skip_addr > i) {
|
|
|
|
int end_addr;
|
|
|
|
|
|
|
|
end_addr = MIN(address, skip_addr);
|
|
|
|
address_offset += end_addr - i;
|
|
|
|
i = skip_addr;
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
address -= address_offset;
|
|
|
|
fmt3_ins->address = address;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
}
|
|
|
|
case AIC_OP_OR:
|
|
|
|
case AIC_OP_AND:
|
|
|
|
case AIC_OP_XOR:
|
|
|
|
case AIC_OP_ADD:
|
|
|
|
case AIC_OP_ADC:
|
|
|
|
case AIC_OP_BMOV:
|
|
|
|
if (fmt1_ins->parity != 0) {
|
|
|
|
fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
fmt1_ins->parity = 0;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case AIC_OP_ROL:
|
|
|
|
if ((ahc->features & AHC_ULTRA2) != 0) {
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
/* Calculate odd parity for the instruction */
|
|
|
|
for (i = 0, count = 0; i < 31; i++) {
|
|
|
|
u_int32_t mask;
|
|
|
|
|
|
|
|
mask = 0x01 << i;
|
|
|
|
if ((instr.integer & mask) != 0)
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
if ((count & 0x01) == 0)
|
|
|
|
instr.format1.parity = 1;
|
|
|
|
} else {
|
|
|
|
/* Compress the instruction for older sequencers */
|
|
|
|
if (fmt3_ins != NULL) {
|
|
|
|
instr.integer =
|
|
|
|
fmt3_ins->immediate
|
|
|
|
| (fmt3_ins->source << 8)
|
|
|
|
| (fmt3_ins->address << 16)
|
|
|
|
| (fmt3_ins->opcode << 25);
|
|
|
|
} else {
|
|
|
|
instr.integer =
|
|
|
|
fmt1_ins->immediate
|
|
|
|
| (fmt1_ins->source << 8)
|
|
|
|
| (fmt1_ins->destination << 16)
|
|
|
|
| (fmt1_ins->ret << 24)
|
|
|
|
| (fmt1_ins->opcode << 25);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
instr.integer = htole32(instr.integer);
|
|
|
|
ahc_outsb(ahc, SEQRAM, instr.bytes, 4);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("Unknown opcode encountered in seq program");
|
1996-05-16 07:59:03 +04:00
|
|
|
break;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_set_recoveryscb(struct ahc_softc *ahc, struct scb *scb)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scb->flags & SCB_RECOVERY_SCB) == 0) {
|
|
|
|
struct scb *scbp;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
scb->flags |= SCB_RECOVERY_SCB;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Take all queued, but not sent SCBs out of the equation.
|
|
|
|
* Also ensure that no new CCBs are queued to us while we
|
|
|
|
* try to fix this problem.
|
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_channel_freeze(&ahc->sc_channel, 1);
|
|
|
|
if (ahc->features & AHC_TWIN)
|
|
|
|
scsipi_channel_freeze(&ahc->sc_channel_b, 1);
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Go through all of our pending SCBs and remove
|
|
|
|
* any scheduled timeouts for them. We will reschedule
|
|
|
|
* them after we've successfully fixed this problem.
|
|
|
|
*/
|
|
|
|
scbp = ahc->pending_ccbs.lh_first;
|
|
|
|
while (scbp != NULL) {
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&scbp->xs->xs_callout);
|
2000-03-15 05:08:28 +03:00
|
|
|
scbp = scbp->plinks.le_next;
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_timeout(void *arg)
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb *scb;
|
|
|
|
struct ahc_softc *ahc;
|
1996-07-11 02:50:44 +04:00
|
|
|
int s, found;
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int last_phase;
|
|
|
|
int target;
|
|
|
|
int lun;
|
|
|
|
int i;
|
1996-05-16 07:59:03 +04:00
|
|
|
char channel;
|
|
|
|
|
2000-06-30 03:12:19 +04:00
|
|
|
scb = (struct scb *)arg;
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc =
|
|
|
|
(void *)scb->xs->xs_periph->periph_channel->chan_adapter->adapt_dev;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
s = splbio();
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Ensure that the card doesn't do anything
|
|
|
|
* behind our back. Also make sure that we
|
|
|
|
* didn't "just" miss an interrupt that would
|
|
|
|
* affect this timeout.
|
|
|
|
*/
|
|
|
|
do {
|
|
|
|
ahc_intr(ahc);
|
|
|
|
pause_sequencer(ahc);
|
|
|
|
} while (ahc_inb(ahc, INTSTAT) & INT_PEND);
|
|
|
|
|
|
|
|
if ((scb->flags & SCB_ACTIVE) == 0) {
|
1996-05-16 07:59:03 +04:00
|
|
|
/* Previous timeout took care of me already */
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Timedout SCB handled by another timeout\n");
|
|
|
|
unpause_sequencer(ahc);
|
1996-05-16 07:59:03 +04:00
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
target = SCB_TARGET(scb);
|
|
|
|
channel = SCB_CHANNEL(scb);
|
|
|
|
lun = SCB_LUN(scb);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("SCB %x - timed out ", scb->hscb->tag);
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
|
|
|
* Take a snapshot of the bus state and print out
|
|
|
|
* some information so we can track down driver bugs.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
last_phase = ahc_inb(ahc, LASTPHASE);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
for (i = 0; i < num_phases; i++) {
|
|
|
|
if (last_phase == phase_table[i].phase)
|
1996-05-16 07:59:03 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("%s", phase_table[i].phasemsg);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
printf(", SEQADDR == 0x%x\n",
|
|
|
|
ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));
|
|
|
|
printf("SCSIRATE == 0x%x\n", ahc_inb(ahc, SCSIRATE));
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
ahc_print_scb(scb);
|
|
|
|
#endif
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#if 0
|
|
|
|
printf("SSTAT1 == 0x%x\n", ahc_inb(ahc, SSTAT1));
|
|
|
|
printf("SSTAT3 == 0x%x\n", ahc_inb(ahc, SSTAT3));
|
|
|
|
printf("SCSIPHASE == 0x%x\n", ahc_inb(ahc, SCSIPHASE));
|
|
|
|
printf("SCSIOFFSET == 0x%x\n", ahc_inb(ahc, SCSIOFFSET));
|
|
|
|
printf("SEQ_FLAGS == 0x%x\n", ahc_inb(ahc, SEQ_FLAGS));
|
|
|
|
printf("SCB_DATAPTR == 0x%x\n", ahc_inb(ahc, SCB_DATAPTR)
|
|
|
|
| ahc_inb(ahc, SCB_DATAPTR + 1) << 8
|
|
|
|
| ahc_inb(ahc, SCB_DATAPTR + 2) << 16
|
|
|
|
| ahc_inb(ahc, SCB_DATAPTR + 3) << 24);
|
|
|
|
printf("SCB_DATACNT == 0x%x\n", ahc_inb(ahc, SCB_DATACNT)
|
|
|
|
| ahc_inb(ahc, SCB_DATACNT + 1) << 8
|
|
|
|
| ahc_inb(ahc, SCB_DATACNT + 2) << 16);
|
|
|
|
printf("SCB_SGCOUNT == 0x%x\n", ahc_inb(ahc, SCB_SGCOUNT));
|
|
|
|
printf("CCSCBCTL == 0x%x\n", ahc_inb(ahc, CCSCBCTL));
|
|
|
|
printf("CCSCBCNT == 0x%x\n", ahc_inb(ahc, CCSCBCNT));
|
|
|
|
printf("DFCNTRL == 0x%x\n", ahc_inb(ahc, DFCNTRL));
|
|
|
|
printf("DFSTATUS == 0x%x\n", ahc_inb(ahc, DFSTATUS));
|
|
|
|
printf("CCHCNT == 0x%x\n", ahc_inb(ahc, CCHCNT));
|
|
|
|
if (scb->sg_count > 0) {
|
|
|
|
for (i = 0; i < scb->sg_count; i++) {
|
|
|
|
printf("sg[%d] - Addr 0x%x : Length %d\n",
|
|
|
|
i,
|
|
|
|
le32toh(scb->sg_list[i].addr),
|
|
|
|
le32toh(scb->sg_list[i].len));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (scb->flags & (SCB_DEVICE_RESET|SCB_ABORT)) {
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
|
|
|
* Been down this road before.
|
|
|
|
* Do a full bus reset.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
bus_reset:
|
|
|
|
ahcsetccbstatus(scb->xs, XS_TIMEOUT);
|
|
|
|
found = ahc_reset_channel(ahc, channel, /*Initiate Reset*/TRUE);
|
|
|
|
printf("%s: Issued Channel %c Bus Reset. "
|
1996-05-16 07:59:03 +04:00
|
|
|
"%d SCBs aborted\n", ahc_name(ahc), channel, found);
|
2000-03-15 05:08:28 +03:00
|
|
|
} else {
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* If we are a target, transition to bus free and report
|
|
|
|
* the timeout.
|
2000-06-30 03:12:19 +04:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* The target/initiator that is holding up the bus may not
|
1996-05-16 07:59:03 +04:00
|
|
|
* be the same as the one that triggered this timeout
|
|
|
|
* (different commands have different timeout lengths).
|
2000-03-15 05:08:28 +03:00
|
|
|
* If the bus is idle and we are actiing as the initiator
|
|
|
|
* for this request, queue a BDR message to the timed out
|
|
|
|
* target. Otherwise, if the timed out transaction is
|
|
|
|
* active:
|
|
|
|
* Initiator transaction:
|
|
|
|
* Stuff the message buffer with a BDR message and assert
|
|
|
|
* ATN in the hopes that the target will let go of the bus
|
|
|
|
* and go to the mesgout phase. If this fails, we'll
|
|
|
|
* get another timeout 2 seconds later which will attempt
|
|
|
|
* a bus reset.
|
1996-05-16 07:59:03 +04:00
|
|
|
*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Target transaction:
|
|
|
|
* Transition to BUS FREE and report the error.
|
|
|
|
* It's good to be the target!
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int active_scb_index;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
active_scb_index = ahc_inb(ahc, SCB_TAG);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-06-30 03:12:19 +04:00
|
|
|
if (last_phase != P_BUSFREE
|
2000-03-15 05:08:28 +03:00
|
|
|
&& (active_scb_index < ahc->scb_data->numscbs)) {
|
|
|
|
struct scb *active_scb;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the active SCB is not from our device,
|
|
|
|
* assume that another device is hogging the bus
|
|
|
|
* and wait for it's timeout to expire before
|
|
|
|
* taking additional action.
|
2000-06-30 03:12:19 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
active_scb = &ahc->scb_data->scbarray[active_scb_index];
|
|
|
|
if (active_scb->hscb->tcl != scb->hscb->tcl) {
|
|
|
|
u_int newtimeout;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Other SCB Timeout%s",
|
|
|
|
(scb->flags & SCB_OTHERTCL_TIMEOUT) != 0
|
|
|
|
? " again\n" : "\n");
|
|
|
|
scb->flags |= SCB_OTHERTCL_TIMEOUT;
|
|
|
|
newtimeout = MAX(active_scb->xs->timeout,
|
|
|
|
scb->xs->timeout);
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&scb->xs->xs_callout,
|
2002-04-05 22:27:45 +04:00
|
|
|
mstohz(newtimeout), ahc_timeout, scb);
|
2000-03-15 05:08:28 +03:00
|
|
|
splx(s);
|
|
|
|
return;
|
2000-06-30 03:12:19 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
/* It's us */
|
|
|
|
if ((scb->hscb->control & TARGET_SCB) != 0) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send back any queued up transactions
|
|
|
|
* and properly record the error condition.
|
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
ahc_freeze_devq(ahc, scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
ahcsetccbstatus(scb->xs, XS_TIMEOUT);
|
|
|
|
ahc_freeze_ccb(scb);
|
|
|
|
ahc_done(ahc, scb);
|
|
|
|
|
|
|
|
/* Will clear us from the bus */
|
|
|
|
restart_sequencer(ahc);
|
2001-04-10 03:51:28 +04:00
|
|
|
splx(s);
|
2000-03-15 05:08:28 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ahc_set_recoveryscb(ahc, active_scb);
|
|
|
|
ahc_outb(ahc, MSG_OUT, MSG_BUS_DEV_RESET);
|
|
|
|
ahc_outb(ahc, SCSISIGO, last_phase|ATNO);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(active_scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("BDR message in message buffer\n");
|
|
|
|
active_scb->flags |= SCB_DEVICE_RESET;
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&active_scb->xs->xs_callout,
|
|
|
|
2 * hz, ahc_timeout, active_scb);
|
2000-03-15 05:08:28 +03:00
|
|
|
unpause_sequencer(ahc);
|
|
|
|
} else {
|
|
|
|
int disconnected;
|
|
|
|
|
|
|
|
/* XXX Shouldn't panic. Just punt instead */
|
|
|
|
if ((scb->hscb->control & TARGET_SCB) != 0)
|
|
|
|
panic("Timed-out target SCB but bus idle");
|
|
|
|
|
|
|
|
if (last_phase != P_BUSFREE
|
|
|
|
&& (ahc_inb(ahc, SSTAT0) & TARGET) != 0) {
|
|
|
|
/* XXX What happened to the SCB? */
|
|
|
|
/* Hung target selection. Goto busfree */
|
|
|
|
printf("%s: Hung target selection\n",
|
|
|
|
ahc_name(ahc));
|
|
|
|
restart_sequencer(ahc);
|
2001-04-10 03:51:28 +04:00
|
|
|
splx(s);
|
2000-03-15 05:08:28 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ahc_search_qinfifo(ahc, target, channel, lun,
|
|
|
|
scb->hscb->tag, ROLE_INITIATOR,
|
|
|
|
/*status*/0, SEARCH_COUNT) > 0) {
|
|
|
|
disconnected = FALSE;
|
|
|
|
} else {
|
|
|
|
disconnected = TRUE;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
if (disconnected) {
|
|
|
|
u_int active_scb;
|
|
|
|
|
|
|
|
ahc_set_recoveryscb(ahc, scb);
|
|
|
|
/*
|
|
|
|
* Simply set the MK_MESSAGE control bit.
|
|
|
|
*/
|
|
|
|
scb->hscb->control |= MK_MESSAGE;
|
|
|
|
scb->flags |= SCB_QUEUED_MSG
|
|
|
|
| SCB_DEVICE_RESET;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mark the cached copy of this SCB in the
|
|
|
|
* disconnected list too, so that a reconnect
|
|
|
|
* at this point causes a BDR or abort.
|
|
|
|
*/
|
|
|
|
active_scb = ahc_inb(ahc, SCBPTR);
|
|
|
|
if (ahc_search_disc_list(ahc, target,
|
|
|
|
channel, lun,
|
|
|
|
scb->hscb->tag,
|
|
|
|
/*stop_on_first*/TRUE,
|
|
|
|
/*remove*/FALSE,
|
|
|
|
/*save_state*/FALSE)) {
|
|
|
|
u_int scb_control;
|
|
|
|
|
|
|
|
scb_control = ahc_inb(ahc, SCB_CONTROL);
|
|
|
|
scb_control |= MK_MESSAGE;
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, scb_control);
|
|
|
|
}
|
|
|
|
ahc_outb(ahc, SCBPTR, active_scb);
|
|
|
|
ahc_index_busy_tcl(ahc, scb->hscb->tcl,
|
|
|
|
/*unbusy*/TRUE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actually re-queue this SCB in case we can
|
|
|
|
* select the device before it reconnects.
|
|
|
|
* Clear out any entries in the QINFIFO first
|
|
|
|
* so we are the next SCB for this target
|
|
|
|
* to run.
|
|
|
|
*/
|
|
|
|
ahc_search_qinfifo(ahc, SCB_TARGET(scb),
|
|
|
|
channel, SCB_LUN(scb),
|
|
|
|
SCB_LIST_NULL,
|
|
|
|
ROLE_INITIATOR,
|
|
|
|
SCB_REQUEUE,
|
|
|
|
SEARCH_COMPLETE);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Queuing a BDR SCB\n");
|
|
|
|
ahc->qinfifo[ahc->qinfifonext++] =
|
|
|
|
scb->hscb->tag;
|
|
|
|
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat,
|
|
|
|
ahc->shared_data_dmamap,
|
|
|
|
QINFIFO_OFFSET * 256, 256,
|
|
|
|
BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
if ((ahc->features & AHC_QUEUE_REGS) != 0) {
|
|
|
|
ahc_outb(ahc, HNSCB_QOFF,
|
|
|
|
ahc->qinfifonext);
|
|
|
|
} else {
|
|
|
|
ahc_outb(ahc, KERNEL_QINPOS,
|
|
|
|
ahc->qinfifonext);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&scb->xs->xs_callout, 2 * hz,
|
|
|
|
ahc_timeout, scb);
|
2000-03-15 05:08:28 +03:00
|
|
|
unpause_sequencer(ahc);
|
|
|
|
} else {
|
|
|
|
/* Go "immediatly" to the bus reset */
|
|
|
|
/* This shouldn't happen */
|
|
|
|
ahc_set_recoveryscb(ahc, scb);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("SCB %x: Immediate reset. "
|
|
|
|
"Flags = 0x%x\n", scb->hscb->tag,
|
|
|
|
scb->flags);
|
|
|
|
goto bus_reset;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
splx(s);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
static int
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_search_qinfifo(struct ahc_softc *ahc, int target, char channel,
|
|
|
|
int lun, u_int tag, role_t role, scb_flag status,
|
|
|
|
ahc_search_action action)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct scb *scbp;
|
|
|
|
u_int8_t qinpos;
|
|
|
|
u_int8_t qintail;
|
|
|
|
int found;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
qinpos = ahc_inb(ahc, QINPOS);
|
|
|
|
qintail = ahc->qinfifonext;
|
|
|
|
found = 0;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Start with an empty queue. Entries that are not chosen
|
|
|
|
* for removal will be re-added to the queue as we go.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->qinfifonext = qinpos;
|
|
|
|
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap,
|
|
|
|
QINFIFO_OFFSET * 256, 256, BUS_DMASYNC_POSTREAD);
|
|
|
|
|
|
|
|
while (qinpos != qintail) {
|
|
|
|
scbp = &ahc->scb_data->scbarray[ahc->qinfifo[qinpos]];
|
|
|
|
if (ahc_match_scb(scbp, target, channel, lun, tag, role)) {
|
|
|
|
/*
|
|
|
|
* We found an scb that needs to be removed.
|
|
|
|
*/
|
|
|
|
switch (action) {
|
|
|
|
case SEARCH_COMPLETE:
|
|
|
|
if (!(scbp->xs->xs_status & XS_STS_DONE)) {
|
|
|
|
scbp->flags |= status;
|
|
|
|
scbp->xs->error = XS_NOERROR;
|
|
|
|
}
|
|
|
|
ahc_freeze_ccb(scbp);
|
|
|
|
ahc_done(ahc, scbp);
|
|
|
|
break;
|
|
|
|
case SEARCH_COUNT:
|
|
|
|
ahc->qinfifo[ahc->qinfifonext++] =
|
|
|
|
scbp->hscb->tag;
|
|
|
|
break;
|
|
|
|
case SEARCH_REMOVE:
|
|
|
|
break;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
found++;
|
|
|
|
} else {
|
|
|
|
ahc->qinfifo[ahc->qinfifonext++] = scbp->hscb->tag;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
qinpos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_dmamap_sync(ahc->parent_dmat, ahc->shared_data_dmamap,
|
|
|
|
QINFIFO_OFFSET * 256, 256, BUS_DMASYNC_PREWRITE);
|
|
|
|
|
|
|
|
if ((ahc->features & AHC_QUEUE_REGS) != 0) {
|
|
|
|
ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext);
|
|
|
|
} else {
|
|
|
|
ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
return (found);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Abort all SCBs that match the given description (target/channel/lun/tag),
|
|
|
|
* setting their status to the passed in status if the status has not already
|
|
|
|
* been modified from CAM_REQ_INPROG. This routine assumes that the sequencer
|
|
|
|
* is paused before it is called.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ahc_abort_scbs(struct ahc_softc *ahc, int target, char channel,
|
|
|
|
int lun, u_int tag, role_t role, int status)
|
|
|
|
{
|
|
|
|
struct scb *scbp;
|
|
|
|
u_int active_scb;
|
|
|
|
int i;
|
|
|
|
int found;
|
|
|
|
|
|
|
|
/* restore this when we're done */
|
|
|
|
active_scb = ahc_inb(ahc, SCBPTR);
|
|
|
|
|
|
|
|
found = ahc_search_qinfifo(ahc, target, channel, lun, SCB_LIST_NULL,
|
|
|
|
role, SCB_REQUEUE, SEARCH_COMPLETE);
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
|
|
|
* Search waiting for selection list.
|
|
|
|
*/
|
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int8_t next, prev;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
next = ahc_inb(ahc, WAITING_SCBH); /* Start at head of list. */
|
1996-05-16 07:59:03 +04:00
|
|
|
prev = SCB_LIST_NULL;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
while (next != SCB_LIST_NULL) {
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int8_t scb_index;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCBPTR, next);
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
if (scb_index >= ahc->scb_data->numscbs) {
|
|
|
|
panic("Waiting List inconsistency. "
|
|
|
|
"SCB index == %d, yet numscbs == %d.",
|
|
|
|
scb_index, ahc->scb_data->numscbs);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
scbp = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
if (ahc_match_scb(scbp, target, channel,
|
|
|
|
lun, SCB_LIST_NULL, role)) {
|
|
|
|
|
|
|
|
next = ahc_abort_wscb(ahc, next, prev);
|
|
|
|
} else {
|
2000-06-30 03:12:19 +04:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
prev = next;
|
2000-03-15 05:08:28 +03:00
|
|
|
next = ahc_inb(ahc, SCB_NEXT);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Go through the disconnected list and remove any entries we
|
|
|
|
* have queued for completion, 0'ing their control byte too.
|
|
|
|
* We save the active SCB and restore it ourselves, so there
|
|
|
|
* is no reason for this search to restore it too.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_search_disc_list(ahc, target, channel, lun, tag,
|
|
|
|
/*stop_on_first*/FALSE, /*remove*/TRUE,
|
|
|
|
/*save_state*/FALSE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Go through the hardware SCB array looking for commands that
|
|
|
|
* were active but not on any list.
|
|
|
|
*/
|
|
|
|
for(i = 0; i < ahc->scb_data->maxhscbs; i++) {
|
|
|
|
u_int scbid;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCBPTR, i);
|
|
|
|
scbid = ahc_inb(ahc, SCB_TAG);
|
|
|
|
scbp = &ahc->scb_data->scbarray[scbid];
|
|
|
|
if (scbid < ahc->scb_data->numscbs
|
|
|
|
&& ahc_match_scb(scbp, target, channel, lun, tag, role))
|
|
|
|
ahc_add_curscb_to_free_list(ahc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Go through the pending CCB list and look for
|
|
|
|
* commands for this target that are still active.
|
|
|
|
* These are other tagged commands that were
|
2001-09-16 20:34:23 +04:00
|
|
|
* disconnected when the reset occurred.
|
2000-03-15 05:08:28 +03:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct scb *scb;
|
|
|
|
|
|
|
|
scb = ahc->pending_ccbs.lh_first;
|
|
|
|
while (scb != NULL) {
|
|
|
|
scbp = scb;
|
|
|
|
scb = scb->plinks.le_next;
|
|
|
|
if (ahc_match_scb(scbp, target, channel,
|
|
|
|
lun, tag, role)) {
|
|
|
|
if (!(scbp->xs->xs_status & XS_STS_DONE))
|
|
|
|
ahcsetccbstatus(scbp->xs, status);
|
|
|
|
ahc_freeze_ccb(scbp);
|
|
|
|
ahc_done(ahc, scbp);
|
|
|
|
found++;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
ahc_outb(ahc, SCBPTR, active_scb);
|
1996-05-16 07:59:03 +04:00
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static int
|
|
|
|
ahc_search_disc_list(struct ahc_softc *ahc, int target, char channel,
|
|
|
|
int lun, u_int tag, int stop_on_first, int remove,
|
|
|
|
int save_state)
|
|
|
|
{
|
|
|
|
struct scb *scbp;
|
|
|
|
u_int next;
|
|
|
|
u_int prev;
|
|
|
|
u_int count;
|
|
|
|
u_int active_scb;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
next = ahc_inb(ahc, DISCONNECTED_SCBH);
|
|
|
|
prev = SCB_LIST_NULL;
|
|
|
|
|
|
|
|
if (save_state) {
|
|
|
|
/* restore this when we're done */
|
|
|
|
active_scb = ahc_inb(ahc, SCBPTR);
|
|
|
|
} else
|
|
|
|
/* Silence compiler */
|
|
|
|
active_scb = SCB_LIST_NULL;
|
|
|
|
|
|
|
|
while (next != SCB_LIST_NULL) {
|
|
|
|
u_int scb_index;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCBPTR, next);
|
|
|
|
scb_index = ahc_inb(ahc, SCB_TAG);
|
|
|
|
if (scb_index >= ahc->scb_data->numscbs) {
|
|
|
|
panic("Disconnected List inconsistency. "
|
|
|
|
"SCB index == %d, yet numscbs == %d.",
|
|
|
|
scb_index, ahc->scb_data->numscbs);
|
|
|
|
}
|
|
|
|
scbp = &ahc->scb_data->scbarray[scb_index];
|
|
|
|
if (ahc_match_scb(scbp, target, channel, lun,
|
|
|
|
tag, ROLE_INITIATOR)) {
|
|
|
|
count++;
|
|
|
|
if (remove) {
|
|
|
|
next =
|
|
|
|
ahc_rem_scb_from_disc_list(ahc, prev, next);
|
|
|
|
} else {
|
|
|
|
prev = next;
|
|
|
|
next = ahc_inb(ahc, SCB_NEXT);
|
|
|
|
}
|
|
|
|
if (stop_on_first)
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
prev = next;
|
|
|
|
next = ahc_inb(ahc, SCB_NEXT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (save_state)
|
|
|
|
ahc_outb(ahc, SCBPTR, active_scb);
|
|
|
|
return (count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u_int
|
|
|
|
ahc_rem_scb_from_disc_list(struct ahc_softc *ahc, u_int prev, u_int scbptr)
|
|
|
|
{
|
|
|
|
u_int next;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCBPTR, scbptr);
|
|
|
|
next = ahc_inb(ahc, SCB_NEXT);
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, 0);
|
|
|
|
|
|
|
|
ahc_add_curscb_to_free_list(ahc);
|
|
|
|
|
|
|
|
if (prev != SCB_LIST_NULL) {
|
|
|
|
ahc_outb(ahc, SCBPTR, prev);
|
|
|
|
ahc_outb(ahc, SCB_NEXT, next);
|
|
|
|
} else
|
|
|
|
ahc_outb(ahc, DISCONNECTED_SCBH, next);
|
|
|
|
|
|
|
|
return (next);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_add_curscb_to_free_list(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
/* Invalidate the tag so that ahc_find_scb doesn't think it's active */
|
|
|
|
ahc_outb(ahc, SCB_TAG, SCB_LIST_NULL);
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCB_NEXT, ahc_inb(ahc, FREE_SCBH));
|
|
|
|
ahc_outb(ahc, FREE_SCBH, ahc_inb(ahc, SCBPTR));
|
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
|
|
|
* Manipulate the waiting for selection list and return the
|
|
|
|
* scb that follows the one that we remove.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
static u_int
|
|
|
|
ahc_abort_wscb(struct ahc_softc *ahc, u_int scbpos, u_int prev)
|
2000-06-30 03:12:19 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int curscb, next;
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
|
|
|
* Select the SCB we want to abort and
|
|
|
|
* pull the next pointer out of it.
|
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
curscb = ahc_inb(ahc, SCBPTR);
|
|
|
|
ahc_outb(ahc, SCBPTR, scbpos);
|
|
|
|
next = ahc_inb(ahc, SCB_NEXT);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/* Clear the necessary fields */
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCB_CONTROL, 0);
|
|
|
|
|
|
|
|
ahc_add_curscb_to_free_list(ahc);
|
1996-05-16 07:59:03 +04:00
|
|
|
|
|
|
|
/* update the waiting list */
|
2000-03-15 05:08:28 +03:00
|
|
|
if (prev == SCB_LIST_NULL) {
|
1996-05-16 07:59:03 +04:00
|
|
|
/* First in the list */
|
2000-06-30 03:12:19 +04:00
|
|
|
ahc_outb(ahc, WAITING_SCBH, next);
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure we aren't attempting to perform
|
|
|
|
* selection for this entry.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, SCSISEQ, (ahc_inb(ahc, SCSISEQ) & ~ENSELO));
|
|
|
|
} else {
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-06-30 03:12:19 +04:00
|
|
|
* Select the scb that pointed to us
|
1996-05-16 07:59:03 +04:00
|
|
|
* and update its next pointer.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCBPTR, prev);
|
|
|
|
ahc_outb(ahc, SCB_NEXT, next);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
1995-10-09 12:49:30 +03:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Point us back at the original scb position.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCBPTR, curscb);
|
1996-05-16 07:59:03 +04:00
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_clear_intstat(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
/* Clear any interrupt conditions this may have caused */
|
|
|
|
ahc_outb(ahc, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO);
|
|
|
|
ahc_outb(ahc, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI
|
|
|
|
|CLRBUSFREE|CLRSCSIPERR|CLRPHASECHG|
|
|
|
|
CLRREQINIT);
|
|
|
|
ahc_outb(ahc, CLRINT, CLRSCSIINT);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_reset_current_bus(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
u_int8_t scsiseq;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENSCSIRST);
|
|
|
|
scsiseq = ahc_inb(ahc, SCSISEQ);
|
|
|
|
ahc_outb(ahc, SCSISEQ, scsiseq | SCSIRSTO);
|
|
|
|
DELAY(AHC_BUSRESET_DELAY);
|
|
|
|
/* Turn off the bus reset */
|
|
|
|
ahc_outb(ahc, SCSISEQ, scsiseq & ~SCSIRSTO);
|
|
|
|
|
|
|
|
ahc_clear_intstat(ahc);
|
|
|
|
|
|
|
|
/* Re-enable reset interrupts */
|
|
|
|
ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) | ENSCSIRST);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ahc_reset_channel(struct ahc_softc *ahc, char channel, int initiate_reset)
|
|
|
|
{
|
|
|
|
u_int initiator, target, max_scsiid;
|
|
|
|
u_int sblkctl;
|
|
|
|
u_int our_id;
|
|
|
|
int found;
|
|
|
|
int restart_needed;
|
|
|
|
char cur_channel;
|
|
|
|
|
|
|
|
ahc->pending_device = NULL;
|
|
|
|
|
|
|
|
pause_sequencer(ahc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run our command complete fifos to ensure that we perform
|
|
|
|
* completion processing on any commands that 'completed'
|
|
|
|
* before the reset occurred.
|
|
|
|
*/
|
|
|
|
ahc_run_qoutfifo(ahc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the bus if we are initiating this reset
|
|
|
|
*/
|
|
|
|
sblkctl = ahc_inb(ahc, SBLKCTL);
|
|
|
|
cur_channel = 'A';
|
|
|
|
if ((ahc->features & AHC_TWIN) != 0
|
|
|
|
&& ((sblkctl & SELBUSB) != 0))
|
|
|
|
cur_channel = 'B';
|
|
|
|
if (cur_channel != channel) {
|
|
|
|
/* Case 1: Command for another bus is active
|
|
|
|
* Stealthily reset the other bus without
|
|
|
|
* upsetting the current bus.
|
|
|
|
*/
|
|
|
|
ahc_outb(ahc, SBLKCTL, sblkctl ^ SELBUSB);
|
|
|
|
ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENBUSFREE);
|
|
|
|
ahc_outb(ahc, SCSISEQ,
|
|
|
|
ahc_inb(ahc, SCSISEQ) & (ENSELI|ENRSELI|ENAUTOATNP));
|
|
|
|
if (initiate_reset)
|
|
|
|
ahc_reset_current_bus(ahc);
|
|
|
|
ahc_clear_intstat(ahc);
|
|
|
|
ahc_outb(ahc, SBLKCTL, sblkctl);
|
|
|
|
restart_needed = FALSE;
|
|
|
|
} else {
|
|
|
|
/* Case 2: A command from this bus is active or we're idle */
|
|
|
|
ahc_clear_msg_state(ahc);
|
|
|
|
ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENBUSFREE);
|
|
|
|
ahc_outb(ahc, SCSISEQ,
|
|
|
|
ahc_inb(ahc, SCSISEQ) & (ENSELI|ENRSELI|ENAUTOATNP));
|
|
|
|
if (initiate_reset)
|
|
|
|
ahc_reset_current_bus(ahc);
|
|
|
|
ahc_clear_intstat(ahc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we are going to restart the sequencer, avoid
|
|
|
|
* a race in the sequencer that could cause corruption
|
|
|
|
* of our Q pointers by starting over from index 0.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->qoutfifonext = 0;
|
|
|
|
if ((ahc->features & AHC_QUEUE_REGS) != 0)
|
|
|
|
ahc_outb(ahc, SDSCB_QOFF, 0);
|
|
|
|
else
|
|
|
|
ahc_outb(ahc, QOUTPOS, 0);
|
|
|
|
restart_needed = TRUE;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up all the state information for the
|
|
|
|
* pending transactions on this bus.
|
|
|
|
*/
|
|
|
|
found = ahc_abort_scbs(ahc, AHC_TARGET_WILDCARD, channel,
|
|
|
|
AHC_LUN_WILDCARD, SCB_LIST_NULL,
|
|
|
|
ROLE_UNKNOWN, XS_RESET);
|
|
|
|
if (channel == 'B') {
|
|
|
|
our_id = ahc->our_id_b;
|
|
|
|
} else {
|
|
|
|
our_id = ahc->our_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_scsiid = (ahc->features & AHC_WIDE) ? 15 : 7;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Revert to async/narrow transfers until we renegotiate.
|
|
|
|
*/
|
|
|
|
for (target = 0; target <= max_scsiid; target++) {
|
|
|
|
|
|
|
|
if (ahc->enabled_targets[target] == NULL)
|
|
|
|
continue;
|
|
|
|
for (initiator = 0; initiator <= max_scsiid; initiator++) {
|
|
|
|
struct ahc_devinfo devinfo;
|
|
|
|
|
|
|
|
ahc_compile_devinfo(&devinfo, target, initiator,
|
|
|
|
AHC_LUN_WILDCARD,
|
|
|
|
channel, ROLE_UNKNOWN);
|
|
|
|
ahc_set_width(ahc, &devinfo,
|
|
|
|
MSG_EXT_WDTR_BUS_8_BIT,
|
|
|
|
AHC_TRANS_CUR, /*paused*/TRUE, FALSE);
|
|
|
|
ahc_set_syncrate(ahc, &devinfo,
|
|
|
|
/*syncrate*/NULL, /*period*/0,
|
|
|
|
/*offset*/0, AHC_TRANS_CUR,
|
|
|
|
/*paused*/TRUE, FALSE);
|
2001-04-26 20:56:53 +04:00
|
|
|
ahc_update_xfer_mode(ahc, &devinfo);
|
2000-03-15 05:08:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (restart_needed)
|
|
|
|
restart_sequencer(ahc);
|
|
|
|
else
|
|
|
|
unpause_sequencer(ahc);
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ahc_match_scb(struct scb *scb, int target, char channel,
|
|
|
|
int lun, u_int tag, role_t role)
|
|
|
|
{
|
|
|
|
int targ = SCB_TARGET(scb);
|
|
|
|
char chan = SCB_CHANNEL(scb);
|
|
|
|
int slun = SCB_LUN(scb);
|
|
|
|
int match;
|
|
|
|
|
|
|
|
match = ((chan == channel) || (channel == ALL_CHANNELS));
|
|
|
|
if (match != 0)
|
|
|
|
match = ((targ == target) || (target == AHC_TARGET_WILDCARD));
|
|
|
|
if (match != 0)
|
|
|
|
match = ((lun == slun) || (lun == AHC_LUN_WILDCARD));
|
|
|
|
|
|
|
|
return match;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_construct_sdtr(struct ahc_softc *ahc, u_int period, u_int offset)
|
1995-10-09 12:49:30 +03:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_SDTR_LEN;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_SDTR;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = period;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = offset;
|
|
|
|
ahc->msgout_len += 5;
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
static void
|
|
|
|
ahc_construct_wdtr(struct ahc_softc *ahc, u_int bus_width)
|
|
|
|
{
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_WDTR_LEN;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_WDTR;
|
|
|
|
ahc->msgout_buf[ahc->msgout_index++] = bus_width;
|
|
|
|
ahc->msgout_len += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_calc_residual(struct scb *scb)
|
|
|
|
{
|
|
|
|
struct hardware_scb *hscb;
|
|
|
|
|
|
|
|
hscb = scb->hscb;
|
1995-10-09 12:49:30 +03:00
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* If the disconnected flag is still set, this is bogus
|
|
|
|
* residual information left over from a sequencer
|
|
|
|
* pagin/pageout, so ignore this case.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
if ((scb->hscb->control & DISCONNECTED) == 0) {
|
|
|
|
u_int32_t resid;
|
|
|
|
int resid_sgs;
|
|
|
|
int sg;
|
2000-06-30 03:12:19 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Remainder of the SG where the transfer
|
|
|
|
* stopped.
|
|
|
|
*/
|
|
|
|
resid = (hscb->residual_data_count[2] << 16)
|
|
|
|
| (hscb->residual_data_count[1] <<8)
|
|
|
|
| (hscb->residual_data_count[0]);
|
|
|
|
|
1996-05-16 07:59:03 +04:00
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Add up the contents of all residual
|
|
|
|
* SG segments that are after the SG where
|
|
|
|
* the transfer stopped.
|
1996-05-16 07:59:03 +04:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
resid_sgs = scb->hscb->residual_SG_count - 1/*current*/;
|
|
|
|
sg = scb->sg_count - resid_sgs;
|
|
|
|
while (resid_sgs > 0) {
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
resid += le32toh(scb->sg_list[sg].len);
|
|
|
|
sg++;
|
|
|
|
resid_sgs--;
|
|
|
|
}
|
|
|
|
scb->xs->resid = resid;
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-03-15 05:08:28 +03:00
|
|
|
* Clean out the residual information in this SCB for its
|
|
|
|
* next consumer.
|
1995-10-09 12:49:30 +03:00
|
|
|
*/
|
2000-03-15 05:08:28 +03:00
|
|
|
hscb->residual_SG_count = 0;
|
|
|
|
|
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if (ahc_debug & AHC_SHOWMISC) {
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_printaddr(scb->xs->xs_periph);
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("Handled Residual of %ld bytes\n" ,(long)scb->xs->resid);
|
1995-10-09 12:49:30 +03:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_update_pending_syncrates(struct ahc_softc *ahc)
|
|
|
|
{
|
|
|
|
struct scb *scb;
|
|
|
|
int pending_ccb_count;
|
|
|
|
int i;
|
|
|
|
u_int saved_scbptr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Traverse the pending SCB list and ensure that all of the
|
|
|
|
* SCBs there have the proper settings.
|
|
|
|
*/
|
|
|
|
scb = LIST_FIRST(&ahc->pending_ccbs);
|
|
|
|
pending_ccb_count = 0;
|
|
|
|
while (scb != NULL) {
|
|
|
|
struct ahc_devinfo devinfo;
|
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
struct scb *pending_scb;
|
|
|
|
struct hardware_scb *pending_hscb;
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
u_int our_id, remote_id;
|
|
|
|
|
|
|
|
xs = scb->xs;
|
|
|
|
pending_scb = scb;
|
|
|
|
pending_hscb = pending_scb->hscb;
|
|
|
|
our_id = SCB_IS_SCSIBUS_B(pending_scb)
|
|
|
|
? ahc->our_id_b : ahc->our_id;
|
2001-04-25 21:53:04 +04:00
|
|
|
remote_id = xs->xs_periph->periph_target;
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_compile_devinfo(&devinfo, our_id, remote_id,
|
|
|
|
SCB_LUN(pending_scb),
|
|
|
|
SCB_CHANNEL(pending_scb),
|
|
|
|
ROLE_UNKNOWN);
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo.channel,
|
|
|
|
our_id, remote_id, &tstate);
|
|
|
|
pending_hscb->control &= ~ULTRAENB;
|
|
|
|
if ((tstate->ultraenb & devinfo.target_mask) != 0)
|
|
|
|
pending_hscb->control |= ULTRAENB;
|
|
|
|
pending_hscb->scsirate = tinfo->scsirate;
|
|
|
|
pending_hscb->scsioffset = tinfo->current.offset;
|
|
|
|
pending_ccb_count++;
|
|
|
|
scb = LIST_NEXT(scb, plinks);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pending_ccb_count == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
saved_scbptr = ahc_inb(ahc, SCBPTR);
|
|
|
|
/* Ensure that the hscbs down on the card match the new information */
|
|
|
|
for (i = 0; i < ahc->scb_data->maxhscbs; i++) {
|
|
|
|
u_int scb_tag;
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCBPTR, i);
|
|
|
|
scb_tag = ahc_inb(ahc, SCB_TAG);
|
|
|
|
if (scb_tag != SCB_LIST_NULL) {
|
|
|
|
struct ahc_devinfo devinfo;
|
|
|
|
struct scb *pending_scb;
|
|
|
|
struct scsipi_xfer *xs;
|
|
|
|
struct hardware_scb *pending_hscb;
|
|
|
|
struct ahc_initiator_tinfo *tinfo;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
u_int our_id, remote_id;
|
|
|
|
u_int control;
|
|
|
|
|
|
|
|
pending_scb = &ahc->scb_data->scbarray[scb_tag];
|
|
|
|
if (pending_scb->flags == SCB_FREE)
|
|
|
|
continue;
|
|
|
|
pending_hscb = pending_scb->hscb;
|
|
|
|
xs = pending_scb->xs;
|
|
|
|
our_id = SCB_IS_SCSIBUS_B(pending_scb)
|
|
|
|
? ahc->our_id_b : ahc->our_id;
|
2001-04-25 21:53:04 +04:00
|
|
|
remote_id = xs->xs_periph->periph_target;
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_compile_devinfo(&devinfo, our_id, remote_id,
|
|
|
|
SCB_LUN(pending_scb),
|
|
|
|
SCB_CHANNEL(pending_scb),
|
|
|
|
ROLE_UNKNOWN);
|
|
|
|
tinfo = ahc_fetch_transinfo(ahc, devinfo.channel,
|
|
|
|
our_id, remote_id, &tstate);
|
|
|
|
control = ahc_inb(ahc, SCB_CONTROL);
|
|
|
|
control &= ~ULTRAENB;
|
|
|
|
if ((tstate->ultraenb & devinfo.target_mask) != 0)
|
|
|
|
control |= ULTRAENB;
|
|
|
|
ahc_outb(ahc, SCB_CONTROL, control);
|
|
|
|
ahc_outb(ahc, SCB_SCSIRATE, tinfo->scsirate);
|
|
|
|
ahc_outb(ahc, SCB_SCSIOFFSET, tinfo->current.offset);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_outb(ahc, SCBPTR, saved_scbptr);
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
1995-10-09 12:49:30 +03:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#if UNUSED
|
|
|
|
static void
|
|
|
|
ahc_dump_targcmd(struct target_cmd *cmd)
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
u_int8_t *byte;
|
|
|
|
u_int8_t *last_byte;
|
1996-05-16 07:59:03 +04:00
|
|
|
int i;
|
2000-03-15 05:08:28 +03:00
|
|
|
|
|
|
|
byte = &cmd->initiator_channel;
|
|
|
|
/* Debugging info for received commands */
|
|
|
|
last_byte = &cmd[1].initiator_channel;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (byte < last_byte) {
|
|
|
|
if (i == 0)
|
|
|
|
printf("\t");
|
|
|
|
printf("%#x", *byte++);
|
|
|
|
i++;
|
|
|
|
if (i == 8) {
|
|
|
|
printf("\n");
|
|
|
|
i = 0;
|
|
|
|
} else {
|
|
|
|
printf(", ");
|
|
|
|
}
|
1996-05-16 07:59:03 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
ahc_shutdown(void *arg)
|
1996-05-16 07:59:03 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
struct ahc_softc *ahc;
|
|
|
|
int i;
|
|
|
|
u_int sxfrctl1_a, sxfrctl1_b;
|
1996-05-16 07:59:03 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc = (struct ahc_softc *)arg;
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
pause_sequencer(ahc);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
/*
|
|
|
|
* Preserve the value of the SXFRCTL1 register for all channels.
|
|
|
|
* It contains settings that affect termination and we don't want
|
|
|
|
* to disturb the integrity of the bus during shutdown in case
|
|
|
|
* we are in a multi-initiator setup.
|
|
|
|
*/
|
|
|
|
sxfrctl1_b = 0;
|
|
|
|
if ((ahc->features & AHC_TWIN) != 0) {
|
|
|
|
u_int sblkctl;
|
|
|
|
|
|
|
|
sblkctl = ahc_inb(ahc, SBLKCTL);
|
|
|
|
ahc_outb(ahc, SBLKCTL, sblkctl | SELBUSB);
|
|
|
|
sxfrctl1_b = ahc_inb(ahc, SXFRCTL1);
|
|
|
|
ahc_outb(ahc, SBLKCTL, sblkctl & ~SELBUSB);
|
|
|
|
}
|
|
|
|
|
|
|
|
sxfrctl1_a = ahc_inb(ahc, SXFRCTL1);
|
|
|
|
|
|
|
|
/* This will reset most registers to 0, but not all */
|
|
|
|
ahc_reset(ahc);
|
|
|
|
|
|
|
|
if ((ahc->features & AHC_TWIN) != 0) {
|
|
|
|
u_int sblkctl;
|
|
|
|
|
|
|
|
sblkctl = ahc_inb(ahc, SBLKCTL);
|
|
|
|
ahc_outb(ahc, SBLKCTL, sblkctl | SELBUSB);
|
|
|
|
ahc_outb(ahc, SXFRCTL1, sxfrctl1_b);
|
|
|
|
ahc_outb(ahc, SBLKCTL, sblkctl & ~SELBUSB);
|
|
|
|
}
|
|
|
|
ahc_outb(ahc, SXFRCTL1, sxfrctl1_a);
|
|
|
|
|
|
|
|
ahc_outb(ahc, SCSISEQ, 0);
|
|
|
|
ahc_outb(ahc, SXFRCTL0, 0);
|
|
|
|
ahc_outb(ahc, DSPCISTATUS, 0);
|
|
|
|
|
|
|
|
for (i = TARG_SCSIRATE; i < HA_274_BIOSCTRL; i++)
|
|
|
|
ahc_outb(ahc, i, 0);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
|
|
|
|
2000-03-15 05:08:28 +03:00
|
|
|
#if defined(AHC_DEBUG) && 0
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
static void
|
2000-03-15 05:08:28 +03:00
|
|
|
ahc_dumptinfo(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo)
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
{
|
2000-03-15 05:08:28 +03:00
|
|
|
printf("%s: tinfo: rate %u\n", ahc_name(ahc), tinfo->scsirate);
|
|
|
|
|
|
|
|
printf("\tcurrent:\n");
|
|
|
|
printf("\t\twidth %u period %u offset %u flags %x\n",
|
|
|
|
tinfo->current.width, tinfo->current.period,
|
|
|
|
tinfo->current.offset, tinfo->current.ppr_flags);
|
|
|
|
|
|
|
|
printf("\tgoal:\n");
|
|
|
|
printf("\t\twidth %u period %u offset %u flags %x\n",
|
|
|
|
tinfo->goal.width, tinfo->goal.period,
|
|
|
|
tinfo->goal.offset, tinfo->goal.ppr_flags);
|
|
|
|
|
|
|
|
printf("\tuser:\n");
|
|
|
|
printf("\t\twidth %u period %u offset %u flags %x\n",
|
|
|
|
tinfo->user.width, tinfo->user.period,
|
|
|
|
tinfo->user.offset, tinfo->user.ppr_flags);
|
dev/microcode/aic7xxx/aic7xxx.seq,
dev/microcode/aic7xxx_seq.h,
dev/ic/aic7xxxreg.h:
Remove intrinsic knowledge about SDTR and WDTR messages and replace it
with a generic message system that allows the kernel driver to handle
SDTR, WDTR and any other type of extended message it chooses too. This
makes the sequencer code much simpler, makes extended message handling
debuggable since the bulk of the work is in the kernel driver, and saves
lots of instruction space.
Regen microcode header file.
dev/ic/aic7xxx.c, dev/ic/aic7xxxvar.h:
Add code to handle WDTR and SDTR negotiation in light of the changes in
the message interface to the sequencer. Don't reject targets that
negotiate async by sending an SDTR with a 0 offset. Use an sdtr message
with 0,0 to negotiate async when a target suggests a period that is too
long for us to handle. Some tape and cdrom drives don't like us doing
the message reject that we did in the past.
Fix a problem with handing the QUEUE FULL condition.
Fix a race condition (most likely the cause of the SCB paging problems) that
might allow the sequencer to get unpaused before the condition that caused
it to be paused (a SEQINT) was handled.
Race condition pointed out by Doug Ledford <dledford@dialnet.net> and
by "Dan Willis" <dan@plutotech.com>.
dev/pci/ahc_pci.c:
Add support for the 2940AU, an aic7860 based controller.
dev/pci/pcidevs.h, dev/pci/pcidevs_data.h:
Add product IDs for the 2940AU, aic7860 and aic7855.
Regen data file.
scsi/scsi_message.h:
Add MSG_EXT_SDTR_LEN and MSG_EXT_WDTR_LEN - the length of bytes in these
extended messages.
Thanks to Chuck Cranor <chuck@maria.wustl.edu> for testing these changes
out for me.
1996-10-08 07:04:02 +04:00
|
|
|
}
|
2000-03-15 05:08:28 +03:00
|
|
|
#endif
|
2000-03-25 22:52:12 +03:00
|
|
|
|
|
|
|
static int
|
2000-05-25 15:41:05 +04:00
|
|
|
ahc_istagged_device(struct ahc_softc *ahc, struct scsipi_xfer *xs,
|
|
|
|
int nocmdcheck)
|
2000-03-25 22:52:12 +03:00
|
|
|
{
|
2000-12-02 17:53:01 +03:00
|
|
|
#ifdef AHC_NO_TAGS
|
|
|
|
return 0;
|
|
|
|
#else
|
2000-03-25 22:52:12 +03:00
|
|
|
char channel;
|
|
|
|
u_int our_id, target;
|
|
|
|
struct tmode_tstate *tstate;
|
|
|
|
struct ahc_devinfo devinfo;
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
channel = SIM_CHANNEL(ahc, xs->xs_periph);
|
|
|
|
our_id = SIM_SCSI_ID(ahc, xs->xs_periph);
|
|
|
|
target = xs->xs_periph->periph_target;
|
2000-03-25 22:52:12 +03:00
|
|
|
(void)ahc_fetch_transinfo(ahc, channel, our_id, target, &tstate);
|
|
|
|
|
|
|
|
ahc_compile_devinfo(&devinfo, our_id, target,
|
2001-04-25 21:53:04 +04:00
|
|
|
xs->xs_periph->periph_lun, channel, ROLE_INITIATOR);
|
2000-03-25 22:52:12 +03:00
|
|
|
|
|
|
|
return (tstate->tagenable & devinfo.target_mask);
|
2000-12-02 17:53:01 +03:00
|
|
|
#endif
|
2000-03-25 22:52:12 +03:00
|
|
|
}
|