Use the new adapter_softc field in the scsi_link structure so that
in the future, these drivers won't need to maintain an array of configured units. They still need to because ISA interrupt handlers take a unit number. :( Pass "softc" pointers instead of unit numbers to many functions that did a conversion of unit->softc anyway.
This commit is contained in:
parent
7087c7dd9a
commit
379226f072
@ -12,7 +12,7 @@
|
||||
* on the understanding that TFS is not responsible for the correct
|
||||
* functioning of this software in any circumstances.
|
||||
*
|
||||
* $Id: aha1542.c,v 1.53 1995/12/15 00:11:26 bde Exp $
|
||||
* $Id: aha1542.c,v 1.54 1995/12/29 00:30:06 peter Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -309,6 +309,7 @@ static struct aha_data {
|
||||
struct aha_mbx aha_mbx; /* all the mailboxes */
|
||||
struct aha_ccb *aha_ccb_free; /* the next free ccb */
|
||||
struct aha_ccb aha_ccb[AHA_MBX_SIZE]; /* all the CCBs */
|
||||
int unit; /* unit number */
|
||||
int aha_int; /* irq level */
|
||||
int aha_dma; /* DMA req channel */
|
||||
int aha_scsi_dev; /* scsi bus address */
|
||||
@ -324,29 +325,30 @@ static struct aha_data {
|
||||
|
||||
static u_int32 aha_adapter_info __P((int unit));
|
||||
static int ahaattach __P((struct isa_device *dev));
|
||||
static int aha_bus_speed_check __P((int unit, int speed));
|
||||
static int aha_bus_speed_check __P((struct aha_data *aha, int speed));
|
||||
#ifdef notyet
|
||||
static int aha_cmd __P((int unit, int icnt, int ocnt, int wait,
|
||||
static int aha_cmd __P((struct aha_data *aha, int icnt, int ocnt, int wait,
|
||||
u_char *retval, unsigned opcode, ...));
|
||||
#else
|
||||
static int aha_cmd();
|
||||
#endif
|
||||
static void aha_done __P((int unit, struct aha_ccb *ccb));
|
||||
static void aha_done __P((struct aha_data *aha, struct aha_ccb *ccb));
|
||||
static int aha_escape __P((struct scsi_xfer *xs, struct aha_ccb *ccb));
|
||||
static void aha_free_ccb __P((int unit, struct aha_ccb *ccb, int flags));
|
||||
static void aha_free_ccb __P((struct aha_data *aha, struct aha_ccb *ccb,
|
||||
int flags));
|
||||
static struct aha_ccb *
|
||||
aha_get_ccb __P((int unit, int flags));
|
||||
static int aha_init __P((int unit));
|
||||
aha_get_ccb __P((struct aha_data *aha, int flags));
|
||||
static int aha_init __P((struct aha_data *aha));
|
||||
static void ahaminphys __P((struct buf *bp));
|
||||
static int aha_poll __P((int unit, struct scsi_xfer *xs,
|
||||
static int aha_poll __P((struct aha_data *aha, struct scsi_xfer *xs,
|
||||
struct aha_ccb *ccb));
|
||||
static int ahaprobe __P((struct isa_device *dev));
|
||||
static void aha_registerdev __P((struct isa_device *id));
|
||||
static int32 aha_scsi_cmd __P((struct scsi_xfer *xs));
|
||||
static int aha_set_bus_speed __P((int unit));
|
||||
static int aha_set_bus_speed __P((struct aha_data *aha));
|
||||
static timeout_t
|
||||
aha_timeout;
|
||||
static char *board_rev __P((int unit, int type));
|
||||
static char *board_rev __P((struct aha_data *aha, int type));
|
||||
static int physcontig __P((int kv, int len));
|
||||
static void put_host_stat __P((int host_stat));
|
||||
|
||||
@ -426,7 +428,7 @@ main()
|
||||
#else /*KERNEL */
|
||||
|
||||
/*
|
||||
* aha_cmd(unit,icnt, ocnt,wait, retval, opcode, args)
|
||||
* aha_cmd(struct aha_data *aha,icnt, ocnt,wait, retval, opcode, args)
|
||||
* Activate Adapter command
|
||||
* icnt: number of args (outbound bytes written after opcode)
|
||||
* ocnt: number of expected returned bytes
|
||||
@ -441,8 +443,8 @@ main()
|
||||
* separately. This is only called during set-up.
|
||||
*/
|
||||
static int
|
||||
aha_cmd(unit, icnt, ocnt, wait, retval, opcode, args)
|
||||
int unit;
|
||||
aha_cmd(aha, icnt, ocnt, wait, retval, opcode, args)
|
||||
struct aha_data *aha;
|
||||
int icnt;
|
||||
int ocnt;
|
||||
int wait;
|
||||
@ -450,7 +452,6 @@ aha_cmd(unit, icnt, ocnt, wait, retval, opcode, args)
|
||||
unsigned opcode;
|
||||
u_char args;
|
||||
{
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
unsigned *ic = &opcode;
|
||||
u_char oc;
|
||||
register i;
|
||||
@ -480,7 +481,7 @@ aha_cmd(unit, icnt, ocnt, wait, retval, opcode, args)
|
||||
}
|
||||
if (!i) {
|
||||
printf("aha%d: aha_cmd, host not idle(0x%x)\n",
|
||||
unit, sts);
|
||||
aha->unit, sts);
|
||||
return (ENXIO);
|
||||
}
|
||||
}
|
||||
@ -507,7 +508,8 @@ aha_cmd(unit, icnt, ocnt, wait, retval, opcode, args)
|
||||
DELAY(50);
|
||||
}
|
||||
if (i == 0) {
|
||||
printf("aha%d: aha_cmd, cmd/data port full\n", unit);
|
||||
printf("aha%d: aha_cmd, cmd/data port full\n",
|
||||
aha->unit);
|
||||
outb(AHA_CTRL_STAT_PORT, AHA_SRST);
|
||||
return (ENXIO);
|
||||
}
|
||||
@ -527,7 +529,7 @@ aha_cmd(unit, icnt, ocnt, wait, retval, opcode, args)
|
||||
}
|
||||
if (i == 0) {
|
||||
printf("aha%d: aha_cmd, cmd/data port empty %d\n",
|
||||
unit, ocnt);
|
||||
aha->unit, ocnt);
|
||||
return (ENXIO);
|
||||
}
|
||||
oc = inb(AHA_CMD_DATA_PORT);
|
||||
@ -546,7 +548,8 @@ aha_cmd(unit, icnt, ocnt, wait, retval, opcode, args)
|
||||
DELAY(50);
|
||||
}
|
||||
if (i == 0) {
|
||||
printf("aha%d: aha_cmd, host not finished(0x%x)\n", unit, sts);
|
||||
printf("aha%d: aha_cmd, host not finished(0x%x)\n",
|
||||
aha->unit, sts);
|
||||
return (ENXIO);
|
||||
}
|
||||
outb(AHA_CTRL_STAT_PORT, AHA_IRST);
|
||||
@ -606,7 +609,7 @@ ahaprobe(dev)
|
||||
* Try initialise a unit at this location
|
||||
* sets up dma and bus speed, loads aha->aha_int
|
||||
*/
|
||||
if (aha_init(unit) != 0) {
|
||||
if (aha_init(aha) != 0) {
|
||||
ahadata[unit] = NULL;
|
||||
free(aha, M_TEMP);
|
||||
return 0;
|
||||
@ -651,6 +654,7 @@ ahaattach(dev)
|
||||
*/
|
||||
aha->sc_link.adapter_unit = unit;
|
||||
aha->sc_link.adapter_targ = aha->aha_scsi_dev;
|
||||
aha->sc_link.adapter_softc = aha;
|
||||
aha->sc_link.adapter = &aha_switch;
|
||||
aha->sc_link.device = &aha_dev;
|
||||
aha->sc_link.flags = aha->flags;;
|
||||
@ -789,7 +793,7 @@ ahaintr(unit)
|
||||
#endif /*AHADEBUG */
|
||||
if (ccb) {
|
||||
untimeout(aha_timeout, (caddr_t)ccb);
|
||||
aha_done(unit, ccb);
|
||||
aha_done(aha, ccb);
|
||||
}
|
||||
mbi->stat = AHA_MBI_FREE;
|
||||
}
|
||||
@ -801,12 +805,11 @@ ahaintr(unit)
|
||||
* free list.
|
||||
*/
|
||||
static void
|
||||
aha_free_ccb(unit, ccb, flags)
|
||||
int unit;
|
||||
aha_free_ccb(aha, ccb, flags)
|
||||
struct aha_data *aha;
|
||||
struct aha_ccb *ccb;
|
||||
int flags;
|
||||
{
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
unsigned int opri = 0;
|
||||
|
||||
if (!(flags & SCSI_NOMASK))
|
||||
@ -830,11 +833,10 @@ aha_free_ccb(unit, ccb, flags)
|
||||
* Get a free ccb (and hence mbox-out entry)
|
||||
*/
|
||||
static struct aha_ccb *
|
||||
aha_get_ccb(unit, flags)
|
||||
int unit;
|
||||
aha_get_ccb(aha, flags)
|
||||
struct aha_data *aha;
|
||||
int flags;
|
||||
{
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
unsigned opri = 0;
|
||||
struct aha_ccb *rc;
|
||||
|
||||
@ -894,8 +896,8 @@ put_host_stat(int host_stat)
|
||||
* went. Wake up the owner if waiting
|
||||
*/
|
||||
static void
|
||||
aha_done(unit, ccb)
|
||||
int unit;
|
||||
aha_done(aha, ccb)
|
||||
struct aha_data *aha;
|
||||
struct aha_ccb *ccb;
|
||||
{
|
||||
struct scsi_sense_data *s1, *s2;
|
||||
@ -907,7 +909,7 @@ aha_done(unit, ccb)
|
||||
* into the xfer and call whoever started it
|
||||
*/
|
||||
if (!(xs->flags & INUSE)) {
|
||||
printf("aha%d: exiting but not in use!\n", unit);
|
||||
printf("aha%d: exiting but not in use!\n", aha->unit);
|
||||
Debugger("aha1542");
|
||||
}
|
||||
xs->status = ccb->target_stat;
|
||||
@ -956,7 +958,7 @@ aha_done(unit, ccb)
|
||||
|
||||
default: /* Other scsi protocol messes */
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
printf("aha%d: ", unit);
|
||||
printf("aha%d: ", aha->unit);
|
||||
put_host_stat(ccb->host_stat);
|
||||
}
|
||||
} else {
|
||||
@ -973,14 +975,14 @@ aha_done(unit, ccb)
|
||||
break;
|
||||
default:
|
||||
printf("aha%d:target_stat%x\n",
|
||||
unit, ccb->target_stat);
|
||||
aha->unit, ccb->target_stat);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xs->flags |= ITSDONE;
|
||||
aha_free_ccb(unit, ccb, xs->flags);
|
||||
aha_free_ccb(aha, ccb, xs->flags);
|
||||
scsi_done(xs);
|
||||
}
|
||||
|
||||
@ -990,7 +992,7 @@ aha_done(unit, ccb)
|
||||
*/
|
||||
#define PROBABLY_NEW_BOARD(REV) (REV > 0x43 && REV < 0x56)
|
||||
|
||||
static char *board_rev(int unit, int type)
|
||||
static char *board_rev(struct aha_data *aha, int type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
@ -1009,11 +1011,12 @@ static char *board_rev(int unit, int type)
|
||||
if (PROBABLY_NEW_BOARD(type))
|
||||
{
|
||||
printf("aha%d: Assuming type %02x is a new board.\n",
|
||||
unit, type);
|
||||
aha->unit, type);
|
||||
return "New Adaptec rev?";
|
||||
}
|
||||
|
||||
printf("aha%d: type %02x is an unknown board.\n", unit, type);
|
||||
printf("aha%d: type %02x is an unknown board.\n",
|
||||
aha->unit, type);
|
||||
return "Unknown board";
|
||||
}
|
||||
}
|
||||
@ -1022,10 +1025,9 @@ static char *board_rev(int unit, int type)
|
||||
* Start the board, ready for normal operation
|
||||
*/
|
||||
static int
|
||||
aha_init(unit)
|
||||
int unit;
|
||||
aha_init(aha)
|
||||
struct aha_data *aha;
|
||||
{
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
char *desc;
|
||||
unsigned char ad[3];
|
||||
volatile int i, sts;
|
||||
@ -1071,14 +1073,14 @@ aha_init(unit)
|
||||
* command fails, blatter about it, nuke the boardid so the 1542C
|
||||
* stuff gets skipped over, and reset the board again.
|
||||
*/
|
||||
if(aha_cmd(unit, 0, sizeof(inquire), 1 ,&inquire, AHA_INQUIRE)) {
|
||||
if(aha_cmd(aha, 0, sizeof(inquire), 1 ,&inquire, AHA_INQUIRE)) {
|
||||
/*
|
||||
* Blah.. not a real adaptec board!!!
|
||||
* Seems that the Buslogic 545S and the DTC3290 both get
|
||||
* this wrong.
|
||||
*/
|
||||
printf ("aha%d: not a REAL adaptec board, may cause warnings\n",
|
||||
unit);
|
||||
aha->unit);
|
||||
inquire.boardid = 0;
|
||||
outb(AHA_CTRL_STAT_PORT, AHA_HRST | AHA_SRST);
|
||||
for (i = AHA_RESET_TIMEOUT; i; i--) {
|
||||
@ -1101,7 +1103,7 @@ aha_init(unit)
|
||||
}
|
||||
#ifdef AHADEBUG
|
||||
printf("aha%d: inquire %x, %x, %x, %x\n",
|
||||
unit,
|
||||
aha->unit,
|
||||
inquire.boardid, inquire.spec_opts,
|
||||
inquire.revision_1, inquire.revision_2);
|
||||
#endif /* AHADEBUG */
|
||||
@ -1119,23 +1121,23 @@ aha_init(unit)
|
||||
* No need to check the extended bios flags as some of the
|
||||
* extensions that cause us problems are not flagged in that byte.
|
||||
*/
|
||||
desc = board_rev(unit, inquire.boardid);
|
||||
desc = board_rev(aha, inquire.boardid);
|
||||
|
||||
PRVERBOSE( ("aha%d: Rev %02x (%s) V%c.%c",
|
||||
unit, inquire.boardid, desc, inquire.revision_1,
|
||||
inquire.revision_2) );
|
||||
aha->unit, inquire.boardid, desc, inquire.revision_1,
|
||||
inquire.revision_2) );
|
||||
|
||||
if (PROBABLY_NEW_BOARD(inquire.boardid) ||
|
||||
(inquire.boardid == 0x41
|
||||
&& inquire.revision_1 == 0x31 && inquire.revision_2 == 0x34)) {
|
||||
aha_cmd(unit, 0, sizeof(extbios), 0, &extbios, AHA_EXT_BIOS);
|
||||
aha_cmd(aha, 0, sizeof(extbios), 0, &extbios, AHA_EXT_BIOS);
|
||||
#ifdef AHADEBUG
|
||||
printf("aha%d: extended bios flags %x\n", unit, extbios.flags);
|
||||
printf("aha%d: extended bios flags %x\n", aha->unit, extbios.flags);
|
||||
#endif /* AHADEBUG */
|
||||
|
||||
PRVERBOSE( (", enabling mailbox") );
|
||||
|
||||
aha_cmd(unit, 2, 0, 0, 0, AHA_MBX_ENABLE,
|
||||
aha_cmd(aha, 2, 0, 0, 0, AHA_MBX_ENABLE,
|
||||
0, extbios.mailboxlock);
|
||||
}
|
||||
|
||||
@ -1169,13 +1171,13 @@ aha_init(unit)
|
||||
* setup dma channel from jumpers and save int
|
||||
* level
|
||||
*/
|
||||
PRVERBOSE(("aha%d: reading board settings, ", unit));
|
||||
PRVERBOSE(("aha%d: reading board settings, ", aha->unit));
|
||||
|
||||
if (inquire.boardid == 0x20) {
|
||||
DELAY(1000); /* for Bustek 545 */
|
||||
}
|
||||
|
||||
aha_cmd(unit, 0, sizeof(conf), 0, &conf, AHA_CONF_GET);
|
||||
aha_cmd(aha, 0, sizeof(conf), 0, &conf, AHA_CONF_GET);
|
||||
switch (conf.chan) {
|
||||
case CHAN0:
|
||||
outb(0x0b, 0x0c);
|
||||
@ -1198,7 +1200,7 @@ aha_init(unit)
|
||||
aha->aha_dma = 7;
|
||||
break;
|
||||
default:
|
||||
printf("aha%d: illegal dma jumper setting\n", unit);
|
||||
printf("aha%d: illegal dma jumper setting\n", aha->unit);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
@ -1224,7 +1226,7 @@ aha_init(unit)
|
||||
aha->aha_int = 15;
|
||||
break;
|
||||
default:
|
||||
printf("aha%d: illegal int jumper setting\n", unit);
|
||||
printf("aha%d: illegal int jumper setting\n", aha->unit);
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
@ -1238,15 +1240,15 @@ aha_init(unit)
|
||||
/*
|
||||
* Change the bus on/off times to not clash with other dma users.
|
||||
*/
|
||||
aha_cmd(unit, 1, 0, 0, 0, AHA_BUS_ON_TIME_SET, 7);
|
||||
aha_cmd(unit, 1, 0, 0, 0, AHA_BUS_OFF_TIME_SET, 4);
|
||||
aha_cmd(aha, 1, 0, 0, 0, AHA_BUS_ON_TIME_SET, 7);
|
||||
aha_cmd(aha, 1, 0, 0, 0, AHA_BUS_OFF_TIME_SET, 4);
|
||||
|
||||
#ifdef TUNE_1542
|
||||
/*
|
||||
* Initialize memory transfer speed
|
||||
* Not compiled in by default because it breaks some machines
|
||||
*/
|
||||
if (!(aha_set_bus_speed(unit))) {
|
||||
if (!(aha_set_bus_speed(aha))) {
|
||||
return (EIO);
|
||||
}
|
||||
#else
|
||||
@ -1257,7 +1259,7 @@ aha_init(unit)
|
||||
*/
|
||||
scsi_uto3b(KVTOPHYS(&aha->aha_mbx), ad);
|
||||
|
||||
aha_cmd(unit, 4, 0, 0, 0, AHA_MBX_INIT,
|
||||
aha_cmd(aha, 4, 0, 0, 0, AHA_MBX_INIT,
|
||||
AHA_MBX_SIZE,
|
||||
ad[0],
|
||||
ad[1],
|
||||
@ -1311,7 +1313,8 @@ aha_escape(xs, ccb)
|
||||
|
||||
case SCSI_OP_TARGET:
|
||||
s= splbio();
|
||||
aha_cmd(xs->sc_link->adapter_unit, 2, 0, 0, 0, AHA_TARGET_EN,
|
||||
aha_cmd((struct aha_data *)xs->sc_link->adapter_softc,
|
||||
2, 0, 0, 0, AHA_TARGET_EN,
|
||||
(int)xs->cmd->bytes[0], (int)1);
|
||||
splx(s);
|
||||
ret = COMPLETE;
|
||||
@ -1388,8 +1391,7 @@ aha_scsi_cmd(xs)
|
||||
struct scsi_xfer *xs;
|
||||
{
|
||||
struct scsi_link *sc_link = xs->sc_link;
|
||||
int unit = sc_link->adapter_unit;
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
struct aha_data *aha;
|
||||
struct aha_ccb *ccb;
|
||||
struct aha_scat_gath *sg;
|
||||
int seg; /* scatter gather seg being worked on */
|
||||
@ -1398,6 +1400,8 @@ aha_scsi_cmd(xs)
|
||||
int bytes_this_seg, bytes_this_page, datalen, flags;
|
||||
int s;
|
||||
|
||||
aha = (struct aha_data *)sc_link->adapter_softc;
|
||||
|
||||
SC_DEBUG(xs->sc_link, SDEV_DB2, ("aha_scsi_cmd\n"));
|
||||
/*
|
||||
* get a ccb (mbox-out) to use. If the transfer
|
||||
@ -1405,13 +1409,13 @@ aha_scsi_cmd(xs)
|
||||
* then we can't allow it to sleep
|
||||
*/
|
||||
flags = xs->flags;
|
||||
if (!(ccb = aha_get_ccb(unit, flags))) {
|
||||
if (!(ccb = aha_get_ccb(aha, flags))) {
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return (TRY_AGAIN_LATER);
|
||||
}
|
||||
if (ccb->mbx->cmd != AHA_MBO_FREE)
|
||||
printf("aha%d: MBO %02x and not %02x (free)\n",
|
||||
unit, ccb->mbx->cmd, AHA_MBO_FREE);
|
||||
aha->unit, ccb->mbx->cmd, AHA_MBO_FREE);
|
||||
|
||||
/*
|
||||
* Put all the arguments for the xfer in the ccb
|
||||
@ -1422,8 +1426,8 @@ aha_scsi_cmd(xs)
|
||||
} else {
|
||||
/* can't use S/G if zero length */
|
||||
ccb->opcode = (xs->datalen ?
|
||||
ahadata[unit]->sg_opcode
|
||||
: ahadata[unit]->init_opcode);
|
||||
aha->sg_opcode
|
||||
: aha->init_opcode);
|
||||
}
|
||||
ccb->target = sc_link->target;
|
||||
ccb->data_out = 0;
|
||||
@ -1566,9 +1570,9 @@ aha_scsi_cmd(xs)
|
||||
{
|
||||
printf("aha%d: DMA beyond"
|
||||
" end Of ISA: 0x%x\n",
|
||||
unit, thisphys);
|
||||
aha->unit, thisphys);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
aha_free_ccb(unit, ccb, flags);
|
||||
aha_free_ccb(aha, ccb, flags);
|
||||
return (HAD_ERROR);
|
||||
}
|
||||
/** how far to the end of the page ***/
|
||||
@ -1602,17 +1606,17 @@ aha_scsi_cmd(xs)
|
||||
|
||||
if (datalen) { /* there's still data, must have run out of segs! */
|
||||
printf("aha%d: aha_scsi_cmd, more than %d DMA segs\n",
|
||||
unit, AHA_NSEG);
|
||||
aha->unit, AHA_NSEG);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
aha_free_ccb(unit, ccb, flags);
|
||||
aha_free_ccb(aha, ccb, flags);
|
||||
return (HAD_ERROR);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("aha_scsi_cmd%d: Illegal CCB opcode.\n", unit);
|
||||
printf("aha_scsi_cmd%d: Illegal CCB opcode.\n", aha->unit);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
aha_free_ccb(unit,ccb,flags);
|
||||
aha_free_ccb(aha,ccb,flags);
|
||||
return HAD_ERROR;
|
||||
}
|
||||
|
||||
@ -1639,19 +1643,18 @@ aha_scsi_cmd(xs)
|
||||
/*
|
||||
* If we can't use interrupts, poll on completion
|
||||
*/
|
||||
return (aha_poll(unit, xs, ccb)); /* only during boot */
|
||||
return (aha_poll(aha, xs, ccb)); /* only during boot */
|
||||
}
|
||||
|
||||
/*
|
||||
* Poll a particular unit, looking for a particular xs
|
||||
*/
|
||||
static int
|
||||
aha_poll(unit, xs, ccb)
|
||||
int unit;
|
||||
aha_poll(aha, xs, ccb)
|
||||
struct aha_data *aha;
|
||||
struct scsi_xfer *xs;
|
||||
struct aha_ccb *ccb;
|
||||
{
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
int count = xs->timeout;
|
||||
u_char stat;
|
||||
|
||||
@ -1663,7 +1666,7 @@ aha_poll(unit, xs, ccb)
|
||||
*/
|
||||
stat = inb(AHA_INTR_PORT);
|
||||
if (stat & AHA_ANY_INTR) {
|
||||
ahaintr(unit);
|
||||
ahaintr(aha->unit);
|
||||
}
|
||||
if (xs->flags & ITSDONE) {
|
||||
break;
|
||||
@ -1692,7 +1695,7 @@ aha_poll(unit, xs, ccb)
|
||||
*/
|
||||
stat = inb(AHA_INTR_PORT);
|
||||
if (stat & AHA_ANY_INTR) {
|
||||
ahaintr(unit);
|
||||
ahaintr(aha->unit);
|
||||
}
|
||||
if (xs->flags & ITSDONE) {
|
||||
break;
|
||||
@ -1741,18 +1744,17 @@ static struct bus_speed
|
||||
};
|
||||
|
||||
static int
|
||||
aha_set_bus_speed(unit)
|
||||
int unit;
|
||||
aha_set_bus_speed(aha)
|
||||
struct aha_data *aha;
|
||||
{
|
||||
int speed;
|
||||
int lastworking;
|
||||
int retval,retval2;
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
|
||||
lastworking = -1;
|
||||
speed = 7;
|
||||
while (1) {
|
||||
retval = aha_bus_speed_check(unit,speed);
|
||||
retval = aha_bus_speed_check(aha,speed);
|
||||
if(retval != 0) {
|
||||
lastworking = speed;
|
||||
}
|
||||
@ -1768,7 +1770,7 @@ aha_set_bus_speed(unit)
|
||||
} else {
|
||||
lastworking++;
|
||||
}
|
||||
retval2 = aha_bus_speed_check(unit,lastworking);
|
||||
retval2 = aha_bus_speed_check(aha,lastworking);
|
||||
if(retval2 == 0) {
|
||||
printf("test retry failed.. aborting.\n");
|
||||
return 0;
|
||||
@ -1791,13 +1793,13 @@ static char aha_test_string[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijk
|
||||
u_char aha_scratch_buf[256];
|
||||
|
||||
static int
|
||||
aha_bus_speed_check(unit, speed)
|
||||
int unit, speed;
|
||||
aha_bus_speed_check(aha, speed)
|
||||
struct aha_data *aha;
|
||||
int speed;
|
||||
{
|
||||
int numspeeds = sizeof(aha_bus_speeds) / sizeof(struct bus_speed);
|
||||
int loopcount;
|
||||
u_char ad[3];
|
||||
struct aha_data *aha = ahadata[unit];
|
||||
|
||||
/*
|
||||
* Check we have such an entry
|
||||
@ -1808,7 +1810,7 @@ aha_bus_speed_check(unit, speed)
|
||||
/*
|
||||
* Set the dma-speed
|
||||
*/
|
||||
aha_cmd(unit, 1, 0, 0, 0, AHA_SPEED_SET, aha_bus_speeds[speed].arg);
|
||||
aha_cmd(aha, 1, 0, 0, 0, AHA_SPEED_SET, aha_bus_speeds[speed].arg);
|
||||
|
||||
/*
|
||||
* put the test data into the buffer and calculate
|
||||
@ -1819,7 +1821,7 @@ aha_bus_speed_check(unit, speed)
|
||||
{
|
||||
strcpy(aha_scratch_buf, aha_test_string);
|
||||
|
||||
aha_cmd(unit, 3, 0, 0, 0, AHA_WRITE_FIFO, ad[0], ad[1], ad[2]);
|
||||
aha_cmd(aha, 3, 0, 0, 0, AHA_WRITE_FIFO, ad[0], ad[1], ad[2]);
|
||||
|
||||
/*
|
||||
* clear the buffer then copy the contents back from the
|
||||
@ -1827,7 +1829,7 @@ aha_bus_speed_check(unit, speed)
|
||||
*/
|
||||
bzero(aha_scratch_buf, 54); /* 54 bytes transfered by test */
|
||||
|
||||
aha_cmd(unit, 3, 0, 0, 0, AHA_READ_FIFO, ad[0], ad[1], ad[2]);
|
||||
aha_cmd(aha, 3, 0, 0, 0, AHA_READ_FIFO, ad[0], ad[1], ad[2]);
|
||||
|
||||
/*
|
||||
* Compare the original data and the final data and
|
||||
@ -1847,12 +1849,10 @@ static void
|
||||
aha_timeout(void *arg1)
|
||||
{
|
||||
struct aha_ccb * ccb = (struct aha_ccb *)arg1;
|
||||
int unit;
|
||||
int s = splbio();
|
||||
struct aha_data *aha;
|
||||
|
||||
unit = ccb->xfer->sc_link->adapter_unit;
|
||||
aha = ahadata[unit];
|
||||
aha = (struct aha_data *)ccb->xfer->sc_link->adapter_softc;
|
||||
sc_print_addr(ccb->xfer->sc_link);
|
||||
printf("timed out ");
|
||||
|
||||
@ -1874,7 +1874,7 @@ aha_timeout(void *arg1)
|
||||
printf(" AGAIN\n");
|
||||
ccb->xfer->retries = 0; /* I MEAN IT ! */
|
||||
ccb->host_stat = AHA_ABORTED;
|
||||
aha_done(unit, ccb);
|
||||
aha_done(aha, ccb);
|
||||
} else {
|
||||
/* abort the operation that has timed out */
|
||||
printf("\n");
|
||||
|
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id: aic6360.c,v 1.17 1995/12/15 00:53:51 bde Exp $
|
||||
* $Id: aic6360.c,v 1.18 1996/01/04 21:11:21 wollman Exp $
|
||||
*
|
||||
* Acknowledgements: Many of the algorithms used in this driver are
|
||||
* inspired by the work of Julian Elischer (julian@tfs.com) and
|
||||
@ -646,7 +646,7 @@ static void aic_done __P((struct acb *));
|
||||
static void aic_dataout __P((struct aic_data *aic));
|
||||
static void aic_datain __P((struct aic_data *aic));
|
||||
static int32 aic_scsi_cmd __P((struct scsi_xfer *));
|
||||
static int aic_poll __P((int, struct acb *));
|
||||
static int aic_poll __P((struct aic_data *aic, struct acb *));
|
||||
void aic_add_timeout __P((struct acb *, int));
|
||||
void aic_remove_timeout __P((struct acb *));
|
||||
static void aic6360_reset __P((struct aic_data *aic));
|
||||
@ -828,6 +828,7 @@ aicattach(dev)
|
||||
*/
|
||||
aic->sc_link.adapter_unit = unit;
|
||||
aic->sc_link.adapter_targ = AIC_SCSI_HOSTID;
|
||||
aic->sc_link.adapter_softc = aic;
|
||||
aic->sc_link.adapter = &aic_switch;
|
||||
aic->sc_link.device = &aic_dev;
|
||||
|
||||
@ -994,12 +995,12 @@ aic_scsi_cmd(xs)
|
||||
struct scsi_xfer *xs;
|
||||
{
|
||||
struct scsi_link *sc = xs->sc_link;
|
||||
int unit = sc->adapter_unit;
|
||||
struct aic_data *aic = aicdata[unit];
|
||||
struct aic_data *aic;
|
||||
struct acb *acb;
|
||||
int s = 0;
|
||||
int flags;
|
||||
|
||||
aic = (struct aic_data *)sc->adapter_softc;
|
||||
SC_DEBUG(sc, SDEV_DB2, ("aic_scsi_cmd\n"));
|
||||
AIC_TRACE(("aic_scsi_cmd\n"));
|
||||
AIC_MISC(("[0x%x, %d]->%d ", (int)xs->cmd->opcode, xs->cmdlen,
|
||||
@ -1054,7 +1055,7 @@ aic_scsi_cmd(xs)
|
||||
}
|
||||
|
||||
/* Not allowed to use interrupts, use polling instead */
|
||||
return aic_poll(unit, acb);
|
||||
return aic_poll(aic, acb);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1084,11 +1085,10 @@ aic_adapter_info(unit)
|
||||
* Used when interrupt driven I/O isn't allowed, e.g. during boot.
|
||||
*/
|
||||
static int
|
||||
aic_poll(unit, acb)
|
||||
int unit;
|
||||
aic_poll(aic, acb)
|
||||
struct aic_data *aic;
|
||||
struct acb *acb;
|
||||
{
|
||||
struct aic_data *aic = aicdata[unit];
|
||||
register u_short iobase = aic->iobase;
|
||||
struct scsi_xfer *xs = acb->xs;
|
||||
int count = xs->timeout * 10;
|
||||
@ -1096,7 +1096,7 @@ aic_poll(unit, acb)
|
||||
AIC_TRACE(("aic_poll\n"));
|
||||
while (count) {
|
||||
if (inb(DMASTAT) & INTSTAT)
|
||||
aicintr(unit);
|
||||
aicintr(xs->sc_link->adapter_unit);
|
||||
if (xs->flags & ITSDONE)
|
||||
break;
|
||||
DELAY(100);
|
||||
@ -1213,8 +1213,7 @@ aic_done(acb)
|
||||
{
|
||||
struct scsi_xfer *xs = acb->xs;
|
||||
struct scsi_link *sc = xs->sc_link;
|
||||
int unit = sc->adapter_unit;
|
||||
struct aic_data *aic = aicdata[unit];
|
||||
struct aic_data *aic = (struct aic_data *)sc->adapter_softc;
|
||||
|
||||
AIC_TRACE(("aic_done "));
|
||||
|
||||
@ -1306,7 +1305,8 @@ aic_done(acb)
|
||||
else if (acb->chain.tqe_next) {
|
||||
TAILQ_REMOVE(&aic->ready_list, acb, chain);
|
||||
} else {
|
||||
printf("aic%d: can't find matching acb\n", unit);
|
||||
printf("aic%d: can't find matching acb\n",
|
||||
xs->sc_link->adapter_unit);
|
||||
Debugger("aic6360");
|
||||
fatal_if_no_DDB();
|
||||
}
|
||||
|
@ -502,6 +502,7 @@ int nca_attach (struct isa_device *dev)
|
||||
/* fill in the prototype scsi_link */
|
||||
z->sc_link.adapter_unit = unit;
|
||||
z->sc_link.adapter_targ = z->scsi_addr;
|
||||
z->sc_link.adapter_softc = z;
|
||||
z->sc_link.adapter = &nca_switch;
|
||||
z->sc_link.device = &nca_dev;
|
||||
|
||||
@ -576,7 +577,7 @@ void nca_tick (void *arg)
|
||||
int32 nca_scsi_cmd (struct scsi_xfer *xs)
|
||||
{
|
||||
int unit = xs->sc_link->adapter_unit, flags = xs->flags, x = 0;
|
||||
adapter_t *z = &ncadata[unit];
|
||||
adapter_t *z = (adapter_t *)xs->sc_link->adapter_softc;
|
||||
scb_t *scb;
|
||||
|
||||
/* PRINT (("nca%d/%d/%d command 0x%x\n", unit, xs->sc_link->target,
|
||||
@ -714,7 +715,7 @@ void nca_timeout (void *arg)
|
||||
{
|
||||
scb_t *scb = (scb_t*) arg;
|
||||
int unit = scb->xfer->sc_link->adapter_unit;
|
||||
adapter_t *z = &ncadata[unit];
|
||||
adapter_t *z = (adapter_t *)scb->xfer->sc_link->adapter_softc;
|
||||
int x = splbio ();
|
||||
|
||||
if (! (scb->xfer->flags & SCSI_NOMASK))
|
||||
|
@ -60,7 +60,7 @@
|
||||
* that category, with the possible exception of scanners and
|
||||
* some of the older MO drives.
|
||||
*
|
||||
* $Id: seagate.c,v 1.14 1995/12/07 12:46:04 davidg Exp $
|
||||
* $Id: seagate.c,v 1.15 1995/12/10 13:39:10 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -559,6 +559,7 @@ int sea_attach (struct isa_device *dev)
|
||||
/* fill in the prototype scsi_link */
|
||||
z->sc_link.adapter_unit = unit;
|
||||
z->sc_link.adapter_targ = z->scsi_addr;
|
||||
z->sc_link.adapter_softc = z;
|
||||
z->sc_link.adapter = &sea_switch;
|
||||
z->sc_link.device = &sea_dev;
|
||||
|
||||
@ -626,8 +627,8 @@ void sea_tick (void *arg)
|
||||
*/
|
||||
int32 sea_scsi_cmd (struct scsi_xfer *xs)
|
||||
{
|
||||
int unit = xs->sc_link->adapter_unit, flags = xs->flags, x = 0;
|
||||
adapter_t *z = &seadata[unit];
|
||||
int flags = xs->flags, x = 0;
|
||||
adapter_t *z = (adapter_t *)xs->sc_link->adapter_softc;
|
||||
scb_t *scb;
|
||||
|
||||
PRINT (("sea%d/%d/%d command 0x%x\n", unit, xs->sc_link->target,
|
||||
@ -635,15 +636,16 @@ int32 sea_scsi_cmd (struct scsi_xfer *xs)
|
||||
if (xs->bp)
|
||||
flags |= SCSI_NOSLEEP;
|
||||
if (flags & ITSDONE) {
|
||||
printf ("sea%d: already done?", unit);
|
||||
printf ("sea%d: already done?", xs->sc_link->adapter_unit);
|
||||
xs->flags &= ~ITSDONE;
|
||||
}
|
||||
if (! (flags & INUSE)) {
|
||||
printf ("sea%d: not in use?", unit);
|
||||
printf ("sea%d: not in use?", xs->sc_link->adapter_unit);
|
||||
xs->flags |= INUSE;
|
||||
}
|
||||
if (flags & SCSI_RESET)
|
||||
printf ("sea%d: SCSI_RESET not implemented\n", unit);
|
||||
printf ("sea%d: SCSI_RESET not implemented\n",
|
||||
xs->sc_link->adapter_unit);
|
||||
|
||||
if (! (flags & SCSI_NOMASK))
|
||||
x = splbio ();
|
||||
@ -698,7 +700,8 @@ int32 sea_scsi_cmd (struct scsi_xfer *xs)
|
||||
return (SUCCESSFULLY_QUEUED);
|
||||
timeout (sea_timeout, (caddr_t) scb, (xs->timeout * hz) / 1000);
|
||||
scb->flags |= SCB_TIMECHK;
|
||||
PRINT (("sea%d/%d/%d command queued\n", unit,
|
||||
PRINT (("sea%d/%d/%d command queued\n",
|
||||
xs->sc_link->adapter_unit,
|
||||
xs->sc_link->target, xs->sc_link->lun));
|
||||
return (SUCCESSFULLY_QUEUED);
|
||||
}
|
||||
@ -719,7 +722,7 @@ int32 sea_scsi_cmd (struct scsi_xfer *xs)
|
||||
* this time there is no clock queue entry to remove. */
|
||||
sea_timeout ((void*) scb);
|
||||
}
|
||||
PRINT (("sea%d/%d/%d command %s\n", unit,
|
||||
PRINT (("sea%d/%d/%d command %s\n", xs->sc_link->adapter_unit,
|
||||
xs->sc_link->target, xs->sc_link->lun,
|
||||
xs->error ? "failed" : "done"));
|
||||
return (xs->error ? HAD_ERROR : COMPLETE);
|
||||
@ -764,12 +767,12 @@ again:
|
||||
void sea_timeout (void *arg)
|
||||
{
|
||||
scb_t *scb = (scb_t*) arg;
|
||||
int unit = scb->xfer->sc_link->adapter_unit;
|
||||
adapter_t *z = &seadata[unit];
|
||||
adapter_t *z = (adapter_t *)scb->xfer->sc_link->adapter_softc;
|
||||
int x = splbio ();
|
||||
|
||||
if (! (scb->xfer->flags & SCSI_NOMASK))
|
||||
printf ("sea%d/%d/%d (%s%d) timed out\n", unit,
|
||||
printf ("sea%d/%d/%d (%s%d) timed out\n",
|
||||
scb->xfer->sc_link->adapter_unit,
|
||||
scb->xfer->sc_link->target,
|
||||
scb->xfer->sc_link->lun,
|
||||
scb->xfer->sc_link->device->name,
|
||||
|
@ -22,7 +22,7 @@
|
||||
* today: Fri Jun 2 17:21:03 EST 1994
|
||||
* added 24F support ++sg
|
||||
*
|
||||
* $Id: ultra14f.c,v 1.42 1995/12/10 13:39:22 phk Exp $
|
||||
* $Id: ultra14f.c,v 1.43 1995/12/15 00:11:27 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -252,39 +252,43 @@ struct mscp {
|
||||
};
|
||||
|
||||
static struct uha_data {
|
||||
int flags;
|
||||
int flags;
|
||||
#define UHA_INIT 0x01
|
||||
#define UHA_24F 0x02
|
||||
int baseport;
|
||||
struct mscp *mscphash[MSCP_HASH_SIZE];
|
||||
struct mscp *free_mscp;
|
||||
int our_id; /* our scsi id */
|
||||
int vect;
|
||||
int dma;
|
||||
int nummscps;
|
||||
struct scsi_link sc_link;
|
||||
int baseport;
|
||||
struct mscp *mscphash[MSCP_HASH_SIZE];
|
||||
struct mscp *free_mscp;
|
||||
int unit;
|
||||
int our_id; /* our scsi id */
|
||||
int vect;
|
||||
int dma;
|
||||
int nummscps;
|
||||
struct scsi_link sc_link;
|
||||
struct uha_reg *ur;
|
||||
struct uha_bits *ub;
|
||||
} *uhadata[NUHA];
|
||||
|
||||
static int uha_abort __P((int unit, struct mscp *mscp));
|
||||
static int uha_abort __P((struct uha_data *uha, struct mscp *mscp));
|
||||
static u_int32 uha_adapter_info __P((int unit));
|
||||
static int uha_attach __P((struct isa_device *dev));
|
||||
static void uha_done __P((int unit, struct mscp *mscp));
|
||||
static void uha_free_mscp __P((int unit, struct mscp *mscp, int flags));
|
||||
static void uha_done __P((struct uha_data *uha, struct mscp *mscp));
|
||||
static void uha_free_mscp __P((struct uha_data *uha, struct mscp *mscp,
|
||||
int flags));
|
||||
static struct mscp *
|
||||
uha_get_mscp __P((int unit, int flags));
|
||||
static int uha_init __P((int unit));
|
||||
static int uha24_init __P((int unit));
|
||||
uha_get_mscp __P((struct uha_data *uha, int flags));
|
||||
static int uha_init __P((struct uha_data *uha));
|
||||
static int uha24_init __P((struct uha_data *uha));
|
||||
static void uhaminphys __P((struct buf *bp));
|
||||
static struct mscp *
|
||||
uha_mscp_phys_kv __P((struct uha_data *uha, long mscp_phys));
|
||||
static int uha_poll __P((int unit, int wait));
|
||||
static int uha_poll __P((struct uha_data *uha, int wait));
|
||||
#ifdef UHADEBUG
|
||||
static void uha_print_active_mscp __P((int unit));
|
||||
static void uha_print_active_mscp __P((struct uha_data *uha));
|
||||
static void uha_print_mscp __P((struct mscp *mscp));
|
||||
#endif
|
||||
static int uhaprobe __P((struct isa_device *dev));
|
||||
static int32 uha_scsi_cmd __P((struct scsi_xfer *xs));
|
||||
static void uha_send_mbox __P((int unit, struct mscp *mscp));
|
||||
static void uha_send_mbox __P((struct uha_data *uha, struct mscp *mscp));
|
||||
static timeout_t
|
||||
uha_timeout;
|
||||
|
||||
@ -367,13 +371,12 @@ main()
|
||||
* Function to send a command out through a mailbox
|
||||
*/
|
||||
static void
|
||||
uha_send_mbox(int unit, struct mscp *mscp)
|
||||
uha_send_mbox(struct uha_data *uha, struct mscp *mscp)
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
int port = uha->baseport;
|
||||
int spincount = 100000; /* 1s should be enough */
|
||||
struct uha_reg *ur = uhareg[unit];
|
||||
struct uha_bits *ub = uhabits[unit];
|
||||
struct uha_reg *ur = uha->ur;
|
||||
struct uha_bits *ub = uha->ub;
|
||||
int s = splbio();
|
||||
|
||||
while (--spincount) {
|
||||
@ -382,7 +385,8 @@ uha_send_mbox(int unit, struct mscp *mscp)
|
||||
DELAY(100);
|
||||
}
|
||||
if (spincount == 0) {
|
||||
printf("uha%d: uha_send_mbox, board not responding\n", unit);
|
||||
printf("uha%d: uha_send_mbox, board not responding\n",
|
||||
uha->unit);
|
||||
Debugger("ultra14f");
|
||||
}
|
||||
outl(ur->ogmptr, KVTOPHYS(mscp));
|
||||
@ -395,14 +399,13 @@ uha_send_mbox(int unit, struct mscp *mscp)
|
||||
* Function to send abort to 14f
|
||||
*/
|
||||
int
|
||||
uha_abort(int unit, struct mscp *mscp)
|
||||
uha_abort(struct uha_data *uha, struct mscp *mscp)
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
int port = uha->baseport;
|
||||
int spincount = 100; /* 1 mSec */
|
||||
int abortcount = 200000; /*2 secs */
|
||||
struct uha_reg *ur = uhareg[unit];
|
||||
struct uha_bits *ub = uhabits[unit];
|
||||
int port = uha->baseport;
|
||||
int spincount = 100; /* 1 mSec */
|
||||
int abortcount = 200000; /*2 secs */
|
||||
struct uha_reg *ur = uha->ur;
|
||||
struct uha_bits *ub = uha->ub;
|
||||
int s = splbio();
|
||||
|
||||
while (--spincount) {
|
||||
@ -411,7 +414,7 @@ uha_abort(int unit, struct mscp *mscp)
|
||||
DELAY(10);
|
||||
}
|
||||
if (spincount == 0) {
|
||||
printf("uha%d: uha_abort, board not responding\n", unit);
|
||||
printf("uha%d: uha_abort, board not responding\n", uha->unit);
|
||||
Debugger("ultra14f");
|
||||
}
|
||||
outl(ur->ogmptr,KVTOPHYS(mscp));
|
||||
@ -424,7 +427,7 @@ uha_abort(int unit, struct mscp *mscp)
|
||||
DELAY(10);
|
||||
}
|
||||
if (abortcount == 0) {
|
||||
printf("uha%d: uha_abort, board not responding\n", unit);
|
||||
printf("uha%d: uha_abort, board not responding\n", uha->unit);
|
||||
Debugger("ultra14f");
|
||||
}
|
||||
if ((inb(ur->sint) & 0x10) != 0) {
|
||||
@ -444,12 +447,11 @@ uha_abort(int unit, struct mscp *mscp)
|
||||
* wait = timeout in msec
|
||||
*/
|
||||
static int
|
||||
uha_poll(int unit, int wait)
|
||||
uha_poll(struct uha_data *uha, int wait)
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
int port = uha->baseport;
|
||||
struct uha_reg *ur = uhareg[unit];
|
||||
struct uha_bits *ub = uhabits[unit];
|
||||
struct uha_reg *ur = uha->ur;
|
||||
struct uha_bits *ub = uha->ub;
|
||||
int stport = ur->sint;
|
||||
|
||||
retry:
|
||||
@ -459,10 +461,10 @@ uha_poll(int unit, int wait)
|
||||
DELAY(1000); /* 1 mSec per loop */
|
||||
}
|
||||
if (wait == 0) {
|
||||
printf("uha%d: uha_poll, board not responding\n", unit);
|
||||
printf("uha%d: uha_poll, board not responding\n", uha->unit);
|
||||
return (EIO);
|
||||
}
|
||||
uhaintr(unit);
|
||||
uhaintr(uha->unit);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -477,8 +479,6 @@ uhaprobe(dev)
|
||||
{
|
||||
int unit = uha_unit;
|
||||
struct uha_data *uha;
|
||||
struct uha_reg *ur;
|
||||
struct uha_bits *ub;
|
||||
|
||||
dev->id_unit = unit; /* XXX */
|
||||
|
||||
@ -505,35 +505,34 @@ uhaprobe(dev)
|
||||
}
|
||||
bzero(uha, sizeof(struct uha_data));
|
||||
|
||||
ur = malloc(sizeof(struct uha_reg), M_TEMP, M_NOWAIT);
|
||||
if (!ur) {
|
||||
uha->ur = malloc(sizeof(struct uha_reg), M_TEMP, M_NOWAIT);
|
||||
if (!uha->ur) {
|
||||
printf("uha%d: cannot malloc!\n", unit);
|
||||
return 0;
|
||||
}
|
||||
bzero(ur, sizeof(struct uha_reg));
|
||||
bzero(uha->ur, sizeof(struct uha_reg));
|
||||
|
||||
ub = malloc(sizeof(struct uha_bits), M_TEMP, M_NOWAIT);
|
||||
if (!ub) {
|
||||
uha->ub = malloc(sizeof(struct uha_bits), M_TEMP, M_NOWAIT);
|
||||
if (!uha->ub) {
|
||||
printf("uha%d: cannot malloc!\n", unit);
|
||||
return 0;
|
||||
}
|
||||
bzero(ub, sizeof(struct uha_bits));
|
||||
bzero(uha->ub, sizeof(struct uha_bits));
|
||||
|
||||
uha_registerdev(dev);
|
||||
|
||||
uhareg[unit] = ur;
|
||||
uhabits[unit] = ub;
|
||||
uhadata[unit] = uha;
|
||||
uha->unit = unit;
|
||||
uha->baseport = dev->id_iobase;
|
||||
/*
|
||||
* Try initialise a unit at this location
|
||||
* sets up dma and bus speed, loads uha->vect
|
||||
*/
|
||||
if (uha_init(unit) != 0 && uha24_init(unit) != 0) {
|
||||
if (uha_init(uha) != 0 && uha24_init(uha) != 0) {
|
||||
uhadata[unit] = NULL;
|
||||
free(uha->ur, M_TEMP);
|
||||
free(uha->ub, M_TEMP);
|
||||
free(uha, M_TEMP);
|
||||
free(ur, M_TEMP);
|
||||
free(ub, M_TEMP);
|
||||
return (0);
|
||||
}
|
||||
/* if it's there put in its interrupt and DRQ vectors */
|
||||
@ -561,6 +560,7 @@ uha_attach(dev)
|
||||
*/
|
||||
uha->sc_link.adapter_unit = unit;
|
||||
uha->sc_link.adapter_targ = uha->our_id;
|
||||
uha->sc_link.adapter_softc = uha;
|
||||
uha->sc_link.adapter = &uha_switch;
|
||||
uha->sc_link.device = &uha_dev;
|
||||
uha->sc_link.flags = SDEV_BOUNCE;
|
||||
@ -605,10 +605,13 @@ uhaintr(unit)
|
||||
struct mscp *mscp;
|
||||
u_char uhastat;
|
||||
unsigned long int mboxval;
|
||||
struct uha_reg *ur = uhareg[unit];
|
||||
struct uha_bits *ub = uhabits[unit];
|
||||
struct uha_reg *ur;
|
||||
struct uha_bits *ub;
|
||||
int port;
|
||||
|
||||
int port = uha->baseport;
|
||||
ur = uha->ur;
|
||||
ub = uha->ub;
|
||||
port = uha->baseport;
|
||||
|
||||
#ifdef UHADEBUG
|
||||
printf("uhaintr ");
|
||||
@ -637,7 +640,7 @@ uhaintr(unit)
|
||||
}
|
||||
untimeout(uha_timeout, (caddr_t)mscp);
|
||||
|
||||
uha_done(unit, mscp);
|
||||
uha_done(uha, mscp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,11 +649,10 @@ uhaintr(unit)
|
||||
* how the operation went.
|
||||
*/
|
||||
void
|
||||
uha_done(unit, mscp)
|
||||
int unit;
|
||||
uha_done(uha, mscp)
|
||||
struct uha_data *uha;
|
||||
struct mscp *mscp;
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
struct scsi_sense_data *s1, *s2;
|
||||
struct scsi_xfer *xs = mscp->xs;
|
||||
|
||||
@ -682,7 +684,7 @@ uha_done(unit, mscp)
|
||||
default: /* Other scsi protocol messes */
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
printf("uha%d: unexpected ha_status 0x%x (target status 0x%x)\n",
|
||||
unit, mscp->ha_status,
|
||||
uha->unit, mscp->ha_status,
|
||||
mscp->targ_status);
|
||||
break;
|
||||
}
|
||||
@ -700,7 +702,7 @@ uha_done(unit, mscp)
|
||||
break;
|
||||
default:
|
||||
printf("uha%d: unexpected targ_status 0x%x\n",
|
||||
unit, mscp->targ_status);
|
||||
uha->unit, mscp->targ_status);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
break;
|
||||
}
|
||||
@ -713,7 +715,7 @@ uha_done(unit, mscp)
|
||||
}
|
||||
done:
|
||||
xs->flags |= ITSDONE;
|
||||
uha_free_mscp(unit, mscp, xs->flags);
|
||||
uha_free_mscp(uha, mscp, xs->flags);
|
||||
scsi_done(xs);
|
||||
}
|
||||
|
||||
@ -721,12 +723,11 @@ uha_done(unit, mscp)
|
||||
* A mscp (and hence a mbx-out) is put onto the free list.
|
||||
*/
|
||||
void
|
||||
uha_free_mscp(unit, mscp, flags)
|
||||
int unit;
|
||||
uha_free_mscp(uha, mscp, flags)
|
||||
struct uha_data *uha;
|
||||
struct mscp *mscp;
|
||||
int flags;
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
unsigned int opri = 0;
|
||||
|
||||
if (!(flags & SCSI_NOMASK))
|
||||
@ -753,10 +754,10 @@ uha_free_mscp(unit, mscp, flags)
|
||||
* hash table too otherwise either return an error or sleep.
|
||||
*/
|
||||
static struct mscp *
|
||||
uha_get_mscp(unit, flags)
|
||||
int unit, flags;
|
||||
uha_get_mscp(uha, flags)
|
||||
struct uha_data *uha;
|
||||
int flags;
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
unsigned opri = 0;
|
||||
struct mscp *mscpp;
|
||||
int hashnum;
|
||||
@ -784,7 +785,7 @@ uha_get_mscp(unit, flags)
|
||||
mscpp->nexthash = uha->mscphash[hashnum];
|
||||
uha->mscphash[hashnum] = mscpp;
|
||||
} else {
|
||||
printf("uha%d: Can't malloc MSCP\n", unit);
|
||||
printf("uha%d: Can't malloc MSCP\n", uha->unit);
|
||||
}
|
||||
goto gottit;
|
||||
} else {
|
||||
@ -829,10 +830,9 @@ uha_mscp_phys_kv(uha, mscp_phys)
|
||||
* Start the board, ready for normal operation
|
||||
*/
|
||||
int
|
||||
uha_init(unit)
|
||||
int unit;
|
||||
uha_init(uha)
|
||||
struct uha_data *uha;
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
unsigned char ad[4];
|
||||
volatile unsigned char model;
|
||||
volatile unsigned char submodel;
|
||||
@ -844,8 +844,8 @@ uha_init(unit)
|
||||
int port = uha->baseport;
|
||||
int i;
|
||||
int resetcount = 4000; /* 4 secs? */
|
||||
struct uha_reg *ur = uhareg[unit];
|
||||
struct uha_bits *ub = uhabits[unit];
|
||||
struct uha_reg *ur = uha->ur;
|
||||
struct uha_bits *ub = uha->ub;
|
||||
|
||||
/*
|
||||
* Prepare to use a 14/34F.
|
||||
@ -878,7 +878,7 @@ uha_init(unit)
|
||||
model = inb(ur->id);
|
||||
submodel = inb(ur->id + 1);
|
||||
if ((model != 0x56) & (submodel != 0x40)) return(ENXIO);
|
||||
printf("uha%d: reading board settings, ", unit);
|
||||
printf("uha%d: reading board settings, ", uha->unit);
|
||||
|
||||
config_reg1 = inb(ur->config);
|
||||
config_reg2 = inb(ur->config + 1);
|
||||
@ -939,7 +939,7 @@ uha_init(unit)
|
||||
DELAY(1000); /* 1 mSec per loop */
|
||||
}
|
||||
if (resetcount == 0) {
|
||||
printf("uha%d: board timed out during reset\n", unit);
|
||||
printf("uha%d: board timed out during reset\n", uha->unit);
|
||||
return (ENXIO);
|
||||
}
|
||||
outb(ur->smask, 0x81); /* make sure interrupts are enabled */
|
||||
@ -952,16 +952,15 @@ uha_init(unit)
|
||||
* Initialize an Ultrastor 24F
|
||||
*/
|
||||
int
|
||||
uha24_init(unit)
|
||||
int unit;
|
||||
uha24_init(uha)
|
||||
struct uha_data *uha;
|
||||
{
|
||||
unsigned char p0, p1, p2, p3, p5, p7;
|
||||
unsigned char id[7], rev, haid;
|
||||
int port = 0, irq, i;
|
||||
int resetcount = 4000;
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
struct uha_reg *ur = uhareg[unit];
|
||||
struct uha_bits *ub = uhabits[unit];
|
||||
struct uha_reg *ur = uha->ur;
|
||||
struct uha_bits *ub = uha->ub;
|
||||
|
||||
/* Search for the 24F's product ID */
|
||||
uha_slot++;
|
||||
@ -1037,12 +1036,12 @@ int unit;
|
||||
case 0x40: irq = 11; break;
|
||||
case 0x80: irq = 10; break;
|
||||
default:
|
||||
printf("uha%d: bad 24F irq\n", unit);
|
||||
printf("uha%d: bad 24F irq\n", uha->unit);
|
||||
return(ENXIO);
|
||||
}
|
||||
|
||||
haid = (p7 & 0x07);
|
||||
printf("uha%d: UltraStor 24F int=%d id=%d\n", unit, irq, haid);
|
||||
printf("uha%d: UltraStor 24F int=%d id=%d\n", uha->unit, irq, haid);
|
||||
|
||||
/* Issue SCSI and adapter reset */
|
||||
outb(ur->lint, ub->asrst);
|
||||
@ -1052,7 +1051,7 @@ int unit;
|
||||
DELAY(1000); /* 1 mSec per loop */
|
||||
}
|
||||
if (resetcount == 0) {
|
||||
printf("uha%d: board timed out during reset\n", unit);
|
||||
printf("uha%d: board timed out during reset\n", uha->unit);
|
||||
return (ENXIO);
|
||||
}
|
||||
outb(ur->smask, 0xc2); /* make sure interrupts are enabled */
|
||||
@ -1093,15 +1092,15 @@ uha_scsi_cmd(xs)
|
||||
int rc = 0;
|
||||
int thiskv;
|
||||
unsigned long int thisphys, nextphys;
|
||||
int unit = xs->sc_link->adapter_unit;
|
||||
int bytes_this_seg, bytes_this_page, datalen, flags;
|
||||
struct iovec *iovp;
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
struct iovec *iovp;
|
||||
struct uha_data *uha;
|
||||
int s;
|
||||
unsigned int stat;
|
||||
int port = uha->baseport;
|
||||
unsigned long int templen;
|
||||
|
||||
uha = (struct uha_data *)xs->sc_link->adapter_softc;
|
||||
SC_DEBUG(xs->sc_link, SDEV_DB2, ("uha_scsi_cmd\n"));
|
||||
/*
|
||||
* get a mscp (mbox-out) to use. If the transfer
|
||||
@ -1112,14 +1111,14 @@ uha_scsi_cmd(xs)
|
||||
if (xs->bp)
|
||||
flags |= (SCSI_NOSLEEP); /* just to be sure */
|
||||
if (flags & ITSDONE) {
|
||||
printf("uha%d: Already done?", unit);
|
||||
printf("uha%d: Already done?", uha->unit);
|
||||
xs->flags &= ~ITSDONE;
|
||||
}
|
||||
if (!(flags & INUSE)) {
|
||||
printf("uha%d: Not in use?", unit);
|
||||
printf("uha%d: Not in use?", uha->unit);
|
||||
xs->flags |= INUSE;
|
||||
}
|
||||
if (!(mscp = uha_get_mscp(unit, flags))) {
|
||||
if (!(mscp = uha_get_mscp(uha, flags))) {
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return (TRY_AGAIN_LATER);
|
||||
}
|
||||
@ -1146,7 +1145,7 @@ uha_scsi_cmd(xs)
|
||||
#ifdef GOTTABEJOKING
|
||||
if (xs->sc_link->lun != 0) {
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
uha_free_mscp(unit, mscp, flags);
|
||||
uha_free_mscp(uha, mscp, flags);
|
||||
return (HAD_ERROR);
|
||||
}
|
||||
#endif
|
||||
@ -1274,9 +1273,9 @@ uha_scsi_cmd(xs)
|
||||
SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n"));
|
||||
if (datalen) { /* there's still data, must have run out of segs! */
|
||||
printf("uha%d: uha_scsi_cmd, more than %d DMA segs\n",
|
||||
unit, UHA_NSEG);
|
||||
uha->unit, UHA_NSEG);
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
uha_free_mscp(unit, mscp, flags);
|
||||
uha_free_mscp(uha, mscp, flags);
|
||||
return (HAD_ERROR);
|
||||
}
|
||||
} else { /* No data xfer, use non S/G values */
|
||||
@ -1303,7 +1302,7 @@ uha_scsi_cmd(xs)
|
||||
*/
|
||||
if (!(flags & SCSI_NOMASK)) {
|
||||
s = splbio();
|
||||
uha_send_mbox(unit, mscp);
|
||||
uha_send_mbox(uha, mscp);
|
||||
timeout(uha_timeout, (caddr_t)mscp, (xs->timeout * hz) / 1000);
|
||||
splx(s);
|
||||
SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n"));
|
||||
@ -1313,15 +1312,16 @@ uha_scsi_cmd(xs)
|
||||
/*
|
||||
* If we can't use interrupts, poll on completion
|
||||
*/
|
||||
uha_send_mbox(unit, mscp);
|
||||
uha_send_mbox(uha, mscp);
|
||||
SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_wait\n"));
|
||||
do {
|
||||
if (uha_poll(unit, xs->timeout)) {
|
||||
if (uha_poll(uha, xs->timeout)) {
|
||||
if (!(xs->flags & SCSI_SILENT))
|
||||
printf("uha%d: cmd fail\n", unit);
|
||||
if (!(uha_abort(unit, mscp))) {
|
||||
printf("uha%d: abort failed in wait\n", unit);
|
||||
uha_free_mscp(unit, mscp, flags);
|
||||
printf("uha%d: cmd fail\n", uha->unit);
|
||||
if (!(uha_abort(uha, mscp))) {
|
||||
printf("uha%d: abort failed in wait\n",
|
||||
uha->unit);
|
||||
uha_free_mscp(uha, mscp, flags);
|
||||
}
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
return (HAD_ERROR);
|
||||
@ -1339,27 +1339,24 @@ uha_timeout(arg1)
|
||||
void *arg1;
|
||||
{
|
||||
struct mscp *mscp = (struct mscp *)arg1;
|
||||
int unit;
|
||||
struct uha_data *uha;
|
||||
int s = splbio();
|
||||
/*int port = uha->baseport; */
|
||||
|
||||
unit = mscp->xs->sc_link->adapter_unit;
|
||||
uha = uhadata[unit];
|
||||
printf("uha%d:%d:%d (%s%d) timed out ", unit
|
||||
uha = (struct uha_data *)mscp->xs->sc_link->adapter_softc;
|
||||
printf("uha%d:%d:%d (%s%d) timed out ", uha->unit
|
||||
,mscp->xs->sc_link->target
|
||||
,mscp->xs->sc_link->lun
|
||||
,mscp->xs->sc_link->device->name
|
||||
,mscp->xs->sc_link->dev_unit);
|
||||
|
||||
#ifdef UHADEBUG
|
||||
uha_print_active_mscp(unit);
|
||||
uha_print_active_mscp(uha);
|
||||
#endif /*UHADEBUG */
|
||||
|
||||
if ((uha_abort(unit, mscp) != 1) || (mscp->flags = MSCP_ABORTED)) {
|
||||
if ((uha_abort(uha, mscp) != 1) || (mscp->flags = MSCP_ABORTED)) {
|
||||
printf("AGAIN");
|
||||
mscp->xs->retries = 0; /* I MEAN IT ! */
|
||||
uha_done(unit, mscp);
|
||||
uha_done(uha, mscp);
|
||||
} else { /* abort the operation that has timed out */
|
||||
printf("\n");
|
||||
timeout(uha_timeout, (caddr_t)mscp, 2 * hz);
|
||||
@ -1389,9 +1386,8 @@ uha_print_mscp(mscp)
|
||||
}
|
||||
|
||||
void
|
||||
uha_print_active_mscp(int unit)
|
||||
uha_print_active_mscp(struct uha_data *uha)
|
||||
{
|
||||
struct uha_data *uha = uhadata[unit];
|
||||
struct mscp *mscp;
|
||||
int i = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user