diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-26 00:27:57 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-26 00:27:57 +0000 |
commit | 729a9d7ceffba9e7e741540048479eed9907601e (patch) | |
tree | 716f1614729ffc0b602e2fdfece3bc84b3e930b1 /sys/dev | |
parent | 8102ec86d426fccfffa292d80d3e50914c22a932 (diff) |
sync 0521
Diffstat (limited to 'sys/dev')
85 files changed, 4634 insertions, 2052 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c index 887b7ba0f21..32a1f3844b9 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,5 +1,5 @@ -/* $OpenBSD: audio.c,v 1.7 1996/04/21 22:19:38 deraadt Exp $ */ -/* $NetBSD: audio.c,v 1.24 1996/03/30 22:51:23 christos Exp $ */ +/* $OpenBSD: audio.c,v 1.8 1996/05/26 00:26:49 deraadt Exp $ */ +/* $NetBSD: audio.c,v 1.26 1996/05/13 02:26:15 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -79,8 +79,8 @@ #include <sys/kernel.h> #include <sys/signalvar.h> #include <sys/conf.h> - #include <sys/audioio.h> + #include <dev/audiovar.h> #include <dev/audio_if.h> diff --git a/sys/dev/eisa/aha1742.c b/sys/dev/eisa/aha1742.c index b91639a1969..52645cf86e6 100644 --- a/sys/dev/eisa/aha1742.c +++ b/sys/dev/eisa/aha1742.c @@ -1,5 +1,5 @@ -/* $OpenBSD: aha1742.c,v 1.8 1996/05/10 12:34:20 deraadt Exp $ */ -/* $NetBSD: aha1742.c,v 1.60 1996/05/05 03:12:47 mycroft Exp $ */ +/* $OpenBSD: aha1742.c,v 1.9 1996/05/26 00:26:52 deraadt Exp $ */ +/* $NetBSD: aha1742.c,v 1.61 1996/05/12 23:40:01 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -60,6 +60,7 @@ #include <sys/user.h> #include <machine/bus.h> +#include <machine/intr.h> #include <dev/eisa/eisareg.h> #include <dev/eisa/eisavar.h> diff --git a/sys/dev/eisa/ahc_eisa.c b/sys/dev/eisa/ahc_eisa.c new file mode 100644 index 00000000000..ef1fa58c7f1 --- /dev/null +++ b/sys/dev/eisa/ahc_eisa.c @@ -0,0 +1,527 @@ +/* $NetBSD: ahc_eisa.c,v 1.4 1996/05/20 00:55:44 thorpej Exp $ */ + +/* + * 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. + */ + +#if defined(__FreeBSD__) +#include <eisa.h> +#endif +#if NEISA > 0 || defined(__NetBSD__) + +#include <sys/param.h> +#include <sys/systm.h> +#if defined(__FreeBSD__) +#include <sys/devconf.h> +#endif +#include <sys/kernel.h> + +#if defined(__NetBSD__) +#include <sys/device.h> +#include <machine/bus.h> +#include <machine/intr.h> +#endif /* defined(__NetBSD__) */ + +#include <scsi/scsi_all.h> +#include <scsi/scsiconf.h> + +#if defined(__FreeBSD__) + +#include <machine/clock.h> + +#include <i386/eisa/eisaconf.h> +#include <i386/scsi/aic7xxx.h> +#include <dev/aic7xxx/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 struct kern_devconf kdc_aic7770 = { + 0, 0, 0, /* filled in by dev_attach */ + "ahc", 0, { MDDT_EISA, 0, "bio" }, + eisa_generic_externalize, 0, 0, EISA_EXTERNALLEN, + &kdc_eisa0, /* parent */ + 0, /* parentdata */ + DC_UNCONFIGURED, /* always start out here */ + NULL, + DC_CLS_MISC /* host adapters aren't special */ +}; + + +static char *aic7770_match __P((eisa_id_t type)); + +static 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_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, aic7770_match))) { + iobase = (e_dev->ioconf.slot * EISA_SLOT_SIZE) + + AHC_EISA_SLOT_OFFSET; + ahc_reset(iobase); + + eisa_add_iospace(e_dev, iobase, AHC_EISA_IOSIZE, RESVADDR_NONE); + intdef = inb(INTDEF + iobase); + switch (intdef & 0xf) { + case 9: + irq = 9; + break; + case 10: + irq = 10; + break; + case 11: + irq = 11; + break; + case 12: + irq = 12; + break; + case 14: + irq = 14; + break; + case 15: + irq = 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, &kdc_aic7770); + if(e_dev->id == EISA_DEVICE_ID_ADAPTEC_284xB + || e_dev->id == EISA_DEVICE_ID_ADAPTEC_284x) { + /* Our real parent is the isa bus. Say so. */ + e_dev->kdc->kdc_parent = &kdc_isa0; + } + 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_data), 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_char 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 it's 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_data *ahc; + resvaddr_t *iospace; + int unit = e_dev->unit; + int irq = ffs(e_dev->ioconf.irq) - 1; + + 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, type, AHC_FNONE))) + return -1; + + eisa_reg_start(e_dev); + if(eisa_reg_iospace(e_dev, iospace)) { + ahc_free(ahc); + return -1; + } + + /* + * 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_data *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_char 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. + * It's still not clear exactly what is differenent about the Rev E. + * We think it allows 8 bit entries in the QOUTFIFO to support + * "paging" SCBs so you can have more than 4 commands active at + * once. + */ + { + char *id_string; + u_char sblkctl; + u_char 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); + + /* Allow paging on this adapter */ + ahc->flags |= AHC_PAGESCBS; + } + else + id_string = "aic7770 <= Rev C, "; + + printf("%s: %s", ahc_name(ahc), id_string); + } + + /* Setup the FIFO threshold and the bus off time */ + { + u_char 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; + } + + e_dev->kdc->kdc_state = DC_BUSY; /* host adapters always busy */ +#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 +#ifdef __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/dev/eisa/eisadevs b/sys/dev/eisa/eisadevs index 53e68b6844e..7fb1022bcc4 100644 --- a/sys/dev/eisa/eisadevs +++ b/sys/dev/eisa/eisadevs @@ -1,4 +1,4 @@ -$OpenBSD: eisadevs,v 1.3 1996/05/02 13:29:11 deraadt Exp $ +$OpenBSD: eisadevs,v 1.4 1996/05/26 00:26:53 deraadt Exp $ /* $NetBSD: eisadevs,v 1.1 1996/02/26 23:46:22 cgd Exp $ */ /* @@ -41,6 +41,7 @@ vendor AMI AMI vendor BUS BusLogic vendor DEC Digital Equipment vendor TCM 3Com +vendor USC UltraStor /* * List of known products, grouped by vendor. @@ -65,9 +66,15 @@ product BUS 4202 Bt74xC SCSI /* Digital Equipment products */ product DEC 4250 DE425 Ethernet -/* ??? DEC DEFEA */ +product DEC 3001 DEFEA FDDI Controller +product DEC 3002 DEFEA FDDI Controller +product DEC 3003 DEFEA FDDI Controller +product DEC 3004 DEFEA FDDI Controller /* 3Com products */ product TCM 5091 3C509 Ethernet product TCM 5092 3C579-TP Ethernet product TCM 5093 3C579 Ethernet + +/* UltraStor products */ +product USC 0240 24f SCSI diff --git a/sys/dev/eisa/eisadevs.h b/sys/dev/eisa/eisadevs.h index 70d524cc035..6ea9ce252f2 100644 --- a/sys/dev/eisa/eisadevs.h +++ b/sys/dev/eisa/eisadevs.h @@ -60,9 +60,15 @@ /* Digital Equipment products */ #define EISA_PRODUCT_DEC4250 "Digital Equipment DE425 Ethernet" -/* ??? DEC DEFEA */ +#define EISA_PRODUCT_DEC3001 "Digital Equipment DEFEA FDDI Controller" +#define EISA_PRODUCT_DEC3002 "Digital Equipment DEFEA FDDI Controller" +#define EISA_PRODUCT_DEC3003 "Digital Equipment DEFEA FDDI Controller" +#define EISA_PRODUCT_DEC3004 "Digital Equipment DEFEA FDDI Controller" /* 3Com products */ #define EISA_PRODUCT_TCM5091 "3Com 3C509 Ethernet" #define EISA_PRODUCT_TCM5092 "3Com 3C579-TP Ethernet" #define EISA_PRODUCT_TCM5093 "3Com 3C579 Ethernet" + +/* UltraStor products */ +#define EISA_PRODUCT_USC0240 "UltraStor 24f SCSI" diff --git a/sys/dev/eisa/eisadevs_data.h b/sys/dev/eisa/eisadevs_data.h index 872a55abe6e..0d0e8cd717f 100644 --- a/sys/dev/eisa/eisadevs_data.h +++ b/sys/dev/eisa/eisadevs_data.h @@ -100,6 +100,26 @@ struct eisa_knowndev eisa_knowndevs[] = { }, { 0, + "DEC3001", + EISA_PRODUCT_DEC3001, + }, + { + 0, + "DEC3002", + EISA_PRODUCT_DEC3002, + }, + { + 0, + "DEC3003", + EISA_PRODUCT_DEC3003, + }, + { + 0, + "DEC3004", + EISA_PRODUCT_DEC3004, + }, + { + 0, "TCM5091", EISA_PRODUCT_TCM5091, }, @@ -114,6 +134,11 @@ struct eisa_knowndev eisa_knowndevs[] = { EISA_PRODUCT_TCM5093, }, { + 0, + "USC0240", + EISA_PRODUCT_USC0240, + }, + { EISA_KNOWNDEV_NOPROD, "ADP", "Adaptec", @@ -138,5 +163,10 @@ struct eisa_knowndev eisa_knowndevs[] = { "TCM", "3Com", }, + { + EISA_KNOWNDEV_NOPROD, + "USC", + "UltraStor", + }, { 0, NULL, NULL, } }; diff --git a/sys/dev/eisa/files.eisa b/sys/dev/eisa/files.eisa index 99921ff0377..016affc357f 100644 --- a/sys/dev/eisa/files.eisa +++ b/sys/dev/eisa/files.eisa @@ -1,5 +1,5 @@ -# $OpenBSD: files.eisa,v 1.5 1996/05/05 12:42:25 deraadt Exp $ -# $NetBSD: files.eisa,v 1.8 1996/04/25 02:16:39 thorpej Exp $ +# $OpenBSD: files.eisa,v 1.6 1996/05/26 00:26:54 deraadt Exp $ +# $NetBSD: files.eisa,v 1.10 1996/05/20 00:44:11 thorpej Exp $ # # Config.new file and device description for machine-independent EISA code. # Included by ports that need it. Requires that the SCSI files be @@ -15,11 +15,16 @@ attach ahb at eisa file dev/eisa/aha1742.c ahb # Adaptec AHA-27/284X and aic7770 motherboard SCSI controllers -device ahe: scsi, aic7xxx -attach ahe at eisa -file dev/eisa/aic7770.c ahe +# device declaration in sys/conf/files +attach ahc at eisa with ahc_eisa +file dev/eisa/ahc_eisa.c ahc_eisa # 3Com 3c579 and 3c509 masquerading as EISA Ethernet Controllers # device declaration in sys/conf/files attach ep at eisa with ep_eisa file dev/eisa/if_ep_eisa.c ep_eisa + +# DEC DEFEA EISA FDDI Controller +device fea: pdq, fddi, ifnet +attach fea at eisa +file dev/eisa/if_fea.c fea diff --git a/sys/dev/eisa/if_ep_eisa.c b/sys/dev/eisa/if_ep_eisa.c index 8ca2de48c67..38692ddedd5 100644 --- a/sys/dev/eisa/if_ep_eisa.c +++ b/sys/dev/eisa/if_ep_eisa.c @@ -1,7 +1,7 @@ -/* $NetBSD: if_ep_eisa.c,v 1.3 1996/05/03 19:07:18 christos Exp $ */ +/* $NetBSD: if_ep_eisa.c,v 1.6 1996/05/14 22:21:05 thorpej Exp $ */ /* - * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> + * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,6 +62,7 @@ #include <machine/cpu.h> #include <machine/bus.h> +#include <machine/intr.h> #include <dev/ic/elink3var.h> #include <dev/ic/elink3reg.h> @@ -108,15 +109,14 @@ ep_eisa_attach(parent, self, aux) struct eisa_attach_args *ea = aux; bus_chipset_tag_t bc = ea->ea_bc; bus_io_handle_t ioh; - int irq, k; - u_short conn = 0; + u_int16_t k, conn = 0; eisa_chipset_tag_t ec = ea->ea_ec; eisa_intr_handle_t ih; const char *model, *intrstr; + u_int irq; /* Map i/o space. */ - if (bus_io_map(bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE, - &ioh)) + if (bus_io_map(bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE, &ioh)) panic("ep_eisa_attach: can't map i/o space"); sc->bustype = EP_BUS_EISA; @@ -151,7 +151,7 @@ ep_eisa_attach(parent, self, aux) printf(": <%s> ", model); if (eisa_intr_map(ec, irq, &ih)) { - printf("couldn't map interrupt (%d)\n", irq); + printf("couldn't map interrupt (%u)\n", irq); return; } intrstr = eisa_intr_string(ec, ih); @@ -165,8 +165,7 @@ ep_eisa_attach(parent, self, aux) return; } if (intrstr != NULL) - printf("interrupting at %s, ", sc->sc_dev.dv_xname, - intrstr); + printf("%s, ", intrstr); epconfig(sc, conn); } diff --git a/sys/dev/eisa/if_fea.c b/sys/dev/eisa/if_fea.c new file mode 100644 index 00000000000..1b92bc64189 --- /dev/null +++ b/sys/dev/eisa/if_fea.c @@ -0,0 +1,532 @@ +/* $NetBSD: if_fea.c,v 1.3 1996/05/20 15:52:32 thorpej Exp $ */ + +/*- + * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com> + * 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. The name of the author may not be used to endorse or promote products + * derived from this software withough 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. + * + * Id: if_fea.c,v 1.5 1996/05/17 01:15:18 thomas Exp + */ + +/* + * DEC PDQ FDDI Controller + * + * This module support the DEFEA EISA FDDI Controller. + */ + + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/mbuf.h> +#include <sys/protosw.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/errno.h> +#include <sys/malloc.h> +#if defined(__FreeBSD__) +#include <sys/devconf.h> +#elif defined(__bsdi__) || defined(__NetBSD__) +#include <sys/device.h> +#endif + +#include <net/if.h> +#include <net/if_types.h> +#include <net/if_dl.h> +#include <net/route.h> + +#include "bpfilter.h" +#if NBPFILTER > 0 +#include <net/bpf.h> +#include <net/bpfdesc.h> +#endif + +#ifdef INET +#include <netinet/in.h> +#include <netinet/in_systm.h> +#include <netinet/in_var.h> +#include <netinet/ip.h> +#include <netinet/if_ether.h> +#endif + +#if defined(__FreeBSD__) +#include <netinet/if_fddi.h> +#else +#include <net/if_fddi.h> +#endif + +#include <vm/vm.h> +#include <vm/vm_kern.h> +#include <vm/vm_param.h> + +#if defined(__FreeBSD__) +#include <i386/eisa/eisaconf.h> +#include <i386/isa/icu.h> +#include <pci/pdqvar.h> +#include <pci/pdqreg.h> +#elif defined(__bsdi__) +#include <i386/isa/isa.h> +#include <i386/isa/icu.h> +#include <i386/isa/dma.h> +#include <i386/isa/isavar.h> +#include <i386/eisa/eisa.h> +#include <i386/eisa/pdqvar.h> +#include <i386/eisa/pdqreg.h> +#elif defined(__NetBSD__) +#include <machine/cpu.h> +#include <machine/bus.h> + +#include <dev/ic/pdqvar.h> +#include <dev/ic/pdqreg.h> + +#include <dev/eisa/eisareg.h> +#include <dev/eisa/eisavar.h> +#include <dev/eisa/eisadevs.h> +#endif + +/* + * + */ + +#if defined(__FreeBSD__) +static pdq_softc_t *pdqs_eisa[16]; +#define PDQ_EISA_UNIT_TO_SOFTC(unit) (pdqs_eisa[unit]) +#define DEFEA_INTRENABLE 0x8 /* level interrupt */ +#define pdq_eisa_ifwatchdog NULL +static const int pdq_eisa_irqs[4] = { 9, 10, 11, 15 }; + +#elif defined(__bsdi__) +extern struct cfdriver feacd; +#define PDQ_EISA_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)feacd.cd_devs[unit]) +#define DEFEA_INTRENABLE 0x28 /* edge interrupt */ +static const int pdq_eisa_irqs[4] = { IRQ9, IRQ10, IRQ11, IRQ15 }; + +#elif defined(__NetBSD__) +#define DEFEA_INTRENABLE 0x8 /* level interrupt */ +#define pdq_eisa_ifwatchdog NULL +static const int pdq_eisa_irqs[4] = { 9, 10, 11, 15 }; + +#else +#error unknown system +#endif + +#ifndef pdq_eisa_ifwatchdog +static ifnet_ret_t +pdq_eisa_ifwatchdog( + int unit) +{ + pdq_ifwatchdog(&PDQ_EISA_UNIT_TO_SOFTC(unit)->sc_if); +} +#endif + +static void +pdq_eisa_subprobe( + pdq_bus_t bc, + pdq_bus_ioport_t iobase, + pdq_uint32_t *maddr, + pdq_uint32_t *msize, + pdq_uint32_t *irq) +{ + if (irq != NULL) + *irq = pdq_eisa_irqs[PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_IO_CONFIG_STAT_0) & 3]; + *maddr = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_0) << 8) + | (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_CMP_1) << 16); + *msize = (PDQ_OS_IORD_8(bc, iobase, PDQ_EISA_MEM_ADD_MASK_0) + 4) << 8; +} + +static void +pdq_eisa_devinit( + pdq_softc_t *sc) +{ + pdq_uint8_t data; + + /* + * Do the standard initialization for the DEFEA registers. + */ + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_FUNCTION_CTRL, 0x23); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_1_1, (sc->sc_iobase >> 8) & 0xF0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CMP_0_1, (sc->sc_iobase >> 8) & 0xF0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_SLOT_CTRL, 0x01); + data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF); +#if defined(PDQ_IOMAPPED) + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data & ~1); +#else + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_BURST_HOLDOFF, data | 1); +#endif + data = PDQ_OS_IORD_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0); + PDQ_OS_IOWR_8(sc->sc_bc, sc->sc_iobase, PDQ_EISA_IO_CONFIG_STAT_0, data | DEFEA_INTRENABLE); +} + +#if defined(__FreeBSD__) +static int pdq_eisa_shutdown(struct kern_devconf *kdc, int force); +static int pdq_eisa_probe(void); +static int pdq_eisa_attach(struct eisa_device *ed); + +static unsigned long pdq_eisa_unit; + +static struct eisa_driver pdq_eisa_driver = { + "fea", pdq_eisa_probe, pdq_eisa_attach, NULL, &pdq_eisa_unit +}; + +DATA_SET(eisadriver_set, pdq_eisa_driver); + +static struct kern_devconf kdc_pdq_eisa = { + 0, 0, 0, /* filled in by dev_attach */ + "fea", 0, { MDDT_EISA, 0, "net" }, + eisa_generic_externalize, 0, pdq_eisa_shutdown, EISA_EXTERNALLEN, + &kdc_eisa0, /* parent */ + 0, /* parentdata */ + DC_BUSY, /* host adapters are always ``in use'' */ + "DEC DEFEA EISA FDDI Controller", + DC_CLS_NETIF +}; + +static const char * +pdq_eisa_match( + eisa_id_t type) +{ + if ((type >> 8) == 0x10a330) + return kdc_pdq_eisa.kdc_description; + return NULL; +} + +static int +pdq_eisa_probe( + void) +{ + struct eisa_device *ed = NULL; + int count; + + for (count = 0; (ed = eisa_match_dev(ed, pdq_eisa_match)) != NULL; count++) { + pdq_bus_ioport_t iobase = ed->ioconf.slot * EISA_SLOT_SIZE; + pdq_uint32_t irq, maddr, msize; + + eisa_add_iospace(ed, iobase, 0x200, RESVADDR_NONE); + pdq_eisa_subprobe(PDQ_BUS_EISA, iobase, &maddr, &msize, &irq); + eisa_add_mspace(ed, maddr, msize, RESVADDR_NONE); + eisa_add_intr(ed, irq); + eisa_registerdev(ed, &pdq_eisa_driver, &kdc_pdq_eisa); + } + return count; +} + +static void +pdq_eisa_interrupt( + void *arg) +{ + pdq_softc_t * const sc = (pdq_softc_t *) arg; + (void) pdq_interrupt(sc->sc_pdq); +} + +static int +pdq_eisa_attach( + struct eisa_device *ed) +{ + pdq_softc_t *sc; + resvaddr_t *iospace; + resvaddr_t *mspace; + int irq = ffs(ed->ioconf.irq) - 1; + + sc = (pdq_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_WAITOK); + if (sc == NULL) { + printf("fea%d: malloc failed!\n", sc->sc_if.if_unit); + return -1; + } + pdqs_eisa[ed->unit] = sc; + + bzero(sc, sizeof(pdq_softc_t)); /* Zero out the softc*/ + sc->sc_if.if_name = "fea"; + sc->sc_if.if_unit = ed->unit; + + if ((iospace = ed->ioconf.ioaddrs.lh_first) == NULL) { + printf("fea%d: no iospace??\n", sc->sc_if.if_unit); + return -1; + } + if ((mspace = ed->ioconf.maddrs.lh_first) == NULL) { + printf("fea%d: no memory space??\n", sc->sc_if.if_unit); + return -1; + } + + sc->sc_iobase = (pdq_bus_ioport_t) iospace->addr; + sc->sc_membase = (pdq_bus_memaddr_t) pmap_mapdev(mspace->addr, mspace->size); + if (sc->sc_membase == NULL) { + printf("fea%d: failed to map memory 0x%x-0x%x!\n", + sc->sc_if.if_unit, mspace->addr, mspace->addr + mspace->size - 1); + return -1; + } + + eisa_reg_start(ed); + if (eisa_reg_iospace(ed, iospace)) { + printf("fea%d: failed to register iospace 0x%x-0x%x!\n", + sc->sc_if.if_unit, iospace->addr, iospace->addr + iospace->size - 1); + return -1; + } + if (eisa_reg_mspace(ed, mspace)) { + printf("fea%d: failed to register memory 0x%x-0x%x!\n", + sc->sc_if.if_unit, mspace->addr, mspace->addr + mspace->size - 1); + return -1; + } + + if (eisa_reg_intr(ed, irq, pdq_eisa_interrupt, sc, &net_imask, 1)) { + printf("fea%d: interrupt registration failed\n", sc->sc_if.if_unit); + return -1; + } + + eisa_reg_end(ed); + + pdq_eisa_devinit(sc); + sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, sc->sc_membase, + sc->sc_if.if_name, sc->sc_if.if_unit, + (void *) sc, PDQ_DEFEA); + if (sc->sc_pdq == NULL) { + printf("fea%d: initialization failed\n", sc->sc_if.if_unit); + return -1; + } + + if (eisa_enable_intr(ed, irq)) { + printf("fea%d: failed to enable interrupt\n", sc->sc_if.if_unit); + return -1; + } + + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + pdq_ifattach(sc, pdq_eisa_ifwatchdog); + + ed->kdc->kdc_state = DC_BUSY; /* host adapters always busy */ + + return 0; +} + +static int +pdq_eisa_shutdown( + struct kern_devconf *kdc, + int force) +{ + pdq_hwreset(PDQ_EISA_UNIT_TO_SOFTC(kdc->kdc_unit)->sc_pdq); + (void) dev_detach(kdc); + return 0; +} +#endif /* __FreeBSD__ */ + +#if defined(__bsdi__) +static int +pdq_eisa_probe( + struct device *parent, + struct cfdata *cf, + void *aux) +{ + struct isa_attach_args *ia = (struct isa_attach_args *) aux; + int slot; + pdq_uint32_t irq, maddr, msize; + + if (isa_bustype != BUS_EISA) + return 0; + + if ((slot = eisa_match(cf, ia)) == 0) + return 0; + ia->ia_iobase = slot << 12; + ia->ia_iosize = EISA_NPORT; + eisa_slotalloc(slot); + + pdq_eisa_subprobe(PDQ_BUS_EISA, ia->ia_iobase, &maddr, &msize, &irq); + if (ia->ia_irq != IRQUNK && irq != ia->ia_irq) { + printf("fea%d: error: desired IRQ of %d does not match device's actual IRQ (%d),\n", + cf->cf_unit, + ffs(ia->ia_irq) - 1, ffs(irq) - 1); + return 0; + } + if (ia->ia_irq == IRQUNK) { + if ((ia->ia_irq = isa_irqalloc(irq)) == 0) { + if ((ia->ia_irq = isa_irqalloc(IRQ9|IRQ10|IRQ11|IRQ15)) == 0) { + printf("fea%d: error: IRQ %d is already in use\n", cf->cf_unit, + ffs(irq) - 1); + return 0; + } + irq = PDQ_OS_IORD_8(PDQ_BUS_EISA, ia->ia_iobase, PDQ_EISA_IO_CONFIG_STAT_0) & ~3; + switch (ia->ia_irq) { + case IRQ9: irq |= 0; + case IRQ10: irq |= 1; + case IRQ11: irq |= 2; + case IRQ15: irq |= 3; + } + PDQ_OS_IOWR_8(PDQ_BUS_EISA, ia->ia_iobase, PDQ_EISA_IO_CONFIG_STAT_0, irq); + } + } + if (maddr == 0) { + printf("fea%d: error: memory not enabled! ECU reconfiguration required\n", + cf->cf_unit); + return 0; + } + + /* EISA bus masters don't use host DMA channels */ + ia->ia_drq = DRQNONE; + + ia->ia_maddr = (caddr_t) maddr; + ia->ia_msize = msize; + return 1; +} + +static void +pdq_eisa_attach( + struct device *parent, + struct device *self, + void *aux) +{ + pdq_softc_t *sc = (pdq_softc_t *) self; + register struct isa_attach_args *ia = (struct isa_attach_args *) aux; + register struct ifnet *ifp = &sc->sc_if; + + sc->sc_if.if_unit = sc->sc_dev.dv_unit; + sc->sc_if.if_name = "fea"; + sc->sc_if.if_flags = 0; + + sc->sc_iobase = ia->ia_iobase; + + pdq_eisa_devinit(sc); + sc->sc_pdq = pdq_initialize(PDQ_BUS_EISA, + (pdq_bus_memaddr_t) ISA_HOLE_VADDR(ia->ia_maddr), + sc->sc_if.if_name, sc->sc_if.if_unit, + (void *) sc, PDQ_DEFEA); + if (sc->sc_pdq == NULL) { + printf("fea%d: initialization failed\n", sc->sc_if.if_unit); + return; + } + + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + + pdq_ifattach(sc, pdq_eisa_ifwatchdog); + + isa_establish(&sc->sc_id, &sc->sc_dev); + + sc->sc_ih.ih_fun = pdq_interrupt; + sc->sc_ih.ih_arg = (void *) sc->sc_pdq; + intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET); + + sc->sc_ats.func = (void (*)(void *)) pdq_hwreset; + sc->sc_ats.arg = (void *) sc->sc_pdq; + atshutdown(&sc->sc_ats, ATSH_ADD); +} + +static char *pdq_eisa_ids[] = { + "DEC3001", /* 0x0130A310 */ + "DEC3002", /* 0x0230A310 */ + "DEC3003", /* 0x0330A310 */ + "DEC3004", /* 0x0430A310 */ +}; + +struct cfdriver feacd = { + 0, "fea", pdq_eisa_probe, pdq_eisa_attach, DV_IFNET, sizeof(pdq_softc_t), + pdq_eisa_ids +}; +#endif /* __bsdi__ */ + +#if defined(__NetBSD__) +static int +pdq_eisa_match( + struct device *parent, + void *match, + void *aux) +{ + const struct eisa_attach_args * const ea = (struct eisa_attach_args *) aux; + + if (strncmp(ea->ea_idstring, "DEC300", 6) == 0) + return 1; + + return 0; +} + +static void +pdq_eisa_attach( + struct device *parent, + struct device *self, + void *aux) +{ + pdq_softc_t * const sc = (pdq_softc_t *) self; + struct eisa_attach_args * const ea = (struct eisa_attach_args *) aux; + pdq_uint32_t irq, maddr, msize; + eisa_intr_handle_t ih; + const char *intrstr; + + sc->sc_bc = ea->ea_bc; + bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ); + sc->sc_if.if_flags = 0; + sc->sc_if.if_softc = sc; + + if (bus_io_map(sc->sc_bc, EISA_SLOT_ADDR(ea->ea_slot), EISA_SLOT_SIZE, &sc->sc_iobase)) { + printf("\n%s: failed to map I/O!\n", sc->sc_dev.dv_xname); + return; + } + + pdq_eisa_subprobe(sc->sc_bc, sc->sc_iobase, &maddr, &msize, &irq); + +#if !defined(PDQ_IOMAPPED) + if (maddr == 0 || msize == 0) { + printf("\n%s: error: memory not enabled! ECU reconfiguration required\n", + sc->sc_dev.dv_xname); + return; + } + + if (bus_mem_map(sc->sc_bc, maddr, msize, 0, &sc->sc_membase)) { + bus_io_unmap(sc->sc_bc, sc->sc_iobase, EISA_SLOT_SIZE); + printf("\n%s: failed to map memory!\n", sc->sc_dev.dv_xname); + return; + } +#endif + pdq_eisa_devinit(sc); + sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase, + sc->sc_if.if_xname, 0, + (void *) sc, PDQ_DEFEA); + if (sc->sc_pdq == NULL) { + printf("%s: initialization failed\n", sc->sc_dev.dv_xname); + return; + } + + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + + pdq_ifattach(sc, pdq_eisa_ifwatchdog); + + if (eisa_intr_map(ea->ea_ec, irq, &ih)) { + printf("%s: couldn't map interrupt (%d)\n", sc->sc_dev.dv_xname, irq); + return; + } + intrstr = eisa_intr_string(ea->ea_ec, ih); + sc->sc_ih = eisa_intr_establish(ea->ea_ec, ih, IST_LEVEL, IPL_NET, + (int (*)(void *)) pdq_interrupt, sc->sc_pdq, sc->sc_dev.dv_xname); + if (sc->sc_ih == NULL) { + printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname); + if (intrstr != NULL) + printf(" at %s", intrstr); + printf("\n"); + return; + } + sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq); + if (sc->sc_ats == NULL) + printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname); + if (intrstr != NULL) + printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr); +} + +struct cfattach fea_ca = { + sizeof(pdq_softc_t), pdq_eisa_match, pdq_eisa_attach +}; + +struct cfdriver fea_cd = { + 0, "fea", DV_IFNET +}; +#endif diff --git a/sys/dev/ic/aic7xxx.c b/sys/dev/ic/aic7xxx.c index 793ac9eac73..614cd0616df 100644 --- a/sys/dev/ic/aic7xxx.c +++ b/sys/dev/ic/aic7xxx.c @@ -1,3 +1,5 @@ +/* $NetBSD: aic7xxx.c,v 1.8 1996/05/20 00:58:07 thorpej Exp $ */ + /* * Generic driver for the aic7xxx based adaptec SCSI controllers * Product specific probe and attach routines can be found in: @@ -30,8 +32,6 @@ * 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: aic7xxx.c,v 1.5 1996/05/05 12:42:29 deraadt Exp $ */ /* * TODO: @@ -117,14 +117,8 @@ #include <sys/systm.h> #if defined(__NetBSD__) #include <sys/device.h> -#if NetBSD1_1 < 3 -#include <machine/pio.h> -#else #include <machine/bus.h> -#ifdef __alpha__ #include <machine/intr.h> -#endif -#endif #endif /* defined(__NetBSD__) */ #include <sys/malloc.h> @@ -149,14 +143,11 @@ #include <i386/scsi/aic7xxx.h> #include <dev/aic7xxx/aic7xxx_reg.h> - -#define AHCNAME_FMT "ahc%d" -#define AHCNAME_VAR(ahc) (ahc)->unit #endif /* defined(__FreeBSD__) */ #if defined(__NetBSD__) +#include <dev/ic/aic7xxxreg.h> #include <dev/ic/aic7xxxvar.h> -#include <dev/microcode/aic7xxx/aic7xxx_reg.h> #define bootverbose 1 @@ -165,9 +156,6 @@ #undef DEBUGTARG #define DEBUGTARG 9 #endif - -#define AHCNAME_FMT "%s" -#define AHCNAME_VAR(ahc) (ahc)->sc_dev.dv_xname #endif /* defined(__NetBSD__) */ #define PAGESIZ NBPG @@ -178,14 +166,16 @@ #define MIN(a,b) ((a < b) ? a : b) #define ALL_TARGETS -1 +#if defined(__FreeBSD__) u_long ahc_unit = 0; +#endif #ifdef AHC_DEBUG static int ahc_debug = AHC_SHOWSENSE; #endif -#ifdef AIC7XXX_BROKEN_CACHE -int aic7xxx_broken_cache = 1; +#ifdef AHC_BROKEN_CACHE +int ahc_broken_cache = 1; /* * "wbinvd" cause writing back whole cache (both CPU internal & external) @@ -235,22 +225,22 @@ static struct scsi_device ahc_dev = * XXX Should add a timeout in here?? */ #define PAUSE_SEQUENCER(ahc) \ - outb(HCNTRL + ahc->baseport, ahc->pause); \ + AHC_OUTB(ahc, HCNTRL, ahc->pause); \ \ - while ((inb(HCNTRL + ahc->baseport) & PAUSE) == 0) \ + while ((AHC_INB(ahc, HCNTRL) & PAUSE) == 0) \ ; #define UNPAUSE_SEQUENCER(ahc) \ - outb( HCNTRL + ahc->baseport, ahc->unpause ) + AHC_OUTB(ahc, HCNTRL, ahc->unpause ) /* * Restart the sequencer program from address zero */ #define RESTART_SEQUENCER(ahc) \ do { \ - outb( SEQCTL + ahc->baseport, SEQRESET|FASTMODE ); \ - } while (inb(SEQADDR0 + ahc->baseport) != 0 && \ - inb(SEQADDR1 + ahc->baseport) != 0); \ + AHC_OUTB(ahc, SEQCTL, SEQRESET|FASTMODE); \ + } while (AHC_INB(ahc, SEQADDR0) != 0 && \ + AHC_INB(ahc, SEQADDR1) != 0); \ \ UNPAUSE_SEQUENCER(ahc); @@ -269,9 +259,10 @@ static struct scsi_device ahc_dev = #endif static u_char ahc_abort_wscb __P((struct ahc_data *ahc, struct scb *scbp, - u_char prev, u_long iobase, + u_char prev, u_char timedout_scb, u_int32_t xs_error)); -static void ahc_add_waiting_scb __P((u_long iobase, struct scb *scb)); +static void ahc_add_waiting_scb __P((struct ahc_data *ahc, + struct scb *scb)); static void ahc_done __P((struct ahc_data *ahc, struct scb *scbp)); static void ahc_free_scb __P((struct ahc_data *ahc, struct scb *scb, int flags)); @@ -282,7 +273,7 @@ static inline void ahc_page_scb __P((struct ahc_data *ahc, struct scb *out_scb, static inline void ahc_run_waiting_queues __P((struct ahc_data *ahc)); static struct scb * ahc_get_scb __P((struct ahc_data *ahc, int flags)); -static void ahc_loadseq __P((u_long iobase)); +static void ahc_loadseq __P((struct ahc_data *ahc)); static int ahc_match_scb __P((struct scb *scb, int target, char channel)); static int ahc_poll __P((struct ahc_data *ahc, int wait)); #ifdef AHC_DEBUG @@ -294,7 +285,7 @@ static int ahc_reset_channel __P((struct ahc_data *ahc, char channel, static int ahc_reset_device __P((struct ahc_data *ahc, int target, char channel, u_char timedout_scb, u_int32_t xs_error)); -static void ahc_reset_current_bus __P((u_long iobase)); +static void ahc_reset_current_bus __P((struct ahc_data *ahc)); static void ahc_run_done_queue __P((struct ahc_data *ahc)); static void ahc_scsirate __P((struct ahc_data* ahc, u_char *scsirate, int period, int offset, int target)); @@ -304,10 +295,27 @@ static timeout_t #elif defined(__NetBSD__) static void ahc_timeout __P((void *)); #endif -static void ahc_busy_target __P((int target, char channel, - u_long iobase)); -static void ahc_unbusy_target __P((int target, char channel, - u_long iobase)); +static void ahc_busy_target __P((struct ahc_data *ahc, + int target, char channel)); +static void ahc_unbusy_target __P((struct ahc_data *ahc, + int target, char channel)); + +#if defined(__FreeBSD__) + +char *ahc_name(ahc) + struct ahc_data *ahc; +{ + static char name[10]; + + sprintf(name, "ahc%d", ahc->unit); + return (name); +} + +#elif defined(__NetBSD__) +struct cfdriver ahc_cd = { + NULL, "ahc", DV_DULL +}; +#endif #ifdef AHC_DEBUG static void @@ -358,11 +366,11 @@ static struct { { 0x100, 50, "20.0" }, { 0x110, 62, "16.0" }, { 0x120, 75, "13.4" }, - { 0x130, 87, "11.4" }, - { 0x140, 100, "10.0" }, - { 0x150, 112, "8.8" }, - { 0x160, 125, "8.0" }, - { 0x170, 137, "7.2" }, + { 0x130, 175, "5.7" }, + { 0x140, 200, "5.0" }, + { 0x150, 225, "4.4" }, + { 0x160, 250, "4.0" }, + { 0x170, 275, "3.6" }, { 0x000, 100, "10.0" }, { 0x010, 125, "8.0" }, { 0x020, 150, "6.67" }, @@ -385,15 +393,15 @@ static int ahc_num_syncrates = #if defined(__FreeBSD__) struct ahc_data * ahc_alloc(unit, iobase, type, flags) + int unit; u_long iobase; #elif defined(__NetBSD__) void -ahc_construct(ahc, unit, bc, iobase, type, flags) +ahc_construct(ahc, bc, ioh, type, flags) struct ahc_data *ahc; bus_chipset_tag_t bc; - bus_io_handle_t iobase; /* XXX - ioh */ + bus_io_handle_t ioh; #endif - int unit; ahc_type type; ahc_flag flags; { @@ -416,18 +424,20 @@ ahc_construct(ahc, unit, bc, iobase, type, flags) } bzero(ahc, sizeof(struct ahc_data)); #endif - STAILQ_INIT(&ahc->free_scbs); - STAILQ_INIT(&ahc->page_scbs); - STAILQ_INIT(&ahc->waiting_scbs); - STAILQ_INIT(&ahc->assigned_scbs); + SIMPLEQ_INIT(&ahc->free_scbs); + SIMPLEQ_INIT(&ahc->page_scbs); + SIMPLEQ_INIT(&ahc->waiting_scbs); + SIMPLEQ_INIT(&ahc->assigned_scbs); +#if defined(__FreeBSD__) ahc->unit = unit; -#if defined(__NetBSD__) + ahc->baseport = iobase; +#elif defined(__NetBSD__) ahc->sc_bc = bc; + ahc->sc_ioh = ioh; #endif - ahc->baseport = iobase; ahc->type = type; ahc->flags = flags; - ahc->unpause = (inb(HCNTRL + iobase) & IRQMS) | INTEN; + ahc->unpause = (AHC_INB(ahc, HCNTRL) & IRQMS) | INTEN; ahc->pause = ahc->unpause | PAUSE; #if defined(__FreeBSD__) @@ -450,27 +460,35 @@ void ahc_reset(iobase) u_long iobase; #elif defined(__NetBSD__) -ahc_reset(devname, bc, iobase) +ahc_reset(devname, bc, ioh) char *devname; bus_chipset_tag_t bc; - bus_io_handle_t iobase; /* XXX - ioh */ + bus_io_handle_t ioh; #endif { u_char hcntrl; int wait; /* Retain the IRQ type accross the chip reset */ +#if defined(__FreeBSD__) hcntrl = (inb(HCNTRL + iobase) & IRQMS) | INTEN; + outb(HCNTRL + iobase, CHIPRST | PAUSE); +#elif defined(__NetBSD__) + hcntrl = (bus_io_read_1(bc, ioh, HCNTRL) & IRQMS) | INTEN; + + bus_io_write_1(bc, ioh, HCNTRL, CHIPRST | PAUSE); +#endif /* * Ensure that the reset has finished */ wait = 1000; - while (wait--) { +#if defined(__FreeBSD__) + while (--wait && !(inb(HCNTRL + iobase) & CHIPRSTACK)) +#elif defined(__NetBSD__) + while (--wait && !(bus_io_read_1(bc, ioh, HCNTRL) & CHIPRSTACK)) +#endif DELAY(1000); - if(!(inb(HCNTRL + iobase) & CHIPRST)) - break; - } if(wait == 0) { #if defined(__FreeBSD__) printf("ahc at 0x%lx: WARNING - Failed chip reset! " @@ -480,7 +498,11 @@ ahc_reset(devname, bc, iobase) "Trying to initialize anyway.\n", devname); #endif } +#if defined(__FreeBSD__) outb(HCNTRL + iobase, hcntrl | PAUSE); +#elif defined(__NetBSD__) + bus_io_write_1(bc, ioh, HCNTRL, hcntrl | PAUSE); +#endif } /* @@ -504,16 +526,8 @@ ahc_scsirate(ahc, scsirate, period, offset, target ) * enabled and vice-versa. */ if (ahc->type & AHC_ULTRA) { - if (!(ahc_syncrates[i].sxfr & ULTRA_SXFR)) { - printf(AHCNAME_FMT - ": target %d requests " - "%sMHz transfers, but adapter " - "in Ultra mode can only sync at " - "7.2MHz or above\n", - AHCNAME_VAR(ahc), - target, ahc_syncrates[i].rate); + if (!(ahc_syncrates[i].sxfr & ULTRA_SXFR)) break; /* Use Async */ - } } else { if (ahc_syncrates[i].sxfr & ULTRA_SXFR) { @@ -529,10 +543,9 @@ ahc_scsirate(ahc, scsirate, period, offset, target ) } *scsirate = (ahc_syncrates[i].sxfr) | (offset & 0x0f); if(bootverbose) { - printf(AHCNAME_FMT - ": target %d synchronous at %sMHz," + printf("%s: target %d synchronous at %sMHz," " offset = 0x%x\n", - AHCNAME_VAR(ahc), target, + ahc_name(ahc), target, ahc_syncrates[i].rate, offset ); } return; @@ -541,8 +554,8 @@ ahc_scsirate(ahc, scsirate, period, offset, target ) /* Default to asyncronous transfers. Also reject this SDTR request. */ *scsirate = 0; if(bootverbose) { - printf(AHCNAME_FMT ": target %d using asyncronous transfers\n", - AHCNAME_VAR(ahc), target ); + printf("%s: target %d using asyncronous transfers\n", + ahc_name(ahc), target ); } } @@ -568,12 +581,12 @@ ahc_attach(ahc) { struct scsibus_data *scbus; -#ifdef AIC7XXX_BROKEN_CACHE +#ifdef AHC_BROKEN_CACHE if (cpu_class == CPUCLASS_386) /* doesn't have "wbinvd" instruction */ - aic7xxx_broken_cache = 0; + ahc_broken_cache = 0; #endif /* - * fill in the prototype scsi_link. + * fill in the prototype scsi_links. */ #if defined(__FreeBSD__) ahc->sc_link.adapter_unit = ahc->unit; @@ -588,69 +601,91 @@ ahc_attach(ahc) ahc->sc_link.device = &ahc_dev; ahc->sc_link.flags = DEBUGLEVEL; + if(ahc->type & AHC_TWIN) { + /* Configure the second scsi bus */ + ahc->sc_link_b = ahc->sc_link; +#if defined(__FreeBSD__) + ahc->sc_link_b.adapter_targ = ahc->our_id_b; + ahc->sc_link_b.adapter_bus = 1; + ahc->sc_link_b.fordriver = (void *)SELBUSB; +#elif defined(__NetBSD__) + ahc->sc_link_b.adapter_target = ahc->our_id_b; +#endif + } + + +#if defined(__FreeBSD__) /* * Prepare the scsibus_data area for the upperlevel * scsi code. */ -#if defined(__FreeBSD__) scbus = scsi_alloc_bus(); if(!scbus) return 0; - scbus->adapter_link = &ahc->sc_link; + scbus->adapter_link = (ahc->flags & AHC_CHANNEL_B_PRIMARY) ? + &ahc->sc_link_b : &ahc->sc_link; if(ahc->type & AHC_WIDE) scbus->maxtarg = 15; -#elif defined(__NetBSD__) - /* - * XXX - Update MI SCSI code - * - * if(ahc->type & AHC_WIDE) - * XXX max target XXX = 15; - */ -#endif /* * ask the adapter what subunits are present */ -#if defined(__FreeBSD__) if(bootverbose) - printf("ahc%d: Probing channel A\n", ahc->unit); + printf("ahc%d: Probing channel %c\n", ahc->unit, + (ahc->flags & AHC_CHANNEL_B_PRIMARY) ? 'B' : 'A'); scsi_attachdevs(scbus); scbus = NULL; /* Upper-level SCSI code owns this now */ -#elif defined(__NetBSD__) - ahc->sc_link_b.scsibus = 0xff; /* for IS_SCSIBUS_B(), never match */ - printf("%s: Probing channel A\n", ahc->sc_dev.dv_xname); - config_found((void *)ahc, &ahc->sc_link, ahcprint); -#endif if(ahc->type & AHC_TWIN) { - /* Configure the second scsi bus */ - ahc->sc_link_b = ahc->sc_link; -#if defined(__FreeBSD__) - ahc->sc_link_b.adapter_targ = ahc->our_id_b; - ahc->sc_link_b.adapter_bus = 1; - ahc->sc_link_b.fordriver = (void *)SELBUSB; scbus = scsi_alloc_bus(); if(!scbus) return 0; - scbus->adapter_link = &ahc->sc_link_b; + scbus->adapter_link = (ahc->flags & AHC_CHANNEL_B_PRIMARY) ? + &ahc->sc_link : &ahc->sc_link_b; if(ahc->type & AHC_WIDE) scbus->maxtarg = 15; if(bootverbose) - printf("ahc%d: Probing Channel B\n", ahc->unit); + printf("ahc%d: Probing Channel %c\n", ahc->unit, + (ahc->flags & AHC_CHANNEL_B_PRIMARY) ? 'A': 'B'); scsi_attachdevs(scbus); scbus = NULL; /* Upper-level SCSI code owns this now */ + } #elif defined(__NetBSD__) + /* + * XXX - Update MI SCSI code + * + * if(ahc->type & AHC_WIDE) + * max target of both channel A and B = 15; + */ + + /* + * ask the adapter what subunits are present + */ + if ((ahc->flags & AHC_CHANNEL_B_PRIMARY) == 0) { + /* make IS_SCSIBUS_B() == false, while probing channel A */ + ahc->sc_link_b.scsibus = 0xff; + + if (ahc->type & AHC_TWIN) + printf("%s: Probing channel A\n", ahc_name(ahc)); + config_found((void *)ahc, &ahc->sc_link, ahcprint); + if (ahc->type & AHC_TWIN) { + printf("%s: Probing channel B\n", ahc_name(ahc)); + config_found((void *)ahc, &ahc->sc_link_b, ahcprint); + } + } else { /* - * XXX - Update MI SCSI code - * - * if(ahc->type & AHC_WIDE) - * XXX max target XXX = 15; + * if implementation of IS_SCSIBUS_B() is changed to use + * ahc->sc_link.scsibus, then "ahc->sc_link.scsibus = 0xff;" + * is needed, here. */ - ahc->sc_link_b.adapter_target = ahc->our_id_b; - printf("%s: Probing channel B\n", ahc->sc_dev.dv_xname); + + /* assert(ahc->type & AHC_TWIN); */ + printf("%s: Probing channel B\n", ahc_name(ahc)); config_found((void *)ahc, &ahc->sc_link_b, ahcprint); -#endif + printf("%s: Probing channel A\n", ahc_name(ahc)); + config_found((void *)ahc, &ahc->sc_link, ahcprint); } +#endif return 1; } @@ -663,16 +698,14 @@ ahc_send_scb(ahc, scb) struct ahc_data *ahc; struct scb *scb; { - u_long iobase = ahc->baseport; - - outb(SCBCNT + iobase, SCBAUTO); + AHC_OUTB(ahc, SCBCNT, SCBAUTO); if( ahc->type == AHC_284 ) /* Can only do 8bit PIO */ - outsb(SCBARRAY+iobase, scb, SCB_PIO_TRANSFER_SIZE); + AHC_OUTSB(ahc, SCBARRAY, scb, SCB_PIO_TRANSFER_SIZE); else - outsl(SCBARRAY+iobase, scb, + AHC_OUTSL(ahc, SCBARRAY, scb, (SCB_PIO_TRANSFER_SIZE + 3) / 4); - outb(SCBCNT + iobase, 0); + AHC_OUTB(ahc, SCBCNT, 0); } /* @@ -684,14 +717,12 @@ ahc_fetch_scb(ahc, scb) struct ahc_data *ahc; struct scb *scb; { - u_long iobase = ahc->baseport; - - outb(SCBCNT + iobase, 0x80); /* SCBAUTO */ + AHC_OUTB(ahc, SCBCNT, 0x80); /* SCBAUTO */ /* Can only do 8bit PIO for reads */ - insb(SCBARRAY+iobase, scb, SCB_PIO_TRANSFER_SIZE); + AHC_INSB(ahc, SCBARRAY, scb, SCB_PIO_TRANSFER_SIZE); - outb(SCBCNT + iobase, 0); + AHC_OUTB(ahc, SCBCNT, 0); } /* @@ -728,27 +759,26 @@ ahc_run_waiting_queues(ahc) { struct scb* scb; u_char cur_scb; - u_long iobase = ahc->baseport; - if(!(ahc->assigned_scbs.stqh_first || ahc->waiting_scbs.stqh_first)) + if(!(ahc->assigned_scbs.sqh_first || ahc->waiting_scbs.sqh_first)) return; PAUSE_SEQUENCER(ahc); - cur_scb = inb(SCBPTR + iobase); + cur_scb = AHC_INB(ahc, SCBPTR); /* * First handle SCBs that are waiting but have been * assigned a slot. */ - while((scb = ahc->assigned_scbs.stqh_first) != NULL) { - STAILQ_REMOVE_HEAD(&ahc->assigned_scbs, links); - outb(SCBPTR + iobase, scb->position); + while((scb = ahc->assigned_scbs.sqh_first) != NULL) { + SIMPLEQ_REMOVE_HEAD(&ahc->assigned_scbs, scb, links); + AHC_OUTB(ahc, SCBPTR, scb->position); ahc_send_scb(ahc, scb); /* Mark this as an active command */ scb->flags = SCB_ACTIVE; - outb(QINFIFO + iobase, scb->position); + AHC_OUTB(ahc, QINFIFO, scb->position); if (!(scb->xs->flags & SCSI_NOMASK)) { timeout(ahc_timeout, (caddr_t)scb, (scb->xs->timeout * hz) / 1000); @@ -756,9 +786,9 @@ ahc_run_waiting_queues(ahc) SC_DEBUG(scb->xs->sc_link, SDEV_DB3, ("cmd_sent\n")); } /* Now deal with SCBs that require paging */ - if((scb = ahc->waiting_scbs.stqh_first) != NULL) { - u_char disc_scb = inb(DISCONNECTED_SCBH + iobase); - u_char active = inb(FLAGS+iobase) & (SELECTED|IDENTIFY_SEEN); + if((scb = ahc->waiting_scbs.sqh_first) != NULL) { + u_char disc_scb = AHC_INB(ahc, DISCONNECTED_SCBH); + u_char active = AHC_INB(ahc, FLAGS) & (SELECTED|IDENTIFY_SEEN); int count = 0; do { @@ -772,8 +802,8 @@ ahc_run_waiting_queues(ahc) * Advance disc_scb to the next on in the * list. */ - outb(SCBPTR + iobase, disc_scb); - next_scb = inb(SCB_NEXT + iobase); + AHC_OUTB(ahc, SCBPTR, disc_scb); + next_scb = AHC_INB(ahc, SCB_NEXT); /* * We have to be careful about when we allow @@ -793,13 +823,14 @@ ahc_run_waiting_queues(ahc) u_char out_scbi; struct scb* out_scbp; - STAILQ_REMOVE_HEAD(&ahc->waiting_scbs, links); + SIMPLEQ_REMOVE_HEAD(&ahc->waiting_scbs, scb, + links); /* * Find the in-core SCB for the one * we're paging out. */ - out_scbi = inb(SCB_TAG + iobase); + out_scbi = AHC_INB(ahc, SCB_TAG); out_scbp = ahc->scbarray[out_scbi]; /* Do the page out */ @@ -809,7 +840,7 @@ ahc_run_waiting_queues(ahc) scb->flags = SCB_ACTIVE; /* Queue the command */ - outb(QINFIFO + iobase, scb->position); + AHC_OUTB(ahc, QINFIFO, scb->position); if (!(scb->xs->flags & SCSI_NOMASK)) { timeout(ahc_timeout, (caddr_t)scb, (scb->xs->timeout * hz) / 1000); @@ -823,21 +854,21 @@ ahc_run_waiting_queues(ahc) } else break; - } while((scb = ahc->waiting_scbs.stqh_first) != NULL); + } while((scb = ahc->waiting_scbs.sqh_first) != NULL); if(count) { /* * Update the head of the disconnected list. */ - outb(DISCONNECTED_SCBH + iobase, disc_scb); + AHC_OUTB(ahc, DISCONNECTED_SCBH, disc_scb); if(disc_scb != SCB_LIST_NULL) { - outb(SCBPTR + iobase, disc_scb); - outb(SCB_PREV + iobase, SCB_LIST_NULL); + AHC_OUTB(ahc, SCBPTR, disc_scb); + AHC_OUTB(ahc, SCB_PREV, SCB_LIST_NULL); } } } /* Restore old position */ - outb(SCBPTR + iobase, cur_scb); + AHC_OUTB(ahc, SCBPTR, cur_scb); UNPAUSE_SEQUENCER(ahc); } @@ -845,21 +876,21 @@ ahc_run_waiting_queues(ahc) * Add this SCB to the head of the "waiting for selection" list. */ static -void ahc_add_waiting_scb (iobase, scb) - u_long iobase; +void ahc_add_waiting_scb(ahc, scb) + struct ahc_data *ahc; struct scb *scb; { u_char next; u_char curscb; - curscb = inb(SCBPTR + iobase); - next = inb(WAITING_SCBH + iobase); + curscb = AHC_INB(ahc, SCBPTR); + next = AHC_INB(ahc, WAITING_SCBH); - outb(SCBPTR+iobase, scb->position); - outb(SCB_NEXT+iobase, next); - outb(WAITING_SCBH + iobase, scb->position); + AHC_OUTB(ahc, SCBPTR, scb->position); + AHC_OUTB(ahc, SCB_NEXT, next); + AHC_OUTB(ahc, WAITING_SCBH, scb->position); - outb(SCBPTR + iobase, curscb); + AHC_OUTB(ahc, SCBPTR, curscb); } /* @@ -875,13 +906,11 @@ ahc_intr(arg) { int intstat; u_char status; - u_long iobase; struct scb *scb = NULL; struct scsi_xfer *xs = NULL; struct ahc_data *ahc = (struct ahc_data *)arg; - iobase = ahc->baseport; - intstat = inb(INTSTAT + iobase); + intstat = AHC_INB(ahc, INTSTAT); /* * Is this interrupt for me? or for * someone who is sharing my interrupt @@ -897,14 +926,14 @@ ahc_intr(arg) /* We upset the sequencer :-( */ /* Lookup the error message */ - int i, error = inb(ERROR + iobase); + int i, error = AHC_INB(ahc, ERROR); int num_errors = sizeof(hard_error)/sizeof(hard_error[0]); for(i = 0; error != 1 && i < num_errors; i++) error >>= 1; - panic(AHCNAME_FMT ": brkadrint, %s at seqaddr = 0x%x\n", - AHCNAME_VAR(ahc), hard_error[i].errmesg, - (inb(SEQADDR1 + iobase) << 8) | - inb(SEQADDR0 + iobase)); + panic("%s: brkadrint, %s at seqaddr = 0x%x\n", + ahc_name(ahc), hard_error[i].errmesg, + (AHC_INB(ahc, SEQADDR1) << 8) | + AHC_INB(ahc, SEQADDR0)); } if (intstat & SEQINT) { /* @@ -913,10 +942,10 @@ ahc_intr(arg) * inb. */ u_short targ_mask; - u_char target = (inb(SCSIID + iobase) >> 4) & 0x0f; + u_char target = (AHC_INB(ahc, SCSIID) >> 4) & 0x0f; u_char scratch_offset = target; char channel = - inb(SBLKCTL + iobase) & SELBUSB ? 'B': 'A'; + AHC_INB(ahc, SBLKCTL) & SELBUSB ? 'B': 'A'; if (channel == 'B') scratch_offset += 8; @@ -924,45 +953,46 @@ ahc_intr(arg) switch (intstat & SEQINT_MASK) { case BAD_PHASE: - panic(AHCNAME_FMT ":%c:%d: unknown scsi bus phase. " + panic("%s:%c:%d: unknown scsi bus phase. " "Attempting to continue\n", - AHCNAME_VAR(ahc), channel, target); + ahc_name(ahc), channel, target); break; case SEND_REJECT: { - u_char rejbyte = inb(REJBYTE + iobase); + u_char rejbyte = AHC_INB(ahc, REJBYTE); if(( rejbyte & 0xf0) == 0x20) { /* Tagged Message */ - printf("\n" AHCNAME_FMT - ":%c:%d: Tagged message " + printf("\n%s:%c:%d: Tagged message " "received without identify. " "Disabling tagged commands " "for this target.\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), channel, target); ahc->tagenable &= ~targ_mask; } else - printf(AHCNAME_FMT ":%c:%d: Warning - " + printf("%s:%c:%d: Warning - " "unknown message recieved from " "target (0x%x - 0x%x). Rejecting\n", - AHCNAME_VAR(ahc), - channel, target, - rejbyte, inb(REJBYTE_EXT + iobase)); + ahc_name(ahc), channel, target, + rejbyte, + AHC_INB(ahc, REJBYTE_EXT)); break; } case NO_IDENT: - panic(AHCNAME_FMT - ":%c:%d: Target did not send an IDENTIFY " + panic("%s:%c:%d: Target did not send an IDENTIFY " "message. SAVED_TCL == 0x%x\n", - AHCNAME_VAR(ahc), channel, target, - inb(SAVED_TCL + iobase)); + ahc_name(ahc), channel, target, + AHC_INB(ahc, SAVED_TCL)); break; case NO_MATCH: if(ahc->flags & AHC_PAGESCBS) { /* SCB Page-in request */ + u_char tag; + u_char next; + u_char disc_scb; struct scb *outscb; - u_char arg_1 = inb(ARG_1 + iobase); + u_char arg_1 = AHC_INB(ahc, ARG_1); if(arg_1 == SCB_LIST_NULL) { /* Non-tagged command */ int index = target | @@ -975,98 +1005,137 @@ ahc_intr(arg) /* * Now to pick the SCB to page out. * Either take a free SCB, an assigned SCB, - * an SCB that just completed or the first - * one on the disconnected SCB list. + * an SCB that just completed, the first + * one on the disconnected SCB list, or + * as a last resort a queued SCB. */ - if(ahc->free_scbs.stqh_first) { - outscb = ahc->free_scbs.stqh_first; - STAILQ_REMOVE_HEAD(&ahc->free_scbs, - links); + if((outscb = ahc->free_scbs.sqh_first) != NULL) { + SIMPLEQ_REMOVE_HEAD(&ahc->free_scbs, + outscb, links); scb->position = outscb->position; outscb->position = SCB_LIST_NULL; - STAILQ_INSERT_HEAD(&ahc->page_scbs, - outscb, links); - outb(SCBPTR + iobase, scb->position); + SIMPLEQ_INSERT_HEAD(&ahc->page_scbs, + outscb, links); + AHC_OUTB(ahc, SCBPTR, scb->position); ahc_send_scb(ahc, scb); scb->flags &= ~SCB_PAGED_OUT; + goto pagein_done; } - else if(ahc->assigned_scbs.stqh_first) { - outscb = ahc->assigned_scbs.stqh_first; - STAILQ_REMOVE_HEAD(&ahc->assigned_scbs, - links); + if((outscb = ahc->assigned_scbs.sqh_first) != NULL) { + SIMPLEQ_REMOVE_HEAD(&ahc->assigned_scbs, + outscb, links); scb->position = outscb->position; outscb->position = SCB_LIST_NULL; - STAILQ_INSERT_HEAD(&ahc->waiting_scbs, - outscb, links); + SIMPLEQ_INSERT_HEAD(&ahc->waiting_scbs, + outscb, links); outscb->flags = SCB_WAITINGQ; - outb(SCBPTR + iobase, scb->position); + AHC_OUTB(ahc, SCBPTR, scb->position); ahc_send_scb(ahc, scb); scb->flags &= ~SCB_PAGED_OUT; + goto pagein_done; } - else if(intstat & CMDCMPLT) { + if(intstat & CMDCMPLT) { int scb_index; printf("PIC\n"); - outb(CLRINT + iobase, CLRCMDINT); - scb_index = inb(QOUTFIFO + iobase); - if(!(inb(QOUTCNT + iobase) & ahc->qcntmask)) + AHC_OUTB(ahc, CLRINT, CLRCMDINT); + scb_index = AHC_INB(ahc, QOUTFIFO); + if(!(AHC_INB(ahc, QOUTCNT) & ahc->qcntmask)) intstat &= ~CMDCMPLT; outscb = ahc->scbarray[scb_index]; if (!outscb || !(outscb->flags & SCB_ACTIVE)) { - printf(AHCNAME_FMT - ": WARNING " + printf("%s: WARNING " "no command for scb %d (cmdcmplt)\n", - AHCNAME_VAR(ahc), - scb_index ); - goto use_disconnected_scb; + ahc_name(ahc), + scb_index); + /* Fall through in hopes of finding another SCB */ } else { scb->position = outscb->position; outscb->position = SCB_LIST_NULL; - outb(SCBPTR + iobase, scb->position); + AHC_OUTB(ahc, SCBPTR, scb->position); ahc_send_scb(ahc, scb); scb->flags &= ~SCB_PAGED_OUT; untimeout(ahc_timeout, (caddr_t)outscb); ahc_done(ahc, outscb); + goto pagein_done; } } - else { - u_char tag; - u_char next; - u_char disc_scb; -use_disconnected_scb: - disc_scb = - inb(DISCONNECTED_SCBH + iobase); - if(disc_scb == SCB_LIST_NULL) - panic("Page-in request with no " - "candidates"); - outb(SCBPTR + iobase, disc_scb); - tag = inb(SCB_TAG + iobase); + disc_scb = AHC_INB(ahc, DISCONNECTED_SCBH); + if(disc_scb != SCB_LIST_NULL) { + AHC_OUTB(ahc, SCBPTR, disc_scb); + tag = AHC_INB(ahc, SCB_TAG); outscb = ahc->scbarray[tag]; - next = inb(SCB_NEXT + iobase); + next = AHC_INB(ahc, SCB_NEXT); if(next != SCB_LIST_NULL) { - outb(SCBPTR + iobase, next); - outb(SCB_PREV + iobase, + AHC_OUTB(ahc, SCBPTR, next); + AHC_OUTB(ahc, SCB_PREV, SCB_LIST_NULL); - outb(SCBPTR + iobase, disc_scb); + AHC_OUTB(ahc, SCBPTR, disc_scb); } - outb(DISCONNECTED_SCBH + iobase, next); + AHC_OUTB(ahc, DISCONNECTED_SCBH, next); ahc_page_scb(ahc, outscb, scb); } - outb(RETURN_1 + iobase, SCB_PAGEDIN); + else if(AHC_INB(ahc, QINCNT) & ahc->qcntmask) { + /* Pull one of our queued commands as a last resort */ + disc_scb = AHC_INB(ahc, QINFIFO); + AHC_OUTB(ahc, SCBPTR, disc_scb); + tag = AHC_INB(ahc, SCB_TAG); + outscb = ahc->scbarray[tag]; + if((outscb->control & 0x23) != TAG_ENB) { + /* + * This is not a simple tagged command + * so its position in the queue + * matters. Take the command at the + * end of the queue instead. + */ + int i; + int saved_queue[AHC_SCB_MAX]; + int queued = AHC_INB(ahc, QINCNT) & ahc->qcntmask; + + /* Count the command we removed already */ + saved_queue[0] = disc_scb; + queued++; + + /* Empty the input queue */ + for (i = 1; i < queued; i++) + saved_queue[i] = AHC_INB(ahc, QINFIFO); + + /* Put everyone back put the last entry */ + queued--; + for (i = 0; i < queued; i++) + AHC_OUTB(ahc, QINFIFO, saved_queue[i]); + + AHC_OUTB(ahc, SCBPTR, saved_queue[queued]); + tag = AHC_INB(ahc, SCB_TAG); + outscb = ahc->scbarray[tag]; + } + untimeout(ahc_timeout, (caddr_t)outscb); + scb->position = outscb->position; + outscb->position = SCB_LIST_NULL; + SIMPLEQ_INSERT_HEAD(&ahc->waiting_scbs, + outscb, links); + outscb->flags = SCB_WAITINGQ; + ahc_send_scb(ahc, scb); + scb->flags &= ~SCB_PAGED_OUT; + } + else + panic("Page-in request with no candidates"); +pagein_done: + AHC_OUTB(ahc, RETURN_1, SCB_PAGEDIN); } else { - printf(AHCNAME_FMT ":%c:%d: no active SCB for " + printf("%s:%c:%d: no active SCB for " "reconnecting target - " "issuing ABORT\n", - AHCNAME_VAR(ahc), channel, target); + ahc_name(ahc), channel, target); printf("SAVED_TCL == 0x%x\n", - inb(SAVED_TCL + iobase)); - ahc_unbusy_target(target, channel, iobase); - outb(SCB_CONTROL + iobase, 0); - outb(CLRSINT1 + iobase, CLRSELTIMEO); - outb(RETURN_1 + iobase, 0); + AHC_INB(ahc, SAVED_TCL)); + ahc_unbusy_target(ahc, target, channel); + AHC_OUTB(ahc, SCB_CONTROL, 0); + AHC_OUTB(ahc, CLRSINT1, CLRSELTIMEO); + AHC_OUTB(ahc, RETURN_1, 0); } break; case SDTR_MSG: @@ -1082,9 +1151,9 @@ use_disconnected_scb: * the sync negotiation message. So, we must * multiply by four */ - period = inb(ARG_1 + iobase) << 2; - offset = inb(ACCUM + iobase); - targ_scratch = inb(TARG_SCRATCH + iobase + period = AHC_INB(ahc, ARG_1) << 2; + offset = AHC_INB(ahc, ACCUM); + targ_scratch = AHC_INB(ahc, TARG_SCRATCH + scratch_offset); if(targ_scratch & WIDEXFER) maxoffset = 0x08; @@ -1095,9 +1164,9 @@ use_disconnected_scb: target); /* Preserve the WideXfer flag */ targ_scratch = rate | (targ_scratch & WIDEXFER); - outb(TARG_SCRATCH + iobase + scratch_offset, + AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset, targ_scratch); - outb(SCSIRATE + iobase, targ_scratch); + AHC_OUTB(ahc, SCSIRATE, targ_scratch); if( (targ_scratch & 0x0f) == 0 ) { /* @@ -1109,7 +1178,7 @@ use_disconnected_scb: * ensure we go to asyncronous * transfers. */ - outb(RETURN_1 + iobase, SEND_REJ); + AHC_OUTB(ahc, RETURN_1, SEND_REJ); } /* See if we initiated Sync Negotiation */ else if(ahc->sdtrpending & targ_mask) @@ -1118,7 +1187,7 @@ use_disconnected_scb: * Don't send an SDTR back to * the target */ - outb(RETURN_1 + iobase, 0); + AHC_OUTB(ahc, RETURN_1, 0); } else{ /* @@ -1128,7 +1197,7 @@ use_disconnected_scb: if(ahc_debug & AHC_SHOWMISC) printf("Sending SDTR!!\n"); #endif - outb(RETURN_1 + iobase, SEND_SDTR); + AHC_OUTB(ahc, RETURN_1, SEND_SDTR); } /* * Negate the flags @@ -1141,9 +1210,9 @@ use_disconnected_scb: { u_char scratch, bus_width; - bus_width = inb(ARG_1 + iobase); + bus_width = AHC_INB(ahc, ARG_1); - scratch = inb(TARG_SCRATCH + iobase + scratch = AHC_INB(ahc, TARG_SCRATCH + scratch_offset); if(ahc->wdtrpending & targ_mask) @@ -1152,7 +1221,7 @@ use_disconnected_scb: * Don't send a WDTR back to the * target, since we asked first. */ - outb(RETURN_1 + iobase, 0); + AHC_OUTB(ahc, RETURN_1, 0); switch(bus_width) { case BUS_8_BIT: @@ -1160,11 +1229,10 @@ use_disconnected_scb: break; case BUS_16_BIT: if(bootverbose) - printf(AHCNAME_FMT - ": target " + printf("%s: target " "%d using 16Bit " "transfers\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), target); scratch |= 0x80; break; @@ -1174,14 +1242,13 @@ use_disconnected_scb: * transfers on a 16bit * bus? */ - outb(RETURN_1 + iobase, + AHC_OUTB(ahc, RETURN_1, SEND_REJ); - printf(AHCNAME_FMT - ": target " + printf("%s: target " "%d requested 32Bit " "transfers. " "Rejecting...\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), target); break; default: @@ -1203,12 +1270,11 @@ use_disconnected_scb: /* Negotiate 16_BITS */ bus_width = BUS_16_BIT; if(bootverbose) - printf(AHCNAME_FMT - ": " + printf("%s: " "target %d " "using 16Bit " "transfers\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), target); scratch |= 0x80; } @@ -1218,14 +1284,14 @@ use_disconnected_scb: default: break; } - outb(RETURN_1 + iobase, + AHC_OUTB(ahc, RETURN_1, bus_width | SEND_WDTR); } ahc->needwdtr &= ~targ_mask; ahc->wdtrpending &= ~targ_mask; - outb(TARG_SCRATCH + iobase + scratch_offset, + AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset, scratch); - outb(SCSIRATE + iobase, scratch); + AHC_OUTB(ahc, SCSIRATE, scratch); break; } case REJECT_MSG: @@ -1239,7 +1305,7 @@ use_disconnected_scb: u_char targ_scratch; - targ_scratch = inb(TARG_SCRATCH + iobase + targ_scratch = AHC_INB(ahc, TARG_SCRATCH + scratch_offset); if(ahc->wdtrpending & targ_mask){ @@ -1247,10 +1313,10 @@ use_disconnected_scb: targ_scratch &= 0x7f; ahc->needwdtr &= ~targ_mask; ahc->wdtrpending &= ~targ_mask; - printf(AHCNAME_FMT ":%c:%d: refuses " + printf("%s:%c:%d: refuses " "WIDE negotiation. Using " "8bit transfers\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), channel, target); } else if(ahc->sdtrpending & targ_mask){ @@ -1258,10 +1324,10 @@ use_disconnected_scb: targ_scratch &= 0xf0; ahc->needsdtr &= ~targ_mask; ahc->sdtrpending &= ~targ_mask; - printf(AHCNAME_FMT ":%c:%d: refuses " + printf("%s:%c:%d: refuses " "syncronous negotiation. Using " "asyncronous transfers\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), channel, target); } else { @@ -1270,17 +1336,16 @@ use_disconnected_scb: */ #ifdef AHC_DEBUG if(ahc_debug & AHC_SHOWMISC) - printf(AHCNAME_FMT - ":%c:%d: Message " + printf("%s:%c:%d: Message " "reject -- ignored\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), channel, target); #endif break; } - outb(TARG_SCRATCH + iobase + scratch_offset, + AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset, targ_scratch); - outb(SCSIRATE + iobase, targ_scratch); + AHC_OUTB(ahc, SCSIRATE, targ_scratch); break; } case BAD_STATUS: @@ -1294,7 +1359,7 @@ use_disconnected_scb: * without error. */ - scb_index = inb(SCB_TAG + iobase); + scb_index = AHC_INB(ahc, SCB_TAG); scb = ahc->scbarray[scb_index]; /* @@ -1303,11 +1368,11 @@ use_disconnected_scb: * this if needed and this reduces code * duplication. */ - outb(RETURN_1 + iobase, 0); + AHC_OUTB(ahc, RETURN_1, 0); if (!(scb && (scb->flags & SCB_ACTIVE))) { - printf(AHCNAME_FMT ":%c:%d: ahc_intr - referenced scb " + printf("%s:%c:%d: ahc_intr - referenced scb " "not valid during seqint 0x%x scb(%d)\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), channel, target, intstat, scb_index); goto clear; @@ -1315,7 +1380,7 @@ use_disconnected_scb: xs = scb->xs; - scb->status = inb(SCB_TARGET_STATUS + iobase); + scb->status = AHC_INB(ahc, SCB_TARGET_STATUS); #ifdef AHC_DEBUG if((ahc_debug & AHC_SHOWSCBS) @@ -1325,8 +1390,8 @@ use_disconnected_scb: xs->status = scb->status; switch(scb->status){ case SCSI_OK: - printf(AHCNAME_FMT ": Interrupted for staus of" - " 0???\n", AHCNAME_VAR(ahc)); + printf("%s: Interrupted for staus of" + " 0???\n", ahc_name(ahc)); break; case SCSI_CHECK: #ifdef AHC_DEBUG @@ -1366,8 +1431,8 @@ use_disconnected_scb: scb->SG_list_pointer = KVTOPHYS(sg); scb->data = sg->addr; scb->datalen = sg->len; -#ifdef AIC7XXX_BROKEN_CACHE - if (aic7xxx_broken_cache) +#ifdef AHC_BROKEN_CACHE + if (ahc_broken_cache) INVALIDATE_CACHE(); #endif scb->cmdpointer = KVTOPHYS(sc); @@ -1381,13 +1446,13 @@ use_disconnected_scb: * commands if we happen to be doing * tagged I/O. */ - ahc_busy_target(target,channel,iobase); + ahc_busy_target(ahc, target, channel); /* * Make us the next command to run */ - ahc_add_waiting_scb(iobase, scb); - outb(RETURN_1 + iobase, SEND_SENSE); + ahc_add_waiting_scb(ahc, scb); + AHC_OUTB(ahc, RETURN_1, SEND_SENSE); break; } /* @@ -1415,7 +1480,7 @@ use_disconnected_scb: sc_print_addr(xs->sc_link); printf("Queue Full\n"); scb->flags = SCB_ASSIGNEDQ; - STAILQ_INSERT_TAIL(&ahc->assigned_scbs, + SIMPLEQ_INSERT_TAIL(&ahc->assigned_scbs, scb, links); break; #elif defined(__NetBSD__) @@ -1438,7 +1503,7 @@ use_disconnected_scb: case RESIDUAL: { int scb_index; - scb_index = inb(SCB_TAG + iobase); + scb_index = AHC_INB(ahc, SCB_TAG); scb = ahc->scbarray[scb_index]; xs = scb->xs; /* @@ -1454,16 +1519,16 @@ use_disconnected_scb: * stopped. */ xs->resid = - (inb(iobase+SCB_RESID_DCNT2)<<16) | - (inb(iobase+SCB_RESID_DCNT1)<<8) | - inb(iobase+SCB_RESID_DCNT0); + (AHC_INB(ahc, SCB_RESID_DCNT2)<<16) | + (AHC_INB(ahc, SCB_RESID_DCNT1)<<8) | + AHC_INB(ahc, SCB_RESID_DCNT0); /* * Add up the contents of all residual * SG segments that are after the SG where * the transfer stopped. */ - resid_sgs = inb(SCB_RESID_SGCNT + iobase) - 1; + resid_sgs = AHC_INB(ahc, SCB_RESID_SGCNT) - 1; while(resid_sgs > 0) { int sg; @@ -1490,7 +1555,7 @@ use_disconnected_scb: case ABORT_TAG: { int scb_index; - scb_index = inb(SCB_TAG + iobase); + scb_index = AHC_INB(ahc, SCB_TAG); scb = ahc->scbarray[scb_index]; xs = scb->xs; /* @@ -1507,7 +1572,7 @@ use_disconnected_scb: case AWAITING_MSG: { int scb_index; - scb_index = inb(SCB_TAG + iobase); + scb_index = AHC_INB(ahc, SCB_TAG); scb = ahc->scbarray[scb_index]; /* * This SCB had a zero length command, informing @@ -1517,9 +1582,9 @@ use_disconnected_scb: */ if(scb->flags & SCB_DEVICE_RESET) { - outb(MSG0 + iobase, + AHC_OUTB(ahc, MSG0, MSG_BUS_DEVICE_RESET); - outb(MSG_LEN + iobase, 1); + AHC_OUTB(ahc, MSG_LEN, 1); printf("Bus Device Reset Message Sent\n"); } else @@ -1532,7 +1597,7 @@ use_disconnected_scb: /* * Take care of device reset messages */ - u_char scbindex = inb(SCB_TAG + iobase); + u_char scbindex = AHC_INB(ahc, SCB_TAG); scb = ahc->scbarray[scbindex]; if(scb->flags & SCB_DEVICE_RESET) { u_char targ_scratch; @@ -1541,15 +1606,15 @@ use_disconnected_scb: * Go back to async/narrow transfers and * renegotiate. */ - ahc_unbusy_target(target, channel, iobase); + ahc_unbusy_target(ahc, target, channel); ahc->needsdtr |= ahc->needsdtr_orig & targ_mask; ahc->needwdtr |= ahc->needwdtr_orig & targ_mask; ahc->sdtrpending &= ~targ_mask; ahc->wdtrpending &= ~targ_mask; - targ_scratch = inb(TARG_SCRATCH + iobase + targ_scratch = AHC_INB(ahc, TARG_SCRATCH + scratch_offset); targ_scratch &= SXFR; - outb(TARG_SCRATCH + iobase + scratch_offset, + AHC_OUTB(ahc, TARG_SCRATCH + scratch_offset, targ_scratch); found = ahc_reset_device(ahc, target, channel, SCB_LIST_NULL, @@ -1575,7 +1640,7 @@ use_disconnected_scb: default: printf("ahc_intr: seqint, " "intstat == 0x%x, scsisigi = 0x%x\n", - intstat, inb(SCSISIGI + iobase)); + intstat, AHC_INB(ahc, SCSISIGI)); break; } clear: @@ -1583,7 +1648,7 @@ clear: * Clear the upper byte that holds SEQINT status * codes and clear the SEQINT bit. */ - outb(CLRINT + iobase, CLRSEQINT); + AHC_OUTB(ahc, CLRINT, CLRSEQINT); /* * The sequencer is paused immediately on @@ -1596,8 +1661,8 @@ clear: if (intstat & SCSIINT) { - int scb_index = inb(SCB_TAG + iobase); - status = inb(SSTAT1 + iobase); + int scb_index = AHC_INB(ahc, SCB_TAG); + status = AHC_INB(ahc, SSTAT1); scb = ahc->scbarray[scb_index]; if (scb != NULL) /* XXX - is this case exist ? */ @@ -1605,10 +1670,10 @@ clear: if (status & SCSIRSTI) { char channel; - channel = inb(SBLKCTL + iobase); + channel = AHC_INB(ahc, SBLKCTL); channel = channel & SELBUSB ? 'B' : 'A'; - printf(AHCNAME_FMT ": Someone reset channel %c\n", - AHCNAME_VAR(ahc), channel); + printf("%s: Someone reset channel %c\n", + ahc_name(ahc), channel); ahc_reset_channel(ahc, channel, SCB_LIST_NULL, @@ -1617,12 +1682,12 @@ clear: scb = NULL; } else if (!(scb && (scb->flags & SCB_ACTIVE))){ - printf(AHCNAME_FMT ": ahc_intr - referenced scb not " + printf("%s: ahc_intr - referenced scb not " "valid during scsiint 0x%x scb(%d)\n", - AHCNAME_VAR(ahc), status, scb_index); - outb(CLRSINT1 + iobase, status); + ahc_name(ahc), status, scb_index); + AHC_OUTB(ahc, CLRSINT1, status); UNPAUSE_SEQUENCER(ahc); - outb(CLRINT + iobase, CLRSCSIINT); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); scb = NULL; } else if (status & SCSIPERR) { @@ -1632,7 +1697,7 @@ clear: */ char *phase; u_char mesg_out = MSG_NOP; - u_char lastphase = inb(LASTPHASE + iobase); + u_char lastphase = AHC_INB(ahc, LASTPHASE); sc_print_addr(xs->sc_link); @@ -1672,8 +1737,8 @@ clear: * mesg_out to something other than MSG_NOP. */ if(mesg_out != MSG_NOP) { - outb(MSG0 + iobase, mesg_out); - outb(MSG_LEN + iobase, 1); + AHC_OUTB(ahc, MSG0, mesg_out); + AHC_OUTB(ahc, MSG_LEN, 1); } else /* @@ -1690,37 +1755,36 @@ clear: * Clear any pending messages for the timed out * target, and mark the target as free */ - flags = inb(FLAGS + iobase); - outb(MSG_LEN + iobase, 0); - ahc_unbusy_target(xs->sc_link->target, + flags = AHC_INB(ahc, FLAGS); + AHC_OUTB(ahc, MSG_LEN, 0); + ahc_unbusy_target(ahc, xs->sc_link->target, #if defined(__FreeBSD__) ((long)xs->sc_link->fordriver & SELBUSB) #elif defined(__NetBSD__) IS_SCSIBUS_B(ahc, xs->sc_link) #endif - ? 'B' : 'A', - iobase); + ? 'B' : 'A'); - outb(SCB_CONTROL + iobase, 0); + AHC_OUTB(ahc, SCB_CONTROL, 0); - outb(CLRSINT1 + iobase, CLRSELTIMEO); + AHC_OUTB(ahc, CLRSINT1, CLRSELTIMEO); - outb(CLRINT + iobase, CLRSCSIINT); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); /* Shift the waiting for selection queue forward */ - waiting = inb(WAITING_SCBH + iobase); - outb(SCBPTR + iobase, waiting); - waiting = inb(SCB_NEXT + iobase); - outb(WAITING_SCBH + iobase, waiting); + waiting = AHC_INB(ahc, WAITING_SCBH); + AHC_OUTB(ahc, SCBPTR, waiting); + waiting = AHC_INB(ahc, SCB_NEXT); + AHC_OUTB(ahc, WAITING_SCBH, waiting); RESTART_SEQUENCER(ahc); } else if (!(status & BUSFREE)) { sc_print_addr(xs->sc_link); printf("Unknown SCSIINT. Status = 0x%x\n", status); - outb(CLRSINT1 + iobase, status); + AHC_OUTB(ahc, CLRSINT1, status); UNPAUSE_SEQUENCER(ahc); - outb(CLRINT + iobase, CLRSCSIINT); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); scb = NULL; } if(scb != NULL) { @@ -1733,22 +1797,22 @@ clear: int scb_index; do { - scb_index = inb(QOUTFIFO + iobase); + scb_index = AHC_INB(ahc, QOUTFIFO); scb = ahc->scbarray[scb_index]; if (!scb || !(scb->flags & SCB_ACTIVE)) { - printf(AHCNAME_FMT ": WARNING " + printf("%s: WARNING " "no command for scb %d (cmdcmplt)\n" "QOUTCNT == %d\n", - AHCNAME_VAR(ahc), scb_index, - inb(QOUTCNT + iobase)); - outb(CLRINT + iobase, CLRCMDINT); + ahc_name(ahc), scb_index, + AHC_INB(ahc, QOUTCNT)); + AHC_OUTB(ahc, CLRINT, CLRCMDINT); continue; } - outb(CLRINT + iobase, CLRCMDINT); + AHC_OUTB(ahc, CLRINT, CLRCMDINT); untimeout(ahc_timeout, (caddr_t)scb); ahc_done(ahc, scb); - } while (inb(QOUTCNT + iobase) & ahc->qcntmask); + } while (AHC_INB(ahc, QOUTCNT) & ahc->qcntmask); ahc_run_waiting_queues(ahc); } @@ -1811,9 +1875,8 @@ ahc_done(ahc, scb) inq_data = (struct scsi_inquiry_data *)xs->data; if((inq_data->flags & SID_CmdQue) && !(ahc->tagenable & mask)) { - printf(AHCNAME_FMT - ": target %d Tagged Queuing Device\n", - AHCNAME_VAR(ahc), xs->sc_link->target); + printf("%s: target %d Tagged Queuing Device\n", + ahc_name(ahc), xs->sc_link->target); ahc->tagenable |= mask; if(ahc->maxhscbs >= 16 || (ahc->flags & AHC_PAGESCBS)) { /* Default to 8 tags */ @@ -1845,7 +1908,6 @@ int ahc_init(ahc) struct ahc_data *ahc; { - u_long iobase = ahc->baseport; u_char scsi_conf, sblkctl, i; int max_targ = 15; /* @@ -1858,19 +1920,21 @@ ahc_init(ahc) #endif /* Determine channel configuration and who we are on the scsi bus. */ - switch ( (sblkctl = inb(SBLKCTL + iobase) & 0x0a) ) { + switch ( (sblkctl = AHC_INB(ahc, SBLKCTL) & 0x0a) ) { case 0: - ahc->our_id = (inb(SCSICONF + iobase) & HSCSIID); + ahc->our_id = (AHC_INB(ahc, SCSICONF) & HSCSIID); + ahc->flags &= ~AHC_CHANNEL_B_PRIMARY; if(ahc->type == AHC_394) printf("Channel %c, SCSI Id=%d, ", ahc->flags & AHC_CHNLB ? 'B' : 'A', ahc->our_id); else printf("Single Channel, SCSI Id=%d, ", ahc->our_id); - outb(FLAGS + iobase, SINGLE_BUS | (ahc->flags & AHC_PAGESCBS)); + AHC_OUTB(ahc, FLAGS, SINGLE_BUS | (ahc->flags & AHC_PAGESCBS)); break; case 2: - ahc->our_id = (inb(SCSICONF + 1 + iobase) & HWSCSIID); + ahc->our_id = (AHC_INB(ahc, SCSICONF + 1) & HWSCSIID); + ahc->flags &= ~AHC_CHANNEL_B_PRIMARY; if(ahc->type == AHC_394) printf("Wide Channel %c, SCSI Id=%d, ", ahc->flags & AHC_CHNLB ? 'B' : 'A', @@ -1878,15 +1942,15 @@ ahc_init(ahc) else printf("Wide Channel, SCSI Id=%d, ", ahc->our_id); ahc->type |= AHC_WIDE; - outb(FLAGS + iobase, WIDE_BUS | (ahc->flags & AHC_PAGESCBS)); + AHC_OUTB(ahc, FLAGS, WIDE_BUS | (ahc->flags & AHC_PAGESCBS)); break; case 8: - ahc->our_id = (inb(SCSICONF + iobase) & HSCSIID); - ahc->our_id_b = (inb(SCSICONF + 1 + iobase) & HSCSIID); + ahc->our_id = (AHC_INB(ahc, SCSICONF) & HSCSIID); + ahc->our_id_b = (AHC_INB(ahc, SCSICONF + 1) & HSCSIID); printf("Twin Channel, A SCSI Id=%d, B SCSI Id=%d, ", ahc->our_id, ahc->our_id_b); ahc->type |= AHC_TWIN; - outb(FLAGS + iobase, TWIN_BUS | (ahc->flags & AHC_PAGESCBS)); + AHC_OUTB(ahc, FLAGS, TWIN_BUS | (ahc->flags & AHC_PAGESCBS)); break; default: printf(" Unsupported adapter type. Ignoring\n"); @@ -1896,26 +1960,26 @@ ahc_init(ahc) /* Determine the number of SCBs */ { - outb(SCBPTR + iobase, 0); - outb(SCB_CONTROL + iobase, 0); + AHC_OUTB(ahc, SCBPTR, 0); + AHC_OUTB(ahc, SCB_CONTROL, 0); for(i = 1; i < AHC_SCB_MAX; i++) { - outb(SCBPTR + iobase, i); - outb(SCB_CONTROL + iobase, i); - if(inb(SCB_CONTROL + iobase) != i) + AHC_OUTB(ahc, SCBPTR, i); + AHC_OUTB(ahc, SCB_CONTROL, i); + if(AHC_INB(ahc, SCB_CONTROL) != i) break; - outb(SCBPTR + iobase, 0); - if(inb(SCB_CONTROL + iobase) != 0) + AHC_OUTB(ahc, SCBPTR, 0); + if(AHC_INB(ahc, SCB_CONTROL) != 0) break; /* Clear the control byte. */ - outb(SCBPTR + iobase, i); - outb(SCB_CONTROL + iobase, 0); + AHC_OUTB(ahc, SCBPTR, i); + AHC_OUTB(ahc, SCB_CONTROL, 0); ahc->qcntmask |= i; /* Update the count mask. */ } /* Ensure we clear the 0 SCB's control byte. */ - outb(SCBPTR + iobase, 0); - outb(SCB_CONTROL + iobase, 0); + AHC_OUTB(ahc, SCBPTR, 0); + AHC_OUTB(ahc, SCB_CONTROL, 0); ahc->qcntmask |= i; ahc->maxhscbs = i; @@ -1933,9 +1997,9 @@ ahc_init(ahc) #ifdef AHC_DEBUG if(ahc_debug & AHC_SHOWMISC) { struct scb test; - printf(AHCNAME_FMT ": hardware scb %ld bytes; kernel scb; " + printf("%s: hardware scb %ld bytes; kernel scb; " "ahc_dma %d bytes\n", - AHCNAME_VAR(ahc), + ahc_name(ahc), (u_long)&(test.next) - (u_long)(&test), sizeof(test), sizeof(struct ahc_dma_seg)); @@ -1949,44 +2013,56 @@ ahc_init(ahc) * The device is gated to channel B after a chip reset, * so set those values first */ - outb(SCSIID + iobase, ahc->our_id_b); - scsi_conf = inb(SCSICONF + 1 + iobase) & (ENSPCHK|STIMESEL); - outb(SXFRCTL1 + iobase, scsi_conf|ENSTIMER|ACTNEGEN|STPWEN); - outb(SIMODE1 + iobase, ENSELTIMO|ENSCSIRST|ENSCSIPERR); + AHC_OUTB(ahc, SCSIID, ahc->our_id_b); + scsi_conf = AHC_INB(ahc, SCSICONF + 1); + AHC_OUTB(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL)) + | ENSTIMER|ACTNEGEN|STPWEN); + AHC_OUTB(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR); if(ahc->type & AHC_ULTRA) - outb(SXFRCTL0 + iobase, DFON|SPIOEN|ULTRAEN); + AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN|ULTRAEN); else - outb(SXFRCTL0 + iobase, DFON|SPIOEN); - - /* Reset the bus */ - outb(SCSISEQ + iobase, SCSIRSTO); - DELAY(1000); - outb(SCSISEQ + iobase, 0); - - /* Ensure we don't get a RSTI interrupt from this */ - outb(CLRSINT1 + iobase, CLRSCSIRSTI); - outb(CLRINT + iobase, CLRSCSIINT); + AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN); + + if(scsi_conf & RESET_SCSI) { + /* Reset the bus */ + if(bootverbose) + printf("%s: Reseting Channel B\n", + ahc_name(ahc)); + AHC_OUTB(ahc, SCSISEQ, SCSIRSTO); + DELAY(1000); + AHC_OUTB(ahc, SCSISEQ, 0); + + /* Ensure we don't get a RSTI interrupt from this */ + AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); + } /* Select Channel A */ - outb(SBLKCTL + iobase, 0); + AHC_OUTB(ahc, SBLKCTL, 0); } - outb(SCSIID + iobase, ahc->our_id); - scsi_conf = inb(SCSICONF + iobase) & (ENSPCHK|STIMESEL); - outb(SXFRCTL1 + iobase, scsi_conf|ENSTIMER|ACTNEGEN|STPWEN); - outb(SIMODE1 + iobase, ENSELTIMO|ENSCSIRST|ENSCSIPERR); + AHC_OUTB(ahc, SCSIID, ahc->our_id); + scsi_conf = AHC_INB(ahc, SCSICONF); + AHC_OUTB(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL)) + | ENSTIMER|ACTNEGEN|STPWEN); + AHC_OUTB(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR); if(ahc->type & AHC_ULTRA) - outb(SXFRCTL0 + iobase, DFON|SPIOEN|ULTRAEN); + AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN|ULTRAEN); else - outb(SXFRCTL0 + iobase, DFON|SPIOEN); + AHC_OUTB(ahc, SXFRCTL0, DFON|SPIOEN); - /* Reset the bus */ - outb(SCSISEQ + iobase, SCSIRSTO); - DELAY(1000); - outb(SCSISEQ + iobase, 0); + if(scsi_conf & RESET_SCSI) { + /* Reset the bus */ + if(bootverbose) + printf("%s: Reseting Channel A\n", ahc_name(ahc)); + + AHC_OUTB(ahc, SCSISEQ, SCSIRSTO); + DELAY(1000); + AHC_OUTB(ahc, SCSISEQ, 0); - /* Ensure we don't get a RSTI interrupt from this */ - outb(CLRSINT1 + iobase, CLRSCSIRSTI); - outb(CLRINT + iobase, CLRSCSIINT); + /* Ensure we don't get a RSTI interrupt from this */ + AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); + } /* * Look at the information that board initialization or @@ -2002,14 +2078,13 @@ ahc_init(ahc) /* Grab the disconnection disable table and invert it for our needs */ if(ahc->flags & AHC_USEDEFAULTS) { - printf(AHCNAME_FMT - ": Host Adapter Bios disabled. Using default SCSI " - "device parameters\n", AHCNAME_VAR(ahc)); + printf("%s: Host Adapter Bios disabled. Using default SCSI " + "device parameters\n", ahc_name(ahc)); ahc->discenable = 0xff; } else - ahc->discenable = ~((inb(DISC_DSB + iobase + 1) << 8) - | inb(DISC_DSB + iobase)); + ahc->discenable = ~((AHC_INB(ahc, DISC_DSB + 1) << 8) + | AHC_INB(ahc, DISC_DSB)); if(!(ahc->type & (AHC_WIDE|AHC_TWIN))) max_targ = 7; @@ -2023,7 +2098,7 @@ ahc_init(ahc) } else { /* Take the settings leftover in scratch RAM. */ - target_settings = inb(TARG_SCRATCH + i + iobase); + target_settings = AHC_INB(ahc, TARG_SCRATCH + i); if(target_settings & 0x0f){ ahc->needsdtr_orig |= (0x01 << i); @@ -2041,7 +2116,7 @@ ahc_init(ahc) target_settings &= 0x7f; } } - outb(TARG_SCRATCH+i+iobase,target_settings); + AHC_OUTB(ahc, TARG_SCRATCH+i,target_settings); } /* * If we are not a WIDE device, forget WDTR. This @@ -2068,50 +2143,50 @@ ahc_init(ahc) /* * Set the number of availible SCBs */ - outb(SCBCOUNT + iobase, ahc->maxhscbs); + AHC_OUTB(ahc, SCBCOUNT, ahc->maxhscbs); /* * 2's compliment of maximum tag value */ i = ahc->maxscbs; - outb(COMP_SCBCOUNT + iobase, -i & 0xff); + AHC_OUTB(ahc, COMP_SCBCOUNT, -i & 0xff); /* * QCount mask to deal with broken aic7850s that * sporatically get garbage in the upper bits of * their QCount registers. */ - outb(QCNTMASK + iobase, ahc->qcntmask); + AHC_OUTB(ahc, QCNTMASK, ahc->qcntmask); /* We don't have any busy targets right now */ - outb(ACTIVE_A + iobase, 0); - outb(ACTIVE_B + iobase, 0); + AHC_OUTB(ahc, ACTIVE_A, 0); + AHC_OUTB(ahc, ACTIVE_B, 0); /* We don't have any waiting selections */ - outb(WAITING_SCBH + iobase, SCB_LIST_NULL); + AHC_OUTB(ahc, WAITING_SCBH, SCB_LIST_NULL); /* Our disconnection list is empty too */ - outb(DISCONNECTED_SCBH + iobase, SCB_LIST_NULL); + AHC_OUTB(ahc, DISCONNECTED_SCBH, SCB_LIST_NULL); /* Message out buffer starts empty */ - outb(MSG_LEN + iobase, 0x00); + AHC_OUTB(ahc, MSG_LEN, 0x00); /* * Load the Sequencer program and Enable the adapter * in "fast" mode. */ if(bootverbose) - printf(AHCNAME_FMT ": Downloading Sequencer Program...", - AHCNAME_VAR(ahc)); + printf("%s: Downloading Sequencer Program...", + ahc_name(ahc)); - ahc_loadseq(iobase); + ahc_loadseq(ahc); if(bootverbose) printf("Done\n"); - outb(SEQCTL + iobase, FASTMODE); + AHC_OUTB(ahc, SEQCTL, FASTMODE); - UNPAUSE_SEQUENCER(ahc); + UNPAUSE_SEQUENCER(ahc); /* * Note that we are going and return (to probe) @@ -2173,11 +2248,11 @@ ahc_scsi_cmd(xs) */ flags = xs->flags; if (flags & ITSDONE) { - printf(AHCNAME_FMT ": Already done?", AHCNAME_VAR(ahc)); + printf("%s: Already done?", ahc_name(ahc)); xs->flags &= ~ITSDONE; } if (!(flags & INUSE)) { - printf(AHCNAME_FMT ": Not in use?", AHCNAME_VAR(ahc)); + printf("%s: Not in use?", ahc_name(ahc)); xs->flags |= INUSE; } if (!(scb = ahc_get_scb(ahc, flags))) { @@ -2284,15 +2359,14 @@ ahc_scsi_cmd(xs) SC_DEBUGN(xs->sc_link, SDEV_DB4, ("\n")); if (datalen) { /* there's still data, must have run out of segs! */ - printf(AHCNAME_FMT - ": ahc_scsi_cmd: more than %d DMA segs\n", - AHCNAME_VAR(ahc), AHC_NSEG); + printf("%s: ahc_scsi_cmd: more than %d DMA segs\n", + ahc_name(ahc), AHC_NSEG); xs->error = XS_DRIVER_STUFFUP; ahc_free_scb(ahc, scb, flags); return (COMPLETE); } -#ifdef AIC7XXX_BROKEN_CACHE - if (aic7xxx_broken_cache) +#ifdef AHC_BROKEN_CACHE + if (ahc_broken_cache) INVALIDATE_CACHE(); #endif } @@ -2315,15 +2389,14 @@ ahc_scsi_cmd(xs) if( scb->position != SCB_LIST_NULL ) { /* We already have a valid slot */ - u_long iobase = ahc->baseport; u_char curscb; PAUSE_SEQUENCER(ahc); - curscb = inb(SCBPTR + iobase); - outb(SCBPTR + iobase, scb->position); + curscb = AHC_INB(ahc, SCBPTR); + AHC_OUTB(ahc, SCBPTR, scb->position); ahc_send_scb(ahc, scb); - outb(SCBPTR + iobase, curscb); - outb(QINFIFO + iobase, scb->position); + AHC_OUTB(ahc, SCBPTR, curscb); + AHC_OUTB(ahc, QINFIFO, scb->position); UNPAUSE_SEQUENCER(ahc); scb->flags = SCB_ACTIVE; if (!(flags & SCSI_NOMASK)) { @@ -2334,7 +2407,7 @@ ahc_scsi_cmd(xs) } else { scb->flags = SCB_WAITINGQ; - STAILQ_INSERT_TAIL(&ahc->waiting_scbs, scb, links); + SIMPLEQ_INSERT_TAIL(&ahc->waiting_scbs, scb, links); ahc_run_waiting_queues(ahc); } if (!(flags & SCSI_NOMASK)) { @@ -2375,8 +2448,8 @@ ahc_free_scb(ahc, scb, flags) scb->flags = SCB_FREE; if(scb->position == SCB_LIST_NULL) { - STAILQ_INSERT_HEAD(&ahc->page_scbs, scb, links); - if(!scb->links.stqe_next && !ahc->free_scbs.stqh_first) + SIMPLEQ_INSERT_HEAD(&ahc->page_scbs, scb, links); + if(!scb->links.sqe_next && !ahc->free_scbs.sqh_first) /* * If there were no SCBs availible, wake anybody waiting * for one to come free. @@ -2390,10 +2463,10 @@ ahc_free_scb(ahc, scb, flags) * completes for a particular interrupt are completed * or when we start another command. */ - else if((wscb = ahc->waiting_scbs.stqh_first) != NULL) { + else if((wscb = ahc->waiting_scbs.sqh_first) != NULL) { + SIMPLEQ_REMOVE_HEAD(&ahc->waiting_scbs, wscb, links); wscb->position = scb->position; - STAILQ_REMOVE_HEAD(&ahc->waiting_scbs, links); - STAILQ_INSERT_HEAD(&ahc->assigned_scbs, wscb, links); + SIMPLEQ_INSERT_HEAD(&ahc->assigned_scbs, wscb, links); wscb->flags = SCB_ASSIGNEDQ; /* @@ -2402,8 +2475,8 @@ ahc_free_scb(ahc, scb, flags) * queue. */ scb->position = SCB_LIST_NULL; - STAILQ_INSERT_HEAD(&ahc->page_scbs, scb, links); - if(!scb->links.stqe_next && !ahc->free_scbs.stqh_first) + SIMPLEQ_INSERT_HEAD(&ahc->page_scbs, scb, links); + if(!scb->links.sqe_next && !ahc->free_scbs.sqh_first) /* * If there were no SCBs availible, wake anybody waiting * for one to come free. @@ -2411,11 +2484,11 @@ ahc_free_scb(ahc, scb, flags) wakeup((caddr_t)&ahc->free_scbs); } else { - STAILQ_INSERT_HEAD(&ahc->free_scbs, scb, links); + SIMPLEQ_INSERT_HEAD(&ahc->free_scbs, scb, links); #ifdef AHC_DEBUG ahc->activescbs--; #endif - if(!scb->links.stqe_next && !ahc->page_scbs.stqh_first) + if(!scb->links.sqe_next && !ahc->page_scbs.sqh_first) /* * If there were no SCBs availible, wake anybody waiting * for one to come free. @@ -2445,11 +2518,11 @@ ahc_get_scb(ahc, flags) * but only if we can't allocate a new one. */ while (1) { - if((scbp = ahc->free_scbs.stqh_first)) { - STAILQ_REMOVE_HEAD(&ahc->free_scbs, links); + if((scbp = ahc->free_scbs.sqh_first)) { + SIMPLEQ_REMOVE_HEAD(&ahc->free_scbs, scbp, links); } - else if((scbp = ahc->page_scbs.stqh_first)) { - STAILQ_REMOVE_HEAD(&ahc->page_scbs, links); + else if((scbp = ahc->page_scbs.sqh_first)) { + SIMPLEQ_REMOVE_HEAD(&ahc->page_scbs, scbp, links); } else if (ahc->numscbs < ahc->maxscbs) { scbp = (struct scb *) malloc(sizeof(struct scb), @@ -2469,8 +2542,8 @@ ahc_get_scb(ahc, flags) ahc->scbarray[scbp->tag] = scbp; } else { - printf(AHCNAME_FMT ": Can't malloc SCB\n", - AHCNAME_VAR(ahc)); + printf("%s: Can't malloc SCB\n", + ahc_name(ahc)); } } else { @@ -2491,8 +2564,7 @@ ahc_get_scb(ahc, flags) ahc->activescbs++; if((ahc_debug & AHC_SHOWSCBCNT) && (ahc->activescbs == ahc->maxhscbs)) - printf(AHCNAME_FMT ": Max SCBs active\n", - AHCNAME_VAR(ahc)); + printf("%s: Max SCBs active\n", ahc_name(ahc)); #endif } @@ -2501,23 +2573,23 @@ ahc_get_scb(ahc, flags) return (scbp); } -static void ahc_loadseq(iobase) - u_long iobase; +static void ahc_loadseq(ahc) + struct ahc_data *ahc; { static unsigned char seqprog[] = { # include "aic7xxx_seq.h" }; - outb(SEQCTL + iobase, PERRORDIS|SEQRESET|LOADRAM); + AHC_OUTB(ahc, SEQCTL, PERRORDIS|SEQRESET|LOADRAM); - outsb(SEQRAM + iobase, seqprog, sizeof(seqprog)); + AHC_OUTSB(ahc, SEQRAM, seqprog, sizeof(seqprog)); - outb(SEQCTL + iobase, FASTMODE|SEQRESET); + AHC_OUTB(ahc, SEQCTL, FASTMODE|SEQRESET); do { - outb(SEQCTL + iobase, SEQRESET|FASTMODE); + AHC_OUTB(ahc, SEQCTL, SEQRESET|FASTMODE); - } while (inb(SEQADDR0 + iobase) != 0 && - inb(SEQADDR1 + iobase) != 0); + } while (AHC_INB(ahc, SEQADDR0) != 0 && + AHC_INB(ahc, SEQADDR1) != 0); } /* @@ -2529,16 +2601,12 @@ ahc_poll(ahc, wait) struct ahc_data *ahc; int wait; /* in msec */ { - u_long iobase = ahc->baseport; - u_long stport = INTSTAT + iobase; - while (--wait) { DELAY(1000); - if (inb(stport) & INT_PEND) + if (AHC_INB(ahc, INTSTAT) & INT_PEND) break; } if (wait == 0) { - printf(AHCNAME_FMT ": board not responding\n", - AHCNAME_VAR(ahc)); + printf("%s: board not responding\n", ahc_name(ahc)); return (EIO); } ahc_intr((void *)ahc); @@ -2553,7 +2621,6 @@ ahc_timeout(arg) struct ahc_data *ahc; int s, h, found; u_char bus_state; - u_long iobase; char channel; s = splbio(); @@ -2580,8 +2647,8 @@ ahc_timeout(arg) * recovery SCB. Cut our losses and panic. Its * better to do this than trash a filesystem. */ - panic(AHCNAME_FMT ": Timed-out command times out " - "again\n", AHCNAME_VAR(ahc)); + panic("%s: Timed-out command times out " + "again\n", ahc_name(ahc)); } else if (!(scb->flags & SCB_ABORTED)) { @@ -2614,8 +2681,7 @@ ahc_timeout(arg) * Take a snapshot of the bus state and print out * some information so we can track down driver bugs. */ - iobase = ahc->baseport; - bus_state = inb(iobase + LASTPHASE); + bus_state = AHC_INB(ahc, LASTPHASE); switch(bus_state & PHASE_MASK) { @@ -2648,7 +2714,7 @@ ahc_timeout(arg) break; } - printf(", SCSISIGI == 0x%x\n", inb(iobase + SCSISIGI)); + printf(", SCSISIGI == 0x%x\n", AHC_INB(ahc, SCSISIGI)); /* Decide our course of action */ @@ -2662,8 +2728,8 @@ ahc_timeout(arg) ? 'B': 'A'; found = ahc_reset_channel(ahc, channel, scb->tag, XS_TIMEOUT, /*Initiate Reset*/TRUE); - printf(AHCNAME_FMT ": Issued Channel %c Bus Reset #1. " - "%d SCBs aborted\n", AHCNAME_VAR(ahc), channel, found); + printf("%s: Issued Channel %c Bus Reset #1. " + "%d SCBs aborted\n", ahc_name(ahc), channel, found); ahc->in_timeout = FALSE; } else if(scb->control & TAG_ENB) { @@ -2706,33 +2772,33 @@ ahc_timeout(arg) u_char active_scb; struct scb *active_scbp; - active_scb = inb(SCBPTR + iobase); - active_scbp = ahc->scbarray[inb(SCB_TAG + iobase)]; - outb(SCBPTR + iobase, scb->position); + active_scb = AHC_INB(ahc, SCBPTR); + active_scbp = ahc->scbarray[AHC_INB(ahc, SCB_TAG)]; + AHC_OUTB(ahc, SCBPTR, scb->position); - if(inb(SCB_CONTROL + iobase) & DISCONNECTED) { + if(AHC_INB(ahc, SCB_CONTROL) & DISCONNECTED) { if(ahc->flags & AHC_PAGESCBS) { /* * Pull this SCB out of the * disconnected list. */ - u_char prev = inb(SCB_PREV + iobase); - u_char next = inb(SCB_NEXT + iobase); + u_char prev = AHC_INB(ahc, SCB_PREV); + u_char next = AHC_INB(ahc, SCB_NEXT); if(prev == SCB_LIST_NULL) { /* At the head */ - outb(DISCONNECTED_SCBH + iobase, + AHC_OUTB(ahc, DISCONNECTED_SCBH, next ); } else { - outb(SCBPTR + iobase, prev); - outb(SCB_NEXT + iobase, next); + AHC_OUTB(ahc, SCBPTR, prev); + AHC_OUTB(ahc, SCB_NEXT, next); if(next != SCB_LIST_NULL) { - outb(SCBPTR + iobase, + AHC_OUTB(ahc, SCBPTR, next); - outb(SCB_PREV + iobase, + AHC_OUTB(ahc, SCB_PREV, prev); } - outb(SCBPTR + iobase, + AHC_OUTB(ahc, SCBPTR, scb->position); } } @@ -2744,19 +2810,19 @@ ahc_timeout(arg) scb->data = 0; scb->datalen = 0; ahc_send_scb(ahc, scb); - ahc_add_waiting_scb(iobase, scb); + ahc_add_waiting_scb(ahc, scb); timeout(ahc_timeout, (caddr_t)scb, (2 * hz)); sc_print_addr(scb->xs->sc_link); printf("BUS DEVICE RESET message queued.\n"); - outb(SCBPTR + iobase, active_scb); + AHC_OUTB(ahc, SCBPTR, active_scb); UNPAUSE_SEQUENCER(ahc); goto done; } /* Is the active SCB really active? */ else if((active_scbp->flags & SCB_ACTIVE) && bus_state){ - outb(MSG_LEN + iobase, 1); - outb(MSG0 + iobase, MSG_BUS_DEVICE_RESET); - outb(SCSISIGO + iobase, bus_state|ATNO); + AHC_OUTB(ahc, MSG_LEN, 1); + AHC_OUTB(ahc, MSG0, MSG_BUS_DEVICE_RESET); + AHC_OUTB(ahc, SCSISIGO, bus_state|ATNO); sc_print_addr(active_scbp->xs->sc_link); printf("asserted ATN - device reset in " "message buffer\n"); @@ -2771,7 +2837,7 @@ ahc_timeout(arg) } timeout(ahc_timeout, (caddr_t)active_scbp, (2 * hz)); - outb(SCBPTR + iobase, active_scb); + AHC_OUTB(ahc, SCBPTR, active_scb); UNPAUSE_SEQUENCER(ahc); goto done; } @@ -2784,8 +2850,8 @@ ahc_timeout(arg) found = ahc_reset_channel(ahc, channel, scb->tag, XS_TIMEOUT, /*Initiate Reset*/TRUE); - printf(AHCNAME_FMT ": Issued Channel %c Bus Reset #2. " - "%d SCBs aborted\n", AHCNAME_VAR(ahc), channel, + printf("%s: Issued Channel %c Bus Reset #2. " + "%d SCBs aborted\n", ahc_name(ahc), channel, found); ahc->in_timeout = FALSE; } @@ -2806,26 +2872,25 @@ ahc_reset_device(ahc, target, channel, timedout_scb, xs_error) u_char timedout_scb; u_int32_t xs_error; { - u_long iobase = ahc->baseport; struct scb *scbp; u_char active_scb; int i = 0; int found = 0; /* restore this when we're done */ - active_scb = inb(SCBPTR + iobase); + active_scb = AHC_INB(ahc, SCBPTR); /* * Search the QINFIFO. */ { int saved_queue[AHC_SCB_MAX]; - int queued = inb(QINCNT + iobase) & ahc->qcntmask; + int queued = AHC_INB(ahc, QINCNT) & ahc->qcntmask; for (i = 0; i < (queued - found); i++) { - saved_queue[i] = inb(QINFIFO + iobase); - outb(SCBPTR + iobase, saved_queue[i]); - scbp = ahc->scbarray[inb(SCB_TAG + iobase)]; + saved_queue[i] = AHC_INB(ahc, QINFIFO); + AHC_OUTB(ahc, SCBPTR, saved_queue[i]); + scbp = ahc->scbarray[AHC_INB(ahc, SCB_TAG)]; if (ahc_match_scb (scbp, target, channel)){ /* * We found an scb that needs to be aborted. @@ -2834,14 +2899,14 @@ ahc_reset_device(ahc, target, channel, timedout_scb, xs_error) scbp->xs->error |= xs_error; if(scbp->position != timedout_scb) untimeout(ahc_timeout, (caddr_t)scbp); - outb(SCB_CONTROL + iobase, 0); + AHC_OUTB(ahc, SCB_CONTROL, 0); i--; found++; } } /* Now put the saved scbs back. */ for (queued = 0; queued < i; queued++) { - outb (QINFIFO + iobase, saved_queue[queued]); + AHC_OUTB(ahc, QINFIFO, saved_queue[queued]); } } @@ -2851,23 +2916,23 @@ ahc_reset_device(ahc, target, channel, timedout_scb, xs_error) { u_char next, prev; - next = inb(WAITING_SCBH + iobase); /* Start at head of list. */ + next = AHC_INB(ahc, WAITING_SCBH); /* Start at head of list. */ prev = SCB_LIST_NULL; while (next != SCB_LIST_NULL) { - outb(SCBPTR + iobase, next); - scbp = ahc->scbarray[inb(SCB_TAG + iobase)]; + AHC_OUTB(ahc, SCBPTR, next); + scbp = ahc->scbarray[AHC_INB(ahc, SCB_TAG)]; /* * Select the SCB. */ if (ahc_match_scb(scbp, target, channel)) { next = ahc_abort_wscb(ahc, scbp, prev, - iobase, timedout_scb, xs_error); + timedout_scb, xs_error); found++; } else { prev = next; - next = inb(SCB_NEXT + iobase); + next = AHC_INB(ahc, SCB_NEXT); } } } @@ -2882,11 +2947,11 @@ ahc_reset_device(ahc, target, channel, timedout_scb, xs_error) if((scbp->flags & SCB_ACTIVE) && ahc_match_scb(scbp, target, channel)) { /* Ensure the target is "free" */ - ahc_unbusy_target(target, channel, iobase); + ahc_unbusy_target(ahc, target, channel); if( !(scbp->flags & SCB_PAGED_OUT) ) { - outb(SCBPTR + iobase, scbp->position); - outb(SCB_CONTROL + iobase, 0); + AHC_OUTB(ahc, SCBPTR, scbp->position); + AHC_OUTB(ahc, SCB_CONTROL, 0); } scbp->flags = SCB_ABORTED|SCB_QUEUED_FOR_DONE; scbp->xs->error |= xs_error; @@ -2895,7 +2960,7 @@ ahc_reset_device(ahc, target, channel, timedout_scb, xs_error) found++; } } - outb(SCBPTR + iobase, active_scb); + AHC_OUTB(ahc, SCBPTR, active_scb); return found; } @@ -2904,11 +2969,10 @@ ahc_reset_device(ahc, target, channel, timedout_scb, xs_error) * scb that follows the one that we remove. */ static u_char -ahc_abort_wscb (ahc, scbp, prev, iobase, timedout_scb, xs_error) +ahc_abort_wscb (ahc, scbp, prev, timedout_scb, xs_error) struct ahc_data *ahc; struct scb *scbp; u_char prev; - u_long iobase; u_char timedout_scb; u_int32_t xs_error; { @@ -2919,33 +2983,33 @@ ahc_abort_wscb (ahc, scbp, prev, iobase, timedout_scb, xs_error) * Select the SCB we want to abort and * pull the next pointer out of it. */ - curscbp = inb(SCBPTR + iobase); - outb(SCBPTR + iobase, scbp->position); - next = inb(SCB_NEXT + iobase); + curscbp = AHC_INB(ahc, SCBPTR); + AHC_OUTB(ahc, SCBPTR, scbp->position); + next = AHC_INB(ahc, SCB_NEXT); /* Clear the necessary fields */ - outb(SCB_CONTROL + iobase, 0); - outb(SCB_NEXT + iobase, SCB_LIST_NULL); - ahc_unbusy_target(target, channel, iobase); + AHC_OUTB(ahc, SCB_CONTROL, 0); + AHC_OUTB(ahc, SCB_NEXT, SCB_LIST_NULL); + ahc_unbusy_target(ahc, target, channel); /* update the waiting list */ if( prev == SCB_LIST_NULL ) /* First in the list */ - outb(WAITING_SCBH + iobase, next); + AHC_OUTB(ahc, WAITING_SCBH, next); else { /* * Select the scb that pointed to us * and update its next pointer. */ - outb(SCBPTR + iobase, prev); - outb(SCB_NEXT + iobase, next); + AHC_OUTB(ahc, SCBPTR, prev); + AHC_OUTB(ahc, SCB_NEXT, next); } /* * Point us back at the original scb position * and inform the SCSI system that the command * has been aborted. */ - outb(SCBPTR + iobase, curscbp); + AHC_OUTB(ahc, SCBPTR, curscbp); scbp->flags = SCB_ABORTED|SCB_QUEUED_FOR_DONE; scbp->xs->error |= xs_error; if(scbp->tag != timedout_scb) @@ -2954,13 +3018,14 @@ ahc_abort_wscb (ahc, scbp, prev, iobase, timedout_scb, xs_error) } static void -ahc_busy_target(target, channel, iobase) +ahc_busy_target(ahc, target, channel) + struct ahc_data *ahc; u_char target; char channel; - u_long iobase; { u_char active; - u_long active_port = ACTIVE_A + iobase; + u_long active_port = ACTIVE_A; + if(target > 0x07 || channel == 'B') { /* * targets on the Second channel or @@ -2969,19 +3034,20 @@ ahc_busy_target(target, channel, iobase) */ active_port++; } - active = inb(active_port); + active = AHC_INB(ahc, active_port); active |= (0x01 << (target & 0x07)); - outb(active_port, active); + AHC_OUTB(ahc, active_port, active); } static void -ahc_unbusy_target(target, channel, iobase) +ahc_unbusy_target(ahc, target, channel) + struct ahc_data *ahc; u_char target; char channel; - u_long iobase; { u_char active; - u_long active_port = ACTIVE_A + iobase; + u_long active_port = ACTIVE_A; + if(target > 0x07 || channel == 'B') { /* * targets on the Second channel or @@ -2990,18 +3056,18 @@ ahc_unbusy_target(target, channel, iobase) */ active_port++; } - active = inb(active_port); + active = AHC_INB(ahc, active_port); active &= ~(0x01 << (target & 0x07)); - outb(active_port, active); + AHC_OUTB(ahc, active_port, active); } static void -ahc_reset_current_bus(iobase) - u_long iobase; +ahc_reset_current_bus(ahc) + struct ahc_data *ahc; { - outb(SCSISEQ + iobase, SCSIRSTO); + AHC_OUTB(ahc, SCSISEQ, SCSIRSTO); DELAY(1000); - outb(SCSISEQ + iobase, 0); + AHC_OUTB(ahc, SCSISEQ, 0); } static int @@ -3012,7 +3078,6 @@ ahc_reset_channel(ahc, channel, timedout_scb, xs_error, initiate_reset) u_int32_t xs_error; u_char initiate_reset; { - u_long iobase = ahc->baseport; u_char sblkctl; char cur_channel; u_long offset, offset_max; @@ -3027,26 +3092,26 @@ ahc_reset_channel(ahc, channel, timedout_scb, xs_error, initiate_reset) if(channel == 'B'){ ahc->needsdtr |= (ahc->needsdtr_orig & 0xff00); ahc->sdtrpending &= 0x00ff; - outb(ACTIVE_B + iobase, 0); - offset = TARG_SCRATCH + iobase + 8; - offset_max = TARG_SCRATCH + iobase + 16; + AHC_OUTB(ahc, ACTIVE_B, 0); + offset = TARG_SCRATCH + 8; + offset_max = TARG_SCRATCH + 16; } else if (ahc->type & AHC_WIDE){ ahc->needsdtr = ahc->needsdtr_orig; ahc->needwdtr = ahc->needwdtr_orig; ahc->sdtrpending = 0; ahc->wdtrpending = 0; - outb(ACTIVE_A + iobase, 0); - outb(ACTIVE_B + iobase, 0); - offset = TARG_SCRATCH + iobase; - offset_max = TARG_SCRATCH + iobase + 16; + AHC_OUTB(ahc, ACTIVE_A, 0); + AHC_OUTB(ahc, ACTIVE_B, 0); + offset = TARG_SCRATCH; + offset_max = TARG_SCRATCH + 16; } else{ ahc->needsdtr |= (ahc->needsdtr_orig & 0x00ff); ahc->sdtrpending &= 0xff00; - outb(ACTIVE_A + iobase, 0); - offset = TARG_SCRATCH + iobase; - offset_max = TARG_SCRATCH + iobase + 8; + AHC_OUTB(ahc, ACTIVE_A, 0); + offset = TARG_SCRATCH; + offset_max = TARG_SCRATCH + 8; } for(;offset < offset_max;offset++) { /* @@ -3054,9 +3119,10 @@ ahc_reset_channel(ahc, channel, timedout_scb, xs_error, initiate_reset) * until we renegotiate. */ u_char targ_scratch; - targ_scratch = inb(offset); + + targ_scratch = AHC_INB(ahc, offset); targ_scratch &= SXFR; - outb(offset, targ_scratch); + AHC_OUTB(ahc, offset, targ_scratch); } /* @@ -3064,7 +3130,7 @@ ahc_reset_channel(ahc, channel, timedout_scb, xs_error, initiate_reset) * restart/unpause the sequencer */ /* Case 1: Command for another bus is active */ - sblkctl = inb(SBLKCTL + iobase); + sblkctl = AHC_INB(ahc, SBLKCTL); cur_channel = (sblkctl & SELBUSB) ? 'B' : 'A'; if(cur_channel != channel) { @@ -3072,24 +3138,24 @@ ahc_reset_channel(ahc, channel, timedout_scb, xs_error, initiate_reset) * Stealthily reset the other bus * without upsetting the current bus */ - outb(SBLKCTL + iobase, sblkctl ^ SELBUSB); + AHC_OUTB(ahc, SBLKCTL, sblkctl ^ SELBUSB); if( initiate_reset ) { - ahc_reset_current_bus(iobase); + ahc_reset_current_bus(ahc); } - outb(CLRSINT1 + iobase, CLRSCSIRSTI|CLRSELTIMEO); - outb(CLRINT + iobase, CLRSCSIINT); - outb(SBLKCTL + iobase, sblkctl); + AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI|CLRSELTIMEO); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); + AHC_OUTB(ahc, SBLKCTL, sblkctl); UNPAUSE_SEQUENCER(ahc); } /* Case 2: A command from this bus is active or we're idle */ else { if( initiate_reset ) { - ahc_reset_current_bus(iobase); + ahc_reset_current_bus(ahc); } - outb(CLRSINT1 + iobase, CLRSCSIRSTI|CLRSELTIMEO); - outb(CLRINT + iobase, CLRSCSIINT); + AHC_OUTB(ahc, CLRSINT1, CLRSCSIRSTI|CLRSELTIMEO); + AHC_OUTB(ahc, CLRINT, CLRSCSIINT); RESTART_SEQUENCER(ahc); } ahc_run_done_queue(ahc); diff --git a/sys/dev/ic/aic7xxxreg.h b/sys/dev/ic/aic7xxxreg.h new file mode 100644 index 00000000000..240d1f57a93 --- /dev/null +++ b/sys/dev/ic/aic7xxxreg.h @@ -0,0 +1,776 @@ +/* $NetBSD: aic7xxxreg.h,v 1.2 1996/05/20 00:58:10 thorpej Exp $ */ + +/* + * Aic7xxx register and scratch ram definitions. + * + * 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. + */ + +/* + * This header is shared by the sequencer code and the kernel level driver. + * + * All page numbers refer to the Adaptec AIC-7770 Data Book availible from + * Adaptec's Technical Documents Department 1-800-934-2766 + */ + +/* + * SCSI Sequence Control (p. 3-11). + * Each bit, when set starts a specific SCSI sequence on the bus + */ +#define SCSISEQ 0x000 +#define TEMODEO 0x80 +#define ENSELO 0x40 +#define ENSELI 0x20 +#define ENRSELI 0x10 +#define ENAUTOATNO 0x08 +#define ENAUTOATNI 0x04 +#define ENAUTOATNP 0x02 +#define SCSIRSTO 0x01 + +/* + * SCSI Transfer Control 0 Register (pp. 3-13). + * Controls the SCSI module data path. + */ +#define SXFRCTL0 0x001 +#define DFON 0x80 +#define DFPEXP 0x40 +#define ULTRAEN 0x20 +#define CLRSTCNT 0x10 +#define SPIOEN 0x08 +#define SCAMEN 0x04 +#define CLRCHN 0x02 +/* UNUSED 0x01 */ + +/* + * SCSI Transfer Control 1 Register (pp. 3-14,15). + * Controls the SCSI module data path. + */ +#define SXFRCTL1 0x002 +#define BITBUCKET 0x80 +#define SWRAPEN 0x40 +#define ENSPCHK 0x20 +#define STIMESEL 0x18 +#define ENSTIMER 0x04 +#define ACTNEGEN 0x02 +#define STPWEN 0x01 /* Powered Termination */ + +/* + * SCSI Control Signal Read Register (p. 3-15). + * Reads the actual state of the SCSI bus pins + */ +#define SCSISIGI 0x003 +#define CDI 0x80 +#define IOI 0x40 +#define MSGI 0x20 +#define ATNI 0x10 +#define SELI 0x08 +#define BSYI 0x04 +#define REQI 0x02 +#define ACKI 0x01 + +/* + * Possible phases in SCSISIGI + */ +#define PHASE_MASK 0xe0 +#define P_DATAOUT 0x00 +#define P_DATAIN 0x40 +#define P_COMMAND 0x80 +#define P_MESGOUT 0xa0 +#define P_STATUS 0xc0 +#define P_MESGIN 0xe0 +/* + * SCSI Contol Signal Write Register (p. 3-16). + * Writing to this register modifies the control signals on the bus. Only + * those signals that are allowed in the current mode (Initiator/Target) are + * asserted. + */ +#define SCSISIGO 0x003 +#define CDO 0x80 +#define IOO 0x40 +#define MSGO 0x20 +#define ATNO 0x10 +#define SELO 0x08 +#define BSYO 0x04 +#define REQO 0x02 +#define ACKO 0x01 + +/* + * SCSI Rate Control (p. 3-17). + * Contents of this register determine the Synchronous SCSI data transfer + * rate and the maximum synchronous Req/Ack offset. An offset of 0 in the + * SOFS (3:0) bits disables synchronous data transfers. Any offset value + * greater than 0 enables synchronous transfers. + */ +#define SCSIRATE 0x004 +#define WIDEXFER 0x80 /* Wide transfer control */ +#define SXFR 0x70 /* Sync transfer rate */ +#define SOFS 0x0f /* Sync offset */ + +/* + * SCSI ID (p. 3-18). + * Contains the ID of the board and the current target on the + * selected channel. + */ +#define SCSIID 0x005 +#define TID 0xf0 /* Target ID mask */ +#define OID 0x0f /* Our ID mask */ + +/* + * SCSI Latched Data (p. 3-19). + * Read/Write latchs used to transfer data on the SCSI bus during + * Automatic or Manual PIO mode. SCSIDATH can be used for the + * upper byte of a 16bit wide asyncronouse data phase transfer. + */ +#define SCSIDATL 0x006 +#define SCSIDATH 0x007 + +/* + * SCSI Transfer Count (pp. 3-19,20) + * These registers count down the number of bytes transfered + * across the SCSI bus. The counter is decremented only once + * the data has been safely transfered. SDONE in SSTAT0 is + * set when STCNT goes to 0 + */ +#define STCNT 0x008 +#define STCNT0 0x008 +#define STCNT1 0x009 +#define STCNT2 0x00a + +/* + * Clear SCSI Interrupt 0 (p. 3-20) + * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT0. + */ +#define CLRSINT0 0x00b +#define CLRSELDO 0x40 +#define CLRSELDI 0x20 +#define CLRSELINGO 0x10 +#define CLRSWRAP 0x08 +/* UNUSED 0x04 */ +#define CLRSPIORDY 0x02 +/* UNUSED 0x01 */ + +/* + * SCSI Status 0 (p. 3-21) + * Contains one set of SCSI Interrupt codes + * These are most likely of interest to the sequencer + */ +#define SSTAT0 0x00b +#define TARGET 0x80 /* Board acting as target */ +#define SELDO 0x40 /* Selection Done */ +#define SELDI 0x20 /* Board has been selected */ +#define SELINGO 0x10 /* Selection In Progress */ +#define SWRAP 0x08 /* 24bit counter wrap */ +#define SDONE 0x04 /* STCNT = 0x000000 */ +#define SPIORDY 0x02 /* SCSI PIO Ready */ +#define DMADONE 0x01 /* DMA transfer completed */ + +/* + * Clear SCSI Interrupt 1 (p. 3-23) + * Writing a 1 to a bit clears the associated SCSI Interrupt in SSTAT1. + */ +#define CLRSINT1 0x00c +#define CLRSELTIMEO 0x80 +#define CLRATNO 0x40 +#define CLRSCSIRSTI 0x20 +/* UNUSED 0x10 */ +#define CLRBUSFREE 0x08 +#define CLRSCSIPERR 0x04 +#define CLRPHASECHG 0x02 +#define CLRREQINIT 0x01 + +/* + * SCSI Status 1 (p. 3-24) + */ +#define SSTAT1 0x00c +#define SELTO 0x80 +#define ATNTARG 0x40 +#define SCSIRSTI 0x20 +#define PHASEMIS 0x10 +#define BUSFREE 0x08 +#define SCSIPERR 0x04 +#define PHASECHG 0x02 +#define REQINIT 0x01 + +/* + * SCSI Interrupt Mode 1 (pp. 3-28,29) + * Setting any bit will enable the corresponding function + * in SIMODE1 to interrupt via the IRQ pin. + */ +#define SIMODE1 0x011 +#define ENSELTIMO 0x80 +#define ENATNTARG 0x40 +#define ENSCSIRST 0x20 +#define ENPHASEMIS 0x10 +#define ENBUSFREE 0x08 +#define ENSCSIPERR 0x04 +#define ENPHASECHG 0x02 +#define ENREQINIT 0x01 + +/* + * SCSI Data Bus (High) (p. 3-29) + * This register reads data on the SCSI Data bus directly. + */ +#define SCSIBUSL 0x012 +#define SCSIBUSH 0x013 + +/* + * SCSI/Host Address (p. 3-30) + * These registers hold the host address for the byte about to be + * transfered on the SCSI bus. They are counted up in the same + * manner as STCNT is counted down. SHADDR should always be used + * to determine the address of the last byte transfered since HADDR + * can be squewed by write ahead. + */ +#define SHADDR 0x014 +#define SHADDR0 0x014 +#define SHADDR1 0x015 +#define SHADDR2 0x016 +#define SHADDR3 0x017 + +/* + * Selection/Reselection ID (p. 3-31) + * Upper four bits are the device id. The ONEBIT is set when the re/selecting + * device did not set its own ID. + */ +#define SELID 0x019 +#define SELID_MASK 0xf0 +#define ONEBIT 0x08 +/* UNUSED 0x07 */ + +/* + * SCSI Block Control (p. 3-32) + * Controls Bus type and channel selection. In a twin channel configuration + * addresses 0x00-0x1e are gated to the appropriate channel based on this + * register. SELWIDE allows for the coexistence of 8bit and 16bit devices + * on a wide bus. + */ +#define SBLKCTL 0x01f +#define DIAGLEDEN 0x80 /* Aic78X0 only */ +#define DIAGLEDON 0x40 /* Aic78X0 only */ +#define AUTOFLUSHDIS 0x20 +/* UNUSED 0x10 */ +#define SELBUS_MASK 0x0a +#define SELBUSB 0x08 +/* UNUSED 0x04 */ +#define SELWIDE 0x02 +/* UNUSED 0x01 */ +#define SELNARROW 0x00 + +/* + * Sequencer Control (p. 3-33) + * Error detection mode and speed configuration + */ +#define SEQCTL 0x060 +#define PERRORDIS 0x80 +#define PAUSEDIS 0x40 +#define FAILDIS 0x20 +#define FASTMODE 0x10 +#define BRKADRINTEN 0x08 +#define STEP 0x04 +#define SEQRESET 0x02 +#define LOADRAM 0x01 + +/* + * Sequencer RAM Data (p. 3-34) + * Single byte window into the Scratch Ram area starting at the address + * specified by SEQADDR0 and SEQADDR1. To write a full word, simply write + * four bytes in sucessesion. The SEQADDRs will increment after the most + * significant byte is written + */ +#define SEQRAM 0x061 + +/* + * Sequencer Address Registers (p. 3-35) + * Only the first bit of SEQADDR1 holds addressing information + */ +#define SEQADDR0 0x062 +#define SEQADDR1 0x063 +#define SEQADDR1_MASK 0x01 + +/* + * Accumulator + * We cheat by passing arguments in the Accumulator up to the kernel driver + */ +#define ACCUM 0x064 + +#define SINDEX 0x065 +#define DINDEX 0x066 +#define ALLZEROS 0x06a +#define NONE 0x06a +#define SINDIR 0x06c +#define DINDIR 0x06d +#define FUNCTION1 0x06e + +/* + * Host Address (p. 3-48) + * This register contains the address of the byte about + * to be transfered across the host bus. + */ +#define HADDR 0x088 +#define HADDR0 0x088 +#define HADDR1 0x089 +#define HADDR2 0x08a +#define HADDR3 0x08b + +#define HCNT 0x08c +#define HCNT0 0x08c +#define HCNT1 0x08d +#define HCNT2 0x08e +/* + * SCB Pointer (p. 3-49) + * Gate one of the four SCBs into the SCBARRAY window. + */ +#define SCBPTR 0x090 + +/* + * Board Control (p. 3-43) + */ +#define BCTL 0x084 +/* RSVD 0xf0 */ +#define ACE 0x08 /* Support for external processors */ +/* RSVD 0x06 */ +#define ENABLE 0x01 + +/* + * On the aic78X0 chips, Board Control is replaced by the DSCommand + * register (p. 4-64) + */ +#define DSCOMMAND 0x084 +#define CACHETHEN 0x80 /* Cache Threshold enable */ +#define DPARCKEN 0x40 /* Data Parity Check Enable */ +#define MPARCKEN 0x20 /* Memory Parity Check Enable */ +#define EXTREQLCK 0x10 /* External Request Lock */ + +/* + * Bus On/Off Time (p. 3-44) + */ +#define BUSTIME 0x085 +#define BOFF 0xf0 +#define BON 0x0f + +/* + * Bus Speed (p. 3-45) + */ +#define BUSSPD 0x086 +#define DFTHRSH 0xc0 +#define STBOFF 0x38 +#define STBON 0x07 +#define DFTHRSH_100 0xc0 + +/* + * Host Control (p. 3-47) R/W + * Overal host control of the device. + */ +#define HCNTRL 0x087 +/* UNUSED 0x80 */ +#define POWRDN 0x40 +/* UNUSED 0x20 */ +#define SWINT 0x10 +#define IRQMS 0x08 +#define PAUSE 0x04 +#define INTEN 0x02 +#define CHIPRST 0x01 +#define CHIPRSTACK 0x01 + +/* + * Interrupt Status (p. 3-50) + * Status for system interrupts + */ +#define INTSTAT 0x091 +#define SEQINT_MASK 0xf1 /* SEQINT Status Codes */ +#define BAD_PHASE 0x01 /* unknown scsi bus phase */ +#define SEND_REJECT 0x11 /* sending a message reject */ +#define NO_IDENT 0x21 /* no IDENTIFY after reconnect*/ +#define NO_MATCH 0x31 /* no cmd match for reconnect */ +#define SDTR_MSG 0x41 /* SDTR message received */ +#define WDTR_MSG 0x51 /* WDTR message received */ +#define REJECT_MSG 0x61 /* Reject message received */ +#define BAD_STATUS 0x71 /* Bad status from target */ +#define RESIDUAL 0x81 /* Residual byte count != 0 */ +#define ABORT_TAG 0x91 /* Sent an ABORT_TAG message */ +#define AWAITING_MSG 0xa1 /* + * Kernel requested to specify + * a message to this target + * (command was null), so tell + * it that it can fill the + * message buffer. + */ +#define IMMEDDONE 0xb1 /* + * An immediate command has + * completed + */ +#define MSG_BUFFER_BUSY 0xc1 /* + * Sequencer wants to use the + * message buffer, but it + * already contains a message + */ +#define MSGIN_PHASEMIS 0xd1 /* + * Target changed phase on us + * when we were expecting + * another msgin byte. + */ +#define BRKADRINT 0x08 +#define SCSIINT 0x04 +#define CMDCMPLT 0x02 +#define SEQINT 0x01 +#define INT_PEND (BRKADRINT | SEQINT | SCSIINT | CMDCMPLT) + +/* + * Hard Error (p. 3-53) + * Reporting of catastrophic errors. You usually cannot recover from + * these without a full board reset. + */ +#define ERROR 0x092 +/* UNUSED 0xf0 */ +#define PARERR 0x08 +#define ILLOPCODE 0x04 +#define ILLSADDR 0x02 +#define ILLHADDR 0x01 + +/* + * Clear Interrupt Status (p. 3-52) + */ +#define CLRINT 0x092 +#define CLRBRKADRINT 0x08 +#define CLRSCSIINT 0x04 +#define CLRCMDINT 0x02 +#define CLRSEQINT 0x01 + +#define DFCNTRL 0x093 +#define WIDEODD 0x40 +#define SCSIEN 0x20 +#define SDMAEN 0x10 +#define SDMAENACK 0x10 +#define HDMAEN 0x08 +#define HDMAENACK 0x08 +#define DIRECTION 0x04 +#define FIFOFLUSH 0x02 +#define FIFORESET 0x01 + +#define DFSTATUS 0x094 +#define HDONE 0x08 +#define FIFOEMP 0x01 + +#define DFDAT 0x099 + +/* + * SCB Auto Increment (p. 3-59) + * Byte offset into the SCB Array and an optional bit to allow auto + * incrementing of the address during download and upload operations + */ +#define SCBCNT 0x09a +#define SCBAUTO 0x80 +#define SCBCNT_MASK 0x1f + +/* + * Queue In FIFO (p. 3-60) + * Input queue for queued SCBs (commands that the seqencer has yet to start) + */ +#define QINFIFO 0x09b + +/* + * Queue In Count (p. 3-60) + * Number of queued SCBs + */ +#define QINCNT 0x09c + +/* + * Queue Out FIFO (p. 3-61) + * Queue of SCBs that have completed and await the host + */ +#define QOUTFIFO 0x09d + +/* + * Queue Out Count (p. 3-61) + * Number of queued SCBs in the Out FIFO + */ +#define QOUTCNT 0x09e + +/* + * SCB Definition (p. 5-4) + * The two reserved bytes at SCBARRAY+1[23] are expected to be set to + * zero. Bit 3 in SCBARRAY+0 is used as an internal flag to indicate + * whether or not to DMA an SCB from host ram. This flag prevents the + * "re-fetching" of transactions that are requed because the target is + * busy with another command. We also use bits 6 & 7 to indicate whether + * or not to initiate SDTR or WDTR repectively when starting this command. + */ +#define SCBARRAY 0x0a0 +#define SCB_CONTROL 0x0a0 +#define NEEDWDTR 0x80 +#define DISCENB 0x40 +#define TAG_ENB 0x20 +#define NEEDSDTR 0x10 +#define DISCONNECTED 0x04 +#define SCB_TAG_TYPE 0x03 +#define SCB_TCL 0x0a1 +#define SCB_TARGET_STATUS 0x0a2 +#define SCB_SGCOUNT 0x0a3 +#define SCB_SGPTR 0x0a4 +#define SCB_SGPTR0 0x0a4 +#define SCB_SGPTR1 0x0a5 +#define SCB_SGPTR2 0x0a6 +#define SCB_SGPTR3 0x0a7 +#define SCB_RESID_SGCNT 0x0a8 +#define SCB_RESID_DCNT 0x0a9 +#define SCB_RESID_DCNT0 0x0a9 +#define SCB_RESID_DCNT1 0x0aa +#define SCB_RESID_DCNT2 0x0ab +#define SCB_DATAPTR 0x0ac +#define SCB_DATAPTR0 0x0ac +#define SCB_DATAPTR1 0x0ad +#define SCB_DATAPTR2 0x0ae +#define SCB_DATAPTR3 0x0af +#define SCB_DATACNT 0x0b0 +#define SCB_DATACNT0 0x0b0 +#define SCB_DATACNT1 0x0b1 +#define SCB_DATACNT2 0x0b2 +/* UNUSED - QUAD PADDING 0x0b3 */ +#define SCB_CMDPTR 0x0b4 +#define SCB_CMDPTR0 0x0b4 +#define SCB_CMDPTR1 0x0b5 +#define SCB_CMDPTR2 0x0b6 +#define SCB_CMDPTR3 0x0b7 +#define SCB_CMDLEN 0x0b8 +#define SCB_TAG 0x0b9 +#define SCB_NEXT 0x0ba +#define SCB_PREV 0x0bb + +#ifdef __linux__ +#define SG_SIZEOF 0x0c /* sizeof(struct scatterlist) */ +#else +#define SG_SIZEOF 0x08 /* sizeof(struct ahc_dma) */ +#endif + +/* --------------------- AHA-2840-only definitions -------------------- */ + +#define SEECTL_2840 0x0c0 +/* UNUSED 0xf8 */ +#define CS_2840 0x04 +#define CK_2840 0x02 +#define DO_2840 0x01 + +#define STATUS_2840 0x0c1 +#define EEPROM_TF 0x80 +#define BIOS_SEL 0x60 +#define ADSEL 0x1e +#define DI_2840 0x01 + +/* --------------------- AIC-7870-only definitions -------------------- */ + +#define DSPCISTATUS 0x086 + +/* + * Serial EEPROM Control (p. 4-92 in 7870 Databook) + * Controls the reading and writing of an external serial 1-bit + * EEPROM Device. In order to access the serial EEPROM, you must + * first set the SEEMS bit that generates a request to the memory + * port for access to the serial EEPROM device. When the memory + * port is not busy servicing another request, it reconfigures + * to allow access to the serial EEPROM. When this happens, SEERDY + * gets set high to verify that the memory port access has been + * granted. + * + * After successful arbitration for the memory port, the SEECS bit of + * the SEECTL register is connected to the chip select. The SEECK, + * SEEDO, and SEEDI are connected to the clock, data out, and data in + * lines respectively. The SEERDY bit of SEECTL is useful in that it + * gives us an 800 nsec timer. After a write to the SEECTL register, + * the SEERDY goes high 800 nsec later. The one exception to this is + * when we first request access to the memory port. The SEERDY goes + * high to signify that access has been granted and, for this case, has + * no implied timing. + * + * See 93cx6.c for detailed information on the protocol necessary to + * read the serial EEPROM. + */ +#define SEECTL 0x01e +#define EXTARBACK 0x80 +#define EXTARBREQ 0x40 +#define SEEMS 0x20 +#define SEERDY 0x10 +#define SEECS 0x08 +#define SEECK 0x04 +#define SEEDO 0x02 +#define SEEDI 0x01 + +/* ---------------------- Scratch RAM Offsets ------------------------- */ +/* These offsets are either to values that are initialized by the board's + * BIOS or are specified by the sequencer code. + * + * The host adapter card (at least the BIOS) uses 20-2f for SCSI + * device information, 32-33 and 5a-5f as well. As it turns out, the + * BIOS trashes 20-2f, writing the synchronous negotiation results + * on top of the BIOS values, so we re-use those for our per-target + * scratchspace (actually a value that can be copied directly into + * SCSIRATE). The kernel driver will enable synchronous negotiation + * for all targets that have a value other than 0 in the lower four + * bits of the target scratch space. This should work regardless of + * whether the bios has been installed. + */ + +/* + * 1 byte per target starting at this address for configuration values + */ +#define TARG_SCRATCH 0x020 + +/* + * The sequencer will stick the frist byte of any rejected message here so + * we can see what is getting thrown away. Extended messages put the + * extended message type in REJBYTE_EXT. + */ +#define REJBYTE 0x030 +#define REJBYTE_EXT 0x031 + +/* + * Bit vector of targets that have disconnection disabled. + */ +#define DISC_DSB 0x032 +#define DISC_DSB_A 0x032 +#define DISC_DSB_B 0x033 + +/* + * Length of pending message + */ +#define MSG_LEN 0x034 + +/* We reserve 8bytes to store outgoing messages */ +#define MSG0 0x035 +#define COMP_MSG0 0xcb /* 2's complement of MSG0 */ +#define MSG1 0x036 +#define MSG2 0x037 +#define MSG3 0x038 +#define MSG4 0x039 +#define MSG5 0x03a +#define MSG6 0x03b +#define MSG7 0x03c + +/* + * These are offsets into the card's scratch ram. Some of the values are + * specified in the AHA2742 technical reference manual and are initialized + * by the BIOS at boot time. + */ +#define LASTPHASE 0x03d +#define ARG_1 0x03e +#define MAXOFFSET 0x01 +#define RETURN_1 0x03f +#define SEND_WDTR 0x80 +#define SEND_SDTR 0x60 +#define SEND_SENSE 0x40 +#define SEND_REJ 0x20 +#define SCB_PAGEDIN 0x10 + +#define SIGSTATE 0x040 + +#define DMAPARAMS 0x041 /* Parameters for DMA Logic */ + +#define SG_COUNT 0x042 +#define SG_NEXT 0x043 /* working value of SG pointer */ +#define SG_NEXT0 0x043 +#define SG_NEXT1 0x044 +#define SG_NEXT2 0x045 +#define SG_NEXT3 0x046 + +#define SCBCOUNT 0x047 /* + * Number of SCBs supported by + * this card. + */ +#define COMP_SCBCOUNT 0x048 /* + * Two's compliment of SCBCOUNT + */ +#define QCNTMASK 0x049 /* + * Mask of bits to test against + * when looking at the Queue Count + * registers. Works around a bug + * on aic7850 chips. + */ +#define FLAGS 0x04a +#define SINGLE_BUS 0x00 +#define TWIN_BUS 0x01 +#define WIDE_BUS 0x02 +#define PAGESCBS 0x04 +#define DPHASE 0x10 +#define SELECTED 0x20 +#define IDENTIFY_SEEN 0x40 +#define RESELECTED 0x80 + +#define SAVED_TCL 0x04b /* + * Temporary storage for the + * target/channel/lun of a + * reconnecting target + */ +#define ACTIVE_A 0x04c +#define ACTIVE_B 0x04d +#define WAITING_SCBH 0x04e /* + * head of list of SCBs awaiting + * selection + */ +#define DISCONNECTED_SCBH 0x04f /* + * head of list of SCBs that are + * disconnected. Used for SCB + * paging. + */ +#define SCB_LIST_NULL 0xff + +#define SAVED_LINKPTR 0x050 +#define SAVED_SCBPTR 0x051 + +#define SCSICONF 0x05a +#define RESET_SCSI 0x40 + +#define HOSTCONF 0x05d + +#define HA_274_BIOSCTRL 0x05f +#define BIOSMODE 0x30 +#define BIOSDISABLED 0x30 +#define CHANNEL_B_PRIMARY 0x08 + +/* Message codes */ +#define MSG_EXTENDED 0x01 +#define MSG_SDTR 0x01 +#define MSG_WDTR 0x03 +#define MSG_SDPTRS 0x02 +#define MSG_RDPTRS 0x03 +#define MSG_DISCONNECT 0x04 +#define MSG_INITIATOR_DET_ERROR 0x05 +#define MSG_ABORT 0x06 +#define MSG_REJECT 0x07 +#define MSG_NOP 0x08 +#define MSG_MSG_PARITY_ERROR 0x09 +#define MSG_BUS_DEVICE_RESET 0x0c +#define MSG_ABORT_TAG 0x0d +#define MSG_SIMPLE_TAG 0x20 +#define MSG_IDENTIFY 0x80 + +/* WDTR Message values */ +#define BUS_8_BIT 0x00 +#define BUS_16_BIT 0x01 +#define BUS_32_BIT 0x02 + +#define MAX_OFFSET_8BIT 0x0f +#define MAX_OFFSET_16BIT 0x08 diff --git a/sys/dev/ic/aic7xxxvar.h b/sys/dev/ic/aic7xxxvar.h index 8338785c59f..90fe40dfb1f 100644 --- a/sys/dev/ic/aic7xxxvar.h +++ b/sys/dev/ic/aic7xxxvar.h @@ -1,3 +1,5 @@ +/* $NetBSD: aic7xxxvar.h,v 1.7 1996/05/20 00:58:11 thorpej Exp $ */ + /* * Interface to the generic driver for the aic7xxx based adaptec * SCSI controllers. This is used to implement product specific @@ -29,8 +31,6 @@ * 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: aic7xxxvar.h,v 1.4 1996/05/05 12:42:31 deraadt Exp $ */ #ifndef _AIC7XXX_H_ @@ -40,74 +40,7 @@ #include "ahc.h" /* for NAHC from config */ #endif -#ifndef STAILQ_ENTRY /* for NetBSD, from FreeBSD <sys/queue.h> */ -/* - * Singly-linked Tail queue definitions. - */ -#define STAILQ_HEAD(name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ - struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -/* - * Singly-linked Tail queue functions. - */ -#define STAILQ_INIT(head) { \ - (head)->stqh_first = NULL; \ - (head)->stqh_last = &(head)->stqh_first; \ -} - -#define STAILQ_INSERT_HEAD(head, elm, field) { \ - if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (head)->stqh_first = (elm); \ -} - -#define STAILQ_INSERT_TAIL(head, elm, field) { \ - (elm)->field.stqe_next = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &(elm)->field.stqe_next; \ -} - -#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) { \ - if (((elm)->field.stqe_next = (tqelm)->field.stqe_next) == NULL)\ - (head)->stqh_last = &(elm)->field.stqe_next; \ - (tqelm)->field.stqe_next = (elm); \ -} - -#define STAILQ_REMOVE_HEAD(head, field) { \ - if (((head)->stqh_first = \ - (head)->stqh_first->field.stqe_next) == NULL) \ - (head)->stqh_last = &(head)->stqh_first; \ -} - -#define STAILQ_REMOVE(head, elm, type, field) { \ - if ((head)->stqh_first == (elm)) { \ - STAILQ_REMOVE_HEAD(head, field); \ - } \ - else { \ - struct type *curelm = (head)->stqh_first; \ - while( curelm->field.stqe_next != (elm) ) \ - curelm = curelm->field.stqe_next; \ - if((curelm->field.stqe_next = \ - curelm->field.stqe_next->field.stqe_next) == NULL) \ - (head)->stqh_last = &(curelm)->field.stqe_next; \ - } \ -} - -#endif /* STAILQ_ENTRY */ - -#ifndef NetBSD1_1 -#define NetBSD1_1 0 -#endif - -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) #define AHC_INB(ahc, port) \ inb((ahc)->baseport+(port)) #define AHC_INSB(ahc, port, valp, size) \ @@ -120,15 +53,15 @@ struct { \ outsl((ahc)->baseport+(port), valp, size) #elif defined(__NetBSD__) #define AHC_INB(ahc, port) \ - bus_io_read_1((ahc)->sc_bc, ahc->baseport, port) + bus_io_read_1((ahc)->sc_bc, (ahc)->sc_ioh, port) #define AHC_INSB(ahc, port, valp, size) \ - bus_io_read_multi_1((ahc)->sc_bc, ahc->baseport, port, valp, size) + bus_io_read_multi_1((ahc)->sc_bc, (ahc)->sc_ioh, port, valp, size) #define AHC_OUTB(ahc, port, val) \ - bus_io_write_1((ahc)->sc_bc, ahc->baseport, port, val) + bus_io_write_1((ahc)->sc_bc, (ahc)->sc_ioh, port, val) #define AHC_OUTSB(ahc, port, valp, size) \ - bus_io_write_multi_1((ahc)->sc_bc, ahc->baseport, port, valp, size) + bus_io_write_multi_1((ahc)->sc_bc, (ahc)->sc_ioh, port, valp, size) #define AHC_OUTSL(ahc, port, valp, size) \ - bus_io_write_multi_4((ahc)->sc_bc, ahc->baseport, port, valp, size) + bus_io_write_multi_4((ahc)->sc_bc, (ahc)->sc_ioh, port, valp, size) #endif #define AHC_NSEG 256 /* number of dma segments supported */ @@ -143,7 +76,9 @@ struct { \ typedef unsigned long int physaddr; +#if defined(__FreeBSD__) extern u_long ahc_unit; +#endif struct ahc_dma_seg { physaddr addr; @@ -170,27 +105,47 @@ typedef enum { }ahc_type; typedef enum { - AHC_FNONE = 0x00, - AHC_INIT = 0x01, - AHC_RUNNING = 0x02, - AHC_PAGESCBS = 0x04, /* Enable SCB paging */ - AHC_USEDEFAULTS = 0x10, /* + AHC_FNONE = 0x00, + AHC_INIT = 0x01, + AHC_RUNNING = 0x02, + AHC_PAGESCBS = 0x04, /* Enable SCB paging */ + AHC_CHANNEL_B_PRIMARY = 0x08, /* + * On twin channel adapters, probe + * channel B first since it is the + * primary bus. + */ + AHC_USEDEFAULTS = 0x10, /* * For cards without an seeprom * or a BIOS to initialize the chip's - * SRAM, we use the default chip and - * target settings. + * SRAM, we use the default target + * settings. */ - AHC_CHNLB = 0x20, /* + AHC_CHNLB = 0x20, /* * Second controller on 3940 * Also encodes the offset in the * SEEPROM for CHNLB info (32) */ }ahc_flag; +typedef enum { + SCB_FREE = 0x000, + SCB_ACTIVE = 0x001, + SCB_ABORTED = 0x002, + SCB_DEVICE_RESET = 0x004, + SCB_IMMED = 0x008, + SCB_SENSE = 0x010, + SCB_TIMEDOUT = 0x020, + SCB_QUEUED_FOR_DONE = 0x040, + SCB_PAGED_OUT = 0x080, + SCB_WAITINGQ = 0x100, + SCB_ASSIGNEDQ = 0x200, + SCB_SENTORDEREDTAG = 0x400 +}scb_flag; + /* * The driver keeps up to MAX_SCB scb structures per card in memory. Only the - * first 26 bytes of the structure need to be transfered to the card during - * normal operation. The fields starting at byte 32 are used for kernel level + * first 28 bytes of the structure need to be transfered to the card during + * normal operation. The fields starting at byte 28 are used for kernel level * bookkeeping. */ struct scb { @@ -222,61 +177,46 @@ struct scb { */ /*27*/ u_char prev; /*-----------------end of hardware supported fields----------------*/ - STAILQ_ENTRY(scb) links; /* for chaining */ + SIMPLEQ_ENTRY(scb) links; /* for chaining */ struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ - int flags; -#define SCB_FREE 0x000 -#define SCB_ACTIVE 0x001 -#define SCB_ABORTED 0x002 -#define SCB_DEVICE_RESET 0x004 -#define SCB_IMMED 0x008 -#define SCB_SENSE 0x010 -#define SCB_TIMEDOUT 0x020 -#define SCB_QUEUED_FOR_DONE 0x040 -#define SCB_PAGED_OUT 0x080 -#define SCB_WAITINGQ 0x100 -#define SCB_ASSIGNEDQ 0x200 -#define SCB_SENTORDEREDTAG 0x400 + scb_flag flags; u_char position; /* Position in card's scbarray */ struct ahc_dma_seg ahc_dma[AHC_NSEG] __attribute__ ((packed)); struct scsi_sense sense_cmd; /* SCSI command block */ }; -#if defined(__NetBSD__) -#if NetBSD1_1 < 3 /* NetBSD-1.1 */ -typedef int bus_chipset_tag_t; -typedef int bus_io_handle_t; -#endif -#endif - struct ahc_data { -#if defined(__NetBSD__) +#if defined(__FreeBSD__) + int unit; +#elif defined(__NetBSD__) struct device sc_dev; void *sc_ih; bus_chipset_tag_t sc_bc; + bus_io_handle_t sc_ioh; #endif - int unit; ahc_type type; ahc_flag flags; +#if defined(__FreeBSD__) u_long baseport; +#endif struct scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */ struct scb *pagedout_ntscbs[16];/* * Paged out, non-tagged scbs * indexed by target. */ - STAILQ_HEAD(, scb) free_scbs; /* + SIMPLEQ_HEAD(, scb) free_scbs; /* * SCBs assigned to free slots * on the card. (no paging required) */ - STAILQ_HEAD(, scb) page_scbs; /* + SIMPLEQ_HEAD(, scb) page_scbs; /* * SCBs that will require paging * before use (no assigned slot) */ - STAILQ_HEAD(, scb) waiting_scbs;/* + SIMPLEQ_HEAD(, scb) waiting_scbs;/* * SCBs waiting to be paged in * and started. */ - STAILQ_HEAD(, scb)assigned_scbs;/* + SIMPLEQ_HEAD(, scb)assigned_scbs;/* * SCBs that were waiting but have * now been assigned a slot by * ahc_free_scb. @@ -321,11 +261,17 @@ extern int ahc_debug; /* Initialized in i386/scsi/aic7xxx.c */ #endif #if defined(__FreeBSD__) + +char *ahc_name __P((struct ahc_data *ahc)); + void ahc_reset __P((u_long iobase)); struct ahc_data *ahc_alloc __P((int unit, u_long io_base, ahc_type type, ahc_flag flags)); #elif defined(__NetBSD__) + +#define ahc_name(ahc) (ahc)->sc_dev.dv_xname + void ahc_reset __P((char *devname, bus_chipset_tag_t bc, bus_io_handle_t ioh)); -void ahc_construct __P((struct ahc_data *ahc, int unit, bus_chipset_tag_t bc, bus_io_handle_t ioh, ahc_type type, ahc_flag flags)); +void ahc_construct __P((struct ahc_data *ahc, bus_chipset_tag_t bc, bus_io_handle_t ioh, ahc_type type, ahc_flag flags)); #endif void ahc_free __P((struct ahc_data *)); int ahc_init __P((struct ahc_data *)); diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 409afeb3c58..e5da21469df 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,5 +1,5 @@ -/* $OpenBSD: com.c,v 1.14 1996/05/10 12:37:13 deraadt Exp $ */ -/* $NetBSD: com.c,v 1.81 1996/05/05 19:50:44 christos Exp $ */ +/* $OpenBSD: com.c,v 1.15 1996/05/26 00:27:14 deraadt Exp $ */ +/* $NetBSD: com.c,v 1.82 1996/05/12 23:52:00 mycroft Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996 @@ -57,12 +57,8 @@ #include <sys/types.h> #include <sys/device.h> -#ifdef i386 /* XXX */ -#include <machine/cpu.h> /* XXX */ -#else /* XXX */ -#include <machine/intr.h> -#endif /* XXX */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> diff --git a/sys/dev/ic/elink3.c b/sys/dev/ic/elink3.c index 8eeba382af5..8d51ec0467f 100644 --- a/sys/dev/ic/elink3.c +++ b/sys/dev/ic/elink3.c @@ -1,7 +1,7 @@ -/* $NetBSD: elink3.c,v 1.5 1996/05/07 01:43:13 thorpej Exp $ */ +/* $NetBSD: elink3.c,v 1.7 1996/05/14 22:22:05 thorpej Exp $ */ /* - * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> + * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,6 +63,7 @@ #include <machine/cpu.h> #include <machine/bus.h> +#include <machine/intr.h> #include <dev/ic/elink3var.h> #include <dev/ic/elink3reg.h> @@ -94,12 +95,12 @@ static int epbusyeeprom __P((struct ep_softc *)); void epconfig(sc, conn) struct ep_softc *sc; - u_int conn; + u_int16_t conn; { struct ifnet *ifp = &sc->sc_arpcom.ac_if; bus_chipset_tag_t bc = sc->sc_bc; bus_io_handle_t ioh = sc->sc_ioh; - u_short i; + u_int16_t i; sc->ep_connectors = 0; if (conn & IS_AUI) { @@ -125,7 +126,7 @@ epconfig(sc, conn) * Read the station address from the eeprom */ for (i = 0; i < 3; i++) { - u_short x; + u_int16_t x; if (epbusyeeprom(sc)) return; bus_io_write_2(bc, ioh, EP_W0_EEPROM_COMMAND, READ_EEPROM | i); @@ -398,7 +399,7 @@ startagain: readcheck: if ((bus_io_read_2(bc, ioh, EP_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) { /* We received a complete packet. */ - u_short status = bus_io_read_2(bc, ioh, EP_STATUS); + u_int16_t status = bus_io_read_2(bc, ioh, EP_STATUS); if ((status & S_INTR_LATCH) == 0) { /* @@ -439,7 +440,7 @@ epstatus(sc) { bus_chipset_tag_t bc = sc->sc_bc; bus_io_handle_t ioh = sc->sc_ioh; - u_short fifost; + u_int16_t fifost; /* * Check the FIFO status and act accordingly @@ -527,7 +528,7 @@ epintr(arg) bus_chipset_tag_t bc = sc->sc_bc; bus_io_handle_t ioh = sc->sc_ioh; struct ifnet *ifp = &sc->sc_arpcom.ac_if; - u_short status; + u_int16_t status; int ret = 0; for (;;) { diff --git a/sys/dev/ic/elink3reg.h b/sys/dev/ic/elink3reg.h index 721ee04f163..48dccc48339 100644 --- a/sys/dev/ic/elink3reg.h +++ b/sys/dev/ic/elink3reg.h @@ -1,7 +1,7 @@ -/* $NetBSD: elink3reg.h,v 1.2 1996/04/30 22:32:39 thorpej Exp $ */ +/* $NetBSD: elink3reg.h,v 1.3 1996/05/10 05:28:09 thorpej Exp $ */ /* - * Copyright (c) 1995 Herb Peyerl <hpeyerl@novatel.ca> + * Copyright (c) 1995 Herb Peyerl <hpeyerl@beer.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/ic/elink3var.h b/sys/dev/ic/elink3var.h index 534c68d8c66..19296129b76 100644 --- a/sys/dev/ic/elink3var.h +++ b/sys/dev/ic/elink3var.h @@ -1,7 +1,7 @@ -/* $NetBSD: elink3var.h,v 1.3 1996/05/03 19:08:48 christos Exp $ */ +/* $NetBSD: elink3var.h,v 1.5 1996/05/14 22:22:06 thorpej Exp $ */ /* - * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> + * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,6 +62,6 @@ struct ep_softc { }; u_int16_t epreadeeprom __P((bus_chipset_tag_t, bus_io_handle_t, int)); -void epconfig __P((struct ep_softc *, u_int)); +void epconfig __P((struct ep_softc *, u_int16_t)); int epintr __P((void *)); void epstop __P((struct ep_softc *)); diff --git a/sys/dev/ic/ncr5380sbc.c b/sys/dev/ic/ncr5380sbc.c index a7e356d4bac..56c3ab8cc1e 100644 --- a/sys/dev/ic/ncr5380sbc.c +++ b/sys/dev/ic/ncr5380sbc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ncr5380sbc.c,v 1.5 1996/04/21 22:21:21 deraadt Exp $ */ -/* $NetBSD: ncr5380sbc.c,v 1.9 1996/03/18 23:09:02 gwr Exp $ */ +/* $OpenBSD: ncr5380sbc.c,v 1.6 1996/05/26 00:27:01 deraadt Exp $ */ +/* $NetBSD: ncr5380sbc.c,v 1.11 1996/05/13 14:10:21 christos Exp $ */ /* * Copyright (c) 1995 David Jones, Gordon W. Ross @@ -917,7 +917,7 @@ next_job: case XS_BUSY: /* XXX - Reset and try again. */ - printf("%s: SCSI bus busy, resetting...\n", + printf("%s: select found SCSI bus busy, resetting...\n", sc->sc_dev.dv_xname); ncr5380_reset_scsibus(sc); /* fallthrough */ @@ -1057,6 +1057,7 @@ ncr5380_reselect(sc) { struct sci_req *sr; int target, lun, phase, timo; + int target_mask; u_char bus, data, icmd, msg; #ifdef DIAGNOSTIC @@ -1125,6 +1126,7 @@ ncr5380_reselect(sc) printf("%s: selected as target, data=0x%x\n", sc->sc_dev.dv_xname, data); /* Not much we can do. Reset the bus. */ + /* XXX: send some sort of message? */ ncr5380_reset_scsibus(sc); return; } @@ -1132,11 +1134,12 @@ ncr5380_reselect(sc) /* * OK, this is a reselection. */ - for (target = 0; target < 7; target++) - if (data & (1 << target)) + for (target = 0; target < 7; target++) { + target_mask = (1 << target); + if (data & target_mask) break; - - if ((data & 0x7F) != (1 << target)) { + } + if ((data & 0x7F) != target_mask) { /* No selecting ID? or >2 IDs on bus? */ printf("%s: bad reselect, data=0x%x\n", sc->sc_dev.dv_xname, data); @@ -1218,6 +1221,13 @@ ncr5380_reselect(sc) sc->sc_msgoutq = 0; sc->sc_msgout = 0; + /* XXX: Restore the normal mode register. */ + /* If this target's bit is set, do NOT check parity. */ + if (sc->sc_parity_disable & target_mask) + *sc->sci_mode = (SCI_MODE_MONBSY); + else + *sc->sci_mode = (SCI_MODE_MONBSY | SCI_MODE_PAR_CHK); + /* * Another hack for the Sun3 "si", which needs * some setup done to its DMA engine before the @@ -1280,7 +1290,7 @@ ncr5380_select(sc, sr) struct ncr5380_softc *sc; struct sci_req *sr; { - int timo, s; + int timo, s, target_mask; u_char data, icmd; /* Check for reselect */ @@ -1409,7 +1419,8 @@ ncr5380_select(sc, sr) * the host and target. Also set ATN now, to * ask the target for a message out phase. */ - data = 0x80 | (1 << sr->sr_target); + target_mask = (1 << sr->sr_target); + data = 0x80 | target_mask; *(sc->sci_odata) = data; icmd |= (SCI_ICMD_DATA | SCI_ICMD_ATN); *(sc->sci_icmd) = icmd; @@ -1464,8 +1475,11 @@ success: icmd &= ~(SCI_ICMD_DATA | SCI_ICMD_SEL); *sc->sci_icmd = icmd; - /* XXX - Make parity checking optional? */ - *sc->sci_mode = (SCI_MODE_MONBSY | SCI_MODE_PAR_CHK); + /* If this target's bit is set, do NOT check parity. */ + if (sc->sc_parity_disable & target_mask) + *sc->sci_mode = (SCI_MODE_MONBSY); + else + *sc->sci_mode = (SCI_MODE_MONBSY | SCI_MODE_PAR_CHK); return XS_NOERROR; } @@ -2333,7 +2347,7 @@ do_actions: * We have to wait here for BSY to drop, otherwise * the next command may decide we need a bus reset. */ - timo = ncr5380_wait_nrq_timo; /* XXX */ + timo = ncr5380_wait_req_timo; /* XXX */ for (;;) { if (!SCI_BUSY(sc)) goto busfree; @@ -2342,8 +2356,9 @@ do_actions: delay(2); } /* Device is sitting on the bus! */ - printf("%s: SCSI job did not finish, resetting...\n", - sc->sc_dev.dv_xname); + printf("%s: Target %d LUN %d stuck busy, resetting...\n", + sc->sc_dev.dv_xname, + sr->sr_target, sr->sr_lun); ncr5380_reset_scsibus(sc); busfree: NCR_TRACE("machine: discon, waited %d\n", diff --git a/sys/dev/ic/ncr5380var.h b/sys/dev/ic/ncr5380var.h index ec9086c3df8..534105dfc29 100644 --- a/sys/dev/ic/ncr5380var.h +++ b/sys/dev/ic/ncr5380var.h @@ -1,5 +1,5 @@ -/* $OpenBSD: ncr5380var.h,v 1.3 1996/04/18 23:47:21 niklas Exp $ */ -/* $NetBSD: ncr5380var.h,v 1.5 1996/03/01 01:42:07 gwr Exp $ */ +/* $OpenBSD: ncr5380var.h,v 1.4 1996/05/26 00:27:02 deraadt Exp $ */ +/* $NetBSD: ncr5380var.h,v 1.6 1996/05/10 18:04:06 gwr Exp $ */ /* * Copyright (c) 1995 David Jones, Gordon W. Ross @@ -111,6 +111,9 @@ struct ncr5380_softc { #define NCR5380_PERMIT_RESELECT 1 /* Allow disconnect/reselect */ #define NCR5380_FORCE_POLLING 2 /* Do not use interrupts. */ + /* Set bits in this to disable parity for some target. */ + int sc_parity_disable; + int sc_min_dma_len; /* Smaller than this is done with PIO */ /* Begin MI shared data */ diff --git a/sys/dev/ic/pdq.c b/sys/dev/ic/pdq.c index 1ee64d8d4a1..099ea3247a1 100644 --- a/sys/dev/ic/pdq.c +++ b/sys/dev/ic/pdq.c @@ -1,8 +1,8 @@ -/* $OpenBSD: pdq.c,v 1.2 1996/04/18 23:47:22 niklas Exp $ */ -/* $NetBSD: pdq.c,v 1.3 1996/03/11 21:41:28 thorpej Exp $ */ +/* $OpenBSD: pdq.c,v 1.3 1996/05/26 00:27:02 deraadt Exp $ */ +/* $NetBSD: pdq.c,v 1.5 1996/05/20 00:26:15 thorpej Exp $ */ /*- - * Copyright (c) 1995 Matt Thomas (matt@lkg.dec.com) + * Copyright (c) 1995,1996 Matt Thomas <matt@3am-software.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,103 +24,43 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * from Id: pdq.c,v 1.18 1995/08/20 18:59:00 thomas Exp thomas - * - * Log: pdq.c,v - * Revision 1.18 1995/08/20 18:59:00 thomas - * Changes for NetBSD - * - * Revision 1.17 1995/08/16 22:57:28 thomas - * Add support for NetBSD - * - * Revision 1.16 1995/08/04 21:54:56 thomas - * Clean IRQ processing under BSD/OS. - * A receive tweaks. (print source of MAC CRC errors, etc.) - * - * Revision 1.15 1995/06/30 23:36:21 thomas - * Optimize fix. - * - * Revision 1.14 1995/06/30 23:35:39 thomas - * Fix severe bug in transmit path (corruption of ring). - * - * Revision 1.13 1995/06/21 18:29:27 thomas - * SVR4.2 changes - * - * Revision 1.12 1995/06/05 23:49:36 thomas - * Fix bonehead error. Don't try to queue a command if there - * is a command. - * - * Revision 1.11 1995/06/03 15:43:26 thomas - * Fix the command submission logic to only submit one - * command at a time no matter what. This simplies the - * code significantly thereby allowing us to do some up - * front optimizations. - * - * Revision 1.10 1995/06/02 22:18:34 thomas - * Don't know why but on some motherboards, the PDQ just can't - * multiple outstanding commands. - * - * Revision 1.9 1995/04/20 20:17:33 thomas - * Add PCI support for BSD/OS. - * Fix BSD/OS EISA support. - * Set latency timer for DEFPA to recommended value if 0. - * - * Revision 1.8 1995/03/14 01:52:52 thomas - * Update for new FreeBSD PCI Interrupt interface - * - * Revision 1.7 1995/03/07 23:03:16 thomas - * Fix SMT queue processing - * - * Revision 1.6 1995/03/06 18:03:47 thomas - * restart trasmitter once link is available - * - * Revision 1.5 1995/03/06 17:07:56 thomas - * Add copyright/disclaimer - * Add error recovery code. - * Add BPF SMT support - * - * Revision 1.3 1995/03/03 13:48:35 thomas - * more fixes - * + * Id: pdq.c,v 1.26 1996/05/17 01:15:18 thomas Exp * */ /* * DEC PDQ FDDI Controller O/S independent code * - * Written by Matt Thomas <matt@lkg.dec.com> - * * This module should work any PDQ based board. Note that changes for * MIPS and Alpha architectures (or any other architecture which requires * a flushing of memory or write buffers and/or has incoherent caches) * have yet to be made. + * + * However, it is expected that the PDQ_CSR_WRITE macro will cause a + * flushing of the write buffers. */ #define PDQ_HWSUPPORT /* for pdq.h */ -#include "pdqreg.h" -#if defined(__NetBSD__) #include "pdqvar.h" -#else -#include "pdq_os.h" -#endif +#include "pdqreg.h" #define PDQ_ROUNDUP(n, x) (((n) + ((x) - 1)) & ~((x) - 1)) #define PDQ_CMD_RX_ALIGNMENT 16 -#if defined(PDQTEST) && !defined(PDQ_NOPRINTF) +#if (defined(PDQTEST) && !defined(PDQ_NOPRINTF)) || defined(PDQVERBOSE) #define PDQ_PRINTF(x) printf x #else #define PDQ_PRINTF(x) do { } while (0) #endif -const char * const pdq_halt_codes[] = { +static const char * const pdq_halt_codes[] = { "Selftest Timeout", "Host Bus Parity Error", "Host Directed Fault", "Software Fault", "Hardware Fault", "PC Trace Path Test", "DMA Error", "Image CRC Error", "Adapter Processer Error" }; -const char * const pdq_adapter_states[] = { +static const char * const pdq_adapter_states[] = { "Reset", "Upgrade", "DMA Unavailable", "DMA Available", "Link Available", "Link Unavailable", "Halted", "Ring Member" }; @@ -129,19 +69,19 @@ const char * const pdq_adapter_states[] = { * The following are used in conjunction with * unsolicited events */ -const char * const pdq_entities[] = { +static const char * const pdq_entities[] = { "Station", "Link", "Phy Port" }; -const char * const pdq_station_events[] = { +static const char * const pdq_station_events[] = { "Trace Received" }; -const char * const pdq_station_arguments[] = { +static const char * const pdq_station_arguments[] = { "Reason" }; -const char * const pdq_link_events[] = { +static const char * const pdq_link_events[] = { "Transmit Underrun", "Transmit Failed", "Block Check Error (CRC)", @@ -163,63 +103,63 @@ const char * const pdq_link_events[] = { "Directed Beacon Received", }; -const char * const pdq_link_arguments[] = { +static const char * const pdq_link_arguments[] = { "Reason", "Data Link Header", "Source", "Upstream Neighbor" }; -const char * const pdq_phy_events[] = { +static const char * const pdq_phy_events[] = { "LEM Error Monitor Reject", "Elasticy Buffer Error", "Link Confidence Test Reject" }; -const char * const pdq_phy_arguments[] = { +static const char * const pdq_phy_arguments[] = { "Direction" }; -const char * const * const pdq_event_arguments[] = { +static const char * const * const pdq_event_arguments[] = { pdq_station_arguments, pdq_link_arguments, pdq_phy_arguments }; -const char * const * const pdq_event_codes[] = { +static const char * const * const pdq_event_codes[] = { pdq_station_events, pdq_link_events, pdq_phy_events }; -const char * const pdq_station_types[] = { +static const char * const pdq_station_types[] = { "SAS", "DAC", "SAC", "NAC", "DAS" }; -const char * const pdq_smt_versions[] = { "", "V6.2", "V7.2", "V7.3" }; +static const char * const pdq_smt_versions[] = { "", "V6.2", "V7.2", "V7.3" }; -const char pdq_phy_types[] = "ABSM"; +static const char pdq_phy_types[] = "ABSM"; -const char * const pdq_pmd_types0[] = { +static const char * const pdq_pmd_types0[] = { "ANSI Multi-Mode", "ANSI Single-Mode Type 1", "ANSI Single-Mode Type 2", "ANSI Sonet" }; -const char * const pdq_pmd_types100[] = { +static const char * const pdq_pmd_types100[] = { "Low Power", "Thin Wire", "Shielded Twisted Pair", "Unshielded Twisted Pair" }; -const char * const * const pdq_pmd_types[] = { +static const char * const * const pdq_pmd_types[] = { pdq_pmd_types0, pdq_pmd_types100 }; -const char * const pdq_descriptions[] = { +static const char * const pdq_descriptions[] = { "DEFPA PCI", "DEFEA EISA", }; -void +static void pdq_print_fddi_chars( pdq_t *pdq, const pdq_response_status_chars_get_t *rsp) @@ -275,44 +215,46 @@ pdq_print_fddi_chars( printf("\n"); } -void +static void pdq_init_csrs( pdq_csrs_t *csrs, - void *csr_va, + pdq_bus_t bus, + pdq_bus_memaddr_t csr_base, size_t csrsize) { - volatile pdq_uint32_t *csr_base = (volatile pdq_uint32_t *) csr_va; - - csrs->csr_port_reset = &csr_base[0 * csrsize]; - csrs->csr_host_data = &csr_base[1 * csrsize]; - csrs->csr_port_control = &csr_base[2 * csrsize]; - csrs->csr_port_data_a = &csr_base[3 * csrsize]; - csrs->csr_port_data_b = &csr_base[4 * csrsize]; - csrs->csr_port_status = &csr_base[5 * csrsize]; - csrs->csr_host_int_type_0 = &csr_base[6 * csrsize]; - csrs->csr_host_int_enable = &csr_base[7 * csrsize]; - csrs->csr_type_2_producer = &csr_base[8 * csrsize]; - csrs->csr_cmd_response_producer = &csr_base[10 * csrsize]; - csrs->csr_cmd_request_producer = &csr_base[11 * csrsize]; - csrs->csr_host_smt_producer = &csr_base[12 * csrsize]; - csrs->csr_unsolicited_producer = &csr_base[13 * csrsize]; + csrs->csr_bus = bus; + csrs->csr_base = csr_base; + csrs->csr_port_reset = PDQ_CSR_OFFSET(csr_base, 0 * csrsize); + csrs->csr_host_data = PDQ_CSR_OFFSET(csr_base, 1 * csrsize); + csrs->csr_port_control = PDQ_CSR_OFFSET(csr_base, 2 * csrsize); + csrs->csr_port_data_a = PDQ_CSR_OFFSET(csr_base, 3 * csrsize); + csrs->csr_port_data_b = PDQ_CSR_OFFSET(csr_base, 4 * csrsize); + csrs->csr_port_status = PDQ_CSR_OFFSET(csr_base, 5 * csrsize); + csrs->csr_host_int_type_0 = PDQ_CSR_OFFSET(csr_base, 6 * csrsize); + csrs->csr_host_int_enable = PDQ_CSR_OFFSET(csr_base, 7 * csrsize); + csrs->csr_type_2_producer = PDQ_CSR_OFFSET(csr_base, 8 * csrsize); + csrs->csr_cmd_response_producer = PDQ_CSR_OFFSET(csr_base, 10 * csrsize); + csrs->csr_cmd_request_producer = PDQ_CSR_OFFSET(csr_base, 11 * csrsize); + csrs->csr_host_smt_producer = PDQ_CSR_OFFSET(csr_base, 12 * csrsize); + csrs->csr_unsolicited_producer = PDQ_CSR_OFFSET(csr_base, 13 * csrsize); } -void +static void pdq_init_pci_csrs( pdq_pci_csrs_t *csrs, - void *csr_va, + pdq_bus_t bus, + pdq_bus_memaddr_t csr_base, size_t csrsize) { - volatile pdq_uint32_t *csr_base = (volatile pdq_uint32_t *) csr_va; - - csrs->csr_pfi_mode_control = &csr_base[16 * csrsize]; - csrs->csr_pfi_status = &csr_base[17 * csrsize]; - csrs->csr_fifo_write = &csr_base[18 * csrsize]; - csrs->csr_fifo_read = &csr_base[19 * csrsize]; + csrs->csr_bus = bus; + csrs->csr_base = csr_base; + csrs->csr_pfi_mode_control = PDQ_CSR_OFFSET(csr_base, 16 * csrsize); + csrs->csr_pfi_status = PDQ_CSR_OFFSET(csr_base, 17 * csrsize); + csrs->csr_fifo_write = PDQ_CSR_OFFSET(csr_base, 18 * csrsize); + csrs->csr_fifo_read = PDQ_CSR_OFFSET(csr_base, 19 * csrsize); } -void +static void pdq_flush_databuf_queue( pdq_databuf_queue_t *q) { @@ -325,51 +267,51 @@ pdq_flush_databuf_queue( } } -pdq_boolean_t +static pdq_boolean_t pdq_do_port_control( const pdq_csrs_t * const csrs, pdq_uint32_t cmd) { int cnt = 0; - *csrs->csr_host_int_type_0 = PDQ_HOST_INT_CSR_CMD_DONE; - *csrs->csr_port_control = PDQ_PCTL_CMD_ERROR | cmd; - while ((*csrs->csr_host_int_type_0 & PDQ_HOST_INT_CSR_CMD_DONE) == 0 && cnt < 33000000) + PDQ_CSR_WRITE(csrs, csr_host_int_type_0, PDQ_HOST_INT_CSR_CMD_DONE); + PDQ_CSR_WRITE(csrs, csr_port_control, PDQ_PCTL_CMD_ERROR | cmd); + while ((PDQ_CSR_READ(csrs, csr_host_int_type_0) & PDQ_HOST_INT_CSR_CMD_DONE) == 0 && cnt < 33000000) cnt++; PDQ_PRINTF(("CSR cmd spun %d times\n", cnt)); - if (*csrs->csr_host_int_type_0 & PDQ_HOST_INT_CSR_CMD_DONE) { - *csrs->csr_host_int_type_0 = PDQ_HOST_INT_CSR_CMD_DONE; - return (*csrs->csr_port_control & PDQ_PCTL_CMD_ERROR) ? PDQ_FALSE : PDQ_TRUE; + if (PDQ_CSR_READ(csrs, csr_host_int_type_0) & PDQ_HOST_INT_CSR_CMD_DONE) { + PDQ_CSR_WRITE(csrs, csr_host_int_type_0, PDQ_HOST_INT_CSR_CMD_DONE); + return (PDQ_CSR_READ(csrs, csr_port_control) & PDQ_PCTL_CMD_ERROR) ? PDQ_FALSE : PDQ_TRUE; } /* adapter failure */ PDQ_ASSERT(0); return PDQ_FALSE; } -void +static void pdq_read_mla( const pdq_csrs_t * const csrs, pdq_lanaddr_t *hwaddr) { pdq_uint32_t data; - *csrs->csr_port_data_a = 0; + PDQ_CSR_WRITE(csrs, csr_port_data_a, 0); pdq_do_port_control(csrs, PDQ_PCTL_MLA_READ); - data = *csrs->csr_host_data; + data = PDQ_CSR_READ(csrs, csr_host_data); hwaddr->lanaddr_bytes[0] = (data >> 0) & 0xFF; hwaddr->lanaddr_bytes[1] = (data >> 8) & 0xFF; hwaddr->lanaddr_bytes[2] = (data >> 16) & 0xFF; hwaddr->lanaddr_bytes[3] = (data >> 24) & 0xFF; - *csrs->csr_port_data_a = 1; + PDQ_CSR_WRITE(csrs, csr_port_data_a, 1); pdq_do_port_control(csrs, PDQ_PCTL_MLA_READ); - data = *csrs->csr_host_data; + data = PDQ_CSR_READ(csrs, csr_host_data); hwaddr->lanaddr_bytes[4] = (data >> 0) & 0xFF; hwaddr->lanaddr_bytes[5] = (data >> 8) & 0xFF; } -void +static void pdq_read_fwrev( const pdq_csrs_t * const csrs, pdq_fwrev_t *fwrev) @@ -377,7 +319,7 @@ pdq_read_fwrev( pdq_uint32_t data; pdq_do_port_control(csrs, PDQ_PCTL_FW_REV_READ); - data = *csrs->csr_host_data; + data = PDQ_CSR_READ(csrs, csr_host_data); fwrev->fwrev_bytes[3] = (data >> 0) & 0xFF; fwrev->fwrev_bytes[2] = (data >> 8) & 0xFF; @@ -385,7 +327,7 @@ pdq_read_fwrev( fwrev->fwrev_bytes[0] = (data >> 24) & 0xFF; } -pdq_boolean_t +static pdq_boolean_t pdq_read_error_log( pdq_t *pdq, pdq_response_error_log_get_t *log_entry) @@ -396,22 +338,22 @@ pdq_read_error_log( pdq_do_port_control(csrs, PDQ_PCTL_ERROR_LOG_START); while (pdq_do_port_control(csrs, PDQ_PCTL_FW_REV_READ) == PDQ_TRUE) { - *ptr++ = *csrs->csr_host_data; + *ptr++ = PDQ_CSR_READ(csrs, csr_host_data); if ((pdq_uint8_t *) ptr - (pdq_uint8_t *) log_entry == sizeof(*log_entry)) break; } return (ptr == (pdq_uint32_t *) log_entry) ? PDQ_FALSE : PDQ_TRUE; } -pdq_chip_rev_t +static pdq_chip_rev_t pdq_read_chiprev( const pdq_csrs_t * const csrs) { pdq_uint32_t data; - *csrs->csr_port_data_a = PDQ_SUB_CMD_PDQ_REV_GET; + PDQ_CSR_WRITE(csrs, csr_port_data_a, PDQ_SUB_CMD_PDQ_REV_GET); pdq_do_port_control(csrs, PDQ_PCTL_SUB_CMD); - data = *csrs->csr_host_data; + data = PDQ_CSR_READ(csrs, csr_host_data); return (pdq_chip_rev_t) data; } @@ -499,7 +441,7 @@ static const struct { #endif }; -void +static void pdq_queue_commands( pdq_t *pdq) { @@ -603,11 +545,11 @@ pdq_queue_commands( pdq_cmd_info[op].cmd_name)); ci->ci_command_active++; - *csrs->csr_cmd_response_producer = ci->ci_response_producer | (ci->ci_response_completion << 8); - *csrs->csr_cmd_request_producer = ci->ci_request_producer | (ci->ci_request_completion << 8); + PDQ_CSR_WRITE(csrs, csr_cmd_response_producer, ci->ci_response_producer | (ci->ci_response_completion << 8)); + PDQ_CSR_WRITE(csrs, csr_cmd_request_producer, ci->ci_request_producer | (ci->ci_request_completion << 8)); } -void +static void pdq_process_command_responses( pdq_t * const pdq) { @@ -650,8 +592,10 @@ pdq_process_command_responses( if (ci->ci_pending_commands != 0) { pdq_queue_commands(pdq); } else { - *csrs->csr_cmd_response_producer = ci->ci_response_producer | (ci->ci_response_completion << 8); - *csrs->csr_cmd_request_producer = ci->ci_request_producer | (ci->ci_request_completion << 8); + PDQ_CSR_WRITE(csrs, csr_cmd_response_producer, + ci->ci_response_producer | (ci->ci_response_completion << 8)); + PDQ_CSR_WRITE(csrs, csr_cmd_request_producer, + ci->ci_request_producer | (ci->ci_request_completion << 8)); } } @@ -661,7 +605,7 @@ pdq_process_command_responses( * event buffers so it can be used to initialize the queue * as well. */ -void +static void pdq_process_unsolicited_events( pdq_t *pdq) { @@ -686,7 +630,7 @@ pdq_process_unsolicited_events( PDQ_OS_PREFIX_ARGS, pdq_entities[event->event_entity], pdq_event_codes[event->event_entity][event->event_code.value]); - if (event->event_type == PDQ_ENTITY_PHY_PORT) + if (event->event_entity == PDQ_ENTITY_PHY_PORT) printf("[%d]", event->event_index); printf("\n"); break; @@ -705,10 +649,11 @@ pdq_process_unsolicited_events( PDQ_ADVANCE(ui->ui_producer, ui->ui_free, PDQ_RING_MASK(dbp->pdqdb_unsolicited_events)); ui->ui_free = 0; - *csrs->csr_unsolicited_producer = ui->ui_producer | (ui->ui_completion << 8); + PDQ_CSR_WRITE(csrs, csr_unsolicited_producer, + ui->ui_producer | (ui->ui_completion << 8)); } -void +static void pdq_process_received_data( pdq_t *pdq, pdq_rx_info_t *rx, @@ -950,7 +895,7 @@ pdq_queue_transmit_data( return PDQ_TRUE; } -void +static void pdq_process_transmitted_data( pdq_t *pdq) { @@ -1010,22 +955,23 @@ pdq_hwreset( pdq_state_t state; int cnt; - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); if (state == PDQS_DMA_UNAVAILABLE) return; - *csrs->csr_port_data_a = (state == PDQS_HALTED) ? 0 : PDQ_PRESET_SKIP_SELFTEST; - *csrs->csr_port_reset = 1; + PDQ_CSR_WRITE(csrs, csr_port_data_a, + (state == PDQS_HALTED) ? 0 : PDQ_PRESET_SKIP_SELFTEST); + PDQ_CSR_WRITE(csrs, csr_port_reset, 1); PDQ_OS_USEC_DELAY(100); - *csrs->csr_port_reset = 0; + PDQ_CSR_WRITE(csrs, csr_port_reset, 0); for (cnt = 45000;;cnt--) { PDQ_OS_USEC_DELAY(1000); - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); if (state == PDQS_DMA_UNAVAILABLE || cnt == 0) break; } PDQ_PRINTF(("PDQ Reset spun %d cycles\n", 45000 - cnt)); PDQ_OS_USEC_DELAY(10000); - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); PDQ_ASSERT(state == PDQS_DMA_UNAVAILABLE); PDQ_ASSERT(cnt > 0); } @@ -1044,10 +990,10 @@ pdq_stop( PDQ_OS_DATABUF_T **buffers; restart: - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); if (state != PDQS_DMA_UNAVAILABLE) { pdq_hwreset(pdq); - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); PDQ_ASSERT(state == PDQS_DMA_UNAVAILABLE); } #if 0 @@ -1055,18 +1001,18 @@ pdq_stop( case PDQS_RING_MEMBER: case PDQS_LINK_UNAVAILABLE: case PDQS_LINK_AVAILABLE: { - *csrs->csr_port_data_a = PDQ_SUB_CMD_LINK_UNINIT; - *csrs->csr_port_data_b = 0; + PDQ_CSR_WRITE(csrs, csr_port_data_a, PDQ_SUB_CMD_LINK_UNINIT); + PDQ_CSR_WRITE(csrs, csr_port_data_b, 0); pdq_do_port_control(csrs, PDQ_PCTL_SUB_CMD); - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); PDQ_ASSERT(state == PDQS_DMA_AVAILABLE); /* FALL THROUGH */ } case PDQS_DMA_AVAILABLE: { - *csrs->csr_port_data_a = 0; - *csrs->csr_port_data_b = 0; + PDQ_CSR_WRITE(csrs, csr_port_data_a, 0); + PDQ_CSR_WRITE(csrs, csr_port_data_b, 0); pdq_do_port_control(csrs, PDQ_PCTL_DMA_UNINIT); - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); PDQ_ASSERT(state == PDQS_DMA_UNAVAILABLE); /* FALL THROUGH */ } @@ -1092,14 +1038,15 @@ pdq_stop( /* * Disable interrupts and DMA. */ - *pdq->pdq_pci_csrs.csr_pfi_mode_control = 0; - *pdq->pdq_pci_csrs.csr_pfi_status = 0x10; + PDQ_CSR_WRITE(&pdq->pdq_pci_csrs, csr_pfi_mode_control, 0); + PDQ_CSR_WRITE(&pdq->pdq_pci_csrs, csr_pfi_status, 0x10); } /* * Flush all the databuf queues. */ pdq_flush_databuf_queue(&pdq->pdq_tx_info.tx_txq); + pdq->pdq_flags &= ~PDQ_TXOK; buffers = (PDQ_OS_DATABUF_T **) pdq->pdq_rx_info.rx_buffers; for (idx = 0; idx < PDQ_RING_SIZE(pdq->pdq_dbp->pdqdb_receives); idx++) { if (buffers[idx] != NULL) { @@ -1153,32 +1100,38 @@ pdq_stop( */ if (pdq->pdq_type == PDQ_DEFPA) { #ifdef PDQTEST - *pdq->pdq_pci_csrs.csr_pfi_mode_control = PDQ_PFI_MODE_DMA_ENABLE; + PDQ_CSR_WRITE(&pdq->pdq_pci_csrs, csr_pfi_mode_control, + PDQ_PFI_MODE_DMA_ENABLE); #else - *pdq->pdq_pci_csrs.csr_pfi_mode_control = PDQ_PFI_MODE_DMA_ENABLE - |PDQ_PFI_MODE_PFI_PCI_INTR|PDQ_PFI_MODE_PDQ_PCI_INTR; + PDQ_CSR_WRITE(&pdq->pdq_pci_csrs, csr_pfi_mode_control, + PDQ_PFI_MODE_DMA_ENABLE + /*|PDQ_PFI_MODE_PFI_PCI_INTR*/|PDQ_PFI_MODE_PDQ_PCI_INTR); #endif } /* - * Make the unsolicited queue has events ... + * Make sure the unsolicited queue has events ... */ pdq_process_unsolicited_events(pdq); - *csrs->csr_port_data_b = PDQ_DMA_BURST_8LW; - *csrs->csr_port_data_a = PDQ_SUB_CMD_DMA_BURST_SIZE_SET; + if (pdq->pdq_type == PDQ_DEFEA && pdq->pdq_chip_rev == PDQ_CHIP_REV_E) + PDQ_CSR_WRITE(csrs, csr_port_data_b, PDQ_DMA_BURST_16LW); + else + PDQ_CSR_WRITE(csrs, csr_port_data_b, PDQ_DMA_BURST_8LW); + PDQ_CSR_WRITE(csrs, csr_port_data_a, PDQ_SUB_CMD_DMA_BURST_SIZE_SET); pdq_do_port_control(csrs, PDQ_PCTL_SUB_CMD); - *csrs->csr_port_data_b = 0; - *csrs->csr_port_data_a = PDQ_OS_VA_TO_PA(pdq->pdq_cbp); + PDQ_CSR_WRITE(csrs, csr_port_data_b, 0); + PDQ_CSR_WRITE(csrs, csr_port_data_a, PDQ_OS_VA_TO_PA(pdq->pdq_cbp)); pdq_do_port_control(csrs, PDQ_PCTL_CONSUMER_BLOCK); - *csrs->csr_port_data_b = 0; - *csrs->csr_port_data_a = PDQ_OS_VA_TO_PA(pdq->pdq_dbp) | PDQ_DMA_INIT_LW_BSWAP_DATA; + PDQ_CSR_WRITE(csrs, csr_port_data_b, 0); + PDQ_CSR_WRITE(csrs, csr_port_data_a, + PDQ_OS_VA_TO_PA(pdq->pdq_dbp) | PDQ_DMA_INIT_LW_BSWAP_DATA); pdq_do_port_control(csrs, PDQ_PCTL_DMA_INIT); for (cnt = 0; cnt < 1000; cnt++) { - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); if (state == PDQS_HALTED) { if (pass > 0) return PDQS_HALTED; @@ -1193,8 +1146,8 @@ pdq_stop( } PDQ_ASSERT(state == PDQS_DMA_AVAILABLE); - *csrs->csr_host_int_type_0 = 0xFF; - *csrs->csr_host_int_enable = 0 /* PDQ_HOST_INT_STATE_CHANGE + PDQ_CSR_WRITE(csrs, csr_host_int_type_0, 0xFF); + PDQ_CSR_WRITE(csrs, csr_host_int_enable, 0) /* PDQ_HOST_INT_STATE_CHANGE |PDQ_HOST_INT_FATAL_ERROR|PDQ_HOST_INT_CMD_RSP_ENABLE |PDQ_HOST_INT_UNSOL_ENABLE */; @@ -1216,7 +1169,7 @@ pdq_stop( break; PDQ_OS_USEC_DELAY(1000); } - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); } return state; @@ -1229,7 +1182,7 @@ pdq_run( const pdq_csrs_t * const csrs = &pdq->pdq_csrs; pdq_state_t state; - state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); PDQ_ASSERT(state != PDQS_DMA_UNAVAILABLE); PDQ_ASSERT(state != PDQS_RESET); PDQ_ASSERT(state != PDQS_HALTED); @@ -1242,10 +1195,10 @@ pdq_run( * So we need to clear all the errors/interrupts so the real * ones will get through. */ - *csrs->csr_host_int_type_0 = 0xFF; - *csrs->csr_host_int_enable = PDQ_HOST_INT_STATE_CHANGE|PDQ_HOST_INT_XMT_DATA_FLUSH + PDQ_CSR_WRITE(csrs, csr_host_int_type_0, 0xFF); + PDQ_CSR_WRITE(csrs, csr_host_int_enable, PDQ_HOST_INT_STATE_CHANGE|PDQ_HOST_INT_XMT_DATA_FLUSH |PDQ_HOST_INT_FATAL_ERROR|PDQ_HOST_INT_CMD_RSP_ENABLE|PDQ_HOST_INT_UNSOL_ENABLE - |PDQ_HOST_INT_RX_ENABLE|PDQ_HOST_INT_TX_ENABLE|PDQ_HOST_INT_HOST_SMT_ENABLE; + |PDQ_HOST_INT_RX_ENABLE|PDQ_HOST_INT_TX_ENABLE|PDQ_HOST_INT_HOST_SMT_ENABLE); /* * Set the MAC and address filters and start up the PDQ. */ @@ -1260,7 +1213,9 @@ pdq_run( pdq->pdq_dbp->pdqdb_host_smt, pdq->pdq_cbp->pdqcb_host_smt, PDQ_RING_MASK(pdq->pdq_dbp->pdqdb_host_smt)); - *csrs->csr_host_smt_producer = pdq->pdq_host_smt_info.rx_producer | (pdq->pdq_host_smt_info.rx_completion << 8); + PDQ_CSR_WRITE(csrs, csr_host_smt_producer, + pdq->pdq_host_smt_info.rx_producer + | (pdq->pdq_host_smt_info.rx_completion << 8)); } pdq->pdq_command_info.ci_pending_commands = PDQ_BITMASK(PDQC_FILTER_SET) | PDQ_BITMASK(PDQC_ADDR_FILTER_SET) | PDQ_BITMASK(PDQC_START); @@ -1280,7 +1235,9 @@ pdq_run( pdq->pdq_dbp->pdqdb_host_smt, pdq->pdq_cbp->pdqcb_host_smt, PDQ_RING_MASK(pdq->pdq_dbp->pdqdb_host_smt)); - *csrs->csr_host_smt_producer = pdq->pdq_host_smt_info.rx_producer | (pdq->pdq_host_smt_info.rx_completion << 8); + PDQ_CSR_WRITE(csrs, csr_host_smt_producer, + pdq->pdq_host_smt_info.rx_producer + | (pdq->pdq_host_smt_info.rx_completion << 8)); } pdq_process_unsolicited_events(pdq); pdq_queue_commands(pdq); @@ -1300,10 +1257,9 @@ pdq_interrupt( int progress = 0; if (pdq->pdq_type == PDQ_DEFPA) - if (*pdq->pdq_pci_csrs.csr_pfi_status & 0x10) - *pdq->pdq_pci_csrs.csr_pfi_status = 0x10; + PDQ_CSR_WRITE(&pdq->pdq_pci_csrs, csr_pfi_status, 0x18); - while ((data = *csrs->csr_port_status) & PDQ_PSTS_INTR_PENDING) { + while ((data = PDQ_CSR_READ(csrs, csr_port_status)) & PDQ_PSTS_INTR_PENDING) { progress = 1; PDQ_PRINTF(("PDQ Interrupt: Status = 0x%08x\n", data)); if (data & PDQ_PSTS_RCV_DATA_PENDING) { @@ -1318,7 +1274,7 @@ pdq_interrupt( pdq->pdq_dbp->pdqdb_host_smt, pdq->pdq_cbp->pdqcb_host_smt, PDQ_RING_MASK(pdq->pdq_dbp->pdqdb_host_smt)); - *csrs->csr_host_smt_producer = pdq->pdq_host_smt_info.rx_producer | (pdq->pdq_host_smt_info.rx_completion << 8); + PDQ_DO_HOST_SMT_PRODUCER(pdq); } if (data & PDQ_PSTS_XMT_DATA_PENDING) pdq_process_transmitted_data(pdq); @@ -1327,9 +1283,9 @@ pdq_interrupt( if (data & PDQ_PSTS_CMD_RSP_PENDING) pdq_process_command_responses(pdq); if (data & PDQ_PSTS_TYPE_0_PENDING) { - data = *csrs->csr_host_int_type_0; + data = PDQ_CSR_READ(csrs, csr_host_int_type_0); if (data & PDQ_HOST_INT_STATE_CHANGE) { - pdq_state_t state = PDQ_PSTS_ADAPTER_STATE(*csrs->csr_port_status); + pdq_state_t state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(csrs, csr_port_status)); printf(PDQ_OS_PREFIX "%s", PDQ_OS_PREFIX_ARGS, pdq_adapter_states[state]); if (state == PDQS_LINK_UNAVAILABLE) { pdq->pdq_flags &= ~PDQ_TXOK; @@ -1338,12 +1294,12 @@ pdq_interrupt( pdq_os_restart_transmitter(pdq); } else if (state == PDQS_HALTED) { pdq_response_error_log_get_t log_entry; - pdq_halt_code_t halt_code = PDQ_PSTS_HALT_ID(*csrs->csr_port_status); + pdq_halt_code_t halt_code = PDQ_PSTS_HALT_ID(PDQ_CSR_READ(csrs, csr_port_status)); printf(": halt code = %d (%s)\n", halt_code, pdq_halt_codes[halt_code]); - if (halt_code == PDQH_DMA_ERROR) { + if (halt_code == PDQH_DMA_ERROR && pdq->pdq_type == PDQ_DEFPA) { PDQ_PRINTF(("\tPFI status = 0x%x, Host 0 Fatal Interrupt = 0x%x\n", - *pdq->pdq_pci_csrs.csr_pfi_status, + PDQ_CSR_READ(&pdq->pdq_pci_csrs, csr_pfi_status), data & PDQ_HOST_INT_FATAL_ERROR)); } pdq_read_error_log(pdq, &log_entry); @@ -1353,7 +1309,7 @@ pdq_interrupt( return 1; } printf("\n"); - *csrs->csr_host_int_type_0 = PDQ_HOST_INT_STATE_CHANGE; + PDQ_CSR_WRITE(csrs, csr_host_int_type_0, PDQ_HOST_INT_STATE_CHANGE); } if (data & PDQ_HOST_INT_FATAL_ERROR) { pdq_stop(pdq); @@ -1366,19 +1322,19 @@ pdq_interrupt( pdq->pdq_flags &= ~PDQ_TXOK; pdq_flush_transmitter(pdq); pdq_do_port_control(csrs, PDQ_PCTL_XMT_DATA_FLUSH_DONE); - *csrs->csr_host_int_type_0 = PDQ_HOST_INT_XMT_DATA_FLUSH; + PDQ_CSR_WRITE(csrs, csr_host_int_type_0, PDQ_HOST_INT_XMT_DATA_FLUSH); } } if (pdq->pdq_type == PDQ_DEFPA) - if (*pdq->pdq_pci_csrs.csr_pfi_status & 0x10) - *pdq->pdq_pci_csrs.csr_pfi_status = 0x10; + PDQ_CSR_WRITE(&pdq->pdq_pci_csrs, csr_pfi_status, 0x18); } return progress; } pdq_t * pdq_initialize( - void *csr_va, + pdq_bus_t bus, + pdq_bus_memaddr_t csr_base, const char *name, int unit, void *ctx, @@ -1489,42 +1445,39 @@ pdq_initialize( /* * Initialize the CSR references. + * the DEFAA (FutureBus+) skips a longword between registers */ - pdq_init_csrs(&pdq->pdq_csrs, csr_va, 1); - switch (pdq->pdq_type) { - case PDQ_DEFPA: pdq_init_pci_csrs(&pdq->pdq_pci_csrs, csr_va, 1); break; -#ifdef PDQ_DO_EISA - case PDQ_DEFEA: pdq_init_esia_csrs(&pdq->pdq_eisa_csrs, csr_va, 1); break; -#endif - } + pdq_init_csrs(&pdq->pdq_csrs, bus, csr_base, pdq->pdq_type == PDQ_DEFAA ? 2 : 1); + if (pdq->pdq_type == PDQ_DEFPA) + pdq_init_pci_csrs(&pdq->pdq_pci_csrs, bus, csr_base, 1); - PDQ_PRINTF(("PDQ CSRs:\n")); + PDQ_PRINTF(("PDQ CSRs: BASE = %x\n", pdq->pdq_csrs.csr_base)); PDQ_PRINTF((" Port Reset = %x [0x%08x]\n", - pdq->pdq_csrs.csr_port_reset, *pdq->pdq_csrs.csr_port_reset)); + pdq->pdq_csrs.csr_port_reset, PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_reset))); PDQ_PRINTF((" Host Data = %x [0x%08x]\n", - pdq->pdq_csrs.csr_host_data, *pdq->pdq_csrs.csr_host_data)); + pdq->pdq_csrs.csr_host_data, PDQ_CSR_READ(&pdq->pdq_csrs, csr_host_data))); PDQ_PRINTF((" Port Control = %x [0x%08x]\n", - pdq->pdq_csrs.csr_port_control, *pdq->pdq_csrs.csr_port_control)); + pdq->pdq_csrs.csr_port_control, PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_control))); PDQ_PRINTF((" Port Data A = %x [0x%08x]\n", - pdq->pdq_csrs.csr_port_data_a, *pdq->pdq_csrs.csr_port_data_a)); + pdq->pdq_csrs.csr_port_data_a, PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_data_a))); PDQ_PRINTF((" Port Data B = %x [0x%08x]\n", - pdq->pdq_csrs.csr_port_data_b, *pdq->pdq_csrs.csr_port_data_b)); + pdq->pdq_csrs.csr_port_data_b, PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_data_b))); PDQ_PRINTF((" Port Status = %x [0x%08x]\n", - pdq->pdq_csrs.csr_port_status, *pdq->pdq_csrs.csr_port_status)); + pdq->pdq_csrs.csr_port_status, PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_status))); PDQ_PRINTF((" Host Int Type 0 = %x [0x%08x]\n", - pdq->pdq_csrs.csr_host_int_type_0, *pdq->pdq_csrs.csr_host_int_type_0)); + pdq->pdq_csrs.csr_host_int_type_0, PDQ_CSR_READ(&pdq->pdq_csrs, csr_host_int_type_0))); PDQ_PRINTF((" Host Int Enable = %x [0x%08x]\n", - pdq->pdq_csrs.csr_host_int_enable, *pdq->pdq_csrs.csr_host_int_enable)); + pdq->pdq_csrs.csr_host_int_enable, PDQ_CSR_READ(&pdq->pdq_csrs, csr_host_int_enable))); PDQ_PRINTF((" Type 2 Producer = %x [0x%08x]\n", - pdq->pdq_csrs.csr_type_2_producer, *pdq->pdq_csrs.csr_type_2_producer)); + pdq->pdq_csrs.csr_type_2_producer, PDQ_CSR_READ(&pdq->pdq_csrs, csr_type_2_producer))); PDQ_PRINTF((" Command Response Producer = %x [0x%08x]\n", - pdq->pdq_csrs.csr_cmd_response_producer, *pdq->pdq_csrs.csr_cmd_response_producer)); + pdq->pdq_csrs.csr_cmd_response_producer, PDQ_CSR_READ(&pdq->pdq_csrs, csr_cmd_response_producer))); PDQ_PRINTF((" Command Request Producer = %x [0x%08x]\n", - pdq->pdq_csrs.csr_cmd_request_producer, *pdq->pdq_csrs.csr_cmd_request_producer)); + pdq->pdq_csrs.csr_cmd_request_producer, PDQ_CSR_READ(&pdq->pdq_csrs, csr_cmd_request_producer))); PDQ_PRINTF((" Host SMT Producer = %x [0x%08x]\n", - pdq->pdq_csrs.csr_host_smt_producer, *pdq->pdq_csrs.csr_host_smt_producer)); + pdq->pdq_csrs.csr_host_smt_producer, PDQ_CSR_READ(&pdq->pdq_csrs, csr_host_smt_producer))); PDQ_PRINTF((" Unsolicited Producer = %x [0x%08x]\n", - pdq->pdq_csrs.csr_unsolicited_producer, *pdq->pdq_csrs.csr_unsolicited_producer)); + pdq->pdq_csrs.csr_unsolicited_producer, PDQ_CSR_READ(&pdq->pdq_csrs, csr_unsolicited_producer))); /* * Initialize the command information block @@ -1582,7 +1535,7 @@ pdq_initialize( pdq->pdq_tx_info.tx_hdrdesc.txd_sop = 1; pdq->pdq_tx_info.tx_hdrdesc.txd_pa_lo = PDQ_OS_VA_TO_PA(pdq->pdq_tx_hdr); - state = PDQ_PSTS_ADAPTER_STATE(*pdq->pdq_csrs.csr_port_status); + state = PDQ_PSTS_ADAPTER_STATE(PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_status)); PDQ_PRINTF(("PDQ Adapter State = %s\n", pdq_adapter_states[state])); /* @@ -1596,6 +1549,16 @@ pdq_initialize( * If the adapter is not the state we expect, then the initialization * failed. Cleanup and exit. */ +#if defined(PDQVERBOSE) + if (state == PDQS_HALTED) { + pdq_halt_code_t halt_code = PDQ_PSTS_HALT_ID(PDQ_CSR_READ(&pdq->pdq_csrs, csr_port_status)); + printf("Halt code = %d (%s)\n", halt_code, pdq_halt_codes[halt_code]); + if (halt_code == PDQH_DMA_ERROR && pdq->pdq_type == PDQ_DEFPA) + PDQ_PRINTF(("PFI status = 0x%x, Host 0 Fatal Interrupt = 0x%x\n", + PDQ_CSR_READ(&pdq->pdq_pci_csrs, csr_pfi_status), + PDQ_CSR_READ(&pdq->pdq_csrs, csr_host_int_type_0) & PDQ_HOST_INT_FATAL_ERROR)); + } +#endif if (state == PDQS_RESET || state == PDQS_HALTED || state == PDQS_UPGRADE) goto cleanup_and_return; diff --git a/sys/dev/ic/pdq_ifsubr.c b/sys/dev/ic/pdq_ifsubr.c index 4526538ab41..9435e716c18 100644 --- a/sys/dev/ic/pdq_ifsubr.c +++ b/sys/dev/ic/pdq_ifsubr.c @@ -1,8 +1,8 @@ -/* $OpenBSD: pdq_ifsubr.c,v 1.2 1996/05/10 12:41:12 deraadt Exp $ */ -/* $NetBSD: pdq_ifsubr.c,v 1.3 1996/05/07 01:43:15 thorpej Exp $ */ +/* $OpenBSD: pdq_ifsubr.c,v 1.3 1996/05/26 00:27:03 deraadt Exp $ */ +/* $NetBSD: pdq_ifsubr.c,v 1.5 1996/05/20 00:26:21 thorpej Exp $ */ /*- - * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com) + * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,80 +24,19 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * from Id: pdq_ifsubr.c,v 1.2 1995/08/20 18:59:00 thomas Exp - * - * Log: pdq_ifsubr.c,v - * Revision 1.2 1995/08/20 18:59:00 thomas - * Changes for NetBSD - * - * Revision 1.1 1995/08/20 15:43:49 thomas - * Initial revision - * - * Revision 1.13 1995/08/04 21:54:56 thomas - * Clean IRQ processing under BSD/OS. - * A receive tweaks. (print source of MAC CRC errors, etc.) - * - * Revision 1.12 1995/06/02 16:04:22 thomas - * Use correct PCI defs for BSDI now that they have fixed them. - * Increment the slot number 0x1000, not one! (*duh*) - * - * Revision 1.11 1995/04/21 13:23:55 thomas - * Fix a few pub in the DEFPA BSDI support - * - * Revision 1.10 1995/04/20 21:46:42 thomas - * Why??? - * , - * - * Revision 1.9 1995/04/20 20:17:33 thomas - * Add PCI support for BSD/OS. - * Fix BSD/OS EISA support. - * Set latency timer for DEFPA to recommended value if 0. - * - * Revision 1.8 1995/04/04 22:54:29 thomas - * Fix DEFEA support - * - * Revision 1.7 1995/03/14 01:52:52 thomas - * Update for new FreeBSD PCI Interrupt interface - * - * Revision 1.6 1995/03/10 17:06:59 thomas - * Update for latest version of FreeBSD. - * Compensate for the fast that the ifp will not be first thing - * in softc on BSDI. - * - * Revision 1.5 1995/03/07 19:59:42 thomas - * First pass at BSDI EISA support - * - * Revision 1.4 1995/03/06 17:06:03 thomas - * Add transmit timeout support. - * Add support DEFEA (untested). - * - * Revision 1.3 1995/03/03 13:48:35 thomas - * more fixes - * + * Id: pdq_ifsubr.c,v 1.6 1996/05/16 14:25:26 thomas Exp * */ /* * DEC PDQ FDDI Controller; code for BSD derived operating systems * - * Written by Matt Thomas - * - * This driver supports the following FDDI controllers: - * - * Device: Config file entry: - * DEC DEFPA (PCI) device fpa0 - * DEC DEFEA (EISA) device fea0 at isa0 net irq ? vector feaintr - * - * Eventually, the following adapters will also be supported: - * - * DEC DEFTA (TC) device fta0 at tc? slot * vector ftaintr - * DEC DEFQA (Q-Bus) device fta0 at uba? csr 0?? vector fqaintr - * DEC DEFAA (FB+) device faa0 at fbus? slot * vector faaintr + * This module provide bus independent BSD specific O/S functions. + * (ie. it provides an ifnet interface to the rest of the system) */ #include <sys/param.h> -#include <sys/systm.h> #include <sys/kernel.h> #include <sys/mbuf.h> #include <sys/protosw.h> @@ -135,6 +74,10 @@ #include <net/if_fddi.h> #endif +#if defined(__bsdi__) && _BSDI_VERSION < 199401 +#include <i386/isa/isavar.h> +#endif + #ifdef NS #include <netns/ns.h> #include <netns/ns_if.h> @@ -144,12 +87,23 @@ #include <vm/vm_kern.h> #include <vm/vm_param.h> -#include "pdqreg.h" -#if defined(__NetBSD__) #include "pdqvar.h" -#else -#include "pdq_os.h" +#include "pdqreg.h" + +#if defined(__bsdi__) && _BSDI_VERSION < 199506 /* XXX */ +static void +arp_ifinit( + struct arpcom *ac, + struct ifaddr *ifa) +{ + sc->sc_ac.ac_ipaddr = IA_SIN(ifa)->sin_addr; + arpwhohas(&sc->sc_ac, &IA_SIN(ifa)->sin_addr); +#if _BSDI_VERSION >= 199401 + ifa->ifa_rtrequest = arp_rtrequest; + ifa->ifa_flags |= RTF_CLONING; #endif +#endif + void pdq_ifinit( @@ -183,18 +137,18 @@ pdq_ifinit( void pdq_ifwatchdog( - pdq_softc_t *sc) + struct ifnet *ifp) { - struct mbuf *m; /* * No progress was made on the transmit queue for PDQ_OS_TX_TRANSMIT * seconds. Remove all queued packets. */ - sc->sc_if.if_flags &= ~IFF_OACTIVE; - sc->sc_if.if_timer = 0; + ifp->if_flags &= ~IFF_OACTIVE; + ifp->if_timer = 0; for (;;) { - IF_DEQUEUE(&sc->sc_if.if_snd, m); + struct mbuf *m; + IF_DEQUEUE(&ifp->if_snd, m); if (m == NULL) return; m_freem(m); @@ -247,7 +201,7 @@ pdq_os_receive_pdu( sc->sc_if.if_ipackets++; #if NBPFILTER > 0 if (sc->sc_bpf != NULL) - bpf_mtap(sc->sc_bpf, m); + PDQ_BPF_MTAP(sc, m); if ((fh->fddi_fc & (FDDIFC_L|FDDIFC_F)) != FDDIFC_LLC_ASYNC) { m_freem(m); return; @@ -283,7 +237,7 @@ pdq_os_transmit_done( pdq_softc_t *sc = (pdq_softc_t *) pdq->pdq_os_ctx; #if NBPFILTER > 0 if (sc->sc_bpf != NULL) - bpf_mtap(sc->sc_bpf, m); + PDQ_BPF_MTAP(sc, m); #endif m_freem(m); sc->sc_if.if_opackets++; @@ -327,22 +281,15 @@ pdq_ifioctl( ifp->if_flags |= IFF_UP; switch(ifa->ifa_addr->sa_family) { -#ifdef INET +#if defined(INET) case AF_INET: { - sc->sc_ac.ac_ipaddr = IA_SIN(ifa)->sin_addr; pdq_ifinit(sc); -#if !defined(__bsdi__) arp_ifinit(&sc->sc_ac, ifa); -#else - arpwhohas(&sc->sc_ac, &IA_SIN(ifa)->sin_addr); - ifa->ifa_rtrequest = arp_rtrequest; - ifa->ifa_flags |= RTF_CLONING; -#endif break; } #endif /* INET */ -#ifdef NS +#if defined(NS) /* This magic copied from if_is.c; I don't use XNS, * so I have no way of telling if this actually * works or not. @@ -404,20 +351,24 @@ pdq_ifioctl( return error; } +#ifndef IFF_NOTRAILERS +#define IFF_NOTRAILERS 0 +#endif + void pdq_ifattach( pdq_softc_t *sc, - pdq_ifinit_t ifinit, - pdq_ifwatchdog_t ifwatchdog) + ifnet_ret_t (*ifwatchdog)(int unit)) { struct ifnet *ifp = &sc->sc_if; ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST; -#if !defined(__NetBSD__) - ifp->if_init = ifinit; -#endif +#if (defined(__FreeBSD__) && BSD >= 199506) || defined(__NetBSD__) + ifp->if_watchdog = pdq_ifwatchdog; +#else ifp->if_watchdog = ifwatchdog; +#endif ifp->if_ioctl = pdq_ifioctl; ifp->if_output = fddi_output; @@ -426,6 +377,6 @@ pdq_ifattach( if_attach(ifp); fddi_ifattach(ifp); #if NBPFILTER > 0 - bpfattach(&sc->sc_bpf, ifp, DLT_FDDI, sizeof(struct fddi_header)); + PDQ_BPFATTACH(sc, DLT_FDDI, sizeof(struct fddi_header)); #endif } diff --git a/sys/dev/ic/pdqreg.h b/sys/dev/ic/pdqreg.h index 8dd9a28dd58..a8850f08b19 100644 --- a/sys/dev/ic/pdqreg.h +++ b/sys/dev/ic/pdqreg.h @@ -1,8 +1,8 @@ -/* $OpenBSD: pdqreg.h,v 1.2 1996/04/18 23:47:24 niklas Exp $ */ -/* $NetBSD: pdqreg.h,v 1.3 1996/03/11 21:41:33 thorpej Exp $ */ +/* $OpenBSD: pdqreg.h,v 1.3 1996/05/26 00:27:04 deraadt Exp $ */ +/* $NetBSD: pdqreg.h,v 1.4 1996/05/20 00:26:23 thorpej Exp $ */ /*- - * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com) + * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,33 +24,13 @@ * (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: pdqreg.h,v 1.6 1995/06/03 15:43:26 thomas Exp - * - * Log: pdqreg.h,v - * Revision 1.6 1995/06/03 15:43:26 thomas - * Fix the command submission logic to only submit one - * command at a time no matter what. This simplies the - * code significantly thereby allowing us to do some up - * front optimizations. - * - * Revision 1.5 1995/03/10 17:41:55 thomas - * Add DEFTA, DEFQA, and DEFAA - * - * Revision 1.4 1995/03/06 17:07:05 thomas - * Add copyright/disclaimer - * Add EISA register definitions - * - * Revision 1.3 1995/03/03 13:48:35 thomas - * more fixes - * + * Id: pdqreg.h,v 1.9 1996/05/16 14:25:26 thomas Exp * */ /* * DEC PDQ FDDI Controller; PDQ port driver definitions * - * Written by Matt Thomas - * */ #ifndef _PDQREG_H @@ -88,21 +68,17 @@ #define PDQ_FDDI_PH1 0x38 #define PDQ_FDDI_PH2 0x00 -typedef unsigned int pdq_uint32_t; -typedef unsigned short pdq_uint16_t; -typedef unsigned char pdq_uint8_t; - typedef pdq_uint32_t pdq_physaddr_t; -typedef struct { +struct _pdq_lanaddr_t { pdq_uint8_t lanaddr_bytes[8]; -} pdq_lanaddr_t; +}; typedef struct { pdq_uint8_t fwrev_bytes[4]; } pdq_fwrev_t; -typedef enum { +enum _pdq_state_t { PDQS_RESET=0, PDQS_UPGRADE=1, PDQS_DMA_UNAVAILABLE=2, @@ -111,30 +87,34 @@ typedef enum { PDQS_LINK_UNAVAILABLE=5, PDQS_HALTED=6, PDQS_RING_MEMBER=7 -} pdq_state_t; +}; -typedef struct { - volatile pdq_uint32_t *csr_port_reset; /* 0x00 [RW] */ - volatile pdq_uint32_t *csr_host_data; /* 0x04 [R] */ - volatile pdq_uint32_t *csr_port_control; /* 0x08 [RW] */ - volatile pdq_uint32_t *csr_port_data_a; /* 0x0C [RW] */ - volatile pdq_uint32_t *csr_port_data_b; /* 0x10 [RW] */ - volatile pdq_uint32_t *csr_port_status; /* 0x14 [R] */ - volatile pdq_uint32_t *csr_host_int_type_0; /* 0x18 [RW] */ - volatile pdq_uint32_t *csr_host_int_enable; /* 0x1C [RW] */ - volatile pdq_uint32_t *csr_type_2_producer; /* 0x20 [RW] */ - volatile pdq_uint32_t *csr_cmd_response_producer; /* 0x28 [RW] */ - volatile pdq_uint32_t *csr_cmd_request_producer; /* 0x2C [RW] */ - volatile pdq_uint32_t *csr_host_smt_producer; /* 0x30 [RW] */ - volatile pdq_uint32_t *csr_unsolicited_producer; /* 0x34 [RW] */ -} pdq_csrs_t; +struct _pdq_csrs_t { + pdq_bus_memoffset_t csr_port_reset; /* 0x00 [RW] */ + pdq_bus_memoffset_t csr_host_data; /* 0x04 [R] */ + pdq_bus_memoffset_t csr_port_control; /* 0x08 [RW] */ + pdq_bus_memoffset_t csr_port_data_a; /* 0x0C [RW] */ + pdq_bus_memoffset_t csr_port_data_b; /* 0x10 [RW] */ + pdq_bus_memoffset_t csr_port_status; /* 0x14 [R] */ + pdq_bus_memoffset_t csr_host_int_type_0; /* 0x18 [RW] */ + pdq_bus_memoffset_t csr_host_int_enable; /* 0x1C [RW] */ + pdq_bus_memoffset_t csr_type_2_producer; /* 0x20 [RW] */ + pdq_bus_memoffset_t csr_cmd_response_producer; /* 0x28 [RW] */ + pdq_bus_memoffset_t csr_cmd_request_producer; /* 0x2C [RW] */ + pdq_bus_memoffset_t csr_host_smt_producer; /* 0x30 [RW] */ + pdq_bus_memoffset_t csr_unsolicited_producer; /* 0x34 [RW] */ + pdq_bus_t csr_bus; + pdq_bus_memaddr_t csr_base; +}; -typedef struct { - volatile pdq_uint32_t *csr_pfi_mode_control; /* 0x40 [RW] */ - volatile pdq_uint32_t *csr_pfi_status; /* 0x44 [RW] */ - volatile pdq_uint32_t *csr_fifo_write; /* 0x48 [RW] */ - volatile pdq_uint32_t *csr_fifo_read; /* 0x4C [RW] */ -} pdq_pci_csrs_t; +struct _pdq_pci_csrs_t { + pdq_bus_memoffset_t csr_pfi_mode_control; /* 0x40 [RW] */ + pdq_bus_memoffset_t csr_pfi_status; /* 0x44 [RW] */ + pdq_bus_memoffset_t csr_fifo_write; /* 0x48 [RW] */ + pdq_bus_memoffset_t csr_fifo_read; /* 0x4C [RW] */ + pdq_bus_t csr_bus; + pdq_bus_memaddr_t csr_base; +}; #define PDQ_PFI_MODE_DMA_ENABLE 0x01 /* DMA Enable */ #define PDQ_PFI_MODE_PFI_PCI_INTR 0x02 /* PFI-to-PCI Int Enable */ @@ -189,6 +169,11 @@ typedef struct { #define PDQ_EISA_OUTPUT_PORT 0x0CAD #define PDQ_EISA_FUNCTION_CTRL 0x0CAE +#define PDQ_TC_CSR_OFFSET 0x00100000 +#define PDQ_TC_CSR_SPACE 0x0040 +#define PDQ_FBUS_CSR_OFFSET 0x00200000 +#define PDQ_FBUS_CSR_SPACE 0x0080 + /* * Port Reset Data A Definitions */ @@ -370,14 +355,6 @@ typedef struct { #endif } pdq_descriptor_block_t; -typedef enum { - PDQ_DEFPA, /* PCI-bus */ - PDQ_DEFEA, /* EISA-bus */ - PDQ_DEFTA, /* TurboChannel */ - PDQ_DEFAA, /* FutureBus+ */ - PDQ_DEFQA /* Q-bus */ -} pdq_type_t; - typedef struct { /* * These value manage the available space in command/response @@ -416,10 +393,17 @@ typedef struct { #define PDQ_RX_FC_OFFSET (sizeof(pdq_rxstatus_t) + 3) #define PDQ_RX_SEGCNT ((PDQ_FDDI_MAX + PDQ_OS_DATABUF_SIZE - 1) / PDQ_OS_DATABUF_SIZE) #define PDQ_DO_TYPE2_PRODUCER(pdq) \ - (*pdq->pdq_csrs.csr_type_2_producer = (pdq->pdq_rx_info.rx_producer << 0) \ - | (pdq->pdq_tx_info.tx_producer << 8) \ - | (pdq->pdq_rx_info.rx_completion << 16) \ - | (pdq->pdq_tx_info.tx_completion << 24)) + PDQ_CSR_WRITE(&(pdq)->pdq_csrs, csr_type_2_producer, \ + ((pdq)->pdq_rx_info.rx_producer << 0) \ + | ((pdq)->pdq_tx_info.tx_producer << 8) \ + | ((pdq)->pdq_rx_info.rx_completion << 16) \ + | ((pdq)->pdq_tx_info.tx_completion << 24)) + +#define PDQ_DO_HOST_SMT_PRODUCER(pdq) \ + PDQ_CSR_WRITE(&(pdq)->pdq_csrs, csr_host_smt_producer, \ + ((pdq)->pdq_host_smt_info.rx_producer << 0) \ + | ((pdq)->pdq_host_smt_info.rx_completion << 8))\ + #define PDQ_ADVANCE(n, a, m) ((n) = ((n) + (a)) & (m)) typedef struct { @@ -446,7 +430,7 @@ typedef struct { pdq_uint32_t tx_completion; } pdq_tx_info_t; -typedef struct { +struct _pdq_t { pdq_csrs_t pdq_csrs; pdq_pci_csrs_t pdq_pci_csrs; pdq_type_t pdq_type; @@ -471,7 +455,7 @@ typedef struct { pdq_rx_info_t pdq_rx_info; pdq_rx_info_t pdq_host_smt_info; pdq_uint8_t pdq_tx_hdr[3]; -} pdq_t; +}; typedef enum { PDQC_START=0, @@ -576,10 +560,10 @@ typedef enum { PDQI_FULL_DUPLEX_ENABLE=44 } pdq_item_code_t; -typedef enum { +enum _pdq_boolean_t { PDQ_FALSE=0, PDQ_TRUE=1 -} pdq_boolean_t; +}; typedef enum { PDQ_FILTER_BLOCK=0, diff --git a/sys/dev/ic/pdqvar.h b/sys/dev/ic/pdqvar.h index 3b40d483578..b8eaab5d6da 100644 --- a/sys/dev/ic/pdqvar.h +++ b/sys/dev/ic/pdqvar.h @@ -1,8 +1,8 @@ -/* $OpenBSD: pdqvar.h,v 1.3 1996/05/10 12:41:13 deraadt Exp $ */ -/* $NetBSD: pdqvar.h,v 1.5 1996/05/07 01:43:17 thorpej Exp $ */ +/* $OpenBSD: pdqvar.h,v 1.4 1996/05/26 00:27:05 deraadt Exp $ */ +/* $NetBSD: pdqvar.h,v 1.6 1996/05/20 00:26:26 thorpej Exp $ */ /*- - * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com) + * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,40 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * from Id: pdq_os.h,v 1.11 1995/08/20 18:59:00 thomas Exp - * - * Log: pdq_os.h,v - * Revision 1.11 1995/08/20 18:59:00 thomas - * Changes for NetBSD - * - * Revision 1.10 1995/08/16 22:57:28 thomas - * Add support for NetBSD - * - * Revision 1.9 1995/06/21 18:29:27 thomas - * SVR4.2 changes - * - * Revision 1.8 1995/06/12 17:49:37 thomas - * Add SVR4.2 support - * - * Revision 1.7 1995/04/20 20:17:33 thomas - * Add PCI support for BSD/OS. - * Fix BSD/OS EISA support. - * Set latency timer for DEFPA to recommended value if 0. - * - * Revision 1.6 1995/03/14 01:52:52 thomas - * Update for new FreeBSD PCI Interrupt interface - * Use inl/inb/... inline macros provided by FreeBSD and BSDI - * - * Revision 1.5 1995/03/10 17:42:24 thomas - * More changes for BSDI - * - * Revision 1.4 1995/03/06 17:08:56 thomas - * Add copyright/disclaimer - * Add inx/outx macros - * - * Revision 1.3 1995/03/03 13:48:35 thomas - * more fixes - * + * Id: pdqvar.h,v 1.17 1996/05/17 01:15:18 thomas Exp * */ @@ -73,11 +40,31 @@ #define PDQ_OS_TX_TIMEOUT 5 /* seconds */ +typedef struct _pdq_t pdq_t; +typedef struct _pdq_csrs_t pdq_csrs_t; +typedef struct _pdq_pci_csrs_t pdq_pci_csrs_t; +typedef struct _pdq_lanaddr_t pdq_lanaddr_t; +typedef unsigned int pdq_uint32_t; +typedef unsigned short pdq_uint16_t; +typedef unsigned char pdq_uint8_t; +typedef enum _pdq_boolean_t pdq_boolean_t; +typedef enum _pdq_type_t pdq_type_t; +typedef enum _pdq_state_t pdq_state_t; + +enum _pdq_type_t { + PDQ_DEFPA, /* PCI-bus */ + PDQ_DEFEA, /* EISA-bus */ + PDQ_DEFTA, /* TurboChannel */ + PDQ_DEFAA, /* FutureBus+ */ + PDQ_DEFQA /* Q-bus */ +}; + #if defined(PDQTEST) #include <pdq_os_test.h> #elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__) #include <sys/param.h> +#include <sys/systm.h> #ifndef M_MCAST #include <sys/mbuf.h> #endif /* M_CAST */ @@ -86,13 +73,21 @@ #include <vm/vm_kern.h> #define PDQ_USE_MBUFS +#if defined(__NetBSD__) +#define PDQ_OS_PREFIX "%s: " +#define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name +#else #define PDQ_OS_PREFIX "%s%d: " #define PDQ_OS_PREFIX_ARGS pdq->pdq_os_name, pdq->pdq_unit - +#endif #define PDQ_OS_PAGESIZE NBPG #define PDQ_OS_USEC_DELAY(n) DELAY(n) #define PDQ_OS_MEMZERO(p, n) bzero((caddr_t)(p), (n)) +#if defined(__NetBSD__) && defined(__alpha__) +#define PDQ_OS_VA_TO_PA(p) (vtophys(p) | 0x40000000) +#else #define PDQ_OS_VA_TO_PA(p) vtophys(p) +#endif #define PDQ_OS_MEMALLOC(n) malloc(n, M_DEVBUF, M_NOWAIT) #define PDQ_OS_MEMFREE(p, n) free((void *) p, M_DEVBUF) #ifdef __FreeBSD__ @@ -104,27 +99,93 @@ #endif /* __FreeBSD__ */ #if defined(__FreeBSD__) +#include <vm/pmap.h> +#include <vm/vm_extern.h> #include <machine/cpufunc.h> #include <machine/clock.h> typedef void ifnet_ret_t; typedef int ioctl_cmd_t; +typedef enum { PDQ_BUS_EISA, PDQ_BUS_PCI } pdq_bus_t; +typedef u_int16_t pdq_bus_ioport_t; +typedef volatile pdq_uint32_t *pdq_bus_memaddr_t; +typedef pdq_bus_memaddr_t pdq_bus_memoffset_t; +#if BSD >= 199506 /* __FreeBSD__ */ +#define PDQ_BPF_MTAP(sc, m) bpf_mtap(&(sc)->sc_if, m) +#define PDQ_BPFATTACH(sc, t, s) bpfattach(&(sc)->sc_if, t, s) +#endif + + #elif defined(__bsdi__) #include <machine/inline.h> typedef int ifnet_ret_t; typedef int ioctl_cmd_t; +typedef enum { PDQ_BUS_EISA, PDQ_BUS_PCI } pdq_bus_t; +typedef u_int16_t pdq_bus_ioport_t; +typedef volatile pdq_uint32_t *pdq_bus_memaddr_t; +typedef pdq_bus_memaddr_t pdq_bus_memoffset_t; + + #elif defined(__NetBSD__) +#include <machine/bus.h> +#include <machine/intr.h> typedef void ifnet_ret_t; typedef u_long ioctl_cmd_t; +typedef bus_chipset_tag_t pdq_bus_t; +typedef bus_io_handle_t pdq_bus_ioport_t; +#if defined(PDQ_IOMAPPED) +typedef bus_io_handle_t pdq_bus_memaddr_t; +#else +typedef bus_mem_handle_t pdq_bus_memaddr_t; +#endif +typedef pdq_uint32_t pdq_bus_memoffset_t; +#define PDQ_OS_IOMEM +#define PDQ_OS_IORD_32(t, base, offset) bus_io_read_4 (t, base, offset) +#define PDQ_OS_IOWR_32(t, base, offset, data) bus_io_write_4 (t, base, offset, data) +#define PDQ_OS_IORD_8(t, base, offset) bus_io_read_1 (t, base, offset) +#define PDQ_OS_IOWR_8(t, base, offset, data) bus_io_write_1 (t, base, offset, data) +#define PDQ_OS_MEMRD_32(t, base, offset) bus_mem_read_4(t, base, offset) +#define PDQ_OS_MEMWR_32(t, base, offset, data) bus_mem_write_4(t, base, offset, data) +#define PDQ_CSR_OFFSET(base, offset) (0 + (offset)*sizeof(pdq_uint32_t)) + +#if defined(PDQ_IOMAPPED) +#define PDQ_CSR_WRITE(csr, name, data) PDQ_OS_IOWR_32((csr)->csr_bus, (csr)->csr_base, (csr)->name, data) +#define PDQ_CSR_READ(csr, name) PDQ_OS_IORD_32((csr)->csr_bus, (csr)->csr_base, (csr)->name) +#else +#define PDQ_CSR_WRITE(csr, name, data) PDQ_OS_MEMWR_32((csr)->csr_bus, (csr)->csr_base, (csr)->name, data) +#define PDQ_CSR_READ(csr, name) PDQ_OS_MEMRD_32((csr)->csr_bus, (csr)->csr_base, (csr)->name) +#endif + +#endif + +#if !defined(PDQ_BPF_MTAP) +#define PDQ_BPF_MTAP(sc, m) bpf_mtap((sc)->sc_bpf, m) +#endif + +#if !defined(PDQ_BPFATTACH) +#define PDQ_BPFATTACH(sc, t, s) bpfattach(&(sc)->sc_bpf, &(sc)->sc_if, t, s) +#endif + +#if !defined(PDQ_OS_IOMEM) +#define PDQ_OS_IORD_32(t, base, offset) inl((base) + (offset)) +#define PDQ_OS_IOWR_32(t, base, offset, data) outl((base) + (offset), data) +#define PDQ_OS_IORD_8(t, base, offset) inb((base) + (offset)) +#define PDQ_OS_IOWR_8(t, base, offset, data) outb((base) + (offset), data) +#define PDQ_OS_MEMRD_32(t, base, offset) (0 + *((base) + (offset))) +#define PDQ_OS_MEMWR_32(t, base, offset, data) do *((base) + (offset)) = (data); while (0) +#endif +#ifndef PDQ_CSR_OFFSET +#define PDQ_CSR_OFFSET(base, offset) (0 + (base) + (offset)) +#endif + +#ifndef PDQ_CSR_WRITE +#define PDQ_CSR_WRITE(csr, name, data) PDQ_OS_MEMWR_32((csr)->csr_bus, (csr)->name, 0, data) +#define PDQ_CSR_READ(csr, name) PDQ_OS_MEMRD_32((csr)->csr_bus, (csr)->name, 0) #endif #if !defined(PDQ_HWSUPPORT) -#define PDQ_OS_IORD_32(port) inl(port) -#define PDQ_OS_IOWR_32(port, data) outl(port, data) -#define PDQ_OS_IORD_8(port) inb(port) -#define PDQ_OS_IOWR_8(port, data) outb(port, data) typedef struct { -#ifdef __bsdi__ +#if defined(__bsdi__) struct device sc_dev; /* base device */ struct isadev sc_id; /* ISA device */ struct intrhand sc_ih; /* interrupt vectoring */ @@ -133,31 +194,38 @@ typedef struct { struct device sc_dev; /* base device */ void *sc_ih; /* interrupt vectoring */ void *sc_ats; /* shutdown hook */ +#elif defined(__FreeBSD__) + struct kern_devconf *sc_kdc; /* freebsd cruft */ #endif struct arpcom sc_ac; - pdq_t *sc_pdq; - unsigned sc_iobase; -} pdq_softc_t; - #define sc_if sc_ac.ac_if + pdq_t *sc_pdq; +#if defined(__alpha__) || defined(__i386__) + pdq_bus_ioport_t sc_iobase; +#endif +#ifdef PDQ_IOMAPPED +#define sc_membase sc_iobase +#else + pdq_bus_memaddr_t sc_membase; +#endif + pdq_bus_t sc_bc; +#if !defined(__bsdi__) || _BSDI_VERSION >= 199401 #define sc_bpf sc_if.if_bpf - -#if defined(__NetBSD__) -typedef ifnet_ret_t (*pdq_ifwatchdog_t)(struct ifnet *ifp); -typedef ifnet_ret_t (*pdq_ifinit_t)(struct ifnet *ifp); #else -typedef ifnet_ret_t (*pdq_ifwatchdog_t)(int unit); -typedef ifnet_ret_t (*pdq_ifinit_t)(int unit); + caddr_t sc_bpf; #endif +} pdq_softc_t; + extern void pdq_ifreset(pdq_softc_t *sc); extern void pdq_ifinit(pdq_softc_t *sc); -extern void pdq_ifwatchdog(pdq_softc_t *sc); +extern void pdq_ifwatchdog(struct ifnet *ifp); extern ifnet_ret_t pdq_ifstart(struct ifnet *ifp); extern int pdq_ifioctl(struct ifnet *ifp, ioctl_cmd_t cmd, caddr_t data); -extern void pdq_ifattach(pdq_softc_t *sc, pdq_ifinit_t ifinit, - pdq_ifwatchdog_t ifwatchdog); -#endif /* PDQ_HWSUPPORT */ +extern void pdq_ifattach(pdq_softc_t *sc, ifnet_ret_t (*ifwatchdog)(int unit)); +#endif /* !PDQ_HWSUPPORT */ + + #elif defined(DLPI_PDQ) #include <sys/param.h> #include <sys/kmem.h> @@ -263,39 +331,15 @@ extern void pdq_os_receive_pdu(pdq_t *, PDQ_OS_DATABUF_T *pdu, size_t pdulen); extern void pdq_os_restart_transmitter(pdq_t *pdq); extern void pdq_os_transmit_done(pdq_t *pdq, PDQ_OS_DATABUF_T *pdu); -extern void pdq_print_fddi_chars(pdq_t *pdq, const pdq_response_status_chars_get_t *rsp); - -extern void pdq_init_csrs(pdq_csrs_t *csrs, void *csrs_va, size_t csr_size); -extern void pdq_init_pci_csrs(pdq_pci_csrs_t *csrs, void *csrs_va, size_t csr_size); - -extern void pdq_flush_databuf_queue(pdq_databuf_queue_t *q); - -extern pdq_boolean_t pdq_do_port_control(const pdq_csrs_t * const csrs, pdq_uint32_t cmd); -extern void pdq_read_mla(const pdq_csrs_t * const csrs, pdq_lanaddr_t *hwaddr); -extern void pdq_read_fwrev(const pdq_csrs_t * const csrs, pdq_fwrev_t *fwrev); -extern pdq_boolean_t pdq_read_error_log(pdq_t *pdq, pdq_response_error_log_get_t *log_entry); -extern pdq_chip_rev_t pdq_read_chiprev(const pdq_csrs_t * const csrs); - -extern void pdq_queue_commands(pdq_t *pdq); -extern void pdq_process_command_responses(pdq_t *pdq); -extern void pdq_process_unsolicited_events(pdq_t *pdq); - -extern void pdq_process_received_data(pdq_t *pdq, pdq_rx_info_t *rx, - pdq_rxdesc_t *receives, - pdq_uint32_t completion_goal, - pdq_uint32_t ring_mask); - extern pdq_boolean_t pdq_queue_transmit_data(pdq_t *pdq, PDQ_OS_DATABUF_T *pdu); -extern void pdq_process_transmitted_data(pdq_t *pdq); extern void pdq_flush_transmitter(pdq_t *pdq); - -extern void pdq_hwreset(pdq_t *pdq); -extern pdq_state_t pdq_stop(pdq_t *pdq); extern void pdq_run(pdq_t *pdq); +extern pdq_state_t pdq_stop(pdq_t *pdq); +extern void pdq_hwreset(pdq_t *pdq); extern int pdq_interrupt(pdq_t *pdq); -extern pdq_t *pdq_initialize(void *csr_va, const char *name, int unit, void *ctx, pdq_type_t type); - - +extern pdq_t *pdq_initialize(pdq_bus_t bus, pdq_bus_memaddr_t csr_va, + const char *name, int unit, + void *ctx, pdq_type_t type); #endif /* _PDQ_OS_H */ diff --git a/sys/dev/ic/smc93cx6.c b/sys/dev/ic/smc93cx6.c new file mode 100644 index 00000000000..10405cd0289 --- /dev/null +++ b/sys/dev/ic/smc93cx6.c @@ -0,0 +1,222 @@ +/* $NetBSD: smc93cx6.c,v 1.1 1996/05/16 03:59:10 mycroft Exp $ */ + +/* + * Interface for the 93C46/26/06 serial eeprom parts. + * + * Copyright (c) 1995 Daniel M. Eischen + * 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 + * Daniel M. Eischen. + * 4. Modifications may be freely made to this file if the above conditions + * are met. + */ + +/* + * The instruction set of the 93C46/26/06 chips are as follows: + * + * Start OP + * Function Bit Code Address Data Description + * ------------------------------------------------------------------- + * READ 1 10 A5 - A0 Reads data stored in memory, + * starting at specified address + * EWEN 1 00 11XXXX Write enable must preceed + * all programming modes + * ERASE 1 11 A5 - A0 Erase register A5A4A3A2A1A0 + * WRITE 1 01 A5 - A0 D15 - D0 Writes register + * ERAL 1 00 10XXXX Erase all registers + * WRAL 1 00 01XXXX D15 - D0 Writes to all registers + * EWDS 1 00 00XXXX Disables all programming + * instructions + * *Note: A value of X for address is a don't care condition. + * + * The 93C46 has a four wire interface: clock, chip select, data in, and + * data out. In order to perform one of the above functions, you need + * to enable the chip select for a clock period (typically a minimum of + * 1 usec, with the clock high and low a minimum of 750 and 250 nsec + * respectively. While the chip select remains high, you can clock in + * the instructions (above) starting with the start bit, followed by the + * OP code, Address, and Data (if needed). For the READ instruction, the + * requested 16-bit register contents is read from the data out line but + * is preceded by an initial zero (leading 0, followed by 16-bits, MSB + * first). The clock cycling from low to high initiates the next data + * bit to be sent from the chip. + * + */ + +#include <sys/param.h> +#include <sys/systm.h> +#if defined(__FreeBSD__) +#include <machine/clock.h> +#include <i386/scsi/93cx6.h> +#elif defined(__NetBSD__) +#include <machine/bus.h> +#include <dev/ic/smc93cx6var.h> +#endif + +/* + * Right now, we only have to read the SEEPROM. But we make it easier to + * add other 93Cx6 functions. + */ +static struct seeprom_cmd { + unsigned char len; + unsigned char bits[3]; +} seeprom_read = {3, {1, 1, 0}}; + +#if defined(__FreeBSD__) +#define SEEPROM_INB(sd) inb(sd->sd_iobase) +#define SEEPROM_OUTB(sd, value) outb(sd->sd_iobase, value) +#elif defined(__NetBSD__) +#define SEEPROM_INB(sd) \ + bus_io_read_1(sd->sd_bc, sd->sd_ioh, sd->sd_offset) +#define SEEPROM_OUTB(sd, value) \ + bus_io_write_1(sd->sd_bc, sd->sd_ioh, sd->sd_offset, value) +#endif + +/* + * Wait for the SEERDY to go high; about 800 ns. + */ +#define CLOCK_PULSE(sd, rdy) \ + while ((SEEPROM_INB(sd) & rdy) == 0) { \ + ; /* Do nothing */ \ + } + +/* + * Read the serial EEPROM and returns 1 if successful and 0 if + * not successful. + */ +int +read_seeprom(sd, buf, start_addr, count) + struct seeprom_descriptor *sd; + u_int16_t *buf; +#if defined(__FreeBSD__) + u_int start_addr; + int count; +#elif defined(__NetBSD__) + bus_io_size_t start_addr; + bus_io_size_t count; +#endif +{ + int i = 0, k = 0; + u_int16_t v; + u_int8_t temp; + + /* + * Read the requested registers of the seeprom. The loop + * will range from 0 to count-1. + */ + for (k = start_addr; k < count + start_addr; k++) { + /* Send chip select for one clock cycle. */ + temp = sd->sd_MS ^ sd->sd_CS; + SEEPROM_OUTB(sd, temp ^ sd->sd_CK); + CLOCK_PULSE(sd, sd->sd_RDY); + + /* + * Now we're ready to send the read command followed by the + * address of the 16-bit register we want to read. + */ + for (i = 0; i < seeprom_read.len; i++) { + if (seeprom_read.bits[i] != 0) + temp ^= sd->sd_DO; + SEEPROM_OUTB(sd, temp); + CLOCK_PULSE(sd, sd->sd_RDY); + SEEPROM_OUTB(sd, temp ^ sd->sd_CK); + CLOCK_PULSE(sd, sd->sd_RDY); + if (seeprom_read.bits[i] != 0) + temp ^= sd->sd_DO; + } + /* Send the 6 bit address (MSB first, LSB last). */ + for (i = 5; i >= 0; i--) { + if ((k & (1 << i)) != 0) + temp ^= sd->sd_DO; + SEEPROM_OUTB(sd, temp); + CLOCK_PULSE(sd, sd->sd_RDY); + SEEPROM_OUTB(sd, temp ^ sd->sd_CK); + CLOCK_PULSE(sd, sd->sd_RDY); + if ((k & (1 << i)) != 0) + temp ^= sd->sd_DO; + } + + /* + * Now read the 16 bit register. An initial 0 precedes the + * register contents which begins with bit 15 (MSB) and ends + * with bit 0 (LSB). The initial 0 will be shifted off the + * top of our word as we let the loop run from 0 to 16. + */ + v = 0; + for (i = 16; i >= 0; i--) { + SEEPROM_OUTB(sd, temp); + CLOCK_PULSE(sd, sd->sd_RDY); + v <<= 1; + if (SEEPROM_INB(sd) & sd->sd_DI) + v |= 1; + SEEPROM_OUTB(sd, temp ^ sd->sd_CK); + CLOCK_PULSE(sd, sd->sd_RDY); + } + + buf[k - start_addr] = v; + + /* Reset the chip select for the next command cycle. */ + temp = sd->sd_MS; + SEEPROM_OUTB(sd, temp); + CLOCK_PULSE(sd, sd->sd_RDY); + SEEPROM_OUTB(sd, temp ^ sd->sd_CK); + CLOCK_PULSE(sd, sd->sd_RDY); + SEEPROM_OUTB(sd, temp); + CLOCK_PULSE(sd, sd->sd_RDY); + } +#if 0 + printf ("Serial EEPROM:"); + for (k = 0; k < count; k = k + 1) { + if (((k % 8) == 0) && (k != 0)) + { + printf ("\n "); + } + printf (" 0x%x", buf[k]); + } + printf ("\n"); +#endif + return (1); +} + +int +acquire_seeprom(sd) + struct seeprom_descriptor *sd; +{ + int wait; + + /* + * Request access of the memory port. When access is + * granted, SEERDY will go high. We use a 1 second + * timeout which should be near 1 second more than + * is needed. Reason: after the chip reset, there + * should be no contention. + */ + SEEPROM_OUTB(sd, sd->sd_MS); + wait = 1000; /* 1 second timeout in msec */ + while (--wait && ((SEEPROM_INB(sd) & sd->sd_RDY) == 0)) { + DELAY (1000); /* delay 1 msec */ + } + if ((SEEPROM_INB(sd) & sd->sd_RDY) == 0) { + SEEPROM_OUTB(sd, 0); + return (0); + } + return(1); +} + +void +release_seeprom(sd) + struct seeprom_descriptor *sd; +{ + /* Release access to the memory port and the serial EEPROM. */ + SEEPROM_OUTB(sd, 0); +} diff --git a/sys/dev/ic/smc93cx6var.h b/sys/dev/ic/smc93cx6var.h new file mode 100644 index 00000000000..d1c7c0162cc --- /dev/null +++ b/sys/dev/ic/smc93cx6var.h @@ -0,0 +1,70 @@ +/* + * Interface to the 93C46 serial EEPROM that is used to store BIOS + * settings for the aic7xxx based adaptec SCSI controllers. It can + * also be used for 93C26 and 93C06 serial EEPROMS. + * + * Copyright (c) 1994, 1995 Justin T. Gibbs. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice immediately at the beginning of the file, without modification, + * this list of conditions, and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Absolutely no warranty of function or purpose is made by the author + * Justin T. Gibbs. + * 4. Modifications may be freely made to this file if the above conditions + * are met. + * + * $Id: smc93cx6var.h,v 1.1 1996/05/26 00:27:06 deraadt Exp $ + */ + +#include <sys/param.h> +#if !defined(__NetBSD__) +#include <sys/systm.h> +#endif + +struct seeprom_descriptor { +#if defined(__FreeBSD__) + u_long sd_iobase; +#elif defined(__NetBSD__) + bus_chipset_tag_t sd_bc; + bus_io_handle_t sd_ioh; + bus_io_size_t sd_offset; +#endif + u_int16_t sd_MS; + u_int16_t sd_RDY; + u_int16_t sd_CS; + u_int16_t sd_CK; + u_int16_t sd_DO; + u_int16_t sd_DI; +}; + +/* + * This function will read count 16-bit words from the serial EEPROM and + * return their value in buf. The port address of the aic7xxx serial EEPROM + * control register is passed in as offset. The following parameters are + * also passed in: + * + * CS - Chip select + * CK - Clock + * DO - Data out + * DI - Data in + * RDY - SEEPROM ready + * MS - Memory port mode select + * + * A failed read attempt returns 0, and a successful read returns 1. + */ +#if defined(__FreeBSD__) +int read_seeprom __P((struct seeprom_descriptor *sd, + u_int16_t *buf, u_int start_addr, int count)); +#elif defined(__NetBSD__) +int read_seeprom __P((struct seeprom_descriptor *sd, + u_int16_t *buf, bus_io_size_t start_addr, bus_io_size_t count)); +#endif +int acquire_seeprom __P((struct seeprom_descriptor *sd)); +void release_seeprom __P((struct seeprom_descriptor *sd)); diff --git a/sys/dev/ic/z8530sc.c b/sys/dev/ic/z8530sc.c index 387f2b8aaf7..59e9b22f3cd 100644 --- a/sys/dev/ic/z8530sc.c +++ b/sys/dev/ic/z8530sc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: z8530sc.c,v 1.2 1996/04/21 22:21:35 deraadt Exp $ */ -/* $NetBSD: z8530sc.c,v 1.3 1996/04/10 21:44:35 gwr Exp $ */ +/* $OpenBSD: z8530sc.c,v 1.3 1996/05/26 00:27:06 deraadt Exp $ */ +/* $NetBSD: z8530sc.c,v 1.4 1996/05/17 19:30:34 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -99,7 +99,7 @@ zs_getspeed(cs) tconst = zs_read_reg(cs, 12); tconst |= zs_read_reg(cs, 13) << 8; - return (TCONST_TO_BPS(cs->cs_pclk_div16, tconst)); + return (TCONST_TO_BPS(cs->cs_brg_clk, tconst)); } /* diff --git a/sys/dev/ic/z8530sc.h b/sys/dev/ic/z8530sc.h index f271fe46bde..3af19f88141 100644 --- a/sys/dev/ic/z8530sc.h +++ b/sys/dev/ic/z8530sc.h @@ -1,4 +1,4 @@ -/* $NetBSD: z8530sc.h,v 1.2 1996/04/10 21:44:44 gwr Exp $ */ +/* $NetBSD: z8530sc.h,v 1.3 1996/05/17 19:29:37 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -69,10 +69,11 @@ struct zs_chanstate { volatile u_char *cs_reg_data; /* data or numbered register */ int cs_channel; /* sub-unit number */ - void *cs_private; /* sub-driver data pointer */ + void *cs_private; /* sub-driver data pointer */ struct zsops *cs_ops; - int cs_pclk_div16; /* PCLK / 16 */ + int cs_brg_clk; /* BAUD Rate Generator clock + * (usually PCLK / 16) */ int cs_defspeed; /* default baud rate (from PROM) */ /* @@ -93,7 +94,7 @@ struct zs_chanstate { u_char cs_heldchange; /* change pending (creg != preg) */ u_char cs_rr0; /* last rr0 processed */ - u_char cs_rr0_new; /* rr0 saved in status interrupt. */ + u_char cs_rr0_new; /* rr0 saved in status interrupt. */ char cs_softreq; /* need soft interrupt call */ }; diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index db07810fdf9..9a62a507339 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,5 +1,5 @@ -/* $OpenBSD: z8530tty.c,v 1.3 1996/04/21 22:21:46 deraadt Exp $ */ -/* $NetBSD: z8530tty.c,v 1.6 1996/04/10 21:44:47 gwr Exp $ */ +/* $OpenBSD: z8530tty.c,v 1.4 1996/05/26 00:27:08 deraadt Exp $ */ +/* $NetBSD: z8530tty.c,v 1.8 1996/05/17 22:49:23 gwr Exp $ */ /* * Copyright (c) 1994 Gordon W. Ross @@ -51,6 +51,19 @@ * * This is the "slave" driver that will be attached to * the "zsc" driver for plain "tty" async. serial lines. + * + * Credits, history: + * + * The original version of this code was the sparc/dev/zs.c driver + * as distributed with the Berkeley 4.4 Lite release. Since then, + * Gordon Ross reorganized the code into the current parent/child + * driver scheme, separating the Sun keyboard and mouse support + * into independent child drivers. + * + * RTS/CTS flow-control support was a collaboration of: + * Gordon Ross <gwr@netbsd.org>, + * Bill Studenmund <wrstuden@loki.stanford.edu> + * Ian Dall <Ian.Dall@dsto.defence.gov.au> */ #include <sys/param.h> @@ -96,6 +109,9 @@ extern int zs_check_kgdb(); */ int zstty_rbuf_size = ZSTTY_RING_SIZE; +/* This should usually be 3/4 of ZSTTY_RING_SIZE */ +int zstty_rbuf_hiwat = (ZSTTY_RING_SIZE - (ZSTTY_RING_SIZE >> 2)); + struct zstty_softc { struct device zst_dev; /* required first: base device */ struct tty *zst_tty; @@ -104,22 +120,6 @@ struct zstty_softc { int zst_hwflags; /* see z8530var.h */ int zst_swflags; /* TIOCFLAG_SOFTCAR, ... <ttycom.h> */ - /* Flags to communicate with zstty_softint() */ - volatile int zst_intr_flags; -#define INTR_RX_OVERRUN 1 -#define INTR_TX_EMPTY 2 -#define INTR_ST_CHECK 4 - - /* - * The transmit byte count and address are used for pseudo-DMA - * output in the hardware interrupt code. PDMA can be suspended - * to get pending changes done; heldtbc is used for this. It can - * also be stopped for ^S; this sets TS_TTSTOP in tp->t_state. - */ - int zst_tbc; /* transmit byte count */ - caddr_t zst_tba; /* transmit buffer address */ - int zst_heldtbc; /* held tbc while xmission stopped */ - /* * Printing an overrun error message often takes long enough to * cause another overrun, so we only print one per second. @@ -130,10 +130,31 @@ struct zstty_softc { /* * The receive ring buffer. */ - u_int zst_rbget; /* ring buffer `get' index */ - volatile u_int zst_rbput; /* ring buffer `put' index */ - u_int zst_ringmask; + int zst_rbget; /* ring buffer `get' index */ + volatile int zst_rbput; /* ring buffer `put' index */ + int zst_ringmask; + int zst_rbhiwat; + u_short *zst_rbuf; /* rr1, data pairs */ + + /* + * The transmit byte count and address are used for pseudo-DMA + * output in the hardware interrupt code. PDMA can be suspended + * to get pending changes done; heldtbc is used for this. It can + * also be stopped for ^S; this sets TS_TTSTOP in tp->t_state. + */ + int zst_tbc; /* transmit byte count */ + caddr_t zst_tba; /* transmit buffer address */ + int zst_heldtbc; /* held tbc while xmission stopped */ + + /* Flags to communicate with zstty_softint() */ + volatile char zst_rx_blocked; /* input block at ring */ + volatile char zst_rx_overrun; /* ring overrun */ + volatile char zst_tx_busy; /* working on an output chunk */ + volatile char zst_tx_done; /* done with one output chunk */ + volatile char zst_tx_stopped; /* H/W level stop (lost CTS) */ + volatile char zst_st_check; /* got a status interrupt */ + char pad[2]; }; @@ -157,6 +178,8 @@ cdev_decl(zs); /* open, close, read, write, ioctl, stop, ... */ static void zsstart(struct tty *); static int zsparam(struct tty *, struct termios *); static void zs_modem(struct zstty_softc *zst, int onoff); +static int zshwiflow(struct tty *, int); +static void zs_hwiflow(struct zstty_softc *, int); /* * zstty_match: how is this zs channel configured? @@ -235,8 +258,10 @@ zstty_attach(parent, self, aux) tp->t_dev = dev; tp->t_oproc = zsstart; tp->t_param = zsparam; + tp->t_hwiflow = zshwiflow; zst->zst_tty = tp; + zst->zst_rbhiwat = zstty_rbuf_size; /* impossible value */ zst->zst_ringmask = zstty_rbuf_size - 1; zst->zst_rbuf = malloc(zstty_rbuf_size * sizeof(zst->zst_rbuf[0]), M_DEVBUF, M_WAITOK); @@ -566,6 +591,13 @@ zsstart(tp) goto out; /* + * If under CRTSCTS hfc and halted, do nothing + */ + if (tp->t_cflag & CRTSCTS) + if (zst->zst_tx_stopped) + goto out; + + /* * If there are sleepers, and output has drained below low * water mark, awaken. */ @@ -578,15 +610,16 @@ zsstart(tp) } nch = ndqb(&tp->t_outq, 0); /* XXX */ + (void) splzs(); + if (nch) { register char *p = tp->t_outq.c_cf; /* mark busy, enable tx done interrupts, & send first byte */ tp->t_state |= TS_BUSY; - (void) splzs(); - + zst->zst_tx_busy = 1; cs->cs_preg[1] |= ZSWR1_TIE; - cs->cs_creg[1] |= ZSWR1_TIE; + cs->cs_creg[1] = cs->cs_preg[1]; zs_write_reg(cs, 1, cs->cs_creg[1]); zs_write_data(cs, *p); zst->zst_tba = p + 1; @@ -596,9 +629,8 @@ zsstart(tp) * Nothing to send, turn off transmit done interrupts. * This is useful if something is doing polled output. */ - (void) splzs(); cs->cs_preg[1] &= ~ZSWR1_TIE; - cs->cs_creg[1] &= ~ZSWR1_TIE; + cs->cs_creg[1] = cs->cs_preg[1]; zs_write_reg(cs, 1, cs->cs_creg[1]); } out: @@ -624,8 +656,11 @@ zsstop(tp, flag) if (tp->t_state & TS_BUSY) { /* * Device is transmitting; must stop it. + * Also clear _heldtbc to prevent any + * flow-control event from resuming. */ zst->zst_tbc = 0; + zst->zst_heldtbc = 0; if ((tp->t_state & TS_TTSTOP) == 0) tp->t_state |= TS_FLUSH; } @@ -652,12 +687,7 @@ zsparam(tp, t) zst = zstty_cd.cd_devs[minor(tp->t_dev)]; cs = zst->zst_cs; - /* - * Because PCLK is only run at 4.9 MHz, the fastest we - * can go is 51200 baud (this corresponds to TC=1). - * This is somewhat unfortunate as there is no real - * reason we should not be able to handle higher rates. - */ + /* XXX: Need to use an MD function for this. */ bps = t->c_ospeed; if (bps < 0 || (t->c_ispeed && t->c_ispeed != bps)) return (EINVAL); @@ -666,12 +696,12 @@ zsparam(tp, t) zs_modem(zst, 0); return (0); } - tconst = BPS_TO_TCONST(cs->cs_pclk_div16, bps); + tconst = BPS_TO_TCONST(cs->cs_brg_clk, bps); if (tconst < 0) return (EINVAL); /* Convert back to make sure we can do it. */ - bps = TCONST_TO_BPS(cs->cs_pclk_div16, tconst); + bps = TCONST_TO_BPS(cs->cs_brg_clk, tconst); if (bps != t->c_ospeed) return (EINVAL); tp->t_ispeed = tp->t_ospeed = bps; @@ -714,18 +744,7 @@ zsparam(tp, t) break; } - /* - * Output hardware flow control on the chip is horrendous: if - * carrier detect drops, the receiver is disabled. Hence we - * can only do this when the carrier is on. - */ - tmp3 |= ZSWR3_RX_ENABLE; - if (cflag & CCTS_OFLOW) { - if (zs_read_csr(cs) & ZSRR0_DCD) - tmp3 |= ZSWR3_HFC; - } - - cs->cs_preg[3] = tmp3; + cs->cs_preg[3] = tmp3 | ZSWR3_RX_ENABLE; cs->cs_preg[5] = tmp5 | ZSWR5_TX_ENABLE | ZSWR5_DTR | ZSWR5_RTS; tmp4 = ZSWR4_CLK_X16 | (cflag & CSTOPB ? ZSWR4_TWOSB : ZSWR4_ONESB); @@ -736,14 +755,28 @@ zsparam(tp, t) cs->cs_preg[4] = tmp4; /* + * Output hardware flow control on the chip is horrendous: + * if carrier detect drops, the receiver is disabled. + * Therefore, NEVER set the HFC bit, and instead use + * the status interrupts to detect CTS changes. + */ + if (cflag & CRTSCTS) { + zst->zst_rbhiwat = zstty_rbuf_hiwat; + cs->cs_preg[15] |= ZSWR15_CTS_IE; + } else { + zst->zst_rbhiwat = zstty_rbuf_size; /* impossible value */ + cs->cs_preg[15] &= ~ZSWR15_CTS_IE; + } + + /* * If nothing is being transmitted, set up new current values, * else mark them as pending. */ if (cs->cs_heldchange == 0) { - if (tp->t_state & TS_BUSY) { + if (zst->zst_tx_busy) { zst->zst_heldtbc = zst->zst_tbc; zst->zst_tbc = 0; - cs->cs_heldchange = 1; + cs->cs_heldchange = 0xFFFF; } else { zs_loadchannelregs(cs); } @@ -778,37 +811,113 @@ zs_modem(zst, onoff) s = splzs(); cs->cs_preg[5] = (cs->cs_preg[5] | bis) & and; if (cs->cs_heldchange == 0) { - if (tp->t_state & TS_BUSY) { + if (zst->zst_tx_busy) { zst->zst_heldtbc = zst->zst_tbc; zst->zst_tbc = 0; - cs->cs_heldchange = 1; + cs->cs_heldchange = (1<<5); } else { - cs->cs_creg[5] = (cs->cs_creg[5] | bis) & and; + cs->cs_creg[5] = cs->cs_preg[5]; zs_write_reg(cs, 5, cs->cs_creg[5]); } } splx(s); } +/* + * Try to block or unblock input using hardware flow-control. + * This is called by kern/tty.c if MDMBUF|CRTSCTS is set, and + * if this function returns non-zero, the TS_TBLOCK flag will + * be set or cleared according to the "stop" arg passed. + */ +int +zshwiflow(tp, stop) + struct tty *tp; + int stop; +{ + register struct zstty_softc *zst; + int s; + + zst = zstty_cd.cd_devs[minor(tp->t_dev)]; + + s = splzs(); + if (stop) { + /* + * The tty layer is asking us to block input. + * If we already did it, just return TRUE. + */ + if (zst->zst_rx_blocked) + goto out; + zst->zst_rx_blocked = 1; + } else { + /* + * The tty layer is asking us to resume input. + * The input ring is always empty by now. + */ + zst->zst_rx_blocked = 0; + } + zs_hwiflow(zst, stop); + out: + splx(s); + return 1; +} + +/* + * Internal version of zshwiflow + * called at splzs + */ +static void +zs_hwiflow(zst, stop) + register struct zstty_softc *zst; + int stop; +{ + register struct zs_chanstate *cs; + register struct tty *tp; + register int bis, and; + + cs = zst->zst_cs; + tp = zst->zst_tty; + + if (stop) { + /* Block input (Lower RTS) */ + bis = 0; + and = ~ZSWR5_RTS; + } else { + /* Unblock input (Raise RTS) */ + bis = ZSWR5_RTS; + and = ~0; + } + + cs->cs_preg[5] = (cs->cs_preg[5] | bis) & and; + if (cs->cs_heldchange == 0) { + if (zst->zst_tx_busy) { + zst->zst_heldtbc = zst->zst_tbc; + zst->zst_tbc = 0; + cs->cs_heldchange = (1<<5); + } else { + cs->cs_creg[5] = cs->cs_preg[5]; + zs_write_reg(cs, 5, cs->cs_creg[5]); + } + } +} + /**************************************************************** * Interface to the lower layer (zscc) ****************************************************************/ -/* - * XXX: need to do input flow-control to avoid ring overrun. - */ /* - * receiver ready interrupt. (splzs) + * receiver ready interrupt. + * called at splzs */ static void zstty_rxint(cs) register struct zs_chanstate *cs; { register struct zstty_softc *zst; - register put, put_next, ringmask; + register int cc, put, put_next, ringmask; register u_char c, rr0, rr1; + register u_short ch_rr1; zst = cs->cs_private; put = zst->zst_rbput; @@ -822,18 +931,21 @@ nextchar: */ rr1 = zs_read_reg(cs, 1); c = zs_read_data(cs); + ch_rr1 = (c << 8) | rr1; - if (rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) { + if (ch_rr1 & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE)) { /* Clear the receive error. */ zs_write_csr(cs, ZSWR0_RESET_ERRORS); } - zst->zst_rbuf[put] = (c << 8) | rr1; + /* XXX: Check for the stop character? */ + + zst->zst_rbuf[put] = ch_rr1; put_next = (put + 1) & ringmask; /* Would overrun if increment makes (put==get). */ if (put_next == zst->zst_rbget) { - zst->zst_intr_flags |= INTR_RX_OVERRUN; + zst->zst_rx_overrun = 1; } else { /* OK, really increment. */ put = put_next; @@ -847,6 +959,17 @@ nextchar: /* Done reading. */ zst->zst_rbput = put; + /* + * If ring is getting too full, try to block input. + */ + cc = put - zst->zst_rbget; + if (cc < 0) + cc += zstty_rbuf_size; + if ((cc > zst->zst_rbhiwat) && (zst->zst_rx_blocked == 0)) { + zst->zst_rx_blocked = 1; + zs_hwiflow(zst, 1); + } + /* Ask for softint() call. */ cs->cs_softreq = 1; } @@ -862,7 +985,26 @@ zstty_txint(cs) register int count; zst = cs->cs_private; - count = zst->zst_tbc; + + /* + * If we suspended output for a "held" change, + * then handle that now and resume. + * Do flow-control changes ASAP. + * When the only change is for flow control, + * avoid hitting other registers, because that + * often makes the stupid zs drop input... + */ + if (cs->cs_heldchange) { + if (cs->cs_heldchange == (1<<5)) { + /* Avoid whacking the chip... */ + cs->cs_creg[5] = cs->cs_preg[5]; + zs_write_reg(cs, 5, cs->cs_creg[5]); + } else + zs_loadchannelregs(cs); + cs->cs_heldchange = 0; + count = zst->zst_heldtbc; + } else + count = zst->zst_tbc; /* * If our transmit buffer still has data, @@ -879,7 +1021,8 @@ zstty_txint(cs) zs_write_csr(cs, ZSWR0_RESET_TXINT); /* Ask the softint routine for more output. */ - zst->zst_intr_flags |= INTR_TX_EMPTY; + zst->zst_tx_busy = 0; + zst->zst_tx_done = 1; cs->cs_softreq = 1; } @@ -901,26 +1044,6 @@ zstty_stint(cs) zs_write_csr(cs, ZSWR0_RESET_STATUS); /* - * The chip's hardware flow control is, as noted in zsreg.h, - * busted---if the DCD line goes low the chip shuts off the - * receiver (!). If we want hardware CTS flow control but do - * not have it, and carrier is now on, turn HFC on; if we have - * HFC now but carrier has gone low, turn it off. - */ - if (rr0 & ZSRR0_DCD) { - if (tp->t_cflag & CCTS_OFLOW && - (cs->cs_creg[3] & ZSWR3_HFC) == 0) { - cs->cs_creg[3] |= ZSWR3_HFC; - zs_write_reg(cs, 3, cs->cs_creg[3]); - } - } else { - if (cs->cs_creg[3] & ZSWR3_HFC) { - cs->cs_creg[3] &= ~ZSWR3_HFC; - zs_write_reg(cs, 3, cs->cs_creg[3]); - } - } - - /* * Check here for console break, so that we can abort * even when interrupts are locking up the machine. */ @@ -931,8 +1054,21 @@ zstty_stint(cs) return; } + /* + * Need to handle CTS output flow control here. + * Output remains stopped as long as either the + * zst_tx_stopped or TS_TTSTOP flag is set. + * Never restart here; the softint routine will + * do that after things are ready to move. + */ + if (((rr0 & ZSRR0_CTS) == 0) && (tp->t_cflag & CRTSCTS)) { + zst->zst_tbc = 0; + zst->zst_heldtbc = 0; + zst->zst_tx_stopped = 1; + } + cs->cs_rr0_new = rr0; - zst->zst_intr_flags |= INTR_ST_CHECK; + zst->zst_st_check = 1; /* Ask for softint() call. */ cs->cs_softreq = 1; @@ -957,6 +1093,15 @@ zsoverrun(zst, ptime, what) /* * Software interrupt. Called at zssoft + * + * The main job to be done here is to empty the input ring + * by passing its contents up to the tty layer. The ring is + * always emptied during this operation, therefore the ring + * must not be larger than the space after "high water" in + * the tty layer, or the tty layer might drop our input. + * + * Note: an "input blockage" condition is assumed to exist if + * EITHER the TS_TBLOCK flag or zst_rx_blocked flag is set. */ static void zstty_softint(cs) @@ -966,28 +1111,23 @@ zstty_softint(cs) register struct linesw *line; register struct tty *tp; register int get, c, s; - int intr_flags, ringmask; + int ringmask, overrun; register u_short ring_data; - register u_char rr0, rr1; + register u_char rr0, rr1, delta; zst = cs->cs_private; tp = zst->zst_tty; line = &linesw[tp->t_line]; ringmask = zst->zst_ringmask; - - /* Atomically get and clear flags. */ - s = splzs(); - intr_flags = zst->zst_intr_flags; - zst->zst_intr_flags = 0; + overrun = 0; /* - * Lower to tty priority while servicing the ring. + * Raise to tty priority while servicing the ring. */ - (void) spltty(); + s = spltty(); - if (intr_flags & INTR_RX_OVERRUN) { - /* May turn this on again below. */ - intr_flags &= ~INTR_RX_OVERRUN; + if (zst->zst_rx_overrun) { + zst->zst_rx_overrun = 0; zsoverrun(zst, &zst->zst_rotime, "ring"); } @@ -1000,7 +1140,7 @@ zstty_softint(cs) get = (get + 1) & ringmask; if (ring_data & ZSRR1_DO) - intr_flags |= INTR_RX_OVERRUN; + overrun++; /* low byte of ring_data is rr1 */ c = (ring_data >> 8) & 0xff; if (ring_data & ZSRR1_FE) @@ -1017,57 +1157,61 @@ zstty_softint(cs) * copying char/status pairs from the ring, which * means this was a hardware (fifo) overrun. */ - if (intr_flags & INTR_RX_OVERRUN) { + if (overrun) { zsoverrun(zst, &zst->zst_fotime, "fifo"); } - if (intr_flags & INTR_TX_EMPTY) { - /* - * The transmitter output buffer count is zero. - * If we suspended output for a "held" change, - * then handle that now and resume. Otherwise, - * try to start a new output chunk. - */ - if (cs->cs_heldchange) { - (void) splzs(); - rr0 = zs_read_csr(cs); - if ((rr0 & ZSRR0_DCD) == 0) - cs->cs_preg[3] &= ~ZSWR3_HFC; - zs_loadchannelregs(cs); - (void) spltty(); - cs->cs_heldchange = 0; - if (zst->zst_heldtbc && - (tp->t_state & TS_TTSTOP) == 0) - { - zst->zst_tbc = zst->zst_heldtbc - 1; - zs_write_data(cs, *zst->zst_tba); - zst->zst_tba++; - goto tx_resumed; + /* + * We have emptied the input ring. Maybe unblock input. + * Note: an "input blockage" condition is assumed to exist + * when EITHER zst_rx_blocked or the TS_TBLOCK flag is set, + * so unblock here ONLY if TS_TBLOCK has not been set. + */ + if (zst->zst_rx_blocked && ((tp->t_state & TS_TBLOCK) == 0)) { + (void) splzs(); + zst->zst_rx_blocked = 0; + zs_hwiflow(zst, 0); /* unblock input */ + (void) spltty(); + } + + /* + * Do any deferred work for status interrupts. + * The rr0 was saved in the h/w interrupt to + * avoid another splzs in here. + */ + if (zst->zst_st_check) { + zst->zst_st_check = 0; + + rr0 = cs->cs_rr0_new; + delta = rr0 ^ cs->cs_rr0; + cs->cs_rr0 = rr0; + if (delta & ZSRR0_DCD) { + c = ((rr0 & ZSRR0_DCD) != 0); + if (line->l_modem(tp, c) == 0) + zs_modem(zst, c); + } + if ((delta & ZSRR0_CTS) && (tp->t_cflag & CRTSCTS)) { + /* + * Only do restart here. Stop is handled + * at the h/w interrupt level. + */ + if (rr0 & ZSRR0_CTS) { + zst->zst_tx_stopped = 0; + tp->t_state &= ~TS_TTSTOP; + (*line->l_start)(tp); } } + } + + if (zst->zst_tx_done) { + zst->zst_tx_done = 0; tp->t_state &= ~TS_BUSY; if (tp->t_state & TS_FLUSH) tp->t_state &= ~TS_FLUSH; else ndflush(&tp->t_outq, zst->zst_tba - - (caddr_t) tp->t_outq.c_cf); + (caddr_t) tp->t_outq.c_cf); line->l_start(tp); - tx_resumed: - } - - if (intr_flags & INTR_ST_CHECK) { - /* - * Status line change. HFC bit is run in - * hardware interrupt, to avoid locking - * at splzs here. - */ - rr0 = cs->cs_rr0_new; - if ((rr0 ^ cs->cs_rr0) & ZSRR0_DCD) { - c = ((rr0 & ZSRR0_DCD) != 0); - if (line->l_modem(tp, c) == 0) - zs_modem(zst, c); - } - cs->cs_rr0 = rr0; } splx(s); diff --git a/sys/dev/isa/aha.c b/sys/dev/isa/aha.c index cc6e2a826b0..94cf9130897 100644 --- a/sys/dev/isa/aha.c +++ b/sys/dev/isa/aha.c @@ -1,5 +1,5 @@ -/* $OpenBSD: aha.c,v 1.18 1996/05/10 12:35:01 deraadt Exp $ */ -/* $NetBSD: aha.c,v 1.10 1996/05/05 00:40:01 mycroft Exp $ */ +/* $OpenBSD: aha.c,v 1.19 1996/05/26 00:27:09 deraadt Exp $ */ +/* $NetBSD: aha.c,v 1.11 1996/05/12 23:51:23 mycroft Exp $ */ #define AHADIAG #define integrate @@ -60,6 +60,7 @@ #include <sys/proc.h> #include <sys/user.h> +#include <machine/intr.h> #include <machine/pio.h> #include <scsi/scsi_all.h> diff --git a/sys/dev/isa/aha284x.c b/sys/dev/isa/aha284x.c deleted file mode 100644 index bff15bed8e3..00000000000 --- a/sys/dev/isa/aha284x.c +++ /dev/null @@ -1,188 +0,0 @@ -/* $NetBSD: aha284x.c,v 1.4 1996/04/11 22:28:04 cgd Exp $ */ - -/* - * Copyright (c) 1996 Michael Graff. 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Graff. - * 4. 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. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/kernel.h> -#include <sys/device.h> - -#include <scsi/scsi_all.h> -#include <scsi/scsiconf.h> - -#include <dev/isa/isavar.h> - -#include <dev/ic/aic7xxxvar.h> - -#include <machine/pio.h> - -static int ahe_probe __P((struct device *, void *, void *)); -static void ahe_attach __P((struct device *, struct device *, void *)); - -struct cfattach ahe_ca = { - sizeof(struct ahc_softc), ahe_probe, ahe_attach -}; - -struct cfdriver ahe_cd = { - NULL, "ahe", DV_DULL -}; - -/* - * shouldn't this be in aic7xxxvar.h? - */ -int ahcintr __P((void *)); - -/* - * Standard EISA Host ID regs (Offset from slot base) - * These seem to work on the aha284x as well (VLB card) - */ -#define HID0 0xC80 /* 0,1: msb of ID2, 2-7: ID1 */ -#define HID1 0xC81 /* 0-4: ID3, 5-7: LSB ID2 */ -#define HID2 0xC82 /* product */ -#define HID3 0xC83 /* firmware revision */ - -#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@') -#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@') -#define CHAR3(B1,B2) ((B2 & 0x1F) | '@') - -typedef struct { - ahc_type type; - unsigned char id; /* The Last EISA Host ID reg */ -} aic7770_sig; - -aic7770_sig valid_ids[] = { - /* Entries of other tested adaptors should be added here */ - { AHC_274, 0x70 }, /*aic7770 on Motherboard*/ - { AHC_274, 0x71 }, /*274x*/ - { AHC_284, 0x56 }, /*284x, BIOS enabled*/ - { AHC_284, 0x57 } /*284x, BIOS disabled*/ -}; - -int -ahe_probe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct ahc_softc *ahc = match; - struct isa_attach_args *ia = aux; - - char intdef; - int iobase; - u_char sig_id[4]; - int i; - -#ifdef NEWCONFIG - if (ia->ia_iobase == IOBASEUNK) - return 0; -#endif - - /* - * Make the offsets the same as for EISA - * - * I have NO idea why the values in aic7xxx.c are all 0xc00 too - * high, but this hack fixes it. This is the same hack that's in - * the 294x pci code. - */ - iobase = ia->ia_iobase - 0xc00; - - for (i = 0; i < sizeof(sig_id); i++) { - /* - * An outb is required to prime these - * registers on VL cards - */ - outb(iobase + HID0, HID0 + i); - sig_id[i] = inb(iobase + HID0 + i); - } - - if (sig_id[0] == 0xff) - return 0; - - if (CHAR1(sig_id[0], sig_id[1]) != 'A' - || CHAR2(sig_id[0], sig_id[1]) != 'D' - || CHAR3(sig_id[0], sig_id[1]) != 'P' - || sig_id[2] != 0x77) - return 0; - - ahc->type = 0; - - for (i = 0; i < sizeof(valid_ids)/sizeof(aic7770_sig); i++) - if (sig_id[3] == valid_ids[i].id) { - ahc->type = valid_ids[i].type; - break; - } - - if (ahc->type == 0) - printf("%s: Unknown board type 0x%02x\n", - ahc->sc_dev.dv_xname, sig_id[3]); - - if (ahcprobe(ahc, iobase) == 0) - return 0; - - /* - * set up some other isa variables and make certain the irq the - * card is set at matches the one in the configuration file, - * it is wa defined there - */ - - ia->ia_iosize = 0x100; /* address range for the card */ - - if (ia->ia_irq == IRQUNK) - ia->ia_irq = ahc->sc_irq; /* probed from the card */ - else - if (ia->ia_irq != ahc->sc_irq) { - printf("%s: irq mismatch; kernel configured %d != board configured %d\n", - ahc->sc_dev.dv_xname, ia->ia_irq, ahc->sc_irq); - return 0; - } - - /* Must be ok... */ - return 1; -} - -void -ahe_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct ahc_softc *ahc = (void *)self; - struct isa_attach_args *ia = aux; - -#ifdef NEWCONFIG - isa_establish(&ahc->sc_id, &ahc->sc_dev); -#endif - ahc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, - IPL_BIO, ahcintr, ahc, ahc->sc_dev.dv_xname); - - /* - * attach the devices on the bus - */ - ahcattach(ahc); -} diff --git a/sys/dev/isa/aic6360.c b/sys/dev/isa/aic6360.c index 5f29e589674..9ce8e590f43 100644 --- a/sys/dev/isa/aic6360.c +++ b/sys/dev/isa/aic6360.c @@ -1,5 +1,5 @@ -/* $OpenBSD: aic6360.c,v 1.8 1996/05/07 07:36:09 deraadt Exp $ */ -/* $NetBSD: aic6360.c,v 1.45 1996/04/29 20:02:45 christos Exp $ */ +/* $OpenBSD: aic6360.c,v 1.9 1996/05/26 00:27:11 deraadt Exp $ */ +/* $NetBSD: aic6360.c,v 1.46 1996/05/12 23:51:37 mycroft Exp $ */ #define integrate static inline @@ -128,6 +128,7 @@ #include <sys/user.h> #include <sys/queue.h> +#include <machine/intr.h> #include <machine/pio.h> #include <scsi/scsi_all.h> diff --git a/sys/dev/isa/ast.c b/sys/dev/isa/ast.c index 32331305bc5..fd63423c6a5 100644 --- a/sys/dev/isa/ast.c +++ b/sys/dev/isa/ast.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ast.c,v 1.10 1996/05/10 12:35:41 deraadt Exp $ */ -/* $NetBSD: ast.c,v 1.27 1996/05/05 19:49:54 christos Exp $ */ +/* $OpenBSD: ast.c,v 1.11 1996/05/26 00:27:11 deraadt Exp $ */ +/* $NetBSD: ast.c,v 1.28 1996/05/12 23:51:45 mycroft Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -39,12 +39,8 @@ #include <sys/device.h> #include <sys/termios.h> -#ifdef i386 /* XXX */ -#include <machine/cpu.h> /* XXX */ -#else /* XXX */ -#include <machine/intr.h> -#endif /* XXX */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> diff --git a/sys/dev/isa/boca.c b/sys/dev/isa/boca.c index a53a052500a..6473e0f82a3 100644 --- a/sys/dev/isa/boca.c +++ b/sys/dev/isa/boca.c @@ -1,5 +1,5 @@ -/* $OpenBSD: boca.c,v 1.9 1996/05/10 12:35:42 deraadt Exp $ */ -/* $NetBSD: boca.c,v 1.14 1996/05/05 19:49:55 christos Exp $ */ +/* $OpenBSD: boca.c,v 1.10 1996/05/26 00:27:12 deraadt Exp $ */ +/* $NetBSD: boca.c,v 1.15 1996/05/12 23:51:50 mycroft Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -39,12 +39,8 @@ #include <sys/device.h> #include <sys/termios.h> -#ifdef i386 /* XXX */ -#include <machine/cpu.h> /* XXX */ -#else /* XXX */ -#include <machine/intr.h> -#endif /* XXX */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> diff --git a/sys/dev/isa/bt.c b/sys/dev/isa/bt.c index 39c2904476e..02be97419ab 100644 --- a/sys/dev/isa/bt.c +++ b/sys/dev/isa/bt.c @@ -1,4 +1,4 @@ -/* $NetBSD: bt.c,v 1.9 1996/04/29 20:02:53 christos Exp $ */ +/* $NetBSD: bt.c,v 1.10 1996/05/12 23:51:54 mycroft Exp $ */ #define BTDIAG #define integrate @@ -59,6 +59,7 @@ #include <sys/proc.h> #include <sys/user.h> +#include <machine/intr.h> #include <machine/pio.h> #include <scsi/scsi_all.h> diff --git a/sys/dev/isa/com.c b/sys/dev/isa/com.c index 409afeb3c58..e5da21469df 100644 --- a/sys/dev/isa/com.c +++ b/sys/dev/isa/com.c @@ -1,5 +1,5 @@ -/* $OpenBSD: com.c,v 1.14 1996/05/10 12:37:13 deraadt Exp $ */ -/* $NetBSD: com.c,v 1.81 1996/05/05 19:50:44 christos Exp $ */ +/* $OpenBSD: com.c,v 1.15 1996/05/26 00:27:14 deraadt Exp $ */ +/* $NetBSD: com.c,v 1.82 1996/05/12 23:52:00 mycroft Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996 @@ -57,12 +57,8 @@ #include <sys/types.h> #include <sys/device.h> -#ifdef i386 /* XXX */ -#include <machine/cpu.h> /* XXX */ -#else /* XXX */ -#include <machine/intr.h> -#endif /* XXX */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index 96a8fad62e3..6f240edf660 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,5 +1,5 @@ -# $OpenBSD: files.isa,v 1.16 1996/05/10 12:33:24 deraadt Exp $ -# $NetBSD: files.isa,v 1.20 1996/05/07 01:50:09 thorpej Exp $ +# $OpenBSD: files.isa,v 1.17 1996/05/26 00:27:14 deraadt Exp $ +# $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $ # # Config.new file and device description for machine-independent ISA code. # Included by ports that need it. Requires that the SCSI files be diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index b45a5005882..f87d3928e19 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,5 +1,5 @@ -/* $OpenBSD: gus.c,v 1.10 1996/05/07 07:36:36 deraadt Exp $ */ -/* $NetBSD: gus.c,v 1.15 1996/05/03 22:35:24 jtk Exp $ */ +/* $OpenBSD: gus.c,v 1.11 1996/05/26 00:27:15 deraadt Exp $ */ +/* $NetBSD: gus.c,v 1.16 1996/05/12 23:52:08 mycroft Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -111,6 +111,7 @@ #include <sys/kernel.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <machine/cpufunc.h> #include <sys/audioio.h> diff --git a/sys/dev/isa/if_ed.c b/sys/dev/isa/if_ed.c index d520b509d41..cd989034f91 100644 --- a/sys/dev/isa/if_ed.c +++ b/sys/dev/isa/if_ed.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ed.c,v 1.15 1996/05/10 12:41:16 deraadt Exp $ */ -/* $NetBSD: if_ed.c,v 1.98 1996/05/07 01:55:13 thorpej Exp $ */ +/* $OpenBSD: if_ed.c,v 1.16 1996/05/26 00:27:17 deraadt Exp $ */ +/* $NetBSD: if_ed.c,v 1.100 1996/05/12 23:52:19 mycroft Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -50,6 +50,7 @@ #include <machine/cpu.h> #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> @@ -456,7 +457,7 @@ ed_find_WD80x3(sc, cf, ia) bus_mem_handle_t memh; u_int memsize; u_char iptr, isa16bit, sum; - int i, rv, mapped_mem = 0; + int i, rv, memfail, mapped_mem = 0; int asicbase, nicbase; bc = ia->ia_bc; @@ -795,25 +796,47 @@ ed_find_WD80x3(sc, cf, ia) (void) bus_io_read_1(bc, delayioh, 0); /* Now zero memory and verify that it is clear. */ - for (i = 0; i < memsize; ++i) - bus_mem_write_1(bc, memh, sc->mem_start + i, 0); - - for (i = 0; i < memsize; ++i) - if (bus_mem_read_1(bc, memh, sc->mem_start + i)) { - printf("%s: failed to clear shared memory at %x - check configuration\n", - sc->sc_dev.dv_xname, - (ia->ia_maddr + sc->mem_start + i)); + if (isa16bit) { + for (i = 0; i < memsize; i += 2) + bus_mem_write_2(bc, memh, sc->mem_start + i, 0); + } else { + for (i = 0; i < memsize; ++i) + bus_mem_write_1(bc, memh, sc->mem_start + i, 0); + } - /* Disable 16 bit access to shared memory. */ - bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, - sc->wd_msr_proto); - if (isa16bit) - bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR, - sc->wd_laar_proto); - (void) bus_io_read_1(bc, delayioh, 0); - (void) bus_io_read_1(bc, delayioh, 0); - goto out; + memfail = 0; + if (isa16bit) { + for (i = 0; i < memsize; i += 2) { + if (bus_mem_read_2(bc, memh, sc->mem_start + i)) { + memfail = 1; + break; + } + } + } else { + for (i = 0; i < memsize; ++i) { + if (bus_mem_read_1(bc, memh, sc->mem_start + i)) { + memfail = 1; + break; + } } + } + + if (memfail) { + printf("%s: failed to clear shared memory at %x - " + "check configuration\n", + sc->sc_dev.dv_xname, + (ia->ia_maddr + sc->mem_start + i)); + + /* Disable 16 bit access to shared memory. */ + bus_io_write_1(bc, ioh, asicbase + ED_WD_MSR, + sc->wd_msr_proto); + if (isa16bit) + bus_io_write_1(bc, ioh, asicbase + ED_WD_LAAR, + sc->wd_laar_proto); + (void) bus_io_read_1(bc, delayioh, 0); + (void) bus_io_read_1(bc, delayioh, 0); + goto out; + } /* * Disable 16bit access to shared memory - we leave it disabled @@ -869,8 +892,8 @@ ed_find_3Com(sc, cf, ia) bus_chipset_tag_t bc; bus_io_handle_t ioh; bus_mem_handle_t memh; - int i; - u_int memsize; + int i, rv, mapped_mem = 0; + u_int memsize, memfail; u_char isa16bit, x; int ptr, asicbase, nicbase; @@ -880,7 +903,6 @@ ed_find_3Com(sc, cf, ia) */ memsize = 8192; - bc = ia->ia_bc; if (bus_io_map(bc, ia->ia_iobase, ED_WD_IO_PORTS, &ioh)) @@ -1100,17 +1122,39 @@ ed_find_3Com(sc, cf, ia) bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR1, 0xff); bus_io_write_1(bc, ioh, asicbase + ED_3COM_VPTR0, 0x00); - /* Zero memory and verify that it is clear. */ - for (i = 0; i < memsize; ++i) - bus_mem_write_1(bc, memh, sc->mem_start + i, 0); + /* Now zero memory and verify that it is clear. */ + if (isa16bit) { + for (i = 0; i < memsize; i += 2) + bus_mem_write_2(bc, memh, sc->mem_start + i, 0); + } else { + for (i = 0; i < memsize; ++i) + bus_mem_write_1(bc, memh, sc->mem_start + i, 0); + } - for (i = 0; i < memsize; ++i) - if (bus_mem_read_1(bc, memh, sc->mem_start + i)) { - printf("%s: failed to clear shared memory at %x - check configuration\n", - sc->sc_dev.dv_xname, - (ia->ia_maddr + sc->mem_start + i)); - goto out; + memfail = 0; + if (isa16bit) { + for (i = 0; i < memsize; i += 2) { + if (bus_mem_read_2(bc, memh, sc->mem_start + i)) { + memfail = 1; + break; + } } + } else { + for (i = 0; i < memsize; ++i) { + if (bus_mem_read_1(bc, memh, sc->mem_start + i)) { + memfail = 1; + break; + } + } + } + + if (memfail) { + printf("%s: failed to clear shared memory at %x - " + "check configuration\n", + sc->sc_dev.dv_xname, + (ia->ia_maddr + sc->mem_start + i)); + goto out; + } ia->ia_msize = memsize; ia->ia_iosize = ED_3COM_IO_PORTS; @@ -2706,35 +2750,59 @@ ed_getmcaf(ac, af) } void -ed_shared_writemem(sc, buf, card, len) +ed_shared_writemem(sc, from, card, len) struct ed_softc *sc; - caddr_t buf; + caddr_t from; int card, len; { bus_chipset_tag_t bc = sc->sc_bc; bus_mem_handle_t memh = sc->sc_memh; - u_int8_t *ptr = (u_int8_t *)buf; - int i; - /* XXX should have bus_mem_copyout_{1,2,4,8}() */ - - for (i = 0; i < len; ++i) - bus_mem_write_1(bc, memh, card + i, ptr[i]); + /* + * For 16-bit cards, 16-bit memory access has already + * been set up. Note that some cards are really picky + * about enforcing 16-bit access to memory, so we + * have to be careful. + */ + if (sc->isa16bit) { + while (len > 1) { + bus_mem_write_2(bc, memh, card, + *((u_int16_t *)from)); + from += 2; + card += 2; + len -= 2; + } + if (len == 1) + bus_mem_write_2(bc, memh, card, (u_int16_t)(*from)); + } else { + while (len--) + bus_mem_write_1(bc, memh, card++, *from++); + } } void -ed_shared_readmem(sc, card, buf, len) +ed_shared_readmem(sc, card, to, len) struct ed_softc *sc; - caddr_t buf; + caddr_t to; int card, len; { bus_chipset_tag_t bc = sc->sc_bc; bus_mem_handle_t memh = sc->sc_memh; - u_int8_t *ptr = (u_int8_t *)buf; - int i; - /* XXX should have bus_mem_copyin_{1,2,4,8}() */ - - for (i = 0; i < len; ++i) - ptr[i] = bus_mem_read_1(bc, memh, card + i); + /* + * See comment above re. 16-bit cards. + */ + if (sc->isa16bit) { + while (len > 1) { + *((u_int16_t *)to) = bus_mem_read_2(bc, memh, card); + to += 2; + card += 2; + len -= 2; + } + if (len == 1) + *to = bus_mem_read_2(bc, memh, card) & 0xff; + } else { + while (len--) + *to++ = bus_mem_read_1(bc, memh, card++); + } } diff --git a/sys/dev/isa/if_eg.c b/sys/dev/isa/if_eg.c index 463bbb05457..12cb9cf27a2 100644 --- a/sys/dev/isa/if_eg.c +++ b/sys/dev/isa/if_eg.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_eg.c,v 1.25 1996/05/07 01:55:17 thorpej Exp $ */ +/* $NetBSD: if_eg.c,v 1.26 1996/05/12 23:52:27 mycroft Exp $ */ /* * Copyright (c) 1993 Dean Huxley <dean@fsa.ca> @@ -69,6 +69,7 @@ #endif #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/isa/if_el.c b/sys/dev/isa/if_el.c index 692b84108ff..7036ec9dbcb 100644 --- a/sys/dev/isa/if_el.c +++ b/sys/dev/isa/if_el.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_el.c,v 1.10 1996/05/10 12:41:18 deraadt Exp $ */ -/* $NetBSD: if_el.c,v 1.38 1996/05/07 01:55:20 thorpej Exp $ */ +/* $OpenBSD: if_el.c,v 1.11 1996/05/26 00:27:18 deraadt Exp $ */ +/* $NetBSD: if_el.c,v 1.39 1996/05/12 23:52:32 mycroft Exp $ */ /* * Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted @@ -48,6 +48,7 @@ #endif #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/isa/if_ep_isa.c b/sys/dev/isa/if_ep_isa.c index 2b9c1290b4b..4583b913d81 100644 --- a/sys/dev/isa/if_ep_isa.c +++ b/sys/dev/isa/if_ep_isa.c @@ -1,8 +1,8 @@ -/* $NetBSD: if_ep_isa.c,v 1.3 1996/05/03 19:06:25 christos Exp $ */ +/* $NetBSD: if_ep_isa.c,v 1.5 1996/05/12 23:52:36 mycroft Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe <thorpej@beer.org> - * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> + * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,6 +64,7 @@ #include <machine/cpu.h> #include <machine/bus.h> +#include <machine/intr.h> #include <dev/ic/elink3var.h> #include <dev/ic/elink3reg.h> diff --git a/sys/dev/isa/if_fe.c b/sys/dev/isa/if_fe.c index 7f1a21191fe..a9379b4d9eb 100644 --- a/sys/dev/isa/if_fe.c +++ b/sys/dev/isa/if_fe.c @@ -74,6 +74,7 @@ #endif #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isareg.h> diff --git a/sys/dev/isa/if_ie.c b/sys/dev/isa/if_ie.c index 77c99075c63..3b7e32575b3 100644 --- a/sys/dev/isa/if_ie.c +++ b/sys/dev/isa/if_ie.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ie.c,v 1.10 1996/05/10 12:41:20 deraadt Exp $ */ -/* $NetBSD: if_ie.c,v 1.50 1996/05/07 01:55:25 thorpej Exp $ */ +/* $OpenBSD: if_ie.c,v 1.11 1996/05/26 00:27:21 deraadt Exp $ */ +/* $NetBSD: if_ie.c,v 1.51 1996/05/12 23:52:48 mycroft Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles Hannum. @@ -143,6 +143,7 @@ iomem, and to make 16-pointers, we subtract sc_maddr and and with 0xffff. #include <machine/cpu.h> #include <machine/pio.h> /* XXX convert this driver! */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/isa/if_iy.c b/sys/dev/isa/if_iy.c index 2e8ee044b67..4dd2482a5f3 100644 --- a/sys/dev/isa/if_iy.c +++ b/sys/dev/isa/if_iy.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iy.c,v 1.2 1996/05/07 01:55:28 thorpej Exp $ */ +/* $NetBSD: if_iy.c,v 1.4 1996/05/12 23:52:53 mycroft Exp $ */ /* #define IYDEBUG */ /* #define IYMEMDEBUG */ /*- @@ -73,6 +73,7 @@ #include <vm/vm.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isareg.h> @@ -727,7 +728,7 @@ eepromread(io, offset) */ void iywatchdog(ifp) - struct ifnet *ifp + struct ifnet *ifp; { struct iy_softc *sc = ifp->if_softc; diff --git a/sys/dev/isa/if_le_isa.c b/sys/dev/isa/if_le_isa.c index 44aaf16676a..bfc7de2813d 100644 --- a/sys/dev/isa/if_le_isa.c +++ b/sys/dev/isa/if_le_isa.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le_isa.c,v 1.1 1996/05/07 01:50:05 thorpej Exp $ */ +/* $NetBSD: if_le_isa.c,v 1.2 1996/05/12 23:52:56 mycroft Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -58,6 +58,7 @@ #include <vm/vm.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isareg.h> diff --git a/sys/dev/isa/isa.c b/sys/dev/isa/isa.c index 435f3b45f5a..f50e0e9a90b 100644 --- a/sys/dev/isa/isa.c +++ b/sys/dev/isa/isa.c @@ -1,5 +1,5 @@ -/* $OpenBSD: isa.c,v 1.9 1996/05/10 12:37:45 deraadt Exp $ */ -/* $NetBSD: isa.c,v 1.82 1996/05/05 01:14:07 thorpej Exp $ */ +/* $OpenBSD: isa.c,v 1.10 1996/05/26 00:27:23 deraadt Exp $ */ +/* $NetBSD: isa.c,v 1.85 1996/05/14 00:31:04 thorpej Exp $ */ /*- * Copyright (c) 1993, 1994 Charles Hannum. All rights reserved. @@ -36,9 +36,8 @@ #include <sys/conf.h> #include <sys/malloc.h> #include <sys/device.h> -#ifndef i386 /* XXX */ + #include <machine/intr.h> -#endif /* XXX */ #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> @@ -86,7 +85,7 @@ isaattach(parent, self, aux) sc->sc_ic = iba->iba_ic; /* - * Map port 0x84, which causes a 2.5us delay when read. + * Map port 0x84, which causes a 1.25us delay when read. * We do this now, since several drivers need it. */ if (bus_io_map(sc->sc_bc, 0x84, 1, &sc->sc_delayioh)) diff --git a/sys/dev/isa/isavar.h b/sys/dev/isa/isavar.h index 02697e40294..9c70d3cad31 100644 --- a/sys/dev/isa/isavar.h +++ b/sys/dev/isa/isavar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: isavar.h,v 1.11 1996/05/12 08:45:38 pefo Exp $ */ -/* $NetBSD: isavar.h,v 1.22 1996/05/05 01:14:14 thorpej Exp $ */ +/* $OpenBSD: isavar.h,v 1.12 1996/05/26 00:27:24 deraadt Exp $ */ +/* $NetBSD: isavar.h,v 1.23 1996/05/08 23:32:31 thorpej Exp $ */ /* * Copyright (c) 1995 Chris G. Demetriou @@ -122,7 +122,7 @@ struct isa_softc { /* * This i/o handle is used to map port 0x84, which is - * read to provide a 2.5us delay. This i/o handle + * read to provide a 1.25us delay. This i/o handle * is mapped in isaattach(), and exported to drivers * via isa_attach_args. */ diff --git a/sys/dev/isa/lpt.c b/sys/dev/isa/lpt.c index 571ed8b7a8d..ddef7451f8e 100644 --- a/sys/dev/isa/lpt.c +++ b/sys/dev/isa/lpt.c @@ -1,5 +1,5 @@ -/* $OpenBSD: lpt.c,v 1.10 1996/05/07 07:37:16 deraadt Exp $ */ -/* $NetBSD: lpt.c,v 1.38 1996/04/29 20:30:48 christos Exp $ */ +/* $OpenBSD: lpt.c,v 1.11 1996/05/26 00:27:24 deraadt Exp $ */ +/* $NetBSD: lpt.c,v 1.39 1996/05/12 23:53:06 mycroft Exp $ */ /* * Copyright (c) 1993, 1994 Charles Hannum. @@ -66,12 +66,8 @@ #include <sys/conf.h> #include <sys/syslog.h> -#ifdef i386 /* XXX */ -#include <machine/cpu.h> /* XXX */ -#else /* XXX */ -#include <machine/intr.h> -#endif /* XXX */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isavar.h> #include <dev/isa/lptreg.h> diff --git a/sys/dev/isa/mcd.c b/sys/dev/isa/mcd.c index 851a367ef2c..3ef11fa2e49 100644 --- a/sys/dev/isa/mcd.c +++ b/sys/dev/isa/mcd.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mcd.c,v 1.11 1996/05/07 07:37:20 deraadt Exp $ */ -/* $NetBSD: mcd.c,v 1.48 1996/04/29 20:28:44 christos Exp $ */ +/* $OpenBSD: mcd.c,v 1.12 1996/05/26 00:27:25 deraadt Exp $ */ +/* $NetBSD: mcd.c,v 1.49 1996/05/12 23:53:11 mycroft Exp $ */ /* * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved. @@ -74,6 +74,7 @@ #include <sys/disk.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c index c5697fa8ea0..8afde25ff14 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,5 +1,5 @@ -/* $OpenBSD: pas.c,v 1.10 1996/05/07 07:37:25 deraadt Exp $ */ -/* $NetBSD: pas.c,v 1.16 1996/04/29 20:03:28 christos Exp $ */ +/* $OpenBSD: pas.c,v 1.11 1996/05/26 00:27:26 deraadt Exp $ */ +/* $NetBSD: pas.c,v 1.17 1996/05/12 23:53:18 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -49,6 +49,7 @@ #include <sys/proc.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <sys/audioio.h> diff --git a/sys/dev/isa/pss.c b/sys/dev/isa/pss.c index b101ce3cfdd..3c7e94ef2c7 100644 --- a/sys/dev/isa/pss.c +++ b/sys/dev/isa/pss.c @@ -1,5 +1,5 @@ -/* $OpenBSD: pss.c,v 1.9 1996/05/07 07:37:33 deraadt Exp $ */ -/* $NetBSD: pss.c,v 1.14 1996/04/29 20:00:39 christos Exp $ */ +/* $OpenBSD: pss.c,v 1.10 1996/05/26 00:27:27 deraadt Exp $ */ +/* $NetBSD: pss.c,v 1.15 1996/05/12 23:53:23 mycroft Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -61,6 +61,7 @@ #include <sys/buf.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <sys/audioio.h> diff --git a/sys/dev/isa/rtfps.c b/sys/dev/isa/rtfps.c index 9ab6e9359ea..e0b4c2acd0e 100644 --- a/sys/dev/isa/rtfps.c +++ b/sys/dev/isa/rtfps.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rtfps.c,v 1.9 1996/05/10 12:35:41 deraadt Exp $ */ -/* $NetBSD: rtfps.c,v 1.22 1996/05/05 19:49:51 christos Exp $ */ +/* $OpenBSD: rtfps.c,v 1.10 1996/05/26 00:27:27 deraadt Exp $ */ +/* $NetBSD: rtfps.c,v 1.23 1996/05/12 23:53:29 mycroft Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. @@ -39,12 +39,8 @@ #include <sys/device.h> #include <sys/termios.h> -#ifdef i386 /* XXX */ -#include <machine/cpu.h> /* XXX */ -#else /* XXX */ -#include <machine/intr.h> -#endif /* XXX */ #include <machine/bus.h> +#include <machine/intr.h> #include <dev/isa/isavar.h> #include <dev/isa/comreg.h> diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index 8e08f39b818..495009c13f5 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,5 +1,5 @@ -/* $OpenBSD: sb.c,v 1.10 1996/05/07 07:37:37 deraadt Exp $ */ -/* $NetBSD: sb.c,v 1.35 1996/04/29 20:03:29 christos Exp $ */ +/* $OpenBSD: sb.c,v 1.11 1996/05/26 00:27:28 deraadt Exp $ */ +/* $NetBSD: sb.c,v 1.36 1996/05/12 23:53:33 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -44,6 +44,7 @@ #include <sys/proc.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <sys/audioio.h> diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index 448cee0acab..cc28f846b5c 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: sbdsp.c,v 1.5 1996/05/07 07:37:41 deraadt Exp $ */ -/* $NetBSD: sbdsp.c,v 1.25 1996/04/29 20:03:31 christos Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.6 1996/05/26 00:27:29 deraadt Exp $ */ +/* $NetBSD: sbdsp.c,v 1.26 1996/05/12 23:53:38 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -52,6 +52,7 @@ #include <vm/vm.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <sys/audioio.h> diff --git a/sys/dev/isa/seagate.c b/sys/dev/isa/seagate.c index d426bd3db8a..43f6d6c2433 100644 --- a/sys/dev/isa/seagate.c +++ b/sys/dev/isa/seagate.c @@ -75,6 +75,7 @@ #include <sys/queue.h> #include <sys/malloc.h> +#include <machine/intr.h> #include <machine/pio.h> #include <scsi/scsi_all.h> diff --git a/sys/dev/isa/ultra14f.c b/sys/dev/isa/ultra14f.c index 2db41f76b9c..50e604c301b 100644 --- a/sys/dev/isa/ultra14f.c +++ b/sys/dev/isa/ultra14f.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ultra14f.c,v 1.14 1996/05/07 07:37:54 deraadt Exp $ */ -/* $NetBSD: ultra14f.c,v 1.65 1996/04/29 19:51:30 christos Exp $ */ +/* $OpenBSD: ultra14f.c,v 1.15 1996/05/26 00:27:30 deraadt Exp $ */ +/* $NetBSD: ultra14f.c,v 1.66 1996/05/12 23:53:54 mycroft Exp $ */ /* * Copyright (c) 1994 Charles Hannum. All rights reserved. @@ -64,6 +64,7 @@ #include <sys/proc.h> #include <sys/user.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/isa/wd.c b/sys/dev/isa/wd.c index 8b22c59e798..d384c5ad144 100644 --- a/sys/dev/isa/wd.c +++ b/sys/dev/isa/wd.c @@ -1,5 +1,5 @@ -/* $OpenBSD: wd.c,v 1.12 1996/05/07 07:37:58 deraadt Exp $ */ -/* $NetBSD: wd.c,v 1.149 1996/04/29 19:50:47 christos Exp $ */ +/* $OpenBSD: wd.c,v 1.13 1996/05/26 00:27:31 deraadt Exp $ */ +/* $NetBSD: wd.c,v 1.150 1996/05/12 23:54:03 mycroft Exp $ */ /* * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -52,6 +52,7 @@ #include <vm/vm.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/isa/wds.c b/sys/dev/isa/wds.c index 8fa110bc53f..08b53127d38 100644 --- a/sys/dev/isa/wds.c +++ b/sys/dev/isa/wds.c @@ -1,4 +1,4 @@ -/* $NetBSD: wds.c,v 1.6 1996/05/05 00:40:03 mycroft Exp $ */ +/* $NetBSD: wds.c,v 1.7 1996/05/12 23:54:09 mycroft Exp $ */ #define WDSDIAG #define integrate @@ -63,6 +63,7 @@ #include <sys/proc.h> #include <sys/user.h> +#include <machine/intr.h> #include <machine/pio.h> #include <scsi/scsi_all.h> diff --git a/sys/dev/isa/wss.c b/sys/dev/isa/wss.c index 2c1f914fdf6..c16ca3ce0c0 100644 --- a/sys/dev/isa/wss.c +++ b/sys/dev/isa/wss.c @@ -1,5 +1,5 @@ -/* $OpenBSD: wss.c,v 1.10 1996/05/07 07:38:08 deraadt Exp $ */ -/* $NetBSD: wss.c,v 1.12 1996/04/29 19:46:09 christos Exp $ */ +/* $OpenBSD: wss.c,v 1.11 1996/05/26 00:27:32 deraadt Exp $ */ +/* $NetBSD: wss.c,v 1.13 1996/05/12 23:54:16 mycroft Exp $ */ /* * Copyright (c) 1994 John Brezak @@ -46,6 +46,7 @@ #include <sys/buf.h> #include <machine/cpu.h> +#include <machine/intr.h> #include <machine/pio.h> #include <sys/audioio.h> diff --git a/sys/dev/isa/wt.c b/sys/dev/isa/wt.c index 9d55fa4880d..80a065db8f6 100644 --- a/sys/dev/isa/wt.c +++ b/sys/dev/isa/wt.c @@ -1,5 +1,5 @@ -/* $OpenBSD: wt.c,v 1.9 1996/05/07 07:38:11 deraadt Exp $ */ -/* $NetBSD: wt.c,v 1.32 1996/04/29 19:45:32 christos Exp $ */ +/* $OpenBSD: wt.c,v 1.10 1996/05/26 00:27:33 deraadt Exp $ */ +/* $NetBSD: wt.c,v 1.33 1996/05/12 23:54:22 mycroft Exp $ */ /* * Streamer tape driver. @@ -65,6 +65,7 @@ #include <vm/vm_param.h> +#include <machine/intr.h> #include <machine/pio.h> #include <dev/isa/isavar.h> diff --git a/sys/dev/microcode/aic7xxx/Makefile.inc b/sys/dev/microcode/aic7xxx/Makefile.inc index 063a9b92afd..88ff6c63822 100644 --- a/sys/dev/microcode/aic7xxx/Makefile.inc +++ b/sys/dev/microcode/aic7xxx/Makefile.inc @@ -1,3 +1,5 @@ +# $NetBSD: Makefile.inc,v 1.4 1996/05/20 00:48:43 thorpej Exp $ + .if target(aic7xxx.o) PATH: $S/dev/microcode/aic7xxx @@ -7,5 +9,7 @@ aic7xxx_seq.h: aic7xxx_asm $S/dev/microcode/aic7xxx/aic7xxx.seq ./aic7xxx_asm -o ${.TARGET} $S/dev/microcode/aic7xxx/aic7xxx.seq aic7xxx_asm: $S/dev/microcode/aic7xxx/aic7xxx_asm.c - cc -o ${.TARGET} $< + +clean:: + rm -f aic7xxx_asm .endif diff --git a/sys/dev/microcode/aic7xxx/aic7xxx.seq b/sys/dev/microcode/aic7xxx/aic7xxx.seq index 9db05bec6f0..718c8db724a 100644 --- a/sys/dev/microcode/aic7xxx/aic7xxx.seq +++ b/sys/dev/microcode/aic7xxx/aic7xxx.seq @@ -1,3 +1,5 @@ +/* $NetBSD: aic7xxx.seq,v 1.3 1996/05/20 00:48:45 thorpej Exp $ */ + /*+M*********************************************************************** *Adaptec 274x/284x/294x device driver for Linux and FreeBSD. * @@ -39,10 +41,10 @@ * *-M************************************************************************/ -VERSION AIC7XXX_SEQ_VER "$Id: aic7xxx.seq,v 1.2 1996/05/05 12:42:37 deraadt Exp $" +VERSION AIC7XXX_SEQ_VER "$NetBSD: aic7xxx.seq,v 1.3 1996/05/20 00:48:45 thorpej Exp $" #if defined(__NetBSD__) -#include "../../../../dev/microcode/aic7xxx/aic7xxx_reg.h" +#include "../../../../dev/ic/aic7xxxreg.h" #elif defined(__FreeBSD__) #include "../../dev/aic7xxx/aic7xxx_reg.h" #endif @@ -397,7 +399,7 @@ dma_finish2: * For Linux, we must throw away four bytes since there is a 32bit gap * in the middle of a struct scatterlist. */ -#ifdef linux +#ifdef __linux__ mov NONE,DFDAT mov NONE,DFDAT mov NONE,DFDAT diff --git a/sys/dev/microcode/aic7xxx/aic7xxx_asm.1 b/sys/dev/microcode/aic7xxx/aic7xxx_asm.1 index 2ff33b78190..be533d3c052 100644 --- a/sys/dev/microcode/aic7xxx/aic7xxx_asm.1 +++ b/sys/dev/microcode/aic7xxx/aic7xxx_asm.1 @@ -1,3 +1,5 @@ +.\" $NetBSD: aic7xxx_asm.1,v 1.2 1996/05/20 00:48:47 thorpej Exp $ +.\" .\" Copyright (c) 1994, 1995 .\" Justin T. Gibbs. All rights reserved. .\" diff --git a/sys/dev/microcode/aic7xxx/aic7xxx_asm.c b/sys/dev/microcode/aic7xxx/aic7xxx_asm.c index 2d2a47efb4a..fd9e8bb4229 100644 --- a/sys/dev/microcode/aic7xxx/aic7xxx_asm.c +++ b/sys/dev/microcode/aic7xxx/aic7xxx_asm.c @@ -1,3 +1,5 @@ +/* $NetBSD: aic7xxx_asm.c,v 1.4 1996/05/20 00:48:48 thorpej Exp $ */ + /*+M************************************************************************* * Adaptec AIC7770/AIC7870 sequencer code assembler. * @@ -43,7 +45,7 @@ * are token separators. * *-M*************************************************************************/ -static char id[] = "$Id: aic7xxx_asm.c,v 1.3 1996/05/07 07:38:22 deraadt Exp $"; +static char id[] = "$NetBSD: aic7xxx_asm.c,v 1.4 1996/05/20 00:48:48 thorpej Exp $"; #include <ctype.h> #include <stdio.h> #include <string.h> @@ -87,9 +89,7 @@ Malloc(size_t size) } void * -Realloc(ptr, size) - void *ptr; - size_t size; +Realloc(void *ptr, size_t size) { void *p = realloc(ptr, size); if (!p) @@ -143,8 +143,7 @@ define(char *name, int value) } sym_t * -lookup(name) - char *name; +lookup(char *name) { sym_t *p; @@ -163,7 +162,7 @@ patch(sym_t *p, int location) p->patch[p->npatch - 1] = location; } -void backpatch() +void backpatch(void) { int i; sym_t *p; @@ -203,8 +202,7 @@ void backpatch() * since the sequencer RAM is loaded that way. */ void -output(fp) - FILE *fp; +output(FILE *fp) { int i; @@ -218,8 +216,7 @@ output(fp) } char ** -getl(n) - int *n; +getl(int *n) { int i; char *p, *quote; @@ -378,9 +375,7 @@ eval_operand(char **a, int spec) } int -eval_sdi(a, spec) - char **a; - int spec; +eval_sdi(char **a, int spec) { sym_t *p; unsigned val; @@ -450,9 +445,7 @@ eval_sdi(a, spec) } int -eval_addr(a, spec) - char **a; - int spec; +eval_addr(char **a, int spec) { sym_t *p; @@ -477,9 +470,7 @@ eval_addr(a, spec) } int -crack(a, n) - char **a; - int n; +crack(char **a, int n) { int i; int I_imm, I_addr; diff --git a/sys/dev/pci/aic7870.c b/sys/dev/pci/ahc_pci.c index 00762ab76c2..d1f96318df4 100644 --- a/sys/dev/pci/aic7870.c +++ b/sys/dev/pci/ahc_pci.c @@ -1,3 +1,5 @@ +/* $NetBSD: ahc_pci.c,v 1.2 1996/05/20 00:56:39 thorpej Exp $ */ + /* * Product specific probe and attach routines for: * 3940, 2940, aic7880, aic7870, aic7860 and aic7850 SCSI controllers @@ -28,8 +30,6 @@ * 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: aic7870.c,v 1.8 1996/05/05 12:42:41 deraadt Exp $ */ #if defined(__FreeBSD__) @@ -43,14 +43,10 @@ #include <sys/queue.h> #if defined(__NetBSD__) #include <sys/device.h> -#if NetBSD1_1 < 3 -#include <machine/pio.h> -#else #include <machine/bus.h> #ifdef __alpha__ #include <machine/intr.h> #endif -#endif #endif /* defined(__NetBSD__) */ #include <scsi/scsi_all.h> @@ -75,17 +71,12 @@ #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> +#include <dev/ic/aic7xxxreg.h> #include <dev/ic/aic7xxxvar.h> -#include <dev/ic/93cx6.h> - -#include <dev/microcode/aic7xxx/aic7xxx_reg.h> +#include <dev/ic/smc93cx6var.h> #define bootverbose 1 -#if NetBSD1_1 < 3 -#define PCI_BASEADR0 PCI_MAP_REG_START -#else #define PCI_BASEADR0 PCI_MAPREG_START -#endif #endif /* defined(__NetBSD__) */ @@ -137,7 +128,7 @@ struct seeprom_config { #define CFINCBIOS 0x0200 /* include in BIOS scan */ #define CFRNFOUND 0x0400 /* report even if not found */ /* UNUSED 0xf800 */ - unsigned short device_flags[16]; /* words 0-15 */ + u_int16_t device_flags[16]; /* words 0-15 */ /* * BIOS Control Bits @@ -150,7 +141,7 @@ struct seeprom_config { /* UNUSED 0x0060 */ #define CFEXTEND 0x0080 /* extended translation enabled */ /* UNUSED 0xff00 */ - unsigned short bios_control; /* word 16 */ + u_int16_t bios_control; /* word 16 */ /* * Host Adapter Control Bits @@ -163,7 +154,7 @@ struct seeprom_config { /* UNUSED 0x0020 */ #define CFRESETB 0x0040 /* reset SCSI bus at IC initialization */ /* UNUSED 0xff80 */ - unsigned short adapter_control; /* word 17 */ + u_int16_t adapter_control; /* word 17 */ /* * Bus Release, Host Adapter ID @@ -171,27 +162,20 @@ struct seeprom_config { #define CFSCSIID 0x000f /* host adapter SCSI ID */ /* UNUSED 0x00f0 */ #define CFBRTIME 0xff00 /* bus release time */ - unsigned short brtime_id; /* word 18 */ + u_int16_t brtime_id; /* word 18 */ /* * Maximum targets */ #define CFMAXTARG 0x00ff /* maximum targets */ /* UNUSED 0xff00 */ - unsigned short max_targets; /* word 19 */ - - unsigned short res_1[11]; /* words 20-30 */ - unsigned short checksum; /* word 31 */ + u_int16_t max_targets; /* word 19 */ + u_int16_t res_1[11]; /* words 20-30 */ + u_int16_t checksum; /* word 31 */ }; -static int load_seeprom __P((struct ahc_data *ahc)); -static int acquire_seeprom __P((u_long offset, u_short CS, u_short CK, - u_short DO, u_short DI, u_short RDY, - u_short MS)); -static void release_seeprom __P((u_long offset, u_short CS, u_short CK, - u_short DO, u_short DI, u_short RDY, - u_short MS)); +static void load_seeprom __P((struct ahc_data *ahc)); static u_char aic3940_count; @@ -256,26 +240,15 @@ aic7870_probe (pcici_t tag, pcidi_t type) #elif defined(__NetBSD__) -int aic7870_probe __P((struct device *, void *, void *)); -void aic7870_attach __P((struct device *, struct device *, void *)); +int ahc_pci_probe __P((struct device *, void *, void *)); +void ahc_pci_attach __P((struct device *, struct device *, void *)); -#if NetBSD1_1 < 3 -struct cfdriver ahccd = { - NULL, "ahc", aic7870_probe, aic7870_attach, DV_DULL, - sizeof(struct ahc_data) -}; -#else -struct cfattach ahc_ca = { - sizeof(struct ahc_data), aic7870_probe, aic7870_attach +struct cfattach ahc_pci_ca = { + sizeof(struct ahc_data), ahc_pci_probe, ahc_pci_attach }; -struct cfdriver ahc_cd = { - NULL, "ahc", DV_DULL -}; -#endif - int -aic7870_probe(parent, match, aux) +ahc_pci_probe(parent, match, aux) struct device *parent; void *match, *aux; { @@ -306,7 +279,7 @@ aic7870_attach(config_id, unit) int unit; #elif defined(__NetBSD__) void -aic7870_attach(parent, self, aux) +ahc_pci_attach(parent, self, aux) struct device *parent, *self; void *aux; #endif @@ -317,17 +290,12 @@ aic7870_attach(parent, self, aux) struct pci_attach_args *pa = aux; struct ahc_data *ahc = (void *)self; int unit = ahc->sc_dev.dv_unit; -#if NetBSD1_1 < 3 - pcitag_t config_id = pa->pa_tag; - u_long io_port; -#else bus_io_addr_t iobase; bus_io_size_t iosize; bus_io_handle_t ioh; pci_intr_handle_t ih; const char *intrstr; #endif -#endif u_long id; unsigned opri = 0; ahc_type ahc_t = AHC_NONE; @@ -335,8 +303,10 @@ aic7870_attach(parent, self, aux) #if defined(__FreeBSD__) struct ahc_data *ahc; #endif + u_char ultra_enb = 0; + u_char our_id = 0; -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) if(!(io_port = pci_conf_read(config_id, PCI_BASEADR0))) return; /* @@ -351,7 +321,7 @@ aic7870_attach(parent, self, aux) return; #endif -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) switch ((id = pci_conf_read(config_id, PCI_ID_REG))) { #elif defined(__NetBSD__) switch (id = pa->pa_id) { @@ -395,19 +365,26 @@ aic7870_attach(parent, self, aux) /* On all PCI adapters, we allow SCB paging */ ahc_f |= AHC_PAGESCBS; + /* Remeber how the card was setup in case there is no SEEPROM */ +#if defined(__FreeBSD__) + our_id = inb(SCSIID + io_port) & OID; + if(ahc_t & AHC_ULTRA) + ultra_enb = inb(SXFRCTL0 + io_port) & ULTRAEN; +#else + our_id = bus_io_read_1(pa->pa_bc, ioh, SCSIID) & OID; + if(ahc_t & AHC_ULTRA) + ultra_enb = bus_io_read_1(pa->pa_bc, ioh, SXFRCTL0) & ULTRAEN; +#endif + #if defined(__FreeBSD__) ahc_reset(io_port); #elif defined(__NetBSD__) printf("\n"); -#if NetBSD1_1 < 3 - ahc_reset(ahc->sc_dev.dv_xname, 0, io_port); -#else ahc_reset(ahc->sc_dev.dv_xname, pa->pa_bc, ioh); #endif -#endif if(ahc_t & AHC_AIC7870){ -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) u_long devconfig = pci_conf_read(config_id, DEVCONFIG); #elif defined(__NetBSD__) u_long devconfig = @@ -435,10 +412,10 @@ aic7870_attach(parent, self, aux) * affect RAMPSM either way. */ devconfig &= ~(RAMPSM|SCBRAMSEL); -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) pci_conf_write(config_id, DEVCONFIG, devconfig); #elif defined(__NetBSD__) - pci_conf_write(pa->pa_bc, pa->pa_tag, + pci_conf_write(pa->pa_pc, pa->pa_tag, DEVCONFIG, devconfig); #endif } @@ -449,7 +426,7 @@ aic7870_attach(parent, self, aux) * and latency timer. */ { -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) u_long csize_lattime = pci_conf_read(config_id, CSIZE_LATTIME); #elif defined(__NetBSD__) u_long csize_lattime = @@ -471,10 +448,10 @@ aic7870_attach(parent, self, aux) unit, csize_lattime & CACHESIZE, (csize_lattime >> 8) & 0xff); -#if defined(__FreeBSD__) || NetBSD1_1 < 3 +#if defined(__FreeBSD__) pci_conf_write(config_id, CSIZE_LATTIME, csize_lattime); #elif defined(__NetBSD__) - pci_conf_write(pa->pa_bc, pa->pa_tag, CSIZE_LATTIME, + pci_conf_write(pa->pa_pc, pa->pa_tag, CSIZE_LATTIME, csize_lattime); #endif } @@ -488,11 +465,7 @@ aic7870_attach(parent, self, aux) return; } #elif defined(__NetBSD__) -#if NetBSD1_1 < 3 - ahc_construct(ahc, unit, 0, io_port, ahc_t, ahc_f); - ahc->sc_ih = pci_map_int(pa->pa_tag, PCI_IPL_BIO, ahc_intr, ahc); -#else - ahc_construct(ahc, unit, pa->pa_bc, ioh, ahc_t, ahc_f); + ahc_construct(ahc, pa->pa_bc, ioh, ahc_t, ahc_f); if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin, pa->pa_intrline, &ih)) { @@ -501,12 +474,11 @@ aic7870_attach(parent, self, aux) return; } intrstr = pci_intr_string(pa->pa_pc, ih); + ahc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc #ifdef __OpenBSD__ - ahc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc, - ahc->sc_dev.dv_xname); -#else - ahc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, ahc_intr, ahc); + , ahc->sc_dev.dv_xname #endif + ); if (ahc->sc_ih == NULL) { printf("%s: couldn't establish interrupt", ahc->sc_dev.dv_xname); @@ -520,7 +492,6 @@ aic7870_attach(parent, self, aux) printf("%s: interrupting at %s\n", ahc->sc_dev.dv_xname, intrstr); #endif -#endif /* * Protect ourself from spurrious interrupts during * intialization. @@ -554,14 +525,20 @@ aic7870_attach(parent, self, aux) case AHC_AIC7860: { id_string = "aic7860 "; - /* Assume there is no BIOS for these cards? */ + /* + * Use defaults, if the chip wasn't initialized by + * a BIOS. + */ ahc->flags |= AHC_USEDEFAULTS; break; } case AHC_AIC7850: { id_string = "aic7850 "; - /* Assume there is no BIOS for these cards? */ + /* + * Use defaults, if the chip wasn't initialized by + * a BIOS. + */ ahc->flags |= AHC_USEDEFAULTS; break; } @@ -574,8 +551,6 @@ aic7870_attach(parent, self, aux) } } - printf("ahc%d: %s", unit, id_string); - /* * Take the LED out of diagnostic mode */ @@ -592,13 +567,37 @@ aic7870_attach(parent, self, aux) /* * PCI Adapter default setup * Should only be used if the adapter does not have - * an SEEPROM and we don't think a BIOS was installed. + * an SEEPROM. */ - /* Set the host ID */ - AHC_OUTB(ahc, SCSICONF, 7); + /* See if someone else set us up already */ + u_long i; + for(i = TARG_SCRATCH; i < 0x60; i++) { + if(AHC_INB(ahc, i) != 0xff) + break; + } + if(i != 0x60) { + printf("%s: Using left over BIOS settings\n", + ahc_name(ahc)); + ahc->flags &= ~AHC_USEDEFAULTS; + } + else + our_id = 0x07; + AHC_OUTB(ahc, SCSICONF, + (our_id & 0x07)|ENSPCHK|RESET_SCSI); /* In case we are a wide card */ - AHC_OUTB(ahc, SCSICONF + 1, 7); + AHC_OUTB(ahc, SCSICONF + 1, our_id); + + if(!ultra_enb || (ahc->flags & AHC_USEDEFAULTS)) { + /* + * If there wasn't a BIOS or the board + * wasn't in this mode to begin with, + * turn off ultra. + */ + ahc->type &= ~AHC_ULTRA; + } } + + printf("%s: %s", ahc_name(ahc), id_string); } if(ahc_init(ahc)){ @@ -615,30 +614,41 @@ aic7870_attach(parent, self, aux) /* * Read the SEEPROM. Return 0 on failure */ -int +void load_seeprom(ahc) struct ahc_data *ahc; { + struct seeprom_descriptor sd; struct seeprom_config sc; u_short *scarray = (u_short *)≻ u_short checksum = 0; - u_long iobase = ahc->baseport; u_char scsi_conf; u_char host_id; - int have_seeprom, retval; + int have_seeprom; +#if defined(__FreeBSD__) + sd.sd_iobase = ahc->baseport + SEECTL; +#elif defined(__NetBSD__) + sd.sd_bc = ahc->sc_bc; + sd.sd_ioh = ahc->sc_ioh; + sd.sd_offset = SEECTL; +#endif + sd.sd_MS = SEEMS; + sd.sd_RDY = SEERDY; + sd.sd_CS = SEECS; + sd.sd_CK = SEECK; + sd.sd_DO = SEEDO; + sd.sd_DI = SEEDI; + if(bootverbose) - printf("ahc%d: Reading SEEPROM...", ahc->unit); - have_seeprom = acquire_seeprom(iobase + SEECTL, SEECS, - SEECK, SEEDO, SEEDI, SEERDY, SEEMS); + printf("%s: Reading SEEPROM...", ahc_name(ahc)); + have_seeprom = acquire_seeprom(&sd); if (have_seeprom) { - have_seeprom = read_seeprom(iobase + SEECTL, - (u_short *)&sc, + have_seeprom = read_seeprom(&sd, + (u_int16_t *)&sc, ahc->flags & AHC_CHNLB, - sizeof(sc)/2, SEECS, SEECK, SEEDO, - SEEDI, SEERDY, SEEMS); - release_seeprom(iobase + SEECTL, SEECS, SEECK, SEEDO, - SEEDI, SEERDY, SEEMS); + sizeof(sc)/2); + release_seeprom(&sd); if (have_seeprom) { /* Check checksum */ int i; @@ -646,7 +656,8 @@ load_seeprom(ahc) for (i = 0;i < (sizeof(sc)/2 - 1);i = i + 1) checksum = checksum + scarray[i]; if (checksum != sc.checksum) { - printf ("checksum error"); + if(bootverbose) + printf ("checksum error"); have_seeprom = 0; } else if(bootverbose) @@ -654,17 +665,9 @@ load_seeprom(ahc) } } if (!have_seeprom) { - printf("\nahc%d: SEEPROM read failed, " - "using leftover BIOS values\n", ahc->unit); - retval = 0; - - host_id = 0x7; - scsi_conf = host_id | ENSPCHK; /* Assume a default */ - /* - * If we happen to be an ULTRA card, - * default to non-ultra mode. - */ - ahc->type &= ~AHC_ULTRA; + if(bootverbose) + printf("\n%s: No SEEPROM availible\n", ahc_name(ahc)); + ahc->flags |= AHC_USEDEFAULTS; } else { /* @@ -683,16 +686,18 @@ load_seeprom(ahc) target_settings |= WIDEXFER; if (sc.device_flags[i] & CFDISC) ahc->discenable |= (0x01 << i); - outb(TARG_SCRATCH+i+iobase, target_settings); + AHC_OUTB(ahc, TARG_SCRATCH+i, target_settings); } - outb(DISC_DSB + iobase, ~(ahc->discenable & 0xff)); - outb(DISC_DSB + iobase + 1, ~((ahc->discenable >> 8) & 0xff)); + AHC_OUTB(ahc, DISC_DSB, ~(ahc->discenable & 0xff)); + AHC_OUTB(ahc, DISC_DSB + 1, ~((ahc->discenable >> 8) & 0xff)); host_id = sc.brtime_id & CFSCSIID; scsi_conf = (host_id & 0x7); if(sc.adapter_control & CFSPARITY) scsi_conf |= ENSPCHK; + if(sc.adapter_control & CFRESETB) + scsi_conf |= RESET_SCSI; if(ahc->type & AHC_ULTRA) { /* Should we enable Ultra mode? */ @@ -700,58 +705,11 @@ load_seeprom(ahc) /* Treat us as a non-ultra card */ ahc->type &= ~AHC_ULTRA; } - retval = 1; + /* Set the host ID */ + AHC_OUTB(ahc, SCSICONF, scsi_conf); + /* In case we are a wide card */ + AHC_OUTB(ahc, SCSICONF + 1, host_id); } - /* Set the host ID */ - outb(SCSICONF + iobase, scsi_conf); - /* In case we are a wide card */ - outb(SCSICONF + 1 + iobase, host_id); - - return(retval); -} - -static int -acquire_seeprom(offset, CS, CK, DO, DI, RDY, MS) - u_long offset; - u_short CS; /* chip select */ - u_short CK; /* clock */ - u_short DO; /* data out */ - u_short DI; /* data in */ - u_short RDY; /* ready */ - u_short MS; /* mode select */ -{ - int wait; - /* - * Request access of the memory port. When access is - * granted, SEERDY will go high. We use a 1 second - * timeout which should be near 1 second more than - * is needed. Reason: after the chip reset, there - * should be no contention. - */ - outb(offset, MS); - wait = 1000; /* 1 second timeout in msec */ - while (--wait && ((inb(offset) & RDY) == 0)) { - DELAY (1000); /* delay 1 msec */ - } - if ((inb(offset) & RDY) == 0) { - outb (offset, 0); - return (0); - } - return(1); -} - -static void -release_seeprom(offset, CS, CK, DO, DI, RDY, MS) - u_long offset; - u_short CS; /* chip select */ - u_short CK; /* clock */ - u_short DO; /* data out */ - u_short DI; /* data in */ - u_short RDY; /* ready */ - u_short MS; /* mode select */ -{ - /* Release access to the memory port and the serial EEPROM. */ - outb(offset, 0); } #endif /* NPCI > 0 */ diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci index 05ffa120293..f13e0cf0bbc 100644 --- a/sys/dev/pci/files.pci +++ b/sys/dev/pci/files.pci @@ -1,5 +1,5 @@ -# $OpenBSD: files.pci,v 1.6 1996/05/10 12:33:25 deraadt Exp $ -# $NetBSD: files.pci,v 1.15 1996/05/07 02:03:07 thorpej Exp $ +# $OpenBSD: files.pci,v 1.7 1996/05/26 00:27:40 deraadt Exp $ +# $NetBSD: files.pci,v 1.16 1996/05/16 03:44:16 mycroft Exp $ # # Config.new file and device description for machine-independent PCI code. # Included by ports that need it. Requires that the SCSI files be @@ -10,10 +10,11 @@ attach pci at pcibus file dev/pci/pci.c pci needs-flag file dev/pci/pci_subr.c pci -# Adaptec 7870 chips -device ahc: scsi, aic7xxx -attach ahc at pci -file dev/pci/aic7870.c ahc +# Adaptec 3940, 2940, and aic78[5678]0 SCSI controllers +# device declaration in sys/conf/files +attach ahc at pci with ahc_pci +file dev/pci/ahc_pci.c ahc_pci +file dev/ic/smc93cx6.c ahc_pci # Ethernet driver for DC21040-based boards device de: ether, ifnet diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c index 6c85de4952b..0b3b79beca7 100644 --- a/sys/dev/pci/if_de.c +++ b/sys/dev/pci/if_de.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_de.c,v 1.9 1996/05/10 12:41:24 deraadt Exp $ */ -/* $NetBSD: if_de.c,v 1.19 1996/05/07 02:17:18 thorpej Exp $ */ +/* $OpenBSD: if_de.c,v 1.10 1996/05/26 00:27:41 deraadt Exp $ */ +/* $NetBSD: if_de.c,v 1.22 1996/05/13 00:03:09 mycroft Exp $ */ /*- * Copyright (c) 1994, 1995 Matt Thomas (matt@lkg.dec.com) @@ -104,9 +104,8 @@ #if defined(__NetBSD__) #include <machine/bus.h> -#ifdef __alpha__ #include <machine/intr.h> -#endif + #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> #include <dev/ic/dc21040reg.h> @@ -1945,7 +1944,6 @@ tulip_ioctl( switch(ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: { - sc->tulip_ac.ac_ipaddr = IA_SIN(ifa)->sin_addr; tulip_init(sc); arp_ifinit(&sc->tulip_ac, ifa); break; @@ -2427,7 +2425,9 @@ tulip_pci_attach( bus_mem_addr_t membase; bus_mem_size_t memsize; #endif +#if defined(__FreeBSD__) int unit = sc->tulip_dev.dv_unit; +#endif const char *intrstr = NULL; #endif int retval, idx, revinfo, id; diff --git a/sys/dev/pci/if_ep_pci.c b/sys/dev/pci/if_ep_pci.c index bd44943ceb9..b49bee13719 100644 --- a/sys/dev/pci/if_ep_pci.c +++ b/sys/dev/pci/if_ep_pci.c @@ -1,7 +1,7 @@ -/* $NetBSD: if_ep_pci.c,v 1.3 1996/05/03 19:08:00 christos Exp $ */ +/* $NetBSD: if_ep_pci.c,v 1.7 1996/05/13 00:03:15 mycroft Exp $ */ /* - * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> + * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,6 +61,7 @@ #include <machine/cpu.h> #include <machine/bus.h> +#include <machine/intr.h> #include <dev/ic/elink3var.h> #include <dev/ic/elink3reg.h> @@ -69,11 +70,12 @@ #include <dev/pci/pcireg.h> #include <dev/pci/pcidevs.h> -/* PCI constants */ -#define PCI_VENDORID(x) ((x) & 0xFFFF) -#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF) +/* + * PCI constants. + * XXX These should be in a common file! + */ #define PCI_CONN 0x48 /* Connector type */ -#define PCI_CBMA 0x10 /* Configuration Base Memory Address */ +#define PCI_CBIO 0x10 /* Configuration Base IO Address */ int ep_pci_match __P((struct device *, void *, void *)); void ep_pci_attach __P((struct device *, struct device *, void *)); @@ -89,10 +91,10 @@ ep_pci_match(parent, match, aux) { struct pci_attach_args *pa = (struct pci_attach_args *) aux; - if (PCI_VENDORID(pa->pa_id) != PCI_VENDOR_3COM) + if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_3COM) return 0; - switch (PCI_CHIPID(pa->pa_id)) { + switch (PCI_PRODUCT(pa->pa_id)) { case PCI_PRODUCT_3COM_3C590: case PCI_PRODUCT_3COM_3C595: break; @@ -115,11 +117,12 @@ ep_pci_attach(parent, self, aux) bus_io_addr_t iobase; bus_io_size_t iosize; pci_intr_handle_t ih; - u_short i, conn = 0; + u_short conn = 0; + pcireg_t i; char *model; const char *intrstr = NULL; - if (pci_io_find(pc, pa->pa_tag, PCI_CBMA, &iobase, &iosize)) { + if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) { printf(": can't find i/o space\n"); return; } @@ -147,7 +150,7 @@ ep_pci_attach(parent, self, aux) GO_WINDOW(0); - switch (PCI_CHIPID(pa->pa_id)) { + switch (PCI_PRODUCT(pa->pa_id)) { case PCI_PRODUCT_3COM_3C590: model = "3Com 3C590 Ethernet"; break; diff --git a/sys/dev/pci/if_fpa.c b/sys/dev/pci/if_fpa.c index 7a53b6df129..ccab7b949f5 100644 --- a/sys/dev/pci/if_fpa.c +++ b/sys/dev/pci/if_fpa.c @@ -1,8 +1,7 @@ -/* $OpenBSD: if_fpa.c,v 1.6 1996/05/10 12:41:26 deraadt Exp $ */ -/* $NetBSD: if_fpa.c,v 1.8 1996/05/07 02:17:23 thorpej Exp $ */ +/* $NetBSD: if_fpa.c,v 1.11 1996/05/20 15:53:02 thorpej Exp $ */ /*- - * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com) + * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,70 +23,18 @@ * (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: if_fpa.c,v 1.2 1995/08/20 18:56:11 thomas Exp - * - * Log: if_fpa.c,v - * Revision 1.2 1995/08/20 18:56:11 thomas - * Misc. changes for NetBSD - * - * Revision 1.1 1995/08/16 22:57:28 thomas - * Initial revision - * - * Revision 1.13 1995/08/04 21:54:56 thomas - * Clean IRQ processing under BSD/OS. - * A receive tweaks. (print source of MAC CRC errors, etc.) - * - * Revision 1.12 1995/06/02 16:04:22 thomas - * Use correct PCI defs for BSDI now that they have fixed them. - * Increment the slot number 0x1000, not one! (*duh*) - * - * Revision 1.11 1995/04/21 13:23:55 thomas - * Fix a few pub in the DEFPA BSDI support - * - * Revision 1.10 1995/04/20 21:46:42 thomas - * Why??? - * , - * - * Revision 1.9 1995/04/20 20:17:33 thomas - * Add PCI support for BSD/OS. - * Fix BSD/OS EISA support. - * Set latency timer for DEFPA to recommended value if 0. - * - * Revision 1.8 1995/04/04 22:54:29 thomas - * Fix DEFEA support - * - * Revision 1.7 1995/03/14 01:52:52 thomas - * Update for new FreeBSD PCI Interrupt interface - * - * Revision 1.6 1995/03/10 17:06:59 thomas - * Update for latest version of FreeBSD. - * Compensate for the fast that the ifp will not be first thing - * in softc on BSDI. - * - * Revision 1.5 1995/03/07 19:59:42 thomas - * First pass at BSDI EISA support - * - * Revision 1.4 1995/03/06 17:06:03 thomas - * Add transmit timeout support. - * Add support DEFEA (untested). - * - * Revision 1.3 1995/03/03 13:48:35 thomas - * more fixes - * + * Id: if_fpa.c,v 1.8 1996/05/17 01:15:18 thomas Exp * */ /* * DEC PDQ FDDI Controller; code for BSD derived operating systems * - * Written by Matt Thomas - * * This module supports the DEC DEFPA PCI FDDI Controller */ #include <sys/param.h> -#include <sys/systm.h> #include <sys/kernel.h> #include <sys/mbuf.h> #include <sys/protosw.h> @@ -97,7 +44,7 @@ #include <sys/malloc.h> #if defined(__FreeBSD__) #include <sys/devconf.h> -#elif defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__bsdi__) || defined(__NetBSD__) #include <sys/device.h> #endif @@ -130,18 +77,24 @@ #include "fpa.h" #include <pci/pcivar.h> #include <i386/isa/icu.h> +#include <pci/pdqvar.h> #include <pci/pdqreg.h> -#include <pci/pdq_os.h> #elif defined(__bsdi__) +#if BSDI_VERSION < 199401 +#include <i386/isa/isavar.h> +#include <i386/isa/icu.h> +#define DRQNONE 0 +#define IRQSHARE 0 +#endif #include <i386/pci/pci.h> +#include <i386/pci/pdqvar.h> #include <i386/pci/pdqreg.h> -#include <i386/pci/pdq_os.h> -#elif defined(__NetBSD__) || defined (__OpenBSD__) -#include <dev/pci/pcireg.h> +#elif defined(__NetBSD__) +#include <dev/pci/pcidevs.h> #include <dev/pci/pcivar.h> -#include <dev/ic/pdqreg.h> #include <dev/ic/pdqvar.h> -#endif /* __NetBSD__ || __OpenBSD */ +#include <dev/ic/pdqreg.h> +#endif /* __NetBSD__ */ #define DEC_VENDORID 0x1011 @@ -153,71 +106,32 @@ #define PCI_CFLT 0x0C /* Configuration Latency */ #define PCI_CBMA 0x10 /* Configuration Base Memory Address */ +#define PCI_CBIO 0x14 /* Configuration Base I/O Address */ #if defined(__FreeBSD__) -/* - * This is the PCI configuration support. Since the PDQ is available - * on both EISA and PCI boards, one must be careful in how defines the - * PDQ in the config file. - */ -static char *pdq_pci_probe (pcici_t config_id, pcidi_t device_id); -static void pdq_pci_attach(pcici_t config_id, int unit); -static int pdq_pci_shutdown(struct kern_devconf *, int); -static u_long pdq_pci_count; - -struct pci_device fpadevice = { - "fpa", - pdq_pci_probe, - pdq_pci_attach, - &pdq_pci_count, - pdq_pci_shutdown, -}; - -#ifdef DATA_SET -DATA_SET (pcidevice_set, fpadevice); -#endif static pdq_softc_t *pdqs_pci[NFPA]; #define PDQ_PCI_UNIT_TO_SOFTC(unit) (pdqs_pci[unit]) -#endif /* __FreeBSD__ */ +#if BSD >= 199506 +#define pdq_pci_ifwatchdog NULL +#endif -#if defined(__bsdi__) +#elif defined(__bsdi__) extern struct cfdriver fpacd; #define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpacd.cd_devs[unit]) -#endif -#if defined(__NetBSD__) || defined (__OpenBSD__) +#elif defined(__NetBSD__) extern struct cfattach fpa_ca; extern struct cfdriver fpa_cd; #define PDQ_PCI_UNIT_TO_SOFTC(unit) ((pdq_softc_t *)fpa_cd.cd_devs[unit]) +#define pdq_pci_ifwatchdog NULL #endif -#if defined(__NetBSD__) -static ifnet_ret_t -pdq_pci_ifinit( - struct ifnet *ifp) -{ - pdq_ifinit((pdq_softc_t *)(ifp->if_softc)); -} - -static ifnet_ret_t -pdq_pci_ifwatchdog( - struct ifnet *ifp) -{ - pdq_ifwatchdog((pdq_softc_t *)(ifp->if_softc)); -} -#else -static ifnet_ret_t -pdq_pci_ifinit( - int unit) -{ - pdq_ifinit(PDQ_PCI_UNIT_TO_SOFTC(unit)); -} - +#ifndef pdq_pci_ifwatchdog static ifnet_ret_t pdq_pci_ifwatchdog( int unit) { - pdq_ifwatchdog(PDQ_PCI_UNIT_TO_SOFTC(unit)); + pdq_ifwatchdog(&PDQ_PCI_UNIT_TO_SOFTC(unit)->sc_if); } #endif @@ -228,13 +142,18 @@ pdq_pci_ifintr( pdq_softc_t * const sc = (pdq_softc_t *) arg; #ifdef __FreeBSD__ return pdq_interrupt(sc->sc_pdq); -#elif defined(__bsdi__) || defined(__NetBSD__) || defined(__OpenBSD__) +#elif defined(__bsdi__) || defined(__NetBSD__) (void) pdq_interrupt(sc->sc_pdq); return 1; #endif } #if defined(__FreeBSD__) +/* + * This is the PCI configuration support. Since the PDQ is available + * on both EISA and PCI boards, one must be careful in how defines the + * PDQ in the config file. + */ static char * pdq_pci_probe( pcici_t config_id, @@ -262,7 +181,7 @@ pdq_pci_attach( } data = pci_conf_read(config_id, PCI_CFLT); - if ((data & 0xFF00) == 0) { + if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) { data &= ~0xFF00; data |= DEFPA_LATENCY << 8; pci_conf_write(config_id, PCI_CFLT, data); @@ -280,7 +199,9 @@ pdq_pci_attach( sc->sc_if.if_name = "fpa"; sc->sc_if.if_unit = unit; - sc->sc_pdq = pdq_initialize((void *) va_csrs, "fpa", unit, + sc->sc_membase = (pdq_bus_memaddr_t) va_csrs; + sc->sc_pdq = pdq_initialize(PDQ_BUS_PCI, sc->sc_membase, + sc->sc_if.if_name, sc->sc_if.if_unit, (void *) sc, PDQ_DEFPA); if (sc->sc_pdq == NULL) { free((void *) sc, M_DEVBUF); @@ -288,7 +209,7 @@ pdq_pci_attach( } bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); pdqs_pci[unit] = sc; - pdq_ifattach(sc, pdq_pci_ifinit, pdq_pci_ifwatchdog); + pdq_ifattach(sc, pdq_pci_ifwatchdog); pci_map_int(config_id, pdq_pci_ifintr, (void*) sc, &net_imask); } @@ -302,6 +223,20 @@ pdq_pci_shutdown( (void) dev_detach(kdc); return 0; } + +static u_long pdq_pci_count; + +struct pci_device fpadevice = { + "fpa", + pdq_pci_probe, + pdq_pci_attach, + &pdq_pci_count, + pdq_pci_shutdown, +}; + +#ifdef DATA_SET +DATA_SET (pcidevice_set, fpadevice); +#endif #elif defined(__bsdi__) static int @@ -344,10 +279,9 @@ pdq_pci_probe( ffs(ia->ia_irq) - 1, ffs(irq) - 1); return 0; } - if (ia->ia_irq == IRQUNK && (ia->ia_irq = isa_irqalloc(irq)) == 0) { - printf("fpa%d: error: IRQ %d is already in use\n", cf->cf_unit, - ffs(irq) - 1); - return 0; + if (ia->ia_irq == IRQUNK) { + (void) isa_irqalloc(irq); + ia->ia_irq = irq; } /* PCI bus masters don't use host DMA channels */ @@ -366,11 +300,12 @@ pdq_pci_probe( /* Make sure the latency timer is what the DEFPA likes */ data = pci_inl(pa, PCI_CFLT); - if ((data & 0xFF00) == 0) { + if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) { data &= ~0xFF00; data |= DEFPA_LATENCY << 8; pci_outl(pa, PCI_CFLT, data); } + ia->ia_irq |= IRQSHARE; return 1; } @@ -389,9 +324,11 @@ pdq_pci_attach( sc->sc_if.if_unit = sc->sc_dev.dv_unit; sc->sc_if.if_name = "fpa"; sc->sc_if.if_flags = 0; + sc->sc_membase = (pdq_bus_memaddr_t) mapphys((vm_offset_t)ia->ia_maddr, ia->ia_msize); - sc->sc_pdq = pdq_initialize((void *) mapphys((vm_offset_t)ia->ia_maddr, ia->ia_msize), "fpa", - sc->sc_if.if_unit, (void *) sc, PDQ_DEFPA); + sc->sc_pdq = pdq_initialize(PDQ_BUS_PCI, sc->sc_membase, + sc->sc_if.if_nme, sc->sc_if.if_unit, + (void *) sc, PDQ_DEFPA); if (sc->sc_pdq == NULL) { printf("fpa%d: initialization failed\n", sc->sc_if.if_unit); return; @@ -399,13 +336,13 @@ pdq_pci_attach( bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); - pdq_ifattach(sc, pdq_pci_ifinit, pdq_pci_ifwatchdog); + pdq_ifattach(sc, pdq_pci_ifwatchdog); isa_establish(&sc->sc_id, &sc->sc_dev); sc->sc_ih.ih_fun = pdq_pci_ifintr; sc->sc_ih.ih_arg = (void *)sc; - intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET, sc->sc_dv.dv_xname); + intr_establish(ia->ia_irq, &sc->sc_ih, DV_NET); sc->sc_ats.func = (void (*)(void *)) pdq_hwreset; sc->sc_ats.arg = (void *) sc->sc_pdq; @@ -413,23 +350,27 @@ pdq_pci_attach( } struct cfdriver fpacd = { - 0, "fpa", pdq_pci_probe, pdq_pci_attach, DV_IFNET, sizeof(pdq_softc_t) + 0, "fpa", pdq_pci_probe, pdq_pci_attach, +#if _BSDI_VERSION >= 199401 + DV_IFNET, +#endif + sizeof(pdq_softc_t) }; -#elif defined(__NetBSD__) || defined (__OpenBSD__) +#elif defined(__NetBSD__) static int -pdq_pci_probe( +pdq_pci_match( struct device *parent, void *match, void *aux) { struct pci_attach_args *pa = (struct pci_attach_args *) aux; - if (PCI_VENDORID(pa->pa_id) != DEC_VENDORID) + if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_DEC) + return 0; + if (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_DEC_DEFPA) return 0; - if (PCI_CHIPID(pa->pa_id) == DEFPA_CHIPID) - return 1; return 0; } @@ -440,52 +381,85 @@ pdq_pci_attach( struct device * const self, void * const aux) { - vm_offset_t va_csrs, pa_csrs; - pdq_uint32_t data; pdq_softc_t * const sc = (pdq_softc_t *) self; struct pci_attach_args * const pa = (struct pci_attach_args *) aux; - pci_chipset_tag_t pc = pa->pa_pc; + pdq_uint32_t data; + pci_intr_handle_t intrhandle; + const char *intrstr; +#ifdef PDQ_IOMAPPED + bus_io_addr_t iobase; + bus_io_size_t iosize; +#else + bus_mem_addr_t membase; + bus_mem_size_t memsize; +#endif - data = pci_conf_read(pc, pa->pa_tag, PCI_CFLT); - if ((data & 0xFF00) == 0) { + data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFLT); + if ((data & 0xFF00) < (DEFPA_LATENCY << 8)) { data &= ~0xFF00; data |= DEFPA_LATENCY << 8; - pci_conf_write(pc, pa->pa_tag, PCI_CFLT, data); + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CFLT, data); } - if (pci_map_mem(pa->pa_tag, PCI_CBMA, &va_csrs, &pa_csrs)) - return; - + sc->sc_bc = pa->pa_bc; bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ); - sc->sc_if.if_softc = sc; sc->sc_if.if_flags = 0; - sc->sc_pdq = pdq_initialize((void *) va_csrs, - sc->sc_dev.dv_cfdata->cf_driver->cd_name, sc->sc_dev.dv_unit, - (void *) sc, PDQ_DEFPA); - if (sc->sc_pdq == NULL) + sc->sc_if.if_softc = sc; + +#ifdef PDQ_IOMAPPED + if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize) + || bus_io_map(pa->pa_bc, iobase, iosize, &sc->sc_iobase)){ + printf("\n%s: can't map I/O space!\n", sc->sc_dev.dv_xname); + return; + } +#else + if (pci_mem_find(pa->pa_pc, pa->pa_tag, PCI_CBMA, &membase, &memsize, NULL) + || bus_mem_map(pa->pa_bc, membase, memsize, 0, &sc->sc_membase)) { + printf("\n%s: can't map memory space!\n", sc->sc_dev.dv_xname); + return; + } +#endif + + sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase, + sc->sc_if.if_xname, 0, + (void *) sc, PDQ_DEFPA); + if (sc->sc_pdq == NULL) { + printf("%s: initialization failed\n", sc->sc_dev.dv_xname); return; - bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, - 6); - pdq_ifattach(sc, pdq_pci_ifinit, pdq_pci_ifwatchdog); + } - sc->sc_ih = pci_map_int(pa->pa_tag, IPL_NET, pdq_pci_ifintr, sc); + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + pdq_ifattach(sc, pdq_pci_ifwatchdog); + + if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin, + pa->pa_intrline, &intrhandle)) { + printf("%s: couldn't map interrupt\n", self->dv_xname); + return; + } + intrstr = pci_intr_string(pa->pa_pc, intrhandle); + sc->sc_ih = pci_intr_establish(pa->pa_pc, intrhandle, IPL_NET, pdq_pci_ifintr, + sc, self->dv_xname); if (sc->sc_ih == NULL) { - printf("%s: error: couldn't map interrupt\n", sc->sc_dev.dv_xname); + printf("%s: couldn't establish interrupt", self->dv_xname); + if (intrstr != NULL) + printf(" at %s", intrstr); + printf("\n"); return; } -#if 0 - sc->sc_ats = shutdownhook_establish(pdq_hwreset, sc); + + sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq); if (sc->sc_ats == NULL) - printf("%s: warning: couldn't establish shutdown hook\n", - sc->sc_dev.dv_xname); -#endif + printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname); + if (intrstr != NULL) + printf("%s: interrupting at %s\n", self->dv_xname, intrstr); } struct cfattach fpa_ca = { - sizeof(pdq_softc_t), pdq_pci_probe, pdq_pci_attach + sizeof(pdq_softc_t), pdq_pci_match, pdq_pci_attach }; struct cfdriver fpa_cd = { 0, "fpa", DV_IFNET }; -#endif /* __NetBSD__ || __OpenBSD__ */ + +#endif /* __NetBSD__ */ diff --git a/sys/dev/pci/if_le_pci.c b/sys/dev/pci/if_le_pci.c index e08d8906a76..27c932d32aa 100644 --- a/sys/dev/pci/if_le_pci.c +++ b/sys/dev/pci/if_le_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le_pci.c,v 1.1 1996/05/07 02:03:02 thorpej Exp $ */ +/* $NetBSD: if_le_pci.c,v 1.6 1996/05/14 22:23:38 thorpej Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -48,6 +48,10 @@ #include <sys/socket.h> #include <sys/device.h> +#include <vm/vm.h> +#include <vm/vm_kern.h> +#include <vm/vm_param.h> + #include <net/if.h> #ifdef INET @@ -58,7 +62,8 @@ #include <vm/vm.h> #include <machine/cpu.h> -#include <machine/pio.h> +#include <machine/bus.h> +#include <machine/intr.h> #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> @@ -69,6 +74,11 @@ #include <dev/pci/if_levar.h> +#ifdef __alpha__ /* XXX */ +/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */ +#define vtophys(va) (vtophys(va) | 0x40000000) +#endif + int le_pci_match __P((struct device *, void *, void *)); void le_pci_attach __P((struct device *, struct device *, void *)); @@ -79,14 +89,23 @@ struct cfattach le_pci_ca = { hide void le_pci_wrcsr __P((struct am7990_softc *, u_int16_t, u_int16_t)); hide u_int16_t le_pci_rdcsr __P((struct am7990_softc *, u_int16_t)); +/* + * PCI constants. + * XXX These should be in a common file! + */ +#define PCI_CBIO 0x10 /* Configuration Base IO Address */ + hide void le_pci_wrcsr(sc, port, val) struct am7990_softc *sc; u_int16_t port, val; { + struct le_softc *lesc = (struct le_softc *)sc; + bus_chipset_tag_t bc = lesc->sc_bc; + bus_io_handle_t ioh = lesc->sc_ioh; - outw(((struct le_softc *)sc)->sc_rap, port); - outw(((struct le_softc *)sc)->sc_rdp, val); + bus_io_write_2(bc, ioh, lesc->sc_rap, port); + bus_io_write_2(bc, ioh, lesc->sc_rdp, val); } hide u_int16_t @@ -94,10 +113,13 @@ le_pci_rdcsr(sc, port) struct am7990_softc *sc; u_int16_t port; { + struct le_softc *lesc = (struct le_softc *)sc; + bus_chipset_tag_t bc = lesc->sc_bc; + bus_io_handle_t ioh = lesc->sc_ioh; u_int16_t val; - outw(((struct le_softc *)sc)->sc_rap, port); - val = inw(((struct le_softc *)sc)->sc_rdp); + bus_io_write_2(bc, ioh, lesc->sc_rap, port); + val = bus_io_read_2(bc, ioh, lesc->sc_rdp); return (val); } @@ -127,33 +149,43 @@ le_pci_attach(parent, self, aux) struct le_softc *lesc = (void *)self; struct am7990_softc *sc = &lesc->sc_am7990; struct pci_attach_args *pa = aux; - pci_chipset_tag_t pc = pa->pa_pc; pci_intr_handle_t ih; + bus_io_addr_t iobase; + bus_io_size_t iosize; + bus_io_handle_t ioh; + bus_chipset_tag_t bc = pa->pa_bc; + pci_chipset_tag_t pc = pa->pa_pc; pcireg_t csr; - int iobase, i; + int i; const char *model, *intrstr; switch (PCI_PRODUCT(pa->pa_id)) { case PCI_PRODUCT_AMD_PCNET_PCI: model = "PCnet-PCI Ethernet"; - lesc->sc_rap = iobase + PCNET_PCI_RAP; - lesc->sc_rdp = iobase + PCNET_PCI_RDP; + lesc->sc_rap = PCNET_PCI_RAP; + lesc->sc_rdp = PCNET_PCI_RDP; break; default: model = "unknown model!"; } - printf(": %s\n", sc->sc_dev.dv_xname, model); + printf(": %s\n", model); - if (pci_map_io(pa->pa_tag, 0x10, &iobase)) + if (pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) { + printf("%s: can't find I/O base\n", sc->sc_dev.dv_xname); + return; + } + if (bus_io_map(bc, iobase, iosize, &ioh)) { + printf("%s: can't map I/O space\n", sc->sc_dev.dv_xname); return; + } /* * Extract the physical MAC address from the ROM. */ for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++) - sc->sc_arpcom.ac_enaddr[i] = inb(iobase + i); + sc->sc_arpcom.ac_enaddr[i] = bus_io_read_1(bc, ioh, i); sc->sc_mem = malloc(16384, M_DEVBUF, M_NOWAIT); if (sc->sc_mem == 0) { @@ -162,8 +194,11 @@ le_pci_attach(parent, self, aux) return; } + lesc->sc_bc = bc; + lesc->sc_ioh = ioh; + sc->sc_conf3 = 0; - sc->sc_addr = kvtop(sc->sc_mem); /* XXX XXX XXX */ + sc->sc_addr = vtophys(sc->sc_mem); /* XXX XXX XXX */ sc->sc_memsize = 16384; sc->sc_copytodesc = am7990_copytobuf_contig; @@ -180,9 +215,9 @@ le_pci_attach(parent, self, aux) am7990_config(sc); /* Enable the card. */ - csr = pci_conf_read(pa->pa_bc, pa->pa_tag, + csr = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); - pci_conf_write(pa->pa_bc, pa->pa_tag, PCI_COMMAND_STATUS_REG, + pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr | PCI_COMMAND_MASTER_ENABLE); /* Map and establish the interrupt. */ diff --git a/sys/dev/pci/if_levar.h b/sys/dev/pci/if_levar.h index 03f5e0c9312..45045bd3e4b 100644 --- a/sys/dev/pci/if_levar.h +++ b/sys/dev/pci/if_levar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_levar.h,v 1.1 1996/05/07 02:03:04 thorpej Exp $ */ +/* $NetBSD: if_levar.h,v 1.2 1996/05/12 02:30:05 thorpej Exp $ */ /* * LANCE Ethernet driver header file @@ -27,5 +27,7 @@ struct le_softc { struct am7990_softc sc_am7990; /* glue to MI code */ void *sc_ih; + bus_chipset_tag_t sc_bc; /* chipset cookie */ + bus_io_handle_t sc_ioh; /* bus i/o handle */ int sc_rap, sc_rdp; /* offsets to LANCE registers */ }; diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c index 56433f73cd4..55dfddbb607 100644 --- a/sys/dev/pci/ncr.c +++ b/sys/dev/pci/ncr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ncr.c,v 1.8 1996/05/07 07:38:40 deraadt Exp $ */ -/* $NetBSD: ncr.c,v 1.34 1996/05/03 17:39:49 christos Exp $ */ +/* $OpenBSD: ncr.c,v 1.9 1996/05/26 00:27:45 deraadt Exp $ */ +/* $NetBSD: ncr.c,v 1.35 1996/05/13 00:03:26 mycroft Exp $ */ /************************************************************************** ** @@ -195,9 +195,7 @@ extern PRINT_ADDR(); #else #include <sys/device.h> #include <machine/bus.h> -#ifdef __alpha__ #include <machine/intr.h> -#endif #include <dev/pci/ncr_reg.h> #include <dev/pci/pcireg.h> #include <dev/pci/pcivar.h> @@ -1331,7 +1329,7 @@ static void ncr_attach (pcici_t tag, int unit); #if 0 static char ident[] = - "\n$NetBSD: ncr.c,v 1.34 1996/05/03 17:39:49 christos Exp $\n"; + "\n$NetBSD: ncr.c,v 1.35 1996/05/13 00:03:26 mycroft Exp $\n"; #endif u_long ncr_version = NCR_VERSION * 11 diff --git a/sys/dev/pci/pcidevs b/sys/dev/pci/pcidevs index ab2440d41a1..0dad81e610e 100644 --- a/sys/dev/pci/pcidevs +++ b/sys/dev/pci/pcidevs @@ -1,4 +1,4 @@ -$OpenBSD: pcidevs,v 1.8 1996/05/10 12:38:25 deraadt Exp $ +$OpenBSD: pcidevs,v 1.9 1996/05/26 00:27:46 deraadt Exp $ /* $NetBSD: pcidevs,v 1.8 1996/05/07 01:59:45 thorpej Exp $ */ @@ -73,6 +73,7 @@ vendor ZENITH 0x1024 Zenith Data Systems vendor ACER 0x1025 Acer vendor DELL 0x1028 Dell Computer vendor SIEMENS 0x1029 Siemens Nixdorf IS +vendor LSILOGIC 0x102a LSI Logic, Headland div. vendor MATROX 0x102b Matrox vendor CHIPS 0x102c Chips and Technologies vendor WYSE 0x102d WYSE Technology @@ -431,7 +432,8 @@ product ATI MACH64_CX 0x4358 Mach64-CX product ATI MACH64_GX 0x4758 Mach64-GX /* BusLogic products */ -product BUSLOGIC 946C 0x0140 946C +product BUSLOGIC OLD946C 0x0140 946C +product BUSLOGIC 946C 0x1040 946C /* Cirrus Logic products */ /* product CIRRUS UNK 0x00a4 unknown */ @@ -489,11 +491,13 @@ product QLOGIC ISP1020 0x1020 ISP1020 /* S3 products */ /* Names??? */ -product S3 TRIO64 0x8811 Trio64 +product S3 TRIO64 0x8811 Trio32/64/64V+ +product S3 868 0x8880 868 product S3 928 0x88b0 928 product S3 864_0 0x88c0 Vision 864-0 product S3 864_1 0x88c1 Vision 864-1 product S3 964 0x88d0 964 +product S3 968 0x88f0 968 /* SMC products */ product SMC 37C665 0x1000 37C665 @@ -504,5 +508,5 @@ product TSENG W32P_D 0x3207 ET4000w32p rev D /* UMC products */ product UMC UM8673F 0x0101 UM8673F -product UMC UM8881F 0x8881 UM8881F -product UMC UM8886F 0x8886 UM8886F +product UMC UM8881F 0x8881 UM8881F PCI-Host bridge +product UMC UM8886F 0x8886 UM8886F PCI-ISA bridge diff --git a/sys/dev/pci/pcidevs.h b/sys/dev/pci/pcidevs.h index 599116d7456..fe183899754 100644 --- a/sys/dev/pci/pcidevs.h +++ b/sys/dev/pci/pcidevs.h @@ -78,6 +78,7 @@ #define PCI_VENDOR_ACER 0x1025 /* Acer */ #define PCI_VENDOR_DELL 0x1028 /* Dell Computer */ #define PCI_VENDOR_SIEMENS 0x1029 /* Siemens Nixdorf IS */ +#define PCI_VENDOR_LSILOGIC 0x102a /* LSI Logic, Headland div. */ #define PCI_VENDOR_MATROX 0x102b /* Matrox */ #define PCI_VENDOR_CHIPS 0x102c /* Chips and Technologies */ #define PCI_VENDOR_WYSE 0x102d /* WYSE Technology */ @@ -436,7 +437,8 @@ #define PCI_PRODUCT_ATI_MACH64_GX 0x4758 /* Mach64-GX */ /* BusLogic products */ -#define PCI_PRODUCT_BUSLOGIC_946C 0x0140 /* 946C */ +#define PCI_PRODUCT_BUSLOGIC_OLD946C 0x0140 /* 946C */ +#define PCI_PRODUCT_BUSLOGIC_946C 0x1040 /* 946C */ /* Cirrus Logic products */ /* product CIRRUS UNK 0x00a4 unknown */ @@ -494,11 +496,13 @@ /* S3 products */ /* Names??? */ -#define PCI_PRODUCT_S3_TRIO64 0x8811 /* Trio64 */ +#define PCI_PRODUCT_S3_TRIO64 0x8811 /* Trio32/64/64V+ */ +#define PCI_PRODUCT_S3_868 0x8880 /* 868 */ #define PCI_PRODUCT_S3_928 0x88b0 /* 928 */ #define PCI_PRODUCT_S3_864_0 0x88c0 /* Vision 864-0 */ #define PCI_PRODUCT_S3_864_1 0x88c1 /* Vision 864-1 */ #define PCI_PRODUCT_S3_964 0x88d0 /* 964 */ +#define PCI_PRODUCT_S3_968 0x88f0 /* 968 */ /* SMC products */ #define PCI_PRODUCT_SMC_37C665 0x1000 /* 37C665 */ @@ -509,5 +513,5 @@ /* UMC products */ #define PCI_PRODUCT_UMC_UM8673F 0x0101 /* UM8673F */ -#define PCI_PRODUCT_UMC_UM8881F 0x8881 /* UM8881F */ -#define PCI_PRODUCT_UMC_UM8886F 0x8886 /* UM8886F */ +#define PCI_PRODUCT_UMC_UM8881F 0x8881 /* UM8881F PCI-Host bridge */ +#define PCI_PRODUCT_UMC_UM8886F 0x8886 /* UM8886F PCI-ISA bridge */ diff --git a/sys/dev/pci/pcidevs_data.h b/sys/dev/pci/pcidevs_data.h index 09813ed0bb0..9364ba66586 100644 --- a/sys/dev/pci/pcidevs_data.h +++ b/sys/dev/pci/pcidevs_data.h @@ -105,6 +105,12 @@ struct pci_knowndev pci_knowndevs[] = { "Mach64-GX", }, { + PCI_VENDOR_BUSLOGIC, PCI_PRODUCT_BUSLOGIC_OLD946C, + 0, + "BusLogic", + "946C", + }, + { PCI_VENDOR_BUSLOGIC, PCI_PRODUCT_BUSLOGIC_946C, 0, "BusLogic", @@ -288,7 +294,13 @@ struct pci_knowndev pci_knowndevs[] = { PCI_VENDOR_S3, PCI_PRODUCT_S3_TRIO64, 0, "S3", - "Trio64", + "Trio32/64/64V+", + }, + { + PCI_VENDOR_S3, PCI_PRODUCT_S3_868, + 0, + "S3", + "868", }, { PCI_VENDOR_S3, PCI_PRODUCT_S3_928, @@ -315,6 +327,12 @@ struct pci_knowndev pci_knowndevs[] = { "964", }, { + PCI_VENDOR_S3, PCI_PRODUCT_S3_968, + 0, + "S3", + "968", + }, + { PCI_VENDOR_SMC, PCI_PRODUCT_SMC_37C665, 0, "Standard Microsystems", @@ -342,13 +360,13 @@ struct pci_knowndev pci_knowndevs[] = { PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8881F, 0, "United Microelectronics", - "UM8881F", + "UM8881F PCI-Host bridge", }, { PCI_VENDOR_UMC, PCI_PRODUCT_UMC_UM8886F, 0, "United Microelectronics", - "UM8886F", + "UM8886F PCI-ISA bridge", }, { PCI_VENDOR_OLDCOMPAQ, 0, @@ -567,6 +585,12 @@ struct pci_knowndev pci_knowndevs[] = { NULL, }, { + PCI_VENDOR_LSILOGIC, 0, + PCI_KNOWNDEV_NOPROD, + "LSI Logic, Headland div.", + NULL, + }, + { PCI_VENDOR_MATROX, 0, PCI_KNOWNDEV_NOPROD, "Matrox", diff --git a/sys/dev/sun/kbd.c b/sys/dev/sun/kbd.c index 4f5f5cbf6b4..51fc79a0d69 100644 --- a/sys/dev/sun/kbd.c +++ b/sys/dev/sun/kbd.c @@ -1,5 +1,5 @@ -/* $OpenBSD: kbd.c,v 1.3 1996/04/21 22:26:10 deraadt Exp $ */ -/* $NetBSD: kbd.c,v 1.7 1996/04/10 21:44:58 gwr Exp $ */ +/* $OpenBSD: kbd.c,v 1.4 1996/05/26 00:27:49 deraadt Exp $ */ +/* $NetBSD: kbd.c,v 1.8 1996/05/17 19:32:06 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -247,7 +247,7 @@ kbd_attach(parent, self, aux) printf("\n"); /* Initialize the speed, etc. */ - tconst = BPS_TO_TCONST(cs->cs_pclk_div16, KBD_BPS); + tconst = BPS_TO_TCONST(cs->cs_brg_clk, KBD_BPS); s = splzs(); if (k->k_isconsole == 0) { /* Not the console; may need reset. */ diff --git a/sys/dev/sun/ms.c b/sys/dev/sun/ms.c index a176c06bdcb..cf28bde08b2 100644 --- a/sys/dev/sun/ms.c +++ b/sys/dev/sun/ms.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ms.c,v 1.3 1996/04/21 22:26:13 deraadt Exp $ */ -/* $NetBSD: ms.c,v 1.5 1996/04/10 21:45:01 gwr Exp $ */ +/* $OpenBSD: ms.c,v 1.4 1996/05/26 00:27:50 deraadt Exp $ */ +/* $NetBSD: ms.c,v 1.6 1996/05/17 19:32:09 gwr Exp $ */ /* * Copyright (c) 1992, 1993 @@ -195,7 +195,7 @@ ms_attach(parent, self, aux) printf("\n"); /* Initialize the speed, etc. */ - tconst = BPS_TO_TCONST(cs->cs_pclk_div16, MS_BPS); + tconst = BPS_TO_TCONST(cs->cs_brg_clk, MS_BPS); s = splzs(); /* May need reset... */ reset = (channel == 0) ? diff --git a/sys/dev/tc/asc.c b/sys/dev/tc/asc.c index c61f99c5774..0e8e4b385e6 100644 --- a/sys/dev/tc/asc.c +++ b/sys/dev/tc/asc.c @@ -1,4 +1,4 @@ -/* $NetBSD: asc.c,v 1.18 1996/03/18 01:39:47 jonathan Exp $ */ +/* $NetBSD: asc.c,v 1.19 1996/05/20 09:46:21 jonathan Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -129,13 +129,17 @@ #include <sys/conf.h> #include <sys/errno.h> #include <sys/device.h> +#include <sys/reboot.h> + #include <dev/tc/tcvar.h> #include <dev/tc/ioasicvar.h> #include <scsi/scsi_all.h> #include <scsi/scsiconf.h> -#include <machine/machConst.h> +#include <machine/cpu.h> +#include <machine/machConst.h> /* XXX */ +#include <machine/locore.h> /* XXX */ #include <machine/autoconf.h> #include <pmax/dev/device.h> @@ -210,6 +214,7 @@ struct asc_log { } asc_log[NLOG], *asc_logp = asc_log; #define PACK(unit, status, ss, ir) \ ((unit << 24) | (status << 16) | (ss << 8) | ir) +void asc_DumpLog __P((char *str)); #endif /* @@ -504,7 +509,6 @@ ascmatch(parent, match, aux) void *match; void *aux; { - struct cfdata *cf = match; struct confargs *ca = aux; void *ascaddr; @@ -707,7 +711,8 @@ asc_start(scsicmd) * separate LUNs. */ if (asc->cmd[sdp->sd_drive]) { - printf("%s: device %s busy at start\n", sdp->sd_ctlr, + printf("asc %d: device %s busy at start\n", + sdp->sd_ctlr, /*XXX*/ sdp->sd_driver->d_name); (*sdp->sd_driver->d_done)(scsicmd->unit, EBUSY, scsicmd->buflen, 0); @@ -755,17 +760,17 @@ asc_reset(asc, regs) * Reset chip and wait till done */ regs->asc_cmd = ASC_CMD_RESET; - MachEmptyWriteBuffer(); DELAY(25); + wbflush(); DELAY(25); /* spec says this is needed after reset */ regs->asc_cmd = ASC_CMD_NOP; - MachEmptyWriteBuffer(); DELAY(25); + wbflush(); DELAY(25); /* * Set up various chip parameters */ regs->asc_ccf = asc->ccf; - MachEmptyWriteBuffer(); DELAY(25); + wbflush(); DELAY(25); regs->asc_sel_timo = asc->timeout_250; /* restore our ID */ regs->asc_cnfg1 = asc->sc_id | ASC_CNFG1_P_CHECK; @@ -776,7 +781,7 @@ asc_reset(asc, regs) ASC_TC_PUT(regs, 0); regs->asc_syn_p = asc->min_period; regs->asc_syn_o = 0; /* async for now */ - MachEmptyWriteBuffer(); + wbflush(); } /* @@ -878,7 +883,7 @@ asc_startcmd(asc, target) /* preload the FIFO with the message to be sent */ regs->asc_fifo = SCSI_DIS_REC_IDENTIFY; - MachEmptyWriteBuffer(); + wbflush(); /* initialize the DMA */ (*asc->dma_start)(asc, state, state->dmaBufAddr, ASCDMA_WRITE); @@ -926,7 +931,7 @@ again: /* drop spurious interrupts */ if ((status & ASC_CSR_INT) == 0) - return; + return (-1); /* XXX */ ir = regs->asc_intr; /* this resets the previous two: i.e.,*/ /* this re-latches CSR (and SSTEP) */ @@ -1038,6 +1043,7 @@ again: printf("asc: DMA_OUT, fifo resid %d, len %d, flags 0x%x\n", fifo, len, state->flags); len += fifo; +/*XXX*/ goto abort; } else if (state->flags & DMA_IN) { u_char *cp; @@ -1047,11 +1053,12 @@ again: cp = state->dmaBufAddr + (state->dmalen - len); while (fifo-- > 0) *cp++ = regs->asc_fifo; +/*XXX*/ goto abort; } else printf("asc_intr: dmalen %d len %d fifo %d\n", state->dmalen, len, fifo); /* XXX */ regs->asc_cmd = ASC_CMD_FLUSH; - MachEmptyWriteBuffer(); + wbflush(); readback(regs->asc_cmd); DELAY(2); } @@ -1276,7 +1283,7 @@ again: */ done: - MachEmptyWriteBuffer(); + wbflush(); /* watch out for HW race conditions and setup & hold time violations */ ir = regs->asc_status; while (ir != (status = regs->asc_status)) @@ -1792,13 +1799,13 @@ asc_sendsync(asc, status, ss, ir) /* send the extended synchronous negotiation message */ regs->asc_fifo = SCSI_EXTENDED_MSG; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = 3; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = SCSI_SYNCHRONOUS_XFER; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = SCSI_MIN_PERIOD; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = ASC_MAX_OFFSET; /* state to resume after we see the sync reply message */ state->script = asc->script + 2; @@ -1823,13 +1830,13 @@ asc_replysync(asc, status, ss, ir) #endif /* send synchronous transfer in response to a request */ regs->asc_fifo = SCSI_EXTENDED_MSG; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = 3; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = SCSI_SYNCHRONOUS_XFER; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = asc_to_scsi_period[state->sync_period] * asc->tb_ticks; - MachEmptyWriteBuffer(); + wbflush(); regs->asc_fifo = state->sync_offset; regs->asc_cmd = ASC_CMD_XFER_INFO; readback(regs->asc_cmd); @@ -2038,7 +2045,10 @@ asc_disconnect(asc, status, ss, ir) register asc_softc_t asc; register int status, ss, ir; { +#if MACH_DDIAGNOSTIC + /* later Mach driver checks for late asych disconnect here. */ register State *state = &asc->st[asc->target]; +#endif #ifdef DIAGNOSTIC if (!(state->flags & DISCONN)) { @@ -2094,7 +2104,7 @@ asic_dma_start(asc, state, cp, flag) *((volatile int *)IOASIC_REG_SCSI_SCR(ioasic_base)) = 0; phys = MACH_CACHED_TO_PHYS(cp); - cp = (caddr_t)pmax_trunc_page(cp + NBPG); + cp = (caddr_t)mips_trunc_page(cp + NBPG); nphys = MACH_CACHED_TO_PHYS(cp); asc->dma_next = cp; @@ -2108,7 +2118,7 @@ asic_dma_start(asc, state, cp, flag) *ssr |= IOASIC_CSR_SCSI_DIR | IOASIC_CSR_DMAEN_SCSI; else *ssr = (*ssr & ~IOASIC_CSR_SCSI_DIR) | IOASIC_CSR_DMAEN_SCSI; - MachEmptyWriteBuffer(); + wbflush(); } static void @@ -2129,12 +2139,12 @@ asic_dma_end(asc, state, flag) to = (u_short *)MACH_PHYS_TO_CACHED(*dmap >> 3); *dmap = -1; *((volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base)) = -1; - MachEmptyWriteBuffer(); + wbflush(); if (flag == ASCDMA_READ) { MachFlushDCache(MACH_PHYS_TO_CACHED( MACH_UNCACHED_TO_PHYS(state->dmaBufAddr)), state->dmalen); - if (nb = *((int *)IOASIC_REG_SCSI_SCR(ioasic_base))) { + if ( (nb = *((int *)IOASIC_REG_SCSI_SCR(ioasic_base))) != 0) { /* pick up last upto6 bytes, sigh. */ /* Last byte really xferred is.. */ @@ -2173,11 +2183,12 @@ asc_dma_intr() } *(volatile int *)IOASIC_REG_SCSI_DMANPTR(ioasic_base) = IOASIC_DMA_ADDR(next_phys); - MachEmptyWriteBuffer(); + wbflush(); } #endif /*notdef*/ #ifdef DEBUG +void asc_DumpLog(str) char *str; { diff --git a/sys/dev/tc/files.tc b/sys/dev/tc/files.tc index 2cc7de0c1ab..38490a44ab8 100644 --- a/sys/dev/tc/files.tc +++ b/sys/dev/tc/files.tc @@ -1,5 +1,5 @@ -# $OpenBSD: files.tc,v 1.4 1996/05/10 12:33:25 deraadt Exp $ -# $NetBSD: files.tc,v 1.4 1996/05/07 02:25:00 thorpej Exp $ +# $OpenBSD: files.tc,v 1.5 1996/05/26 00:27:52 deraadt Exp $ +# $NetBSD: files.tc,v 1.5 1996/05/20 00:45:02 thorpej Exp $ # # Config.new file and device description for machine-independent # TurboChannel code. Included by ports that need it. @@ -14,3 +14,8 @@ file dev/tc/tc.c tc needs-flag # file dev/tc/if_le_dec.c (le_ioasic | le_tc) # file dev/tc/if_le_ioasic.c le_ioasic needs-flag # for le_iomem # file dev/tc/if_le_tc.c le_tc + +# DEC DEFTA TC FDDI Controller +device fta: pdq, fddi, ifnet +attach fta at tc +file dev/tc/if_fta.c fta diff --git a/sys/dev/tc/if_fta.c b/sys/dev/tc/if_fta.c new file mode 100644 index 00000000000..74686143530 --- /dev/null +++ b/sys/dev/tc/if_fta.c @@ -0,0 +1,119 @@ +/* $NetBSD: if_fta.c,v 1.4 1996/05/20 15:53:09 thorpej Exp $ */ + +/*- + * Copyright (c) 1996 Matt Thomas <matt@3am-software.com> + * 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. The name of the author may not be used to endorse or promote products + * derived from this software withough 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. + * + * Id: if_fta.c,v 1.3 1996/05/17 01:15:18 thomas Exp + * + */ + +/* + * DEC TurboChannel FDDI Controller; code for BSD derived operating systems + * + * Written by Matt Thomas + * + * This module supports the DEC DEFTA TurboChannel FDDI Controller + */ + + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/mbuf.h> +#include <sys/protosw.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/errno.h> +#include <sys/malloc.h> +#include <sys/device.h> + +#include <net/if.h> +#include <net/if_types.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/if_ether.h> +#endif +#include <net/if_fddi.h> + +#include <vm/vm.h> +#include <vm/vm_kern.h> +#include <vm/vm_param.h> + +#include <dev/tc/tcvar.h> +#include <dev/ic/pdqvar.h> +#include <dev/ic/pdqreg.h> + +static int +pdq_tc_match( + struct device *parent, + void *match, + void *aux) +{ + struct tc_attach_args *ta = (struct tc_attach_args *) aux; + + if (strncmp("PMAF-F", ta->ta_modname, 6) == 0) + return 1; + + return 0; +} + +static void +pdq_tc_attach( + struct device * const parent, + struct device * const self, + void * const aux) +{ + pdq_softc_t * const sc = (pdq_softc_t *) self; + struct tc_attach_args * const ta = (struct tc_attach_args *) aux; + + sc->sc_bc = ta->ta_bc; + bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ); + sc->sc_if.if_flags = 0; + sc->sc_if.if_softc = sc; + + if (bus_mem_map(sc->sc_bc, ta->ta_addr + PDQ_TC_CSR_OFFSET, + PDQ_TC_CSR_SPACE, 0, &sc->sc_membase)) { + printf("\n%s: can't map card memory!\n", sc->sc_dev.dv_xname); + return; + } + + sc->sc_pdq = pdq_initialize(sc->sc_bc, sc->sc_membase, + sc->sc_if.if_xname, 0, + (void *) sc, PDQ_DEFTA); + if (sc->sc_pdq == NULL) { + printf("%s: initialization failed\n", sc->sc_dev.dv_xname); + return; + } + bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes, sc->sc_ac.ac_enaddr, 6); + pdq_ifattach(sc, NULL); + + tc_intr_establish(parent, ta->ta_cookie, TC_IPL_NET, + (int (*)(void *)) pdq_interrupt, sc->sc_pdq); + + sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq); + if (sc->sc_ats == NULL) + printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname); +} + +struct cfattach fta_ca = { sizeof(pdq_softc_t), pdq_tc_match, pdq_tc_attach }; +struct cfdriver fta_cd = { 0, "fta", DV_IFNET }; diff --git a/sys/dev/tc/if_le_ibus.c b/sys/dev/tc/if_le_ibus.c new file mode 100644 index 00000000000..904e472bcf9 --- /dev/null +++ b/sys/dev/tc/if_le_ibus.c @@ -0,0 +1,191 @@ +/* $NetBSD: if_le_ibus.c,v 1.3 1996/05/20 23:19:16 jonathan Exp $ */ + +/* + * Copyright 1996 The Board of Trustees of The Leland Stanford + * Junior University. All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this + * software and its documentation for any purpose and without + * fee is hereby granted, provided that the above copyright + * notice appear in all copies. Stanford University + * makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * This driver was contributed by Jonathan Stone. + */ + +/* + * LANCE on Decstation kn01/kn220(?) baseboard. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/mbuf.h> +#include <sys/syslog.h> +#include <sys/socket.h> +#include <sys/device.h> + +#include <net/if.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/if_ether.h> +#endif + +#include <dev/ic/am7990reg.h> +#include <dev/ic/am7990var.h> + +#include <dev/tc/if_levar.h> +#include <dev/tc/tcvar.h> +#include <machine/autoconf.h> +#include <pmax/pmax/kn01.h> +#include <pmax/pmax/kn01var.h> + +extern struct cfdriver mainbus_cd; /* should be in header but where? */ + +extern void le_dec_copytobuf_gap2 __P((struct am7990_softc *, void *, + int, int)); +extern void le_dec_copyfrombuf_gap2 __P((struct am7990_softc *, void *, + int, int)); + +hide void le_dec_zerobuf_gap2 __P((struct am7990_softc *, int, int)); + + +int le_pmax_match __P((struct device *, void *, void *)); +void le_pmax_attach __P((struct device *, struct device *, void *)); + +struct cfattach le_pmax_ca = { + sizeof(struct le_softc), le_pmax_match, le_pmax_attach +}; + + +int +le_pmax_match(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + if (parent->dv_cfdata->cf_driver == &mainbus_cd) { + struct confargs *d = aux; + if (strcmp("lance", d->ca_name) == 0) + return (1); + } + return (0); +} + +void +le_pmax_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + register struct le_softc *lesc = (void *)self; + register struct am7990_softc *sc = &lesc->sc_am7990; + register u_char *cp; + register struct confargs *ca = aux; + + /* + * It's on the baseboard, with a dedicated interrupt line. + */ + lesc->sc_r1 = (struct lereg1 *)(ca->ca_addr); +/*XXX*/ sc->sc_mem = (void *)TC_PHYS_TO_UNCACHED(0x19000000); +/*XXX*/ cp = (u_char *)(TC_PHYS_TO_UNCACHED(KN01_SYS_CLOCK) + 1); + + sc->sc_copytodesc = le_dec_copytobuf_gap2; + sc->sc_copyfromdesc = le_dec_copyfrombuf_gap2; + sc->sc_copytobuf = le_dec_copytobuf_gap2; + sc->sc_copyfrombuf = le_dec_copyfrombuf_gap2; + sc->sc_zerobuf = le_dec_zerobuf_gap2; + + dec_le_common_attach(sc, cp); + /* XXX more thought about ca->slotpri */ + kn01_intr_establish(parent, (void*)ca->ca_slotpri, TC_IPL_NET, + am7990_intr, sc); +} + +/* + * gap2: two bytes of data followed by two bytes of pad. + * + * Buffers must be 4-byte aligned. The code doesn't worry about + * doing an extra byte. + */ + +void +le_dec_copytobuf_gap2(sc, fromv, boff, len) + struct am7990_softc *sc; + void *fromv; + int boff; + register int len; +{ + volatile caddr_t buf = sc->sc_mem; + register caddr_t from = fromv; + register volatile u_int16_t *bptr; + + if (boff & 0x1) { + /* handle unaligned first byte */ + bptr = ((volatile u_int16_t *)buf) + (boff - 1); + *bptr = (*from++ << 8) | (*bptr & 0xff); + bptr += 2; + len--; + } else + bptr = ((volatile u_int16_t *)buf) + boff; + while (len > 1) { + *bptr = (from[1] << 8) | (from[0] & 0xff); + bptr += 2; + from += 2; + len -= 2; + } + if (len == 1) + *bptr = (u_int16_t)*from; +} + +void +le_dec_copyfrombuf_gap2(sc, tov, boff, len) + struct am7990_softc *sc; + void *tov; + int boff, len; +{ + volatile caddr_t buf = sc->sc_mem; + register caddr_t to = tov; + register volatile u_int16_t *bptr; + register u_int16_t tmp; + + if (boff & 0x1) { + /* handle unaligned first byte */ + bptr = ((volatile u_int16_t *)buf) + (boff - 1); + *to++ = (*bptr >> 8) & 0xff; + bptr += 2; + len--; + } else + bptr = ((volatile u_int16_t *)buf) + boff; + while (len > 1) { + tmp = *bptr; + *to++ = tmp & 0xff; + *to++ = (tmp >> 8) & 0xff; + bptr += 2; + len -= 2; + } + if (len == 1) + *to = *bptr & 0xff; +} + +void +le_dec_zerobuf_gap2(sc, boff, len) + struct am7990_softc *sc; + int boff, len; +{ + volatile caddr_t buf = sc->sc_mem; + register volatile u_int16_t *bptr; + + if ((unsigned)boff & 0x1) { + bptr = ((volatile u_int16_t *)buf) + (boff - 1); + *bptr &= 0xff; + bptr += 2; + len--; + } else + bptr = ((volatile u_int16_t *)buf) + boff; + while (len > 0) { + *bptr = 0; + bptr += 2; + len -= 2; + } +} diff --git a/sys/dev/tc/tc.c b/sys/dev/tc/tc.c index 8fe079d85ab..690067798d1 100644 --- a/sys/dev/tc/tc.c +++ b/sys/dev/tc/tc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: tc.c,v 1.5 1996/05/07 07:31:39 deraadt Exp $ */ -/* $NetBSD: tc.c,v 1.15 1996/04/29 16:06:38 cgd Exp $ */ +/* $OpenBSD: tc.c,v 1.6 1996/05/26 00:27:54 deraadt Exp $ */ +/* $NetBSD: tc.c,v 1.16 1996/05/17 23:39:19 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -129,6 +129,9 @@ tcattach(parent, self, aux) * Set up the device attachment information. */ strncpy(ta.ta_modname, builtin->tcb_modname, TC_ROM_LLEN); +#ifdef __alpha__ /* XXX */ + ta.ta_bc = tba->tba_bc; +#endif ta.ta_modname[TC_ROM_LLEN] = '\0'; ta.ta_slot = builtin->tcb_slot; ta.ta_offset = builtin->tcb_offset; diff --git a/sys/dev/tc/tcdevs b/sys/dev/tc/tcdevs index 6329ec0b4dd..bd7b087c711 100644 --- a/sys/dev/tc/tcdevs +++ b/sys/dev/tc/tcdevs @@ -1,4 +1,4 @@ -$OpenBSD: tcdevs,v 1.1 1996/04/18 23:48:23 niklas Exp $ +$OpenBSD: tcdevs,v 1.2 1996/05/26 00:27:54 deraadt Exp $ /* $NetBSD: tcdevs,v 1.3 1996/03/05 23:15:59 cgd Exp $ */ /* @@ -34,7 +34,8 @@ $OpenBSD: tcdevs,v 1.1 1996/04/18 23:48:23 niklas Exp $ device KZTSA-AA tza TZA FWD SCSI device PMAD-AA le LANCE Ethernet -device PMAF-AA fza FZA FDDI +device PMAF-AA fza DEFZA FDDI Controller +device PMAF-F fta DEFTA FDDI Controller device PMAG-AA mfb Monochrome Frame Buffer device PMAG-BA cfb Color Frame Buffer device PMAG-CA ga 2D Graphic Board @@ -43,6 +44,9 @@ device PMAG-FA gq 3D Graphic Board (HE) # the following entry may be incorrect device PMAG-DV xcfb Maxine Color Frame Buffer device PMAGB-BA sfb Smart Frame Buffer +device PMAGD sfbp Smart Frame Buffer Plus, unknown bpp +device PMAGD-AA sfbp Smart Frame Buffer Plus, 8bpp +device PMAGD-BA sfbp Smart Frame Buffer Plus, 32bpp device PMAZ-AA asc 53c94 SCSI device T3PKT tt DECWRL Turbochannel T3 device T1D4PKT ds DECWRL Turbochannel T1 diff --git a/sys/dev/tc/tcdevs.h b/sys/dev/tc/tcdevs.h index aed04ddf028..c0a1fe831a3 100644 --- a/sys/dev/tc/tcdevs.h +++ b/sys/dev/tc/tcdevs.h @@ -44,7 +44,10 @@ #define TC_DESCRIPTION_PMAD_AA "LANCE Ethernet" #define TC_DEVICE_PMAF_AA "fza" -#define TC_DESCRIPTION_PMAF_AA "FZA FDDI" +#define TC_DESCRIPTION_PMAF_AA "DEFZA FDDI Controller" + +#define TC_DEVICE_PMAF_F "fta" +#define TC_DESCRIPTION_PMAF_F "DEFTA FDDI Controller" #define TC_DEVICE_PMAG_AA "mfb" #define TC_DESCRIPTION_PMAG_AA "Monochrome Frame Buffer" @@ -67,6 +70,15 @@ #define TC_DEVICE_PMAGB_BA "sfb" #define TC_DESCRIPTION_PMAGB_BA "Smart Frame Buffer" +#define TC_DEVICE_PMAGD "sfbp" +#define TC_DESCRIPTION_PMAGD "Smart Frame Buffer Plus, unknown bpp" + +#define TC_DEVICE_PMAGD_AA "sfbp" +#define TC_DESCRIPTION_PMAGD_AA "Smart Frame Buffer Plus, 8bpp" + +#define TC_DEVICE_PMAGD_BA "sfbp" +#define TC_DESCRIPTION_PMAGD_BA "Smart Frame Buffer Plus, 32bpp" + #define TC_DEVICE_PMAZ_AA "asc" #define TC_DESCRIPTION_PMAZ_AA "53c94 SCSI" diff --git a/sys/dev/tc/tcdevs_data.h b/sys/dev/tc/tcdevs_data.h index ac4391f366d..1da4880df85 100644 --- a/sys/dev/tc/tcdevs_data.h +++ b/sys/dev/tc/tcdevs_data.h @@ -54,6 +54,11 @@ struct tc_knowndev tc_knowndevs[] = { TC_DESCRIPTION_PMAF_AA, }, { + "PMAF-F ", + TC_DEVICE_PMAF_F, + TC_DESCRIPTION_PMAF_F, + }, + { "PMAG-AA ", TC_DEVICE_PMAG_AA, TC_DESCRIPTION_PMAG_AA, @@ -89,6 +94,21 @@ struct tc_knowndev tc_knowndevs[] = { TC_DESCRIPTION_PMAGB_BA, }, { + "PMAGD ", + TC_DEVICE_PMAGD, + TC_DESCRIPTION_PMAGD, + }, + { + "PMAGD-AA", + TC_DEVICE_PMAGD_AA, + TC_DESCRIPTION_PMAGD_AA, + }, + { + "PMAGD-BA", + TC_DEVICE_PMAGD_BA, + TC_DESCRIPTION_PMAGD_BA, + }, + { "PMAZ-AA ", TC_DEVICE_PMAZ_AA, TC_DESCRIPTION_PMAZ_AA, diff --git a/sys/dev/tc/tcvar.h b/sys/dev/tc/tcvar.h index 970d5334635..566e0dcc01c 100644 --- a/sys/dev/tc/tcvar.h +++ b/sys/dev/tc/tcvar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: tcvar.h,v 1.3 1996/04/21 22:26:30 deraadt Exp $ */ -/* $NetBSD: tcvar.h,v 1.4 1996/03/17 21:37:47 jonathan Exp $ */ +/* $OpenBSD: tcvar.h,v 1.4 1996/05/26 00:27:56 deraadt Exp $ */ +/* $NetBSD: tcvar.h,v 1.5 1996/05/17 23:38:16 cgd Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. @@ -32,14 +32,51 @@ #define __DEV_TC_TCVAR_H__ /* - * TurboChannel autoconfiguration definitions. + * Definitions for TurboChannel autoconfiguration. */ +#ifdef __alpha__ /* XXX pmax does not yet have machine/bus.h */ +#include <machine/bus.h> +#endif #include <dev/tc/tcreg.h> + +/* + * Machine-dependent definitions. + */ +#if (alpha + pmax != 1) +ERROR: COMPILING FOR UNSUPPORTED MACHINE, OR MORE THAN ONE. +#endif +#if alpha +#include <alpha/tc/tc_machdep.h> +#endif +#if pmax #include <machine/tc_machdep.h> +#endif /* - * Interrupt levels. XXX should be common, elsewhere. + * In the long run, the following block will go completely away + * (i.e. both parts of the #if, including the #include, etc.). + * For now, the MI TC code still uses the old definitions provided + * by the pmax port, and not the new definitions provided by the + * alpha port. + */ +#ifdef __alpha_ +/* + * On the alpha, map the new definitions to the old. + */ +#include <machine/intr.h> + +#define tc_intrlevel_t int + +#define TC_IPL_NONE IPL_NONE +#define TC_IPL_BIO IPL_BIO +#define TC_IPL_NET IPL_NET +#define TC_IPL_TTY IPL_TTY +#define TC_IPL_CLOCK IPL_CLOCK + +#else +/* + * On the pmax, we still need the old definitions. */ typedef enum { TC_IPL_NONE, /* block only this interrupt */ @@ -48,12 +85,16 @@ typedef enum { TC_IPL_TTY, /* block terminal interrupts */ TC_IPL_CLOCK, /* block clock interrupts */ } tc_intrlevel_t; +#endif /* * Arguments used to attach TurboChannel busses. */ struct tcbus_attach_args { char *tba_busname; /* XXX should be common */ +#ifdef __alpha__ /* XXX */ + bus_chipset_tag_t tba_bc; /* XXX should be common */ +#endif /* Bus information */ u_int tba_speed; /* see TC_SPEED_* below */ @@ -73,6 +114,10 @@ struct tcbus_attach_args { * Arguments used to attach TurboChannel devices. */ struct tc_attach_args { +#ifdef __alpha__ /* XXX */ + bus_chipset_tag_t ta_bc; +#endif + char ta_modname[TC_ROM_LLEN+1]; u_int ta_slot; tc_offset_t ta_offset; |