1995-08-14 07:55:28 +04:00
|
|
|
/* $NetBSD: scsi96.c,v 1.13 1995/08/14 03:55:28 briggs Exp $ */
|
1994-10-26 11:45:48 +03:00
|
|
|
|
1994-06-26 17:00:32 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1994 Allen K. Briggs
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1994-07-21 05:33:29 +04:00
|
|
|
/*
|
|
|
|
* WARNING! This is a non-working driver at the moment!
|
|
|
|
* That means it does not work! Contact Allen Briggs
|
|
|
|
* (briggs@mail.vt.edu) for current status of this driver.
|
|
|
|
*/
|
|
|
|
|
1994-06-26 17:00:32 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/device.h>
|
1994-11-29 06:43:52 +03:00
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsi_debug.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
#include <machine/scsi96reg.h>
|
1994-07-21 05:33:29 +04:00
|
|
|
#include "../mac68k/via.h"
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
/* Support for the NCR 53C96 SCSI processor--primarily for '040 Macs. */
|
|
|
|
|
|
|
|
#ifdef DDB
|
1995-04-21 06:47:35 +04:00
|
|
|
int Debugger();
|
1994-06-26 17:00:32 +04:00
|
|
|
#else
|
|
|
|
#define Debugger() panic("Should call Debugger here (mac/dev/scsi96.c).")
|
|
|
|
#endif
|
|
|
|
|
1995-07-04 18:38:49 +04:00
|
|
|
extern vm_offset_t SCSIBase;
|
1995-04-21 06:47:35 +04:00
|
|
|
static volatile unsigned char *ncr53c96base =
|
|
|
|
(volatile unsigned char *) 0xF000; /* Offset from IOBase */
|
1994-07-08 15:38:48 +04:00
|
|
|
|
1995-07-04 18:38:49 +04:00
|
|
|
struct ncr53c96_softc {
|
1995-04-21 06:47:35 +04:00
|
|
|
struct device sc_dev;
|
1994-06-26 17:00:32 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void *reg_base;
|
|
|
|
int adapter_target;
|
|
|
|
struct scsi_link sc_link;
|
1995-07-04 18:38:49 +04:00
|
|
|
};
|
1994-07-08 15:38:48 +04:00
|
|
|
#define WAIT_FOR(reg, val) { \
|
|
|
|
int timeo=100000; \
|
|
|
|
while (!(reg & val)) { \
|
|
|
|
if (!(--timeo)) { \
|
|
|
|
printf("scsi96: WAIT_FOR timeout.\n"); \
|
|
|
|
goto have_error; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
1995-07-04 18:38:49 +04:00
|
|
|
static unsigned int ncr53c96_adapter_info(struct ncr53c96_softc * ncr53c96);
|
1995-08-13 00:30:45 +04:00
|
|
|
static void ncr53c96_minphys(struct buf * bp);
|
1995-04-21 06:47:35 +04:00
|
|
|
static int ncr53c96_scsi_cmd(struct scsi_xfer * xs);
|
1994-06-26 17:00:32 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static int ncr53c96_show_scsi_cmd(struct scsi_xfer * xs);
|
|
|
|
static int ncr53c96_reset_target(int adapter, int target);
|
|
|
|
static int ncr53c96_poll(int adapter, int timeout);
|
|
|
|
static int ncr53c96_send_cmd(struct scsi_xfer * xs);
|
1994-06-26 17:00:32 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
struct scsi_adapter ncr53c96_switch = {
|
|
|
|
ncr53c96_scsi_cmd, /* scsi_cmd() */
|
|
|
|
ncr53c96_minphys, /* scsi_minphys() */
|
|
|
|
0, /* open_target_lu() */
|
|
|
|
0, /* close_target_lu() */
|
1994-06-26 17:00:32 +04:00
|
|
|
};
|
|
|
|
/* This is copied from julian's bt driver */
|
|
|
|
/* "so we have a default dev struct for our link struct." */
|
|
|
|
struct scsi_device ncr53c96_dev = {
|
1995-04-21 06:47:35 +04:00
|
|
|
NULL, /* Use default error handler. */
|
|
|
|
NULL, /* have a queue, served by this (?) */
|
|
|
|
NULL, /* have no async handler. */
|
|
|
|
NULL, /* Use default "done" routine. */
|
1994-06-26 17:00:32 +04:00
|
|
|
};
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
extern int matchbyname();
|
|
|
|
static int ncr96probe();
|
|
|
|
static void ncr96attach();
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
struct cfdriver ncr96scsicd =
|
1995-04-21 06:47:35 +04:00
|
|
|
{NULL, "ncr96scsi", ncr96probe, ncr96attach,
|
1995-07-04 18:38:49 +04:00
|
|
|
DV_DULL, sizeof(struct ncr53c96_softc), NULL, 0};
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
ncr96_print(aux, name)
|
1995-04-21 06:47:35 +04:00
|
|
|
void *aux;
|
|
|
|
char *name;
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
/* printf("%s: (sc_link = 0x%x)", name, (int) aux); return UNCONF; */
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1995-07-04 18:38:49 +04:00
|
|
|
ncr96probe(parent, match, aux)
|
1995-04-21 06:47:35 +04:00
|
|
|
struct device *parent;
|
1995-07-04 18:38:49 +04:00
|
|
|
void *match;
|
|
|
|
void *aux;
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
static int probed = 0;
|
1995-07-04 18:38:49 +04:00
|
|
|
struct ncr53c96_softc *ncr53c96;
|
1994-06-26 17:00:32 +04:00
|
|
|
|
1995-08-14 07:55:28 +04:00
|
|
|
return 0;
|
1994-07-10 20:55:53 +04:00
|
|
|
if (!mac68k_machine.scsi96) {
|
1994-06-26 17:00:32 +04:00
|
|
|
return 0;
|
|
|
|
}
|
1995-07-04 18:38:49 +04:00
|
|
|
ncr53c96 = (struct ncr53c96_softc *) match;
|
|
|
|
|
|
|
|
if (strcmp(*((char **) aux), ncr53c96->sc_dev.dv_xname)) {
|
1994-06-26 17:00:32 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!probed) {
|
1994-07-08 15:38:48 +04:00
|
|
|
probed = 1;
|
1995-07-04 18:38:49 +04:00
|
|
|
ncr53c96base += SCSIBase;
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ncr96attach(parent, dev, aux)
|
1995-04-21 06:47:35 +04:00
|
|
|
struct device *parent, *dev;
|
|
|
|
void *aux;
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
int unit = dev->dv_unit;
|
1995-07-04 18:38:49 +04:00
|
|
|
struct ncr53c96_softc *ncr53c96;
|
1995-04-21 06:47:35 +04:00
|
|
|
int r;
|
1994-06-26 17:00:32 +04:00
|
|
|
|
1995-07-04 18:38:49 +04:00
|
|
|
ncr53c96 = (struct ncr53c96_softc *) dev;
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
ncr53c96->sc_link.scsibus = unit;
|
1995-01-15 09:27:54 +03:00
|
|
|
ncr53c96->sc_link.adapter_target = 7;
|
1994-06-26 17:00:32 +04:00
|
|
|
ncr53c96->sc_link.adapter = &ncr53c96_switch;
|
|
|
|
ncr53c96->sc_link.device = &ncr53c96_dev;
|
1995-07-04 18:38:49 +04:00
|
|
|
ncr53c96->sc_link.openings = 1;
|
|
|
|
#ifdef SCSIDEBUG
|
|
|
|
ncr53c96->sc_link.flags = SDEV_DB1 | SDEV_DB2 /* | SDEV_DB3 | SDEV_DB4 */ ;
|
|
|
|
#endif
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
config_found(dev, &(ncr53c96->sc_link), ncr96_print);
|
1994-07-21 05:33:29 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable IRQ and DRQ interrupts.
|
|
|
|
via_reg(VIA2, vIER) = (V2IF_IRQ | V2IF_SCSIDRQ | V2IF_SCSIIRQ);
|
|
|
|
*/
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
#define MIN_PHYS 65536 /* BARF!!!! */
|
1995-08-13 00:30:45 +04:00
|
|
|
static void
|
1995-04-21 06:47:35 +04:00
|
|
|
ncr53c96_minphys(struct buf * bp)
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
|
|
|
if (bp->b_bcount > MIN_PHYS) {
|
|
|
|
printf("Uh-oh... ncr53c96_minphys setting bp->b_bcount "
|
1995-04-21 06:47:35 +04:00
|
|
|
"= %x.\n", MIN_PHYS);
|
1994-06-26 17:00:32 +04:00
|
|
|
bp->b_bcount = MIN_PHYS;
|
|
|
|
}
|
1995-08-13 00:30:45 +04:00
|
|
|
minphys(bp);
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
#undef MIN_PHYS
|
|
|
|
|
|
|
|
static int
|
1995-04-21 06:47:35 +04:00
|
|
|
ncr53c96_scsi_cmd(struct scsi_xfer * xs)
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
int flags, s, r;
|
1994-06-26 17:00:32 +04:00
|
|
|
|
|
|
|
flags = xs->flags;
|
1995-04-21 06:47:35 +04:00
|
|
|
if (xs->bp)
|
|
|
|
flags |= (SCSI_NOSLEEP);
|
|
|
|
if (flags & ITSDONE) {
|
1994-06-26 17:00:32 +04:00
|
|
|
printf("Already done?");
|
|
|
|
xs->flags &= ~ITSDONE;
|
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
if (!(flags & INUSE)) {
|
1994-06-26 17:00:32 +04:00
|
|
|
printf("Not in use?");
|
|
|
|
xs->flags |= INUSE;
|
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
if (flags & SCSI_RESET) {
|
1994-06-26 17:00:32 +04:00
|
|
|
printf("flags & SCSIRESET.\n");
|
1995-04-21 06:47:35 +04:00
|
|
|
if (!(flags & SCSI_NOSLEEP)) {
|
1994-06-26 17:00:32 +04:00
|
|
|
s = splbio();
|
|
|
|
ncr53c96_reset_target(xs->sc_link->scsibus,
|
1995-04-21 06:47:35 +04:00
|
|
|
xs->sc_link->target);
|
1994-06-26 17:00:32 +04:00
|
|
|
splx(s);
|
1995-04-21 06:47:35 +04:00
|
|
|
return (SUCCESSFULLY_QUEUED);
|
1994-06-26 17:00:32 +04:00
|
|
|
} else {
|
|
|
|
ncr53c96_reset_target(xs->sc_link->scsibus,
|
1995-04-21 06:47:35 +04:00
|
|
|
xs->sc_link->target);
|
1994-06-26 17:00:32 +04:00
|
|
|
if (ncr53c96_poll(xs->sc_link->scsibus, xs->timeout)) {
|
1995-01-15 09:27:54 +03:00
|
|
|
return (COMPLETE);
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
return (COMPLETE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* OK. Now that that's over with, let's pack up that
|
|
|
|
* SCSI puppy and send it off. If we can, we'll just
|
|
|
|
* queue and go; otherwise, we'll wait for the command
|
|
|
|
* to finish.
|
|
|
|
if ( ! ( flags & SCSI_NOSLEEP ) ) {
|
|
|
|
s = splbio();
|
|
|
|
ncr53c96_send_cmd(xs);
|
|
|
|
splx(s);
|
|
|
|
return(SUCCESSFULLY_QUEUED);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
r = ncr53c96_send_cmd(xs);
|
|
|
|
xs->flags |= ITSDONE;
|
|
|
|
scsi_done(xs);
|
1995-04-21 06:47:35 +04:00
|
|
|
switch (r) {
|
|
|
|
case COMPLETE:
|
|
|
|
case SUCCESSFULLY_QUEUED:
|
|
|
|
r = SUCCESSFULLY_QUEUED;
|
|
|
|
if (xs->flags & SCSI_POLL)
|
|
|
|
r = COMPLETE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
/*
|
|
|
|
do {
|
|
|
|
if (ncr53c96_poll(xs->sc_link->scsibus, xs->timeout)) {
|
|
|
|
if ( ! ( xs->flags & SCSI_SILENT ) )
|
|
|
|
printf("cmd fail.\n");
|
|
|
|
cmd_cleanup
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
} while ( ! ( xs->flags & ITSDONE ) );
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1995-04-21 06:47:35 +04:00
|
|
|
ncr53c96_show_scsi_cmd(struct scsi_xfer * xs)
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
u_char *b = (u_char *) xs->cmd;
|
|
|
|
int i = 0;
|
1994-06-26 17:00:32 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
if (!(xs->flags & SCSI_RESET)) {
|
1994-06-26 17:00:32 +04:00
|
|
|
printf("ncr53c96(%d:%d:%d)-",
|
1995-04-21 06:47:35 +04:00
|
|
|
xs->sc_link->scsibus, xs->sc_link->target,
|
|
|
|
xs->sc_link->lun);
|
1994-06-26 17:00:32 +04:00
|
|
|
while (i < xs->cmdlen) {
|
1995-04-21 06:47:35 +04:00
|
|
|
if (i)
|
|
|
|
printf(",");
|
|
|
|
printf("%x", b[i++]);
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
printf("-\n");
|
|
|
|
} else {
|
|
|
|
printf("ncr53c96(%d:%d:%d)-RESET-\n",
|
1995-04-21 06:47:35 +04:00
|
|
|
xs->sc_link->scsibus, xs->sc_link->target,
|
|
|
|
xs->sc_link->lun);
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Actual chip control.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern void
|
|
|
|
ncr53c96_intr(int adapter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
|
|
|
ncr53c96_irq_intr(void)
|
|
|
|
{
|
1994-07-08 15:38:48 +04:00
|
|
|
printf("irq\n");
|
1994-06-26 17:00:32 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int
|
|
|
|
ncr53c96_drq_intr(void)
|
|
|
|
{
|
1994-07-08 15:38:48 +04:00
|
|
|
printf("drq\n");
|
1994-06-26 17:00:32 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ncr53c96_reset_target(int adapter, int target)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ncr53c96_poll(int adapter, int timeout)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1994-07-08 15:38:48 +04:00
|
|
|
static int
|
1995-04-21 06:47:35 +04:00
|
|
|
do_send_cmd(struct scsi_xfer * xs)
|
1994-07-08 15:38:48 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
struct ncr53c96regs *ncr = (struct ncr53c96regs *) ncr53c96base;
|
|
|
|
u_char *cmd;
|
|
|
|
int i, stat, is, intr;
|
|
|
|
int status, msg, phase;
|
1994-07-08 15:38:48 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
xs->resid = 0;
|
|
|
|
i = (int) ncr->statreg; /* clear interrupts */
|
1994-07-08 15:38:48 +04:00
|
|
|
ncr->cmdreg = NCR96_CMD_CLRFIFO; /* and fifo */
|
|
|
|
|
|
|
|
cmd = (u_char *) xs->cmd;
|
1995-04-21 06:47:35 +04:00
|
|
|
for (i = 0; i < xs->cmdlen; i++)
|
1994-07-08 15:38:48 +04:00
|
|
|
ncr->fifo = *cmd++;
|
|
|
|
ncr->tcreg_lsb = xs->cmdlen;
|
|
|
|
ncr->tcreg_msb = 0;
|
1995-04-21 06:47:35 +04:00
|
|
|
ncr->stimreg = 122; /* XXX */
|
1994-07-08 15:38:48 +04:00
|
|
|
ncr->sdidreg = xs->sc_link->target;
|
|
|
|
/* ncr->ctrlreg1 = 0x47; from the mac -- inherited*/
|
|
|
|
ncr->cmdreg = NCR96_CMD_SEL;
|
|
|
|
|
|
|
|
WAIT_FOR(ncr->statreg, NCR96_STAT_INT);
|
|
|
|
|
|
|
|
stat = ncr->statreg;
|
|
|
|
is = ncr->isreg;
|
|
|
|
intr = ncr->instreg;
|
1995-04-21 06:47:35 +04:00
|
|
|
if ((is & 0x07) != 0x4 || intr != 0x18) {
|
|
|
|
if ((is & 0x7) != 0x0 || intr != 0x20) {
|
1994-07-08 15:38:48 +04:00
|
|
|
printf("scsi96: stat = 0x%x, is = 0x%x, intr = 0x%x\n",
|
1995-04-21 06:47:35 +04:00
|
|
|
stat, is, intr);
|
1994-07-08 15:38:48 +04:00
|
|
|
}
|
|
|
|
goto have_error;
|
|
|
|
}
|
|
|
|
printf("scsi96: before loop: stat = 0x%x, is = 0x%x, intr = 0x%x, "
|
1995-04-21 06:47:35 +04:00
|
|
|
"datalen = %d\n", stat, is, intr, xs->datalen);
|
1994-07-08 15:38:48 +04:00
|
|
|
phase = ncr->statreg & NCR96_STAT_PHASE;
|
|
|
|
if (((phase == 0x01) || (phase == 0x00)) && xs->datalen) {
|
1995-04-21 06:47:35 +04:00
|
|
|
printf("data = 0x%x, datalen = 0x%x.\n", xs->data, xs->datalen);
|
1994-07-08 15:38:48 +04:00
|
|
|
stat = ncr->statreg;
|
1995-04-21 06:47:35 +04:00
|
|
|
is = ncr->isreg;
|
|
|
|
intr = ncr->instreg;
|
|
|
|
printf("entering info xfer...stat = 0x%x, is = 0x%x, intr = 0x%x\n",
|
|
|
|
stat, is, intr);
|
|
|
|
ncr->tcreg_lsb = (xs->datalen & 0xff);
|
|
|
|
ncr->tcreg_msb = (xs->datalen >> 8) & 0xff;
|
|
|
|
ncr->cmdreg = 0x80 | NCR96_CMD_INFOXFER;
|
|
|
|
printf("rem... %d.\n", ncr->tcreg_lsb | (ncr->tcreg_msb << 8));
|
|
|
|
i = 0;
|
|
|
|
while (i < xs->datalen) {
|
|
|
|
int d, stat;
|
1994-07-08 15:38:48 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
WAIT_FOR(ncr->statreg, NCR96_STAT_INT);
|
1994-07-08 15:38:48 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
stat = ncr->statreg;
|
1994-07-08 15:38:48 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
for (d = 1000000; d && !(via_reg(VIA2, vIFR) & 0x01); d--);
|
|
|
|
if (d <= 0)
|
|
|
|
printf("read timeout.\n");
|
|
|
|
d = ncr->fifostatereg & NCR96_CF_MASK;
|
|
|
|
|
|
|
|
while (d--) {
|
|
|
|
xs->data[i++] = ncr->fifo;
|
|
|
|
printf("0x%x,", xs->data[i - 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
intr = ncr->instreg;
|
|
|
|
printf("\nin loop. stat = 0x%x, intr = 0x%x, cnt = %d. ",
|
|
|
|
stat, intr, cnt);
|
|
|
|
printf("rem... %d.\n", ncr->tcreg_lsb | (ncr->tcreg_msb << 8));
|
|
|
|
}
|
1994-07-08 15:38:48 +04:00
|
|
|
/* } else {
|
|
|
|
WAIT_FOR(ncr->statreg, NCR96_STAT_INT); */
|
|
|
|
}
|
|
|
|
stat = ncr->statreg;
|
|
|
|
is = ncr->isreg;
|
|
|
|
intr = ncr->instreg;
|
|
|
|
printf("past loop...stat = 0x%x, is = 0x%x, intr = 0x%x\n",
|
1995-04-21 06:47:35 +04:00
|
|
|
stat, is, intr);
|
1994-07-08 15:38:48 +04:00
|
|
|
|
|
|
|
ncr->cmdreg = NCR96_CMD_ICCS;
|
|
|
|
|
|
|
|
WAIT_FOR(ncr->statreg, NCR96_STAT_INT);
|
|
|
|
|
|
|
|
stat = ncr->statreg;
|
|
|
|
is = ncr->isreg;
|
|
|
|
intr = ncr->instreg;
|
|
|
|
|
|
|
|
xs->status = ncr->fifo;
|
|
|
|
msg = ncr->fifo;
|
|
|
|
|
|
|
|
ncr->cmdreg = NCR96_CMD_MSGACC;
|
|
|
|
|
|
|
|
WAIT_FOR(ncr->statreg, NCR96_STAT_INT);
|
|
|
|
|
|
|
|
stat = ncr->statreg;
|
|
|
|
is = ncr->isreg;
|
|
|
|
intr = ncr->instreg;
|
|
|
|
if (intr == 0x20 && stat == 0x90)
|
|
|
|
return COMPLETE;
|
|
|
|
|
|
|
|
have_error:
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
1995-01-15 09:27:54 +03:00
|
|
|
return COMPLETE;
|
1994-07-08 15:38:48 +04:00
|
|
|
}
|
|
|
|
|
1994-06-26 17:00:32 +04:00
|
|
|
static int
|
1995-04-21 06:47:35 +04:00
|
|
|
ncr53c96_send_cmd(struct scsi_xfer * xs)
|
1994-06-26 17:00:32 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
int r = COMPLETE;
|
1994-07-08 15:38:48 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
if (xs->sc_link->target >= 5)
|
|
|
|
ncr53c96_show_scsi_cmd(xs);
|
1994-07-08 15:38:48 +04:00
|
|
|
switch (xs->cmd->opcode) {
|
1995-04-21 06:47:35 +04:00
|
|
|
case 0: /* TUN */
|
|
|
|
case 0x12: /* INQUIRY */
|
|
|
|
r = do_send_cmd(xs);
|
|
|
|
default:
|
|
|
|
xs->error = XS_DRIVER_STUFFUP;
|
|
|
|
r = COMPLETE;
|
1994-07-08 15:38:48 +04:00
|
|
|
}
|
|
|
|
return r;
|
1994-06-26 17:00:32 +04:00
|
|
|
}
|