1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Generic driver for the aic7xxx based adaptec SCSI controllers
|
1995-05-30 08:16:23 +00:00
|
|
|
* Copyright (c) 1994, 1995 Justin T. Gibbs.
|
1994-12-31 19:31:56 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Product specific probe and attach routines can be found in:
|
|
|
|
* i386/isa/aic7770.c 27/284X and aic7770 motherboard controllers
|
1995-02-22 01:43:25 +00:00
|
|
|
* /pci/aic7870.c 294x and aic7870 motherboard controllers
|
1995-01-13 02:24:31 +00:00
|
|
|
*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Portions of this driver are based on the FreeBSD 1742 Driver:
|
1994-11-17 20:22:31 +00:00
|
|
|
*
|
|
|
|
* Written by Julian Elischer (julian@tfs.com)
|
|
|
|
* for TRW Financial Systems for use under the MACH(2.5) operating system.
|
|
|
|
*
|
|
|
|
* TRW Financial Systems, in accordance with their agreement with Carnegie
|
|
|
|
* Mellon University, makes this software available to CMU to distribute
|
|
|
|
* or use in any manner that they see fit as long as this message is kept with
|
|
|
|
* the software. For this reason TFS also grants any other persons or
|
|
|
|
* organisations permission to use or modify this software.
|
|
|
|
*
|
|
|
|
* TFS supplies this software to be publicly redistributed
|
|
|
|
* on the understanding that TFS is not responsible for the correct
|
|
|
|
* functioning of this software in any circumstances.
|
|
|
|
*
|
|
|
|
* commenced: Sun Sep 27 18:14:01 PDT 1992
|
|
|
|
*
|
1995-07-04 21:14:45 +00:00
|
|
|
* $Id: aic7xxx.c,v 1.29 1995/06/11 19:31:29 rgrimes Exp $
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* TODO:
|
1995-01-13 02:24:31 +00:00
|
|
|
* Add target reset capabilities
|
1994-11-17 20:22:31 +00:00
|
|
|
* Implement Target Mode
|
|
|
|
*
|
|
|
|
* This driver is very stable, and seems to offer performance
|
1994-12-31 19:31:56 +00:00
|
|
|
* comprable to the 1742 FreeBSD driver. I have not experienced
|
1995-05-30 08:16:23 +00:00
|
|
|
* any timeouts since the timeout code was written, so in that
|
1994-12-31 19:31:56 +00:00
|
|
|
* sense, it is untested.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
1995-03-07 08:59:28 +00:00
|
|
|
#include <machine/clock.h>
|
1995-01-13 02:27:08 +00:00
|
|
|
#include <i386/scsi/aic7xxx.h>
|
1995-07-04 21:14:45 +00:00
|
|
|
#include <i386/scsi/93cx6.h>
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
#define PAGESIZ 4096
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#define MAX_TAGS 4;
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#define KVTOPHYS(x) vtophys(x)
|
|
|
|
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
#define MIN(a,b) ((a < b) ? a : b)
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
struct ahc_data *ahcdata[NAHC];
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
int ahc_init __P((int unit));
|
1995-05-30 08:16:23 +00:00
|
|
|
void ahc_loadseq __P((u_long iobase));
|
1994-11-17 20:22:31 +00:00
|
|
|
int32 ahc_scsi_cmd();
|
|
|
|
timeout_t ahc_timeout;
|
|
|
|
void ahc_done();
|
|
|
|
struct scb *ahc_get_scb __P((int unit, int flags));
|
|
|
|
void ahc_free_scb();
|
1995-01-13 02:24:31 +00:00
|
|
|
void ahc_abort_scb __P((int unit, struct ahc_data *ahc, struct scb *scb));
|
1994-11-17 20:22:31 +00:00
|
|
|
void ahcminphys();
|
|
|
|
struct scb *ahc_scb_phys_kv();
|
1995-03-07 08:59:28 +00:00
|
|
|
int ahc_poll __P((int unit, int wait));
|
1994-11-17 20:22:31 +00:00
|
|
|
u_int32 ahc_adapter_info();
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
int ahc_unit = 0;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
/* Different debugging levels */
|
1994-11-17 20:22:31 +00:00
|
|
|
#define AHC_SHOWMISC 0x0001
|
1995-02-22 01:43:25 +00:00
|
|
|
#define AHC_SHOWCMDS 0x0002
|
|
|
|
#define AHC_SHOWSCBS 0x0004
|
1995-04-27 17:47:17 +00:00
|
|
|
/* #define AHC_DEBUG */
|
1995-03-17 23:58:27 +00:00
|
|
|
int ahc_debug = AHC_SHOWMISC;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/**** bit definitions for SCSIDEF ****/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define HSCSIID 0x07 /* our SCSI ID */
|
|
|
|
#define HWSCSIID 0x0f /* our SCSI ID if Wide Bus */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
struct scsi_adapter ahc_switch =
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_scsi_cmd,
|
|
|
|
ahcminphys,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
ahc_adapter_info,
|
|
|
|
"ahc",
|
|
|
|
{ 0, 0 }
|
1995-05-30 08:16:23 +00:00
|
|
|
};
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/* the below structure is so we have a default dev struct for our link struct */
|
|
|
|
struct scsi_device ahc_dev =
|
|
|
|
{
|
|
|
|
NULL, /* Use default error handler */
|
|
|
|
NULL, /* have a queue, served by this */
|
|
|
|
NULL, /* have no async handler */
|
|
|
|
NULL, /* Use default 'done' routine */
|
|
|
|
"ahc",
|
1995-05-30 08:16:23 +00:00
|
|
|
0,
|
1994-11-17 20:22:31 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
1994-11-18 20:34:30 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* All of these should be in a separate header file shared by the sequencer
|
1995-05-30 08:16:23 +00:00
|
|
|
* code and the kernel level driver. The only catch is that we would need to
|
|
|
|
* add an additional 0xc00 offset when using them in the kernel driver. The
|
|
|
|
* aic7770 assembler must be modified to allow include files as well. All
|
|
|
|
* page numbers refer to the Adaptec AIC-7770 Data Book availible from
|
1995-01-13 02:24:31 +00:00
|
|
|
* Adaptec's Technical Documents Department 1-800-934-2766
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------- AIC-7770 offset definitions ----------------------- */
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
|
|
|
* SCSI Sequence Control (p. 3-11).
|
1994-11-17 20:22:31 +00:00
|
|
|
* Each bit, when set starts a specific SCSI sequence on the bus
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCSISEQ 0xc00ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define TEMODEO 0x80
|
|
|
|
#define ENSELO 0x40
|
|
|
|
#define ENSELI 0x20
|
|
|
|
#define ENRSELI 0x10
|
|
|
|
#define ENAUTOATNO 0x08
|
|
|
|
#define ENAUTOATNI 0x04
|
|
|
|
#define ENAUTOATNP 0x02
|
|
|
|
#define SCSIRSTO 0x01
|
|
|
|
|
1995-01-22 00:48:39 +00:00
|
|
|
/*
|
|
|
|
* SCSI Transfer Control 1 Register (pp. 3-14,15).
|
|
|
|
* Controls the SCSI module data path.
|
|
|
|
*/
|
|
|
|
#define SXFRCTL1 0xc02ul
|
|
|
|
#define BITBUCKET 0x80
|
|
|
|
#define SWRAPEN 0x40
|
|
|
|
#define ENSPCHK 0x20
|
|
|
|
#define STIMESEL 0x18
|
|
|
|
#define ENSTIMER 0x04
|
|
|
|
#define ACTNEGEN 0x02
|
|
|
|
#define STPWEN 0x01 /* Powered Termination */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCSI Interrrupt Mode 1 (pp. 3-28,29).
|
|
|
|
* Set bits in this register enable the corresponding
|
|
|
|
* interrupt source.
|
|
|
|
*/
|
|
|
|
#define SIMODE1 0xc11ul
|
|
|
|
#define ENSELTIMO 0x80
|
|
|
|
#define ENATNTARG 0x40
|
|
|
|
#define ENSCSIRST 0x20
|
|
|
|
#define ENPHASEMIS 0x10
|
|
|
|
#define ENBUSFREE 0x08
|
|
|
|
#define ENSCSIPERR 0x04
|
|
|
|
#define ENPHASECHG 0x02
|
|
|
|
#define ENREQINIT 0x01
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* SCSI Control Signal Read Register (p. 3-15).
|
1994-11-17 20:22:31 +00:00
|
|
|
* Reads the actual state of the SCSI bus pins
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCSISIGI 0xc03ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define CDI 0x80
|
|
|
|
#define IOI 0x40
|
|
|
|
#define MSGI 0x20
|
|
|
|
#define ATNI 0x10
|
|
|
|
#define SELI 0x08
|
|
|
|
#define BSYI 0x04
|
|
|
|
#define REQI 0x02
|
|
|
|
#define ACKI 0x01
|
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* SCSI Contol Signal Write Register (p. 3-16).
|
|
|
|
* Writing to this register modifies the control signals on the bus. Only
|
1994-11-17 20:22:31 +00:00
|
|
|
* those signals that are allowed in the current mode (Initiator/Target) are
|
|
|
|
* asserted.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCSISIGO 0xc03ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define CDO 0x80
|
|
|
|
#define IOO 0x40
|
|
|
|
#define MSGO 0x20
|
|
|
|
#define ATNO 0x10
|
|
|
|
#define SELO 0x08
|
|
|
|
#define BSYO 0x04
|
|
|
|
#define REQO 0x02
|
|
|
|
#define ACKO 0x01
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
/*
|
|
|
|
* SCSI Rate Control (p. 3-17).
|
|
|
|
* Contents of this register determine the Synchronous SCSI data transfer
|
|
|
|
* rate and the maximum synchronous Req/Ack offset. An offset of 0 in the
|
|
|
|
* SOFS (3:0) bits disables synchronous data transfers. Any offset value
|
|
|
|
* greater than 0 enables synchronous transfers.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCSIRATE 0xc04ul
|
1995-06-11 19:33:05 +00:00
|
|
|
#define WIDEXFER 0x80 /* Wide transfer control */
|
|
|
|
#define SXFR 0x70 /* Sync transfer rate */
|
|
|
|
#define SOFS 0x0f /* Sync offset */
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* SCSI ID (p. 3-18).
|
|
|
|
* Contains the ID of the board and the current target on the
|
|
|
|
* selected channel
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCSIID 0xc05ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define TID 0xf0 /* Target ID mask */
|
|
|
|
#define OID 0x0f /* Our ID mask */
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* SCSI Transfer Count (pp. 3-19,20)
|
|
|
|
* These registers count down the number of bytes transfered
|
|
|
|
* across the SCSI bus. The counter is decrimented only once
|
|
|
|
* the data has been safely transfered. SDONE in SSTAT0 is
|
|
|
|
* set when STCNT goes to 0
|
|
|
|
*/
|
|
|
|
#define STCNT 0xc08ul
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* SCSI Status 0 (p. 3-21)
|
|
|
|
* Contains one set of SCSI Interrupt codes
|
|
|
|
* These are most likely of interest to the sequencer
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SSTAT0 0xc0bul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define TARGET 0x80 /* Board is a target */
|
|
|
|
#define SELDO 0x40 /* Selection Done */
|
|
|
|
#define SELDI 0x20 /* Board has been selected */
|
|
|
|
#define SELINGO 0x10 /* Selection In Progress */
|
|
|
|
#define SWRAP 0x08 /* 24bit counter wrap */
|
|
|
|
#define SDONE 0x04 /* STCNT = 0x000000 */
|
|
|
|
#define SPIORDY 0x02 /* SCSI PIO Ready */
|
|
|
|
#define DMADONE 0x01 /* DMA transfer completed */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear SCSI Interrupt 1 (p. 3-23)
|
|
|
|
* Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1.
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define CLRSINT1 0xc0cul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define CLRSELTIMEO 0x80
|
|
|
|
#define CLRATNO 0x40
|
|
|
|
#define CLRSCSIRSTI 0x20
|
|
|
|
/* UNUSED 0x10 */
|
|
|
|
#define CLRBUSFREE 0x08
|
|
|
|
#define CLRSCSIPERR 0x04
|
|
|
|
#define CLRPHASECHG 0x02
|
|
|
|
#define CLRREQINIT 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCSI Status 1 (p. 3-24)
|
|
|
|
* These interrupt bits are of interest to the kernel driver
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SSTAT1 0xc0cul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define SELTO 0x80
|
|
|
|
#define ATNTARG 0x40
|
|
|
|
#define SCSIRSTI 0x20
|
|
|
|
#define PHASEMIS 0x10
|
|
|
|
#define BUSFREE 0x08
|
|
|
|
#define SCSIPERR 0x04
|
|
|
|
#define PHASECHG 0x02
|
|
|
|
#define REQINIT 0x01
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* SCSI/Host Address (p. 3-30)
|
|
|
|
* These registers hold the host address for the byte about to be
|
|
|
|
* transfered on the SCSI bus. They are counted up in the same
|
|
|
|
* manner as STCNT is counted down. SHADDR should always be used
|
|
|
|
* to determine the address of the last byte transfered since HADDR
|
|
|
|
* can be squewed by write ahead.
|
|
|
|
*/
|
|
|
|
#define SHADDR 0xc14ul
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Selection/Reselection ID (p. 3-31)
|
|
|
|
* Upper four bits are the device id. The ONEBIT is set when the re/selecting
|
|
|
|
* device did not set its own ID.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SELID 0xc19ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define SELID_MASK 0xf0
|
|
|
|
#define ONEBIT 0x08
|
|
|
|
/* UNUSED 0x07 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCSI Block Control (p. 3-32)
|
|
|
|
* Controls Bus type and channel selection. In a twin channel configuration
|
|
|
|
* addresses 0x00-0x1e are gated to the appropriate channel based on this
|
|
|
|
* register. SELWIDE allows for the coexistence of 8bit and 16bit devices
|
|
|
|
* on a wide bus.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SBLKCTL 0xc1ful
|
1994-11-17 20:22:31 +00:00
|
|
|
/* UNUSED 0xc0 */
|
|
|
|
#define AUTOFLUSHDIS 0x20
|
|
|
|
/* UNUSED 0x10 */
|
|
|
|
#define SELBUSB 0x08
|
|
|
|
/* UNUSED 0x04 */
|
1995-05-30 08:16:23 +00:00
|
|
|
#define SELWIDE 0x02
|
1994-11-17 20:22:31 +00:00
|
|
|
/* UNUSED 0x01 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sequencer Control (p. 3-33)
|
|
|
|
* Error detection mode and speed configuration
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SEQCTL 0xc60ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define PERRORDIS 0x80
|
|
|
|
#define PAUSEDIS 0x40
|
|
|
|
#define FAILDIS 0x20
|
|
|
|
#define FASTMODE 0x10
|
|
|
|
#define BRKADRINTEN 0x08
|
|
|
|
#define STEP 0x04
|
|
|
|
#define SEQRESET 0x02
|
|
|
|
#define LOADRAM 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sequencer RAM Data (p. 3-34)
|
|
|
|
* Single byte window into the Scratch Ram area starting at the address
|
|
|
|
* specified by SEQADDR0 and SEQADDR1. To write a full word, simply write
|
|
|
|
* four bytes in sucessesion. The SEQADDRs will increment after the most
|
|
|
|
* significant byte is written
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SEQRAM 0xc61ul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Sequencer Address Registers (p. 3-35)
|
1994-11-17 20:22:31 +00:00
|
|
|
* Only the first bit of SEQADDR1 holds addressing information
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SEQADDR0 0xc62ul
|
|
|
|
#define SEQADDR1 0xc63ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define SEQADDR1_MASK 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Accumulator
|
|
|
|
* We cheat by passing arguments in the Accumulator up to the kernel driver
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define ACCUM 0xc64ul
|
|
|
|
|
|
|
|
#define SINDEX 0xc65ul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Board Control (p. 3-43)
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define BCTL 0xc84ul
|
1994-11-17 20:22:31 +00:00
|
|
|
/* RSVD 0xf0 */
|
|
|
|
#define ACE 0x08 /* Support for external processors */
|
|
|
|
/* RSVD 0x06 */
|
|
|
|
#define ENABLE 0x01
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* Bus On/Off Time (p. 3-44)
|
|
|
|
*/
|
|
|
|
#define BUSTIME 0xc85ul
|
|
|
|
#define BOFF 0xf0
|
|
|
|
#define BON 0x0f
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bus Speed (p. 3-45)
|
|
|
|
*/
|
|
|
|
#define BUSSPD 0xc86ul
|
|
|
|
#define DFTHRSH 0xc0
|
|
|
|
#define STBOFF 0x38
|
|
|
|
#define STBON 0x07
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Host Control (p. 3-47) R/W
|
1995-05-30 08:16:23 +00:00
|
|
|
* Overal host control of the device.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define HCNTRL 0xc87ul
|
1994-11-17 20:22:31 +00:00
|
|
|
/* UNUSED 0x80 */
|
|
|
|
#define POWRDN 0x40
|
|
|
|
/* UNUSED 0x20 */
|
|
|
|
#define SWINT 0x10
|
|
|
|
#define IRQMS 0x08
|
|
|
|
#define PAUSE 0x04
|
|
|
|
#define INTEN 0x02
|
|
|
|
#define CHIPRST 0x01
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* Host Address (p. 3-48)
|
|
|
|
* This register contains the address of the byte about
|
|
|
|
* to be transfered across the host bus.
|
|
|
|
*/
|
|
|
|
#define HADDR 0xc88ul
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* SCB Pointer (p. 3-49)
|
|
|
|
* Gate one of the four SCBs into the SCBARRAY window.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCBPTR 0xc90ul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt Status (p. 3-50)
|
|
|
|
* Status for system interrupts
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define INTSTAT 0xc91ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define SEQINT_MASK 0xf0 /* SEQINT Status Codes */
|
|
|
|
#define BAD_PHASE 0x00
|
1995-01-16 16:33:47 +00:00
|
|
|
#define SEND_REJECT 0x10
|
1994-11-17 20:22:31 +00:00
|
|
|
#define NO_IDENT 0x20
|
|
|
|
#define NO_MATCH 0x30
|
1995-01-13 02:24:31 +00:00
|
|
|
#define MSG_SDTR 0x40
|
1995-01-16 16:33:47 +00:00
|
|
|
#define MSG_WDTR 0x50
|
|
|
|
#define MSG_REJECT 0x60
|
|
|
|
#define BAD_STATUS 0x70
|
1995-03-31 13:54:41 +00:00
|
|
|
#define RESIDUAL 0x80
|
1995-04-01 19:53:04 +00:00
|
|
|
#define ABORT_TAG 0x90
|
1995-07-04 21:14:45 +00:00
|
|
|
#define AWAITING_MSG 0xa0
|
1994-11-17 20:22:31 +00:00
|
|
|
#define BRKADRINT 0x08
|
|
|
|
#define SCSIINT 0x04
|
|
|
|
#define CMDCMPLT 0x02
|
|
|
|
#define SEQINT 0x01
|
1995-03-31 13:54:41 +00:00
|
|
|
#define INT_PEND (BRKADRINT | SEQINT | SCSIINT | CMDCMPLT)
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Hard Error (p. 3-53)
|
1995-05-30 08:16:23 +00:00
|
|
|
* Reporting of catastrophic errors. You usually cannot recover from
|
1994-11-17 20:22:31 +00:00
|
|
|
* these without a full board reset.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define ERROR 0xc92ul
|
1994-11-17 20:22:31 +00:00
|
|
|
/* UNUSED 0xf0 */
|
|
|
|
#define PARERR 0x08
|
|
|
|
#define ILLOPCODE 0x04
|
|
|
|
#define ILLSADDR 0x02
|
|
|
|
#define ILLHADDR 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear Interrupt Status (p. 3-52)
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define CLRINT 0xc92ul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define CLRBRKADRINT 0x08
|
1995-03-31 13:54:41 +00:00
|
|
|
#define CLRSCSIINT 0x04
|
1994-11-17 20:22:31 +00:00
|
|
|
#define CLRCMDINT 0x02
|
|
|
|
#define CLRSEQINT 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCB Auto Increment (p. 3-59)
|
1995-05-30 08:16:23 +00:00
|
|
|
* Byte offset into the SCB Array and an optional bit to allow auto
|
1994-11-17 20:22:31 +00:00
|
|
|
* incrementing of the address during download and upload operations
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCBCNT 0xc9aul
|
1994-11-17 20:22:31 +00:00
|
|
|
#define SCBAUTO 0x80
|
|
|
|
#define SCBCNT_MASK 0x1f
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue In FIFO (p. 3-60)
|
|
|
|
* Input queue for queued SCBs (commands that the seqencer has yet to start)
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define QINFIFO 0xc9bul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue In Count (p. 3-60)
|
|
|
|
* Number of queued SCBs
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define QINCNT 0xc9cul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue Out FIFO (p. 3-61)
|
|
|
|
* Queue of SCBs that have completed and await the host
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define QOUTFIFO 0xc9dul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Queue Out Count (p. 3-61)
|
|
|
|
* Number of queued SCBs in the Out FIFO
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define QOUTCNT 0xc9eul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCBARRAY 0xca0ul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/* ---------------- END AIC-7770 Register Definitions ----------------- */
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
/* --------------------- AIC-7870-only definitions -------------------- */
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
#define DSPCISTATUS 0xc86ul
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* Serial EEPROM Control (p. 4-92 in 7870 Databook)
|
|
|
|
* Controls the reading and writing of an external serial 1-bit
|
|
|
|
* EEPROM Device. In order to access the serial EEPROM, you must
|
|
|
|
* first set the SEEMS bit that generates a request to the memory
|
|
|
|
* port for access to the serial EEPROM device. When the memory
|
|
|
|
* port is not busy servicing another request, it reconfigures
|
|
|
|
* to allow access to the serial EEPROM. When this happens, SEERDY
|
|
|
|
* gets set high to verify that the memory port access has been
|
|
|
|
* granted.
|
|
|
|
*
|
|
|
|
* After successful arbitration for the memory port, the SEECS bit of
|
|
|
|
* the SEECTL register is connected to the chip select. The SEECK,
|
|
|
|
* SEEDO, and SEEDI are connected to the clock, data out, and data in
|
|
|
|
* lines respectively. The SEERDY bit of SEECTL is useful in that it
|
|
|
|
* gives us an 800 nsec timer. After a write to the SEECTL register,
|
|
|
|
* the SEERDY goes high 800 nsec later. The one exception to this is
|
|
|
|
* when we first request access to the memory port. The SEERDY goes
|
|
|
|
* high to signify that access has been granted and, for this case, has
|
|
|
|
* no implied timing.
|
|
|
|
*
|
|
|
|
* See 93cx6.c for detailed information on the protocol necessary to
|
|
|
|
* read the serial EEPROM.
|
|
|
|
*/
|
|
|
|
#define SEECTL 0xc1eul
|
|
|
|
#define EXTARBACK 0x80
|
|
|
|
#define EXTARBREQ 0x40
|
|
|
|
#define SEEMS 0x20
|
|
|
|
#define SEERDY 0x10
|
|
|
|
#define SEECS 0x08
|
|
|
|
#define SEECK 0x04
|
|
|
|
#define SEEDO 0x02
|
|
|
|
#define SEEDI 0x01
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/* ---------------------- Scratch RAM Offsets ------------------------- */
|
|
|
|
/* These offsets are either to values that are initialized by the board's
|
|
|
|
* BIOS or are specified by the Linux sequencer code. If I can figure out
|
|
|
|
* how to read the EISA configuration info at probe time, the cards could
|
|
|
|
* be run without BIOS support installed
|
|
|
|
*/
|
|
|
|
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
|
|
|
* 1 byte per target starting at this address for configuration values
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define HA_TARG_SCRATCH 0xc20ul
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* The sequencer will stick the frist byte of any rejected message here so
|
|
|
|
* we can see what is getting thrown away.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
#define HA_REJBYTE 0xc31ul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
/*
|
|
|
|
* Bit vector of targets that have disconnection disabled.
|
|
|
|
*/
|
|
|
|
#define HA_DISC_DSB 0xc32ul
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Length of pending message
|
|
|
|
*/
|
1995-02-22 01:43:25 +00:00
|
|
|
#define HA_MSG_LEN 0xc34ul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* message body
|
|
|
|
*/
|
1995-02-22 01:43:25 +00:00
|
|
|
#define HA_MSG_START 0xc35ul /* outgoing message body */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These are offsets into the card's scratch ram. Some of the values are
|
1995-05-30 08:16:23 +00:00
|
|
|
* specified in the AHA2742 technical reference manual and are initialized
|
1994-11-17 20:22:31 +00:00
|
|
|
* by the BIOS at boot time.
|
|
|
|
*/
|
1995-02-22 01:43:25 +00:00
|
|
|
#define HA_ARG_1 0xc4aul
|
|
|
|
#define HA_RETURN_1 0xc4aul
|
1995-04-27 17:47:17 +00:00
|
|
|
#define SEND_SENSE 0x80
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SEND_WDTR 0x80
|
|
|
|
#define SEND_SDTR 0x80
|
1995-04-15 21:37:32 +00:00
|
|
|
#define SEND_REJ 0x40
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
#define SG_COUNT 0xc4dul
|
|
|
|
#define SG_NEXT 0xc4eul
|
1995-02-22 01:43:25 +00:00
|
|
|
#define HA_SIGSTATE 0xc4bul
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#define HA_SCBCOUNT 0xc52ul
|
|
|
|
#define HA_FLAGS 0xc53ul
|
1995-03-31 13:54:41 +00:00
|
|
|
#define SINGLE_BUS 0x00
|
1994-12-31 19:31:56 +00:00
|
|
|
#define TWIN_BUS 0x01
|
|
|
|
#define WIDE_BUS 0x02
|
1995-01-13 02:24:31 +00:00
|
|
|
#define ACTIVE_MSG 0x20
|
|
|
|
#define IDENTIFY_SEEN 0x40
|
|
|
|
#define RESELECTING 0x80
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#define HA_ACTIVE0 0xc54ul
|
|
|
|
#define HA_ACTIVE1 0xc55ul
|
|
|
|
#define SAVED_TCL 0xc56ul
|
1995-04-27 17:47:17 +00:00
|
|
|
#define WAITING_SCBH 0xc57ul
|
|
|
|
#define WAITING_SCBT 0xc58ul
|
1995-01-13 02:24:31 +00:00
|
|
|
|
|
|
|
#define HA_SCSICONF 0xc5aul
|
|
|
|
#define INTDEF 0xc5cul
|
|
|
|
#define HA_HOSTCONF 0xc5dul
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
#define HA_274_BIOSCTRL 0xc5ful
|
|
|
|
#define BIOSMODE 0x30
|
|
|
|
#define BIOSDISABLED 0x30
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
#define MSG_ABORT 0x06
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
#define MSG_BUS_DEVICE_RESET 0x0c
|
1995-01-13 02:24:31 +00:00
|
|
|
#define BUS_8_BIT 0x00
|
|
|
|
#define BUS_16_BIT 0x01
|
|
|
|
#define BUS_32_BIT 0x02
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* Define the format of the SEEPROM registers (16 bits).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct seeprom_config {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SCSI ID Configuration Flags
|
|
|
|
*/
|
|
|
|
#define CFXFER 0x0007 /* synchronous transfer rate */
|
|
|
|
#define CFSYNCH 0x0008 /* enable synchronous transfer */
|
|
|
|
#define CFDISC 0x0010 /* enable disconnection */
|
|
|
|
#define CFWIDEB 0x0020 /* wide bus device */
|
|
|
|
/* UNUSED 0x00C0 */
|
|
|
|
#define CFSTART 0x0100 /* send start unit SCSI command */
|
|
|
|
#define CFINCBIOS 0x0200 /* include in BIOS scan */
|
|
|
|
#define CFRNFOUND 0x0400 /* report even if not found */
|
|
|
|
/* UNUSED 0xf800 */
|
|
|
|
unsigned short device_flags[16]; /* words 0-15 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BIOS Control Bits
|
|
|
|
*/
|
|
|
|
#define CFSUPREM 0x0001 /* support all removeable drives */
|
|
|
|
#define CFSUPREMB 0x0002 /* support removeable drives for boot only */
|
|
|
|
#define CFBIOSEN 0x0004 /* BIOS enabled */
|
|
|
|
/* UNUSED 0x0008 */
|
|
|
|
#define CFSM2DRV 0x0010 /* support more than two drives */
|
|
|
|
/* UNUSED 0x0060 */
|
|
|
|
#define CFEXTEND 0x0080 /* extended translation enabled */
|
|
|
|
/* UNUSED 0xff00 */
|
|
|
|
unsigned short bios_control; /* word 16 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Host Adapter Control Bits
|
|
|
|
*/
|
|
|
|
/* UNUSED 0x0003 */
|
|
|
|
#define CFSTERM 0x0004 /* SCSI low byte termination (non-wide cards) */
|
|
|
|
#define CFWSTERM 0x0008 /* SCSI high byte termination (wide card) */
|
|
|
|
#define CFSPARITY 0x0010 /* SCSI parity */
|
|
|
|
/* UNUSED 0x0020 */
|
|
|
|
#define CFRESETB 0x0040 /* reset SCSI bus at IC initialization */
|
|
|
|
/* UNUSED 0xff80 */
|
|
|
|
unsigned short adapter_control; /* word 17 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Bus Release, Host Adapter ID
|
|
|
|
*/
|
|
|
|
#define CFSCSIID 0x000f /* host adapter SCSI ID */
|
|
|
|
/* UNUSED 0x00f0 */
|
|
|
|
#define CFBRTIME 0xff00 /* bus release time */
|
|
|
|
unsigned short brtime_id; /* word 18 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum targets
|
|
|
|
*/
|
|
|
|
#define CFMAXTARG 0x00ff /* maximum targets */
|
|
|
|
/* UNUSED 0xff00 */
|
|
|
|
unsigned short max_targets; /* word 19 */
|
|
|
|
|
|
|
|
unsigned short res_1[11]; /* words 20-30 */
|
|
|
|
unsigned short checksum; /* word 31 */
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Since the sequencer can disable pausing in a critical section, we
|
1995-05-30 08:16:23 +00:00
|
|
|
* must loop until it actually stops.
|
1994-12-31 19:31:56 +00:00
|
|
|
* XXX Should add a timeout in here??
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
#define PAUSE_SEQUENCER(ahc) \
|
1995-03-31 13:54:41 +00:00
|
|
|
outb(HCNTRL + ahc->baseport, ahc->pause); \
|
1994-11-17 20:22:31 +00:00
|
|
|
\
|
|
|
|
while ((inb(HCNTRL + ahc->baseport) & PAUSE) == 0) \
|
1995-05-30 08:16:23 +00:00
|
|
|
;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
#define UNPAUSE_SEQUENCER(ahc) \
|
1995-05-30 08:16:23 +00:00
|
|
|
outb( HCNTRL + ahc->baseport, ahc->unpause )
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Restart the sequencer program from address zero
|
|
|
|
*/
|
|
|
|
#define RESTART_SEQUENCER(ahc) \
|
|
|
|
do { \
|
1994-12-31 19:31:56 +00:00
|
|
|
outb( SEQCTL + ahc->baseport, SEQRESET|FASTMODE ); \
|
1995-01-13 02:24:31 +00:00
|
|
|
} while (inb(SEQADDR0 + ahc->baseport) != 0 && \
|
|
|
|
inb(SEQADDR1 + ahc->baseport != 0)); \
|
1994-11-17 20:22:31 +00:00
|
|
|
\
|
1995-05-30 08:16:23 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1994-11-17 20:22:31 +00:00
|
|
|
void
|
|
|
|
ahc_print_scb(scb)
|
|
|
|
struct scb *scb;
|
|
|
|
{
|
1995-02-22 01:43:25 +00:00
|
|
|
printf("scb:0x%x control:0x%x tcl:0x%x cmdlen:%d cmdpointer:0x%x\n"
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb
|
|
|
|
,scb->control
|
|
|
|
,scb->target_channel_lun
|
|
|
|
,scb->cmdlen
|
1995-05-30 08:16:23 +00:00
|
|
|
,scb->cmdpointer );
|
1995-02-22 01:43:25 +00:00
|
|
|
printf(" datlen:%d data:0x%x res:0x%x segs:0x%x segp:0x%x\n"
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb->datalen[2] << 16 | scb->datalen[1] << 8 | scb->datalen[0]
|
|
|
|
,scb->data
|
1995-05-30 08:16:23 +00:00
|
|
|
,scb->RESERVED[1] << 8 | scb->RESERVED[0]
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb->SG_segment_count
|
|
|
|
,scb->SG_list_pointer);
|
|
|
|
printf(" sg_addr:%x sg_len:%d\n"
|
|
|
|
,scb->ahc_dma[0].addr
|
|
|
|
,scb->ahc_dma[0].len);
|
|
|
|
printf(" size:%d\n"
|
|
|
|
,(int)&(scb->next) - (int)scb);
|
|
|
|
}
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
void
|
|
|
|
ahc_print_active_scb(ahc)
|
1994-11-17 20:22:31 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
{
|
|
|
|
int cur_scb_offset;
|
1995-01-13 02:24:31 +00:00
|
|
|
u_long iobase = ahc->baseport;
|
1994-11-17 20:22:31 +00:00
|
|
|
PAUSE_SEQUENCER(ahc);
|
1995-03-17 23:58:27 +00:00
|
|
|
cur_scb_offset = inb(SCBPTR + iobase);
|
1994-11-17 20:22:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
ahc_print_scb(ahc->scbarray[cur_scb_offset]);
|
|
|
|
}
|
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#endif
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
#define PARERR 0x08
|
|
|
|
#define ILLOPCODE 0x04
|
|
|
|
#define ILLSADDR 0x02
|
|
|
|
#define ILLHADDR 0x01
|
|
|
|
|
|
|
|
static struct {
|
1995-05-30 08:16:23 +00:00
|
|
|
u_char errno;
|
1994-11-17 20:22:31 +00:00
|
|
|
char *errmesg;
|
|
|
|
} hard_error[] = {
|
1995-03-07 08:59:28 +00:00
|
|
|
{ ILLHADDR, "Illegal Host Access" },
|
|
|
|
{ ILLSADDR, "Illegal Sequencer Address referrenced" },
|
|
|
|
{ ILLOPCODE, "Illegal Opcode in sequencer program" },
|
|
|
|
{ PARERR, "Sequencer Ram Parity Error" }
|
1995-05-30 08:16:23 +00:00
|
|
|
};
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Valid SCSIRATE values. (p. 3-17)
|
|
|
|
* Provides a mapping of tranfer periods in ns to the proper value to
|
|
|
|
* stick in the scsiscfr reg to use that transfer rate.
|
|
|
|
*/
|
|
|
|
static struct {
|
|
|
|
short sxfr;
|
|
|
|
short period; /* in ns */
|
|
|
|
char *rate;
|
|
|
|
} ahc_syncrates[] = {
|
1995-03-07 08:59:28 +00:00
|
|
|
{ 0x00, 100, "10.0" },
|
|
|
|
{ 0x10, 125, "8.0" },
|
|
|
|
{ 0x20, 150, "6.67" },
|
|
|
|
{ 0x30, 175, "5.7" },
|
|
|
|
{ 0x40, 200, "5.0" },
|
|
|
|
{ 0x50, 225, "4.4" },
|
|
|
|
{ 0x60, 250, "4.0" },
|
|
|
|
{ 0x70, 275, "3.6" }
|
1994-11-17 20:22:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int ahc_num_syncrates =
|
|
|
|
sizeof(ahc_syncrates) / sizeof(ahc_syncrates[0]);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if the device can be found at the port given
|
|
|
|
* and if so, determine configuration and set it up for further work.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
1995-01-13 02:24:31 +00:00
|
|
|
ahcprobe(unit, iobase, type)
|
|
|
|
int unit;
|
|
|
|
u_long iobase;
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_type type;
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find unit and check we have that many defined
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
|
|
|
|
if (unit >= NAHC) {
|
|
|
|
printf("ahc: unit number (%d) too high\n", unit);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a storage area for us
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ahcdata[unit]) {
|
|
|
|
printf("ahc%d: memory already allocated\n", unit);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
ahc = malloc(sizeof(struct ahc_data), M_TEMP, M_NOWAIT);
|
|
|
|
if (!ahc) {
|
|
|
|
printf("ahc%d: cannot malloc!\n", unit);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
bzero(ahc, sizeof(struct ahc_data));
|
|
|
|
ahcdata[unit] = ahc;
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc->baseport = iobase;
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc->type = type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to initialize a unit at this location
|
|
|
|
* reset the AIC-7770, read its registers,
|
|
|
|
* and fill in the dev structure accordingly
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ahc_init(unit) != 0) {
|
|
|
|
ahcdata[unit] = NULL;
|
|
|
|
free(ahc, M_TEMP);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
return (1);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look up the valid period to SCSIRATE conversion in our table.
|
|
|
|
*/
|
|
|
|
static
|
|
|
|
void ahc_scsirate(scsirate, period, offset, unit, target )
|
|
|
|
u_char *scsirate;
|
|
|
|
u_char period, offset;
|
|
|
|
int unit, target;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ahc_num_syncrates; i++) {
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
if ((ahc_syncrates[i].period - period) >= 0) {
|
|
|
|
*scsirate = (ahc_syncrates[i].sxfr) | (offset & 0x0f);
|
1995-01-13 02:24:31 +00:00
|
|
|
printf("ahc%d: target %d synchronous at %sMB/s, "
|
1995-05-30 08:16:23 +00:00
|
|
|
"offset = 0x%x\n", unit, target,
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
ahc_syncrates[i].rate, offset );
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
#endif /* AHC_DEBUG */
|
1994-11-17 20:22:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1995-04-15 21:37:32 +00:00
|
|
|
/* Default to asyncronous transfers. Also reject this SDTR request. */
|
|
|
|
*scsirate = 0;
|
1994-11-17 20:22:31 +00:00
|
|
|
printf("ahc%d: target %d using asyncronous transfers\n",
|
|
|
|
unit, target );
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
#endif /* AHC_DEBUG */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach all the sub-devices we can find
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
int
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc_attach(unit)
|
|
|
|
int unit;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* fill in the prototype scsi_link.
|
|
|
|
*/
|
|
|
|
ahc->sc_link.adapter_unit = unit;
|
|
|
|
ahc->sc_link.adapter_targ = ahc->our_id;
|
|
|
|
ahc->sc_link.adapter = &ahc_switch;
|
1995-03-17 23:58:27 +00:00
|
|
|
ahc->sc_link.opennings = 2;
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc->sc_link.device = &ahc_dev;
|
|
|
|
ahc->sc_link.flags = DEBUGLEVEL;
|
1994-12-31 19:31:56 +00:00
|
|
|
ahc->sc_link.fordriver = 0;
|
1994-11-18 20:34:30 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* ask the adapter what subunits are present
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
printf("ahc%d: Probing channel A\n", unit);
|
1995-05-30 08:16:23 +00:00
|
|
|
scsi_attachdevs(&(ahc->sc_link));
|
1995-02-22 01:43:25 +00:00
|
|
|
if(ahc->type & AHC_TWIN) {
|
1994-12-31 19:31:56 +00:00
|
|
|
/* Configure the second scsi bus */
|
|
|
|
ahc->sc_link_b = ahc->sc_link;
|
1995-07-04 21:14:45 +00:00
|
|
|
ahc->sc_link_b.adapter_targ = ahc->our_id_b;
|
1994-12-31 19:31:56 +00:00
|
|
|
ahc->sc_link_b.fordriver = (void *)0x0008;
|
|
|
|
printf("ahc%d: Probing Channel B\n", unit);
|
1995-05-30 08:16:23 +00:00
|
|
|
scsi_attachdevs(&(ahc->sc_link_b));
|
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
void
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_send_scb( ahc, scb )
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
struct scb *scb;
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1995-01-13 02:24:31 +00:00
|
|
|
u_long iobase = ahc->baseport;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
PAUSE_SEQUENCER(ahc);
|
1995-04-27 17:47:17 +00:00
|
|
|
outb(QINFIFO + iobase, scb->position);
|
1994-11-17 20:22:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
}
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
static
|
1995-01-13 02:24:31 +00:00
|
|
|
void ahc_getscb(iobase, scb)
|
|
|
|
u_long iobase;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct scb *scb;
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SCBCNT + iobase, 0x80); /* SCBAUTO */
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
insb(SCBARRAY + iobase, scb, SCB_UP_SIZE);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SCBCNT + iobase, 0);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* Catch an interrupt from the adaptor
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
int
|
|
|
|
ahcintr(unit)
|
|
|
|
int unit;
|
|
|
|
{
|
|
|
|
int intstat;
|
|
|
|
u_char status;
|
1995-05-30 08:16:23 +00:00
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
1995-01-13 02:24:31 +00:00
|
|
|
u_long iobase = ahc->baseport;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct scb *scb = NULL;
|
1995-05-30 08:16:23 +00:00
|
|
|
struct scsi_xfer *xs = NULL;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
intstat = inb(INTSTAT + iobase);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-03-31 13:54:41 +00:00
|
|
|
/*
|
|
|
|
* Is this interrupt for me? or for
|
|
|
|
* someone who is sharing my interrupt
|
|
|
|
*/
|
|
|
|
if (!(intstat & INT_PEND))
|
|
|
|
return 0;
|
1995-05-30 08:16:23 +00:00
|
|
|
if (intstat & BRKADRINT) {
|
1994-11-17 20:22:31 +00:00
|
|
|
/* We upset the sequencer :-( */
|
|
|
|
|
|
|
|
/* Lookup the error message */
|
1995-01-13 02:24:31 +00:00
|
|
|
int i, error = inb(ERROR + iobase);
|
1994-11-17 20:22:31 +00:00
|
|
|
int num_errors = sizeof(hard_error)/sizeof(hard_error[0]);
|
|
|
|
for(i = 0; error != 1 && i < num_errors; i++)
|
|
|
|
error >>= 1;
|
1995-03-31 13:54:41 +00:00
|
|
|
panic("ahc%d: brkadrint, %s at seqaddr = 0x%x\n",
|
1995-05-30 08:16:23 +00:00
|
|
|
unit, hard_error[i].errmesg,
|
|
|
|
(inb(SEQADDR1 + iobase) << 8) |
|
1995-01-13 02:24:31 +00:00
|
|
|
inb(SEQADDR0 + iobase));
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
if (intstat & SEQINT) {
|
|
|
|
u_short targ_mask;
|
|
|
|
u_char target = (inb(SCSIID + iobase) >> 4) & 0x0f;
|
|
|
|
u_char scratch_offset = target;
|
|
|
|
char channel =
|
|
|
|
inb(SBLKCTL + iobase) & SELBUSB ? 'B': 'A';
|
|
|
|
|
|
|
|
if (channel == 'B')
|
|
|
|
scratch_offset += 8;
|
|
|
|
targ_mask = (0x01 << scratch_offset);
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
switch (intstat & SEQINT_MASK) {
|
|
|
|
case BAD_PHASE:
|
1995-06-11 19:33:05 +00:00
|
|
|
panic("ahc%d:%c:%d: unknown scsi bus phase. "
|
|
|
|
"Attempting to continue\n",
|
|
|
|
unit, channel, target);
|
|
|
|
break;
|
|
|
|
case SEND_REJECT:
|
1995-07-04 21:14:45 +00:00
|
|
|
{
|
|
|
|
u_char rejbyte = inb(HA_REJBYTE + iobase);
|
|
|
|
printf("ahc%d:%c:%d: Warning - message "
|
|
|
|
"rejected by target: 0x%x\n",
|
|
|
|
unit, channel, target, rejbyte);
|
|
|
|
if(( rejbyte & 0xf0) == 0x20) {
|
|
|
|
/* Tagged Message */
|
|
|
|
printf("ahc%d:%c:%d: Tagged message "
|
|
|
|
"rejected. Disabling tagged "
|
|
|
|
"commands for this target.\n",
|
|
|
|
unit, channel, target);
|
|
|
|
ahc->tagenable &= ~targ_mask;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
case NO_IDENT:
|
|
|
|
panic("ahc%d:%c:%d: Target did not send an IDENTIFY "
|
|
|
|
"message. SAVED_TCL == 0x%x\n",
|
|
|
|
unit, channel, target,
|
1995-02-22 01:43:25 +00:00
|
|
|
inb(SAVED_TCL + iobase));
|
1994-11-17 20:22:31 +00:00
|
|
|
break;
|
|
|
|
case NO_MATCH:
|
|
|
|
{
|
|
|
|
u_char active;
|
1995-01-13 02:24:31 +00:00
|
|
|
int active_port = HA_ACTIVE0 + iobase;
|
1995-07-04 21:14:45 +00:00
|
|
|
printf("ahc%d:%c:%d: no active SCB for "
|
|
|
|
"reconnecting target - "
|
1995-06-11 19:33:05 +00:00
|
|
|
"issuing ABORT\n", unit, channel,
|
|
|
|
target);
|
1995-02-22 01:43:25 +00:00
|
|
|
printf("SAVED_TCL == 0x%x\n",
|
|
|
|
inb(SAVED_TCL + iobase));
|
1995-06-11 19:33:05 +00:00
|
|
|
if(targ_mask & 0xff00) {
|
|
|
|
/*
|
|
|
|
* targets on the Second channel or
|
|
|
|
* above id 7 store info in byte two
|
|
|
|
* of HA_ACTIVE
|
1994-12-31 19:31:56 +00:00
|
|
|
*/
|
|
|
|
active_port++;
|
|
|
|
}
|
|
|
|
active = inb(active_port);
|
|
|
|
active &= ~(0x01 << (target & 0x07));
|
1995-01-16 16:33:47 +00:00
|
|
|
outb(SCBARRAY + iobase, SCB_NEEDDMA);
|
1994-12-31 19:31:56 +00:00
|
|
|
outb(active_port, active);
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(CLRSINT1 + iobase, CLRSELTIMEO);
|
1994-11-17 20:22:31 +00:00
|
|
|
RESTART_SEQUENCER(ahc);
|
|
|
|
break;
|
|
|
|
}
|
1995-01-13 02:24:31 +00:00
|
|
|
case MSG_SDTR:
|
|
|
|
{
|
1995-06-11 19:33:05 +00:00
|
|
|
u_char period, offset, rate;
|
|
|
|
u_char targ_scratch;
|
|
|
|
u_char maxoffset;
|
|
|
|
/*
|
|
|
|
* Help the sequencer to translate the
|
|
|
|
* negotiated transfer rate. Transfer is
|
|
|
|
* 1/4 the period in ns as is returned by
|
|
|
|
* the sync negotiation message. So, we must
|
1995-01-13 02:24:31 +00:00
|
|
|
* multiply by four
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
period = inb(HA_ARG_1 + iobase) << 2;
|
1995-01-13 02:24:31 +00:00
|
|
|
offset = inb(ACCUM + iobase);
|
1995-06-11 19:33:05 +00:00
|
|
|
targ_scratch = inb(HA_TARG_SCRATCH + iobase
|
|
|
|
+ scratch_offset);
|
|
|
|
if(targ_scratch & WIDEXFER)
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
maxoffset = 0x08;
|
|
|
|
else
|
|
|
|
maxoffset = 0x0f;
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc_scsirate(&rate, period,
|
|
|
|
MIN(offset,maxoffset), unit, target);
|
1995-01-13 02:24:31 +00:00
|
|
|
/* Preserve the WideXfer flag */
|
1995-06-11 19:33:05 +00:00
|
|
|
targ_scratch = rate | (targ_scratch & WIDEXFER);
|
|
|
|
outb(HA_TARG_SCRATCH + iobase + scratch_offset,
|
|
|
|
targ_scratch);
|
|
|
|
outb(SCSIRATE + iobase, targ_scratch);
|
|
|
|
if( (targ_scratch & 0x0f) == 0 )
|
1995-04-15 21:37:32 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The requested rate was so low
|
|
|
|
* that asyncronous transfers are
|
1995-05-30 08:16:23 +00:00
|
|
|
* faster (not to mention the
|
1995-04-15 21:37:32 +00:00
|
|
|
* controller won't support them),
|
|
|
|
* so we issue a message reject to
|
|
|
|
* ensure we go to asyncronous
|
|
|
|
* transfers.
|
|
|
|
*/
|
|
|
|
outb(HA_RETURN_1 + iobase, SEND_REJ);
|
|
|
|
}
|
1995-01-13 02:24:31 +00:00
|
|
|
/* See if we initiated Sync Negotiation */
|
1995-06-11 19:33:05 +00:00
|
|
|
else if(ahc->sdtrpending & targ_mask)
|
1995-01-13 02:24:31 +00:00
|
|
|
{
|
1995-03-17 23:58:27 +00:00
|
|
|
/*
|
|
|
|
* Don't send an SDTR back to
|
|
|
|
* the target
|
1995-01-13 02:24:31 +00:00
|
|
|
*/
|
|
|
|
outb(HA_RETURN_1 + iobase, 0);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
/*
|
|
|
|
* Send our own SDTR in reply
|
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if(ahc_debug & AHC_SHOWMISC)
|
|
|
|
printf("Sending SDTR!!\n");
|
|
|
|
#endif
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(HA_RETURN_1 + iobase, SEND_SDTR);
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-03-17 23:58:27 +00:00
|
|
|
* Negate the flags
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needsdtr &= ~targ_mask;
|
|
|
|
ahc->sdtrpending &= ~targ_mask;
|
1995-01-13 02:24:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MSG_WDTR:
|
|
|
|
{
|
1995-06-11 19:33:05 +00:00
|
|
|
u_char scratch, bus_width;
|
1995-01-13 02:24:31 +00:00
|
|
|
|
|
|
|
bus_width = inb(ACCUM + iobase);
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
scratch = inb(HA_TARG_SCRATCH + iobase
|
|
|
|
+ scratch_offset);
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
if(ahc->wdtrpending & targ_mask)
|
1995-01-13 02:24:31 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
|
|
|
* Don't send a WDTR back to the
|
1995-01-13 02:24:31 +00:00
|
|
|
* target, since we asked first.
|
|
|
|
*/
|
|
|
|
outb(HA_RETURN_1 + iobase, 0);
|
|
|
|
switch(bus_width)
|
|
|
|
{
|
|
|
|
case BUS_8_BIT:
|
|
|
|
scratch &= 0x7f;
|
|
|
|
break;
|
|
|
|
case BUS_16_BIT:
|
|
|
|
printf("ahc%d: target "
|
|
|
|
"%d using 16Bit "
|
|
|
|
"transfers\n",
|
1995-06-11 19:33:05 +00:00
|
|
|
unit, target);
|
|
|
|
scratch |= 0x80;
|
1995-01-13 02:24:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Send our own WDTR in reply
|
|
|
|
*/
|
|
|
|
printf("Will Send WDTR!!\n");
|
|
|
|
switch(bus_width)
|
|
|
|
{
|
|
|
|
case BUS_8_BIT:
|
|
|
|
scratch &= 0x7f;
|
|
|
|
break;
|
|
|
|
case BUS_32_BIT:
|
|
|
|
/* Negotiate 16_BITS */
|
|
|
|
bus_width = BUS_16_BIT;
|
|
|
|
case BUS_16_BIT:
|
|
|
|
printf("ahc%d: target "
|
|
|
|
"%d using 16Bit "
|
|
|
|
"transfers\n",
|
1995-06-11 19:33:05 +00:00
|
|
|
unit, target);
|
|
|
|
scratch |= 0x80;
|
1995-01-13 02:24:31 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
outb(HA_RETURN_1 + iobase,
|
1995-01-13 02:24:31 +00:00
|
|
|
bus_width | SEND_WDTR);
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needwdtr &= ~targ_mask;
|
|
|
|
ahc->wdtrpending &= ~targ_mask;
|
|
|
|
outb(HA_TARG_SCRATCH + iobase + scratch_offset,
|
|
|
|
scratch);
|
|
|
|
outb(SCSIRATE + iobase, scratch);
|
1995-01-13 02:24:31 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-01-16 16:33:47 +00:00
|
|
|
case MSG_REJECT:
|
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-01-16 16:33:47 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-16 16:33:47 +00:00
|
|
|
u_char targ_scratch;
|
|
|
|
|
|
|
|
targ_scratch = inb(HA_TARG_SCRATCH + iobase
|
1995-06-11 19:33:05 +00:00
|
|
|
+ scratch_offset);
|
1995-01-16 16:33:47 +00:00
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
if(ahc->wdtrpending & targ_mask){
|
1995-01-16 16:33:47 +00:00
|
|
|
/* note 8bit xfers and clear flag */
|
|
|
|
targ_scratch &= 0x7f;
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needwdtr &= ~targ_mask;
|
|
|
|
ahc->wdtrpending &= ~targ_mask;
|
|
|
|
printf("ahc%d:%c:%d: refusing "
|
1995-01-16 16:33:47 +00:00
|
|
|
"WIDE negotiation. Using "
|
|
|
|
"8bit transfers\n",
|
1995-06-11 19:33:05 +00:00
|
|
|
unit, channel, target);
|
1995-01-16 16:33:47 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
else if(ahc->sdtrpending & targ_mask){
|
1995-01-27 17:37:05 +00:00
|
|
|
/* note asynch xfers and clear flag */
|
|
|
|
targ_scratch &= 0xf0;
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->needsdtr &= ~targ_mask;
|
|
|
|
ahc->sdtrpending &= ~targ_mask;
|
|
|
|
printf("ahc%d:%c:%d: refusing "
|
1995-01-27 17:37:05 +00:00
|
|
|
"syncronous negotiation. Using "
|
|
|
|
"asyncronous transfers\n",
|
1995-06-11 19:33:05 +00:00
|
|
|
unit, channel, target);
|
1995-01-27 17:37:05 +00:00
|
|
|
}
|
1995-03-17 23:58:27 +00:00
|
|
|
else {
|
1995-01-27 17:37:05 +00:00
|
|
|
/*
|
|
|
|
* Otherwise, we ignore it.
|
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
if(ahc_debug & AHC_SHOWMISC)
|
1995-06-11 19:33:05 +00:00
|
|
|
printf("ahc%d:%c:%d: Message
|
|
|
|
reject -- ignored\n",
|
|
|
|
unit, channel, target);
|
1995-03-17 23:58:27 +00:00
|
|
|
#endif
|
1995-01-27 17:37:05 +00:00
|
|
|
break;
|
1995-03-17 23:58:27 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
outb(HA_TARG_SCRATCH + iobase + scratch_offset,
|
1995-01-16 16:33:47 +00:00
|
|
|
targ_scratch);
|
1995-01-27 17:37:05 +00:00
|
|
|
outb(SCSIRATE + iobase, targ_scratch);
|
1995-01-16 16:33:47 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
case BAD_STATUS:
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-03-07 08:59:28 +00:00
|
|
|
int scb_index;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
scb_index = inb(SCBPTR + iobase);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
1995-05-01 09:49:45 +00:00
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Set the default return value to 0 (don't
|
1995-05-01 09:49:45 +00:00
|
|
|
* send sense). The sense code with change
|
1995-05-30 08:16:23 +00:00
|
|
|
* this if needed and this reduces code
|
1995-05-01 09:49:45 +00:00
|
|
|
* duplication.
|
|
|
|
*/
|
|
|
|
outb(HA_RETURN_1 + iobase, 0);
|
1994-11-17 20:22:31 +00:00
|
|
|
if (!scb || !(scb->flags & SCB_ACTIVE)) {
|
1995-06-11 19:33:05 +00:00
|
|
|
printf("ahc%d:%c:%d: ahcintr - referenced scb "
|
|
|
|
"not valid during seqint 0x%x scb(%d)\n",
|
|
|
|
unit, channel, target, intstat, scb_index);
|
1994-11-17 20:22:31 +00:00
|
|
|
goto clear;
|
1995-05-01 09:49:45 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-05-01 09:49:45 +00:00
|
|
|
xs = scb->xs;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-05-01 09:49:45 +00:00
|
|
|
ahc_getscb(iobase, scb);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-05-01 09:49:45 +00:00
|
|
|
if(xs->sc_link->target == DEBUGTARG)
|
1994-12-31 19:31:56 +00:00
|
|
|
ahc_print_scb(scb);
|
1994-11-17 20:22:31 +00:00
|
|
|
#endif
|
1995-05-01 09:49:45 +00:00
|
|
|
xs->status = scb->target_status;
|
|
|
|
switch(scb->target_status){
|
1994-12-31 19:31:56 +00:00
|
|
|
case SCSI_OK:
|
|
|
|
printf("ahc%d: Interrupted for staus of"
|
|
|
|
" 0???\n", unit);
|
|
|
|
break;
|
|
|
|
case SCSI_CHECK:
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("requests Check Status\n");
|
1994-11-17 20:22:31 +00:00
|
|
|
#endif
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
if((xs->error == XS_NOERROR) &&
|
1994-12-31 19:31:56 +00:00
|
|
|
!(scb->flags & SCB_SENSE)) {
|
1995-07-04 21:14:45 +00:00
|
|
|
u_char control = scb->control;
|
1995-04-27 17:47:17 +00:00
|
|
|
u_char head;
|
|
|
|
u_char tail;
|
1995-07-04 21:14:45 +00:00
|
|
|
u_short active;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct ahc_dma_seg *sg = scb->ahc_dma;
|
|
|
|
struct scsi_sense *sc = &(scb->sense_cmd);
|
1994-12-31 19:31:56 +00:00
|
|
|
u_char tcl = scb->target_channel_lun;
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Sending Sense\n");
|
1994-11-17 20:22:31 +00:00
|
|
|
#endif
|
1995-01-13 02:24:31 +00:00
|
|
|
bzero(scb, SCB_DOWN_SIZE);
|
1995-07-04 21:14:45 +00:00
|
|
|
#ifdef NOT_YET
|
|
|
|
scb->control |= control & SCB_DISCENB;
|
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->flags |= SCB_SENSE;
|
|
|
|
sc->op_code = REQUEST_SENSE;
|
|
|
|
sc->byte2 = xs->sc_link->lun << 5;
|
|
|
|
sc->length = sizeof(struct scsi_sense_data);
|
1994-12-31 19:31:56 +00:00
|
|
|
sc->control = 0;
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
sg->addr = KVTOPHYS(&xs->sense);
|
|
|
|
sg->len = sizeof(struct scsi_sense_data);
|
1995-04-23 22:04:58 +00:00
|
|
|
|
1994-12-31 19:31:56 +00:00
|
|
|
scb->target_channel_lun = tcl;
|
|
|
|
scb->SG_segment_count = 1;
|
|
|
|
scb->SG_list_pointer = KVTOPHYS(sg);
|
|
|
|
scb->cmdpointer = KVTOPHYS(sc);
|
|
|
|
scb->cmdlen = sizeof(*sc);
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
scb->data = sg->addr;
|
|
|
|
scb->datalen[0] =
|
|
|
|
sg->len & 0xff;
|
|
|
|
scb->datalen[1] =
|
|
|
|
(sg->len >> 8) & 0xff;
|
|
|
|
scb->datalen[2] =
|
|
|
|
(sg->len >> 16) & 0xff;
|
1995-01-16 16:33:47 +00:00
|
|
|
outb(SCBCNT + iobase, 0x80);
|
1995-01-13 02:24:31 +00:00
|
|
|
outsb(SCBARRAY+iobase,scb,SCB_DOWN_SIZE);
|
|
|
|
outb(SCBCNT + iobase, 0);
|
1995-04-27 17:47:17 +00:00
|
|
|
outb(SCBARRAY+iobase+30,SCB_LIST_NULL);
|
1995-07-04 21:14:45 +00:00
|
|
|
/*
|
|
|
|
* Ensure that the target is "BUSY"
|
|
|
|
* so we don't get overlapping
|
|
|
|
* commands if we happen to be doing
|
|
|
|
* tagged I/O.
|
|
|
|
*/
|
|
|
|
active = inb(HA_ACTIVE0 + iobase)
|
|
|
|
| (inb(HA_ACTIVE1 + iobase) << 8);
|
|
|
|
active |= targ_mask;
|
|
|
|
outb(HA_ACTIVE0 + iobase,active & 0xff);
|
|
|
|
outb(HA_ACTIVE1 + iobase,
|
|
|
|
(active >> 8) & 0xff);
|
1995-04-27 17:47:17 +00:00
|
|
|
/*
|
|
|
|
* Add this SCB to the "waiting for
|
|
|
|
* selection" list.
|
1995-01-13 02:24:31 +00:00
|
|
|
*/
|
1995-04-27 17:47:17 +00:00
|
|
|
head = inb(WAITING_SCBH + iobase);
|
|
|
|
tail = inb(WAITING_SCBT + iobase);
|
1995-07-04 21:14:45 +00:00
|
|
|
if(head == SCB_LIST_NULL) {
|
1995-04-27 17:47:17 +00:00
|
|
|
/* List was empty */
|
1995-05-30 08:16:23 +00:00
|
|
|
head = scb->position;
|
1995-04-27 17:47:17 +00:00
|
|
|
tail = SCB_LIST_NULL;
|
|
|
|
}
|
1995-07-04 21:14:45 +00:00
|
|
|
else if(tail == SCB_LIST_NULL) {
|
1995-04-27 17:47:17 +00:00
|
|
|
/* List had one element */
|
|
|
|
tail = scb->position;
|
|
|
|
outb(SCBPTR+iobase,head);
|
|
|
|
outb(SCBARRAY+iobase+30,
|
|
|
|
tail);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
outb(SCBPTR+iobase,tail);
|
|
|
|
tail = scb->position;
|
|
|
|
outb(SCBARRAY+iobase+30,
|
|
|
|
tail);
|
|
|
|
}
|
|
|
|
outb(WAITING_SCBH + iobase, head);
|
|
|
|
outb(WAITING_SCBT + iobase, tail);
|
|
|
|
outb(HA_RETURN_1 + iobase, SEND_SENSE);
|
1995-01-16 16:33:47 +00:00
|
|
|
break;
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Clear the SCB_SENSE Flag and have
|
|
|
|
* the sequencer do a normal command
|
|
|
|
* complete with either a "DRIVER_STUFFUP"
|
|
|
|
* error or whatever other error condition
|
|
|
|
* we already had.
|
|
|
|
*/
|
|
|
|
scb->flags &= ~SCB_SENSE;
|
|
|
|
if(xs->error == XS_NOERROR)
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
break;
|
|
|
|
case SCSI_BUSY:
|
|
|
|
xs->error = XS_BUSY;
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Target Busy\n");
|
1995-03-31 13:54:41 +00:00
|
|
|
break;
|
1995-02-22 01:43:25 +00:00
|
|
|
case SCSI_QUEUE_FULL:
|
|
|
|
/*
|
1995-03-31 13:54:41 +00:00
|
|
|
* The upper level SCSI code will eventually
|
|
|
|
* handle this properly.
|
1995-02-22 01:43:25 +00:00
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Queue Full\n");
|
1995-02-22 01:43:25 +00:00
|
|
|
xs->error = XS_BUSY;
|
|
|
|
break;
|
1994-12-31 19:31:56 +00:00
|
|
|
default:
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
1994-12-31 19:31:56 +00:00
|
|
|
printf("unexpected targ_status: %x\n",
|
|
|
|
scb->target_status);
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1995-03-31 13:54:41 +00:00
|
|
|
case RESIDUAL:
|
|
|
|
{
|
|
|
|
int scb_index;
|
|
|
|
scb_index = inb(SCBPTR + iobase);
|
|
|
|
scb = ahc->scbarray[scb_index];
|
1995-06-11 19:33:05 +00:00
|
|
|
xs = scb->xs;
|
1995-03-31 13:54:41 +00:00
|
|
|
/*
|
|
|
|
* Don't clobber valid resid info with
|
|
|
|
* a resid coming from a check sense
|
|
|
|
* operation.
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
if(!(scb->flags & SCB_SENSE)) {
|
1995-03-31 13:54:41 +00:00
|
|
|
scb->xs->resid = (inb(iobase+SCBARRAY+17) << 16) |
|
|
|
|
(inb(iobase+SCBARRAY+16) << 8) |
|
|
|
|
inb(iobase+SCBARRAY+15);
|
1995-06-11 19:33:05 +00:00
|
|
|
xs->flags |= SCSI_RESID_VALID;
|
1995-04-23 22:04:58 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
1995-07-04 21:14:45 +00:00
|
|
|
printf("Handled Residual of %d bytes\n"
|
|
|
|
"SG_COUNT == %d\n",
|
|
|
|
scb->xs->resid,
|
|
|
|
inb(SCBARRAY+18 + iobase));
|
1995-04-23 22:04:58 +00:00
|
|
|
#endif
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-03-31 13:54:41 +00:00
|
|
|
break;
|
|
|
|
}
|
1995-04-01 19:53:04 +00:00
|
|
|
case ABORT_TAG:
|
|
|
|
{
|
|
|
|
int scb_index;
|
|
|
|
scb_index = inb(SCBPTR + iobase);
|
|
|
|
scb = ahc->scbarray[scb_index];
|
1995-06-11 19:33:05 +00:00
|
|
|
xs = scb->xs;
|
1995-04-01 19:53:04 +00:00
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* We didn't recieve a valid tag back from
|
1995-04-01 19:53:04 +00:00
|
|
|
* the target on a reconnect.
|
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("invalid tag recieved -- sending ABORT_TAG\n");
|
1995-04-01 19:53:04 +00:00
|
|
|
scb->xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
untimeout(ahc_timeout, (caddr_t)scb);
|
|
|
|
ahc_done(unit, scb);
|
|
|
|
break;
|
|
|
|
}
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
case AWAITING_MSG:
|
|
|
|
{
|
|
|
|
int scb_index;
|
|
|
|
scb_index = inb(SCBPTR + iobase);
|
|
|
|
scb = ahc->scbarray[scb_index];
|
|
|
|
/*
|
|
|
|
* This SCB had a zero length command, informing
|
|
|
|
* the sequencer that we wanted to send a special
|
|
|
|
* message to this target. We only do this for
|
|
|
|
* BUS_DEVICE_RESET messages currently.
|
|
|
|
*/
|
|
|
|
if(scb->flags & SCB_DEVICE_RESET)
|
|
|
|
{
|
|
|
|
outb(HA_MSG_START + iobase,
|
|
|
|
MSG_BUS_DEVICE_RESET);
|
|
|
|
outb(HA_MSG_LEN + iobase, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
panic("ahcintr: AWAITING_MSG for an SCB that"
|
|
|
|
"does not have a waiting message");
|
|
|
|
break;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
default:
|
1994-12-31 19:31:56 +00:00
|
|
|
printf("ahc: seqint, "
|
|
|
|
"intstat == 0x%x, scsisigi = 0x%x\n",
|
1995-01-13 02:24:31 +00:00
|
|
|
intstat, inb(SCSISIGI + iobase));
|
1994-11-17 20:22:31 +00:00
|
|
|
break;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
|
|
|
clear:
|
|
|
|
/*
|
1995-03-17 23:58:27 +00:00
|
|
|
* Clear the upper byte that holds SEQINT status
|
|
|
|
* codes and clear the SEQINT bit.
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
outb(CLRINT + iobase, CLRSEQINT);
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-03-17 23:58:27 +00:00
|
|
|
* The sequencer is paused immediately on
|
|
|
|
* a SEQINT, so we should restart it when
|
1995-05-30 08:16:23 +00:00
|
|
|
* we leave this section.
|
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
if (intstat & SCSIINT) {
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
int scb_index = inb(SCBPTR + iobase);
|
|
|
|
status = inb(SSTAT1 + iobase);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
scb = ahc->scbarray[scb_index];
|
1994-12-31 19:31:56 +00:00
|
|
|
if (!scb || !(scb->flags & SCB_ACTIVE)) {
|
1994-11-17 20:22:31 +00:00
|
|
|
printf("ahc%d: ahcintr - referenced scb not "
|
|
|
|
"valid during scsiint 0x%x scb(%d)\n",
|
|
|
|
unit, status, scb_index);
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(CLRSINT1 + iobase, status);
|
1994-11-17 20:22:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1995-03-31 13:54:41 +00:00
|
|
|
outb(CLRINT + iobase, CLRSCSIINT);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb = NULL;
|
|
|
|
goto cmdcomplete;
|
|
|
|
}
|
|
|
|
xs = scb->xs;
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
if (status & SELTO) {
|
1994-11-17 20:22:31 +00:00
|
|
|
u_char active;
|
1995-04-27 17:47:17 +00:00
|
|
|
u_char waiting;
|
1995-01-13 02:24:31 +00:00
|
|
|
u_char flags;
|
|
|
|
u_long active_port = HA_ACTIVE0 + iobase;
|
1995-04-27 17:47:17 +00:00
|
|
|
outb(SCSISEQ + iobase, ENRSELI);
|
1994-11-17 20:22:31 +00:00
|
|
|
xs->error = XS_TIMEOUT;
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* Clear any pending messages for the timed out
|
|
|
|
* target, and mark the target as free
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
flags = inb( HA_FLAGS + iobase );
|
1995-05-30 08:16:23 +00:00
|
|
|
outb(HA_FLAGS + iobase,
|
1995-04-27 17:47:17 +00:00
|
|
|
flags & ~ACTIVE_MSG);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
|
|
|
if (scb->target_channel_lun & 0x88)
|
|
|
|
active_port++;
|
|
|
|
|
|
|
|
active = inb(active_port) &
|
|
|
|
~(0x01 << (xs->sc_link->target & 0x07));
|
|
|
|
outb(active_port, active);
|
|
|
|
|
1995-01-16 16:33:47 +00:00
|
|
|
outb(SCBARRAY + iobase, SCB_NEEDDMA);
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(CLRSINT1 + iobase, CLRSELTIMEO);
|
1995-01-16 16:33:47 +00:00
|
|
|
|
1995-03-31 13:54:41 +00:00
|
|
|
outb(CLRINT + iobase, CLRSCSIINT);
|
1995-04-27 17:47:17 +00:00
|
|
|
|
|
|
|
/* Shift the waiting for selection queue forward */
|
|
|
|
waiting = inb(WAITING_SCBH + iobase);
|
|
|
|
outb(SCBPTR + iobase, waiting);
|
|
|
|
waiting = inb(SCBARRAY + iobase + 30);
|
|
|
|
outb(WAITING_SCBH + iobase, waiting);
|
|
|
|
|
|
|
|
RESTART_SEQUENCER(ahc);
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else if (status & SCSIPERR) {
|
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("parity error\n");
|
1994-11-17 20:22:31 +00:00
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(CLRSINT1 + iobase, CLRSCSIPERR);
|
1994-11-17 20:22:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-03-31 13:54:41 +00:00
|
|
|
outb(CLRINT + iobase, CLRSCSIINT);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb = NULL;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
else if (!(status & BUSFREE)) {
|
1995-06-11 19:33:05 +00:00
|
|
|
sc_print_addr(xs->sc_link);
|
|
|
|
printf("Unknown SCSIINT. Status = 0x%x\n", status);
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(CLRSINT1 + iobase, status);
|
1994-11-17 20:22:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
1995-03-31 13:54:41 +00:00
|
|
|
outb(CLRINT + iobase, CLRSCSIINT);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb = NULL;
|
|
|
|
}
|
|
|
|
if(scb != NULL) {
|
|
|
|
/* We want to process the command */
|
|
|
|
untimeout(ahc_timeout, (caddr_t)scb);
|
|
|
|
ahc_done(unit, scb);
|
|
|
|
}
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
cmdcomplete:
|
|
|
|
if (intstat & CMDCMPLT) {
|
1995-03-07 08:59:28 +00:00
|
|
|
int scb_index;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
|
|
|
do {
|
1995-01-13 02:24:31 +00:00
|
|
|
scb_index = inb(QOUTFIFO + iobase);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb = ahc->scbarray[scb_index];
|
|
|
|
if (!scb || !(scb->flags & SCB_ACTIVE)) {
|
|
|
|
printf("ahc%d: WARNING "
|
1994-12-31 19:31:56 +00:00
|
|
|
"no command for scb %d (cmdcmplt)\n"
|
|
|
|
"QOUTCNT == %d\n",
|
1995-01-13 02:24:31 +00:00
|
|
|
unit, scb_index, inb(QOUTCNT + iobase));
|
1995-05-30 08:16:23 +00:00
|
|
|
outb(CLRINT + iobase, CLRCMDINT);
|
1994-11-17 20:22:31 +00:00
|
|
|
continue;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
outb(CLRINT + iobase, CLRCMDINT);
|
1994-11-17 20:22:31 +00:00
|
|
|
untimeout(ahc_timeout, (caddr_t)scb);
|
|
|
|
ahc_done(unit, scb);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
} while (inb(QOUTCNT + iobase));
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1995-07-04 21:14:45 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
enable_seeprom(u_long offset,
|
|
|
|
u_short CS, /* chip select */
|
|
|
|
u_short CK, /* clock */
|
|
|
|
u_short DO, /* data out */
|
|
|
|
u_short DI, /* data in */
|
|
|
|
u_short RDY, /* ready */
|
|
|
|
u_short MS /* mode select */)
|
|
|
|
{
|
|
|
|
int wait;
|
|
|
|
/*
|
|
|
|
* Request access of the memory port. When access is
|
|
|
|
* granted, SEERDY will go high. We use a 1 second
|
|
|
|
* timeout which should be near 1 second more than
|
|
|
|
* is needed. Reason: after the chip reset, there
|
|
|
|
* should be no contention.
|
|
|
|
*/
|
|
|
|
outb(offset, MS);
|
|
|
|
wait = 1000; /* 1 second timeout in msec */
|
|
|
|
while (--wait && ((inb(offset) & RDY) == 0)) {
|
|
|
|
DELAY (1000); /* delay 1 msec */
|
|
|
|
}
|
|
|
|
if ((inb(offset) & RDY) == 0) {
|
|
|
|
outb (offset, 0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
release_seeprom(u_long offset,
|
|
|
|
u_short CS, /* chip select */
|
|
|
|
u_short CK, /* clock */
|
|
|
|
u_short DO, /* data out */
|
|
|
|
u_short DI, /* data in */
|
|
|
|
u_short RDY, /* ready */
|
|
|
|
u_short MS /* mode select */)
|
|
|
|
{
|
|
|
|
/* Release access to the memory port and the serial EEPROM. */
|
|
|
|
outb(offset, 0);
|
|
|
|
}
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* We have a scb which has been processed by the
|
|
|
|
* adaptor, now we look to see how the operation
|
|
|
|
* went.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ahc_done(unit, scb)
|
|
|
|
int unit;
|
|
|
|
struct scb *scb;
|
|
|
|
{
|
|
|
|
struct scsi_xfer *xs = scb->xs;
|
|
|
|
|
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_done\n"));
|
|
|
|
/*
|
|
|
|
* Put the results of the operation
|
|
|
|
* into the xfer and call whoever started it
|
|
|
|
*/
|
1994-12-31 19:31:56 +00:00
|
|
|
if(scb->flags & SCB_SENSE)
|
|
|
|
xs->error = XS_SENSE;
|
1995-05-30 08:16:23 +00:00
|
|
|
if ((xs->flags & SCSI_ERR_OK) && !(xs->error == XS_SENSE)) {
|
1994-11-17 20:22:31 +00:00
|
|
|
/* All went correctly OR errors expected */
|
1995-02-22 01:43:25 +00:00
|
|
|
xs->error = XS_NOERROR;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
xs->flags |= ITSDONE;
|
1995-04-09 06:39:01 +00:00
|
|
|
#ifdef AHC_TAGENABLE
|
1995-05-30 08:16:23 +00:00
|
|
|
if(xs->cmd->opcode == 0x12 && xs->error == XS_NOERROR)
|
1995-02-22 01:43:25 +00:00
|
|
|
{
|
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
|
|
|
struct scsi_inquiry_data *inq_data;
|
|
|
|
u_short mask = 0x01 << (xs->sc_link->target |
|
|
|
|
(scb->target_channel_lun & 0x08));
|
|
|
|
/*
|
|
|
|
* Sneak a look at the results of the SCSI Inquiry
|
|
|
|
* command and see if we can do Tagged queing. This
|
|
|
|
* should really be done by the higher level drivers.
|
|
|
|
*/
|
|
|
|
inq_data = (struct scsi_inquiry_data *)xs->data;
|
1995-05-30 08:16:23 +00:00
|
|
|
if(((inq_data->device & SID_TYPE) == 0)
|
1995-02-22 01:43:25 +00:00
|
|
|
&& (inq_data->flags & SID_CmdQue)
|
|
|
|
&& !(ahc->tagenable & mask))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Disk type device and can tag
|
|
|
|
*/
|
|
|
|
printf("ahc%d: target %d Tagged Queuing Device\n",
|
|
|
|
unit, xs->sc_link->target);
|
|
|
|
ahc->tagenable |= mask;
|
1995-03-17 23:58:27 +00:00
|
|
|
#ifdef QUEUE_FULL_SUPPORTED
|
|
|
|
xs->sc_link->opennings += 2; */
|
|
|
|
#endif
|
1995-02-22 01:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
1995-04-09 06:39:01 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_free_scb(unit, scb, xs->flags);
|
1995-05-30 08:16:23 +00:00
|
|
|
scsi_done(xs);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the board, ready for normal operation
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ahc_init(unit)
|
|
|
|
int unit;
|
|
|
|
{
|
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
1995-01-13 02:24:31 +00:00
|
|
|
u_long iobase = ahc->baseport;
|
1995-07-04 21:14:45 +00:00
|
|
|
u_char scsi_conf, sblkctl, i, host_id;
|
|
|
|
int intdef, max_targ = 16, wait, have_seeprom = 0;
|
|
|
|
int bios_disabled = 0;
|
|
|
|
struct seeprom_config sc;
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Assume we have a board at this stage
|
|
|
|
* Find out the configured interupt and the card type.
|
|
|
|
*/
|
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-05-30 08:16:23 +00:00
|
|
|
printf("ahc%d: scb %d bytes; SCB_SIZE %d bytes, ahc_dma %d bytes\n",
|
|
|
|
unit, sizeof(struct scb), SCB_DOWN_SIZE,
|
1995-01-22 00:48:39 +00:00
|
|
|
sizeof(struct ahc_dma_seg));
|
1995-02-22 01:43:25 +00:00
|
|
|
#endif /* AHC_DEBUG */
|
1994-11-17 20:22:31 +00:00
|
|
|
printf("ahc%d: reading board settings\n", unit);
|
|
|
|
|
1995-03-31 13:54:41 +00:00
|
|
|
/* Save the IRQ type before we do a chip reset */
|
|
|
|
|
|
|
|
ahc->unpause = (inb(HCNTRL + iobase) & IRQMS) | INTEN;
|
1995-04-15 21:37:32 +00:00
|
|
|
ahc->pause = ahc->unpause | PAUSE;
|
|
|
|
outb(HCNTRL + iobase, CHIPRST | ahc->pause);
|
1995-03-31 13:54:41 +00:00
|
|
|
/*
|
|
|
|
* Ensure that the reset has finished
|
|
|
|
*/
|
|
|
|
wait = 1000;
|
|
|
|
while (wait--) {
|
|
|
|
DELAY(1000);
|
|
|
|
if(!(inb(HCNTRL + iobase) & CHIPRST))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(wait == 0) {
|
1995-04-15 21:37:32 +00:00
|
|
|
printf("ahc%d: WARNING - Failed chip reset! "
|
|
|
|
"Trying to initialize anyway.\n", unit);
|
|
|
|
/* Forcibly clear CHIPRST */
|
|
|
|
outb(HCNTRL + iobase, ahc->pause);
|
1995-03-31 13:54:41 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
switch( ahc->type ) {
|
1995-07-04 21:14:45 +00:00
|
|
|
case AHC_AIC7770:
|
1994-11-17 20:22:31 +00:00
|
|
|
case AHC_274:
|
|
|
|
case AHC_284:
|
1995-07-04 21:14:45 +00:00
|
|
|
{
|
|
|
|
u_char hostconf;
|
|
|
|
if(ahc->type == AHC_274) {
|
|
|
|
printf("ahc%d: 274x ", unit);
|
|
|
|
if((inb(HA_274_BIOSCTRL + iobase) & BIOSMODE)
|
|
|
|
== BIOSDISABLED)
|
|
|
|
bios_disabled = 1;
|
|
|
|
}
|
|
|
|
else if(ahc->type == AHC_284)
|
|
|
|
printf("ahc%d: 284x ", unit);
|
|
|
|
else
|
|
|
|
printf("ahc%d: Motherboard ", unit);
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc->maxscbs = 0x4;
|
1995-07-04 21:14:45 +00:00
|
|
|
/* Should we only do this for the 27/284x? */
|
|
|
|
/* Setup the FIFO threshold and the bus off time */
|
|
|
|
hostconf = inb(HA_HOSTCONF + iobase);
|
|
|
|
outb(BUSSPD + iobase, hostconf & DFTHRSH);
|
|
|
|
outb(BUSTIME + iobase, (hostconf << 2) & BOFF);
|
1994-11-17 20:22:31 +00:00
|
|
|
break;
|
1995-07-04 21:14:45 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
case AHC_AIC7850:
|
1995-03-31 13:54:41 +00:00
|
|
|
case AHC_AIC7870:
|
1995-07-04 21:14:45 +00:00
|
|
|
case AHC_394:
|
1995-01-13 02:24:31 +00:00
|
|
|
case AHC_294:
|
1995-07-04 21:14:45 +00:00
|
|
|
host_id = 0x07; /* default to SCSI ID 7 for 7850 */
|
|
|
|
if (ahc->type != AHC_AIC7850) {
|
|
|
|
unsigned short *scarray = (u_short *)≻
|
|
|
|
unsigned short checksum = 0;
|
|
|
|
|
|
|
|
printf("ahc%d: Reading SEEPROM...", unit);
|
|
|
|
have_seeprom = enable_seeprom (iobase + SEECTL,
|
|
|
|
SEECS, SEECK, SEEDO, SEEDI, SEERDY, SEEMS);
|
|
|
|
if (have_seeprom) {
|
|
|
|
have_seeprom = read_seeprom (iobase + SEECTL,
|
|
|
|
(u_short *)&sc, sizeof(sc)/2, SEECS,
|
|
|
|
SEECK, SEEDO, SEEDI, SEERDY, SEEMS);
|
|
|
|
release_seeprom (iobase + SEECTL, SEECS, SEECK,
|
|
|
|
SEEDO, SEEDI, SEERDY, SEEMS);
|
|
|
|
if (have_seeprom) {
|
|
|
|
/* Check checksum */
|
|
|
|
for (i = 0;i < (sizeof(sc)/2 - 1);i = i + 1)
|
|
|
|
checksum = checksum + scarray[i];
|
|
|
|
if (checksum != sc.checksum) {
|
|
|
|
printf ("checksum error");
|
|
|
|
have_seeprom = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("done.\n");
|
|
|
|
host_id = (sc.brtime_id & CFSCSIID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!have_seeprom) {
|
|
|
|
printf("\nahc%d: SEEPROM read failed, "
|
|
|
|
"using leftover BIOS values\n", unit);
|
|
|
|
host_id = 0x7;
|
|
|
|
}
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
ahc->maxscbs = 0x10;
|
|
|
|
if(ahc->type == AHC_AIC7850){
|
|
|
|
printf("ahc%d: aic7850 ", unit);
|
|
|
|
ahc->maxscbs = 0x03;
|
|
|
|
}
|
|
|
|
else if(ahc->type == AHC_AIC7870)
|
1995-03-31 13:54:41 +00:00
|
|
|
printf("ahc%d: aic7870 ", unit);
|
1995-07-04 21:14:45 +00:00
|
|
|
else if(ahc->type == AHC_394){
|
|
|
|
printf("ahc%d: 3940 ", unit);
|
|
|
|
/* XXX Test this! ahc->maxscbs = 0xff; */
|
|
|
|
}
|
1995-03-31 13:54:41 +00:00
|
|
|
else
|
1995-07-04 21:14:45 +00:00
|
|
|
printf("ahc%d: 2940 ", unit);
|
|
|
|
outb(DSPCISTATUS + iobase, 0xc0 /* DFTHRSH == 100% */);
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-07-04 21:14:45 +00:00
|
|
|
* XXX Use SCSI ID from SEEPROM if we have it; otherwise
|
|
|
|
* its hardcoded to 7 until we can read it from NVRAM.
|
1995-04-15 21:37:32 +00:00
|
|
|
*/
|
1995-07-04 21:14:45 +00:00
|
|
|
outb(HA_SCSICONF + iobase, host_id | 0xc0 /* DFTHRSH = 100% */);
|
1995-03-07 08:59:28 +00:00
|
|
|
/* In case we are a wide card */
|
1995-07-04 21:14:45 +00:00
|
|
|
outb(HA_SCSICONF + 1 + iobase, host_id);
|
1995-03-07 08:59:28 +00:00
|
|
|
break;
|
1994-11-17 20:22:31 +00:00
|
|
|
default:
|
|
|
|
};
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
/* Determine channel configuration and who we are on the scsi bus. */
|
1995-07-04 21:14:45 +00:00
|
|
|
switch ( (sblkctl = inb(SBLKCTL + iobase) & 0x0a) ) {
|
1994-11-17 20:22:31 +00:00
|
|
|
case 0:
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc->our_id = (inb(HA_SCSICONF + iobase) & HSCSIID);
|
|
|
|
printf("Single Channel, SCSI Id=%d, ", ahc->our_id);
|
1995-03-31 13:54:41 +00:00
|
|
|
outb(HA_FLAGS + iobase, SINGLE_BUS);
|
1994-11-17 20:22:31 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc->our_id = (inb(HA_SCSICONF + 1 + iobase) & HWSCSIID);
|
|
|
|
printf("Wide Channel, SCSI Id=%d, ", ahc->our_id);
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->type |= AHC_WIDE;
|
1995-01-16 16:33:47 +00:00
|
|
|
outb(HA_FLAGS + iobase, WIDE_BUS);
|
1994-11-17 20:22:31 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc->our_id = (inb(HA_SCSICONF + iobase) & HSCSIID);
|
|
|
|
ahc->our_id_b = (inb(HA_SCSICONF + 1 + iobase) & HSCSIID);
|
|
|
|
printf("Twin Channel, A SCSI Id=%d, B SCSI Id=%d, ",
|
|
|
|
ahc->our_id, ahc->our_id_b);
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->type |= AHC_TWIN;
|
1995-01-16 16:33:47 +00:00
|
|
|
outb(HA_FLAGS + iobase, TWIN_BUS);
|
1994-11-17 20:22:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf(" Unsupported adapter type. Ignoring\n");
|
|
|
|
return(-1);
|
|
|
|
}
|
1995-03-17 23:58:27 +00:00
|
|
|
/*
|
|
|
|
* Take the bus led out of diagnostic mode
|
|
|
|
*/
|
|
|
|
outb(SBLKCTL + iobase, sblkctl);
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-07-04 21:14:45 +00:00
|
|
|
* Number of SCBs that will be used. Rev E aic7770s supposedly
|
|
|
|
* can do 255 concurrent commands. Right now, we just ID the
|
|
|
|
* card until we can find out how this is done.
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1995-06-11 19:33:05 +00:00
|
|
|
if(!(ahc->type & AHC_AIC78X0))
|
1995-02-22 01:43:25 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-02-22 01:43:25 +00:00
|
|
|
* See if we have a Rev E or higher
|
1995-05-30 08:16:23 +00:00
|
|
|
* aic7770. Anything below a Rev E will
|
|
|
|
* have a R/O autoflush disable configuration
|
1995-05-01 18:43:14 +00:00
|
|
|
* bit.
|
1995-02-22 01:43:25 +00:00
|
|
|
*/
|
1995-03-17 23:58:27 +00:00
|
|
|
u_char sblkctl_orig;
|
1995-02-22 01:43:25 +00:00
|
|
|
sblkctl_orig = inb(SBLKCTL + iobase);
|
|
|
|
sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
|
|
|
|
outb(SBLKCTL + iobase, sblkctl);
|
|
|
|
sblkctl = inb(SBLKCTL + iobase);
|
|
|
|
if(sblkctl != sblkctl_orig)
|
|
|
|
{
|
|
|
|
printf("aic7770 >= Rev E, ");
|
|
|
|
/*
|
|
|
|
* Ensure autoflush is enabled
|
|
|
|
*/
|
|
|
|
sblkctl &= ~AUTOFLUSHDIS;
|
|
|
|
outb(SBLKCTL + iobase, sblkctl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
printf("aic7770 <= Rev C, ");
|
|
|
|
}
|
1995-07-04 21:14:45 +00:00
|
|
|
else if(ahc->type & AHC_AIC7850)
|
|
|
|
printf("aic7850, ");
|
1995-02-22 01:43:25 +00:00
|
|
|
else
|
|
|
|
printf("aic7870, ");
|
1995-01-13 02:24:31 +00:00
|
|
|
printf("%d SCBs\n", ahc->maxscbs);
|
1995-04-27 17:47:17 +00:00
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
if(!(ahc->type & AHC_AIC78X0)) {
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
if(ahc->pause & IRQMS)
|
|
|
|
printf("ahc%d: Using Level Sensitive Interrupts\n",
|
|
|
|
unit);
|
|
|
|
else
|
|
|
|
printf("ahc%d: Using Edge Triggered Interrupts\n",
|
|
|
|
unit);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
if(!(ahc->type & AHC_AIC78X0)){
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-03-17 23:58:27 +00:00
|
|
|
* The 294x cards are PCI, so we get their interrupt from the PCI
|
1995-05-30 08:16:23 +00:00
|
|
|
* BIOS.
|
1995-01-13 02:24:31 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
intdef = inb(INTDEF + iobase);
|
|
|
|
switch (intdef & 0xf) {
|
|
|
|
case 9:
|
|
|
|
ahc->vect = 9;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
ahc->vect = 10;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
ahc->vect = 11;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
ahc->vect = 12;
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
ahc->vect = 14;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
ahc->vect = 15;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("illegal irq setting\n");
|
|
|
|
return (EIO);
|
|
|
|
}
|
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-04-15 21:37:32 +00:00
|
|
|
/* Set the SCSI Id, SXFRCTL1, and SIMODE1, for both channels */
|
1995-02-22 01:43:25 +00:00
|
|
|
if( ahc->type & AHC_TWIN)
|
1995-01-22 00:48:39 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-01-22 00:48:39 +00:00
|
|
|
* The device is gated to channel B after a chip reset,
|
|
|
|
* so set those values first
|
|
|
|
*/
|
|
|
|
outb(SCSIID + iobase, ahc->our_id_b);
|
|
|
|
scsi_conf = inb(HA_SCSICONF + 1 + iobase) & (ENSPCHK|STIMESEL);
|
|
|
|
outb(SXFRCTL1 + iobase, scsi_conf|ENSTIMER|ACTNEGEN|STPWEN);
|
|
|
|
outb(SIMODE1 + iobase, ENSELTIMO|ENSCSIPERR);
|
|
|
|
/* Select Channel A */
|
|
|
|
outb(SBLKCTL + iobase, 0);
|
|
|
|
}
|
|
|
|
outb(SCSIID + iobase, ahc->our_id);
|
|
|
|
scsi_conf = inb(HA_SCSICONF + iobase) & (ENSPCHK|STIMESEL);
|
|
|
|
outb(SXFRCTL1 + iobase, scsi_conf|ENSTIMER|ACTNEGEN|STPWEN);
|
|
|
|
outb(SIMODE1 + iobase, ENSELTIMO|ENSCSIPERR);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
1994-12-31 19:31:56 +00:00
|
|
|
* Look at the information that board initialization or
|
|
|
|
* the board bios has left us. In the lower four bits of each
|
|
|
|
* target's scratch space any value other than 0 indicates
|
1995-05-30 08:16:23 +00:00
|
|
|
* that we should initiate syncronous transfers. If it's zero,
|
|
|
|
* the user or the BIOS has decided to disable syncronous
|
1994-12-31 19:31:56 +00:00
|
|
|
* negotiation to that target so we don't activate the needsdr
|
|
|
|
* flag.
|
|
|
|
*/
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needsdtr_orig = 0;
|
|
|
|
ahc->needwdtr_orig = 0;
|
1995-07-04 21:14:45 +00:00
|
|
|
|
|
|
|
/* Grab the disconnection disable table and invert it for our needs */
|
|
|
|
if(have_seeprom)
|
|
|
|
ahc->discenable = 0;
|
|
|
|
else if(bios_disabled){
|
|
|
|
printf("ahc%d: Host Adapter Bios disabled. Using default SCSI "
|
|
|
|
"device parameters\n", unit);
|
|
|
|
ahc->discenable = 0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ahc->discenable = ~(inw(HA_DISC_DSB + iobase));
|
|
|
|
|
1995-03-31 13:54:41 +00:00
|
|
|
if(!(ahc->type & AHC_WIDE))
|
|
|
|
max_targ = 8;
|
|
|
|
|
|
|
|
for(i = 0; i < max_targ; i++){
|
1995-07-04 21:14:45 +00:00
|
|
|
u_char target_settings;
|
|
|
|
if (have_seeprom) {
|
|
|
|
target_settings = (sc.device_flags[i] & CFXFER) << 4;
|
|
|
|
if (sc.device_flags[i] & CFSYNCH)
|
|
|
|
ahc->needsdtr_orig |= (0x01 << i);
|
|
|
|
if (sc.device_flags[i] & CFWIDEB)
|
|
|
|
ahc->needwdtr_orig |= (0x01 << i);
|
|
|
|
if (sc.device_flags[i] & CFDISC)
|
|
|
|
ahc->discenable |= (0x01 << i);
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
1995-07-04 21:14:45 +00:00
|
|
|
else if (bios_disabled) {
|
|
|
|
target_settings = 0; /* 10MHz */
|
|
|
|
ahc->needsdtr_orig |= (0x01 << i);
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needwdtr_orig |= (0x01 << i);
|
1995-07-04 21:14:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Take the settings leftover in scratch RAM. */
|
|
|
|
target_settings = inb(HA_TARG_SCRATCH + i + iobase);
|
|
|
|
|
|
|
|
if(target_settings & 0x0f){
|
|
|
|
ahc->needsdtr_orig |= (0x01 << i);
|
|
|
|
/*Default to a asyncronous transfers(0 offset)*/
|
|
|
|
target_settings &= 0xf0;
|
|
|
|
}
|
|
|
|
if(target_settings & 0x80){
|
|
|
|
ahc->needwdtr_orig |= (0x01 << i);
|
|
|
|
/*
|
|
|
|
* We'll set the Wide flag when we
|
|
|
|
* are successful with Wide negotiation,
|
|
|
|
* so turn it off for now so we aren't
|
|
|
|
* confused.
|
|
|
|
*/
|
|
|
|
target_settings &= 0x7f;
|
|
|
|
}
|
1995-01-13 02:24:31 +00:00
|
|
|
}
|
|
|
|
outb(HA_TARG_SCRATCH+i+iobase,target_settings);
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-02-22 01:43:25 +00:00
|
|
|
* If we are not a WIDE device, forget WDTR. This
|
|
|
|
* makes the driver work on some cards that don't
|
|
|
|
* leave these fields cleared when the BIOS is not
|
|
|
|
* installed.
|
|
|
|
*/
|
|
|
|
if(!(ahc->type & AHC_WIDE))
|
|
|
|
ahc->needwdtr_orig = 0;
|
1995-03-07 08:59:28 +00:00
|
|
|
ahc->needsdtr = ahc->needsdtr_orig;
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needwdtr = ahc->needwdtr_orig;
|
1995-02-03 17:15:12 +00:00
|
|
|
ahc->sdtrpending = 0;
|
|
|
|
ahc->wdtrpending = 0;
|
1995-02-22 01:43:25 +00:00
|
|
|
ahc->tagenable = 0;
|
1995-03-17 23:58:27 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-04-27 17:47:17 +00:00
|
|
|
* Clear the control byte for every SCB so that the sequencer
|
|
|
|
* doesn't get confused and think that one of them is valid
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1995-04-27 17:47:17 +00:00
|
|
|
for(i = 0; i < ahc->maxscbs; i++) {
|
|
|
|
outb(SCBPTR + iobase, i);
|
|
|
|
outb(SCBARRAY + iobase, 0);
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-03-17 23:58:27 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-07-04 21:14:45 +00:00
|
|
|
printf("NEEDSDTR == 0x%x\nNEEDWDTR == 0x%x\nDISCENABLE == 0x%x\n",
|
|
|
|
ahc->needsdtr, ahc->needwdtr, ahc->discenable);
|
1995-03-17 23:58:27 +00:00
|
|
|
#endif
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Set the number of availible SCBs
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(HA_SCBCOUNT + iobase, ahc->maxscbs);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
|
|
|
/* We don't have any busy targets right now */
|
1995-01-13 02:24:31 +00:00
|
|
|
outb( HA_ACTIVE0 + iobase, 0 );
|
|
|
|
outb( HA_ACTIVE1 + iobase, 0 );
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-04-27 17:47:17 +00:00
|
|
|
/* We don't have any waiting selections */
|
|
|
|
outb( WAITING_SCBH + iobase, SCB_LIST_NULL );
|
|
|
|
outb( WAITING_SCBT + iobase, SCB_LIST_NULL );
|
1995-03-07 08:59:28 +00:00
|
|
|
/*
|
|
|
|
* Load the Sequencer program and Enable the adapter.
|
1995-07-04 21:14:45 +00:00
|
|
|
* Place the aic7xxx in fastmode which makes a big
|
1995-03-07 08:59:28 +00:00
|
|
|
* difference when doing many small block transfers.
|
|
|
|
*/
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-03-07 08:59:28 +00:00
|
|
|
printf("ahc%d: Downloading Sequencer Program...", unit);
|
|
|
|
ahc_loadseq(iobase);
|
|
|
|
printf("Done\n");
|
|
|
|
|
|
|
|
outb(SEQCTL + iobase, FASTMODE);
|
1995-06-11 19:33:05 +00:00
|
|
|
if (!(ahc->type & AHC_AIC78X0))
|
1995-05-30 08:16:23 +00:00
|
|
|
outb(BCTL + iobase, ENABLE);
|
1995-03-07 08:59:28 +00:00
|
|
|
|
1995-02-03 17:15:12 +00:00
|
|
|
/* Reset the bus */
|
1995-05-30 08:16:23 +00:00
|
|
|
outb(SCSISEQ + iobase, SCSIRSTO);
|
1995-07-04 21:14:45 +00:00
|
|
|
DELAY(10000);
|
1995-02-03 17:15:12 +00:00
|
|
|
outb(SCSISEQ + iobase, 0);
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that we are going and return (to probe)
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc->flags = AHC_INIT;
|
1994-11-17 20:22:31 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ahcminphys(bp)
|
1995-05-30 08:16:23 +00:00
|
|
|
struct buf *bp;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1995-01-13 02:24:31 +00:00
|
|
|
* Even though the card can transfer up to 16megs per command
|
1994-11-17 20:22:31 +00:00
|
|
|
* 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_NSEG - 1) * PAGESIZ)) {
|
|
|
|
bp->b_bcount = ((AHC_NSEG - 1) * PAGESIZ);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* start a scsi operation given the command and
|
1995-05-30 08:16:23 +00:00
|
|
|
* the data address, target, and lun all of which
|
1994-11-17 20:22:31 +00:00
|
|
|
* are stored in the scsi_xfer struct
|
|
|
|
*/
|
|
|
|
int32
|
|
|
|
ahc_scsi_cmd(xs)
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
struct scb *scb = NULL;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct ahc_dma_seg *sg;
|
|
|
|
int seg; /* scatter gather seg being worked on */
|
1995-05-30 08:16:23 +00:00
|
|
|
int thiskv;
|
1994-11-17 20:22:31 +00:00
|
|
|
physaddr thisphys, nextphys;
|
|
|
|
int unit = xs->sc_link->adapter_unit;
|
1995-05-30 08:16:23 +00:00
|
|
|
u_short mask = (0x01 << (xs->sc_link->target
|
1995-01-16 16:33:47 +00:00
|
|
|
| ((u_long)xs->sc_link->fordriver & 0x08)));
|
1994-11-17 20:22:31 +00:00
|
|
|
int bytes_this_seg, bytes_this_page, datalen, flags;
|
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
|
|
|
int s;
|
1995-01-13 02:24:31 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahc_scsi_cmd\n"));
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* get an scb to use. If the transfer
|
|
|
|
* is from a buf (possibly from interrupt time)
|
|
|
|
* then we can't allow it to sleep
|
|
|
|
*/
|
|
|
|
flags = xs->flags;
|
|
|
|
if (flags & ITSDONE) {
|
1995-05-30 08:16:23 +00:00
|
|
|
printf("ahc%d: Already done?", unit);
|
|
|
|
xs->flags &= ~ITSDONE;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
if (!(flags & INUSE)) {
|
|
|
|
printf("ahc%d: Not in use?", unit);
|
|
|
|
xs->flags |= INUSE;
|
|
|
|
}
|
|
|
|
if (!(scb = ahc_get_scb(unit, flags))) {
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
return (TRY_AGAIN_LATER);
|
|
|
|
}
|
1995-05-11 19:26:53 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB3, ("start scb(%p)\n", scb));
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->xs = xs;
|
1995-05-30 08:16:23 +00:00
|
|
|
if (flags & SCSI_RESET)
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
scb->flags |= SCB_DEVICE_RESET|SCB_IMMED;
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Put all the arguments for the xfer in the scb
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1995-02-22 01:43:25 +00:00
|
|
|
|
1995-03-31 13:54:41 +00:00
|
|
|
if(ahc->tagenable & mask)
|
|
|
|
scb->control |= SCB_TE;
|
1995-07-04 21:14:45 +00:00
|
|
|
#ifdef NOT_YET
|
|
|
|
if(ahc->discenable & mask)
|
|
|
|
scb->control |= SCB_DISCENB;
|
|
|
|
#endif
|
1995-05-30 08:16:23 +00:00
|
|
|
if((ahc->needwdtr & mask) && !(ahc->wdtrpending & mask))
|
1995-02-03 17:15:12 +00:00
|
|
|
{
|
1995-02-22 01:43:25 +00:00
|
|
|
scb->control |= SCB_NEEDWDTR;
|
|
|
|
ahc->wdtrpending |= mask;
|
1995-02-03 17:15:12 +00:00
|
|
|
}
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
else if((ahc->needsdtr & mask) && !(ahc->sdtrpending & mask))
|
1995-02-03 17:15:12 +00:00
|
|
|
{
|
1995-02-22 01:43:25 +00:00
|
|
|
scb->control |= SCB_NEEDSDTR;
|
|
|
|
ahc->sdtrpending |= mask;
|
1995-02-03 17:15:12 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
scb->target_channel_lun = ((xs->sc_link->target << 4) & 0xF0) |
|
1994-12-31 19:31:56 +00:00
|
|
|
((u_long)xs->sc_link->fordriver & 0x08) |
|
1995-03-07 08:59:28 +00:00
|
|
|
(xs->sc_link->lun & 0x07);
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->cmdlen = xs->cmdlen;
|
|
|
|
scb->cmdpointer = KVTOPHYS(xs->cmd);
|
1995-03-31 13:54:41 +00:00
|
|
|
xs->resid = 0;
|
1995-06-11 19:33:05 +00:00
|
|
|
xs->status = 0;
|
1994-11-17 20:22:31 +00:00
|
|
|
if (xs->datalen) { /* should use S/G only if not zero length */
|
1995-05-30 08:16:23 +00:00
|
|
|
scb->SG_list_pointer = KVTOPHYS(scb->ahc_dma);
|
1994-11-17 20:22:31 +00:00
|
|
|
sg = scb->ahc_dma;
|
|
|
|
seg = 0;
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Set up the scatter gather block
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB4,
|
1995-05-11 19:26:53 +00:00
|
|
|
("%ld @%p:- ", xs->datalen, xs->data));
|
1994-11-17 20:22:31 +00:00
|
|
|
datalen = xs->datalen;
|
|
|
|
thiskv = (int) xs->data;
|
|
|
|
thisphys = KVTOPHYS(thiskv);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
while ((datalen) && (seg < AHC_NSEG)) {
|
|
|
|
bytes_this_seg = 0;
|
|
|
|
|
|
|
|
/* put in the base address */
|
|
|
|
sg->addr = thisphys;
|
|
|
|
|
1995-05-11 19:26:53 +00:00
|
|
|
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("0x%lx",
|
1995-05-30 08:16:23 +00:00
|
|
|
thisphys));
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/* do it at least once */
|
|
|
|
nextphys = thisphys;
|
|
|
|
while ((datalen) && (thisphys == nextphys)) {
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* This page is contiguous (physically)
|
|
|
|
* with the the last, just extend the
|
1994-11-17 20:22:31 +00:00
|
|
|
* length
|
|
|
|
*/
|
|
|
|
/* how far to the end of the page */
|
|
|
|
nextphys = (thisphys & (~(PAGESIZ - 1)))
|
|
|
|
+ PAGESIZ;
|
|
|
|
bytes_this_page = nextphys - thisphys;
|
|
|
|
/**** or the data ****/
|
|
|
|
bytes_this_page = min(bytes_this_page
|
1995-05-30 08:16:23 +00:00
|
|
|
,datalen);
|
1994-11-17 20:22:31 +00:00
|
|
|
bytes_this_seg += bytes_this_page;
|
|
|
|
datalen -= bytes_this_page;
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/* get more ready for the next page */
|
|
|
|
thiskv = (thiskv & (~(PAGESIZ - 1)))
|
|
|
|
+ PAGESIZ;
|
|
|
|
if (datalen)
|
|
|
|
thisphys = KVTOPHYS(thiskv);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* next page isn't contiguous, finish the seg
|
|
|
|
*/
|
|
|
|
SC_DEBUGN(xs->sc_link, SDEV_DB4,
|
1995-05-30 08:16:23 +00:00
|
|
|
("(0x%x)", bytes_this_seg));
|
1994-11-17 20:22:31 +00:00
|
|
|
sg->len = bytes_this_seg;
|
|
|
|
sg++;
|
|
|
|
seg++;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
|
|
|
} /*end of iov/kv decision */
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->SG_segment_count = seg;
|
1995-07-04 21:14:45 +00:00
|
|
|
|
|
|
|
/* Copy the first SG into the data pointer area */
|
|
|
|
scb->data = scb->ahc_dma->addr;
|
|
|
|
scb->datalen[0] = scb->ahc_dma->len & 0xff;
|
|
|
|
scb->datalen[1] = (scb->ahc_dma->len >> 8) & 0xff;
|
|
|
|
scb->datalen[2] = (scb->ahc_dma->len >> 16) & 0xff;
|
1994-11-17 20:22:31 +00:00
|
|
|
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n"));
|
1995-07-04 21:14:45 +00:00
|
|
|
if (datalen) {
|
|
|
|
/* there's still data, must have run out of segs! */
|
1994-11-17 20:22:31 +00:00
|
|
|
printf("ahc_scsi_cmd%d: more than %d DMA segs\n",
|
|
|
|
unit, AHC_NSEG);
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
ahc_free_scb(unit, scb, flags);
|
|
|
|
return (HAD_ERROR);
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
else {
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* No data xfer, use non S/G values
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
*/
|
|
|
|
scb->SG_segment_count = 0;
|
|
|
|
scb->SG_list_pointer = 0;
|
1995-07-04 21:14:45 +00:00
|
|
|
scb->data = 0;
|
|
|
|
scb->datalen[0] = 0;
|
|
|
|
scb->datalen[1] = 0;
|
|
|
|
scb->datalen[2] = 0;
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* Usually return SUCCESSFULLY QUEUED
|
|
|
|
*/
|
1995-02-22 01:43:25 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1994-11-17 20:22:31 +00:00
|
|
|
if(xs->sc_link->target == DEBUGTARG)
|
|
|
|
ahc_print_scb(scb);
|
|
|
|
#endif
|
1995-05-30 08:16:23 +00:00
|
|
|
if (!(flags & SCSI_NOMASK)) {
|
|
|
|
s = splbio();
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_send_scb(ahc, scb);
|
|
|
|
timeout(ahc_timeout, (caddr_t)scb, (xs->timeout * hz) / 1000);
|
1995-05-30 08:16:23 +00:00
|
|
|
splx(s);
|
1994-11-17 20:22:31 +00:00
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n"));
|
|
|
|
return (SUCCESSFULLY_QUEUED);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* If we can't use interrupts, poll on completion
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_send_scb(ahc, scb);
|
|
|
|
SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_wait\n"));
|
1995-05-30 08:16:23 +00:00
|
|
|
do {
|
1994-11-17 20:22:31 +00:00
|
|
|
if (ahc_poll(unit, xs->timeout)) {
|
|
|
|
if (!(xs->flags & SCSI_SILENT))
|
|
|
|
printf("cmd fail\n");
|
|
|
|
printf("cmd fail\n");
|
1995-01-13 02:24:31 +00:00
|
|
|
ahc_abort_scb(unit,ahc,scb);
|
1994-11-17 20:22:31 +00:00
|
|
|
return (HAD_ERROR);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
|
|
|
} while (!(xs->flags & ITSDONE)); /* a non command complete intr */
|
1994-11-17 20:22:31 +00:00
|
|
|
if (xs->error) {
|
|
|
|
return (HAD_ERROR);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
|
|
|
return (COMPLETE);
|
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* Return some information to the caller about
|
1995-05-30 08:16:23 +00:00
|
|
|
* the adapter and it's capabilities.
|
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
u_int32
|
|
|
|
ahc_adapter_info(unit)
|
|
|
|
int unit;
|
|
|
|
{
|
1995-05-30 08:16:23 +00:00
|
|
|
return (2); /* 2 outstanding requests at a time per device */
|
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A scb (and hence an scb entry on the board is put onto the
|
|
|
|
* free list.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ahc_free_scb(unit, scb, flags)
|
|
|
|
int unit, flags;
|
|
|
|
struct scb *scb;
|
|
|
|
{
|
1995-04-23 22:04:58 +00:00
|
|
|
unsigned int opri;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
|
|
|
|
1995-04-23 22:04:58 +00:00
|
|
|
opri = splbio();
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1994-12-31 19:31:56 +00:00
|
|
|
scb->flags = SCB_FREE;
|
1994-11-17 20:22:31 +00:00
|
|
|
scb->next = ahc->free_scb;
|
|
|
|
ahc->free_scb = scb;
|
1995-04-23 22:04:58 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-05-30 08:16:23 +00:00
|
|
|
ahc->activescbs--;
|
1995-04-23 22:04:58 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* If there were none, wake abybody waiting for
|
|
|
|
* one to come free, starting with queued entries
|
|
|
|
*/
|
|
|
|
if (!scb->next) {
|
|
|
|
wakeup((caddr_t)&ahc->free_scb);
|
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
splx(opri);
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Get a free scb
|
|
|
|
* If there are none, see if we can allocate a
|
|
|
|
* new one. Otherwise either return an error or sleep
|
|
|
|
*/
|
|
|
|
struct scb *
|
|
|
|
ahc_get_scb(unit, flags)
|
|
|
|
int unit, flags;
|
|
|
|
{
|
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
1995-04-23 22:04:58 +00:00
|
|
|
unsigned opri;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct scb *scbp;
|
|
|
|
|
1995-04-23 22:04:58 +00:00
|
|
|
opri = splbio();
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* If we can and have to, sleep waiting for one to come free
|
|
|
|
* but only if we can't allocate a new one.
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
1994-11-17 20:22:31 +00:00
|
|
|
while (!(scbp = ahc->free_scb)) {
|
|
|
|
if (ahc->numscbs < ahc->maxscbs) {
|
|
|
|
scbp = (struct scb *) malloc(sizeof(struct scb),
|
|
|
|
M_TEMP, M_NOWAIT);
|
|
|
|
if (scbp) {
|
1995-01-16 16:33:47 +00:00
|
|
|
physaddr scbaddr = KVTOPHYS(scbp);
|
|
|
|
u_long iobase = ahc->baseport;
|
|
|
|
u_char curscb;
|
1995-04-27 17:47:17 +00:00
|
|
|
bzero(scbp, sizeof(struct scb));
|
1994-11-17 20:22:31 +00:00
|
|
|
scbp->position = ahc->numscbs;
|
1995-04-27 17:47:17 +00:00
|
|
|
ahc->numscbs++;
|
|
|
|
scbp->flags = SCB_ACTIVE;
|
1994-11-17 20:22:31 +00:00
|
|
|
/*
|
|
|
|
* Place in the scbarray
|
|
|
|
* Never is removed. Position
|
|
|
|
* in ahc->scbarray is the scbarray
|
|
|
|
* position on the board we will
|
|
|
|
* load it into.
|
|
|
|
*/
|
|
|
|
ahc->scbarray[scbp->position] = scbp;
|
1995-01-16 16:33:47 +00:00
|
|
|
|
|
|
|
/*
|
1995-04-27 17:47:17 +00:00
|
|
|
* Initialize the host memory location
|
1995-01-16 16:33:47 +00:00
|
|
|
* of this SCB down on the board and
|
1995-04-27 17:47:17 +00:00
|
|
|
* flag that it should be DMA's before
|
|
|
|
* reference. Also set its psuedo
|
|
|
|
* next pointer (for use in the psuedo
|
|
|
|
* list of SCBs waiting for selection)
|
|
|
|
* to SCB_LIST_NULL.
|
|
|
|
*/
|
1995-01-16 16:33:47 +00:00
|
|
|
scbp->control = SCB_NEEDDMA;
|
|
|
|
scbp->host_scb = scbaddr;
|
1995-04-27 17:47:17 +00:00
|
|
|
scbp->next_waiting = SCB_LIST_NULL;
|
1995-01-16 16:33:47 +00:00
|
|
|
PAUSE_SEQUENCER(ahc);
|
|
|
|
curscb = inb(SCBPTR + iobase);
|
|
|
|
outb(SCBPTR + iobase, scbp->position);
|
|
|
|
outb(SCBCNT + iobase, 0x80);
|
1995-04-27 17:47:17 +00:00
|
|
|
outsb(SCBARRAY+iobase,scbp,31);
|
1995-01-16 16:33:47 +00:00
|
|
|
outb(SCBCNT + iobase, 0);
|
|
|
|
outb(SCBPTR + iobase, curscb);
|
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
scbp->control = 0;
|
1994-11-17 20:22:31 +00:00
|
|
|
} else {
|
|
|
|
printf("ahc%d: Can't malloc SCB\n", unit);
|
1995-04-23 22:04:58 +00:00
|
|
|
}
|
|
|
|
break;
|
1994-11-17 20:22:31 +00:00
|
|
|
} else {
|
|
|
|
if (!(flags & SCSI_NOSLEEP)) {
|
|
|
|
tsleep((caddr_t)&ahc->free_scb, PRIBIO,
|
|
|
|
"ahcscb", 0);
|
1995-04-23 22:04:58 +00:00
|
|
|
continue;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
break;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (scbp) {
|
1994-11-17 20:22:31 +00:00
|
|
|
/* Get SCB from from free list */
|
|
|
|
ahc->free_scb = scbp->next;
|
Fixes to the aic7xxx sequencer code and device driver from Justin Gibbs:
1) If a target initiated a sync negotiation with us and happened to chose a
value above 15, the old code inadvertantly truncated it with an "& 0x0f".
If the periferal picked something really bad like 0x32, you'd end up with
an offset of 2 which would hang the drive since it didn't expect to ever
get something so low. We now do a MIN(maxoffset, given_offset).
2) In the case of Wide cards, we were turning on sync transfers after a
sucessfull wide negotiation. Now we leave the offset alone in the per
target scratch space (which implies asyncronous transfers since we initialize
it that way) until a syncronous negotation occurs.
3) We were advertizing a max offset of 15 instead of 8 for wide devices.
4) If the upper level SCSI code sent down a "SCSI_RESET", it would hang the
system because we would end up sending a null command to the sequencer. Now
we handle SCSI_RESET correctly by having the sequencer interrupt us when it
is about to fill the message buffer so that we can fill it in ourselves.
The sequencer will also "simulate" a command complete for these "message only"
SCBs so that the kernel driver can finish up properly. The cdplay utility
will send a "SCSI_REST" to the cdplayer if you use the reset command.
5) The code that handles SCSIINTs was broken in that if more than one type
of error was true at once, we'd do outbs without the card being paused.
The else clause after the busfree case was also an accident waiting to
happen. I've now turned this into an if, else if, else type of thing, since
in most cases when we handle one type of error, it should be okay to ignore
the rest (ie if we have a SELTO, who cares if there was a parity error on
the transaction?), but the section should really be rewritten after 2.0.5.
This fix was the least obtrusive way to patch the problem.
6) Only tag either SDTR or WDTR negotiation on an SCB. The real problem is
that I don't account for the case when an SCB that is tagged to do a particular
type of negotiation completes or SELTOs (selection timeout) without the
negotiation taking place, so the accounting of sdtrpending and wdtrpending
gets screwed up. In the wide case, if we tag it to do both wdtr and sdtr,
it only performs wdtr (since wdtr must occur first and we spread out the
negotiation over two commands) so we always have sdtrpending set for that
target and we never do a real SDTR. I fill properly fix the accounting
after 2.0.5 goes out the door, but this works (as confirmed by Dan) on
wide targets.
Other stuff that is also included:
1) Don't do a bzero when recycling SCBs. The only thing that must explicitly
be set to zero is the scb control byte which is done in ahc_get_scb. We also
need to set the SG_list_pointer and SG_list_count to 0 for commands that do
not transfer data.
2) Mask the interrupt type printout for the aic7870 case. The bit we were
using to determine interrupt type is only valid for the aic7770.
Submitted by: Justin Gibbs
1995-05-17 07:06:02 +00:00
|
|
|
scbp->control = 0;
|
1994-11-17 20:22:31 +00:00
|
|
|
scbp->flags = SCB_ACTIVE;
|
1995-04-23 22:04:58 +00:00
|
|
|
#ifdef AHC_DEBUG
|
|
|
|
ahc->activescbs++;
|
|
|
|
if( ahc->activescbs == ahc->maxscbs )
|
1995-05-30 08:16:23 +00:00
|
|
|
printf("ahc%d: Max SCBs active\n", unit);
|
1995-04-23 22:04:58 +00:00
|
|
|
#endif
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-04-23 22:04:58 +00:00
|
|
|
|
|
|
|
gottit:
|
|
|
|
splx(opri);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
return (scbp);
|
|
|
|
}
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
void ahc_loadseq(iobase)
|
|
|
|
u_long iobase;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1994-11-18 09:14:14 +00:00
|
|
|
static unsigned char seqprog[] = {
|
1995-01-13 02:24:31 +00:00
|
|
|
# include "aic7xxx_seq.h"
|
1994-11-18 09:14:14 +00:00
|
|
|
};
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SEQCTL + iobase, PERRORDIS|SEQRESET|LOADRAM);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outsb(SEQRAM + iobase, seqprog, sizeof(seqprog));
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SEQCTL + iobase, FASTMODE|SEQRESET);
|
1994-11-17 20:22:31 +00:00
|
|
|
do {
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SEQCTL + iobase, SEQRESET|FASTMODE);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
} while (inb(SEQADDR0 + iobase) != 0 &&
|
1995-05-30 08:16:23 +00:00
|
|
|
inb(SEQADDR1 + iobase != 0));
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-11-17 20:22:31 +00:00
|
|
|
* Function to poll for command completion when in poll mode
|
1995-05-30 08:16:23 +00:00
|
|
|
*/
|
|
|
|
int
|
1994-11-17 20:22:31 +00:00
|
|
|
ahc_poll(int unit, int wait)
|
|
|
|
{ /* in msec */
|
1995-05-30 08:16:23 +00:00
|
|
|
struct ahc_data *ahc = ahcdata[unit];
|
1995-01-13 02:24:31 +00:00
|
|
|
u_long iobase = ahc->baseport;
|
1995-05-30 08:16:23 +00:00
|
|
|
u_long stport = INTSTAT + iobase;
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
while (--wait) {
|
1995-03-31 13:54:41 +00:00
|
|
|
DELAY(1000);
|
1994-11-17 20:22:31 +00:00
|
|
|
if (inb(stport) & INT_PEND)
|
|
|
|
break;
|
|
|
|
} if (wait == 0) {
|
|
|
|
printf("ahc%d: board not responding\n", unit);
|
|
|
|
return (EIO);
|
|
|
|
}
|
1995-03-31 13:54:41 +00:00
|
|
|
ahcintr(unit);
|
1994-11-17 20:22:31 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-12-31 19:31:56 +00:00
|
|
|
void
|
|
|
|
ahc_abort_scb( unit, ahc, scb )
|
|
|
|
int unit;
|
|
|
|
struct ahc_data *ahc;
|
|
|
|
struct scb *scb;
|
|
|
|
{
|
1995-01-13 02:24:31 +00:00
|
|
|
u_long iobase = ahc->baseport;
|
1994-12-31 19:31:56 +00:00
|
|
|
int found = 0;
|
|
|
|
int active_scb;
|
1995-01-13 02:24:31 +00:00
|
|
|
u_char flags;
|
1995-04-01 19:53:04 +00:00
|
|
|
u_char scb_control;
|
1994-12-31 19:31:56 +00:00
|
|
|
|
|
|
|
PAUSE_SEQUENCER(ahc);
|
|
|
|
/*
|
|
|
|
* Case 1: In the QINFIFO
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int saved_queue[AHC_SCB_MAX];
|
|
|
|
int i;
|
1995-01-13 02:24:31 +00:00
|
|
|
int queued = inb(QINCNT + iobase);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
|
|
|
for( i = 0; i < (queued - found); i++){
|
1995-01-13 02:24:31 +00:00
|
|
|
saved_queue[i] = inb(QINFIFO + iobase);
|
1994-12-31 19:31:56 +00:00
|
|
|
if( saved_queue[i] == scb->position ){
|
|
|
|
i--;
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Re-insert entries back into the queue */
|
|
|
|
for( queued = 0; queued < i; queued++ )
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(QINFIFO + iobase, saved_queue[queued]);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-12-31 19:31:56 +00:00
|
|
|
if( found ){
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
active_scb = inb(SCBPTR + iobase);
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
|
|
|
* Case 2: Not the active command
|
|
|
|
*/
|
|
|
|
if( active_scb != scb->position ){
|
|
|
|
/*
|
|
|
|
* Select the SCB we want to abort
|
|
|
|
* and turn off the disconnected bit.
|
|
|
|
* the driver will then abort the command
|
|
|
|
* and notify us of the abort.
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SCBPTR + iobase, scb->position);
|
|
|
|
scb_control = inb(SCBARRAY + iobase);
|
1994-12-31 19:31:56 +00:00
|
|
|
scb_control &= ~SCB_DIS;
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SCBARRAY + iobase, scb_control);
|
|
|
|
outb(SCBPTR + iobase, active_scb);
|
1994-12-31 19:31:56 +00:00
|
|
|
goto done;
|
|
|
|
}
|
1995-04-01 19:53:04 +00:00
|
|
|
scb_control = inb(SCBARRAY + iobase);
|
|
|
|
if( scb_control & SCB_DIS ) {
|
|
|
|
scb_control &= ~SCB_DIS;
|
|
|
|
outb(SCBARRAY + iobase, scb_control);
|
|
|
|
goto done;
|
|
|
|
}
|
1994-12-31 19:31:56 +00:00
|
|
|
/*
|
|
|
|
* Case 3: Currently active command
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
if ( (flags = inb(HA_FLAGS + iobase)) & ACTIVE_MSG) {
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
|
|
|
* If there's a message in progress,
|
1994-12-31 19:31:56 +00:00
|
|
|
* reset the bus and have all devices renegotiate.
|
|
|
|
*/
|
|
|
|
if(scb->target_channel_lun & 0x08){
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needsdtr |= (ahc->needsdtr_orig & 0xff00);
|
1995-02-03 17:15:12 +00:00
|
|
|
ahc->sdtrpending &= 0x00ff;
|
1995-07-04 21:14:45 +00:00
|
|
|
outb(HA_ACTIVE1 + iobase, 0);
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
1995-02-22 01:43:25 +00:00
|
|
|
else if (ahc->type & AHC_WIDE){
|
1995-01-16 16:33:47 +00:00
|
|
|
ahc->needsdtr = ahc->needsdtr_orig;
|
|
|
|
ahc->needwdtr = ahc->needwdtr_orig;
|
1995-02-03 17:15:12 +00:00
|
|
|
ahc->sdtrpending = 0;
|
|
|
|
ahc->wdtrpending = 0;
|
1995-07-04 21:14:45 +00:00
|
|
|
outb(HA_ACTIVE0 + iobase, 0);
|
|
|
|
outb(HA_ACTIVE1 + iobase, 0);
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
|
|
|
else{
|
1995-02-03 17:15:12 +00:00
|
|
|
ahc->needsdtr |= (ahc->needsdtr_orig & 0x00ff);
|
|
|
|
ahc->sdtrpending &= 0xff00;
|
1995-07-04 21:14:45 +00:00
|
|
|
outb(HA_ACTIVE0 + iobase, 0);
|
1994-12-31 19:31:56 +00:00
|
|
|
}
|
1995-01-16 16:33:47 +00:00
|
|
|
|
|
|
|
/* Reset the bus */
|
1995-05-30 08:16:23 +00:00
|
|
|
outb(SCSISEQ + iobase, SCSIRSTO);
|
1995-03-17 23:58:27 +00:00
|
|
|
DELAY(1000);
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SCSISEQ + iobase, 0);
|
1994-12-31 19:31:56 +00:00
|
|
|
goto done;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1994-12-31 19:31:56 +00:00
|
|
|
* Otherwise, set up an abort message and have the sequencer
|
|
|
|
* clean up
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(HA_FLAGS + iobase, flags | ACTIVE_MSG);
|
|
|
|
outb(HA_MSG_LEN + iobase, 1);
|
|
|
|
outb(HA_MSG_START + iobase, MSG_ABORT);
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
outb(SCSISIGO + iobase, inb(HA_SIGSTATE + iobase) | 0x10);
|
1994-12-31 19:31:56 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
scb->flags |= SCB_ABORTED;
|
|
|
|
UNPAUSE_SEQUENCER(ahc);
|
|
|
|
ahc_done(unit, scb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
void
|
|
|
|
ahc_timeout(void *arg1)
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1994-11-17 20:22:31 +00:00
|
|
|
struct scb *scb = (struct scb *)arg1;
|
1995-03-07 08:59:28 +00:00
|
|
|
int unit;
|
1994-11-17 20:22:31 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
int s = splbio();
|
1994-12-31 19:31:56 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
unit = scb->xs->sc_link->adapter_unit;
|
|
|
|
ahc = ahcdata[unit];
|
1995-02-22 01:43:25 +00:00
|
|
|
printf("ahc%d: target %d, lun %d (%s%d) timed out\n", unit
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb->xs->sc_link->target
|
1995-05-30 08:16:23 +00:00
|
|
|
,scb->xs->sc_link->lun
|
1994-11-17 20:22:31 +00:00
|
|
|
,scb->xs->sc_link->device->name
|
|
|
|
,scb->xs->sc_link->dev_unit);
|
1995-04-15 21:37:32 +00:00
|
|
|
#ifdef SCSIDEBUG
|
1995-05-30 08:16:23 +00:00
|
|
|
show_scsi_cmd(scb->xs);
|
1995-03-17 23:58:27 +00:00
|
|
|
#endif
|
1995-04-15 21:37:32 +00:00
|
|
|
#ifdef AHC_DEBUG
|
1995-02-22 01:43:25 +00:00
|
|
|
if (ahc_debug & AHC_SHOWSCBS)
|
1995-04-27 17:47:17 +00:00
|
|
|
ahc_print_active_scb(ahc);
|
1995-02-22 01:43:25 +00:00
|
|
|
#endif /*AHC_DEBUG */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
|
|
|
/*
|
1995-04-01 19:53:04 +00:00
|
|
|
* If it's immediate, don't try to abort it
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
if (scb->flags & SCB_IMMED) {
|
|
|
|
scb->xs->retries = 0; /* I MEAN IT ! */
|
|
|
|
ahc_done(unit, scb);
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
1994-12-31 19:31:56 +00:00
|
|
|
/* abort the operation that has timed out */
|
|
|
|
printf("\n");
|
|
|
|
ahc_abort_scb( unit, ahc, scb );
|
1994-11-17 20:22:31 +00:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|