summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>1998-09-15 10:39:50 +0000
committergibbs <gibbs@FreeBSD.org>1998-09-15 10:39:50 +0000
commit4035fc4bcc3a3a3a921bfaa090dd3f7f02b9737a (patch)
tree7b89d5b9dbbd21482716d8635071ba3150c84417
parent27097a06ffffe8c252c3869f24ae487bde5feaa7 (diff)
downloadFreeBSD-src-4035fc4bcc3a3a3a921bfaa090dd3f7f02b9737a.zip
FreeBSD-src-4035fc4bcc3a3a3a921bfaa090dd3f7f02b9737a.tar.gz
Obsolteted by CAM.
-rw-r--r--sys/i386/eisa/aha1742.c1317
-rw-r--r--sys/i386/eisa/aic7770.c502
-rw-r--r--sys/i386/eisa/bt74x.c370
3 files changed, 0 insertions, 2189 deletions
diff --git a/sys/i386/eisa/aha1742.c b/sys/i386/eisa/aha1742.c
deleted file mode 100644
index 1bd1a9d..0000000
--- a/sys/i386/eisa/aha1742.c
+++ /dev/null
@@ -1,1317 +0,0 @@
-/*
- * 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
- *
- * $Id: aha1742.c,v 1.63 1998/06/08 09:47:34 bde Exp $
- */
-
-#ifdef KERNEL /* don't laugh, it compiles as a program too.. look */
-#include "opt_ddb.h"
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-
-#include <scsi/scsiconf.h>
-#include <scsi/scsi_debug.h>
-
-#include <machine/clock.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <i386/eisa/eisaconf.h>
-#endif /*KERNEL */
-
-/* */
-
-#ifdef KERNEL
-# ifdef DDB
-#define fatal_if_no_DDB()
-# else
-#define fatal_if_no_DDB() panic("panic for historical reasons")
-# endif
-#endif
-
-typedef unsigned long int physaddr;
-
-#define KVTOPHYS(x) vtophys(x)
-
-#define AHB_ECB_MAX 32 /* store up to 32ECBs at any one time */
- /* in aha1742 H/W ( Not MAX ? ) */
-#define ECB_HASH_SIZE 32 /* when we have a physical addr. for */
- /* a ecb and need to find the ecb in */
- /* space, look it up in the hash table */
-#define ECB_HASH_SHIFT 9 /* only hash on multiples of 512 */
-#define ECB_HASH(x) ((((long int)(x))>>ECB_HASH_SHIFT) % ECB_HASH_SIZE)
-
-#define AHB_NSEG 33 /* number of dma segments supported */
-
-#define EISA_DEVICE_ID_ADAPTEC_1740 0x04900000
-#define AHB_EISA_IOSIZE 0x100
-#define AHB_EISA_SLOT_OFFSET 0xc00
-
-/* AHA1740 EISA board control registers (Offset from slot base) */
-#define EBCTRL 0x084
-#define CDEN 0x01
-/*
- * AHA1740 EISA board mode registers (Offset from slot base)
- */
-#define PORTADDR 0x0C0
-#define PORTADDR_ENHANCED 0x80
-#define BIOSADDR 0x0C1
-#define INTDEF 0x0C2
-#define SCSIDEF 0x0C3
-#define BUSDEF 0x0C4
-#define RESV0 0x0C5
-#define RESV1 0x0C6
-#define RESV2 0x0C7
-/**** bit definitions for INTDEF ****/
-#define INT9 0x00
-#define INT10 0x01
-#define INT11 0x02
-#define INT12 0x03
-#define INT14 0x05
-#define INT15 0x06
-#define INTHIGH 0x08 /* int high=ACTIVE (else edge) */
-#define INTEN 0x10
-/**** bit definitions for SCSIDEF ****/
-#define HSCSIID 0x0F /* our SCSI ID */
-#define RSTPWR 0x10 /* reset scsi bus on power up or reset */
-/**** bit definitions for BUSDEF ****/
-#define B0uS 0x00 /* give up bus immediatly */
-#define B4uS 0x01 /* delay 4uSec. */
-#define B8uS 0x02
-/*
- * AHA1740 ENHANCED mode mailbox control regs (Offset from slot base)
- */
-#define MBOXOUT0 0x0D0
-#define MBOXOUT1 0x0D1
-#define MBOXOUT2 0x0D2
-#define MBOXOUT3 0x0D3
-
-#define ATTN 0x0D4
-#define G2CNTRL 0x0D5
-#define G2INTST 0x0D6
-#define G2STAT 0x0D7
-
-#define MBOXIN0 0x0D8
-#define MBOXIN1 0x0D9
-#define MBOXIN2 0x0DA
-#define MBOXIN3 0x0DB
-
-#define G2STAT2 0x0DC
-
-/*
- * Bit definitions for the 5 control/status registers
- */
-#define ATTN_TARGET 0x0F
-#define ATTN_OPCODE 0xF0
-#define OP_IMMED 0x10
-#define AHB_TARG_RESET 0x80
-#define OP_START_ECB 0x40
-#define OP_ABORT_ECB 0x50
-
-#define G2CNTRL_SET_HOST_READY 0x20
-#define G2CNTRL_CLEAR_EISA_INT 0x40
-#define G2CNTRL_HARD_RESET 0x80
-
-#define G2INTST_TARGET 0x0F
-#define G2INTST_INT_STAT 0xF0
-#define AHB_ECB_OK 0x10
-#define AHB_ECB_RECOVERED 0x50
-#define AHB_HW_ERR 0x70
-#define AHB_IMMED_OK 0xA0
-#define AHB_ECB_ERR 0xC0
-#define AHB_ASN 0xD0 /* for target mode */
-#define AHB_IMMED_ERR 0xE0
-
-#define G2STAT_BUSY 0x01
-#define G2STAT_INT_PEND 0x02
-#define G2STAT_MBOX_EMPTY 0x04
-
-#define G2STAT2_HOST_READY 0x01
-
-struct ahb_dma_seg {
- physaddr addr;
- long len;
-};
-
-struct ahb_ecb_status {
- u_short status;
-#define ST_DON 0x0001
-#define ST_DU 0x0002
-#define ST_QF 0x0008
-#define ST_SC 0x0010
-#define ST_DO 0x0020
-#define ST_CH 0x0040
-#define ST_INT 0x0080
-#define ST_ASA 0x0100
-#define ST_SNS 0x0200
-#define ST_INI 0x0800
-#define ST_ME 0x1000
-#define ST_ECA 0x4000
- u_char ha_status;
-#define HS_OK 0x00
-#define HS_CMD_ABORTED_HOST 0x04
-#define HS_CMD_ABORTED_ADAPTER 0x05
-#define HS_TIMED_OUT 0x11
-#define HS_HARDWARE_ERR 0x20
-#define HS_SCSI_RESET_ADAPTER 0x22
-#define HS_SCSI_RESET_INCOMING 0x23
- u_char targ_status;
-#define TS_OK 0x00
-#define TS_CHECK_CONDITION 0x02
-#define TS_BUSY 0x08
- u_long resid_count;
- u_long resid_addr;
- u_short addit_status;
- u_char sense_len;
- u_char unused[9];
- u_char cdb[6];
-};
-
-
-struct ecb {
- u_char opcode;
-#define ECB_SCSI_OP 0x01
- u_int:4;
- u_int options:3;
- int:1;
- short opt1;
-#define ECB_CNE 0x0001
-#define ECB_DI 0x0080
-#define ECB_SES 0x0400
-#define ECB_S_G 0x1000
-#define ECB_DSB 0x4000
-#define ECB_ARS 0x8000
- short opt2;
-#define ECB_LUN 0x0007
-#define ECB_TAG 0x0008
-#define ECB_TT 0x0030
-#define ECB_ND 0x0040
-#define ECB_DAT 0x0100
-#define ECB_DIR 0x0200
-#define ECB_ST 0x0400
-#define ECB_CHK 0x0800
-#define ECB_REC 0x4000
-#define ECB_NRB 0x8000
- u_short unused1;
- physaddr data;
- u_long datalen;
- physaddr status;
- physaddr chain;
- short unused2;
- short unused3;
- physaddr sense;
- u_char senselen;
- u_char cdblen;
- short cksum;
- u_char cdb[12];
- /*-----------------end of hardware supported fields----------------*/
- struct ecb *next; /* in free list */
- struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
- int flags;
-#define ECB_FREE 0
-#define ECB_ACTIVE 1
-#define ECB_ABORTED 2
-#define ECB_IMMED 4
-#define ECB_IMMED_FAIL 8
- struct ahb_dma_seg ahb_dma[AHB_NSEG];
- struct ahb_ecb_status ecb_status;
- struct scsi_sense_data ecb_sense;
- struct ecb *nexthash;
- physaddr hashkey; /* physaddr of this struct */
-};
-
-struct ahb_data {
- int unit;
- int flags;
-#define AHB_INIT 0x01;
- int baseport;
- struct ecb *ecbhash[ECB_HASH_SIZE];
- struct ecb *free_ecb;
- int our_id; /* our scsi id */
- int vect;
- struct ecb *immed_ecb; /* an outstanding immediete command */
- struct scsi_link sc_link;
- int numecbs;
-};
-
-static u_int32_t ahb_adapter_info __P((int unit));
-static struct ahb_data *
- ahb_alloc __P((int unit, u_long iobase, int irq));
-static int ahb_attach __P((struct eisa_device *dev));
-static int ahb_bus_attach __P((struct ahb_data *ahb));
-static void ahb_done __P((struct ahb_data *ahb, struct ecb *ecb, int state));
-static void ahb_free __P((struct ahb_data *ahb));
-static void ahb_free_ecb __P((struct ahb_data* ahb, struct ecb *ecb,
- int flags));
-static struct ecb *
- ahb_get_ecb __P((struct ahb_data* ahb, int flags));
-static struct ecb *
- ahb_ecb_phys_kv __P((struct ahb_data *ahb, physaddr ecb_phys));
-static int ahb_init __P((struct ahb_data *ahb));
-static void ahbintr __P((void *arg));
-static const char *ahbmatch __P((eisa_id_t type));
-static void ahbminphys __P((struct buf *bp));
-static int ahb_poll __P((struct ahb_data *ahb, int wait));
-#ifdef AHBDEBUG
-static void ahb_print_active_ecb __P((struct ahb_data *ahb));
-static void ahb_print_ecb __P((struct ecb *ecb));
-#endif
-static int ahbprobe __P((void));
-static int ahb_reset __P((u_long port));
-static int32_t ahb_scsi_cmd __P((struct scsi_xfer *xs));
-static void ahb_send_immed __P((struct ahb_data *ahb, int target,
- u_long cmd));
-static void ahb_send_mbox __P((struct ahb_data *ahb, int opcode, int target,
- struct ecb *ecb));
-static timeout_t
- ahb_timeout;
-
-static struct ecb *cheat;
-
-static u_long ahb_unit = 0;
-static int ahb_debug = 0;
-SYSCTL_INT(_debug, OID_AUTO, ahb_debug, CTLFLAG_RW, &ahb_debug, 0, "");
-
-#define AHB_SHOWECBS 0x01
-#define AHB_SHOWINTS 0x02
-#define AHB_SHOWCMDS 0x04
-#define AHB_SHOWMISC 0x08
-#define FAIL 1
-#define SUCCESS 0
-#define PAGESIZ 4096
-
-#ifdef KERNEL
-static struct eisa_driver ahb_eisa_driver =
-{
- "ahb",
- ahbprobe,
- ahb_attach,
- /*shutdown*/NULL,
- &ahb_unit
-};
-
-DATA_SET (eisadriver_set, ahb_eisa_driver);
-
-static struct scsi_adapter ahb_switch =
-{
- ahb_scsi_cmd,
- ahbminphys,
- 0,
- 0,
- ahb_adapter_info,
- "ahb",
- { 0, 0 }
-};
-
-/* the below structure is so we have a default dev struct for our link struct */
-static struct scsi_device ahb_dev =
-{
- NULL, /* Use default error handler */
- NULL, /* have a queue, served by this */
- NULL, /* have no async handler */
- NULL, /* Use default 'done' routine */
- "ahb",
- 0,
- { 0, 0 }
-};
-
-#endif /*KERNEL */
-
-#ifndef KERNEL
-main()
-{
- printf("ahb_data size is %d\n", sizeof(struct ahb_data));
- printf("ecb size is %d\n", sizeof(struct ecb));
-}
-
-#else /*KERNEL */
-
-/*
- * Function to send a command out through a mailbox
- */
-static void
-ahb_send_mbox(struct ahb_data* ahb, int opcode, int target, struct ecb *ecb)
-{
- int port = ahb->baseport;
- int wait = 300; /* 3ms should be enough */
- int stport = port + G2STAT;
- int s = splbio();
-
- while (--wait) {
- if ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY))
- == (G2STAT_MBOX_EMPTY))
- break;
- DELAY(10);
- }
- if (wait == 0) {
- printf("ahb%d: board is not responding\n", ahb->unit);
- Debugger("aha1742");
- fatal_if_no_DDB();
- }
- outl(port + MBOXOUT0, KVTOPHYS(ecb)); /* don't know this will work */
- outb(port + ATTN, opcode | target);
-
- splx(s);
-}
-
-/*
- * Function to poll for command completion when in poll mode
- */
-static int
-ahb_poll(struct ahb_data *ahb, int wait)
-{ /* in msec */
- int port = ahb->baseport;
- int stport = port + G2STAT;
-
- retry:
- while (--wait) {
- if (inb(stport) & G2STAT_INT_PEND)
- break;
- DELAY(1000);
- } if (wait == 0) {
- printf("ahb%d: board is not responding\n", ahb->unit);
- return (EIO);
- }
- if (cheat != ahb_ecb_phys_kv(ahb, inl(port + MBOXIN0))) {
- printf("discarding 0x%x ", inl(port + MBOXIN0));
- outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT);
- DELAY(50000);
- goto retry;
- }
- /* don't know this will work */
- ahbintr((void *)ahb);
- return (0);
-}
-
-/*
- * Function to send an immediate type command to the adapter
- */
-static void
-ahb_send_immed(struct ahb_data *ahb, int target, u_long cmd)
-{
- int port = ahb->baseport;
- int s = splbio();
- int stport = port + G2STAT;
- int wait = 100; /* 1 ms enough? */
-
- while (--wait) {
- if ((inb(stport) & (G2STAT_BUSY | G2STAT_MBOX_EMPTY))
- == (G2STAT_MBOX_EMPTY))
- break;
- DELAY(10);
- } if (wait == 0) {
- printf("ahb%d: board is not responding\n", ahb->unit);
- Debugger("aha1742");
- fatal_if_no_DDB();
- }
- outl(port + MBOXOUT0, cmd); /* don't know this will work */
- outb(port + G2CNTRL, G2CNTRL_SET_HOST_READY);
- outb(port + ATTN, OP_IMMED | target);
- splx(s);
-}
-
-static const char *
-ahbmatch(type)
- eisa_id_t type;
-{
- switch(type & 0xfffffe00) {
- case EISA_DEVICE_ID_ADAPTEC_1740:
- return ("Adaptec 174x SCSI host adapter");
- break;
- default:
- break;
- }
- return (NULL);
-}
-
-int
-ahbprobe(void)
-{
- u_long iobase;
- char intdef;
- u_long irq;
- struct eisa_device *e_dev = NULL;
- int count;
-
- count = 0;
- while ((e_dev = eisa_match_dev(e_dev, ahbmatch))) {
- iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE) +
- AHB_EISA_SLOT_OFFSET;
-
- eisa_add_iospace(e_dev, iobase, AHB_EISA_IOSIZE, RESVADDR_NONE);
- intdef = inb(INTDEF + iobase);
- switch (intdef & 0x7) {
- case INT9:
- irq = 9;
- break;
- case INT10:
- irq = 10;
- break;
- case INT11:
- irq = 11;
- break;
- case INT12:
- irq = 12;
- break;
- case INT14:
- irq = 14;
- break;
- case INT15:
- irq = 15;
- break;
- default:
- printf("aha174X at slot %d: illegal "
- "irq setting %d\n", e_dev->ioconf.slot,
- (intdef & 0x7));
- continue;
- }
- eisa_add_intr(e_dev, irq);
- eisa_registerdev(e_dev, &ahb_eisa_driver);
- count++;
- }
- return count;
-}
-
-static struct ahb_data *
-ahb_alloc(unit, iobase, irq)
- int unit;
- u_long iobase;
- int irq;
-{
- struct ahb_data *ahb;
-
- /*
- * Allocate a storage area for us
- */
- ahb = malloc(sizeof(struct ahb_data), M_TEMP, M_NOWAIT);
- if (!ahb) {
- printf("ahb%d: cannot malloc!\n", unit);
- return NULL;
- }
- bzero(ahb, sizeof(struct ahb_data));
- ahb->unit = unit;
- ahb->baseport = iobase;
- ahb->vect = irq;
-
- return(ahb);
-}
-
-static void
-ahb_free(ahb)
- struct ahb_data *ahb;
-{
- free(ahb, M_DEVBUF);
- return;
-}
-
-/*
- * reset board, If it doesn't respond, return failure
- */
-static int
-ahb_reset(port)
- u_long port;
-{
- u_char i;
- int wait = 1000; /* 1 sec enough? */
- int stport = port + G2STAT;
-
- outb(port + EBCTRL, CDEN); /* enable full card */
- outb(port + PORTADDR, PORTADDR_ENHANCED);
-
- outb(port + G2CNTRL, G2CNTRL_HARD_RESET);
- DELAY(1000);
- outb(port + G2CNTRL, 0);
- DELAY(10000);
- while (--wait) {
- if ((inb(stport) & G2STAT_BUSY) == 0)
- break;
- DELAY(1000);
- } if (wait == 0) {
- printf("ahb_reset: No answer from aha1742 board\n");
- return (0);
- }
- i = inb(port + MBOXIN0) & 0xff;
- if (i) {
- printf("ahb_reset: self test failed, val = 0x%x\n", i);
- return (0);
- }
- while (inb(stport) & G2STAT_INT_PEND) {
- printf(".");
- outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT);
- DELAY(10000);
- }
- outb(port + EBCTRL, CDEN); /* enable full card */
- outb(port + PORTADDR, PORTADDR_ENHANCED);
- return (1);
-}
-
-/*
- * Attach ourselves and the devices on our bus
- */
-static int
-ahb_attach(e_dev)
- struct eisa_device *e_dev;
-{
- /*
- * find unit and check we have that many defined
- */
- int unit = e_dev->unit;
- struct ahb_data *ahb;
- resvaddr_t *iospace;
- int irq;
-
- if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL)
- return (-1);
-
- irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no;
-
- iospace = e_dev->ioconf.ioaddrs.lh_first;
-
- if(!iospace)
- return -1;
-
- if(!(ahb_reset(iospace->addr)))
- return -1;
-
- eisa_reg_start(e_dev);
- if(eisa_reg_iospace(e_dev, iospace)) {
- eisa_reg_end(e_dev);
- return -1;
- }
-
- if(!(ahb = ahb_alloc(unit, iospace->addr, irq))) {
- ahb_free(ahb);
- eisa_reg_end(e_dev);
- return -1;
- }
-
- if(eisa_reg_intr(e_dev, irq, ahbintr, (void *)ahb, &bio_imask,
- /*shared ==*/TRUE)) {
- ahb_free(ahb);
- eisa_reg_end(e_dev);
- return -1;
- }
- eisa_reg_end(e_dev);
-
- /*
- * Now that we know we own the resources we need, do the full
- * card initialization.
- */
- if(ahb_init(ahb)){
- ahb_free(ahb);
- /*
- * The board's IRQ line will not be left enabled
- * if we can't intialize correctly, so its safe
- * to release the irq.
- */
- eisa_release_intr(e_dev, irq, ahbintr);
- return -1;
- }
-
- /* Attach sub-devices - always succeeds */
- ahb_bus_attach(ahb);
-
- return(eisa_enable_intr(e_dev, irq));
-}
-
-
-/*
- * Attach all the sub-devices we can find
- */
-static int
-ahb_bus_attach(ahb)
- struct ahb_data *ahb;
-{
- struct scsibus_data *scbus;
-
- /*
- * fill in the prototype scsi_link.
- */
- ahb->sc_link.adapter_unit = ahb->unit;
- ahb->sc_link.adapter_targ = ahb->our_id;
- ahb->sc_link.adapter_softc = ahb;
- ahb->sc_link.adapter = &ahb_switch;
- ahb->sc_link.device = &ahb_dev;
-
- /*
- * Prepare the scsibus_data area for the upperlevel
- * scsi code.
- */
- scbus = scsi_alloc_bus();
- if(!scbus)
- return 0;
- scbus->adapter_link = &ahb->sc_link;
-
- /*
- * ask the adapter what subunits are present
- */
- scsi_attachdevs(scbus);
-
- return 1;
-}
-
-/*
- * Return some information to the caller about
- * the adapter and its capabilities
- */
-static u_int32_t
-ahb_adapter_info(unit)
- int unit;
-{
- return (2); /* 2 outstanding requests at a time per device */
-}
-
-/*
- * Catch an interrupt from the adaptor
- */
-static void
-ahbintr(arg)
- void *arg;
-{
- struct ahb_data *ahb;
- struct ecb *ecb;
- unsigned char stat;
- u_char ahbstat;
- int target;
- long int mboxval;
- int port;
-
- ahb = (struct ahb_data *)arg;
- port = ahb->baseport;
-
-#ifdef AHBDEBUG
- printf("ahbintr ");
-#endif /*AHBDEBUG */
-
- while (inb(port + G2STAT) & G2STAT_INT_PEND) {
- /*
- * First get all the information and then
- * acknowlege the interrupt
- */
- ahbstat = inb(port + G2INTST);
- target = ahbstat & G2INTST_TARGET;
- stat = ahbstat & G2INTST_INT_STAT;
- mboxval = inl(port + MBOXIN0); /* don't know this will work */
- outb(port + G2CNTRL, G2CNTRL_CLEAR_EISA_INT);
-#ifdef AHBDEBUG
- printf("status = 0x%x ", stat);
-#endif /*AHBDEBUG */
- /*
- * Process the completed operation
- */
-
- if (stat == AHB_ECB_OK) { /* common case is fast */
- ecb = ahb_ecb_phys_kv(ahb, mboxval);
- } else {
- switch (stat) {
- case AHB_IMMED_OK:
- ecb = ahb->immed_ecb;
- ahb->immed_ecb = 0;
- break;
- case AHB_IMMED_ERR:
- ecb = ahb->immed_ecb;
- ecb->flags |= ECB_IMMED_FAIL;
- ahb->immed_ecb = 0;
- break;
- case AHB_ASN: /* for target mode */
- printf("ahb%d: "
- "Unexpected ASN interrupt(0x%lx)\n",
- ahb->unit, mboxval);
- ecb = 0;
- break;
- case AHB_HW_ERR:
- printf("ahb%d: "
- "Hardware error interrupt(0x%lx)\n",
- ahb->unit, mboxval);
- ecb = 0;
- break;
- case AHB_ECB_RECOVERED:
- ecb = ahb_ecb_phys_kv(ahb, mboxval);
- break;
- case AHB_ECB_ERR:
- ecb = ahb_ecb_phys_kv(ahb, mboxval);
- break;
- default:
- printf(" Unknown return from ahb%d(%x)\n",
- ahb->unit, ahbstat);
- ecb = 0;
- }
- } if (ecb) {
-#ifdef AHBDEBUG
- if (ahb_debug & AHB_SHOWCMDS) {
- show_scsi_cmd(ecb->xs);
- }
- if ((ahb_debug & AHB_SHOWECBS) && ecb)
- printf("<int ecb(%x)>", ecb);
-#endif /*AHBDEBUG */
- untimeout(ahb_timeout, (caddr_t)ecb,
- ecb->xs->timeout_ch);
- ahb_done(ahb, ecb, ((stat == AHB_ECB_OK) ? SUCCESS : FAIL));
- }
- }
-}
-
-/*
- * We have a ecb which has been processed by the
- * adaptor, now we look to see how the operation
- * went.
- */
-static void
-ahb_done(ahb, ecb, state)
- struct ahb_data *ahb;
- int state;
- struct ecb *ecb;
-{
- struct ahb_ecb_status *stat = &ecb->ecb_status;
- struct scsi_sense_data *s1, *s2;
- struct scsi_xfer *xs = ecb->xs;
-
- SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahb_done\n"));
- /*
- * Otherwise, put the results of the operation
- * into the xfer and call whoever started it
- */
- if (ecb->flags & ECB_IMMED) {
- if (ecb->flags & ECB_IMMED_FAIL) {
- xs->error = XS_DRIVER_STUFFUP;
- }
- goto done;
- }
- if ((state == SUCCESS) || (xs->flags & SCSI_ERR_OK)) { /* All went correctly OR errors expected */
- xs->resid = 0;
- xs->error = 0;
- } else {
-
- s1 = &(ecb->ecb_sense);
- s2 = &(xs->sense);
-
- if (stat->ha_status) {
- switch (stat->ha_status) {
- case HS_SCSI_RESET_ADAPTER:
- break;
- case HS_SCSI_RESET_INCOMING:
- break;
- case HS_CMD_ABORTED_HOST: /* No response */
- case HS_CMD_ABORTED_ADAPTER: /* No response */
- break;
- case HS_TIMED_OUT: /* No response */
-#ifdef AHBDEBUG
- if (ahb_debug & AHB_SHOWMISC) {
- printf("timeout reported back\n");
- }
-#endif /*AHBDEBUG */
- xs->error = XS_TIMEOUT;
- break;
- default: /* Other scsi protocol messes */
- xs->error = XS_DRIVER_STUFFUP;
-#ifdef AHBDEBUG
- if (ahb_debug & AHB_SHOWMISC) {
- printf("unexpected ha_status: %x\n",
- stat->ha_status);
- }
-#endif /*AHBDEBUG */
- }
- } else {
- switch (stat->targ_status) {
- case TS_CHECK_CONDITION:
- /* structure copy!!!!! */
- *s2 = *s1;
- xs->error = XS_SENSE;
- break;
- case TS_BUSY:
- xs->error = XS_BUSY;
- break;
- default:
-#ifdef AHBDEBUG
- if (ahb_debug & AHB_SHOWMISC) {
- printf("unexpected targ_status: %x\n",
- stat->targ_status);
- }
-#endif /*AHBDEBUG */
- xs->error = XS_DRIVER_STUFFUP;
- }
- }
- }
-done: xs->flags |= ITSDONE;
- ahb_free_ecb(ahb, ecb, xs->flags);
- scsi_done(xs);
-}
-
-/*
- * A ecb (and hence a mbx-out is put onto the
- * free list.
- */
-static void
-ahb_free_ecb(ahb, ecb, flags)
- struct ahb_data *ahb;
- int flags;
- struct ecb *ecb;
-{
- unsigned int opri = 0;
-
- if (!(flags & SCSI_NOMASK))
- opri = splbio();
-
- ecb->next = ahb->free_ecb;
- ahb->free_ecb = ecb;
- ecb->flags = ECB_FREE;
- /*
- * If there were none, wake abybody waiting for
- * one to come free, starting with queued entries
- */
- if (!ecb->next) {
- wakeup((caddr_t)&ahb->free_ecb);
- }
- if (!(flags & SCSI_NOMASK))
- splx(opri);
-}
-
-/*
- * Get a free ecb
- * If there are none, see if we can allocate a
- * new one. If so, put it in the hash table too
- * otherwise either return an error or sleep
- */
-static struct ecb *
-ahb_get_ecb(ahb, flags)
- struct ahb_data *ahb;
- int flags;
-{
- unsigned opri = 0;
- struct ecb *ecbp;
- int hashnum;
-
- opri = splbio();
- /*
- * If we can and have to, sleep waiting for one to come free
- * but only if we can't allocate a new one.
- */
- while (!(ecbp = ahb->free_ecb)) {
- if (ahb->numecbs < AHB_ECB_MAX) {
- ecbp = (struct ecb *) malloc(sizeof(struct ecb),
- M_TEMP,
- M_NOWAIT);
- if (ecbp) {
- bzero(ecbp, sizeof(struct ecb));
- ahb->numecbs++;
- ecbp->flags = ECB_ACTIVE;
- /*
- * put in the phystokv hash table
- * Never gets taken out.
- */
- ecbp->hashkey = KVTOPHYS(ecbp);
- hashnum = ECB_HASH(ecbp->hashkey);
- ecbp->nexthash = ahb->ecbhash[hashnum];
- ahb->ecbhash[hashnum] = ecbp;
- } else {
- printf("ahb%d: Can't malloc ECB\n", ahb->unit);
- }
- break;
- } else {
- if (!(flags & SCSI_NOSLEEP)) {
- tsleep((caddr_t)&ahb->free_ecb, PRIBIO,
- "ahbecb", 0);
- continue;
- }
- break;
- }
- }
- if (ecbp) {
- /* Get ECB from from free list */
- ahb->free_ecb = ecbp->next;
- ecbp->flags = ECB_ACTIVE;
- }
-
- splx(opri);
-
- return (ecbp);
-}
-
-/*
- * given a physical address, find the ecb that
- * it corresponds to:
- */
-static struct ecb *
-ahb_ecb_phys_kv(ahb, ecb_phys)
- struct ahb_data *ahb;
- physaddr ecb_phys;
-{
- int hashnum = ECB_HASH(ecb_phys);
- struct ecb *ecbp = ahb->ecbhash[hashnum];
-
- while (ecbp) {
- if (ecbp->hashkey == ecb_phys)
- break;
- ecbp = ecbp->nexthash;
- }
- return ecbp;
-}
-
-/*
- * Start the board, ready for normal operation
- */
-static int
-ahb_init(ahb)
- struct ahb_data *ahb;
-{
- u_char intdef;
- int port = ahb->baseport;
-
- /*
- * Assume we have a board at this stage
- * setup dma channel from jumpers and save int
- * level
- */
- intdef = inb(port + INTDEF);
- outb(port + INTDEF, (intdef | INTEN)); /* make sure we can interrupt */
-
- /* who are we on the scsi bus? */
- ahb->our_id = (inb(port + SCSIDEF) & HSCSIID);
-
- /*
- * Note that we are going and return (to probe)
- */
- ahb->flags |= AHB_INIT;
- return (0);
-}
-
-#ifndef min
-#define min(x,y) (x < y ? x : y)
-#endif /* min */
-
-static void
-ahbminphys(bp)
- struct buf *bp;
-{
- if (bp->b_bcount > ((AHB_NSEG - 1) * PAGESIZ)) {
- bp->b_bcount = ((AHB_NSEG - 1) * PAGESIZ);
- }
-}
-
-/*
- * start a scsi operation given the command and
- * the data address. Also needs the unit, target
- * and lu
- */
-static int32_t
-ahb_scsi_cmd(xs)
- struct scsi_xfer *xs;
-{
- struct ecb *ecb;
- struct ahb_dma_seg *sg;
- int seg; /* scatter gather seg being worked on */
- int thiskv;
- physaddr thisphys, nextphys;
- int bytes_this_seg, bytes_this_page, datalen, flags;
- struct ahb_data *ahb;
- int s;
-
- ahb = (struct ahb_data *)xs->sc_link->adapter_softc;
- SC_DEBUG(xs->sc_link, SDEV_DB2, ("ahb_scsi_cmd\n"));
- /*
- * get a ecb (mbox-out) 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 (xs->bp)
- flags |= (SCSI_NOSLEEP); /* just to be sure */
- if (flags & ITSDONE) {
- printf("ahb%d: Already done?", ahb->unit);
- xs->flags &= ~ITSDONE;
- }
- if (!(flags & INUSE)) {
- printf("ahb%d: Not in use?", ahb->unit);
- xs->flags |= INUSE;
- }
- if (!(ecb = ahb_get_ecb(ahb, flags))) {
- xs->error = XS_DRIVER_STUFFUP;
- return (TRY_AGAIN_LATER);
- }
- cheat = ecb;
- SC_DEBUG(xs->sc_link, SDEV_DB3, ("start ecb(%p)\n", ecb));
- ecb->xs = xs;
- /*
- * If it's a reset, we need to do an 'immediate'
- * command, and store its ecb for later
- * if there is already an immediate waiting,
- * then WE must wait
- */
- if (flags & SCSI_RESET) {
- ecb->flags |= ECB_IMMED;
- if (ahb->immed_ecb) {
- return (TRY_AGAIN_LATER);
- }
- ahb->immed_ecb = ecb;
- if (!(flags & SCSI_NOMASK)) {
- s = splbio();
- ahb_send_immed(ahb, xs->sc_link->target, AHB_TARG_RESET);
- xs->timeout_ch = timeout(ahb_timeout, (caddr_t)ecb,
- (xs->timeout * hz) / 1000);
- splx(s);
- return (SUCCESSFULLY_QUEUED);
- } else {
- ahb_send_immed(ahb, xs->sc_link->target, AHB_TARG_RESET);
- /*
- * If we can't use interrupts, poll on completion
- */
- SC_DEBUG(xs->sc_link, SDEV_DB3, ("wait\n"));
- if (ahb_poll(ahb, xs->timeout)) {
- ahb_free_ecb(ahb, ecb, flags);
- xs->error = XS_TIMEOUT;
- return (HAD_ERROR);
- }
- return (COMPLETE);
- }
- }
- /*
- * Put all the arguments for the xfer in the ecb
- */
- ecb->opcode = ECB_SCSI_OP;
- ecb->opt1 = ECB_SES | ECB_DSB | ECB_ARS;
- if (xs->datalen) {
- ecb->opt1 |= ECB_S_G;
- }
- ecb->opt2 = xs->sc_link->lun | ECB_NRB;
- ecb->cdblen = xs->cmdlen;
- ecb->sense = KVTOPHYS(&(ecb->ecb_sense));
- ecb->senselen = sizeof(ecb->ecb_sense);
- ecb->status = KVTOPHYS(&(ecb->ecb_status));
-
- if (xs->datalen) { /* should use S/G only if not zero length */
- ecb->data = KVTOPHYS(ecb->ahb_dma);
- sg = ecb->ahb_dma;
- seg = 0;
-#ifdef TFS
- if (flags & SCSI_DATA_UIO) {
- iovp = ((struct uio *) xs->data)->uio_iov;
- datalen = ((struct uio *) xs->data)->uio_iovcnt;
- xs->datalen = 0;
- while ((datalen) && (seg < AHB_NSEG)) {
- sg->addr = (physaddr) iovp->iov_base;
- xs->datalen += sg->len = iovp->iov_len;
- SC_DEBUGN(xs->sc_link, SDEV_DB4,
- ("(0x%x@0x%x)", iovp->iov_len
- ,iovp->iov_base));
- sg++;
- iovp++;
- seg++;
- datalen--;
- }
- }
- else
-#endif /*TFS */
- {
- /*
- * Set up the scatter gather block
- */
-
- SC_DEBUG(xs->sc_link, SDEV_DB4,
- ("%ld @%p:- ", xs->datalen, xs->data));
- datalen = xs->datalen;
- thiskv = (int) xs->data;
- thisphys = KVTOPHYS(thiskv);
-
- while ((datalen) && (seg < AHB_NSEG)) {
- bytes_this_seg = 0;
-
- /* put in the base address */
- sg->addr = thisphys;
-
- SC_DEBUGN(xs->sc_link, SDEV_DB4, ("0x%lx",
- thisphys));
-
- /* do it at least once */
- nextphys = thisphys;
- while ((datalen) && (thisphys == nextphys)) {
- /*
- * This page is contiguous (physically) with
- * the the last, just extend the 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
- ,datalen);
- bytes_this_seg += bytes_this_page;
- datalen -= bytes_this_page;
-
- /* 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,
- ("(0x%x)", bytes_this_seg));
- sg->len = bytes_this_seg;
- sg++;
- seg++;
- }
- } /*end of iov/kv decision */
- ecb->datalen = seg * sizeof(struct ahb_dma_seg);
- SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n"));
- if (datalen) { /* there's still data, must have run out of segs! */
- printf("ahb_scsi_cmd%d: more than %d DMA segs\n",
- ahb->unit, AHB_NSEG);
- xs->error = XS_DRIVER_STUFFUP;
- ahb_free_ecb(ahb, ecb, flags);
- return (HAD_ERROR);
- }
- } else { /* No data xfer, use non S/G values */
- ecb->data = (physaddr) 0;
- ecb->datalen = 0;
- } ecb->chain = (physaddr) 0;
- /*
- * Put the scsi command in the ecb and start it
- */
- bcopy(xs->cmd, ecb->cdb, xs->cmdlen);
- /*
- * Usually return SUCCESSFULLY QUEUED
- */
- if (!(flags & SCSI_NOMASK)) {
- s = splbio();
- ahb_send_mbox(ahb, OP_START_ECB, xs->sc_link->target, ecb);
- xs->timeout_ch = timeout(ahb_timeout, (caddr_t)ecb,
- (xs->timeout * hz) / 1000);
- splx(s);
- SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_sent\n"));
- return (SUCCESSFULLY_QUEUED);
- }
- /*
- * If we can't use interrupts, poll on completion
- */
- ahb_send_mbox(ahb, OP_START_ECB, xs->sc_link->target, ecb);
- SC_DEBUG(xs->sc_link, SDEV_DB3, ("cmd_wait\n"));
- do {
- if (ahb_poll(ahb, xs->timeout)) {
- if (!(xs->flags & SCSI_SILENT))
- printf("cmd fail\n");
- ahb_send_mbox(ahb, OP_ABORT_ECB, xs->sc_link->target, ecb);
- if (ahb_poll(ahb, 2000)) {
- printf("abort failed in wait\n");
- ahb_free_ecb(ahb, ecb, flags);
- }
- xs->error = XS_DRIVER_STUFFUP;
- return (HAD_ERROR);
- }
- } while (!(xs->flags & ITSDONE)); /* something (?) else finished */
- if (xs->error) {
- return (HAD_ERROR);
- }
- return (COMPLETE);
-}
-
-static void
-ahb_timeout(void *arg1)
-{
- struct ecb * ecb = (struct ecb *)arg1;
- struct ahb_data *ahb;
- int s = splbio();
-
- ahb = ecb->xs->sc_link->adapter_softc;
- printf("ahb%d:%d:%d (%s%d) timed out ", ahb->unit
- ,ecb->xs->sc_link->target
- ,ecb->xs->sc_link->lun
- ,ecb->xs->sc_link->device->name
- ,ecb->xs->sc_link->dev_unit);
-
-#ifdef AHBDEBUG
- if (ahb_debug & AHB_SHOWECBS)
- ahb_print_active_ecb(ahb);
-#endif /*AHBDEBUG */
-
- /*
- * If it's immediate, don't try abort it
- */
- if (ecb->flags & ECB_IMMED) {
- ecb->xs->retries = 0; /* I MEAN IT ! */
- ecb->flags |= ECB_IMMED_FAIL;
- ahb_done(ahb, ecb, FAIL);
- splx(s);
- return;
- }
- /*
- * If it has been through before, then
- * a previous abort has failed, don't
- * try abort again
- */
- if (ecb->flags == ECB_ABORTED) {
- /*
- * abort timed out
- */
- printf("AGAIN");
- ecb->xs->retries = 0; /* I MEAN IT ! */
- ecb->ecb_status.ha_status = HS_CMD_ABORTED_HOST;
- ahb_done(ahb, ecb, FAIL);
- } else { /* abort the operation that has timed out */
- printf("\n");
- ahb_send_mbox(ahb, OP_ABORT_ECB, ecb->xs->sc_link->target, ecb);
- /* 2 secs for the abort */
- ecb->xs->timeout_ch = timeout(ahb_timeout,
- (caddr_t)ecb, 2 * hz);
- ecb->flags = ECB_ABORTED;
- }
- splx(s);
-}
-
-#ifdef AHBDEBUG
-static void
-ahb_print_ecb(ecb)
- struct ecb *ecb;
-{
- printf("ecb:%x op:%x cmdlen:%d senlen:%d\n"
- ,ecb
- ,ecb->opcode
- ,ecb->cdblen
- ,ecb->senselen);
- printf(" datlen:%d hstat:%x tstat:%x flags:%x\n"
- ,ecb->datalen
- ,ecb->ecb_status.ha_status
- ,ecb->ecb_status.targ_status
- ,ecb->flags);
- show_scsi_cmd(ecb->xs);
-}
-
-static void
-ahb_print_active_ecb(ahb)
- struct ahb_data *ahb;
-{
- struct ecb *ecb;
- int i = 0;
-
- while (i < ECB_HASH_SIZE) {
- ecb = ahb->ecbhash[i];
- while (ecb) {
- if (ecb->flags != ECB_FREE) {
- ahb_print_ecb(ecb);
- }
- ecb = ecb->nexthash;
- } i++;
- }
-}
-#endif /*AHBDEBUG */
-#endif /*KERNEL */
diff --git a/sys/i386/eisa/aic7770.c b/sys/i386/eisa/aic7770.c
deleted file mode 100644
index 8cdb8b8..0000000
--- a/sys/i386/eisa/aic7770.c
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Product specific probe and attach routines for:
- * 27/284X and aic7770 motherboard SCSI controllers
- *
- * Copyright (c) 1994, 1995, 1996 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. 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 AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id: aic7770.c,v 1.42 1997/09/21 21:35:22 gibbs Exp $
- */
-
-#if defined(__FreeBSD__)
-#include "eisa.h"
-#endif
-#if NEISA > 0 || defined(__NetBSD__)
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-
-#if defined(__NetBSD__)
-#include <sys/device.h>
-#include <machine/bus.h>
-#include <machine/intr.h>
-#endif /* defined(__NetBSD__) */
-
-#include <scsi/scsiconf.h>
-
-#if defined(__FreeBSD__)
-
-#include <i386/eisa/eisaconf.h>
-#include <i386/scsi/aic7xxx.h>
-
-#include "aic7xxx_reg.h"
-
-#define EISA_DEVICE_ID_ADAPTEC_AIC7770 0x04907770
-#define EISA_DEVICE_ID_ADAPTEC_274x 0x04907771
-#define EISA_DEVICE_ID_ADAPTEC_284xB 0x04907756 /* BIOS enabled */
-#define EISA_DEVICE_ID_ADAPTEC_284x 0x04907757 /* BIOS disabled*/
-
-#elif defined(__NetBSD__)
-
-#include <dev/eisa/eisareg.h>
-#include <dev/eisa/eisavar.h>
-#include <dev/eisa/eisadevs.h>
-
-#include <dev/ic/aic7xxxreg.h>
-#include <dev/ic/aic7xxxvar.h>
-
-#endif /* defined(__NetBSD__) */
-
-#define AHC_EISA_SLOT_OFFSET 0xc00
-#define AHC_EISA_IOSIZE 0x100
-#define INTDEF 0x5cul /* Interrupt Definition Register */
-
-#if defined(__FreeBSD__)
-
-static int aic7770probe __P((void));
-static int aic7770_attach __P((struct eisa_device *e_dev));
-
-static struct eisa_driver ahc_eisa_driver =
-{
- "ahc",
- aic7770probe,
- aic7770_attach,
- /*shutdown*/NULL,
- &ahc_unit
-};
-
-DATA_SET (eisadriver_set, ahc_eisa_driver);
-
-static const char *aic7770_match __P((eisa_id_t type));
-
-static const char*
-aic7770_match(type)
- eisa_id_t type;
-{
- switch (type) {
- case EISA_DEVICE_ID_ADAPTEC_AIC7770:
- return ("Adaptec aic7770 SCSI host adapter");
- break;
- case EISA_DEVICE_ID_ADAPTEC_274x:
- return ("Adaptec 274X SCSI host adapter");
- break;
- case EISA_DEVICE_ID_ADAPTEC_284xB:
- case EISA_DEVICE_ID_ADAPTEC_284x:
- return ("Adaptec 284X SCSI host adapter");
- break;
- default:
- break;
- }
- return (NULL);
-}
-
-static int
-aic7770probe(void)
-{
- u_int32_t iobase;
- u_int32_t irq;
- u_int8_t intdef;
- u_int8_t hcntrl;
- struct eisa_device *e_dev = NULL;
- int count;
-
- count = 0;
- while ((e_dev = eisa_match_dev(e_dev, aic7770_match))) {
- iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE)
- + AHC_EISA_SLOT_OFFSET;
-
- /* Pause the card preseving the IRQ type */
- hcntrl = inb(iobase + HCNTRL) & IRQMS;
-
- outb(iobase + HCNTRL, hcntrl | PAUSE);
-
- eisa_add_iospace(e_dev, iobase, AHC_EISA_IOSIZE, RESVADDR_NONE);
- intdef = inb(INTDEF + iobase);
- irq = intdef & 0xf;
- switch (irq) {
- case 9:
- case 10:
- case 11:
- case 12:
- case 14:
- case 15:
- break;
- default:
- printf("aic7770 at slot %d: illegal "
- "irq setting %d\n", e_dev->ioconf.slot,
- intdef);
- continue;
- }
- eisa_add_intr(e_dev, irq);
- eisa_registerdev(e_dev, &ahc_eisa_driver);
- count++;
- }
- return count;
-}
-
-#elif defined(__NetBSD__)
-
-#define bootverbose 1
-
-int ahc_eisa_match __P((struct device *, void *, void *));
-void ahc_eisa_attach __P((struct device *, struct device *, void *));
-
-
-struct cfattach ahc_eisa_ca =
-{
- sizeof(struct ahc_softc), ahc_eisa_match, ahc_eisa_attach
-};
-
-/*
- * Return irq setting of the board, otherwise -1.
- */
-int
-ahc_eisa_irq(bc, ioh)
- bus_chipset_tag_t bc;
- bus_io_handle_t ioh;
-{
- int irq;
- u_int8_t intdef;
-
- ahc_reset("ahc_eisa", bc, ioh);
- intdef = bus_io_read_1(bc, ioh, INTDEF);
- switch (irq = (intdef & 0xf)) {
- case 9:
- case 10:
- case 11:
- case 12:
- case 14:
- case 15:
- break;
- default:
- printf("ahc_eisa_irq: illegal irq setting %d\n", intdef);
- return -1;
- }
-
- /* Note that we are going and return (to probe) */
- return irq;
-}
-
-/*
- * Check the slots looking for a board we recognise
- * If we find one, note its address (slot) and call
- * the actual probe routine to check it out.
- */
-int
-ahc_eisa_match(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- struct eisa_attach_args *ea = aux;
- bus_chipset_tag_t bc = ea->ea_bc;
- bus_io_handle_t ioh;
- int irq;
-
- /* must match one of our known ID strings */
- if (strcmp(ea->ea_idstring, "ADP7770") &&
- strcmp(ea->ea_idstring, "ADP7771") &&
- strcmp(ea->ea_idstring, "ADP7756") && /* XXX - not EISA, but VL */
- strcmp(ea->ea_idstring, "ADP7757")) /* XXX - not EISA, but VL */
- return (0);
-
- if (bus_io_map(bc, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET,
- AHC_EISA_IOSIZE, &ioh))
- return (0);
-
- irq = ahc_eisa_irq(bc, ioh);
-
- bus_io_unmap(bc, ioh, AHC_EISA_IOSIZE);
-
- return (irq >= 0);
-}
-
-#endif /* defined(__NetBSD__) */
-
-#if defined(__FreeBSD__)
-static int
-aic7770_attach(e_dev)
- struct eisa_device *e_dev;
-#elif defined(__NetBSD__)
-void
-ahc_eisa_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-#endif
-{
- ahc_type type;
-
-#if defined(__FreeBSD__)
- struct ahc_softc *ahc;
- resvaddr_t *iospace;
- int unit = e_dev->unit;
- int irq;
-
- if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL)
- return -1;
-
- irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no;
-
- iospace = e_dev->ioconf.ioaddrs.lh_first;
-
- if (!iospace)
- return -1;
-
- switch (e_dev->id) {
- case EISA_DEVICE_ID_ADAPTEC_AIC7770:
- type = AHC_AIC7770;
- break;
- case EISA_DEVICE_ID_ADAPTEC_274x:
- type = AHC_274;
- break;
- case EISA_DEVICE_ID_ADAPTEC_284xB:
- case EISA_DEVICE_ID_ADAPTEC_284x:
- type = AHC_284;
- break;
- default:
- printf("aic7770_attach: Unknown device type!\n");
- return -1;
- break;
- }
-
- if (!(ahc = ahc_alloc(unit, iospace->addr, NULL,
- type, AHC_FNONE, NULL)))
- return -1;
-
- eisa_reg_start(e_dev);
- if (eisa_reg_iospace(e_dev, iospace)) {
- ahc_free(ahc);
- return -1;
- }
-
- ahc_reset(ahc);
-
- /*
- * The IRQMS bit enables level sensitive interrupts. Only allow
- * IRQ sharing if it's set.
- */
- if (eisa_reg_intr(e_dev, irq, ahc_intr, (void *)ahc, &bio_imask,
- /*shared ==*/ahc->pause & IRQMS)) {
- ahc_free(ahc);
- return -1;
- }
- eisa_reg_end(e_dev);
-
-#elif defined(__NetBSD__)
-
- struct ahc_softc *ahc = (void *)self;
- struct eisa_attach_args *ea = aux;
- bus_chipset_tag_t bc = ea->ea_bc;
- bus_io_handle_t ioh;
- int irq;
- eisa_chipset_tag_t ec = ea->ea_ec;
- eisa_intr_handle_t ih;
- const char *model, *intrstr;
-
- if (bus_io_map(bc, EISA_SLOT_ADDR(ea->ea_slot) + AHC_EISA_SLOT_OFFSET,
- AHC_EISA_IOSIZE, &ioh))
- panic("ahc_eisa_attach: could not map I/O addresses");
- if ((irq = ahc_eisa_irq(bc, ioh)) < 0)
- panic("ahc_eisa_attach: ahc_eisa_irq failed!");
-
- if (strcmp(ea->ea_idstring, "ADP7770") == 0) {
- model = EISA_PRODUCT_ADP7770;
- type = AHC_AIC7770;
- } else if (strcmp(ea->ea_idstring, "ADP7771") == 0) {
- model = EISA_PRODUCT_ADP7771;
- type = AHC_274;
- } else if (strcmp(ea->ea_idstring, "ADP7756") == 0) {
- model = EISA_PRODUCT_ADP7756;
- type = AHC_284;
- } else if (strcmp(ea->ea_idstring, "ADP7757") == 0) {
- model = EISA_PRODUCT_ADP7757;
- type = AHC_284;
- } else {
- panic("ahc_eisa_attach: Unknown device type %s\n",
- ea->ea_idstring);
- }
- printf(": %s\n", model);
-
- ahc_construct(ahc, bc, ioh, type, AHC_FNONE);
- if (eisa_intr_map(ec, irq, &ih)) {
- printf("%s: couldn't map interrupt (%d)\n",
- ahc->sc_dev.dv_xname, irq);
- return;
- }
-#endif /* defined(__NetBSD__) */
-
- /*
- * Tell the user what type of interrupts we're using.
- * usefull for debugging irq problems
- */
- if (bootverbose) {
- printf("%s: Using %s Interrupts\n",
- ahc_name(ahc),
- ahc->pause & IRQMS ?
- "Level Sensitive" : "Edge Triggered");
- }
-
- /*
- * Now that we know we own the resources we need, do the
- * card initialization.
- *
- * First, the aic7770 card specific setup.
- */
- switch (ahc->type) {
- case AHC_AIC7770:
- case AHC_274:
- {
- u_int8_t biosctrl = ahc_inb(ahc, HA_274_BIOSCTRL);
-
- /* Get the primary channel information */
- ahc->flags |= (biosctrl & CHANNEL_B_PRIMARY);
-
- if((biosctrl & BIOSMODE) == BIOSDISABLED)
- ahc->flags |= AHC_USEDEFAULTS;
- break;
- }
- case AHC_284:
- {
- /* XXX
- * All values are automagically intialized at
- * POST for these cards, so we can always rely
- * on the Scratch Ram values. However, we should
- * read the SEEPROM here (Dan has the code to do
- * it) so we can say what kind of translation the
- * BIOS is using. Printing out the geometry could
- * save a lot of users the grief of failed installs.
- */
- break;
- }
- default:
- break;
- }
-
- /*
- * See if we have a Rev E or higher aic7770. Anything below a
- * Rev E will have a R/O autoflush disable configuration bit.
- * The Rev E. cards have some changes to support Adaptec's SCB
- * paging scheme, but I don't know what that is yet.
- */
- {
- char *id_string;
- u_int8_t sblkctl;
- u_int8_t sblkctl_orig;
-
- sblkctl_orig = ahc_inb(ahc, SBLKCTL);
- sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
- ahc_outb(ahc, SBLKCTL, sblkctl);
- sblkctl = ahc_inb(ahc, SBLKCTL);
- if (sblkctl != sblkctl_orig) {
- id_string = "aic7770 >= Rev E, ";
- /*
- * Ensure autoflush is enabled
- */
- sblkctl &= ~AUTOFLUSHDIS;
- ahc_outb(ahc, SBLKCTL, sblkctl);
-
- } else
- id_string = "aic7770 <= Rev C, ";
-
- printf("%s: %s", ahc_name(ahc), id_string);
- }
-
- /* Setup the FIFO threshold and the bus off time */
- {
- u_int8_t hostconf = ahc_inb(ahc, HOSTCONF);
- ahc_outb(ahc, BUSSPD, hostconf & DFTHRSH);
- ahc_outb(ahc, BUSTIME, (hostconf << 2) & BOFF);
- }
-
- /*
- * Generic aic7xxx initialization.
- */
- if (ahc_init(ahc)) {
-#if defined(__FreeBSD__)
- ahc_free(ahc);
- /*
- * The board's IRQ line is not yet enabled so it's safe
- * to release the irq.
- */
- eisa_release_intr(e_dev, irq, ahc_intr);
- return -1;
-#elif defined(__NetBSD__)
- ahc_free(ahc);
- return;
-#endif
- }
-
- /*
- * Enable the board's BUS drivers
- */
- ahc_outb(ahc, BCTL, ENABLE);
-
-#if defined(__FreeBSD__)
- /*
- * Enable our interrupt handler.
- */
- if (eisa_enable_intr(e_dev, irq)) {
- ahc_free(ahc);
- eisa_release_intr(e_dev, irq, ahc_intr);
- return -1;
- }
-
-#elif defined(__NetBSD__)
- intrstr = eisa_intr_string(ec, ih);
- /*
- * The IRQMS bit enables level sensitive interrupts only allow
- * IRQ sharing if its set.
- */
- ahc->sc_ih = eisa_intr_establish(ec, ih,
- ahc->pause & IRQMS ? IST_LEVEL : IST_EDGE, IPL_BIO, ahc_intr, ahc
-#if defined(__OpenBSD__)
- , ahc->sc_dev.dv_xname
-#endif
- );
- if (ahc->sc_ih == NULL) {
- printf("%s: couldn't establish interrupt",
- ahc->sc_dev.dv_xname);
- if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
- ahc_free(ahc);
- return;
- }
- if (intrstr != NULL)
- printf("%s: interrupting at %s\n", ahc->sc_dev.dv_xname,
- intrstr);
-#endif /* defined(__NetBSD__) */
-
- /* Attach sub-devices - always succeeds */
- ahc_attach(ahc);
-
-#if defined(__FreeBSD__)
- return 0;
-#endif
-}
-
-#endif /* NEISA > 0 */
diff --git a/sys/i386/eisa/bt74x.c b/sys/i386/eisa/bt74x.c
deleted file mode 100644
index 20c7d81..0000000
--- a/sys/i386/eisa/bt74x.c
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Product specific probe and attach routines for:
- * Buslogic BT74x SCSI controllers
- *
- * Copyright (c) 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.
- *
- * $Id: bt74x.c,v 1.12 1997/09/21 21:35:22 gibbs Exp $
- */
-
-#include "eisa.h"
-#if NEISA > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <scsi/scsiconf.h>
-#include <i386/eisa/eisaconf.h>
-#include <i386/scsi/btreg.h>
-
-#define EISA_DEVICE_ID_BUSLOGIC_74X_B 0x0ab34201
-#define EISA_DEVICE_ID_BUSLOGIC_74X_C 0x0ab34202
-#define EISA_DEVICE_ID_AMI_4801 0x05a94801
-#define EISA_DEVICE_ID_BUS4781 0x0ab34781
-
-#define BT_IOSIZE 0x04 /* Move to central header */
-#define BT_EISA_IOSIZE 0x100
-#define BT_EISA_SLOT_OFFSET 0xc00
-
-#define EISA_IOCONF 0x08C
-#define PORTADDR 0x07
-#define PORT_330 0x00
-#define PORT_334 0x01
-#define PORT_230 0x02
-#define PORT_234 0x03
-#define PORT_130 0x04
-#define PORT_134 0x05
-#define IRQ_CHANNEL 0xe0
-#define INT_11 0x40
-#define INT_10 0x20
-#define INT_15 0xa0
-#define INT_12 0x60
-#define INT_14 0x80
-#define INT_9 0x00
-
-#define EISA_IRQ_TYPE 0x08D
-#define LEVEL 0x40
-
-/* Definitions for the AMI Series 48 controler */
-#define AMI_EISA_IOSIZE 0x500 /* Two separate ranges?? */
-#define AMI_EISA_SLOT_OFFSET 0x800
-#define AMI_EISA_IOCONF 0x000
-#define AMI_DMA_CHANNEL 0x03
-#define AMI_IRQ_CHANNEL 0x1c
-#define AMI_INT_15 0x14
-#define AMI_INT_14 0x10
-#define AMI_INT_12 0x0c
-#define AMI_INT_11 0x00
-#define AMI_INT_10 0x08
-#define AMI_INT_9 0x04
-#define AMI_BIOS_ADDR 0xe0
-
-#define AMI_EISA_IOCONF1 0x001
-#define AMI_PORTADDR 0x0e
-#define AMI_PORT_334 0x08
-#define AMI_PORT_330 0x00
-#define AMI_PORT_234 0x0c
-#define AMI_PORT_230 0x04
-#define AMI_PORT_134 0x0a
-#define AMI_PORT_130 0x02
-#define AMI_IRQ_LEVEL 0x01
-
-
-#define AMI_MISC2_OPTIONS 0x49E
-#define AMI_ENABLE_ISA_DMA 0x08
-
-static int bt_eisa_probe __P((void));
-static int bt_eisa_attach __P((struct eisa_device *e_dev));
-
-static struct eisa_driver bt_eisa_driver = {
- "bt",
- bt_eisa_probe,
- bt_eisa_attach,
- /*shutdown*/NULL,
- &bt_unit
- };
-
-DATA_SET (eisadriver_set, bt_eisa_driver);
-
-static const char *bt_match __P((eisa_id_t type));
-
-static const char*
-bt_match(type)
- eisa_id_t type;
-{
- switch(type) {
- case EISA_DEVICE_ID_BUSLOGIC_74X_B:
- return ("Buslogic 74xB SCSI host adapter");
- break;
- case EISA_DEVICE_ID_BUSLOGIC_74X_C:
- return ("Buslogic 74xC SCSI host adapter");
- break;
- case EISA_DEVICE_ID_AMI_4801:
- return ("AMI Series 48 SCSI host adapter");
- break;
- case EISA_DEVICE_ID_BUS4781:
- return ("Storage Dimensions SDC3222F SCSI host adapter");
- break;
- default:
- break;
- }
- return (NULL);
-}
-
-static int
-bt_eisa_probe(void)
-{
- u_long iobase;
- struct eisa_device *e_dev = NULL;
- int count;
-
- count = 0;
- while ((e_dev = eisa_match_dev(e_dev, bt_match))) {
- u_char ioconf;
- u_long port;
- int irq;
-
- iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE);
- if(e_dev->id == EISA_DEVICE_ID_AMI_4801) {
- u_char ioconf1;
- iobase += AMI_EISA_SLOT_OFFSET;
-
- eisa_add_iospace(e_dev, iobase, AMI_EISA_IOSIZE,
- RESVADDR_NONE);
-
- ioconf = inb(iobase + AMI_EISA_IOCONF);
- ioconf1 = inb(iobase + AMI_EISA_IOCONF1);
- /* Determine "ISA" I/O port */
- switch (ioconf1 & AMI_PORTADDR) {
- case AMI_PORT_330:
- port = 0x330;
- break;
- case AMI_PORT_334:
- port = 0x334;
- break;
- case AMI_PORT_230:
- port = 0x230;
- break;
- case AMI_PORT_234:
- port = 0x234;
- break;
- case AMI_PORT_134:
- port = 0x134;
- break;
- case AMI_PORT_130:
- port = 0x130;
- break;
- default:
- /* Disabled */
- printf("bt: AMI EISA Adapter at "
- "slot %d has a disabled I/O "
- "port. Cannot attach.\n",
- e_dev->ioconf.slot);
- continue;
- }
-
- eisa_add_iospace(e_dev, port, BT_IOSIZE, RESVADDR_NONE);
-
- /* Determine our IRQ */
- switch (ioconf & AMI_IRQ_CHANNEL) {
- case AMI_INT_11:
- irq = 11;
- break;
- case AMI_INT_10:
- irq = 10;
- break;
- case AMI_INT_15:
- irq = 15;
- break;
- case AMI_INT_12:
- irq = 12;
- break;
- case AMI_INT_14:
- irq = 14;
- break;
- case AMI_INT_9:
- irq = 9;
- break;
- default:
- /* Disabled */
- printf("bt: AMI EISA Adapter at "
- "slot %d has its IRQ disabled. "
- "Cannot attach.\n",
- e_dev->ioconf.slot);
- continue;
- }
- }
- else {
- iobase += BT_EISA_SLOT_OFFSET;
-
- eisa_add_iospace(e_dev, iobase, BT_EISA_IOSIZE,
- RESVADDR_NONE);
-
- ioconf = inb(iobase + EISA_IOCONF);
- /* Determine "ISA" I/O port */
- switch (ioconf & PORTADDR) {
- case PORT_330:
- port = 0x330;
- break;
- case PORT_334:
- port = 0x334;
- break;
- case PORT_230:
- port = 0x230;
- break;
- case PORT_234:
- port = 0x234;
- break;
- case PORT_130:
- port = 0x130;
- break;
- case PORT_134:
- port = 0x134;
- break;
- default:
- /* Disabled */
- printf("bt: Buslogic EISA Adapter at "
- "slot %d has a disabled I/O "
- "port. Cannot attach.\n",
- e_dev->ioconf.slot);
- continue;
- }
- eisa_add_iospace(e_dev, port, BT_IOSIZE, RESVADDR_NONE);
-
- /* Determine our IRQ */
- switch (ioconf & IRQ_CHANNEL) {
- case INT_11:
- irq = 11;
- break;
- case INT_10:
- irq = 10;
- break;
- case INT_15:
- irq = 15;
- break;
- case INT_12:
- irq = 12;
- break;
- case INT_14:
- irq = 14;
- break;
- case INT_9:
- irq = 9;
- break;
- default:
- /* Disabled */
- printf("bt: Buslogic EISA Adapter at "
- "slot %d has its IRQ disabled. "
- "Cannot attach.\n",
- e_dev->ioconf.slot);
- continue;
- }
-
- }
- eisa_add_intr(e_dev, irq);
-
- eisa_registerdev(e_dev, &bt_eisa_driver);
-
- count++;
- }
- return count;
-}
-
-static int
-bt_eisa_attach(e_dev)
- struct eisa_device *e_dev;
-{
- struct bt_data *bt;
- int unit = e_dev->unit;
- int irq;
- resvaddr_t *ioport;
- resvaddr_t *eisa_ioport;
- u_char level_intr;
-
- if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL)
- return (-1);
-
- irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no;
-
- /*
- * The addresses are sorted in increasing order
- * so we know the port to pass to the core bt
- * driver comes first.
- */
- ioport = e_dev->ioconf.ioaddrs.lh_first;
-
- if(!ioport)
- return -1;
-
- eisa_ioport = ioport->links.le_next;
-
- if(!eisa_ioport)
- return -1;
-
- if(e_dev->id == EISA_DEVICE_ID_AMI_4801)
- level_intr = inb(eisa_ioport->addr + AMI_EISA_IOCONF1)
- & AMI_IRQ_LEVEL;
- else
- level_intr = inb(eisa_ioport->addr + EISA_IRQ_TYPE)
- & LEVEL;
-
- eisa_reg_start(e_dev);
- if(eisa_reg_iospace(e_dev, ioport))
- return -1;
-
- if(eisa_reg_iospace(e_dev, eisa_ioport))
- return -1;
-
- if(!(bt = bt_alloc(unit, ioport->addr)))
- return -1;
-
- if(eisa_reg_intr(e_dev, irq, bt_intr, (void *)bt, &bio_imask,
- /*shared ==*/level_intr)) {
- bt_free(bt);
- return -1;
- }
- eisa_reg_end(e_dev);
-
- /*
- * Now that we know we own the resources we need, do the full
- * card initialization.
- */
- if(bt_init(bt)){
- bt_free(bt);
- /*
- * The board's IRQ line will not be left enabled
- * if we can't intialize correctly, so its safe
- * to release the irq.
- */
- eisa_release_intr(e_dev, irq, bt_intr);
- return -1;
- }
-
- /* Attach sub-devices - always succeeds */
- bt_attach(bt);
-
- if(eisa_enable_intr(e_dev, irq)) {
- bt_free(bt);
- eisa_release_intr(e_dev, irq, bt_intr);
- return -1;
- }
-
- return 0;
-}
-
-#endif /* NEISA > 0 */
OpenPOWER on IntegriCloud