1995-01-13 02:24:31 +00:00
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Interface to the generic driver for the aic7xxx based adaptec
|
|
|
|
* SCSI controllers. This is used to implement product specific
|
1995-01-13 02:24:31 +00:00
|
|
|
* probe and attach routines.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, 1995 Justin T. Gibbs.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Absolutely no warranty of function or purpose is made by the author
|
|
|
|
* Justin T. Gibbs.
|
|
|
|
* 4. Modifications may be freely made to this file if the above conditions
|
|
|
|
* are met.
|
1995-01-16 16:33:47 +00:00
|
|
|
*
|
1995-05-30 08:16:23 +00:00
|
|
|
* $Id: aic7xxx.h,v 1.8 1995/05/17 07:06:02 davidg Exp $
|
1995-01-13 02:24:31 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _AIC7XXX_H_
|
|
|
|
#define _AIC7XXX_H_
|
|
|
|
|
|
|
|
#include "ahc.h" /* for NAHC from config */
|
|
|
|
|
|
|
|
#define AHC_NSEG 256 /* number of dma segments supported */
|
|
|
|
|
|
|
|
#define AHC_SCB_MAX 16 /*
|
|
|
|
* Up to 16 SCBs on some types of aic7xxx based
|
|
|
|
* boards. The aic7770 family only have 4
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* #define AHCDEBUG */
|
|
|
|
|
|
|
|
typedef unsigned long int physaddr;
|
|
|
|
extern int ahc_unit;
|
|
|
|
|
|
|
|
struct ahc_dma_seg {
|
|
|
|
physaddr addr;
|
|
|
|
long len;
|
|
|
|
};
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-02-22 01:43:25 +00:00
|
|
|
typedef u_char ahc_type;
|
1995-03-31 13:54:41 +00:00
|
|
|
#define AHC_NONE 0x00
|
1995-02-22 01:43:25 +00:00
|
|
|
#define AHC_WIDE 0x02 /* Wide Channel */
|
|
|
|
#define AHC_TWIN 0x08 /* Twin Channel */
|
|
|
|
#define AHC_274 0x10 /* EISA Based Controller */
|
|
|
|
#define AHC_284 0x20 /* VL/ISA Based Controller */
|
1995-03-31 13:54:41 +00:00
|
|
|
#define AHC_AIC7870 0x40 /* PCI Based Controller */
|
|
|
|
#define AHC_294 0xc0 /* PCI Based Controller */
|
1995-01-13 02:24:31 +00:00
|
|
|
|
|
|
|
/*
|
1995-02-22 01:43:25 +00:00
|
|
|
* The driver keeps up to MAX_SCB scb structures per card in memory. Only the
|
1995-01-13 02:24:31 +00:00
|
|
|
* first 26 bytes of the structure are valid for the hardware, the rest used
|
|
|
|
* for driver level bookeeping. The "__attribute ((packed))" tags ensure that
|
|
|
|
* gcc does not attempt to pad the long ints in the structure to word
|
|
|
|
* boundaries since the first 26 bytes of this structure must have the correct
|
|
|
|
* offsets for the hardware to find them. The driver is further optimized
|
|
|
|
* so that we only have to download the first 19 bytes since as long
|
1995-05-30 08:16:23 +00:00
|
|
|
* as we always use S/G, the last fields should be zero anyway.
|
1995-01-13 02:24:31 +00:00
|
|
|
*/
|
|
|
|
struct scb {
|
|
|
|
/* ------------ Begin hardware supported fields ---------------- */
|
|
|
|
/*1*/ u_char control;
|
1995-01-16 16:33:47 +00:00
|
|
|
#define SCB_NEEDWDTR 0x80 /* Initiate Wide Negotiation */
|
|
|
|
#define SCB_NEEDSDTR 0x40 /* Initiate Sync Negotiation */
|
1995-02-22 01:43:25 +00:00
|
|
|
#define SCB_TE 0x20 /* Tag enable */
|
1995-04-27 17:47:17 +00:00
|
|
|
#define SCB_NEEDDMA 0x08 /* Refresh SCB from host ram */
|
1995-01-13 02:24:31 +00:00
|
|
|
#define SCB_DIS 0x04
|
|
|
|
#define SCB_TAG_TYPE 0x3
|
|
|
|
#define SIMPLE_QUEUE 0x0
|
|
|
|
#define HEAD_QUEUE 0x1
|
|
|
|
#define OR_QUEUE 0x2
|
|
|
|
/*2*/ u_char target_channel_lun; /* 4/1/3 bits */
|
|
|
|
/*3*/ u_char SG_segment_count;
|
|
|
|
/*7*/ physaddr SG_list_pointer __attribute__ ((packed));
|
|
|
|
/*11*/ physaddr cmdpointer __attribute__ ((packed));
|
|
|
|
/*12*/ u_char cmdlen;
|
|
|
|
/*14*/ u_char RESERVED[2]; /* must be zero */
|
|
|
|
/*15*/ u_char target_status;
|
|
|
|
/*18*/ u_char residual_data_count[3];
|
|
|
|
/*19*/ u_char residual_SG_segment_count;
|
1995-01-16 16:33:47 +00:00
|
|
|
#define SCB_DOWN_SIZE 19 /* amount to actually download */
|
1995-05-30 08:16:23 +00:00
|
|
|
#define SCB_BZERO_SIZE 19 /*
|
1995-04-23 22:04:58 +00:00
|
|
|
* amount we need to clear between
|
|
|
|
* commands
|
|
|
|
*/
|
1995-01-13 02:24:31 +00:00
|
|
|
/*23*/ physaddr data __attribute__ ((packed));
|
|
|
|
/*26*/ u_char datalen[3];
|
1995-05-30 08:16:23 +00:00
|
|
|
#define SCB_UP_SIZE 26 /*
|
1995-04-23 22:04:58 +00:00
|
|
|
* amount we need to upload to perform
|
|
|
|
* a request sense.
|
|
|
|
*/
|
1995-01-16 16:33:47 +00:00
|
|
|
/*30*/ physaddr host_scb __attribute__ ((packed));
|
1995-05-30 08:16:23 +00:00
|
|
|
/*31*/ u_char next_waiting; /* Used to thread SCBs awaiting
|
1995-04-27 17:47:17 +00:00
|
|
|
* selection
|
|
|
|
*/
|
|
|
|
#define SCB_LIST_NULL 0x10 /* SCB list equivelent to NULL */
|
1995-01-13 02:24:31 +00:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* No real point in transferring this to the
|
|
|
|
* SCB registers.
|
|
|
|
*/
|
1995-04-27 17:47:17 +00:00
|
|
|
unsigned char RESERVED[1];
|
1995-01-13 02:24:31 +00:00
|
|
|
#endif
|
|
|
|
/*-----------------end of hardware supported fields----------------*/
|
|
|
|
struct scb *next; /* in free list */
|
|
|
|
struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
|
|
|
|
int flags;
|
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 SCB_FREE 0x00
|
|
|
|
#define SCB_ACTIVE 0x01
|
|
|
|
#define SCB_ABORTED 0x02
|
|
|
|
#define SCB_DEVICE_RESET 0x04
|
|
|
|
#define SCB_IMMED 0x08
|
|
|
|
#define SCB_SENSE 0x10
|
1995-01-13 02:24:31 +00:00
|
|
|
int position; /* Position in scbarray */
|
|
|
|
struct ahc_dma_seg ahc_dma[AHC_NSEG] __attribute__ ((packed));
|
|
|
|
struct scsi_sense sense_cmd; /* SCSI command block */
|
|
|
|
};
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1995-01-13 02:24:31 +00:00
|
|
|
struct ahc_data {
|
|
|
|
ahc_type type;
|
|
|
|
int flags;
|
|
|
|
#define AHC_INIT 0x01
|
|
|
|
#define AHC_RUNNING 0x02
|
|
|
|
u_long baseport;
|
|
|
|
struct scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */
|
|
|
|
struct scb *free_scb;
|
|
|
|
int our_id; /* our scsi id */
|
|
|
|
int our_id_b; /* B channel scsi id */
|
|
|
|
int vect;
|
|
|
|
struct scb *immed_ecb; /* an outstanding immediete command */
|
|
|
|
struct scsi_link sc_link;
|
|
|
|
struct scsi_link sc_link_b; /* Second bus for Twin channel cards */
|
1995-01-16 16:33:47 +00:00
|
|
|
u_short needsdtr_orig; /* Targets we initiate sync neg with */
|
|
|
|
u_short needwdtr_orig; /* Targets we initiate wide neg with */
|
|
|
|
u_short needsdtr; /* Current list of negotiated targets */
|
|
|
|
u_short needwdtr; /* Current list of negotiated targets */
|
1995-02-03 17:15:12 +00:00
|
|
|
u_short sdtrpending; /* Pending SDTR to these targets */
|
|
|
|
u_short wdtrpending; /* Pending WDTR to these targets */
|
1995-02-22 01:43:25 +00:00
|
|
|
u_short tagenable; /* Targets that can handle tagqueing */
|
1995-01-13 02:24:31 +00:00
|
|
|
int numscbs;
|
1995-04-23 22:04:58 +00:00
|
|
|
int activescbs;
|
1995-01-13 02:24:31 +00:00
|
|
|
u_char maxscbs;
|
1995-03-31 13:54:41 +00:00
|
|
|
u_char unpause;
|
|
|
|
u_char pause;
|
1995-01-13 02:24:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct ahc_data *ahcdata[NAHC];
|
|
|
|
|
|
|
|
int ahcprobe __P((int unit, u_long io_base, ahc_type type));
|
|
|
|
int ahc_attach __P((int unit));
|
|
|
|
int ahcintr();
|
|
|
|
|
|
|
|
#endif /* _AIC7XXX_H_ */
|