diff options
| author | Yoshihiro Takahashi <nyan@FreeBSD.org> | 2017-01-28 02:22:15 +0000 |
|---|---|---|
| committer | Yoshihiro Takahashi <nyan@FreeBSD.org> | 2017-01-28 02:22:15 +0000 |
| commit | 2b375b4edd1b98884c3031d6ccd61acb10bd895d (patch) | |
| tree | f35e4f57ad890ac86d5cb5d3ef760344a41fc0e6 /sys/dev | |
| parent | 34bac11eba2841255bf6319ec78728f0f941c6ac (diff) | |
Notes
Diffstat (limited to 'sys/dev')
64 files changed, 9 insertions, 11657 deletions
diff --git a/sys/dev/aic/aic_cbus.c b/sys/dev/aic/aic_cbus.c deleted file mode 100644 index 84e7f7bf4e9de..0000000000000 --- a/sys/dev/aic/aic_cbus.c +++ /dev/null @@ -1,265 +0,0 @@ -/*- - * Copyright (c) 1999 Luoqi Chen. - * 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. - * - * 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. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/callout.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/module.h> -#include <sys/mutex.h> -#include <sys/bus.h> - -#include <machine/bus.h> -#include <machine/resource.h> -#include <sys/rman.h> - -#include <isa/isavar.h> -#include <dev/aic/aic6360reg.h> -#include <dev/aic/aicvar.h> - -struct aic_isa_softc { - struct aic_softc sc_aic; - struct resource *sc_port; - struct resource *sc_irq; - struct resource *sc_drq; - void *sc_ih; -}; - -static int aic_isa_alloc_resources(device_t); -static void aic_isa_release_resources(device_t); -static int aic_isa_probe(device_t); -static int aic_isa_attach(device_t); - -static u_int aic_isa_ports[] = { 0x1840 }; - -#define AIC_ISA_NUMPORTS nitems(aic_isa_ports) -#define AIC_ISA_PORTSIZE 0x20 - -#define AIC98_GENERIC 0x00 -#define AIC98_NEC100 0x01 -#define AIC_TYPE98(x) (((x) >> 16) & 0x01) - -static bus_addr_t aicport_generic[AIC_ISA_PORTSIZE] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, -}; -static bus_addr_t aicport_100[AIC_ISA_PORTSIZE] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, - 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, - 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, - 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, -}; - -static struct isa_pnp_id aic_ids[] = { - { 0xa180a3b8, "NEC PC9801-100" }, - { 0 } -}; - -static int -aic_isa_alloc_resources(device_t dev) -{ - struct aic_isa_softc *sc = device_get_softc(dev); - int rid; - bus_addr_t *bs_iat; - - if ((isa_get_logicalid(dev) == 0xa180a3b8) || - (AIC_TYPE98(device_get_flags(dev)) == AIC98_NEC100)) - bs_iat = aicport_100; - else - bs_iat = aicport_generic; - - sc->sc_port = sc->sc_irq = sc->sc_drq = NULL; - - rid = 0; - sc->sc_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, - bs_iat, AIC_ISA_PORTSIZE, RF_ACTIVE); - if (!sc->sc_port) { - device_printf(dev, "I/O port allocation failed\n"); - return (ENOMEM); - } - isa_load_resourcev(sc->sc_port, bs_iat, AIC_ISA_PORTSIZE); - mtx_init(&sc->sc_aic.lock, "aic", NULL, MTX_DEF); - - if (isa_get_irq(dev) != -1) { - rid = 0; - sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE); - if (!sc->sc_irq) { - device_printf(dev, "IRQ allocation failed\n"); - aic_isa_release_resources(dev); - return (ENOMEM); - } - } - - if (isa_get_drq(dev) != -1) { - rid = 0; - sc->sc_drq = bus_alloc_resource_any(dev, SYS_RES_DRQ, &rid, - RF_ACTIVE); - if (!sc->sc_drq) { - device_printf(dev, "DRQ allocation failed\n"); - aic_isa_release_resources(dev); - return (ENOMEM); - } - } - - sc->sc_aic.dev = dev; - sc->sc_aic.res = sc->sc_port; - return (0); -} - -static void -aic_isa_release_resources(device_t dev) -{ - struct aic_isa_softc *sc = device_get_softc(dev); - - if (sc->sc_port) - bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->sc_port); - if (sc->sc_irq) - bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); - if (sc->sc_drq) - bus_release_resource(dev, SYS_RES_DRQ, 0, sc->sc_drq); - sc->sc_port = sc->sc_irq = sc->sc_drq = NULL; - mtx_destroy(&sc->sc_aic.lock); -} - -static int -aic_isa_probe(device_t dev) -{ - struct aic_isa_softc *sc = device_get_softc(dev); - struct aic_softc *aic = &sc->sc_aic; - int numports, i; - u_int port, *ports; - u_int8_t porta; - - if (ISA_PNP_PROBE(device_get_parent(dev), dev, aic_ids) == ENXIO) - return (ENXIO); - - port = isa_get_port(dev); - if (port != -1) { - ports = &port; - numports = 1; - } else { - ports = aic_isa_ports; - numports = AIC_ISA_NUMPORTS; - } - - for (i = 0; i < numports; i++) { - if (bus_set_resource(dev, SYS_RES_IOPORT, 0, ports[i], 1)) - continue; - if (aic_isa_alloc_resources(dev)) - continue; - if (aic_probe(aic) == 0) - break; - aic_isa_release_resources(dev); - } - - if (i == numports) - return (ENXIO); - - porta = aic_inb(aic, PORTA); - aic_isa_release_resources(dev); - if (isa_get_irq(dev) == -1) - bus_set_resource(dev, SYS_RES_IRQ, 0, PORTA_IRQ(porta), 1); - if ((aic->flags & AIC_DMA_ENABLE) && isa_get_drq(dev) == -1) - bus_set_resource(dev, SYS_RES_DRQ, 0, PORTA_DRQ(porta), 1); - device_set_desc(dev, "Adaptec 6260/6360 SCSI controller"); - return (0); -} - -static int -aic_isa_attach(device_t dev) -{ - struct aic_isa_softc *sc = device_get_softc(dev); - struct aic_softc *aic = &sc->sc_aic; - int error; - - error = aic_isa_alloc_resources(dev); - if (error) { - device_printf(dev, "resource allocation failed\n"); - return (error); - } - - error = aic_attach(aic); - if (error) { - device_printf(dev, "attach failed\n"); - aic_isa_release_resources(dev); - return (error); - } - - error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM | INTR_ENTROPY | - INTR_MPSAFE, NULL, aic_intr, aic, &sc->sc_ih); - if (error) { - device_printf(dev, "failed to register interrupt handler\n"); - aic_isa_release_resources(dev); - return (error); - } - return (0); -} - -static int -aic_isa_detach(device_t dev) -{ - struct aic_isa_softc *sc = device_get_softc(dev); - struct aic_softc *aic = &sc->sc_aic; - int error; - - error = aic_detach(aic); - if (error) { - device_printf(dev, "detach failed\n"); - return (error); - } - - error = bus_teardown_intr(dev, sc->sc_irq, sc->sc_ih); - if (error) { - device_printf(dev, "failed to unregister interrupt handler\n"); - } - - aic_isa_release_resources(dev); - return (0); -} - -static device_method_t aic_isa_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, aic_isa_probe), - DEVMETHOD(device_attach, aic_isa_attach), - DEVMETHOD(device_detach, aic_isa_detach), - { 0, 0 } -}; - -static driver_t aic_isa_driver = { - "aic", - aic_isa_methods, sizeof(struct aic_isa_softc), -}; - -extern devclass_t aic_devclass; - -MODULE_DEPEND(aic, cam, 1,1,1); -DRIVER_MODULE(aic, isa, aic_isa_driver, aic_devclass, 0, 0); diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h index cf8ed784e7b82..8ef4191eca8c2 100644 --- a/sys/dev/ata/ata-all.h +++ b/sys/dev/ata/ata-all.h @@ -83,7 +83,6 @@ #define ATA_CTLOFFSET 0x206 /* control register offset */ #define ATA_PCCARD_CTLOFFSET 0x0e /* do for PCCARD devices */ -#define ATA_PC98_CTLOFFSET 0x10c /* do for PC98 devices */ #define ATA_A_IDS 0x02 /* disable interrupts */ #define ATA_A_RESET 0x04 /* RESET controller */ #ifdef ATA_LEGACY_SUPPORT @@ -178,17 +177,12 @@ /* misc defines */ #define ATA_PRIMARY 0x1f0 #define ATA_SECONDARY 0x170 -#define ATA_PC98_BANK 0x432 #define ATA_IOSIZE 0x08 -#define ATA_PC98_IOSIZE 0x10 #define ATA_CTLIOSIZE 0x01 #define ATA_BMIOSIZE 0x08 -#define ATA_PC98_BANKIOSIZE 0x01 #define ATA_IOADDR_RID 0 #define ATA_CTLADDR_RID 1 #define ATA_BMADDR_RID 0x20 -#define ATA_PC98_CTLADDR_RID 8 -#define ATA_PC98_BANKADDR_RID 9 #define ATA_IRQ_RID 0 #define ATA_DEV(unit) ((unit > 0) ? 0x10 : 0) #define ATA_CFA_MAGIC1 0x844A diff --git a/sys/dev/ata/ata-cbus.c b/sys/dev/ata/ata-cbus.c deleted file mode 100644 index 4165ea6a947ab..0000000000000 --- a/sys/dev/ata/ata-cbus.c +++ /dev/null @@ -1,349 +0,0 @@ -/*- - * Copyright (c) 2002 - 2008 Søren Schmidt <sos@FreeBSD.org> - * 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, - * without modification, immediately at the beginning of the file. - * 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. - * - * 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/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/ata.h> -#include <sys/bus.h> -#include <sys/malloc.h> -#include <sys/module.h> -#include <sys/conf.h> -#include <sys/sema.h> -#include <sys/taskqueue.h> -#include <vm/uma.h> -#include <machine/resource.h> -#include <machine/bus.h> -#include <sys/rman.h> -#include <isa/isavar.h> -#include <dev/ata/ata-all.h> -#include <ata_if.h> - -/* local vars */ -struct ata_cbus_controller { - struct resource *io; - struct resource *ctlio; - struct resource *bankio; - struct resource *irq; - void *ih; - int channels; - struct { - void (*function)(void *); - void *argument; - } interrupt[2]; -}; - -/* local prototypes */ -static void ata_cbus_intr(void *); - -static int -ata_cbus_probe(device_t dev) -{ - struct resource *io; - int rid; - rman_res_t tmp; - - /* dont probe PnP devices */ - if (isa_get_vendorid(dev)) - return (ENXIO); - - /* allocate the ioport range */ - rid = ATA_IOADDR_RID; - if (!(io = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &rid, - ATA_PC98_IOSIZE, RF_ACTIVE))) - return ENOMEM; - - /* calculate & set the altport range */ - rid = ATA_PC98_CTLADDR_RID; - if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &tmp, &tmp)) { - bus_set_resource(dev, SYS_RES_IOPORT, rid, - rman_get_start(io)+ATA_PC98_CTLOFFSET, ATA_CTLIOSIZE); - } - - /* calculate & set the bank range */ - rid = ATA_PC98_BANKADDR_RID; - if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &tmp, &tmp)) { - bus_set_resource(dev, SYS_RES_IOPORT, rid, - ATA_PC98_BANK, ATA_PC98_BANKIOSIZE); - } - - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); - return 0; -} - -static int -ata_cbus_attach(device_t dev) -{ - struct ata_cbus_controller *ctlr = device_get_softc(dev); - device_t child; - int rid, unit; - - /* allocate resources */ - rid = ATA_IOADDR_RID; - if (!(ctlr->io = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &rid, - ATA_PC98_IOSIZE, RF_ACTIVE))) - return ENOMEM; - - rid = ATA_PC98_CTLADDR_RID; - if (!(ctlr->ctlio = - bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, - rman_get_start(ctlr->io) + ATA_PC98_CTLOFFSET, ~0, - ATA_CTLIOSIZE, RF_ACTIVE))) { - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io); - return ENOMEM; - } - - rid = ATA_PC98_BANKADDR_RID; - if (!(ctlr->bankio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, - ATA_PC98_BANK, ~0, - ATA_PC98_BANKIOSIZE, RF_ACTIVE))) { - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io); - bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio); - return ENOMEM; - } - - rid = ATA_IRQ_RID; - if (!(ctlr->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_ACTIVE | RF_SHAREABLE))) { - device_printf(dev, "unable to alloc interrupt\n"); - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io); - bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio); - bus_release_resource(dev, SYS_RES_IOPORT, - ATA_PC98_BANKADDR_RID, ctlr->bankio); - return ENXIO; - } - - if ((bus_setup_intr(dev, ctlr->irq, ATA_INTR_FLAGS, - NULL, ata_cbus_intr, ctlr, &ctlr->ih))) { - device_printf(dev, "unable to setup interrupt\n"); - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io); - bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio); - bus_release_resource(dev, SYS_RES_IOPORT, - ATA_PC98_BANKADDR_RID, ctlr->bankio); - bus_release_resource(dev, SYS_RES_IOPORT, ATA_IRQ_RID, ctlr->irq); - return ENXIO; - } - - /* Work around the lack of channel serialization in ATA_CAM. */ - ctlr->channels = 1; - device_printf(dev, "second channel ignored\n"); - - for (unit = 0; unit < ctlr->channels; unit++) { - child = device_add_child(dev, "ata", unit); - if (child == NULL) - device_printf(dev, "failed to add ata child device\n"); - else - device_set_ivars(child, (void *)(intptr_t)unit); - } - - bus_generic_attach(dev); - return (0); -} - -static struct resource * -ata_cbus_alloc_resource(device_t dev, device_t child, int type, int *rid, - rman_res_t start, rman_res_t end, rman_res_t count, - u_int flags) -{ - struct ata_cbus_controller *ctlr = device_get_softc(dev); - - if (type == SYS_RES_IOPORT) { - switch (*rid) { - case ATA_IOADDR_RID: - return ctlr->io; - case ATA_CTLADDR_RID: - return ctlr->ctlio; - } - } - if (type == SYS_RES_IRQ) - return ctlr->irq; - return 0; -} - -static int -ata_cbus_setup_intr(device_t dev, device_t child, struct resource *irq, - int flags, driver_filter_t *filter, driver_intr_t *intr, - void *arg, void **cookiep) -{ - struct ata_cbus_controller *controller = device_get_softc(dev); - int unit = ((struct ata_channel *)device_get_softc(child))->unit; - - if (filter != NULL) { - printf("ata-cbus.c: we cannot use a filter here\n"); - return (EINVAL); - } - controller->interrupt[unit].function = intr; - controller->interrupt[unit].argument = arg; - *cookiep = controller; - - return 0; -} - -static int -ata_cbus_print_child(device_t dev, device_t child) -{ - struct ata_channel *ch = device_get_softc(child); - int retval = 0; - - retval += bus_print_child_header(dev, child); - retval += printf(" at bank %d", ch->unit); - retval += bus_print_child_footer(dev, child); - return retval; -} - -static void -ata_cbus_intr(void *data) -{ - struct ata_cbus_controller *ctlr = data; - struct ata_channel *ch; - int unit; - - for (unit = 0; unit < ctlr->channels; unit++) { - if (!(ch = ctlr->interrupt[unit].argument)) - continue; - ctlr->interrupt[unit].function(ch); - } -} - -static device_method_t ata_cbus_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ata_cbus_probe), - DEVMETHOD(device_attach, ata_cbus_attach), -// DEVMETHOD(device_detach, ata_cbus_detach), - - /* bus methods */ - DEVMETHOD(bus_alloc_resource, ata_cbus_alloc_resource), - DEVMETHOD(bus_setup_intr, ata_cbus_setup_intr), - DEVMETHOD(bus_print_child, ata_cbus_print_child), - - DEVMETHOD_END -}; - -static driver_t ata_cbus_driver = { - "atacbus", - ata_cbus_methods, - sizeof(struct ata_cbus_controller), -}; - -static devclass_t ata_cbus_devclass; - -DRIVER_MODULE(atacbus, isa, ata_cbus_driver, ata_cbus_devclass, NULL, NULL); - -static int -ata_cbuschannel_probe(device_t dev) -{ - char buffer[32]; - - sprintf(buffer, "ATA channel %d", (int)(intptr_t)device_get_ivars(dev)); - device_set_desc_copy(dev, buffer); - - return ata_probe(dev); -} - -static int -ata_cbuschannel_attach(device_t dev) -{ - struct ata_cbus_controller *ctlr = device_get_softc(device_get_parent(dev)); - struct ata_channel *ch = device_get_softc(dev); - int i; - - if (ch->attached) - return (0); - ch->attached = 1; - - ch->unit = (intptr_t)device_get_ivars(dev); - /* setup the resource vectors */ - for (i = ATA_DATA; i <= ATA_COMMAND; i ++) { - ch->r_io[i].res = ctlr->io; - ch->r_io[i].offset = i << 1; - } - ch->r_io[ATA_CONTROL].res = ctlr->ctlio; - ch->r_io[ATA_CONTROL].offset = 0; - ch->r_io[ATA_IDX_ADDR].res = ctlr->io; - ata_default_registers(dev); - - /* initialize softc for this channel */ - ch->flags |= ATA_USE_16BIT; - ata_generic_hw(dev); - - return ata_attach(dev); -} - -static int -ata_cbuschannel_detach(device_t dev) -{ - struct ata_channel *ch = device_get_softc(dev); - - if (!ch->attached) - return (0); - ch->attached = 0; - - return ata_detach(dev); -} - -static int -ata_cbuschannel_suspend(device_t dev) -{ - struct ata_channel *ch = device_get_softc(dev); - - if (!ch->attached) - return (0); - - return ata_suspend(dev); -} - -static int -ata_cbuschannel_resume(device_t dev) -{ - struct ata_channel *ch = device_get_softc(dev); - - if (!ch->attached) - return (0); - - return ata_resume(dev); -} - -static device_method_t ata_cbuschannel_methods[] = { - /* device interface */ - DEVMETHOD(device_probe, ata_cbuschannel_probe), - DEVMETHOD(device_attach, ata_cbuschannel_attach), - DEVMETHOD(device_detach, ata_cbuschannel_detach), - DEVMETHOD(device_suspend, ata_cbuschannel_suspend), - DEVMETHOD(device_resume, ata_cbuschannel_resume), - DEVMETHOD_END -}; - -static driver_t ata_cbuschannel_driver = { - "ata", - ata_cbuschannel_methods, - sizeof(struct ata_channel), -}; - -DRIVER_MODULE(ata, atacbus, ata_cbuschannel_driver, ata_devclass, NULL, NULL); -MODULE_DEPEND(ata, ata, 1, 1, 1); diff --git a/sys/dev/ct/bshw_machdep.c b/sys/dev/ct/bshw_machdep.c deleted file mode 100644 index 046aa7d9430cf..0000000000000 --- a/sys/dev/ct/bshw_machdep.c +++ /dev/null @@ -1,743 +0,0 @@ -/* $NecBSD: bshw_machdep.c,v 1.8.12.6 2001/06/29 06:28:05 honda Exp $ */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); -/* $NetBSD$ */ - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * NetBSD/pc98 porting staff. All rights reserved. - * - * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * Naofumi HONDA. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "opt_ddb.h" - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/bio.h> -#include <sys/buf.h> -#include <sys/queue.h> -#include <sys/malloc.h> -#include <sys/errno.h> -#include <sys/rman.h> - -#include <vm/vm.h> - -#include <machine/bus.h> -#include <machine/md_var.h> - -#include <compat/netbsd/dvcfg.h> - -#include <cam/scsi/scsi_low.h> - -#include <dev/ic/wd33c93reg.h> -#include <dev/ct/ctvar.h> -#include <dev/ct/ct_machdep.h> -#include <dev/ct/bshwvar.h> - -#include <vm/pmap.h> - -#define BSHW_IO_CONTROL_FLAGS 0 - -u_int bshw_io_control = BSHW_IO_CONTROL_FLAGS; -int bshw_data_read_bytes = 4096; -int bshw_data_write_bytes = 4096; - -/********************************************************* - * OS dep part - *********************************************************/ -typedef unsigned long vaddr_t; - -/********************************************************* - * GENERIC MACHDEP FUNCTIONS - *********************************************************/ -void -bshw_synch_setup(struct ct_softc *ct, struct targ_info *ti) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct ct_targ_info *cti = (void *) ti; - struct bshw_softc *bs = ct->ct_hw; - struct bshw *hw = bs->sc_hw; - - if (hw->hw_sregaddr == 0) - return; - - ct_cr_write_1(chp, hw->hw_sregaddr + ti->ti_id, cti->cti_syncreg); - if (hw->hw_flags & BSHW_DOUBLE_DMACHAN) - { - ct_cr_write_1(chp, hw->hw_sregaddr + ti->ti_id + 8, - cti->cti_syncreg); - } -} - -void -bshw_bus_reset(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct bshw_softc *bs = ct->ct_hw; - struct bshw *hw = bs->sc_hw; - bus_addr_t offs; - u_int8_t regv; - int i; - - /* open hardware busmaster mode */ - if (hw->hw_dma_init != NULL && ((*hw->hw_dma_init)(ct)) != 0) - { - device_printf(slp->sl_dev, - "change mode using external DMA (%x)\n", - (u_int)ct_cr_read_1(chp, 0x37)); - } - - /* clear hardware synch registers */ - offs = hw->hw_sregaddr; - if (offs != 0) - { - for (i = 0; i < 8; i ++, offs ++) - { - ct_cr_write_1(chp, offs, 0); - if ((hw->hw_flags & BSHW_DOUBLE_DMACHAN) != 0) - ct_cr_write_1(chp, offs + 8, 0); - } - } - - /* disable interrupt & assert reset */ - regv = ct_cr_read_1(chp, wd3s_mbank); - regv |= MBR_RST; - regv &= ~MBR_IEN; - ct_cr_write_1(chp, wd3s_mbank, regv); - - DELAY(500000); - - /* reset signal off */ - regv &= ~MBR_RST; - ct_cr_write_1(chp, wd3s_mbank, regv); - - /* interrupt enable */ - regv |= MBR_IEN; - ct_cr_write_1(chp, wd3s_mbank, regv); -} - -/* probe */ -int -bshw_read_settings(struct ct_bus_access_handle *chp, struct bshw_softc *bs) -{ - static int irq_tbl[] = { 3, 5, 6, 9, 12, 13 }; - - bs->sc_hostid = (ct_cr_read_1(chp, wd3s_auxc) & AUXCR_HIDM); - bs->sc_irq = irq_tbl[(ct_cr_read_1(chp, wd3s_auxc) >> 3) & 7]; - bs->sc_drq = ct_cmdp_read_1(chp) & 3; - return 0; -} - -/********************************************************* - * DMA PIO TRANSFER (SMIT) - *********************************************************/ -#define LC_SMIT_TIMEOUT 2 /* 2 sec: timeout for a fifo status ready */ -#define LC_SMIT_OFFSET 0x1000 -#define LC_FSZ DEV_BSIZE -#define LC_SFSZ 0x0c -#define LC_REST (LC_FSZ - LC_SFSZ) - -#define BSHW_LC_FSET 0x36 -#define BSHW_LC_FCTRL 0x44 -#define FCTRL_EN 0x01 -#define FCTRL_WRITE 0x02 - -#define SF_ABORT 0x08 -#define SF_RDY 0x10 - -static __inline void bshw_lc_smit_start(struct ct_softc *, int, u_int); -static __inline void bshw_lc_smit_stop(struct ct_softc *); -static int bshw_lc_smit_fstat(struct ct_softc *, int, int); - -static __inline void -bshw_lc_smit_stop(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - - ct_cr_write_1(chp, BSHW_LC_FCTRL, 0); - ct_cmdp_write_1(chp, CMDP_DMER); -} - -static __inline void -bshw_lc_smit_start(struct ct_softc *ct, int count, u_int direction) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - u_int8_t pval, val; - - val = ct_cr_read_1(chp, BSHW_LC_FSET); - cthw_set_count(chp, count); - - pval = FCTRL_EN; - if (direction == SCSI_LOW_WRITE) - pval |= (val & 0xe0) | FCTRL_WRITE; - ct_cr_write_1(chp, BSHW_LC_FCTRL, pval); - ct_cr_write_1(chp, wd3s_cmd, WD3S_TFR_INFO); -} - -static int -bshw_lc_smit_fstat(struct ct_softc *ct, int wc, int read) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - u_int8_t stat; - - while (wc -- > 0) - { - chp->ch_bus_weight(chp); - stat = ct_cmdp_read_1(chp); - if (read == SCSI_LOW_READ) - { - if ((stat & SF_RDY) != 0) - return 0; - if ((stat & SF_ABORT) != 0) - return EIO; - } - else - { - if ((stat & SF_ABORT) != 0) - return EIO; - if ((stat & SF_RDY) != 0) - return 0; - } - } - - device_printf(ct->sc_sclow.sl_dev, "SMIT fifo status timeout\n"); - return EIO; -} - -void -bshw_smit_xfer_stop(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct bshw_softc *bs = ct->ct_hw; - struct targ_info *ti; - struct sc_p *sp = &slp->sl_scp; - u_int count; - - bshw_lc_smit_stop(ct); - - ti = slp->sl_Tnexus; - if (ti == NULL) - return; - - if (ti->ti_phase == PH_DATA) - { - count = cthw_get_count(&ct->sc_ch); - if (count < bs->sc_sdatalen) - { - if (sp->scp_direction == SCSI_LOW_READ && - count != bs->sc_edatalen) - goto bad; - - count = bs->sc_sdatalen - count; - if (count > (u_int) sp->scp_datalen) - goto bad; - - sp->scp_data += count; - sp->scp_datalen -= count; - } - else if (count > bs->sc_sdatalen) - { -bad: - device_printf(slp->sl_dev, - "smit_xfer_end: cnt error\n"); - slp->sl_error |= PDMAERR; - } - scsi_low_data_finish(slp); - } - else - { - device_printf(slp->sl_dev, "smit_xfer_end: phase miss\n"); - slp->sl_error |= PDMAERR; - } -} - -int -bshw_smit_xfer_start(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct bshw_softc *bs = ct->ct_hw; - struct sc_p *sp = &slp->sl_scp; - struct targ_info *ti = slp->sl_Tnexus; - struct ct_targ_info *cti = (void *) ti; - u_int datalen, count, io_control; - int wc; - u_int8_t *data; - - io_control = bs->sc_io_control | bshw_io_control; - if ((io_control & BSHW_SMIT_BLOCK) != 0) - return EINVAL; - - if ((slp->sl_scp.scp_datalen % DEV_BSIZE) != 0) - return EINVAL; - - datalen = sp->scp_datalen; - if (slp->sl_scp.scp_direction == SCSI_LOW_READ) - { - if ((io_control & BSHW_READ_INTERRUPT_DRIVEN) != 0 && - datalen > bshw_data_read_bytes) - datalen = bshw_data_read_bytes; - } - else - { - if ((io_control & BSHW_WRITE_INTERRUPT_DRIVEN) != 0 && - datalen > bshw_data_write_bytes) - datalen = bshw_data_write_bytes; - } - - bs->sc_sdatalen = datalen; - data = sp->scp_data; - wc = LC_SMIT_TIMEOUT * 1024 * 1024; - - ct_cr_write_1(chp, wd3s_ctrl, ct->sc_creg | CR_DMA); - bshw_lc_smit_start(ct, datalen, sp->scp_direction); - - if (sp->scp_direction == SCSI_LOW_READ) - { - do - { - if (bshw_lc_smit_fstat(ct, wc, SCSI_LOW_READ)) - break; - - count = (datalen > LC_FSZ ? LC_FSZ : datalen); - bus_read_region_4(chp->ch_mem, - LC_SMIT_OFFSET, (u_int32_t *) data, count >> 2); - data += count; - datalen -= count; - } - while (datalen > 0); - - bs->sc_edatalen = datalen; - } - else - { - do - { - if (bshw_lc_smit_fstat(ct, wc, SCSI_LOW_WRITE)) - break; - if (cti->cti_syncreg == 0) - { - /* XXX: - * If async transfer, reconfirm a scsi phase - * again. Unless C bus might hang up. - */ - if (bshw_lc_smit_fstat(ct, wc, SCSI_LOW_WRITE)) - break; - } - - count = (datalen > LC_SFSZ ? LC_SFSZ : datalen); - bus_write_region_4(chp->ch_mem, - LC_SMIT_OFFSET, (u_int32_t *) data, count >> 2); - data += count; - datalen -= count; - - if (bshw_lc_smit_fstat(ct, wc, SCSI_LOW_WRITE)) - break; - - count = (datalen > LC_REST ? LC_REST : datalen); - bus_write_region_4(chp->ch_mem, - LC_SMIT_OFFSET + LC_SFSZ, - (u_int32_t *) data, count >> 2); - data += count; - datalen -= count; - } - while (datalen > 0); - } - return 0; -} - -/********************************************************* - * DMA TRANSFER (BS) - *********************************************************/ -static __inline void bshw_dma_write_1 \ - (struct ct_bus_access_handle *, bus_addr_t, u_int8_t); -static void bshw_dmastart(struct ct_softc *); -static void bshw_dmadone(struct ct_softc *); - -int -bshw_dma_xfer_start(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct sc_p *sp = &slp->sl_scp; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct bshw_softc *bs = ct->ct_hw; - vaddr_t va, endva, phys, nphys; - u_int io_control; - - io_control = bs->sc_io_control | bshw_io_control; - if ((io_control & BSHW_DMA_BLOCK) != 0 && sp->scp_datalen < 256) - return EINVAL; - - ct_cr_write_1(chp, wd3s_ctrl, ct->sc_creg | CR_DMA); - phys = vtophys((vaddr_t) sp->scp_data); - if (phys >= bs->sc_minphys) - { - /* setup segaddr */ - bs->sc_segaddr = bs->sc_bounce_phys; - /* setup seglen */ - bs->sc_seglen = sp->scp_datalen; - if (bs->sc_seglen > bs->sc_bounce_size) - bs->sc_seglen = bs->sc_bounce_size; - /* setup bufp */ - bs->sc_bufp = bs->sc_bounce_addr; - if (sp->scp_direction == SCSI_LOW_WRITE) - bcopy(sp->scp_data, bs->sc_bufp, bs->sc_seglen); - } - else - { - /* setup segaddr */ - bs->sc_segaddr = (u_int8_t *) phys; - /* setup seglen */ - endva = (vaddr_t) round_page((vaddr_t) sp->scp_data + sp->scp_datalen); - for (va = (vaddr_t) sp->scp_data; ; phys = nphys) - { - if ((va += PAGE_SIZE) >= endva) - { - bs->sc_seglen = sp->scp_datalen; - break; - } - - nphys = vtophys(va); - if (phys + PAGE_SIZE != nphys || nphys >= bs->sc_minphys) - { - bs->sc_seglen = - (u_int8_t *) trunc_page(va) - sp->scp_data; - break; - } - } - /* setup bufp */ - bs->sc_bufp = NULL; - } - - bshw_dmastart(ct); - cthw_set_count(chp, bs->sc_seglen); - ct_cr_write_1(chp, wd3s_cmd, WD3S_TFR_INFO); - return 0; -} - -void -bshw_dma_xfer_stop(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct sc_p *sp = &slp->sl_scp; - struct bshw_softc *bs = ct->ct_hw; - struct targ_info *ti; - u_int count, transbytes; - - bshw_dmadone(ct); - - ti = slp->sl_Tnexus; - if (ti == NULL) - return; - - if (ti->ti_phase == PH_DATA) - { - count = cthw_get_count(&ct->sc_ch); - if (count < (u_int) bs->sc_seglen) - { - transbytes = bs->sc_seglen - count; - if (bs->sc_bufp != NULL && - sp->scp_direction == SCSI_LOW_READ) - bcopy(bs->sc_bufp, sp->scp_data, transbytes); - - sp->scp_data += transbytes; - sp->scp_datalen -= transbytes; - } - else if (count > (u_int) bs->sc_seglen) - { - device_printf(slp->sl_dev, - "port data %x != seglen %x\n", - count, bs->sc_seglen); - slp->sl_error |= PDMAERR; - } - - scsi_low_data_finish(slp); - } - else - { - device_printf(slp->sl_dev, "extra DMA interrupt\n"); - slp->sl_error |= PDMAERR; - } - - bs->sc_bufp = NULL; -} - -/* common dma settings */ -#undef DMA1_SMSK -#define DMA1_SMSK (0x15) -#undef DMA1_MODE -#define DMA1_MODE (0x17) -#undef DMA1_FFC -#define DMA1_FFC (0x19) -#undef DMA1_CHN -#define DMA1_CHN(c) (0x01 + ((c) << 2)) - -#define DMA37SM_SET 0x04 -#define DMA37MD_WRITE 0x04 -#define DMA37MD_READ 0x08 -#define DMA37MD_SINGLE 0x40 - -static bus_addr_t dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 }; - -static __inline void -bshw_dma_write_1(struct ct_bus_access_handle *chp, bus_addr_t port, - u_int8_t val) -{ - - CT_BUS_WEIGHT(chp); - outb(port, val); -} - -static void -bshw_dmastart(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct bshw_softc *bs = ct->ct_hw; - struct ct_bus_access_handle *chp = &ct->sc_ch; - int chan = bs->sc_drq; - bus_addr_t waport; - u_int8_t regv, *phys = bs->sc_segaddr; - u_int nbytes = bs->sc_seglen; - - /* flush cpu cache */ - (*bs->sc_dmasync_before) (ct); - - /* - * Program one of DMA channels 0..3. These are - * byte mode channels. - */ - /* set dma channel mode, and reset address ff */ - - if (slp->sl_scp.scp_direction == SCSI_LOW_READ) - regv = DMA37MD_WRITE | DMA37MD_SINGLE | chan; - else - regv = DMA37MD_READ | DMA37MD_SINGLE | chan; - - bshw_dma_write_1(chp, DMA1_MODE, regv); - bshw_dma_write_1(chp, DMA1_FFC, 0); - - /* send start address */ - waport = DMA1_CHN(chan); - bshw_dma_write_1(chp, waport, (u_int) phys); - bshw_dma_write_1(chp, waport, ((u_int) phys) >> 8); - bshw_dma_write_1(chp, dmapageport[chan], ((u_int) phys) >> 16); - - /* send count */ - bshw_dma_write_1(chp, waport + 2, --nbytes); - bshw_dma_write_1(chp, waport + 2, nbytes >> 8); - - /* vendor unique hook */ - if (bs->sc_hw->hw_dma_start) - (*bs->sc_hw->hw_dma_start)(ct); - - bshw_dma_write_1(chp, DMA1_SMSK, chan); - ct_cmdp_write_1(chp, CMDP_DMES); -} - -static void -bshw_dmadone(struct ct_softc *ct) -{ - struct bshw_softc *bs = ct->ct_hw; - struct ct_bus_access_handle *chp = &ct->sc_ch; - - bshw_dma_write_1(chp, DMA1_SMSK, (bs->sc_drq | DMA37SM_SET)); - ct_cmdp_write_1(chp, CMDP_DMER); - - /* vendor unique hook */ - if (bs->sc_hw->hw_dma_stop) - (*bs->sc_hw->hw_dma_stop) (ct); - - /* flush cpu cache */ - (*bs->sc_dmasync_after) (ct); -} - -/********************************************** - * VENDOR UNIQUE DMA FUNCS - **********************************************/ -static int bshw_dma_init_sc98(struct ct_softc *); -static void bshw_dma_start_sc98(struct ct_softc *); -static void bshw_dma_stop_sc98(struct ct_softc *); -static int bshw_dma_init_texa(struct ct_softc *); -static void bshw_dma_start_elecom(struct ct_softc *); -static void bshw_dma_stop_elecom(struct ct_softc *); - -static int -bshw_dma_init_texa(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - u_int8_t regval; - - if ((regval = ct_cr_read_1(chp, 0x37)) & 0x08) - return 0; - - ct_cr_write_1(chp, 0x37, regval | 0x08); - regval = ct_cr_read_1(chp, 0x3f); - ct_cr_write_1(chp, 0x3f, regval | 0x08); - return 1; -} - -static int -bshw_dma_init_sc98(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - - if (ct_cr_read_1(chp, 0x37) & 0x08) - return 0; - - /* If your card is SC98 with bios ver 1.01 or 1.02 under no PCI */ - ct_cr_write_1(chp, 0x37, 0x1a); - ct_cr_write_1(chp, 0x3f, 0x1a); -#if 0 - /* only valid for IO */ - ct_cr_write_1(chp, 0x40, 0xf4); - ct_cr_write_1(chp, 0x41, 0x9); - ct_cr_write_1(chp, 0x43, 0xff); - ct_cr_write_1(chp, 0x46, 0x4e); - - ct_cr_write_1(chp, 0x48, 0xf4); - ct_cr_write_1(chp, 0x49, 0x9); - ct_cr_write_1(chp, 0x4b, 0xff); - ct_cr_write_1(chp, 0x4e, 0x4e); -#endif - return 1; -} - -static void -bshw_dma_start_sc98(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - - ct_cr_write_1(chp, 0x73, 0x32); - ct_cr_write_1(chp, 0x74, 0x23); -} - -static void -bshw_dma_stop_sc98(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - - ct_cr_write_1(chp, 0x73, 0x43); - ct_cr_write_1(chp, 0x74, 0x34); -} - -static void -bshw_dma_start_elecom(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - u_int8_t tmp = ct_cr_read_1(chp, 0x4c); - - ct_cr_write_1(chp, 0x32, tmp & 0xdf); -} - -static void -bshw_dma_stop_elecom(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - u_int8_t tmp = ct_cr_read_1(chp, 0x4c); - - ct_cr_write_1(chp, 0x32, tmp | 0x20); -} - -static struct bshw bshw_generic = { - BSHW_SYNC_RELOAD, - - 0, - - NULL, - NULL, - NULL, -}; - -static struct bshw bshw_sc98 = { - BSHW_DOUBLE_DMACHAN, - - 0x60, - - bshw_dma_init_sc98, - bshw_dma_start_sc98, - bshw_dma_stop_sc98, -}; - -static struct bshw bshw_texa = { - BSHW_DOUBLE_DMACHAN, - - 0x60, - - bshw_dma_init_texa, - NULL, - NULL, -}; - -static struct bshw bshw_elecom = { - 0, - - 0x38, - - NULL, - bshw_dma_start_elecom, - bshw_dma_stop_elecom, -}; - -static struct bshw bshw_lc_smit = { - BSHW_SMFIFO | BSHW_DOUBLE_DMACHAN, - - 0x60, - - NULL, - NULL, - NULL, -}; - -static struct bshw bshw_lha20X = { - BSHW_DOUBLE_DMACHAN, - - 0x60, - - NULL, - NULL, - NULL, -}; - -/* hw tabs */ -static dvcfg_hw_t bshw_hwsel_array[] = { -/* 0x00 */ &bshw_generic, -/* 0x01 */ &bshw_sc98, -/* 0x02 */ &bshw_texa, -/* 0x03 */ &bshw_elecom, -/* 0x04 */ &bshw_lc_smit, -/* 0x05 */ &bshw_lha20X, -}; - -struct dvcfg_hwsel bshw_hwsel = { - DVCFG_HWSEL_SZ(bshw_hwsel_array), - bshw_hwsel_array -}; diff --git a/sys/dev/ct/bshwvar.h b/sys/dev/ct/bshwvar.h deleted file mode 100644 index ba42a72069795..0000000000000 --- a/sys/dev/ct/bshwvar.h +++ /dev/null @@ -1,96 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: bshwvar.h,v 1.3.14.3 2001/06/21 04:07:37 honda Exp $ */ -/* $NetBSD$ */ - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1994, 1995, 1996, 1997, 1998 - * NetBSD/pc98 porting staff. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _BSHWVAR_H_ -#define _BSHWVAR_H_ - -/* - * bshwvar.h - * NEC 55 compatible board specific definitions - */ - -#define BSHW_DEFAULT_CHIPCLK 20 /* 20MHz */ -#define BSHW_DEFAULT_HOSTID 7 - -struct bshw { -#define BSHW_SYNC_RELOAD 0x01 -#define BSHW_SMFIFO 0x02 -#define BSHW_DOUBLE_DMACHAN 0x04 - u_int hw_flags; - u_int hw_sregaddr; - - int ((*hw_dma_init)(struct ct_softc *)); - void ((*hw_dma_start)(struct ct_softc *)); - void ((*hw_dma_stop)(struct ct_softc *)); -}; - -struct bshw_softc { - int sc_hostid; - int sc_irq; /* irq */ - int sc_drq; /* drq */ - - /* dma transfer */ - u_int8_t *sc_segaddr; - u_int8_t *sc_bufp; - int sc_seglen; - u_int sc_sdatalen; /* SMIT */ - u_int sc_edatalen; /* SMIT */ - - /* private bounce */ - u_int8_t *sc_bounce_phys; - u_int8_t *sc_bounce_addr; - u_int sc_bounce_size; - bus_addr_t sc_minphys; - - /* io control */ -#define BSHW_READ_INTERRUPT_DRIVEN 0x0001 -#define BSHW_WRITE_INTERRUPT_DRIVEN 0x0002 -#define BSHW_DMA_BLOCK 0x0010 -#define BSHW_SMIT_BLOCK 0x0020 - u_int sc_io_control; - - /* hardware */ - struct bshw *sc_hw; - void ((*sc_dmasync_before))(struct ct_softc *); - void ((*sc_dmasync_after))(struct ct_softc *); -}; - -void bshw_synch_setup(struct ct_softc *, struct targ_info *); -void bshw_bus_reset(struct ct_softc *); -int bshw_read_settings(struct ct_bus_access_handle *, struct bshw_softc *); -int bshw_smit_xfer_start(struct ct_softc *); -void bshw_smit_xfer_stop(struct ct_softc *); -int bshw_dma_xfer_start(struct ct_softc *); -void bshw_dma_xfer_stop(struct ct_softc *); - -extern struct dvcfg_hwsel bshw_hwsel; -#endif /* !_BSHWVAR_H_ */ diff --git a/sys/dev/ct/ct.c b/sys/dev/ct/ct.c deleted file mode 100644 index 6a96c9c486e61..0000000000000 --- a/sys/dev/ct/ct.c +++ /dev/null @@ -1,1242 +0,0 @@ -/* $NecBSD: ct.c,v 1.13.12.5 2001/06/26 07:31:53 honda Exp $ */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); -/* $NetBSD$ */ - -#define CT_DEBUG -#define CT_IO_CONTROL_FLAGS (CT_USE_CCSEQ | CT_FAST_INTR) - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * NetBSD/pc98 porting staff. All rights reserved. - * - * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * Naofumi HONDA. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/bio.h> -#include <sys/buf.h> -#include <sys/queue.h> -#include <sys/malloc.h> -#include <sys/errno.h> -#include <sys/rman.h> - -#include <machine/bus.h> - -#include <cam/scsi/scsi_low.h> - -#include <dev/ic/wd33c93reg.h> -#include <dev/ct/ctvar.h> -#include <dev/ct/ct_machdep.h> - -#define CT_NTARGETS 8 -#define CT_NLUNS 8 -#define CT_RESET_DEFAULT 2000 -#define CT_DELAY_MAX (2 * 1000 * 1000) -#define CT_DELAY_INTERVAL (1) - -/*************************************************** - * DEBUG - ***************************************************/ -#ifdef CT_DEBUG -int ct_debug; -#endif /* CT_DEBUG */ - -/*************************************************** - * IO control - ***************************************************/ -#define CT_USE_CCSEQ 0x0100 -#define CT_FAST_INTR 0x0200 - -u_int ct_io_control = CT_IO_CONTROL_FLAGS; - -/*************************************************** - * default data - ***************************************************/ -u_int8_t cthw_cmdlevel[256] = { -/* 0 1 2 3 4 5 6 7 8 9 A B C E D F */ -/*0*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 , -/*1*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*2*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,0 , -/*3*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*4*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*5*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*6*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*7*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*8*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*9*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*A*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*B*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*C*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*D*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*E*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -/*F*/0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , -}; - -#if 0 -/* default synch data table */ -/* A 10 6.6 5.0 4.0 3.3 2.8 2.5 2.0 M/s */ -/* X 100 150 200 250 300 350 400 500 ns */ -static struct ct_synch_data ct_synch_data_FSCSI[] = { - {25, 0xa0}, {37, 0xb0}, {50, 0x20}, {62, 0xd0}, {75, 0x30}, - {87, 0xf0}, {100, 0x40}, {125, 0x50}, {0, 0} -}; - -static struct ct_synch_data ct_synch_data_SCSI[] = { - {50, 0x20}, {75, 0x30}, {100, 0x40}, {125, 0x50}, {0, 0} -}; -#endif -/*************************************************** - * DEVICE STRUCTURE - ***************************************************/ -extern struct cfdriver ct_cd; - -/***************************************************************** - * Interface functions - *****************************************************************/ -static int ct_xfer(struct ct_softc *, u_int8_t *, int, int, u_int *); -static void ct_io_xfer(struct ct_softc *); -static int ct_reselected(struct ct_softc *, u_int8_t); -static void ct_phase_error(struct ct_softc *, u_int8_t); -static int ct_start_selection(struct ct_softc *, struct slccb *); -static int ct_msg(struct ct_softc *, struct targ_info *, u_int); -static int ct_world_start(struct ct_softc *, int); -static __inline void cthw_phase_bypass(struct ct_softc *, u_int8_t); -static int cthw_chip_reset(struct ct_bus_access_handle *, int *, int, int); -static void cthw_bus_reset(struct ct_softc *); -static int ct_ccb_nexus_establish(struct ct_softc *); -static int ct_lun_nexus_establish(struct ct_softc *); -static int ct_target_nexus_establish(struct ct_softc *, int, int); -static void cthw_attention(struct ct_softc *); -static int ct_targ_init(struct ct_softc *, struct targ_info *, int); -static int ct_unbusy(struct ct_softc *); -static void ct_attention(struct ct_softc *); -static struct ct_synch_data *ct_make_synch_table(struct ct_softc *); -static int ct_catch_intr(struct ct_softc *); -static int ct_poll(void *); - -struct scsi_low_funcs ct_funcs = { - SC_LOW_INIT_T ct_world_start, - SC_LOW_BUSRST_T cthw_bus_reset, - SC_LOW_TARG_INIT_T ct_targ_init, - SC_LOW_LUN_INIT_T NULL, - - SC_LOW_SELECT_T ct_start_selection, - SC_LOW_NEXUS_T ct_lun_nexus_establish, - SC_LOW_NEXUS_T ct_ccb_nexus_establish, - - SC_LOW_ATTEN_T cthw_attention, - SC_LOW_MSG_T ct_msg, - - SC_LOW_TIMEOUT_T NULL, - SC_LOW_POLL_T ct_poll, - - NULL, /* SC_LOW_POWER_T cthw_power, */ -}; - -/************************************************** - * HW functions - **************************************************/ -static __inline void -cthw_phase_bypass(struct ct_softc *ct, u_int8_t ph) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - - ct_cr_write_1(chp, wd3s_cph, ph); - ct_cr_write_1(chp, wd3s_cmd, WD3S_SELECT_ATN_TFR); -} - -static void -cthw_bus_reset(struct ct_softc *ct) -{ - - /* - * wd33c93 does not have bus reset function. - */ - if (ct->ct_bus_reset != NULL) - ((*ct->ct_bus_reset) (ct)); -} - -static int -cthw_chip_reset(struct ct_bus_access_handle *chp, int *chiprevp, int chipclk, - int hostid) -{ -#define CT_SELTIMEOUT_20MHz_REGV (0x80) - u_int8_t aux, regv; - u_int seltout; - int wc; - - /* issue abort cmd */ - ct_cr_write_1(chp, wd3s_cmd, WD3S_ABORT); - DELAY(1000); /* 1ms wait */ - (void) ct_stat_read_1(chp); - (void) ct_cr_read_1(chp, wd3s_stat); - - /* setup chip registers */ - regv = 0; - seltout = CT_SELTIMEOUT_20MHz_REGV; - switch (chipclk) - { - case 8: - case 10: - seltout = (seltout * chipclk) / 20; - regv = IDR_FS_8_10; - break; - - case 12: - case 15: - seltout = (seltout * chipclk) / 20; - regv = IDR_FS_12_15; - break; - - case 16: - case 20: - seltout = (seltout * chipclk) / 20; - regv = IDR_FS_16_20; - break; - - default: - panic("ct: illegal chip clk rate"); - break; - } - - regv |= IDR_EHP | hostid | IDR_RAF | IDR_EAF; - ct_cr_write_1(chp, wd3s_oid, regv); - - ct_cr_write_1(chp, wd3s_cmd, WD3S_RESET); - for (wc = CT_RESET_DEFAULT; wc > 0; wc --) - { - aux = ct_stat_read_1(chp); - if (aux != 0xff && (aux & STR_INT)) - { - regv = ct_cr_read_1(chp, wd3s_stat); - if (regv == BSR_RESET || regv == BSR_AFM_RESET) - break; - - ct_cr_write_1(chp, wd3s_cmd, WD3S_RESET); - } - DELAY(1); - } - if (wc == 0) - return ENXIO; - - ct_cr_write_1(chp, wd3s_tout, seltout); - ct_cr_write_1(chp, wd3s_sid, SIDR_RESEL); - ct_cr_write_1(chp, wd3s_ctrl, CR_DEFAULT); - ct_cr_write_1(chp, wd3s_synch, 0); - if (chiprevp != NULL) - { - *chiprevp = CT_WD33C93; - if (regv == BSR_RESET) - goto out; - - *chiprevp = CT_WD33C93_A; - ct_cr_write_1(chp, wd3s_qtag, 0xaa); - if (ct_cr_read_1(chp, wd3s_qtag) != 0xaa) - { - ct_cr_write_1(chp, wd3s_qtag, 0x0); - goto out; - } - ct_cr_write_1(chp, wd3s_qtag, 0x55); - if (ct_cr_read_1(chp, wd3s_qtag) != 0x55) - { - ct_cr_write_1(chp, wd3s_qtag, 0x0); - goto out; - } - ct_cr_write_1(chp, wd3s_qtag, 0x0); - *chiprevp = CT_WD33C93_B; - } - -out: - (void) ct_stat_read_1(chp); - (void) ct_cr_read_1(chp, wd3s_stat); - return 0; -} - -static struct ct_synch_data * -ct_make_synch_table(struct ct_softc *ct) -{ - struct ct_synch_data *sdtp, *sdp; - u_int base, i, period; - - sdtp = sdp = &ct->sc_default_sdt[0]; - - if ((ct->sc_chipclk % 5) == 0) - base = 1000 / (5 * 2); /* 5 MHz type */ - else - base = 1000 / (4 * 2); /* 4 MHz type */ - - if (ct->sc_chiprev >= CT_WD33C93_B) - { - /* fast scsi */ - for (i = 2; i < 8; i ++, sdp ++) - { - period = (base * i) / 2; - if (period >= 200) /* 5 MHz */ - break; - sdp->cs_period = period / 4; - sdp->cs_syncr = (i * 0x10) | 0x80; - } - } - - for (i = 2; i < 8; i ++, sdp ++) - { - period = (base * i); - if (period > 500) /* 2 MHz */ - break; - sdp->cs_period = period / 4; - sdp->cs_syncr = (i * 0x10); - } - - sdp->cs_period = 0; - sdp->cs_syncr = 0; - return sdtp; -} - -/************************************************** - * Attach & Probe - **************************************************/ -int -ctprobesubr(struct ct_bus_access_handle *chp, u_int dvcfg, int hsid, - u_int chipclk, int *chiprevp) -{ - -#if 0 - if ((ct_stat_read_1(chp) & STR_BSY) != 0) - return 0; -#endif - if (cthw_chip_reset(chp, chiprevp, chipclk, hsid) != 0) - return 0; - return 1; -} - -void -ctattachsubr(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - - ct->sc_tmaxcnt = SCSI_LOW_MIN_TOUT * 1000 * 1000; /* default */ - slp->sl_funcs = &ct_funcs; - slp->sl_flags |= HW_READ_PADDING; - (void) scsi_low_attach(slp, 0, CT_NTARGETS, CT_NLUNS, - sizeof(struct ct_targ_info), 0); -} - -/************************************************** - * SCSI LOW interface functions - **************************************************/ -static void -cthw_attention(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - - ct->sc_atten = 1; - if ((ct_stat_read_1(chp) & (STR_BSY | STR_CIP)) != 0) - return; - - ct_cr_write_1(chp, wd3s_cmd, WD3S_ASSERT_ATN); - DELAY(10); - if ((ct_stat_read_1(chp) & STR_LCI) == 0) - ct->sc_atten = 0; - ct_unbusy(ct); - return; -} - -static void -ct_attention(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - - if (slp->sl_atten == 0) - { - ct_unbusy(ct); - scsi_low_attention(slp); - } - else if (ct->sc_atten != 0) - { - ct_unbusy(ct); - cthw_attention(ct); - } -} - -static int -ct_targ_init(struct ct_softc *ct, struct targ_info *ti, int action) -{ - struct ct_targ_info *cti = (void *) ti; - - if (action == SCSI_LOW_INFO_ALLOC || action == SCSI_LOW_INFO_REVOKE) - { - if (ct->sc_sdp == NULL) - { - ct->sc_sdp = ct_make_synch_table(ct); - } - - switch (ct->sc_chiprev) - { - default: - ti->ti_maxsynch.offset = 5; - break; - - case CT_WD33C93_A: - case CT_AM33C93_A: - ti->ti_maxsynch.offset = 12; - break; - - case CT_WD33C93_B: - case CT_WD33C93_C: - ti->ti_maxsynch.offset = 12; - break; - } - - ti->ti_maxsynch.period = ct->sc_sdp[0].cs_period; - ti->ti_width = SCSI_LOW_BUS_WIDTH_8; - cti->cti_syncreg = 0; - } - - return 0; -} - -static int -ct_world_start(struct ct_softc *ct, int fdone) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - - if (ct->sc_sdp == NULL) - { - ct->sc_sdp = ct_make_synch_table(ct); - } - - if (slp->sl_cfgflags & CFG_NOPARITY) - ct->sc_creg = CR_DEFAULT; - else - ct->sc_creg = CR_DEFAULT_HP; - - if (ct->sc_dma & CT_DMA_DMASTART) - (*ct->ct_dma_xfer_stop) (ct); - if (ct->sc_dma & CT_DMA_PIOSTART) - (*ct->ct_pio_xfer_stop) (ct); - ct->sc_dma = 0; - ct->sc_atten = 0; - - cthw_chip_reset(chp, NULL, ct->sc_chipclk, slp->sl_hostid); - scsi_low_bus_reset(slp); - cthw_chip_reset(chp, NULL, ct->sc_chipclk, slp->sl_hostid); - - return 0; -} - -static int -ct_start_selection(struct ct_softc *ct, struct slccb *cb) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - - struct targ_info *ti = slp->sl_Tnexus; - struct lun_info *li = slp->sl_Lnexus; - int s, satok; - u_int8_t cmd; - - ct->sc_tmaxcnt = cb->ccb_tcmax * 1000 * 1000; - ct->sc_atten = 0; - satok = 0; - - if (scsi_low_is_disconnect_ok(cb) != 0) - { - if (ct->sc_chiprev >= CT_WD33C93_A) - satok = 1; - else if (cthw_cmdlevel[slp->sl_scp.scp_cmd[0]] != 0) - satok = 1; - } - - if (satok != 0 && - scsi_low_is_msgout_continue(ti, SCSI_LOW_MSG_IDENTIFY) == 0) - { - cmd = WD3S_SELECT_ATN_TFR; - ct->sc_satgo = CT_SAT_GOING; - } - else - { - cmd = WD3S_SELECT_ATN; - ct->sc_satgo = 0; - } - - if ((ct_stat_read_1(chp) & (STR_BSY | STR_INT | STR_CIP)) != 0) - return SCSI_LOW_START_FAIL; - - if ((ct->sc_satgo & CT_SAT_GOING) != 0) - { - (void) scsi_low_msgout(slp, ti, SCSI_LOW_MSGOUT_INIT); - scsi_low_cmd(slp, ti); - ct_cr_write_1(chp, wd3s_oid, slp->sl_scp.scp_cmdlen); - ct_write_cmds(chp, slp->sl_scp.scp_cmd, slp->sl_scp.scp_cmdlen); - } - else - { - /* anyway attention assert */ - SCSI_LOW_ASSERT_ATN(slp); - } - - ct_target_nexus_establish(ct, li->li_lun, slp->sl_scp.scp_direction); - - s = splhigh(); - if ((ct_stat_read_1(chp) & (STR_BSY | STR_INT | STR_CIP)) == 0) - { - /* XXX: - * Reload a lun again here. - */ - ct_cr_write_1(chp, wd3s_lun, li->li_lun); - ct_cr_write_1(chp, wd3s_cmd, cmd); - if ((ct_stat_read_1(chp) & STR_LCI) == 0) - { - splx(s); - SCSI_LOW_SETUP_PHASE(ti, PH_SELSTART); - return SCSI_LOW_START_OK; - } - } - splx(s); - return SCSI_LOW_START_FAIL; -} - -static int -ct_msg(struct ct_softc *ct, struct targ_info *ti, u_int msg) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct ct_targ_info *cti = (void *) ti; - struct ct_synch_data *csp = ct->sc_sdp; - u_int offset, period; - int error; - - if ((msg & SCSI_LOW_MSG_WIDE) != 0) - { - if (ti->ti_width != SCSI_LOW_BUS_WIDTH_8) - { - ti->ti_width = SCSI_LOW_BUS_WIDTH_8; - return EINVAL; - } - return 0; - } - - if ((msg & SCSI_LOW_MSG_SYNCH) == 0) - return 0; - - offset = ti->ti_maxsynch.offset; - period = ti->ti_maxsynch.period; - for ( ; csp->cs_period != 0; csp ++) - { - if (period == csp->cs_period) - break; - } - - if (ti->ti_maxsynch.period != 0 && csp->cs_period == 0) - { - ti->ti_maxsynch.period = 0; - ti->ti_maxsynch.offset = 0; - cti->cti_syncreg = 0; - error = EINVAL; - } - else - { - cti->cti_syncreg = ((offset & 0x0f) | csp->cs_syncr); - error = 0; - } - - if (ct->ct_synch_setup != 0) - (*ct->ct_synch_setup) (ct, ti); - ct_cr_write_1(chp, wd3s_synch, cti->cti_syncreg); - return error; -} - -/************************************************* - * <DATA PHASE> - *************************************************/ -static int -ct_xfer(struct ct_softc *ct, u_int8_t *data, int len, int direction, - u_int *statp) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - int wc; - register u_int8_t aux; - - *statp = 0; - if (len == 1) - { - ct_cr_write_1(chp, wd3s_cmd, WD3S_SBT | WD3S_TFR_INFO); - } - else - { - cthw_set_count(chp, len); - ct_cr_write_1(chp, wd3s_cmd, WD3S_TFR_INFO); - } - - aux = ct_stat_read_1(chp); - if ((aux & STR_LCI) != 0) - { - cthw_set_count(chp, 0); - return len; - } - - for (wc = 0; wc < ct->sc_tmaxcnt; wc ++) - { - /* check data ready */ - if ((aux & (STR_BSY | STR_DBR)) == (STR_BSY | STR_DBR)) - { - if (direction == SCSI_LOW_READ) - { - *data = ct_cr_read_1(chp, wd3s_data); - if ((aux & STR_PE) != 0) - *statp |= SCSI_LOW_DATA_PE; - } - else - { - ct_cr_write_1(chp, wd3s_data, *data); - } - len --; - if (len <= 0) - break; - data ++; - } - else - { - DELAY(1); - } - - /* check phase miss */ - aux = ct_stat_read_1(chp); - if ((aux & STR_INT) != 0) - break; - } - return len; -} - -#define CT_PADDING_BUF_SIZE 32 - -static void -ct_io_xfer(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct sc_p *sp = &slp->sl_scp; - u_int stat; - int len; - u_int8_t pbuf[CT_PADDING_BUF_SIZE]; - - /* polling mode */ - ct_cr_write_1(chp, wd3s_ctrl, ct->sc_creg); - - if (sp->scp_datalen <= 0) - { - slp->sl_error |= PDMAERR; - - if (slp->sl_scp.scp_direction == SCSI_LOW_WRITE) - bzero(pbuf, CT_PADDING_BUF_SIZE); - ct_xfer(ct, pbuf, CT_PADDING_BUF_SIZE, - sp->scp_direction, &stat); - } - else - { - len = ct_xfer(ct, sp->scp_data, sp->scp_datalen, - sp->scp_direction, &stat); - sp->scp_data += (sp->scp_datalen - len); - sp->scp_datalen = len; - } -} - -/************************************************** - * <PHASE ERROR> - **************************************************/ -struct ct_err { - u_char *pe_msg; - u_int pe_err; - u_int pe_errmsg; - int pe_done; -}; - -struct ct_err ct_cmderr[] = { -/*0*/ { "illegal cmd", FATALIO, SCSI_LOW_MSG_ABORT, 1}, -/*1*/ { "unexpected bus free", FATALIO, 0, 1}, -/*2*/ { NULL, SELTIMEOUTIO, 0, 1}, -/*3*/ { "scsi bus parity error", PARITYERR, SCSI_LOW_MSG_ERROR, 0}, -/*4*/ { "scsi bus parity error", PARITYERR, SCSI_LOW_MSG_ERROR, 0}, -/*5*/ { "unknown" , FATALIO, SCSI_LOW_MSG_ABORT, 1}, -/*6*/ { "miss reselection (target mode)", FATALIO, SCSI_LOW_MSG_ABORT, 0}, -/*7*/ { "wrong status byte", PARITYERR, SCSI_LOW_MSG_ERROR, 0}, -}; - -static void -ct_phase_error(struct ct_softc *ct, u_int8_t scsi_status) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct targ_info *ti = slp->sl_Tnexus; - struct ct_err *pep; - u_int msg = 0; - - if ((scsi_status & BSR_CM) == BSR_CMDERR && - (scsi_status & BSR_PHVALID) == 0) - { - pep = &ct_cmderr[scsi_status & BSR_PM]; - slp->sl_error |= pep->pe_err; - if ((pep->pe_err & PARITYERR) != 0) - { - if (ti->ti_phase == PH_MSGIN) - msg = SCSI_LOW_MSG_PARITY; - else - msg = SCSI_LOW_MSG_ERROR; - } - else - msg = pep->pe_errmsg; - - if (msg != 0) - scsi_low_assert_msg(slp, slp->sl_Tnexus, msg, 1); - - if (pep->pe_msg != NULL) - { - device_printf(slp->sl_dev, "phase error: %s", - pep->pe_msg); - scsi_low_print(slp, slp->sl_Tnexus); - } - - if (pep->pe_done != 0) - scsi_low_disconnected(slp, ti); - } - else - { - slp->sl_error |= FATALIO; - scsi_low_restart(slp, SCSI_LOW_RESTART_HARD, "phase error"); - } -} - -/************************************************** - * ### SCSI PHASE SEQUENCER ### - **************************************************/ -static int -ct_reselected(struct ct_softc *ct, u_int8_t scsi_status) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct targ_info *ti; - u_int sid; - u_int8_t regv; - - ct->sc_atten = 0; - ct->sc_satgo &= ~CT_SAT_GOING; - regv = ct_cr_read_1(chp, wd3s_sid); - if ((regv & SIDR_VALID) == 0) - return EJUSTRETURN; - - sid = regv & SIDR_IDM; - if ((ti = scsi_low_reselected(slp, sid)) == NULL) - return EJUSTRETURN; - - ct_target_nexus_establish(ct, 0, SCSI_LOW_READ); - if (scsi_status != BSR_AFM_RESEL) - return EJUSTRETURN; - - SCSI_LOW_SETUP_PHASE(ti, PH_MSGIN); - regv = ct_cr_read_1(chp, wd3s_data); - if (scsi_low_msgin(slp, ti, (u_int) regv) == 0) - { - if (scsi_low_is_msgout_continue(ti, 0) != 0) - { - /* XXX: scsi_low_attetion */ - scsi_low_attention(slp); - } - } - - if (ct->sc_atten != 0) - { - ct_attention(ct); - } - - ct_cr_write_1(chp, wd3s_cmd, WD3S_NEGATE_ACK); - return EJUSTRETURN; -} - -static int -ct_target_nexus_establish(struct ct_softc *ct, int lun, int dir) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct targ_info *ti = slp->sl_Tnexus; - struct ct_targ_info *cti = (void *) ti; - - if (dir == SCSI_LOW_WRITE) - ct_cr_write_1(chp, wd3s_did, ti->ti_id); - else - ct_cr_write_1(chp, wd3s_did, ti->ti_id | DIDR_DPD); - ct_cr_write_1(chp, wd3s_lun, lun); - ct_cr_write_1(chp, wd3s_ctrl, ct->sc_creg | CR_DMA); - ct_cr_write_1(chp, wd3s_cph, 0); - ct_cr_write_1(chp, wd3s_synch, cti->cti_syncreg); - cthw_set_count(chp, 0); - return 0; -} - -static int -ct_lun_nexus_establish(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct lun_info *li = slp->sl_Lnexus; - - ct_cr_write_1(chp, wd3s_lun, li->li_lun); - return 0; -} - -static int -ct_ccb_nexus_establish(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct lun_info *li = slp->sl_Lnexus; - struct targ_info *ti = slp->sl_Tnexus; - struct ct_targ_info *cti = (void *) ti; - struct slccb *cb = slp->sl_Qnexus; - - ct->sc_tmaxcnt = cb->ccb_tcmax * 1000 * 1000; - - if ((ct->sc_satgo & CT_SAT_GOING) != 0) - { - ct_cr_write_1(chp, wd3s_oid, slp->sl_scp.scp_cmdlen); - ct_write_cmds(chp, slp->sl_scp.scp_cmd, slp->sl_scp.scp_cmdlen); - } - if (slp->sl_scp.scp_direction == SCSI_LOW_WRITE) - ct_cr_write_1(chp, wd3s_did, ti->ti_id); - else - ct_cr_write_1(chp, wd3s_did, ti->ti_id | DIDR_DPD); - ct_cr_write_1(chp, wd3s_lun, li->li_lun); - ct_cr_write_1(chp, wd3s_synch, cti->cti_syncreg); - return 0; -} - -static int -ct_unbusy(struct ct_softc *ct) -{ - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - int wc; - register u_int8_t regv; - - for (wc = 0; wc < CT_DELAY_MAX / CT_DELAY_INTERVAL; wc ++) - { - regv = ct_stat_read_1(chp); - if ((regv & (STR_BSY | STR_CIP)) == 0) - return 0; - if (regv == (u_int8_t) -1) - return EIO; - - DELAY(CT_DELAY_INTERVAL); - } - - device_printf(slp->sl_dev, "unbusy timeout\n"); - return EBUSY; -} - -static int -ct_catch_intr(struct ct_softc *ct) -{ - struct ct_bus_access_handle *chp = &ct->sc_ch; - int wc; - register u_int8_t regv; - - for (wc = 0; wc < CT_DELAY_MAX / CT_DELAY_INTERVAL; wc ++) - { - regv = ct_stat_read_1(chp); - if ((regv & (STR_INT | STR_BSY | STR_CIP)) == STR_INT) - return 0; - - DELAY(CT_DELAY_INTERVAL); - } - return EJUSTRETURN; -} - -void -ctintr(void *arg) -{ - struct ct_softc *ct = arg; - struct scsi_low_softc *slp = &ct->sc_sclow; - - SCSI_LOW_LOCK(slp); - ct_poll(ct); - SCSI_LOW_UNLOCK(slp); -} - -static int -ct_poll(void *arg) -{ - struct ct_softc *ct = arg; - struct scsi_low_softc *slp = &ct->sc_sclow; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct targ_info *ti; - struct buf *bp; - u_int derror, flags; - int len, satgo, error; - u_int8_t scsi_status, regv; - -again: - if (slp->sl_flags & HW_INACTIVE) - return 0; - - /************************************************** - * Get status & bus phase - **************************************************/ - if ((ct_stat_read_1(chp) & STR_INT) == 0) - return 0; - - scsi_status = ct_cr_read_1(chp, wd3s_stat); - if (scsi_status == ((u_int8_t) -1)) - return 1; - - /************************************************** - * Check reselection, or nexus - **************************************************/ - if (scsi_status == BSR_RESEL || scsi_status == BSR_AFM_RESEL) - { - if (ct_reselected(ct, scsi_status) == EJUSTRETURN) - return 1; - } - - if ((ti = slp->sl_Tnexus) == NULL) - return 1; - - /************************************************** - * Debug section - **************************************************/ -#ifdef CT_DEBUG - if (ct_debug > 0) - { - scsi_low_print(slp, NULL); - device_printf(slp->sl_dev, "scsi_status 0x%x\n\n", - (u_int) scsi_status); -#ifdef KDB - if (ct_debug > 1) - kdb_enter(KDB_WHY_CAM, "ct"); -#endif /* KDB */ - } -#endif /* CT_DEBUG */ - - /************************************************** - * Internal scsi phase - **************************************************/ - satgo = ct->sc_satgo; - ct->sc_satgo &= ~CT_SAT_GOING; - - switch (ti->ti_phase) - { - case PH_SELSTART: - if ((satgo & CT_SAT_GOING) == 0) - { - if (scsi_status != BSR_SELECTED) - { - ct_phase_error(ct, scsi_status); - return 1; - } - scsi_low_arbit_win(slp); - SCSI_LOW_SETUP_PHASE(ti, PH_SELECTED); - return 1; - } - else - { - scsi_low_arbit_win(slp); - SCSI_LOW_SETUP_PHASE(ti, PH_MSGOUT); /* XXX */ - } - break; - - case PH_RESEL: - if ((scsi_status & BSR_PHVALID) == 0 || - (scsi_status & BSR_PM) != BSR_MSGIN) - { - scsi_low_restart(slp, SCSI_LOW_RESTART_HARD, - "phase miss after reselect"); - return 1; - } - break; - - default: - if (slp->sl_flags & HW_PDMASTART) - { - slp->sl_flags &= ~HW_PDMASTART; - if (ct->sc_dma & CT_DMA_DMASTART) - { - (*ct->ct_dma_xfer_stop) (ct); - ct->sc_dma &= ~CT_DMA_DMASTART; - } - else if (ct->sc_dma & CT_DMA_PIOSTART) - { - (*ct->ct_pio_xfer_stop) (ct); - ct->sc_dma &= ~CT_DMA_PIOSTART; - } - else - { - scsi_low_data_finish(slp); - } - } - break; - } - - /************************************************** - * parse scsi phase - **************************************************/ - if (scsi_status & BSR_PHVALID) - { - /************************************************** - * Normal SCSI phase. - **************************************************/ - if ((scsi_status & BSR_CM) == BSR_CMDABT) - { - ct_phase_error(ct, scsi_status); - return 1; - } - - switch (scsi_status & BSR_PM) - { - case BSR_DATAOUT: - SCSI_LOW_SETUP_PHASE(ti, PH_DATA); - if (scsi_low_data(slp, ti, &bp, SCSI_LOW_WRITE) != 0) - { - ct_attention(ct); - } - goto common_data_phase; - - case BSR_DATAIN: - SCSI_LOW_SETUP_PHASE(ti, PH_DATA); - if (scsi_low_data(slp, ti, &bp, SCSI_LOW_READ) != 0) - { - ct_attention(ct); - } - -common_data_phase: - if (slp->sl_scp.scp_datalen > 0) - { - slp->sl_flags |= HW_PDMASTART; - if ((ct->sc_xmode & CT_XMODE_PIO) != 0) - { - error = (*ct->ct_pio_xfer_start) (ct); - if (error == 0) - { - ct->sc_dma |= CT_DMA_PIOSTART; - return 1; - } - } - - if ((ct->sc_xmode & CT_XMODE_DMA) != 0) - { - error = (*ct->ct_dma_xfer_start) (ct); - if (error == 0) - { - ct->sc_dma |= CT_DMA_DMASTART; - return 1; - } - } - } - else - { - if (slp->sl_scp.scp_direction == SCSI_LOW_READ) - { - if (!(slp->sl_flags & HW_READ_PADDING)) - { - device_printf(slp->sl_dev, - "read padding required\n"); - return 1; - } - } - else - { - if (!(slp->sl_flags & HW_WRITE_PADDING)) - { - device_printf(slp->sl_dev, - "write padding required\n"); - return 1; - } - } - slp->sl_flags |= HW_PDMASTART; - } - - ct_io_xfer(ct); - return 1; - - case BSR_CMDOUT: - SCSI_LOW_SETUP_PHASE(ti, PH_CMD); - if (scsi_low_cmd(slp, ti) != 0) - { - ct_attention(ct); - } - - if (ct_xfer(ct, slp->sl_scp.scp_cmd, - slp->sl_scp.scp_cmdlen, - SCSI_LOW_WRITE, &derror) != 0) - { - device_printf(slp->sl_dev, - "scsi cmd xfer short\n"); - } - return 1; - - case BSR_STATIN: - SCSI_LOW_SETUP_PHASE(ti, PH_STAT); - if ((ct_io_control & CT_USE_CCSEQ) != 0) - { - if (scsi_low_is_msgout_continue(ti, 0) != 0 || - ct->sc_atten != 0) - { - ct_xfer(ct, ®v, 1, SCSI_LOW_READ, - &derror); - scsi_low_statusin(slp, ti, - regv | derror); - } - else - { - ct->sc_satgo |= CT_SAT_GOING; - cthw_set_count(chp, 0); - cthw_phase_bypass(ct, 0x41); - } - } - else - { - ct_xfer(ct, ®v, 1, SCSI_LOW_READ, &derror); - scsi_low_statusin(slp, ti, regv | derror); - } - return 1; - - case BSR_UNSPINFO0: - case BSR_UNSPINFO1: - device_printf(slp->sl_dev, "illegal bus phase (0x%x)\n", - (u_int) scsi_status); - scsi_low_print(slp, ti); - return 1; - - case BSR_MSGOUT: - SCSI_LOW_SETUP_PHASE(ti, PH_MSGOUT); - flags = SCSI_LOW_MSGOUT_UNIFY; - if (ti->ti_ophase != ti->ti_phase) - flags |= SCSI_LOW_MSGOUT_INIT; - len = scsi_low_msgout(slp, ti, flags); - - if (len > 1 && slp->sl_atten == 0) - { - ct_attention(ct); - } - - if (ct_xfer(ct, ti->ti_msgoutstr, len, - SCSI_LOW_WRITE, &derror) != 0) - { - device_printf(slp->sl_dev, - "scsi msgout xfer short\n"); - } - SCSI_LOW_DEASSERT_ATN(slp); - ct->sc_atten = 0; - return 1; - - case BSR_MSGIN:/* msg in */ - SCSI_LOW_SETUP_PHASE(ti, PH_MSGIN); - - ct_xfer(ct, ®v, 1, SCSI_LOW_READ, &derror); - if (scsi_low_msgin(slp, ti, regv | derror) == 0) - { - if (scsi_low_is_msgout_continue(ti, 0) != 0) - { - /* XXX: scsi_low_attetion */ - scsi_low_attention(slp); - } - } - - if ((ct_io_control & CT_FAST_INTR) != 0) - { - if (ct_catch_intr(ct) == 0) - goto again; - } - return 1; - } - } - else - { - /************************************************** - * Special SCSI phase - **************************************************/ - switch (scsi_status) - { - case BSR_SATSDP: /* SAT with save data pointer */ - SCSI_LOW_SETUP_PHASE(ti, PH_MSGIN); - ct->sc_satgo |= CT_SAT_GOING; - scsi_low_msgin(slp, ti, MSG_SAVESP); - cthw_phase_bypass(ct, 0x41); - return 1; - - case BSR_SATFIN: /* SAT COMPLETE */ - /* - * emulate statusin => msgin - */ - SCSI_LOW_SETUP_PHASE(ti, PH_STAT); - scsi_low_statusin(slp, ti, ct_cr_read_1(chp, wd3s_lun)); - - SCSI_LOW_SETUP_PHASE(ti, PH_MSGIN); - scsi_low_msgin(slp, ti, MSG_COMP); - - scsi_low_disconnected(slp, ti); - return 1; - - case BSR_ACKREQ: /* negate ACK */ - if (ct->sc_atten != 0) - { - ct_attention(ct); - } - - ct_cr_write_1(chp, wd3s_cmd, WD3S_NEGATE_ACK); - if ((ct_io_control & CT_FAST_INTR) != 0) - { - /* XXX: - * Should clear a pending interrupt and - * sync with a next interrupt! - */ - ct_catch_intr(ct); - } - return 1; - - case BSR_DISC: /* disconnect */ - if (slp->sl_msgphase == MSGPH_NULL && - (satgo & CT_SAT_GOING) != 0) - { - /* - * emulate disconnect msg - */ - SCSI_LOW_SETUP_PHASE(ti, PH_MSGIN); - scsi_low_msgin(slp, ti, MSG_DISCON); - } - scsi_low_disconnected(slp, ti); - return 1; - - default: - break; - } - } - - ct_phase_error(ct, scsi_status); - return 1; -} diff --git a/sys/dev/ct/ct_isa.c b/sys/dev/ct/ct_isa.c deleted file mode 100644 index 601f7fb06569c..0000000000000 --- a/sys/dev/ct/ct_isa.c +++ /dev/null @@ -1,382 +0,0 @@ -/* $NecBSD: ct_isa.c,v 1.6 1999/07/26 06:32:01 honda Exp $ */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); -/* $NetBSD$ */ - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1995, 1996, 1997, 1998 - * NetBSD/pc98 porting staff. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#define SCSIBUS_RESCAN - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/bio.h> -#include <sys/buf.h> -#include <sys/queue.h> -#include <sys/malloc.h> -#include <sys/bus.h> -#include <sys/module.h> -#include <sys/errno.h> - -#include <vm/vm.h> - -#include <machine/bus.h> -#include <machine/resource.h> -#include <sys/bus.h> -#include <sys/rman.h> -#include <machine/md_var.h> - -#include <pc98/cbus/cbus.h> -#include <isa/isavar.h> - -#include <compat/netbsd/dvcfg.h> - -#include <cam/scsi/scsi_low.h> - -#include <dev/ic/wd33c93reg.h> -#include <dev/ct/ctvar.h> -#include <dev/ct/bshwvar.h> - -#define BSHW_IOSZ 0x08 -#define BSHW_IOBASE 0xcc0 -#define BSHW_MEMSZ (PAGE_SIZE * 2) - -static int ct_isa_match(device_t); -static int ct_isa_attach(device_t); -static int ct_space_map(device_t, struct bshw *, - struct resource **, struct resource **); -static void ct_space_unmap(device_t, struct ct_softc *); -static struct bshw *ct_find_hw(device_t); -static void ct_dmamap(void *, bus_dma_segment_t *, int, int); -static void ct_isa_bus_access_weight(struct ct_bus_access_handle *); -static void ct_isa_dmasync_before(struct ct_softc *); -static void ct_isa_dmasync_after(struct ct_softc *); - -struct ct_isa_softc { - struct ct_softc sc_ct; - struct bshw_softc sc_bshw; -}; - -static struct isa_pnp_id ct_pnp_ids[] = { - { 0x0100e7b1, "Logitec LHA-301" }, - { 0x110154dc, "I-O DATA SC-98III" }, - { 0x4120acb4, "MELCO IFC-NN" }, - { 0, NULL } -}; - -static device_method_t ct_isa_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ct_isa_match), - DEVMETHOD(device_attach, ct_isa_attach), - { 0, 0 } -}; - -static driver_t ct_isa_driver = { - "ct", ct_isa_methods, sizeof(struct ct_isa_softc), -}; - -static devclass_t ct_devclass; - -DRIVER_MODULE(ct, isa, ct_isa_driver, ct_devclass, 0, 0); - -static int -ct_isa_match(device_t dev) -{ - struct bshw *hw; - struct resource *port_res, *mem_res; - struct ct_bus_access_handle ch; - int rv; - - if (ISA_PNP_PROBE(device_get_parent(dev), dev, ct_pnp_ids) == ENXIO) - return ENXIO; - - switch (isa_get_logicalid(dev)) { - case 0x0100e7b1: /* LHA-301 */ - case 0x110154dc: /* SC-98III */ - case 0x4120acb4: /* IFC-NN */ - /* XXX - force to SMIT mode */ - device_set_flags(dev, device_get_flags(dev) | 0x40000); - break; - } - - if (isa_get_port(dev) == -1) - bus_set_resource(dev, SYS_RES_IOPORT, 0, - BSHW_IOBASE, BSHW_IOSZ); - - if ((hw = ct_find_hw(dev)) == NULL) - return ENXIO; - if (ct_space_map(dev, hw, &port_res, &mem_res) != 0) - return ENXIO; - - bzero(&ch, sizeof(ch)); - ch.ch_io = port_res; - ch.ch_bus_weight = ct_isa_bus_access_weight; - - rv = ctprobesubr(&ch, 0, BSHW_DEFAULT_HOSTID, - BSHW_DEFAULT_CHIPCLK, NULL); - if (rv != 0) - { - struct bshw_softc bshw_tab; - struct bshw_softc *bs = &bshw_tab; - - memset(bs, 0, sizeof(*bs)); - bshw_read_settings(&ch, bs); - bus_set_resource(dev, SYS_RES_IRQ, 0, bs->sc_irq, 1); - bus_set_resource(dev, SYS_RES_DRQ, 0, bs->sc_drq, 1); - } - - bus_release_resource(dev, SYS_RES_IOPORT, 0, port_res); - if (mem_res != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, 0, mem_res); - - if (rv != 0) - return (BUS_PROBE_DEFAULT); - return ENXIO; -} - -static int -ct_isa_attach(device_t dev) -{ - struct ct_isa_softc *pct = device_get_softc(dev); - struct ct_softc *ct = &pct->sc_ct; - struct ct_bus_access_handle *chp = &ct->sc_ch; - struct scsi_low_softc *slp = &ct->sc_sclow; - struct bshw_softc *bs = &pct->sc_bshw; - struct bshw *hw; - int irq_rid, drq_rid, chiprev; - u_int8_t *vaddr; - bus_addr_t addr; - - hw = ct_find_hw(dev); - if (ct_space_map(dev, hw, &ct->port_res, &ct->mem_res) != 0) { - device_printf(dev, "bus io mem map failed\n"); - return ENXIO; - } - - chp->ch_io = ct->port_res; - chp->ch_mem = ct->mem_res; - chp->ch_bus_weight = ct_isa_bus_access_weight; - - irq_rid = 0; - ct->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irq_rid, - RF_ACTIVE); - drq_rid = 0; - ct->drq_res = bus_alloc_resource_any(dev, SYS_RES_DRQ, &drq_rid, - RF_ACTIVE); - if (ct->irq_res == NULL || ct->drq_res == NULL) { - ct_space_unmap(dev, ct); - return ENXIO; - } - - if (ctprobesubr(chp, 0, BSHW_DEFAULT_HOSTID, - BSHW_DEFAULT_CHIPCLK, &chiprev) == 0) - { - device_printf(dev, "hardware missing\n"); - ct_space_unmap(dev, ct); - return ENXIO; - } - - /* setup DMA map */ - if (bus_dma_tag_create(NULL, 1, 0, - BUS_SPACE_MAXADDR_24BIT, BUS_SPACE_MAXADDR, - NULL, NULL, DFLTPHYS, 1, - BUS_SPACE_MAXSIZE_32BIT, - BUS_DMA_ALLOCNOW, NULL, NULL, - &ct->sc_dmat) != 0) { - device_printf(dev, "can't set up ISA DMA map\n"); - ct_space_unmap(dev, ct); - return ENXIO; - } - - if (bus_dmamem_alloc(ct->sc_dmat, (void **)&vaddr, BUS_DMA_NOWAIT, - &ct->sc_dmamapt) != 0) { - device_printf(dev, "can't set up ISA DMA map\n"); - ct_space_unmap(dev, ct); - return ENXIO; - } - - bus_dmamap_load(ct->sc_dmat, ct->sc_dmamapt, vaddr, DFLTPHYS, - ct_dmamap, &addr, BUS_DMA_NOWAIT); - - /* setup machdep softc */ - bs->sc_hw = hw; - bs->sc_io_control = 0; - bs->sc_bounce_phys = (u_int8_t *)addr; - bs->sc_bounce_addr = vaddr; - bs->sc_bounce_size = DFLTPHYS; - bs->sc_minphys = (1 << 24); - bs->sc_dmasync_before = ct_isa_dmasync_before; - bs->sc_dmasync_after = ct_isa_dmasync_after; - bshw_read_settings(chp, bs); - - /* setup ct driver softc */ - ct->ct_hw = bs; - ct->ct_dma_xfer_start = bshw_dma_xfer_start; - ct->ct_pio_xfer_start = bshw_smit_xfer_start; - ct->ct_dma_xfer_stop = bshw_dma_xfer_stop; - ct->ct_pio_xfer_stop = bshw_smit_xfer_stop; - ct->ct_bus_reset = bshw_bus_reset; - ct->ct_synch_setup = bshw_synch_setup; - - ct->sc_xmode = CT_XMODE_DMA; - if (chp->ch_mem != NULL) - ct->sc_xmode |= CT_XMODE_PIO; - - ct->sc_chiprev = chiprev; - switch (chiprev) - { - case CT_WD33C93: - /* s = "WD33C93"; */ - ct->sc_chipclk = 8; - break; - case CT_WD33C93_A: - if (DVCFG_MAJOR(device_get_flags(dev)) > 0) - { - /* s = "AM33C93_A"; */ - ct->sc_chipclk = 20; - ct->sc_chiprev = CT_AM33C93_A; - } - else - { - /* s = "WD33C93_A"; */ - ct->sc_chipclk = 10; - } - break; - - case CT_AM33C93_A: - /* s = "AM33C93_A"; */ - ct->sc_chipclk = 20; - break; - - default: - case CT_WD33C93_B: - /* s = "WD33C93_B"; */ - ct->sc_chipclk = 20; - break; - } -#if 0 - printf("%s: chiprev %s chipclk %d MHz\n", - slp->sl_dev.dv_xname, s, ct->sc_chipclk); -#endif - - slp->sl_dev = dev; - slp->sl_hostid = bs->sc_hostid; - slp->sl_cfgflags = device_get_flags(dev); - mtx_init(&slp->sl_lock, "ct", NULL, MTX_DEF); - - ctattachsubr(ct); - - if (bus_setup_intr(dev, ct->irq_res, INTR_TYPE_CAM | INTR_MPSAFE, - NULL, ctintr, ct, &ct->sc_ih)) { - ct_space_unmap(dev, ct); - return ENXIO; - } - - return 0; -} - -static struct bshw * -ct_find_hw(device_t dev) -{ - return DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(device_get_flags(dev))); -} - -static int -ct_space_map(device_t dev, struct bshw *hw, - struct resource **iohp, struct resource **memhp) -{ - int port_rid, mem_rid; - - *memhp = NULL; - - port_rid = 0; - *iohp = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &port_rid, - BSHW_IOSZ, RF_ACTIVE); - if (*iohp == NULL) - return ENXIO; - - if ((hw->hw_flags & BSHW_SMFIFO) == 0 || isa_get_maddr(dev) == -1) - return 0; - - mem_rid = 0; - *memhp = bus_alloc_resource_anywhere(dev, SYS_RES_MEMORY, &mem_rid, - BSHW_MEMSZ, RF_ACTIVE); - if (*memhp == NULL) { - bus_release_resource(dev, SYS_RES_IOPORT, port_rid, *iohp); - return ENXIO; - } - - return 0; -} - -static void -ct_space_unmap(device_t dev, struct ct_softc *ct) -{ - if (ct->port_res != NULL) - bus_release_resource(dev, SYS_RES_IOPORT, 0, ct->port_res); - if (ct->mem_res != NULL) - bus_release_resource(dev, SYS_RES_MEMORY, 0, ct->mem_res); - if (ct->irq_res != NULL) - bus_release_resource(dev, SYS_RES_IRQ, 0, ct->irq_res); - if (ct->drq_res != NULL) - bus_release_resource(dev, SYS_RES_DRQ, 0, ct->drq_res); -} - -static void -ct_dmamap(void *arg, bus_dma_segment_t *seg, int nseg, int error) -{ - bus_addr_t *addr = (bus_addr_t *)arg; - - *addr = seg->ds_addr; -} - -static void -ct_isa_bus_access_weight(struct ct_bus_access_handle *chp) -{ - - outb(0x5f, 0); -} - -static void -ct_isa_dmasync_before(struct ct_softc *ct) -{ - - if (need_pre_dma_flush) - wbinvd(); -} - -static void -ct_isa_dmasync_after(struct ct_softc *ct) -{ - - if (need_post_dma_flush) - invd(); -} diff --git a/sys/dev/ct/ct_machdep.h b/sys/dev/ct/ct_machdep.h deleted file mode 100644 index 7d92526125eb0..0000000000000 --- a/sys/dev/ct/ct_machdep.h +++ /dev/null @@ -1,186 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: ct_machdep.h,v 1.4.12.2 2001/06/20 06:13:34 honda Exp $ */ -/* $NetBSD$ */ - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * NetBSD/pc98 porting staff. All rights reserved. - * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * Naofumi HONDA. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _CT_MACHDEP_H_ -#define _CT_MACHDEP_H_ - -#include "opt_ct.h" - -/* - * Principal rules: - * 1) do not use bus_space_write/read_X directly in ct.c. - * 2) do not use port offset defs directly in ct.c. - */ - -/* special weight if requried */ -#ifdef CT_BUS_WEIGHT -#undef CT_BUS_WEIGHT -#define CT_BUS_WEIGHT(chp) \ -{ \ - if ((chp)->ch_bus_weight != NULL) \ - (chp)->ch_bus_weight((chp)); \ -} -#else /* !CT_BUS_WEIGHT */ -#define CT_BUS_WEIGHT(chp) -#endif /* !CT_BUS_WEIGHT */ - -/* port offset */ -#ifndef CT_USE_RELOCATE_OFFSET -#define addr_port 0 -#define stat_port 0 -#define ctrl_port 2 -#define cmd_port 4 -#else /* CT_USE_RELOCATE_OFFSET */ -#define addr_port ((chp)->ch_offset[0]) -#define stat_port ((chp)->ch_offset[1]) -#define ctrl_port ((chp)->ch_offset[2]) -#define cmd_port ((chp)->ch_offset[3]) -#endif /* CT_USE_RELOCATE_OFFSET */ - -/* - * All port accesses primitive methods - */ -static __inline u_int8_t ct_stat_read_1 - (struct ct_bus_access_handle *); -static __inline u_int8_t ct_cmdp_read_1 - (struct ct_bus_access_handle *); -static __inline void ct_cmdp_write_1 - (struct ct_bus_access_handle *, u_int8_t); -static __inline u_int8_t ct_cr_read_1 - (struct ct_bus_access_handle *, bus_addr_t); -static __inline void ct_cr_write_1 - (struct ct_bus_access_handle *, bus_addr_t, u_int8_t); -static __inline void ct_write_cmds - (struct ct_bus_access_handle *, u_int8_t *, int); -static __inline u_int cthw_get_count - (struct ct_bus_access_handle *); -static __inline void cthw_set_count - (struct ct_bus_access_handle *, u_int); - -static __inline u_int8_t -ct_stat_read_1(struct ct_bus_access_handle *chp) -{ - u_int8_t regv; - - regv = bus_read_1(chp->ch_io, stat_port); - CT_BUS_WEIGHT(chp) - return regv; -} - -static __inline void -cthw_set_count(struct ct_bus_access_handle *chp, u_int count) -{ - - bus_write_1(chp->ch_io, addr_port, wd3s_cnt); - CT_BUS_WEIGHT(chp) - bus_write_1(chp->ch_io, ctrl_port, count >> 16); - CT_BUS_WEIGHT(chp) - bus_write_1(chp->ch_io, ctrl_port, count >> 8); - CT_BUS_WEIGHT(chp) - bus_write_1(chp->ch_io, ctrl_port, count); - CT_BUS_WEIGHT(chp) -} - -static __inline u_int -cthw_get_count(struct ct_bus_access_handle *chp) -{ - u_int count; - - bus_write_1(chp->ch_io, addr_port, wd3s_cnt); - CT_BUS_WEIGHT(chp) - count = (((u_int) bus_read_1(chp->ch_io, ctrl_port)) << 16); - CT_BUS_WEIGHT(chp) - count += (((u_int) bus_read_1(chp->ch_io, ctrl_port)) << 8); - CT_BUS_WEIGHT(chp) - count += ((u_int) bus_read_1(chp->ch_io, ctrl_port)); - CT_BUS_WEIGHT(chp) - return count; -} - -static __inline void -ct_write_cmds(struct ct_bus_access_handle *chp, u_int8_t *cmd, int len) -{ - int i; - - bus_write_1(chp->ch_io, addr_port, wd3s_cdb); - CT_BUS_WEIGHT(chp) - for (i = 0; i < len; i ++) - { - bus_write_1(chp->ch_io, ctrl_port, cmd[i]); - CT_BUS_WEIGHT(chp) - } -} - -static __inline u_int8_t -ct_cr_read_1(struct ct_bus_access_handle *chp, bus_addr_t offs) -{ - u_int8_t regv; - - bus_write_1(chp->ch_io, addr_port, offs); - CT_BUS_WEIGHT(chp) - regv = bus_read_1(chp->ch_io, ctrl_port); - CT_BUS_WEIGHT(chp) - return regv; -} - -static __inline void -ct_cr_write_1(struct ct_bus_access_handle *chp, bus_addr_t offs, u_int8_t val) -{ - - bus_write_1(chp->ch_io, addr_port, offs); - CT_BUS_WEIGHT(chp) - bus_write_1(chp->ch_io, ctrl_port, val); - CT_BUS_WEIGHT(chp) -} - -static __inline u_int8_t -ct_cmdp_read_1(struct ct_bus_access_handle *chp) -{ - u_int8_t regv; - - regv = bus_read_1(chp->ch_io, cmd_port); - CT_BUS_WEIGHT(chp) - return regv; -} - -static __inline void -ct_cmdp_write_1(struct ct_bus_access_handle *chp, u_int8_t val) -{ - - bus_write_1(chp->ch_io, cmd_port, val); - CT_BUS_WEIGHT(chp) -} - -#endif /* !_CT_MACHDEP_H_ */ diff --git a/sys/dev/ct/ctvar.h b/sys/dev/ct/ctvar.h deleted file mode 100644 index 10ce2d8912002..0000000000000 --- a/sys/dev/ct/ctvar.h +++ /dev/null @@ -1,129 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: ctvar.h,v 1.4.14.3 2001/06/20 06:13:34 honda Exp $ */ -/* $NetBSD$ */ - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * NetBSD/pc98 porting staff. All rights reserved. - * Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001 - * Naofumi HONDA. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _CTVAR_H_ -#define _CTVAR_H_ -/* - * ctvar.h - * Generic wd33c93 chip driver's definitions - */ - -/***************************************************************** - * Host adapter structure - *****************************************************************/ -struct ct_bus_access_handle { - struct resource *ch_io; /* core chip ctrl port */ - struct resource *ch_mem; /* data port (shm) */ - - void (*ch_bus_weight)(struct ct_bus_access_handle *); - -#ifdef CT_USE_RELOCATE_OFFSET - bus_addr_t ch_offset[4]; -#endif /* CT_USE_RELOCATE_OFFSET */ -}; - -struct ct_softc { - struct scsi_low_softc sc_sclow; /* generic data */ - - struct ct_bus_access_handle sc_ch; /* bus access handle */ - - struct resource *port_res; - struct resource *mem_res; - struct resource *irq_res; - struct resource *drq_res; - - bus_dma_tag_t sc_dmat; /* data DMA tag */ - bus_dmamap_t sc_dmamapt; /* data DMAMAP tag */ - - void *sc_ih; - - int sc_chiprev; /* chip version */ -#define CT_WD33C93 0x00000 -#define CT_WD33C93_A 0x10000 -#define CT_AM33C93_A 0x10001 -#define CT_WD33C93_B 0x20000 -#define CT_WD33C93_C 0x30000 - - int sc_xmode; -#define CT_XMODE_PIO 1 -#define CT_XMODE_DMA 2 - - int sc_dma; /* dma transfer start */ -#define CT_DMA_PIOSTART 1 -#define CT_DMA_DMASTART 2 - - int sc_satgo; /* combination cmd start */ -#define CT_SAT_GOING 1 - - int sc_tmaxcnt; - int sc_atten; /* attention */ - u_int8_t sc_creg; /* control register value */ - - int sc_chipclk; /* chipclk 0, 10, 15, 20 */ - struct ct_synch_data { - u_int cs_period; - u_int cs_syncr; - } *sc_sdp; /* synchronous data table pt */ - - struct ct_synch_data sc_default_sdt[16]; - - /* - * Machdep stuff. - */ - void *ct_hw; /* point to bshw_softc etc ... */ - int (*ct_dma_xfer_start)(struct ct_softc *); - int (*ct_pio_xfer_start)(struct ct_softc *); - void (*ct_dma_xfer_stop)(struct ct_softc *); - void (*ct_pio_xfer_stop)(struct ct_softc *); - void (*ct_bus_reset)(struct ct_softc *); - void (*ct_synch_setup)(struct ct_softc *, struct targ_info *); -}; - -/***************************************************************** - * Lun information - *****************************************************************/ -struct ct_targ_info { - struct targ_info cti_ti; - - u_int8_t cti_syncreg; -}; - -/***************************************************************** - * PROTO - *****************************************************************/ -int ctprobesubr(struct ct_bus_access_handle *, u_int, int, u_int, int *); -void ctattachsubr(struct ct_softc *); -void ctintr(void *); -#endif /* !_CTVAR_H_ */ diff --git a/sys/dev/ed/if_ed98.h b/sys/dev/ed/if_ed98.h deleted file mode 100644 index b16054960b31e..0000000000000 --- a/sys/dev/ed/if_ed98.h +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * Copyright (c) KATO Takenori, 1996. 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 as - * the first lines of this file unmodified. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -/* - * PC-9801 specific definitions for DP8390/SMC8216 NICs. - */ - -/* - * Vendor types - */ -#define ED_VENDOR_MISC 0xf0 /* others */ - -/* - * Card types. - * - * Type Card - * 0x00 Allied Telesis CenterCom LA-98-T / SMC EtherEZ98. - * 0x10 ** RESERVED ** - * 0x20 PLANET SMART COM 98 EN-2298 / ELECOM LANEED LD-BDN[123]A. - * 0x30 MELCO EGY-98 / Contec C-NET(98)E-A/L-A. - * 0x40 MELCO LGY-98, IND-SP, IND-SS / MACNICA NE2098(XXX). - * 0x50 ICM DT-ET-25, DT-ET-T5, IF-2766ET, IF-2771ET / - * D-Link DE-298P{T,CAT}, DE-298{T,TP,CAT}. - * 0x60 Allied Telesis SIC-98. - * 0x70 ** RESERVED ** - * 0x80 NEC PC-9801-108. - * 0x90 IO-DATA LA-98 / NEC PC-9801-77. - * 0xa0 Contec C-NET(98). - * 0xb0 Contec C-NET(98)E/L. - * 0xc0 ** RESERVED ** - * 0xd0 Networld EC/EP-98X. - * 0xe0 Soliton SB-9801 / Fujikura FN-9801 / Networld EC/EP-98S. - * 0xf0 NextCom NC5098. - */ -#define ED_TYPE98_BASE 0x80 - -#define ED_TYPE98_GENERIC 0x80 -#define ED_TYPE98_BDN 0x82 -#define ED_TYPE98_EGY 0x83 -#define ED_TYPE98_LGY 0x84 -#define ED_TYPE98_ICM 0x85 -#define ED_TYPE98_SIC 0x86 -#define ED_TYPE98_108 0x88 -#define ED_TYPE98_LA98 0x89 -#define ED_TYPE98_CNET98 0x8a -#define ED_TYPE98_CNET98EL 0x8b -#define ED_TYPE98_NW98X 0x8d -#define ED_TYPE98_SB98 0x8e -#define ED_TYPE98_NC5098 0x8f - -#define ED_TYPE98(x) (((x & 0xffff0000) >> 20) | ED_TYPE98_BASE) -#define ED_TYPE98SUB(x) ((x & 0xf0000) >> 16) - -/* - * Definitions for C-NET(98) serise - */ -/* - * Initial Register(on board JP1) - */ -#define ED_CNET98_INIT 0xaaed /* default */ -#define ED_CNET98_INIT2 0x55ed /* another setting */ - -#define ED_CNET98EL_PAGE_OFFSET 0x0000 /* Page offset for NIC access to mem */ - -/* - * Definitions for Soliton SB-9801 - */ -/* - * I/O port select register - */ -#define ED_SB98_IO_INHIBIT 0x0040 /* XXX - shares printer port! */ - -/* - * Definitions for SMC EtherEZ98(SMC8498BTA) - */ -#define ED_EZ98_NIC_OFFSET 0x100 /* I/O base offset to NIC */ -#define ED_EZ98_ASIC_OFFSET 0 /* I/O base offset to ASIC */ -/* - * XXX - The I/O address range is fragmented in the EtherEZ98; - * it occupies 16*2 I/O addresses, by the way. - */ -#define ED_EZ98_IO_PORTS 16 /* # of i/o addresses used */ diff --git a/sys/dev/ed/if_ed_cbus.c b/sys/dev/ed/if_ed_cbus.c deleted file mode 100644 index 7926fa8e23891..0000000000000 --- a/sys/dev/ed/if_ed_cbus.c +++ /dev/null @@ -1,1629 +0,0 @@ -/*- - * Copyright (c) 1995, David Greenman - * 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 unmodified, 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. - * - * 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. - * - * $FreeBSD$ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/socket.h> -#include <sys/kernel.h> - -#include <sys/module.h> -#include <sys/bus.h> -#include <machine/bus.h> -#include <sys/rman.h> -#include <machine/resource.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> -#include <net/if_mib.h> - -#include <isa/isavar.h> - -#include <dev/ed/if_edvar.h> -#include <dev/ed/if_edreg.h> -#include <dev/ed/if_ed98.h> - -static int ed98_alloc_port(device_t, int); -static int ed98_alloc_memory(device_t, int); -static int ed_pio_testmem(struct ed_softc *, int, int, int); -static int ed_probe_CNET98(device_t, int, int); -static int ed_probe_CNET98EL(device_t, int, int); -static int ed_probe_EZ98(device_t, int, int); -static int ed_probe_NEC77(device_t, int, int); -static int ed_probe_NW98X(device_t, int, int); -static int ed_probe_SB98(device_t, int, int); -static int ed_probe_SIC98(device_t, int, int); -static int ed98_probe_Novell(device_t, int, int); -static int ed98_probe_generic8390(struct ed_softc *); -static void ed_reset_CNET98(struct ed_softc *, int); -static void ed_winsel_CNET98(struct ed_softc *, u_short); -static void ed_get_SB98(struct ed_softc *); - -static int ed_cbus_probe(device_t); -static int ed_cbus_attach(device_t); - -static struct isa_pnp_id ed_ids[] = { -/* TODO - list up PnP boards for PC-98 */ - { 0, NULL } -}; - -static int -ed_cbus_probe(device_t dev) -{ - struct ed_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); - int error = 0; - - sc->type = ED_TYPE98(flags); -#ifdef ED_DEBUG - device_printf(dev, "ed_cbus_probe: sc->type=%x\n", sc->type); -#endif - - /* Check isapnp ids */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids); -#ifdef ED_DEBUG - device_printf(dev, "ed_cbus_probe: ISA_PNP_PROBE returns %d\n", error); -#endif - - /* If the card had a PnP ID that didn't match any we know about */ - if (error == ENXIO) - goto end; - - /* If we had some other problem. */ - if (!(error == 0 || error == ENOENT)) - goto end; - - /* Heuristic probes */ -#ifdef ED_DEBUG - device_printf(dev, "ed_cbus_probe: Heuristic probes start\n"); -#endif - switch (sc->type) { - case ED_TYPE98_GENERIC: - /* - * CAUTION! - * sc->type of these boards are overwritten by PC/AT's value. - */ - - /* - * SMC EtherEZ98 - */ - error = ed_probe_EZ98(dev, 0, flags); - if (error == 0) - goto end; - - ed_release_resources(dev); - - /* - * Allied Telesis CenterCom LA-98-T - */ - error = ed_probe_Novell(dev, 0, flags); - if (error == 0) { - ed_Novell_read_mac(sc); - goto end; - } - break; - - /* - * NE2000-like boards probe routine - */ - case ED_TYPE98_BDN: - /* - * ELECOM LANEED LD-BDN - * PLANET SMART COM 98 EN-2298 - */ - case ED_TYPE98_LGY: - /* - * MELCO LGY-98, IND-SP, IND-SS - * MACNICA NE2098 - */ - case ED_TYPE98_ICM: - /* - * ICM DT-ET-25, DT-ET-T5, IF-2766ET, IF-2771ET - * D-Link DE-298P, DE-298 - */ - case ED_TYPE98_EGY: - /* - * MELCO EGY-98 - * Contec C-NET(98)E-A, C-NET(98)L-A - */ - case ED_TYPE98_108: - /* - * NEC PC-9801-107,108 - */ - case ED_TYPE98_NC5098: - /* - * NextCom NC5098 - */ - error = ed98_probe_Novell(dev, 0, flags); - break; - - /* - * other boards with special probe routine - */ - case ED_TYPE98_SIC: - /* - * Allied Telesis SIC-98 - */ - error = ed_probe_SIC98(dev, 0, flags); - break; - - case ED_TYPE98_CNET98EL: - /* - * Contec C-NET(98)E/L - */ - error = ed_probe_CNET98EL(dev, 0, flags); - break; - - case ED_TYPE98_CNET98: - /* - * Contec C-NET(98) - */ - error = ed_probe_CNET98(dev, 0, flags); - break; - - case ED_TYPE98_LA98: - /* - * IO-DATA LA/T-98 - * NEC PC-9801-77,78 - */ - error = ed_probe_NEC77(dev, 0, flags); - break; - - case ED_TYPE98_NW98X: - /* - * Networld EC/EP-98X - */ - error = ed_probe_NW98X(dev, 0, flags); - break; - - case ED_TYPE98_SB98: - /* - * Soliton SB-9801 - * Fujikura FN-9801 - */ - error = ed_probe_SB98(dev, 0, flags); - break; - } - -end: -#ifdef ED_DEBUG - device_printf(dev, "ed_cbus_probe: end, error=%d\n", error); -#endif - if (error == 0) - error = ed_alloc_irq(dev, 0, 0); - - ed_release_resources(dev); - return (error); -} - -static int -ed_cbus_attach(dev) - device_t dev; -{ - struct ed_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); - int error; - - if (sc->port_used > 0) { - if (ED_TYPE98(flags) == ED_TYPE98_GENERIC) - ed_alloc_port(dev, 0, sc->port_used); - else - ed98_alloc_port(dev, 0); - } - if (sc->mem_used) - ed_alloc_memory(dev, 0, sc->mem_used); - - ed_alloc_irq(dev, 0, 0); - - if (sc->sc_media_ioctl == NULL) - ed_gen_ifmedia_init(sc); - error = ed_attach(dev); - if (error) { - ed_release_resources(dev); - return (error); - } - error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, edintr, sc, &sc->irq_handle); - if (error) - ed_release_resources(dev); - return (error); -} - -/* - * Interrupt conversion table for EtherEZ98 - */ -static uint16_t ed_EZ98_intr_val[] = { - 0, - 3, - 5, - 6, - 0, - 9, - 12, - 13 -}; - -static int -ed_probe_EZ98(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - static unsigned short *intr_vals[] = {NULL, ed_EZ98_intr_val}; - - error = ed_alloc_port(dev, port_rid, ED_EZ98_IO_PORTS); - if (error) { - return (error); - } - - sc->asic_offset = ED_EZ98_ASIC_OFFSET; - sc->nic_offset = ED_EZ98_NIC_OFFSET; - - return ed_probe_WD80x3_generic(dev, flags, intr_vals); -} - -/* - * I/O conversion tables - */ - -/* LGY-98, ICM, C-NET(98)E/L */ -static bus_addr_t ed98_ioaddr_generic[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 -}; - -/* - * Definitions for Contec C-NET(98)E/L - */ -#define ED_CNET98EL_ICR 2 /* Interrupt Configuration Register */ - -#define ED_CNET98EL_ICR_IRQ3 0x01 -#define ED_CNET98EL_ICR_IRQ5 0x02 -#define ED_CNET98EL_ICR_IRQ6 0x04 -#define ED_CNET98EL_ICR_IRQ12 0x20 - -#define ED_CNET98EL_IMR 4 /* Interrupt Mask Register */ -#define ED_CNET98EL_ISR 5 /* Interrupt Status Register */ - -/* EGY-98 */ -static bus_addr_t ed98_ioaddr_egy98[] = { - 0, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, - 0x100, 0x102, 0x104, 0x106, 0x108, 0x10a, 0x10c, 0x10e -}; - -/* SIC-98 */ -static bus_addr_t ed98_ioaddr_sic98[] = { - 0x0000, 0x0200, 0x0400, 0x0600, 0x0800, 0x0a00, 0x0c00, 0x0e00, - 0x1000, 0x1200, 0x1400, 0x1600, 0x1800, 0x1a00, 0x1c00, 0x1e00 -}; - -/* LA/T-98, LD-BDN, PC-9801-77, SB-9801 */ -static bus_addr_t ed98_ioaddr_la98[] = { - 0x0000, 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0x7000, - 0x8000, 0x9000, 0xa000, 0xb000, 0xc000, 0xd000, 0xe000, 0xf000, - 0x0100 /* for NEC 77(see below) */ -}; - -/* - * Definitions for NEC PC-9801-77 - */ -#define ED_NEC77_IRQ 16 /* Interrupt Configuration Register */ - -#define ED_NEC77_IRQ3 0x04 -#define ED_NEC77_IRQ5 0x06 -#define ED_NEC77_IRQ6 0x08 -#define ED_NEC77_IRQ12 0x0a -#define ED_NEC77_IRQ13 0x02 - -/* - * Definitions for Soliton SB-9801 - */ -#define ED_SB98_CFG 1 /* Board configuration */ - -#define ED_SB98_CFG_IRQ3 0x00 -#define ED_SB98_CFG_IRQ5 0x04 -#define ED_SB98_CFG_IRQ6 0x08 -#define ED_SB98_CFG_IRQ12 0x0c -#define ED_SB98_CFG_ALTPORT 0x40 /* use EXTERNAL media */ -#define ED_SB98_CFG_ENABLE 0xa0 /* enable configuration */ - -#define ED_SB98_EEPENA 2 /* EEPROM access enable */ - -#define ED_SB98_EEPENA_DISABLE 0x00 -#define ED_SB98_EEPENA_ENABLE 0x01 - -#define ED_SB98_EEP 3 /* EEPROM access */ - -#define ED_SB98_EEP_SDA 0x01 /* Serial Data */ -#define ED_SB98_EEP_SCL 0x02 /* Serial Clock */ -#define ED_SB98_EEP_READ 0x01 /* Read Command */ - -#define ED_SB98_EEP_DELAY 300 - -#define ED_SB98_ADDRESS 0x01 /* Station Address(1-6) */ - -#define ED_SB98_POLARITY 4 /* Polarity */ - -/* PC-9801-108 */ -static bus_addr_t ed98_ioaddr_nec108[] = { - 0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000a, 0x000c, 0x000e, - 0x1000, 0x1002, 0x1004, 0x1006, 0x1008, 0x100a, 0x100c, 0x100e -}; - -/* C-NET(98) */ -static bus_addr_t ed98_ioaddr_cnet98[] = { - 0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000a, 0x000c, 0x000e, - 0x0400, 0x0402, 0x0404, 0x0406, 0x0408, 0x040a, 0x040c, 0x040e -}; - -/* - * Definitions for Contec C-NET(98) - */ -#define ED_CNET98_MAP_REG0L 0 /* MAPPING register0 Low */ -#define ED_CNET98_MAP_REG1L 1 /* MAPPING register1 Low */ -#define ED_CNET98_MAP_REG2L 2 /* MAPPING register2 Low */ -#define ED_CNET98_MAP_REG3L 3 /* MAPPING register3 Low */ -#define ED_CNET98_MAP_REG0H 4 /* MAPPING register0 Hi */ -#define ED_CNET98_MAP_REG1H 5 /* MAPPING register1 Hi */ -#define ED_CNET98_MAP_REG2H 6 /* MAPPING register2 Hi */ -#define ED_CNET98_MAP_REG3H 7 /* MAPPING register3 Hi */ -#define ED_CNET98_WIN_REG 8 /* Window register */ -#define ED_CNET98_INT_LEV 9 /* Init level register */ - -#define ED_CNET98_INT_IRQ3 0x01 /* INT 0 */ -#define ED_CNET98_INT_IRQ5 0x02 /* INT 1 */ -#define ED_CNET98_INT_IRQ6 0x04 /* INT 2 */ -#define ED_CNET98_INT_IRQ9 0x08 /* INT 3 */ -#define ED_CNET98_INT_IRQ12 0x20 /* INT 5 */ -#define ED_CNET98_INT_IRQ13 0x40 /* INT 6 */ - -#define ED_CNET98_INT_REQ 10 /* Init request register */ -#define ED_CNET98_INT_MASK 11 /* Init mask register */ -#define ED_CNET98_INT_STAT 12 /* Init status register */ -#define ED_CNET98_INT_CLR 12 /* Init clear register */ -#define ED_CNET98_RESERVE1 13 -#define ED_CNET98_RESERVE2 14 -#define ED_CNET98_RESERVE3 15 - -/* EC/EP-98X, NC5098 */ -static bus_addr_t ed98_ioaddr_nw98x[] = { - 0x0000, 0x0100, 0x0200, 0x0300, 0x0400, 0x0500, 0x0600, 0x0700, - 0x0800, 0x0900, 0x0a00, 0x0b00, 0x0c00, 0x0d00, 0x0e00, 0x0f00, - 0x1000 /* for EC/EP-98X(see below) */ -}; - -/* - * Definitions for Networld EC/EP-98X - */ -#define ED_NW98X_IRQ 16 /* Interrupt Configuration Register */ - -#define ED_NW98X_IRQ3 0x04 -#define ED_NW98X_IRQ5 0x06 -#define ED_NW98X_IRQ6 0x08 -#define ED_NW98X_IRQ12 0x0a -#define ED_NW98X_IRQ13 0x02 - -/* NC5098 ASIC */ -static bus_addr_t ed98_asic_nc5098[] = { -/* DATA ENADDR RESET */ - 0x0000, 0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x4000, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* - * Definitions for NextCom NC5098 - */ -#define ED_NC5098_ENADDR 1 /* Station Address(1-6) */ - -/* - * Allocate a port resource with the given resource id. - */ -static int -ed98_alloc_port(device_t dev, int rid) -{ - struct ed_softc *sc = device_get_softc(dev); - struct resource *res; - int error; - bus_addr_t *io_nic, *io_asic, adj; - static bus_addr_t io_res[ED_NOVELL_IO_PORTS + 1]; - int i, n; - int offset, reset, data; - - /* Set i/o table for resource manager */ - io_nic = io_asic = ed98_ioaddr_generic; - offset = ED_NOVELL_ASIC_OFFSET; - reset = ED_NOVELL_RESET; - data = ED_NOVELL_DATA; - n = ED_NOVELL_IO_PORTS; - - switch (sc->type) { - case ED_TYPE98_LGY: - io_asic = ed98_ioaddr_egy98; /* XXX - Yes, we use egy98 */ - offset = 0x0200; - reset = 8; - break; - - case ED_TYPE98_EGY: - io_nic = io_asic = ed98_ioaddr_egy98; - offset = 0x0200; - reset = 8; - break; - - case ED_TYPE98_ICM: - offset = 0x0100; - break; - - case ED_TYPE98_BDN: - io_nic = io_asic = ed98_ioaddr_la98; - offset = 0x0100; - reset = 0x0c; - break; - - case ED_TYPE98_SIC: - io_nic = io_asic = ed98_ioaddr_sic98; - offset = 0x2000; - n = 16+1; - break; - - case ED_TYPE98_108: - io_nic = io_asic = ed98_ioaddr_nec108; - offset = 0x0888; /* XXX - overwritten after */ - reset = 1; - n = 16; /* XXX - does not set ASIC i/o here */ - break; - - case ED_TYPE98_LA98: - io_nic = io_asic = ed98_ioaddr_la98; - offset = 0x0100; - break; - - case ED_TYPE98_CNET98EL: - offset = 0x0400; - data = 0x0e; - break; - - case ED_TYPE98_CNET98: - /* XXX - Yes, we use generic i/o here */ - offset = 0x0400; - break; - - case ED_TYPE98_NW98X: - io_nic = io_asic = ed98_ioaddr_nw98x; - offset = 0x1000; - break; - - case ED_TYPE98_SB98: - io_nic = io_asic = ed98_ioaddr_la98; - offset = 0x0400; - reset = 7; - break; - - case ED_TYPE98_NC5098: - io_nic = ed98_ioaddr_nw98x; - io_asic = ed98_asic_nc5098; - offset = 0x2000; - reset = 7; - n = 16+8; /* XXX */ - break; - } - - bcopy(io_nic, io_res, sizeof(io_nic[0]) * ED_NOVELL_ASIC_OFFSET); - for (i = ED_NOVELL_ASIC_OFFSET; i < ED_NOVELL_IO_PORTS; i++) - io_res[i] = io_asic[i - ED_NOVELL_ASIC_OFFSET] + offset; - - res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, io_res, n, - RF_ACTIVE); - if (!res) - return (ENOENT); - - sc->port_res = res; - sc->port_used = n; - sc->port_bst = rman_get_bustag(res); - sc->port_bsh = rman_get_bushandle(res); - - /* Re-map i/o table if needed */ - switch (sc->type) { - case ED_TYPE98_LA98: - case ED_TYPE98_NW98X: - io_res[n] = io_asic[n - ED_NOVELL_ASIC_OFFSET] + offset; - n++; - break; - - case ED_TYPE98_108: - adj = (rman_get_start(res) & 0xf000) / 2; - offset = (offset | adj) - rman_get_start(res); - - for (n = ED_NOVELL_ASIC_OFFSET; n < ED_NOVELL_IO_PORTS; n++) - io_res[n] = io_asic[n - ED_NOVELL_ASIC_OFFSET] + offset; - break; - - case ED_TYPE98_CNET98: - io_nic = io_asic = ed98_ioaddr_cnet98; - offset = 1; - - bcopy(io_nic, io_res, sizeof(io_nic[0]) * ED_NOVELL_ASIC_OFFSET); - for (n = ED_NOVELL_ASIC_OFFSET; n < ED_NOVELL_IO_PORTS; n++) - io_res[n] = io_asic[n - ED_NOVELL_ASIC_OFFSET] + offset; - break; - - case ED_TYPE98_NC5098: - n = ED_NOVELL_IO_PORTS; - break; - } - - if (reset != ED_NOVELL_RESET) - io_res[ED_NOVELL_ASIC_OFFSET + ED_NOVELL_RESET] = - io_res[ED_NOVELL_ASIC_OFFSET + reset]; - if (data != ED_NOVELL_DATA) { - io_res[ED_NOVELL_ASIC_OFFSET + ED_NOVELL_DATA] = - io_res[ED_NOVELL_ASIC_OFFSET + data]; -#if 0 - io_res[ED_NOVELL_ASIC_OFFSET + ED_NOVELL_DATA + 1] = - io_res[ED_NOVELL_ASIC_OFFSET + data + 1]; -#endif - } - - error = isa_load_resourcev(res, io_res, n); - if (error != 0) - return (ENOENT); -#ifdef ED_DEBUG - device_printf(dev, "ed98_alloc_port: i/o ports = %d\n", n); - for (i = 0; i < n; i++) - printf("%x,", io_res[i]); - printf("\n"); -#endif - return (0); -} - -static int -ed98_alloc_memory(dev, rid) - device_t dev; - int rid; -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - rman_res_t conf_maddr, conf_msize; - - error = bus_get_resource(dev, SYS_RES_MEMORY, 0, &conf_maddr, - &conf_msize); - if (error) - return (error); - - if ((conf_maddr == 0) || (conf_msize == 0)) - return (ENXIO); - - error = ed_alloc_memory(dev, rid, (int) conf_msize); - if (error) - return (error); - - sc->mem_start = 0; - sc->mem_size = conf_msize; - - return (0); -} - -/* - * Generic probe routine for testing for the existance of a DS8390. - * Must be called after the NIC has just been reset. This routine - * works by looking at certain register values that are guaranteed - * to be initialized a certain way after power-up or reset. Seems - * not to currently work on the 83C690. - * - * Specifically: - * - * Register reset bits set bits - * Command Register (CR) TXP, STA RD2, STP - * Interrupt Status (ISR) RST - * Interrupt Mask (IMR) All bits - * Data Control (DCR) LAS - * Transmit Config. (TCR) LB1, LB0 - * - * XXX - We only check the CR register. - * - * Return 1 if 8390 was found, 0 if not. - */ - -static int -ed98_probe_generic8390(struct ed_softc *sc) -{ - u_char tmp = ed_nic_inb(sc, ED_P0_CR); -#ifdef DIAGNOSTIC - printf("ed?: inb(ED_P0_CR)=%x\n", tmp); -#endif - if ((tmp & (ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) != - (ED_CR_RD2 | ED_CR_STP)) - return (0); - - (void) ed_nic_inb(sc, ED_P0_ISR); - - return (1); -} - -static int -ed98_probe_Novell(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - int n; - u_char romdata[ETHER_ADDR_LEN * 2], tmp; - -#ifdef ED_DEBUG - device_printf(dev, "ed98_probe_Novell: start\n"); -#endif - error = ed98_alloc_port(dev, port_rid); - if (error) - return (error); - - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; - - /* Reset the board */ -#ifdef ED_DEBUG - device_printf(dev, "ed98_probe_Novell: reset\n"); -#endif - switch (sc->type) { -#if 1 /* XXX - I'm not sure this is really necessary... */ - case ED_TYPE98_BDN: - tmp = ed_asic_inb(sc, ED_NOVELL_RESET); - ed_asic_outb(sc, ED_NOVELL_RESET, (tmp & 0xf0) | 0x08); - ed_nic_outb(sc, 0x04, tmp); - (void) ed_asic_inb(sc, 0x08); - ed_asic_outb(sc, 0x08, tmp); - ed_asic_outb(sc, 0x08, tmp & 0x7f); - break; -#endif - case ED_TYPE98_NC5098: - ed_asic_outb(sc, ED_NOVELL_RESET, 0x00); - DELAY(5000); - ed_asic_outb(sc, ED_NOVELL_RESET, 0x01); - break; - - default: - tmp = ed_asic_inb(sc, ED_NOVELL_RESET); - - /* - * I don't know if this is necessary; probably cruft leftover from - * Clarkson packet driver code. Doesn't do a thing on the boards I've - * tested. -DG [note that an outb(0x84, 0) seems to work here, and is - * non-invasive...but some boards don't seem to reset and I don't have - * complete documentation on what the 'right' thing to do is...so we - * do the invasive thing for now. Yuck.] - */ - ed_asic_outb(sc, ED_NOVELL_RESET, tmp); - break; - } - DELAY(5000); - - /* - * This is needed because some NE clones apparently don't reset the - * NIC properly (or the NIC chip doesn't reset fully on power-up) XXX - * - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP); - DELAY(5000); - - /* Make sure that we really have an 8390 based board */ - if (!ed98_probe_generic8390(sc)) - return (ENXIO); - - /* Test memory via PIO */ -#ifdef ED_DEBUG - device_printf(dev, "ed98_probe_Novell: test memory\n"); -#endif - sc->cr_proto = ED_CR_RD2; - if (!ed_pio_testmem(sc, 8192, 0, flags) && - !ed_pio_testmem(sc, 16384, 1, flags)) - return (ENXIO); - - /* Setup the board type */ -#ifdef ED_DEBUG - device_printf(dev, "ed98_probe_Novell: board type\n"); -#endif - switch (sc->type) { - case ED_TYPE98_BDN: - sc->type_str = "LD-BDN"; - break; - case ED_TYPE98_EGY: - sc->type_str = "EGY-98"; - break; - case ED_TYPE98_LGY: - sc->type_str = "LGY-98"; - break; - case ED_TYPE98_ICM: - sc->type_str = "ICM"; - break; - case ED_TYPE98_108: - sc->type_str = "PC-9801-108"; - break; - case ED_TYPE98_LA98: - sc->type_str = "LA-98"; - break; - case ED_TYPE98_NW98X: - sc->type_str = "NW98X"; - break; - case ED_TYPE98_NC5098: - sc->type_str = "NC5098"; - break; - default: - sc->type_str = NULL; - break; - } - - /* Get station address */ - switch (sc->type) { - case ED_TYPE98_NC5098: - for (n = 0; n < ETHER_ADDR_LEN; n++) - sc->enaddr[n] = ed_asic_inb(sc, ED_NC5098_ENADDR + n); - break; - - default: - ed_pio_readmem(sc, 0, romdata, sizeof(romdata)); - for (n = 0; n < ETHER_ADDR_LEN; n++) - sc->enaddr[n] = romdata[n * (sc->isa16bit + 1)]; - break; - } - - /* clear any pending interrupts that might have occurred above */ - ed_nic_outb(sc, ED_P0_ISR, 0xff); - - sc->sc_write_mbufs = ed_pio_write_mbufs; - return (0); -} - -/* - * Probe and vendor-specific initialization routine for SIC-98 boards - */ -static int -ed_probe_SIC98(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - int i; - u_char sum; - - /* - * Setup card RAM and I/O address - * Kernel Virtual to segment C0000-DFFFF???? - */ - error = ed98_alloc_port(dev, port_rid); - if (error) - return (error); - - sc->asic_offset = ED_SIC_ASIC_OFFSET; - sc->nic_offset = ED_SIC_NIC_OFFSET; - - error = ed98_alloc_memory(dev, 0); - if (error) - return (error); - - /* Reset card to force it into a known state. */ - ed_asic_outb(sc, 0, 0x00); - DELAY(100); - if (ED_TYPE98SUB(flags) == 0) { - /* SIC-98/SIU-98 */ - ed_asic_outb(sc, 0, 0x94); - DELAY(100); - ed_asic_outb(sc, 0, 0x94); - } else { - /* SIU-98-D */ - ed_asic_outb(sc, 0, 0x80); - DELAY(100); - ed_asic_outb(sc, 0, 0x94); - DELAY(100); - ed_asic_outb(sc, 0, 0x9e); - } - DELAY(100); - - /* - * Here we check the card ROM, if the checksum passes, and the - * type code and ethernet address check out, then we know we have - * an SIC card. - */ - sum = bus_space_read_1(sc->mem_bst, sc->mem_bsh, 6 * 2); - for (i = 0; i < ETHER_ADDR_LEN; i++) - sum ^= (sc->enaddr[i] = - bus_space_read_1(sc->mem_bst, sc->mem_bsh, i * 2)); -#ifdef ED_DEBUG - device_printf(dev, "ed_probe_sic98: got address %6D\n", - sc->enaddr, ":"); -#endif - if (sum != 0) - return (ENXIO); - if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0) - return (ENXIO); - - sc->vendor = ED_VENDOR_SIC; - sc->type_str = "SIC98"; - sc->isa16bit = 1; - sc->cr_proto = 0; - - /* - * SIC RAM page 0x0000-0x3fff(or 0x7fff) - */ - if (ED_TYPE98SUB(flags) == 0) - ed_asic_outb(sc, 0, 0x90); - else - ed_asic_outb(sc, 0, 0x8e); - DELAY(100); - - error = ed_clear_memory(dev); - if (error) - return (error); - - sc->mem_shared = 1; - sc->mem_end = sc->mem_start + sc->mem_size; - - /* - * allocate one xmit buffer if < 16k, two buffers otherwise - */ - if ((sc->mem_size < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING)) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - sc->tx_page_start = 0; - - sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE * sc->txb_cnt; - sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE; - - sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; - - sc->sc_write_mbufs = ed_shmem_write_mbufs; - return (0); -} - -/* - * Contec C-NET(98) series support routines - */ -static void -ed_reset_CNET98(struct ed_softc *sc, int flags) -{ - u_int init_addr = ED_CNET98_INIT; - u_char tmp; - - /* Choose initial register address */ - if (ED_TYPE98SUB(flags) != 0) { - init_addr = ED_CNET98_INIT2; - } -#ifdef ED_DEBUG - printf("ed?: initial register=%x\n", init_addr); -#endif - /* - * Reset the board to force it into a known state. - */ - outb(init_addr, 0x00); /* request */ - DELAY(5000); - outb(init_addr, 0x01); /* cancel */ - DELAY(5000); - - /* - * Set I/O address(A15-12) and cpu type - * - * AAAAIXXC(8bit) - * AAAA: A15-A12, I: I/O enable, XX: reserved, C: CPU type - * - * CPU type is 1:80286 or higher, 0:not. - * But FreeBSD runs under i386 or higher, thus it must be 1. - */ - tmp = (rman_get_start(sc->port_res) & 0xf000) >> 8; - tmp |= (0x08 | 0x01); -#ifdef ED_DEBUG - printf("ed?: outb(%x, %x)\n", init_addr + 2, tmp); -#endif - outb(init_addr + 2, tmp); - DELAY(5000); - - /* - * This is needed because some NE clones apparently don't reset the - * NIC properly (or the NIC chip doesn't reset fully on power-up) XXX - * - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP); - DELAY(5000); -} - -static void -ed_winsel_CNET98(struct ed_softc *sc, u_short bank) -{ - u_char mem = (rman_get_start(sc->mem_res) >> 12) & 0xff; - - /* - * Disable window memory - * bit7 is 0:disable - */ - ed_asic_outb(sc, ED_CNET98_WIN_REG, mem & 0x7f); - DELAY(10); - - /* - * Select window address - * FreeBSD address 0xf00xxxxx - */ - ed_asic_outb(sc, ED_CNET98_MAP_REG0L, bank & 0xff); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG0H, (bank >> 8) & 0xff); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG1L, 0x00); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG1H, 0x41); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG2L, 0x00); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG2H, 0x42); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG3L, 0x00); - DELAY(10); - ed_asic_outb(sc, ED_CNET98_MAP_REG3H, 0x43); - DELAY(10); - - /* - * Enable window memory(16Kbyte) - * bit7 is 1:enable - */ -#ifdef ED_DEBUG - printf("ed?: window start address=%x\n", mem); -#endif - ed_asic_outb(sc, ED_CNET98_WIN_REG, mem); - DELAY(10); -} - -/* - * Probe and vendor-specific initialization routine for C-NET(98) boards - */ -static int -ed_probe_CNET98(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - u_char tmp; - rman_res_t conf_irq, junk; -#ifdef DIAGNOSTIC - u_char tmp_s; -#endif - - error = ed98_alloc_port(dev, port_rid); - if (error) - return (error); - - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; - - error = ed98_alloc_memory(dev, 0); - if (error) - return (error); - - /* Check I/O address. 0x[a-f]3d0 are allowed. */ - if (((rman_get_start(sc->port_res) & 0x0fff) != 0x03d0) - || ((rman_get_start(sc->port_res) & 0xf000) < (u_short) 0xa000)) { -#ifdef DIAGNOSTIC - device_printf(dev, "Invalid i/o port configuration (0x%jx) " - "must be %s for %s\n", rman_get_start(sc->port_res), - "0x[a-f]3d0", "CNET98"); -#endif - return (ENXIO); - } - -#ifdef DIAGNOSTIC - /* Check window area address */ - tmp_s = rman_get_start(sc->mem_res) >> 12; - if (tmp_s < 0x80) { - device_printf(dev, "Please change window address(0x%jx)\n", - rman_get_start(sc->mem_res)); - return (ENXIO); - } - - tmp_s &= 0x0f; - tmp = rman_get_start(sc->port_res) >> 12; - if ((tmp_s <= tmp) && (tmp < (tmp_s + 4))) { - device_printf(dev, "Please change iobase address(0x%jx) " - "or window address(0x%jx)\n", - rman_get_start(sc->port_res), - rman_get_start(sc->mem_res)); - return (ENXIO); - } -#endif - /* Reset the board */ - ed_reset_CNET98(sc, flags); - - /* - * This is needed because some NE clones apparently don't reset the - * NIC properly (or the NIC chip doesn't reset fully on power-up) XXX - * - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP); - DELAY(5000); - - /* Make sure that we really have an 8390 based board */ - if (!ed98_probe_generic8390(sc)) - return (ENXIO); - - /* - * Set window ethernet address area - * board memory base 0x480000 data 256byte - */ - ed_winsel_CNET98(sc, 0x4800); - - /* - * Get station address from on-board ROM - */ - bus_space_read_region_1(sc->mem_bst, sc->mem_bsh, sc->mem_start, - sc->enaddr, ETHER_ADDR_LEN); - - sc->vendor = ED_VENDOR_MISC; - sc->type_str = "CNET98"; - sc->isa16bit = 0; - sc->cr_proto = ED_CR_RD2; - - /* - * Set window buffer memory area - * board memory base 0x400000 data 16kbyte - */ - ed_winsel_CNET98(sc, 0x4000); - - error = ed_clear_memory(dev); - if (error) - return (error); - - sc->mem_shared = 1; - sc->mem_end = sc->mem_start + sc->mem_size; - - sc->txb_cnt = 1; /* XXX */ - sc->tx_page_start = 0; - - sc->rec_page_start = sc->tx_page_start + ED_TXBUF_SIZE; - sc->rec_page_stop = sc->tx_page_start + sc->mem_size / ED_PAGE_SIZE; - - sc->mem_ring = sc->mem_start + ED_PAGE_SIZE * ED_TXBUF_SIZE; - - /* - * Set interrupt level - */ - error = bus_get_resource(dev, SYS_RES_IRQ, 0, &conf_irq, &junk); - if (error) - return (error); - - switch (conf_irq) { - case 3: - tmp = ED_CNET98_INT_IRQ3; - break; - case 5: - tmp = ED_CNET98_INT_IRQ5; - break; - case 6: - tmp = ED_CNET98_INT_IRQ6; - break; - case 9: - tmp = ED_CNET98_INT_IRQ9; - break; - case 12: - tmp = ED_CNET98_INT_IRQ12; - break; - case 13: - tmp = ED_CNET98_INT_IRQ13; - break; - default: - device_printf(dev, "Invalid irq configuration (%jd) must be " - "%s for %s\n", conf_irq, "3,5,6,9,12,13", "CNET98"); - return (ENXIO); - } - ed_asic_outb(sc, ED_CNET98_INT_LEV, tmp); - DELAY(1000); - /* - * Set interrupt mask. - * bit7:1 all interrupt mask - * bit1:1 timer interrupt mask - * bit0:0 NS controler interrupt enable - */ - ed_asic_outb(sc, ED_CNET98_INT_MASK, 0x7e); - DELAY(1000); - - sc->sc_write_mbufs = ed_shmem_write_mbufs; - return (0); -} - -/* - * Probe and vendor-specific initialization routine for C-NET(98)E/L boards - */ -static int -ed_probe_CNET98EL(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - int i; - u_char romdata[ETHER_ADDR_LEN * 2], tmp; - rman_res_t conf_irq, junk; - - error = ed98_alloc_port(dev, port_rid); - if (error) - return (error); - - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; - - /* Check I/O address. 0x[0-f]3d0 are allowed. */ - if ((rman_get_start(sc->port_res) & 0x0fff) != 0x03d0) { -#ifdef DIAGNOSTIC - device_printf(dev, "Invalid i/o port configuration (0x%jx) " - "must be %s for %s\n", rman_get_start(sc->port_res), - "0x?3d0", "CNET98E/L"); -#endif - return (ENXIO); - } - - /* Reset the board */ - ed_reset_CNET98(sc, flags); - - /* - * This is needed because some NE clones apparently don't reset the - * NIC properly (or the NIC chip doesn't reset fully on power-up) XXX - * - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP); - DELAY(5000); - - /* Make sure that we really have an 8390 based board */ - if (!ed98_probe_generic8390(sc)) - return (ENXIO); - - /* Test memory via PIO */ - sc->cr_proto = ED_CR_RD2; - if (!ed_pio_testmem(sc, ED_CNET98EL_PAGE_OFFSET, 1, flags)) - return (ENXIO); - - /* This looks like a C-NET(98)E/L board. */ - sc->type_str = "CNET98E/L"; - - /* - * Set IRQ. C-NET(98)E/L only allows a choice of irq 3,5,6. - */ - error = bus_get_resource(dev, SYS_RES_IRQ, 0, &conf_irq, &junk); - if (error) - return (error); - - switch (conf_irq) { - case 3: - tmp = ED_CNET98EL_ICR_IRQ3; - break; - case 5: - tmp = ED_CNET98EL_ICR_IRQ5; - break; - case 6: - tmp = ED_CNET98EL_ICR_IRQ6; - break; -#if 0 - case 12: - tmp = ED_CNET98EL_ICR_IRQ12; - break; -#endif - default: - device_printf(dev, "Invalid irq configuration (%jd) must be " - "%s for %s\n", conf_irq, "3,5,6", "CNET98E/L"); - return (ENXIO); - } - ed_asic_outb(sc, ED_CNET98EL_ICR, tmp); - ed_asic_outb(sc, ED_CNET98EL_IMR, 0x7e); - - /* Get station address from on-board ROM */ - ed_pio_readmem(sc, 16384, romdata, sizeof(romdata)); - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->enaddr[i] = romdata[i * 2]; - - /* clear any pending interrupts that might have occurred above */ - ed_nic_outb(sc, ED_P0_ISR, 0xff); - - sc->sc_write_mbufs = ed_pio_write_mbufs; - return (0); -} - -/* - * Probe and vendor-specific initialization routine for PC-9801-77 boards - */ -static int -ed_probe_NEC77(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - u_char tmp; - rman_res_t conf_irq, junk; - - error = ed98_probe_Novell(dev, port_rid, flags); - if (error) - return (error); - - /* LA/T-98 does not need IRQ setting. */ - if (ED_TYPE98SUB(flags) == 0) - return (0); - - /* - * Set IRQ. PC-9801-77 only allows a choice of irq 3,5,6,12,13. - */ - error = bus_get_resource(dev, SYS_RES_IRQ, 0, &conf_irq, &junk); - if (error) - return (error); - - switch (conf_irq) { - case 3: - tmp = ED_NEC77_IRQ3; - break; - case 5: - tmp = ED_NEC77_IRQ5; - break; - case 6: - tmp = ED_NEC77_IRQ6; - break; - case 12: - tmp = ED_NEC77_IRQ12; - break; - case 13: - tmp = ED_NEC77_IRQ13; - break; - default: - device_printf(dev, "Invalid irq configuration (%jd) must be " - "%s for %s\n", conf_irq, "3,5,6,12,13", "PC-9801-77"); - return (ENXIO); - } - ed_asic_outb(sc, ED_NEC77_IRQ, tmp); - - return (0); -} - -/* - * Probe and vendor-specific initialization routine for EC/EP-98X boards - */ -static int -ed_probe_NW98X(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - u_char tmp; - rman_res_t conf_irq, junk; - - error = ed98_probe_Novell(dev, port_rid, flags); - if (error) - return (error); - - /* Networld 98X3 does not need IRQ setting. */ - if (ED_TYPE98SUB(flags) == 0) - return (0); - - /* - * Set IRQ. EC/EP-98X only allows a choice of irq 3,5,6,12,13. - */ - error = bus_get_resource(dev, SYS_RES_IRQ, 0, &conf_irq, &junk); - if (error) - return (error); - - switch (conf_irq) { - case 3: - tmp = ED_NW98X_IRQ3; - break; - case 5: - tmp = ED_NW98X_IRQ5; - break; - case 6: - tmp = ED_NW98X_IRQ6; - break; - case 12: - tmp = ED_NW98X_IRQ12; - break; - case 13: - tmp = ED_NW98X_IRQ13; - break; - default: - device_printf(dev, "Invalid irq configuration (%jd) must be " - "%s for %s\n", conf_irq, "3,5,6,12,13", "EC/EP-98X"); - return (ENXIO); - } - ed_asic_outb(sc, ED_NW98X_IRQ, tmp); - - return (0); -} - -/* - * Read SB-9801 station address from Serial Two-Wire EEPROM - */ -static void -ed_get_SB98(struct ed_softc *sc) -{ - int i, j; - u_char mask, val; - - /* enable EEPROM acceess */ - ed_asic_outb(sc, ED_SB98_EEPENA, ED_SB98_EEPENA_ENABLE); - - /* output start command */ - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SDA | ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - - /* output address (7bit) */ - for (mask = 0x40; mask != 0; mask >>= 1) { - val = 0; - if (ED_SB98_ADDRESS & mask) - val = ED_SB98_EEP_SDA; - ed_asic_outb(sc, ED_SB98_EEP, val); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, val | ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - } - - /* output READ command */ - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_READ); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_READ | ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - - /* read station address */ - for (i = 0; i < ETHER_ADDR_LEN; i++) { - /* output ACK */ - ed_asic_outb(sc, ED_SB98_EEP, 0); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - - val = 0; - for (j = 0; j < 8; j++) { - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SDA); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SDA | ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - val <<= 1; - val |= (ed_asic_inb(sc, ED_SB98_EEP) & ED_SB98_EEP_SDA); - DELAY(ED_SB98_EEP_DELAY); - } - sc->enaddr[i] = val; - } - - /* output Last ACK */ - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SDA); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SDA | ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - - /* output stop command */ - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - ed_asic_outb(sc, ED_SB98_EEP, ED_SB98_EEP_SDA | ED_SB98_EEP_SCL); - DELAY(ED_SB98_EEP_DELAY); - - /* disable EEPROM access */ - ed_asic_outb(sc, ED_SB98_EEPENA, ED_SB98_EEPENA_DISABLE); -} - -/* - * Probe and vendor-specific initialization routine for SB-9801 boards - */ -static int -ed_probe_SB98(device_t dev, int port_rid, int flags) -{ - struct ed_softc *sc = device_get_softc(dev); - int error; - u_char tmp; - rman_res_t conf_irq, junk; - - error = ed98_alloc_port(dev, port_rid); - if (error) - return (error); - - sc->asic_offset = ED_NOVELL_ASIC_OFFSET; - sc->nic_offset = ED_NOVELL_NIC_OFFSET; - - /* Check I/O address. 00d[02468ace] are allowed. */ - if ((rman_get_start(sc->port_res) & ~0x000e) != 0x00d0) { -#ifdef DIAGNOSTIC - device_printf(dev, "Invalid i/o port configuration (0x%jx) " - "must be %s for %s\n", rman_get_start(sc->port_res), - "0xd?", "SB9801"); -#endif - return (ENXIO); - } - - /* Write I/O port address and read 4 times */ - outb(ED_SB98_IO_INHIBIT, rman_get_start(sc->port_res) & 0xff); - (void) inb(ED_SB98_IO_INHIBIT); DELAY(300); - (void) inb(ED_SB98_IO_INHIBIT); DELAY(300); - (void) inb(ED_SB98_IO_INHIBIT); DELAY(300); - (void) inb(ED_SB98_IO_INHIBIT); DELAY(300); - - /* - * Check IRQ. Soliton SB-9801 only allows a choice of - * irq 3,5,6,12 - */ - error = bus_get_resource(dev, SYS_RES_IRQ, 0, &conf_irq, &junk); - if (error) - return (error); - - switch (conf_irq) { - case 3: - tmp = ED_SB98_CFG_IRQ3; - break; - case 5: - tmp = ED_SB98_CFG_IRQ5; - break; - case 6: - tmp = ED_SB98_CFG_IRQ6; - break; - case 12: - tmp = ED_SB98_CFG_IRQ12; - break; - default: - device_printf(dev, "Invalid irq configuration (%jd) must be " - "%s for %s\n", conf_irq, "3,5,6,12", "SB9801"); - return (ENXIO); - } - - if (flags & ED_FLAGS_DISABLE_TRANCEIVER) - tmp |= ED_SB98_CFG_ALTPORT; - ed_asic_outb(sc, ED_SB98_CFG, ED_SB98_CFG_ENABLE | tmp); - ed_asic_outb(sc, ED_SB98_POLARITY, 0x01); - - /* Reset the board. */ - ed_asic_outb(sc, ED_NOVELL_RESET, 0x7a); - DELAY(300); - ed_asic_outb(sc, ED_NOVELL_RESET, 0x79); - DELAY(300); - - /* - * This is needed because some NE clones apparently don't reset the - * NIC properly (or the NIC chip doesn't reset fully on power-up) XXX - * - this makes the probe invasive! ...Done against my better - * judgement. -DLG - */ - ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP); - DELAY(5000); - - /* Make sure that we really have an 8390 based board */ - if (!ed98_probe_generic8390(sc)) - return (ENXIO); - - /* Test memory via PIO */ - sc->cr_proto = ED_CR_RD2; - if (!ed_pio_testmem(sc, 16384, 1, flags)) - return (ENXIO); - - /* This looks like an SB9801 board. */ - sc->type_str = "SB9801"; - - /* Get station address */ - ed_get_SB98(sc); - - /* clear any pending interrupts that might have occurred above */ - ed_nic_outb(sc, ED_P0_ISR, 0xff); - - sc->sc_write_mbufs = ed_pio_write_mbufs; - return (0); -} - -/* - * Test the ability to read and write to the NIC memory. - */ -static int -ed_pio_testmem(struct ed_softc *sc, int page_offset, int isa16bit, int flags) -{ - u_long memsize; - static char test_pattern[32] = "THIS is A memory TEST pattern"; - char test_buffer[32]; -#ifdef DIAGNOSTIC - int page_end; -#endif - - sc->vendor = ED_VENDOR_NOVELL; - sc->mem_shared = 0; - sc->isa16bit = isa16bit; - - /* 8k of memory plus an additional 8k if 16bit */ - memsize = (isa16bit ? 16384 : 8192); - - /* - * This prevents packets from being stored in the NIC memory when the - * readmem routine turns on the start bit in the CR. - */ - ed_nic_outb(sc, ED_P0_RCR, ED_RCR_MON); - - /* Initialize DCR for byte/word operations */ - if (isa16bit) - ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS); - else - ed_nic_outb(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS); - ed_nic_outb(sc, ED_P0_PSTART, page_offset / ED_PAGE_SIZE); - ed_nic_outb(sc, ED_P0_PSTOP, (page_offset + memsize) / ED_PAGE_SIZE); -#ifdef ED_DEBUG - printf("ed?: ed_pio_testmem: page start=%x, end=%lx", - page_offset, page_offset + memsize); -#endif - - /* - * Write a test pattern. If this fails, then we don't know - * what this board is. - */ - ed_pio_writemem(sc, test_pattern, page_offset, sizeof(test_pattern)); - ed_pio_readmem(sc, page_offset, test_buffer, sizeof(test_pattern)); - - if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) { -#ifdef ED_DEBUG - printf("ed?: ed_pio_testmem: bcmp(page %x) NG", page_offset); -#endif - return (0); - } - -#ifdef DIAGNOSTIC - /* Check the bottom. */ - page_end = page_offset + memsize - ED_PAGE_SIZE; - ed_pio_writemem(sc, test_pattern, page_end, sizeof(test_pattern)); - ed_pio_readmem(sc, page_end, test_buffer, sizeof(test_pattern)); - - if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) { -#ifdef ED_DEBUG - printf("ed?: ed_pio_testmem: bcmp(page %x) NG", page_end); -#endif - return (0); - } -#endif - sc->mem_size = memsize; - sc->mem_start = page_offset; - sc->mem_end = sc->mem_start + memsize; - sc->tx_page_start = page_offset / ED_PAGE_SIZE; - - /* - * Use one xmit buffer if < 16k, two buffers otherwise (if not told - * otherwise). - */ - if ((memsize < 16384) || (flags & ED_FLAGS_NO_MULTI_BUFFERING)) - sc->txb_cnt = 1; - else - sc->txb_cnt = 2; - - sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE; - sc->rec_page_stop = sc->tx_page_start + memsize / ED_PAGE_SIZE; - - sc->mem_ring = sc->mem_start + sc->txb_cnt * ED_PAGE_SIZE * ED_TXBUF_SIZE; - - return (1); -} - -static device_method_t ed_cbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, ed_cbus_probe), - DEVMETHOD(device_attach, ed_cbus_attach), - DEVMETHOD(device_detach, ed_detach), - - { 0, 0 } -}; - -static driver_t ed_cbus_driver = { - "ed", - ed_cbus_methods, - sizeof(struct ed_softc) -}; - -DRIVER_MODULE(ed, isa, ed_cbus_driver, ed_devclass, 0, 0); -MODULE_DEPEND(ed, isa, 1, 1, 1); -MODULE_DEPEND(ed, ether, 1, 1, 1); diff --git a/sys/dev/ep/if_ep_isa.c b/sys/dev/ep/if_ep_isa.c index e125daf101fd0..7bcb3d410057b 100644 --- a/sys/dev/ep/if_ep_isa.c +++ b/sys/dev/ep/if_ep_isa.c @@ -76,10 +76,6 @@ const char *ep_isa_match_id(uint32_t, struct isa_ident *); #define ISA_ID_3C509_COMBO 0x506d5094 #define ISA_ID_3C509_TPO 0x506d5095 #define ISA_ID_3C509_TPC 0x506d5098 -#ifdef PC98 -#define ISA_ID_3C569B_COMBO 0x506d5694 -#define ISA_ID_3C569B_TPO 0x506d5695 -#endif #ifdef __i386__ static struct isa_ident ep_isa_devs[] = { @@ -88,10 +84,6 @@ static struct isa_ident ep_isa_devs[] = { {ISA_ID_3C509_COMBO, "3Com 3C509-Combo EtherLink III"}, {ISA_ID_3C509_TPO, "3Com 3C509-TPO EtherLink III"}, {ISA_ID_3C509_TPC, "3Com 3C509-TPC EtherLink III"}, -#ifdef PC98 - {ISA_ID_3C569B_COMBO, "3Com 3C569B-J-Combo EtherLink III"}, - {ISA_ID_3C569B_TPO, "3Com 3C569B-J-TPO EtherLink III"}, -#endif {0, NULL}, }; #endif @@ -224,11 +216,7 @@ ep_isa_identify(driver_t * driver, device_t parent) /* Retreive IOPORT */ data = get_eeprom_data(ELINK_ID_PORT, EEPROM_ADDR_CFG); -#ifdef PC98 - ioport = (((data & ADDR_CFG_MASK) * 0x100) + 0x40d0); -#else ioport = (((data & ADDR_CFG_MASK) << 4) + 0x200); -#endif if ((data & ADDR_CFG_MASK) == ADDR_CFG_EISA) { device_printf(parent, diff --git a/sys/dev/exca/excareg.h b/sys/dev/exca/excareg.h index c445efe605834..ecde55a4a1dec 100644 --- a/sys/dev/exca/excareg.h +++ b/sys/dev/exca/excareg.h @@ -417,10 +417,6 @@ #define EXCA_PNP_82365_CARDBUS 0x030ED041 /* PNP0E03 */ #define EXCA_PNP_SCM_SWAPBOX 0x69046d4c /* SMC0469 */ -/* C-Bus PnP Definitions */ -#define EXCA_NEC_PC9801_102 0x9180a3b8 /* NEC8091 PC-9801-102 */ -#define EXCA_NEC_PC9821RA_E01 0x2181a3b8 /* NEC8121 PC-9821RA-E01 */ - /* * Mask of allowable interrupts. * @@ -433,20 +429,7 @@ * NT had a special device that would probe for conflicts early in the * boot process and formulate a mapping table. Maybe we should do * something similar. - * - * For NEC PC-98 machines, irq 3, 5, 6, 9, 10, 11, 12, 13 are allowed. - * These correspond to the C-BUS signals INT 0, 1, 2, 3, 41, 42, 5, 6 - * respectively. - * - * Hiroshi TSUKADA-san writes in FreeBSD98-testers that CBUS INT 2 - * (mapped to IRQ 6) is routed to the IRQ 7 pin of the pcic in pc98 - * cbus add-in cards. He has confirmed this routing with a visual - * inspection of his card or a VOM. */ -#ifdef PC98 -#define EXCA_INT_MASK_ALLOWED 0x3E68 /* PC98 */ -#else #define EXCA_INT_MASK_ALLOWED 0xDEB8 /* AT */ -#endif #endif /* !_SYS_DEV_EXCA_EXCAREG_H */ diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c index 183abdc3bfcb3..169dacc77360e 100644 --- a/sys/dev/fb/fb.c +++ b/sys/dev/fb/fb.c @@ -530,7 +530,6 @@ static char { KD_CGA, "CGA" }, { KD_EGA, "EGA" }, { KD_VGA, "VGA" }, - { KD_PC98, "PC-98x1" }, { KD_TGA, "TGA" }, { -1, "Unknown" }, }; @@ -605,7 +604,6 @@ fb_type(int adp_type) { FBTYPE_CGA, KD_CGA }, { FBTYPE_EGA, KD_EGA }, { FBTYPE_VGA, KD_VGA }, - { FBTYPE_PC98, KD_PC98 }, { FBTYPE_TGA, KD_TGA }, }; int i; diff --git a/sys/dev/fb/splash_bmp.c b/sys/dev/fb/splash_bmp.c index 517a3efd73f3f..719725ee0fe66 100644 --- a/sys/dev/fb/splash_bmp.c +++ b/sys/dev/fb/splash_bmp.c @@ -36,11 +36,9 @@ #include <dev/fb/fbreg.h> #include <dev/fb/splashreg.h> -#ifndef PC98 #include <dev/fb/vgareg.h> #include <isa/isareg.h> -#endif #define FADE_TIMEOUT 15 /* sec */ #define FADE_LEVELS 10 @@ -65,15 +63,6 @@ bmp_start(video_adapter_t *adp) { /* currently only 256-color modes are supported XXX */ static int modes[] = { -#ifdef PC98 - /* - * As 640x400 doesn't generally look great, - * it's least preferred here. - */ - M_PC98_PEGC640x400, - M_PC98_PEGC640x480, - M_PC98_EGC640x400, -#else M_VESA_CG640x480, M_VESA_CG800x600, M_VESA_CG1024x768, @@ -83,7 +72,6 @@ bmp_start(video_adapter_t *adp) * it's least preferred here. */ M_VGA_CG320, -#endif -1, }; video_info_t info; @@ -239,9 +227,6 @@ typedef struct u_char *vidmem; /* video memory allocated for drawing */ video_adapter_t *adp; int bank; -#ifdef PC98 - u_char prev_val; -#endif } BMP_INFO; static BMP_INFO bmp_info; @@ -273,25 +258,6 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val) x += (info->swidth - info->width) / 2; switch(info->sdepth) { -#ifdef PC98 - case 4: - sofs += (x >> 3); - bofs = x & 0x7; /* offset within byte */ - - outb(0x7c, 0x80 | 0x40); /* GRCG on & RMW mode */ - if (val != info->prev_val) { - outb(0x7e, (val & 1) ? 0xff : 0); /* tile B */ - outb(0x7e, (val & 2) ? 0xff : 0); /* tile R */ - outb(0x7e, (val & 4) ? 0xff : 0); /* tile G */ - outb(0x7e, (val & 8) ? 0xff : 0); /* tile I */ - - info->prev_val = val; - } - - *(info->vidmem+sofs) = (0x80 >> bofs); /* write new bit */ - outb(0x7c, 0); /* GRCG off */ - break; -#else case 4: case 1: /* EGA/VGA planar modes */ @@ -307,7 +273,6 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val) outw(GDCIDX, (val << 8) | 0x00); /* set/reset */ *(info->vidmem + sofs) ^= 0xff; /* read-modify-write */ break; -#endif case 8: sofs += x; @@ -589,10 +554,8 @@ bmp_Draw(video_adapter_t *adp) { int line; #if 0 -#ifndef PC98 int i; #endif -#endif if (bmp_info.data == NULL) { /* init failed, do nothing */ return(1); @@ -607,15 +570,11 @@ bmp_Draw(video_adapter_t *adp) /* initialise the info structure for drawing */ bmp_info.index = bmp_info.data; -#ifdef PC98 - bmp_info.prev_val = 255; -#endif /* set the palette for our image */ vidd_load_palette(adp, (u_char *)&bmp_info.palette); #if 0 -#ifndef PC98 /* XXX: this is ugly, but necessary for EGA/VGA 1bpp/4bpp modes */ if ((adp->va_type == KD_EGA) || (adp->va_type == KD_VGA)) { inb(adp->va_crtc_addr + 6); /* reset flip-flop */ @@ -634,7 +593,6 @@ bmp_Draw(video_adapter_t *adp) outw(TSIDX, 0x0102); /* unmask plane #0 */ } #endif -#endif for (line = 0; (line < bmp_info.height) && bmp_info.index; line++) { bmp_DecodeLine(&bmp_info, line); diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 699ccbb2ca644..bb322aa318d21 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -82,12 +82,8 @@ __FBSDID("$FreeBSD$"); #include <machine/stdarg.h> #include <isa/isavar.h> -#ifdef PC98 -#include <pc98/pc98/pc98_machdep.h> -#else #include <isa/isareg.h> #include <isa/rtc.h> -#endif #include <dev/fdc/fdcvar.h> #include <dev/ic/nec765.h> @@ -140,57 +136,34 @@ __FBSDID("$FreeBSD$"); */ static struct fd_type fd_searchlist_360k[] = { -#ifndef PC98 { FDF_5_360 }, -#endif { 0 } }; static struct fd_type fd_searchlist_12m[] = { -#ifdef PC98 - { FDF_5_1200 | FL_AUTO }, - { FDF_5_720 | FL_AUTO }, - { FDF_5_360 | FL_AUTO }, - { FDF_5_640 | FL_AUTO }, - { FDF_5_1230 | FL_AUTO }, -#else { FDF_5_1200 | FL_AUTO }, { FDF_5_400 | FL_AUTO }, { FDF_5_360 | FL_2STEP | FL_AUTO}, -#endif { 0 } }; static struct fd_type fd_searchlist_720k[] = { -#ifndef PC98 { FDF_3_720 }, -#endif { 0 } }; static struct fd_type fd_searchlist_144m[] = { -#ifdef PC98 { FDF_3_1440 | FL_AUTO}, - { FDF_3_1200 | FL_AUTO}, { FDF_3_720 | FL_AUTO}, - { FDF_3_360 | FL_AUTO}, - { FDF_3_640 | FL_AUTO}, - { FDF_3_1230 | FL_AUTO}, -#else - { FDF_3_1440 | FL_AUTO}, - { FDF_3_720 | FL_AUTO}, -#endif { 0 } }; static struct fd_type fd_searchlist_288m[] = { -#ifndef PC98 { FDF_3_1440 | FL_AUTO }, #if 0 { FDF_3_2880 | FL_AUTO }, /* XXX: probably doesn't work */ #endif { FDF_3_720 | FL_AUTO}, -#endif { 0 } }; @@ -211,26 +184,6 @@ static struct fd_type *fd_native_types[] = { * Internals start here */ -#ifdef PC98 -/* registers */ -#define FDSTS 0 /* NEC 765 Main Status Register (R) */ -#define FDDATA 1 /* NEC 765 Data Register (R/W) */ -#define FDCTL 2 /* FD Control Register */ -#define FDC_RST 0x80 /* FDC RESET */ -#define FDC_RDY 0x40 /* force READY */ -#define FDC_DD 0x20 /* FDD Mode Exchange 0:1M 1:640K */ -#define FDC_DMAE 0x10 /* enable floppy DMA */ -#define FDC_MTON 0x08 /* MOTOR ON (when EMTON=1)*/ -#define FDC_TMSK 0x04 /* TIMER MASK */ -#define FDC_TTRG 0x01 /* TIMER TRIGER */ - -#define FDP 3 -#define FDP_EMTON 0x04 /* enable MTON */ -#define FDP_FDDEXC 0x02 /* FDD Mode Exchange 1:1M 0:640K */ -#define FDP_PORTEXC 0x01 /* PORT Exchane 1:1M 0:640K */ - -#define FDEM 4 -#else /* registers */ #define FDOUT 2 /* Digital Output Register (W) */ #define FDO_FDSEL 0x03 /* floppy device select */ @@ -245,7 +198,6 @@ static struct fd_type *fd_native_types[] = { #define FDDSR 4 /* Data Rate Select Register (W) */ #define FDDATA 5 /* NEC 765 Data Register (R/W) */ #define FDCTL 7 /* Control Register (W) */ -#endif /* PC98 */ /* * The YE-DATA PC Card floppies use PIO to read in the data rather @@ -268,11 +220,9 @@ static struct fd_type *fd_native_types[] = { #define FDBCDR 0 /* And 1 */ #define FD_YE_DATAPORT 6 /* Drive Data port */ -#ifndef PC98 #define FDI_DCHG 0x80 /* diskette has been changed */ /* requires drive and motor being selected */ /* is cleared by any step pulse to drive */ -#endif /* * We have three private BIO commands. @@ -309,9 +259,6 @@ struct fd_data { struct g_provider *fd_provider; device_t dev; struct bio_queue_head fd_bq; -#ifdef PC98 - int pc98_trans; -#endif }; #define FD_NOT_VALID -2 @@ -335,19 +282,11 @@ static int retries = 10; SYSCTL_INT(_debug_fdc, OID_AUTO, retries, CTLFLAG_RW, &retries, 0, "Number of retries to attempt"); -#ifdef PC98 -static int spec1 = NE7_SPEC_1(4, 240); -#else static int spec1 = NE7_SPEC_1(6, 240); -#endif SYSCTL_INT(_debug_fdc, OID_AUTO, spec1, CTLFLAG_RW, &spec1, 0, "Specification byte one (step-rate + head unload)"); -#ifdef PC98 -static int spec2 = NE7_SPEC_2(2, 0); -#else static int spec2 = NE7_SPEC_2(16, 0); -#endif SYSCTL_INT(_debug_fdc, OID_AUTO, spec2, CTLFLAG_RW, &spec2, 0, "Specification byte two (head load time + no-dma)"); @@ -397,14 +336,12 @@ fdctl_wr(struct fdc_data *fdc, u_int8_t v) fdregwr(fdc, FDCTL, v); } -#ifndef PC98 static void fdout_wr(struct fdc_data *fdc, u_int8_t v) { fdregwr(fdc, FDOUT, v); } -#endif static u_int8_t fdsts_rd(struct fdc_data *fdc) @@ -413,14 +350,12 @@ fdsts_rd(struct fdc_data *fdc) return fdregrd(fdc, FDSTS); } -#ifndef PC98 static void fddsr_wr(struct fdc_data *fdc, u_int8_t v) { fdregwr(fdc, FDDSR, v); } -#endif static void fddata_wr(struct fdc_data *fdc, u_int8_t v) @@ -436,14 +371,12 @@ fddata_rd(struct fdc_data *fdc) return fdregrd(fdc, FDDATA); } -#ifndef PC98 static u_int8_t fdin_rd(struct fdc_data *fdc) { return fdregrd(fdc, FDCTL); } -#endif /* * Magic pseudo-DMA initialization for YE FDC. Sets count and @@ -570,90 +503,11 @@ fdc_cmd(struct fdc_data *fdc, int n_out, ...) return (0); } -#ifdef PC98 -static void fd_motor(struct fd_data *fd, int turnon); - -static int pc98_trans = 0; /* 0 : HD , 1 : DD , 2 : 1.44 */ -static int pc98_trans_prev = -1; - -static void -set_density(struct fdc_data *fdc) -{ - /* always motor on */ - fdregwr(fdc, FDP, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC); - DELAY(100); - fdctl_wr(fdc, FDC_RST | FDC_DMAE); - /* in the case of note W, always inhibit 100ms timer */ -} - -static int -pc98_fd_check_ready(struct fd_data *fd) -{ - struct fdc_data *fdc = fd->fdc; - int retry = 0, status; - int fdu = device_get_unit(fd->dev); - - while (retry++ < 30000) { - fd_motor(fd, 1); - fdc_out(fdc, NE7CMD_SENSED); /* Sense Drive Status */ - DELAY(100); - fdc_out(fdc, fdu); /* Drive number */ - DELAY(100); - if ((fdc_in(fdc, &status) == 0) && (status & NE7_ST3_RD)) { - fdctl_wr(fdc, FDC_DMAE | FDC_MTON); - DELAY(10); - return (0); - } - } - return (-1); -} - -static void -pc98_fd_check_type(struct fd_data *fd, int unit) -{ - struct fdc_data *fdc; - - if (fd->type != FDT_NONE || unit < 0 || unit > 3) - return; - - fdc = fd->fdc; - - /* Look up what the BIOS thinks we have. */ - if (!((PC98_SYSTEM_PARAMETER(0x55c) >> unit) & 0x01)) { - fd->type = FDT_NONE; - return; - } - if ((PC98_SYSTEM_PARAMETER(0x5ae) >> unit) & 0x01) { - /* Check 3mode I/F */ - fd->pc98_trans = 0; - fdregwr(fdc, FDEM, (unit << 5) | 0x10); - if (!(fdregrd(fdc, FDEM) & 0x01)) { - fd->type = FDT_144M; - return; - } - device_printf(fd->dev, - "Warning: can't control 3mode I/F, fallback to 2mode.\n"); - } - - fd->type = FDT_12M; -} -#endif /* PC98 */ - static void fdc_reset(struct fdc_data *fdc) { int i, r[10]; -#ifdef PC98 - set_density(fdc); - if (pc98_machine_type & M_EPSON_PC98) - fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DD | FDC_MTON); - else - fdctl_wr(fdc, FDC_RST | FDC_RDY | FDC_DMAE | FDC_MTON); - DELAY(200); - fdctl_wr(fdc, FDC_DMAE | FDC_MTON); - DELAY(10); -#else if (fdc->fdct == FDC_ENHANCED) { /* Try a software reset, default precomp, and 500 kb/s */ fddsr_wr(fdc, I8207X_DSR_SR); @@ -666,7 +520,6 @@ fdc_reset(struct fdc_data *fdc) } DELAY(100); fdout_wr(fdc, fdc->fdout); -#endif /* XXX after a reset, silently believe the FDC will accept commands */ if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, spec1, spec2, 0)) @@ -760,7 +613,6 @@ fdc_read_status(struct fdc_data *fdc) return ret; } -#ifndef PC98 /* * Select this drive */ @@ -798,7 +650,6 @@ fd_turnon(void *arg) if (once) wakeup(&fd->fdc->head); } -#endif static void fd_motor(struct fd_data *fd, int turnon) @@ -809,11 +660,6 @@ fd_motor(struct fd_data *fd, int turnon) /* mtx_assert(&fdc->fdc_mtx, MA_OWNED); */ -#ifdef PC98 - fdregwr(fdc, FDP, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC); - DELAY(10); - fdctl_wr(fdc, FDC_DMAE | FDC_MTON); -#else if (turnon) { fd->flags |= FD_MOTORWAIT; fdc->fdout |= (FDO_MOEN0 << fd->fdsu); @@ -824,7 +670,6 @@ fd_motor(struct fd_data *fd, int turnon) fdc->fdout &= ~(FDO_MOEN0 << fd->fdsu); } fdout_wr(fdc, fdc->fdout); -#endif } static void @@ -995,41 +840,15 @@ fdc_worker(struct fdc_data *fdc) } /* Select drive, setup params */ -#ifdef PC98 - pc98_trans = fd->ft->trans; - if (pc98_trans_prev != pc98_trans) { - int i; - - set_density(fdc); - for (i = 0; i < 10; i++) { - outb(0x5f, 0); - outb(0x5f, 0); - } - pc98_trans_prev = pc98_trans; - } - if (pc98_trans != fd->pc98_trans) { - if (fd->type == FDT_144M) { - fdregwr(fdc, FDEM, - (device_get_unit(fd->dev) << 5) | 0x10 | - (pc98_trans >> 1)); - outb(0x5f, 0); - outb(0x5f, 0); - } - fd->pc98_trans = pc98_trans; - } -#else fd_select(fd); if (fdc->fdct == FDC_ENHANCED) fddsr_wr(fdc, fd->ft->trans); else fdctl_wr(fdc, fd->ft->trans); -#endif if (bp->bio_cmd == BIO_PROBE) { if ((!(device_get_flags(fd->dev) & FD_NO_CHLINE) && -#ifndef PC98 !(fdin_rd(fdc) & FDI_DCHG) && -#endif !(fd->flags & FD_EMPTY)) || fd_probe_disk(fd, &need_recal) == 0) return (fdc_biodone(fdc, 0)); @@ -1042,7 +861,6 @@ fdc_worker(struct fdc_data *fdc) if (fd->flags & FD_EMPTY) return (fdc_biodone(fdc, ENXIO)); -#ifndef PC98 /* Check if we lost our media */ if (fdin_rd(fdc) & FDI_DCHG) { if (debugflags & 0x40) @@ -1060,7 +878,6 @@ fdc_worker(struct fdc_data *fdc) g_topology_unlock(); return (fdc_biodone(fdc, ENXIO)); } -#endif /* Check if the floppy is write-protected */ if (bp->bio_cmd == BIO_FMT || bp->bio_cmd == BIO_WRITE) { @@ -1095,9 +912,6 @@ fdc_worker(struct fdc_data *fdc) if ((need_recal & (1 << fd->fdsu)) || (cylinder == 0 && fd->track != 0) || fdc->retry > 2) { -#ifdef PC98 - pc98_fd_check_ready(fd); -#endif retry_line = __LINE__; if (fdc_cmd(fdc, 2, NE7CMD_RECAL, fd->fdsu, 0)) return (1); @@ -1119,9 +933,6 @@ fdc_worker(struct fdc_data *fdc) * SEEK to where we want to be */ if (cylinder != fd->track) { -#ifdef PC98 - pc98_fd_check_ready(fd); -#endif retry_line = __LINE__; if (fdc_cmd(fdc, 3, NE7CMD_SEEK, fd->fdsu, descyl, 0)) return (1); @@ -1429,7 +1240,6 @@ fd_probe_disk(struct fd_data *fd, int *recal) if (fdc_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID) goto done; /* XXX */ *recal |= (1 << fd->fdsu); -#ifndef PC98 if (fdin_rd(fdc) & FDI_DCHG) { if (debugflags & 0x40) printf("Empty in probe\n"); @@ -1437,9 +1247,6 @@ fd_probe_disk(struct fd_data *fd, int *recal) fd->flags |= FD_EMPTY; mtx_unlock(&fdc->fdc_mtx); } else { -#else - { -#endif if (fdc_sense_drive(fdc, &st3) != 0) goto done; if (debugflags & 0x40) @@ -1576,11 +1383,7 @@ fdautoselect(struct fd_data *fd) if (debugflags & 0x40) { device_printf(fd->dev, "autoselected %d KB medium\n", -#ifdef PC98 - (128 << (fd->ft->secsize)) * fd->ft->size / 1024); -#else fd->ft->size / 2); -#endif fdprinttype(fd->ft); } return (0); @@ -1633,10 +1436,6 @@ fd_access(struct g_provider *pp, int r, int w, int e) busy = 0; if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) { -#ifdef PC98 - if (pc98_fd_check_ready(fd) == -1) - return (ENXIO); -#endif if (fdmisccmd(fd, BIO_PROBE, NULL)) return (ENXIO); if (fd->flags & FD_EMPTY) @@ -1706,10 +1505,6 @@ fd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread fd = pp->geom->softc; -#ifdef PC98 - pc98_fd_check_ready(fd); -#endif - switch (cmd) { case FD_GTYPE: /* get drive type */ *(struct fd_type *)data = *fd->ft; @@ -1877,12 +1672,6 @@ fdc_initial_reset(device_t dev, struct fdc_data *fdc) { int ic_type, part_id; -#ifdef PC98 - /* See if it can handle a command. */ - if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(4, 240), - NE7_SPEC_2(2, 0), 0)) - return (ENXIO); -#else /* * A status value of 0xff is very unlikely, but not theoretically * impossible, but it is far more likely to indicate an empty bus. @@ -1911,7 +1700,6 @@ fdc_initial_reset(device_t dev, struct fdc_data *fdc) if (fdc_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(6, 240), NE7_SPEC_2(31, 0), 0)) return (ENXIO); -#endif /* * Try to identify the chip. @@ -1973,11 +1761,7 @@ fdc_detach(device_t dev) mtx_unlock(&fdc->fdc_mtx); /* reset controller, turn motor off */ -#ifdef PC98 - fdc_reset(fdc); -#else fdout_wr(fdc, 0); -#endif if (!(fdc->flags & FDC_NODMA)) isa_dma_release(fdc->dmachan); @@ -2051,11 +1835,7 @@ fdc_attach(device_t dev) mtx_init(&fdc->fdc_mtx, "fdc lock", NULL, MTX_DEF); /* reset controller, turn motor off, clear fdout mirror reg */ -#ifdef PC98 - fdc_reset(fdc); -#else fdout_wr(fdc, fdc->fdout = 0); -#endif bioq_init(&fdc->head); settle = hz / 8; @@ -2117,10 +1897,8 @@ static int fd_probe(device_t dev) { int unit; -#ifndef PC98 int i; u_int st0, st3; -#endif struct fd_data *fd; struct fdc_data *fdc; int fdsu; @@ -2147,9 +1925,7 @@ fd_probe(device_t dev) fd->type = type; } -#ifdef PC98 - pc98_fd_check_type(fd, unit); -#elif defined(__i386__) || defined(__amd64__) +#if defined(__i386__) || defined(__amd64__) if (fd->type == FDT_NONE && (unit == 0 || unit == 1)) { /* Look up what the BIOS thinks we have. */ if (unit == 0) @@ -2164,7 +1940,6 @@ fd_probe(device_t dev) if (fd->type == FDT_NONE) return (ENXIO); -#ifndef PC98 mtx_lock(&fdc->fdc_mtx); /* select it */ @@ -2214,19 +1989,10 @@ fd_probe(device_t dev) if ((flags & FD_NO_PROBE) == 0 && (st0 & NE7_ST0_EC) != 0) /* no track 0 -> no drive present */ return (ENXIO); -#endif /* PC98 */ done: switch (fd->type) { -#ifdef PC98 - case FDT_144M: - device_set_desc(dev, "1.44M FDD"); - break; - case FDT_12M: - device_set_desc(dev, "1M/640K FDD"); - break; -#else case FDT_12M: device_set_desc(dev, "1200-KB 5.25\" drive"); break; @@ -2242,7 +2008,6 @@ done: case FDT_720K: device_set_desc(dev, "720-KB 3.5\" drive"); break; -#endif default: return (ENXIO); } @@ -2250,9 +2015,6 @@ done: fd->fdc = fdc; fd->fdsu = fdsu; fd->options = 0; -#ifdef PC98 - fd->pc98_trans = 0; -#endif callout_init_mtx(&fd->toffhandle, &fd->fdc->fdc_mtx, 0); /* initialize densities for subdevices */ diff --git a/sys/dev/fdc/fdc_cbus.c b/sys/dev/fdc/fdc_cbus.c deleted file mode 100644 index b03b370375d8a..0000000000000 --- a/sys/dev/fdc/fdc_cbus.c +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * Copyright (c) 2004 TAKAHASHI Yoshihiro - * 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, - * without modification, immediately at the beginning of the file. - * 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. - * - * 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. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/bio.h> -#include <sys/bus.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/module.h> -#include <sys/mutex.h> -#include <sys/rman.h> -#include <sys/systm.h> - -#include <machine/bus.h> - -#include <pc98/cbus/cbus.h> -#include <dev/fdc/fdcvar.h> - -#include <isa/isavar.h> - -static bus_addr_t fdc_iat[] = {0, 2, 4}; - -static int -fdc_cbus_alloc_resources(device_t dev, struct fdc_data *fdc) -{ - struct resource *res; - int i, rid; - - fdc->fdc_dev = dev; - rid = 0; - res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, fdc_iat, 3, - RF_ACTIVE); - if (res == NULL) { - device_printf(dev, "cannot reserve I/O port range\n"); - return (ENXIO); - } - isa_load_resourcev(res, fdc_iat, 3); - for (i = 0; i < 3; i++) { - fdc->resio[i] = res; - fdc->ridio[i] = rid; - fdc->ioff[i] = i; - fdc->ioh[i] = rman_get_bushandle(res); - } - fdc->iot = rman_get_bustag(res); - - rid = 3; - bus_set_resource(dev, SYS_RES_IOPORT, rid, IO_FDPORT, 1); - res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); - if (res == NULL) { - device_printf(dev, "cannot reserve I/O port range\n"); - return (ENXIO); - } - fdc->resio[3] = res; - fdc->ridio[3] = rid; - fdc->ioff[3] = 0; - fdc->ioh[3] = rman_get_bushandle(res); - /* XXX: Reuses fdc->iot */ - - rid = 4; - bus_set_resource(dev, SYS_RES_IOPORT, rid, 0x4be, 1); - res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); - if (res == NULL) { - device_printf(dev, "cannot reserve I/O port range\n"); - return (ENXIO); - } - fdc->resio[4] = res; - fdc->ridio[4] = rid; - fdc->ioff[4] = 0; - fdc->ioh[4] = rman_get_bushandle(res); - /* XXX: Reuses fdc->iot */ - - fdc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fdc->rid_irq, - RF_ACTIVE); - if (fdc->res_irq == NULL) { - device_printf(dev, "cannot reserve interrupt line\n"); - return (ENXIO); - } - - if ((fdc->flags & FDC_NODMA) == 0) { - fdc->res_drq = bus_alloc_resource_any(dev, SYS_RES_DRQ, - &fdc->rid_drq, RF_ACTIVE); - if (fdc->res_drq == NULL) { - device_printf(dev, "cannot reserve DMA request line\n"); - return (ENXIO); - } - fdc->dmachan = rman_get_start(fdc->res_drq); - } - - return (0); -} - -static int -fdc_cbus_probe(device_t dev) -{ - int error; - struct fdc_data *fdc; - - fdc = device_get_softc(dev); - - /* Check pnp ids */ - if (isa_get_vendorid(dev)) - return (ENXIO); - - /* Attempt to allocate our resources for the duration of the probe */ - error = fdc_cbus_alloc_resources(dev, fdc); - if (error == 0) - error = fdc_initial_reset(dev, fdc); - - fdc_release_resources(fdc); - return (error); -} - -static int -fdc_cbus_attach(device_t dev) -{ - struct fdc_data *fdc; - int error; - - fdc = device_get_softc(dev); - error = fdc_cbus_alloc_resources(dev, fdc); - if (error == 0) - error = fdc_attach(dev); - if (error == 0) - error = fdc_hints_probe(dev); - if (error == 0) - fdc_start_worker(dev); - else - fdc_release_resources(fdc); - return (error); -} - -static device_method_t fdc_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, fdc_cbus_probe), - DEVMETHOD(device_attach, fdc_cbus_attach), - DEVMETHOD(device_detach, fdc_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, fdc_print_child), - DEVMETHOD(bus_read_ivar, fdc_read_ivar), - DEVMETHOD(bus_write_ivar, fdc_write_ivar), - /* Our children never use any other bus interface methods. */ - - { 0, 0 } -}; - -static driver_t fdc_driver = { - "fdc", - fdc_methods, - sizeof(struct fdc_data) -}; - -DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0); diff --git a/sys/dev/fdc/fdcvar.h b/sys/dev/fdc/fdcvar.h index edaef7959de27..0829901151358 100644 --- a/sys/dev/fdc/fdcvar.h +++ b/sys/dev/fdc/fdcvar.h @@ -49,9 +49,7 @@ struct fdc_data { #define FDC_KTHREAD_ALIVE 0x2000 /* worker thread is alive */ struct fd_data *fd; /* The active drive */ int retry; -#ifndef PC98 int fdout; /* mirror of the w/o digital output reg */ -#endif u_int status[7]; /* copy of the registers */ enum fdc_type fdct; /* chip version of FDC */ int fdc_errs; /* number of logged errors */ diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index 28841b7837773..e4a46011a9a34 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -37,14 +37,6 @@ __FBSDID("$FreeBSD$"); * other types of Ethernet cards, but the author is not sure whether * they are useful. * - * This version also includes some alignments to support RE1000, - * C-NET(98)P2 and so on. These cards are not for AT-compatibles, - * but for NEC PC-98 bus -- a proprietary bus architecture available - * only in Japan. Confusingly, it is different from the Microsoft's - * PC98 architecture. :-{ - * Further work for PC-98 version will be available as a part of - * FreeBSD(98) project. - * * This software is a derivative work of if_ed.c version 1.56 by David * Greenman available as a part of FreeBSD 2.0 RELEASE source distribution. * @@ -61,7 +53,6 @@ __FBSDID("$FreeBSD$"); /* * TODO: * o To support ISA PnP auto configuration for FMV-183/184. - * o To support REX-9886/87(PC-98 only). * o To reconsider mbuf usage. * o To reconsider transmission buffer usage, including * transmission buffer size (currently 4KB x 2) and pros-and- diff --git a/sys/dev/fe/if_fe_cbus.c b/sys/dev/fe/if_fe_cbus.c deleted file mode 100644 index c083cdda87a15..0000000000000 --- a/sys/dev/fe/if_fe_cbus.c +++ /dev/null @@ -1,1020 +0,0 @@ -/*- - * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 - * - * This software may be used, modified, copied, distributed, and sold, in - * both source and binary form provided that the above copyright, these - * terms and the following disclaimer are retained. The name of the author - * and/or the contributor 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 THE CONTRIBUTOR ``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 THE CONTRIBUTOR 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/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/socket.h> -#include <sys/module.h> - -#include <sys/bus.h> -#include <machine/bus.h> -#include <sys/rman.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_mib.h> -#include <net/if_media.h> - -#include <netinet/in.h> -#include <netinet/if_ether.h> - -#include <dev/fe/mb86960.h> -#include <dev/fe/if_fereg.h> -#include <dev/fe/if_fevar.h> - -#include <isa/isavar.h> - -/* - * Cbus specific code. - */ -static int fe_isa_probe(device_t); -static int fe_isa_attach(device_t); - -static struct isa_pnp_id fe_ids[] = { - { 0x101ee0d, NULL }, /* CON0101 - Contec C-NET(98)P2-T */ - { 0, NULL } -}; - -static device_method_t fe_isa_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, fe_isa_probe), - DEVMETHOD(device_attach, fe_isa_attach), - - { 0, 0 } -}; - -static driver_t fe_isa_driver = { - "fe", - fe_isa_methods, - sizeof (struct fe_softc) -}; - -DRIVER_MODULE(fe, isa, fe_isa_driver, fe_devclass, 0, 0); - - -static int fe98_alloc_port(device_t, int); - -static int fe_probe_re1000(device_t); -static int fe_probe_cnet9ne(device_t); -static int fe_probe_rex(device_t); -static int fe_probe_ssi(device_t); -static int fe_probe_jli(device_t); -static int fe_probe_lnx(device_t); -static int fe_probe_gwy(device_t); -static int fe_probe_ubn(device_t); - -/* - * Determine if the device is present at a specified I/O address. The - * main entry to the driver. - */ -static int -fe_isa_probe(device_t dev) -{ - struct fe_softc *sc; - int error; - - /* Prepare for the softc struct. */ - sc = device_get_softc(dev); - sc->sc_unit = device_get_unit(dev); - - /* Check isapnp ids */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, fe_ids); - - /* If the card had a PnP ID that didn't match any we know about */ - if (error == ENXIO) - goto end; - - /* If we had some other problem. */ - if (!(error == 0 || error == ENOENT)) - goto end; - - /* Probe for supported boards. */ - if ((error = fe_probe_re1000(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_cnet9ne(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_rex(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_ssi(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_jli(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_lnx(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_ubn(dev)) == 0) - goto end; - fe_release_resource(dev); - - if ((error = fe_probe_gwy(dev)) == 0) - goto end; - fe_release_resource(dev); - -end: - if (error == 0) - error = fe_alloc_irq(dev, 0); - - fe_release_resource(dev); - return (error); -} - -static int -fe_isa_attach(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - int error = 0; - - /* - * Note: these routines aren't expected to fail since we also call - * them in the probe routine. But coverity complains, so we'll honor - * that complaint since the intention here was never to ignore them.. - */ - if (sc->port_used) { - error = fe98_alloc_port(dev, sc->type); - if (error != 0) - return (error); - } - error = fe_alloc_irq(dev, 0); - if (error != 0) - return (error); - - return fe_attach(dev); -} - - -/* Generic I/O address table */ -static bus_addr_t ioaddr_generic[MAXREGISTERS] = { - 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, - 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f, - 0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017, - 0x018, 0x019, 0x01a, 0x01b, 0x01c, 0x01d, 0x01e, 0x01f, -}; - -/* I/O address table for RE1000/1000Plus */ -static bus_addr_t ioaddr_re1000[MAXREGISTERS] = { - 0x0000, 0x0001, 0x0200, 0x0201, 0x0400, 0x0401, 0x0600, 0x0601, - 0x0800, 0x0801, 0x0a00, 0x0a01, 0x0c00, 0x0c01, 0x0e00, 0x0e01, - 0x1000, 0x1200, 0x1400, 0x1600, 0x1800, 0x1a00, 0x1c00, 0x1e00, - 0x1001, 0x1201, 0x1401, 0x1601, 0x1801, 0x1a01, 0x1c01, 0x1e01, -}; - -/* I/O address table for CNET9NE */ -static bus_addr_t ioaddr_cnet9ne[MAXREGISTERS] = { - 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, - 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f, - 0x400, 0x402, 0x404, 0x406, 0x408, 0x40a, 0x40c, 0x40e, - 0x401, 0x403, 0x405, 0x407, 0x409, 0x40b, 0x40d, 0x40f, -}; - -/* I/O address table for LAC-98 */ -static bus_addr_t ioaddr_lnx[MAXREGISTERS] = { - 0x000, 0x002, 0x004, 0x006, 0x008, 0x00a, 0x00c, 0x00e, - 0x100, 0x102, 0x104, 0x106, 0x108, 0x10a, 0x10c, 0x10e, - 0x200, 0x202, 0x204, 0x206, 0x208, 0x20a, 0x20c, 0x20e, - 0x300, 0x302, 0x304, 0x306, 0x308, 0x30a, 0x30c, 0x30e, -}; - -/* I/O address table for Access/PC N98C+ */ -static bus_addr_t ioaddr_ubn[MAXREGISTERS] = { - 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, - 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f, - 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207, - 0x208, 0x209, 0x20a, 0x20b, 0x20c, 0x20d, 0x20e, 0x20f, -}; - -/* I/O address table for REX-9880 */ -static bus_addr_t ioaddr_rex[MAXREGISTERS] = { - 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, - 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f, - 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, - 0x108, 0x109, 0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, -}; - -static int -fe98_alloc_port(device_t dev, int type) -{ - struct fe_softc *sc = device_get_softc(dev); - struct resource *res; - bus_addr_t *iat; - int size, rid; - - switch (type) { - case FE_TYPE_RE1000: - iat = ioaddr_re1000; - size = MAXREGISTERS; - break; - case FE_TYPE_CNET9NE: - iat = ioaddr_cnet9ne; - size = MAXREGISTERS; - break; - case FE_TYPE_SSI: - iat = ioaddr_generic; - size = MAXREGISTERS; - break; - case FE_TYPE_LNX: - iat = ioaddr_lnx; - size = MAXREGISTERS; - break; - case FE_TYPE_GWY: - iat = ioaddr_generic; - size = MAXREGISTERS; - break; - case FE_TYPE_UBN: - iat = ioaddr_ubn; - size = MAXREGISTERS; - break; - case FE_TYPE_REX: - iat = ioaddr_rex; - size = MAXREGISTERS; - break; - default: - iat = ioaddr_generic; - size = MAXREGISTERS; - break; - } - - rid = 0; - res = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, - iat, size, RF_ACTIVE); - if (res == NULL) - return ENOENT; - - isa_load_resourcev(res, iat, size); - - sc->type = type; - sc->port_used = size; - sc->port_res = res; - return (0); -} - - -/* - * Probe and initialization for Allied-Telesis RE1000 series. - */ -static void -fe_init_re1000(struct fe_softc *sc) -{ - /* Setup IRQ control register on the ASIC. */ - fe_outb(sc, FE_RE1000_IRQCONF, sc->priv_info); -} - -static int -fe_probe_re1000(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - int i, n; - rman_res_t iobase, irq; - u_char sum; - - static struct fe_simple_probe_struct probe_table [] = { - { FE_DLCR2, 0x58, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - - /* See if the specified I/O address is possible for RE1000. */ - /* [01]D[02468ACE] are allowed. */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - if ((iobase & ~0x10E) != 0xD0) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_RE1000)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* See if the card is on its address. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* Get our station address from EEPROM. */ - fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN); - - /* Make sure it is Allied-Telesis's. */ - if (!fe_valid_Ether_p(sc->enaddr, 0x0000F4)) - return ENXIO; -#if 1 - /* Calculate checksum. */ - sum = fe_inb(sc, 0x1e); - for (i = 0; i < ETHER_ADDR_LEN; i++) - sum ^= sc->enaddr[i]; - if (sum != 0) - return ENXIO; -#endif - /* Setup the board type. */ - sc->typestr = "RE1000"; - - /* This looks like an RE1000 board. It requires an - explicit IRQ setting in config. Make sure we have one, - determining an appropriate value for the IRQ control - register. */ - irq = 0; - bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL); - switch (irq) { - case 3: n = 0x10; break; - case 5: n = 0x20; break; - case 6: n = 0x40; break; - case 12: n = 0x80; break; - default: - fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12"); - return ENXIO; - } - sc->priv_info = (fe_inb(sc, FE_RE1000_IRQCONF) & 0x0f) | n; - - /* Setup hooks. We need a special initialization procedure. */ - sc->init = fe_init_re1000; - - return 0; -} - -/* JLI sub-probe for Allied-Telesis RE1000Plus/ME1500 series. */ -static u_short const * -fe_probe_jli_re1000p(struct fe_softc * sc, u_char const * eeprom) -{ - int i; - static u_short const irqmaps_re1000p [4] = { 3, 5, 6, 12 }; - - /* Make sure the EEPROM contains Allied-Telesis bit pattern. */ - if (eeprom[1] != 0xFF) return NULL; - for (i = 2; i < 8; i++) if (eeprom[i] != 0xFF) return NULL; - for (i = 14; i < 24; i++) if (eeprom[i] != 0xFF) return NULL; - - /* Get our station address from EEPROM, and make sure the - EEPROM contains Allied-Telesis's address. */ - bcopy(eeprom + 8, sc->enaddr, ETHER_ADDR_LEN); - if (!fe_valid_Ether_p(sc->enaddr, 0x0000F4)) - return NULL; - - /* I don't know any sub-model identification. */ - sc->typestr = "RE1000Plus/ME1500"; - - /* Returns the IRQ table for the RE1000Plus. */ - return irqmaps_re1000p; -} - - -/* - * Probe for Allied-Telesis RE1000Plus/ME1500 series. - */ -static int -fe_probe_jli(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - int i, n, xirq, error; - rman_res_t iobase, irq; - u_char eeprom [JLI_EEPROM_SIZE]; - u_short const * irqmap; - - static u_short const baseaddr [8] = - { 0x1D6, 0x1D8, 0x1DA, 0x1D4, 0x0D4, 0x0D2, 0x0D8, 0x0D0 }; - static struct fe_simple_probe_struct const probe_table [] = { - /* { FE_DLCR1, 0x20, 0x00 }, Doesn't work. */ - { FE_DLCR2, 0x50, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - /* { FE_DLCR5, 0x80, 0x00 }, Doesn't work. */ -#if 0 - { FE_BMPR16, 0x1B, 0x00 }, - { FE_BMPR17, 0x7F, 0x00 }, -#endif - { 0 } - }; - - /* - * See if the specified address is possible for MB86965A JLI mode. - */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - for (i = 0; i < 8; i++) { - if (baseaddr[i] == iobase) - break; - } - if (i == 8) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_RE1000)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* - * We should test if MB86965A is on the base address now. - * Unfortunately, it is very hard to probe it reliably, since - * we have no way to reset the chip under software control. - * On cold boot, we could check the "signature" bit patterns - * described in the Fujitsu document. On warm boot, however, - * we can predict almost nothing about register values. - */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* Check if our I/O address matches config info on 86965. */ - n = (fe_inb(sc, FE_BMPR19) & FE_B19_ADDR) >> FE_B19_ADDR_SHIFT; - if (baseaddr[n] != iobase) - return ENXIO; - - /* - * We are now almost sure we have an MB86965 at the given - * address. So, read EEPROM through it. We have to write - * into LSI registers to read from EEPROM. I want to avoid it - * at this stage, but I cannot test the presence of the chip - * any further without reading EEPROM. FIXME. - */ - fe_read_eeprom_jli(sc, eeprom); - - /* Make sure that config info in EEPROM and 86965 agree. */ - if (eeprom[FE_EEPROM_CONF] != fe_inb(sc, FE_BMPR19)) - return ENXIO; - - /* Use 86965 media selection scheme, unless othewise - specified. It is "AUTO always" and "select with BMPR13". - This behaviour covers most of the 86965 based board (as - minimum requirements.) It is backward compatible with - previous versions, also. */ - sc->mbitmap = MB_HA; - sc->defmedia = MB_HA; - sc->msel = fe_msel_965; - - /* Perform board-specific probe. */ - if ((irqmap = fe_probe_jli_re1000p(sc, eeprom)) == NULL) - return ENXIO; - - /* Find the IRQ read from EEPROM. */ - n = (fe_inb(sc, FE_BMPR19) & FE_B19_IRQ) >> FE_B19_IRQ_SHIFT; - xirq = irqmap[n]; - - /* Try to determine IRQ setting. */ - error = bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL); - if (error && xirq == NO_IRQ) { - /* The device must be configured with an explicit IRQ. */ - device_printf(dev, "IRQ auto-detection does not work\n"); - return ENXIO; - } else if (error && xirq != NO_IRQ) { - /* Just use the probed IRQ value. */ - bus_set_resource(dev, SYS_RES_IRQ, 0, xirq, 1); - } else if (!error && xirq == NO_IRQ) { - /* No problem. Go ahead. */ - } else if (irq == xirq) { - /* Good. Go ahead. */ - } else { - /* User must be warned in this case. */ - sc->stability |= UNSTABLE_IRQ; - } - - /* Setup a hook, which resets te 86965 when the driver is being - initialized. This may solve a nasty bug. FIXME. */ - sc->init = fe_init_jli; - - return 0; -} - - -/* - * Probe and initialization for Contec C-NET(9N)E series. - */ - -/* TODO: Should be in "if_fereg.h" */ -#define FE_CNET9NE_INTR 0x10 /* Interrupt Mask? */ - -static void -fe_init_cnet9ne(struct fe_softc *sc) -{ - /* Enable interrupt? FIXME. */ - fe_outb(sc, FE_CNET9NE_INTR, 0x10); -} - -static int -fe_probe_cnet9ne (device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - rman_res_t iobase, irq; - - static struct fe_simple_probe_struct probe_table [] = { - { FE_DLCR2, 0x58, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - - /* See if the specified I/O address is possible for C-NET(9N)E. */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - if (iobase != 0x73D0) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_CNET9NE)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* See if the card is on its address. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* Get our station address from EEPROM. */ - fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN); - - /* Make sure it is Contec's. */ - if (!fe_valid_Ether_p(sc->enaddr, 0x00804C)) - return ENXIO; - - /* Determine the card type. */ - if (sc->enaddr[3] == 0x06) { - sc->typestr = "C-NET(9N)C"; - - /* We seems to need our own IDENT bits... FIXME. */ - sc->proto_dlcr7 = FE_D7_BYTSWP_LH | FE_D7_IDENT_NICE; - - /* C-NET(9N)C requires an explicit IRQ to work. */ - if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL) != 0) { - fe_irq_failure(sc->typestr, sc->sc_unit, NO_IRQ, NULL); - return ENXIO; - } - } else { - sc->typestr = "C-NET(9N)E"; - - /* C-NET(9N)E works only IRQ5. */ - if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL) != 0) - return ENXIO; - if (irq != 5) { - fe_irq_failure(sc->typestr, sc->sc_unit, irq, "5"); - return ENXIO; - } - - /* We need an init hook to initialize ASIC before we start. */ - sc->init = fe_init_cnet9ne; - } - - /* C-NET(9N)E has 64KB SRAM. */ - sc->proto_dlcr6 = FE_D6_BUFSIZ_64KB | FE_D6_TXBSIZ_2x4KB - | FE_D6_BBW_WORD | FE_D6_SBW_WORD | FE_D6_SRAM; - - return 0; -} - - -/* - * Probe for Contec C-NET(98)P2 series. - * (Logitec LAN-98TP/LAN-98T25P - parhaps) - */ -static int -fe_probe_ssi(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - rman_res_t iobase, irq; - - u_char eeprom [SSI_EEPROM_SIZE]; - static struct fe_simple_probe_struct probe_table [] = { - { FE_DLCR2, 0x08, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - static u_short const irqmap[] = { - /* INT0 INT1 INT2 */ - NO_IRQ, NO_IRQ, NO_IRQ, 3, NO_IRQ, 5, 6, NO_IRQ, - NO_IRQ, 9, 10, NO_IRQ, 12, 13, NO_IRQ, NO_IRQ, - /* INT3 INT41 INT5 INT6 */ - }; - - /* See if the specified I/O address is possible for 78Q8377A. */ - /* [0-D]3D0 are allowed. */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - if ((iobase & 0xFFF) != 0x3D0) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_SSI)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* See if the card is on its address. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* We now have to read the config EEPROM. We should be very - careful, since doing so destroys a register. (Remember, we - are not yet sure we have a C-NET(98)P2 board here.) Don't - remember to select BMPRs bofore reading EEPROM, since other - register bank may be selected before the probe() is called. */ - fe_read_eeprom_ssi(sc, eeprom); - - /* Make sure the Ethernet (MAC) station address is of Contec's. */ - if (!fe_valid_Ether_p(eeprom + FE_SSI_EEP_ADDR, 0x00804C)) - return ENXIO; - bcopy(eeprom + FE_SSI_EEP_ADDR, sc->enaddr, ETHER_ADDR_LEN); - - /* Setup the board type. */ - sc->typestr = "C-NET(98)P2"; - - /* Non-PnP mode, set static resource from eeprom. */ - if (!isa_get_vendorid(dev)) { - /* Get IRQ configuration from EEPROM. */ - irq = irqmap[eeprom[FE_SSI_EEP_IRQ]]; - if (irq == NO_IRQ) { - fe_irq_failure(sc->typestr, sc->sc_unit, irq, - "3/5/6/9/10/12/13"); - return ENXIO; - } - bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1); - } - - /* Get Duplex-mode configuration from EEPROM. */ - sc->proto_dlcr4 |= (eeprom[FE_SSI_EEP_DUPLEX] & FE_D4_DSC); - - /* Fill softc struct accordingly. */ - sc->mbitmap = MB_HT; - sc->defmedia = MB_HT; - - return 0; -} - - -/* - * Probe for TDK LAC-98012/013/025/9N011 - parhaps. - */ -static int -fe_probe_lnx(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - - rman_res_t iobase, irq; - u_char eeprom [LNX_EEPROM_SIZE]; - - static struct fe_simple_probe_struct probe_table [] = { - { FE_DLCR2, 0x58, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - - /* See if the specified I/O address is possible for TDK/LANX boards. */ - /* 0D0, 4D0, 8D0, and CD0 are allowed. */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - if ((iobase & ~0xC00) != 0xD0) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_LNX)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* See if the card is on its address. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* We now have to read the config EEPROM. We should be very - careful, since doing so destroys a register. (Remember, we - are not yet sure we have a LAC-98012/98013 board here.) */ - fe_read_eeprom_lnx(sc, eeprom); - - /* Make sure the Ethernet (MAC) station address is of TDK/LANX's. */ - if (!fe_valid_Ether_p(eeprom, 0x008098)) - return ENXIO; - bcopy(eeprom, sc->enaddr, ETHER_ADDR_LEN); - - /* Setup the board type. */ - sc->typestr = "LAC-98012/98013"; - - /* This looks like a TDK/LANX board. It requires an - explicit IRQ setting in config. Make sure we have one, - determining an appropriate value for the IRQ control - register. */ - irq = 0; - if (bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL) != 0) - return ENXIO; - switch (irq) { - case 3 : sc->priv_info = 0x10 | LNX_CLK_LO | LNX_SDA_HI; break; - case 5 : sc->priv_info = 0x20 | LNX_CLK_LO | LNX_SDA_HI; break; - case 6 : sc->priv_info = 0x40 | LNX_CLK_LO | LNX_SDA_HI; break; - case 12: sc->priv_info = 0x80 | LNX_CLK_LO | LNX_SDA_HI; break; - default: - fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12"); - return ENXIO; - } - - /* LAC-98's system bus width is 8-bit. */ - sc->proto_dlcr6 = FE_D6_BUFSIZ_32KB | FE_D6_TXBSIZ_2x2KB - | FE_D6_BBW_BYTE | FE_D6_SBW_BYTE | FE_D6_SRAM_150ns; - - /* Setup hooks. We need a special initialization procedure. */ - sc->init = fe_init_lnx; - - return 0; -} - - -/* - * Probe for Gateway Communications' old cards. - * (both as Generic MB86960 probe routine) - */ -static int -fe_probe_gwy(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - - static struct fe_simple_probe_struct probe_table [] = { - /* { FE_DLCR2, 0x70, 0x00 }, */ - { FE_DLCR2, 0x58, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - - /* - * XXX - * I'm not sure which address is possible, so accepts any. - */ - - if (fe98_alloc_port(dev, FE_TYPE_GWY)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* See if the card is on its address. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* Get our station address from EEPROM. */ - fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN); - if (!fe_valid_Ether_p(sc->enaddr, 0x000000)) - return ENXIO; - - /* Determine the card type. */ - sc->typestr = "Generic MB86960 Ethernet"; - if (fe_valid_Ether_p(sc->enaddr, 0x000061)) - sc->typestr = "Gateway Ethernet (Fujitsu chipset)"; - - /* Gateway's board requires an explicit IRQ to work, since it - is not possible to probe the setting of jumpers. */ - if (bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0) { - fe_irq_failure(sc->typestr, sc->sc_unit, NO_IRQ, NULL); - return ENXIO; - } - - return 0; -} - - -/* - * Probe for Ungermann-Bass Access/PC N98C+(Model 85152). - */ -static int -fe_probe_ubn(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - - u_char sum, save7; - rman_res_t iobase, irq; - int i; - static struct fe_simple_probe_struct const probe_table [] = { - { FE_DLCR2, 0x58, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - - /* See if the specified I/O address is possible for Access/PC. */ - /* [01][048C]D0 are allowed. */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - if ((iobase & ~0x1C00) != 0xD0) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_UBN)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* Simple probe. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* NOTE: Access/NOTE N98 sometimes freeze when reading station - address. In case of using it togather with C-NET(9N)C, - this problem usually happens. - Writing DLCR7 prevents freezing, but I don't know why. FIXME. */ - - /* Save the current value for the DLCR7 register we are about - to destroy. */ - save7 = fe_inb(sc, FE_DLCR7); - fe_outb(sc, FE_DLCR7, - sc->proto_dlcr7 | FE_D7_RBS_BMPR | FE_D7_POWER_UP); - - /* Get our station address form ID ROM and make sure it is UBN's. */ - fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN); - if (!fe_valid_Ether_p(sc->enaddr, 0x00DD01)) - goto fail_ubn; -#if 1 - /* Calculate checksum. */ - sum = fe_inb(sc, 0x1e); - for (i = 0; i < ETHER_ADDR_LEN; i++) - sum ^= sc->enaddr[i]; - if (sum != 0) - goto fail_ubn; -#endif - - /* Setup the board type. */ - sc->typestr = "Access/PC"; - - /* This looks like an AccessPC/N98C+ board. It requires an - explicit IRQ setting in config. Make sure we have one, - determining an appropriate value for the IRQ control - register. */ - irq = 0; - bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL); - switch (irq) { - case 3: sc->priv_info = 0x01; break; - case 5: sc->priv_info = 0x02; break; - case 6: sc->priv_info = 0x04; break; - case 12: sc->priv_info = 0x08; break; - default: - fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12"); - goto fail_ubn; - } - - /* Setup hooks. We need a special initialization procedure. */ - sc->init = fe_init_ubn; - - return 0; - -fail_ubn: - fe_outb(sc, FE_DLCR7, save7); - return ENXIO; -} - - -/* - * REX boards(non-JLI type) support routine. - */ - -#define REX_EEPROM_SIZE 32 -#define REX_DAT 0x01 - -static void -fe_read_eeprom_rex(struct fe_softc *sc, u_char *data) -{ - int i; - u_char bit, val; - u_char save16; - - save16 = fe_inb(sc, 0x10); - - /* Issue a start condition. */ - val = fe_inb(sc, 0x10) & 0xf0; - fe_outb(sc, 0x10, val); - - (void) fe_inb(sc, 0x10); - (void) fe_inb(sc, 0x10); - (void) fe_inb(sc, 0x10); - (void) fe_inb(sc, 0x10); - - /* Read bytes from EEPROM. */ - for (i = 0; i < REX_EEPROM_SIZE; i++) { - /* Read a byte and store it into the buffer. */ - val = 0x00; - for (bit = 0x01; bit != 0x00; bit <<= 1) - if (fe_inb(sc, 0x10) & REX_DAT) - val |= bit; - *data++ = val; - } - - fe_outb(sc, 0x10, save16); - -#if 1 - /* Report what we got. */ - if (bootverbose) { - data -= REX_EEPROM_SIZE; - for (i = 0; i < REX_EEPROM_SIZE; i += 16) { - printf("fe%d: EEPROM(REX):%3x: %16D\n", - sc->sc_unit, i, data + i, " "); - } - } -#endif -} - - -static void -fe_init_rex(struct fe_softc *sc) -{ - /* Setup IRQ control register on the ASIC. */ - fe_outb(sc, 0x10, sc->priv_info); -} - -/* - * Probe for RATOC REX-9880/81/82/83 series. - */ -static int -fe_probe_rex(device_t dev) -{ - struct fe_softc *sc = device_get_softc(dev); - - int i; - rman_res_t iobase, irq; - u_char eeprom [REX_EEPROM_SIZE]; - - static struct fe_simple_probe_struct probe_table [] = { - { FE_DLCR2, 0x58, 0x00 }, - { FE_DLCR4, 0x08, 0x00 }, - { 0 } - }; - - /* See if the specified I/O address is possible for REX-9880. */ - /* 6[46CE]D0 are allowed. */ - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &iobase, NULL) != 0) - return ENXIO; - if ((iobase & ~0xA00) != 0x64D0) - return ENXIO; - - if (fe98_alloc_port(dev, FE_TYPE_REX)) - return ENXIO; - - /* Fill the softc struct with default values. */ - fe_softc_defaults(sc); - - /* See if the card is on its address. */ - if (!fe_simple_probe(sc, probe_table)) - return ENXIO; - - /* We now have to read the config EEPROM. We should be very - careful, since doing so destroys a register. (Remember, we - are not yet sure we have a REX-9880 board here.) */ - fe_read_eeprom_rex(sc, eeprom); - for (i = 0; i < ETHER_ADDR_LEN; i++) - sc->enaddr[i] = eeprom[7 - i]; - - /* Make sure it is RATOC's. */ - if (!fe_valid_Ether_p(sc->enaddr, 0x00C0D0) && - !fe_valid_Ether_p(sc->enaddr, 0x00803D)) - return 0; - - /* Setup the board type. */ - sc->typestr = "REX-9880/9883"; - - /* This looks like a REX-9880 board. It requires an - explicit IRQ setting in config. Make sure we have one, - determining an appropriate value for the IRQ control - register. */ - irq = 0; - bus_get_resource(dev, SYS_RES_IRQ, 0, &irq, NULL); - switch (irq) { - case 3: sc->priv_info = 0x10; break; - case 5: sc->priv_info = 0x20; break; - case 6: sc->priv_info = 0x40; break; - case 12: sc->priv_info = 0x80; break; - default: - fe_irq_failure(sc->typestr, sc->sc_unit, irq, "3/5/6/12"); - return ENXIO; - } - - /* Setup hooks. We need a special initialization procedure. */ - sc->init = fe_init_rex; - - /* REX-9880 has 64KB SRAM. */ - sc->proto_dlcr6 = FE_D6_BUFSIZ_64KB | FE_D6_TXBSIZ_2x4KB - | FE_D6_BBW_WORD | FE_D6_SBW_WORD | FE_D6_SRAM; -#if 1 - sc->proto_dlcr7 |= FE_D7_EOPPOL; /* XXX */ -#endif - - return 0; -} diff --git a/sys/dev/fe/if_fereg.h b/sys/dev/fe/if_fereg.h index afc9c5704c58c..a349f77044b18 100644 --- a/sys/dev/fe/if_fereg.h +++ b/sys/dev/fe/if_fereg.h @@ -114,14 +114,6 @@ /* - * Registers on RE1000. (*NOT* on RE1000 Plus.) - */ - -/* IRQ configuration. */ -#define FE_RE1000_IRQCONF 0x10 - - -/* * Fujitsu MB86965 JLI mode support routines. */ diff --git a/sys/dev/ic/i8251.h b/sys/dev/ic/i8251.h deleted file mode 100644 index 162ab29e9ac9c..0000000000000 --- a/sys/dev/ic/i8251.h +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * $FreeBSD$ - */ - -/* - * modified for PC9801 by M.Ishii - * Kyoto University Microcomputer Club (KMC) - * - * modified for 8251(FIFO) by Seigo TANIMURA <tanimura@FreeBSD.org> - */ - -/* i8251 mode register */ -#define MOD8251_5BITS 0x00 -#define MOD8251_6BITS 0x04 -#define MOD8251_7BITS 0x08 -#define MOD8251_8BITS 0x0c -#define MOD8251_PENAB 0x10 /* parity enable */ -#define MOD8251_PEVEN 0x20 /* parity even */ -#define MOD8251_STOP1 0x40 /* 1 stop bit */ -#define MOD8251_STOP15 0x80 /* 1.5 stop bit */ -#define MOD8251_STOP2 0xc0 /* 2 stop bit */ -#define MOD8251_CLKx1 0x01 /* x1 */ -#define MOD8251_CLKx16 0x02 /* x16 */ -#define MOD8251_CLKx64 0x03 /* x64 */ - -/* i8251 command register */ -#define CMD8251_TxEN 0x01 /* transmit enable */ -#define CMD8251_DTR 0x02 /* assert DTR */ -#define CMD8251_RxEN 0x04 /* receive enable */ -#define CMD8251_SBRK 0x08 /* send break */ -#define CMD8251_ER 0x10 /* error reset */ -#define CMD8251_RTS 0x20 /* assert RTS */ -#define CMD8251_RESET 0x40 /* internal reset */ -#define CMD8251_EH 0x80 /* enter hunt mode */ - -/* i8251 status register */ -#define STS8251_TxRDY 0x01 /* transmit READY */ -#define STS8251_RxRDY 0x02 /* data exists in receive buffer */ -#define STS8251_TxEMP 0x04 /* transmit buffer EMPTY */ -#define STS8251_PE 0x08 /* perity error */ -#define STS8251_OE 0x10 /* overrun error */ -#define STS8251_FE 0x20 /* framing error */ -#define STS8251_BI 0x40 /* break detect */ -#define STS8251_DSR 0x80 /* DSR is asserted */ - -/* i8251F line status register */ -#define FLSR_TxEMP 0x01 /* transmit buffer EMPTY */ -#define FLSR_TxRDY 0x02 /* transmit READY */ -#define FLSR_RxRDY 0x04 /* data exists in receive buffer */ -#define FLSR_OE 0x10 /* overrun error */ -#define FLSR_PE 0x20 /* perity error */ -#define FLSR_BI 0x80 /* break detect */ - -/* i8251F modem status register */ -#define MSR_DCD 0x80 /* Current Data Carrier Detect */ -#define MSR_RI 0x40 /* Current Ring Indicator */ -#define MSR_DSR 0x20 /* Current Data Set Ready */ -#define MSR_CTS 0x10 /* Current Clear to Send */ -#define MSR_DDCD 0x08 /* DCD has changed state */ -#define MSR_TERI 0x04 /* RI has toggled low to high */ -#define MSR_DDSR 0x02 /* DSR has changed state */ -#define MSR_DCTS 0x01 /* CTS has changed state */ - -/* i8251F interrupt identification register */ -#define IIR_FIFO_CK1 0x40 -#define IIR_FIFO_CK2 0x20 -#define IIR_IMASK 0x0f -#define IIR_RXTOUT 0x0c /* Receiver timeout */ -#define IIR_RLS 0x06 /* Line status change */ -#define IIR_RXRDY 0x04 /* Receiver ready */ -#define IIR_TXRDY 0x02 /* Transmitter ready */ -#define IIR_NOPEND 0x01 /* Transmitter ready */ -#define IIR_MLSC 0x00 /* Modem status */ - -/* i8251F fifo control register */ -#define FIFO_ENABLE 0x01 /* Turn the FIFO on */ -#define FIFO_RCV_RST 0x02 /* Reset RX FIFO */ -#define FIFO_XMT_RST 0x04 /* Reset TX FIFO */ -#define FIFO_LSR_EN 0x08 -#define FIFO_MSR_EN 0x10 -#define FIFO_TRIGGER_1 0x00 /* Trigger RXRDY intr on 1 character */ -#define FIFO_TRIGGER_4 0x40 /* ibid 4 */ -#define FIFO_TRIGGER_8 0x80 /* ibid 8 */ -#define FIFO_TRIGGER_14 0xc0 /* ibid 14 */ diff --git a/sys/dev/ic/wd33c93reg.h b/sys/dev/ic/wd33c93reg.h deleted file mode 100644 index 8e536cd1d32da..0000000000000 --- a/sys/dev/ic/wd33c93reg.h +++ /dev/null @@ -1,165 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: wd33c93reg.h,v 1.21.24.1 2001/06/13 05:52:05 honda Exp $ */ -/* $NetBSD$ */ -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1996, 1997, 1998 - * NetBSD/pc98 porting staff. All rights reserved. - * Copyright (c) 1996, 1997, 1998 - * Naofumi Honda. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _WD33C93REG_H_ -#define _WD33C93REG_H_ - -/* wd33c93 register */ -#define wd3s_oid 0x00 -#define IDR_FS_16_20 0x80 -#define IDR_FS_12_15 0x40 -#define IDR_FS_8_10 0x00 -#define IDR_RAF 0x20 -#define IDR_EHP 0x10 -#define IDR_EAF 0x08 -#define IDR_IDM 0x07 - -#define wd3s_ctrl 0x01 -#define CR_DMA 0x80 -#define CR_DMAD 0x40 -#define CR_HLT_HOST_PARITY 0x10 -#define CR_DIS_INT 0x08 -#define CR_IDIS_INT 0x04 -#define CR_HLT_ATN 0x02 -#define CR_HLT_BUS_PARITY 0x01 -#define CR_DEFAULT (CR_DIS_INT | CR_IDIS_INT) -#define CR_DEFAULT_HP (CR_DEFAULT | CR_HLT_BUS_PARITY) - -#define wd3s_tout 0x02 -#define wd3s_cdb 0x03 -#define wd3s_lun 0x0f -#define wd3s_cph 0x10 -#define wd3s_synch 0x11 -#define wd3s_cnt 0x12 -#define wd3s_did 0x15 -#define DIDR_SCC 0x80 -#define DIDR_DPD 0x40 - -#define wd3s_sid 0x16 -#define SIDR_RESEL 0x80 -#define SIDR_SEL 0x40 -#define SIDR_VALID 0x08 -#define SIDR_IDM 0x07 - -#define wd3s_stat 0x17 - -#define BSR_CM 0xf0 -#define BSR_CMDCPL 0x10 -#define BSR_CMDABT 0x20 -#define BSR_CMDERR 0x40 -#define BSR_CMDREQ 0x80 - -#define BSR_SM 0x0f -#define BSR_PM 0x07 -#define BSR_PHVALID 0x08 -#define BSR_IOR 0x01 -#define BSR_DATAOUT 0x00 -#define BSR_DATAIN 0x01 -#define BSR_CMDOUT 0x02 -#define BSR_STATIN 0x03 -#define BSR_UNSPINFO0 0x04 -#define BSR_UNSPINFO1 0x05 -#define BSR_MSGOUT 0x06 -#define BSR_MSGIN 0x07 - -#define BSR_RESET 0x00 -#define BSR_AFM_RESET 0x01 -#define BSR_SELECTED 0x11 -#define BSR_SATFIN 0x16 -#define BSR_ACKREQ 0x20 -#define BSR_SATSDP 0x21 -#define BSR_RESEL 0x80 -#define BSR_AFM_RESEL 0x81 -#define BSR_DISC 0x85 - -#define wd3s_cmd 0x18 -#define wd3s_data 0x19 -#define wd3s_qtag 0x1a - -#define wd3s_mbank 0x30 -#define MBR_RST 0x02 -#define MBR_IEN 0x04 - -#define wd3s_mwin 0x31 -#define wd3s_auxc 0x33 -#define AUXCR_HIDM 0x07 -#define AUXCR_INTM 0x38 -#define AUXCR_RRST 0x80 - -/* status port */ -#define STR_INT 0x80 -#define STR_LCI 0x40 -#define STR_BSY 0x20 -#define STR_CIP 0x10 -#define STR_PE 0x02 -#define STR_DBR 0x01 -#define STR_BUSY 0xf0 - -/* cmd port */ -#define CMDP_DMES 0x01 -#define CMDP_DMER 0x02 -#define CMDP_TCMS 0x04 -#define CMDP_TCMR 0x08 -#define CMDP_TCIR 0x10 - -/* wd33c93 chip cmds */ -#define WD3S_SBT 0x80 -#define WD3S_RESET 0x00 -#define WD3S_ABORT 0x01 -#define WD3S_ASSERT_ATN 0x02 -#define WD3S_NEGATE_ACK 0x03 -#define WD3S_DISCONNECT 0x04 -#define WD3S_RESELECT 0x05 -#define WD3S_SELECT_ATN 0x06 -#define WD3S_SELECT_NO_ATN 0x07 -#define WD3S_SELECT_ATN_TFR 0x08 -#define WD3S_SELECT_NO_ATN_TFR 0x09 -#define WD3S_RESELECT_RCV_DATA 0x0a -#define WD3S_RESELECT_SEND_DATA 0x0b -#define WD3S_WAIT_SELECT_RCV 0x0c -#define WD3S_CMD_COMPSEQ 0x0d -#define WD3S_SEND_DISC_MSG 0x0e -#define WD3S_SET_IDI 0x0f -#define WD3S_RCV_CMD 0x10 -#define WD3S_RCV_DATA 0x11 -#define WD3S_RCV_MSG_OUT 0x12 -#define WD3S_RCV_UNSP_INFO_OUT 0x13 -#define WD3S_SEND_STATUS 0x14 -#define WD3S_SEND_DATA 0x15 -#define WD3S_SEND_MSG_IN 0x16 -#define WD3S_SEND_UNSP_INFO_IN 0x17 -#define WD3S_TRANSLATE_ADDRESS 0x18 -#define WD3S_TFR_INFO 0x20 - -#endif /* !_WD33C93REG_H_ */ diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 24dc9bbe48ea9..2452507002ae3 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -1327,13 +1327,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate, state &= ~NLKDOWN; break; case CLK: -#ifndef PC98 state &= ~CLKDOWN; -#else - state &= ~CLKED; - i = state & LOCK_MASK; - (void)kbdd_ioctl(kbd, KDSETLED, (caddr_t)&i); -#endif break; case SLK: state &= ~SLKDOWN; @@ -1363,13 +1357,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate, set_lockkey_state(kbd, state, NLK); break; case CLK: -#ifndef PC98 set_lockkey_state(kbd, state, CLK); -#else - state |= CLKED; - i = state & LOCK_MASK; - (void)kbdd_ioctl(kbd, KDSETLED, (caddr_t)&i); -#endif break; case SLK: set_lockkey_state(kbd, state, SLK); diff --git a/sys/dev/le/am79900.c b/sys/dev/le/am79900.c index 5ea82284535cb..74f9e5c802f32 100644 --- a/sys/dev/le/am79900.c +++ b/sys/dev/le/am79900.c @@ -254,7 +254,7 @@ am79900_rint(struct lance_softc *sc) struct lermd rmd; uint32_t rmd1; int bix, rp; -#if defined(__i386__) && !defined(PC98) +#if defined(__i386__) struct ether_header *eh; #endif @@ -315,7 +315,7 @@ am79900_rint(struct lance_softc *sc) if (m != NULL) { if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); -#if defined(__i386__) && !defined(PC98) +#if defined(__i386__) /* * The VMware LANCE does not present IFF_SIMPLEX * behavior on multicast packets. Thus drop the diff --git a/sys/dev/le/if_le_cbus.c b/sys/dev/le/if_le_cbus.c deleted file mode 100644 index 7b493f9f798d2..0000000000000 --- a/sys/dev/le/if_le_cbus.c +++ /dev/null @@ -1,443 +0,0 @@ -/*- - * Copyright (c) 1994-2000 - * Paul Richards. All rights reserved. - * - * PC-98 port by Chiharu Shibata & FreeBSD(98) porting team. - * - * 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, - * verbatim and that no modifications are made prior to this - * point in the file. - * 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 Paul Richards may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS 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. - * - * from: FreeBSD: src/sys/dev/lnc/if_lnc_cbus.c,v 1.12 2005/11/12 19:14:21 - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/bus.h> -#include <sys/endian.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/module.h> -#include <sys/mutex.h> -#include <sys/resource.h> -#include <sys/rman.h> -#include <sys/socket.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_media.h> - -#include <machine/bus.h> -#include <machine/resource.h> - -#include <isa/isavar.h> - -#include <dev/le/lancereg.h> -#include <dev/le/lancevar.h> -#include <dev/le/am7990var.h> - -#define LE_CBUS_MEMSIZE (16*1024) -#define CNET98S_IOSIZE 32 -#define CNET98S_RDP 0x10 -#define CNET98S_RAP 0x12 -#define CNET98S_RESET 0x14 -#define CNET98S_BDP 0x16 - -struct le_cbus_softc { - struct am7990_softc sc_am7990; /* glue to MI code */ - - struct resource *sc_rres; - - struct resource *sc_ires; - void *sc_ih; - - bus_dma_tag_t sc_pdmat; - bus_dma_tag_t sc_dmat; - bus_dmamap_t sc_dmam; -}; - -static device_probe_t le_cbus_probe; -static device_attach_t le_cbus_attach; -static device_detach_t le_cbus_detach; -static device_resume_t le_cbus_resume; -static device_suspend_t le_cbus_suspend; - -static device_method_t le_cbus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, le_cbus_probe), - DEVMETHOD(device_attach, le_cbus_attach), - DEVMETHOD(device_detach, le_cbus_detach), - /* We can just use the suspend method here. */ - DEVMETHOD(device_shutdown, le_cbus_suspend), - DEVMETHOD(device_suspend, le_cbus_suspend), - DEVMETHOD(device_resume, le_cbus_resume), - - { 0, 0 } -}; - -DEFINE_CLASS_0(le, le_cbus_driver, le_cbus_methods, sizeof(struct le_cbus_softc)); -DRIVER_MODULE(le, isa, le_cbus_driver, le_devclass, 0, 0); -MODULE_DEPEND(le, ether, 1, 1, 1); - -static bus_addr_t le_ioaddr_cnet98s[CNET98S_IOSIZE] = { - 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, - 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f, - 0x400, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, - 0x408, 0x409, 0x40a, 0x40b, 0x40c, 0x40d, 0x40e, 0x40f, -}; - -static void le_cbus_wrbcr(struct lance_softc *, uint16_t, uint16_t); -#ifdef LEDEBUG -static uint16_t le_cbus_rdbcr(struct lance_softc *, uint16_t); -#endif -static void le_cbus_wrcsr(struct lance_softc *, uint16_t, uint16_t); -static uint16_t le_cbus_rdcsr(struct lance_softc *, uint16_t); -static void le_cbus_hwreset(struct lance_softc *); -static bus_dmamap_callback_t le_cbus_dma_callback; - -static void -le_cbus_wrbcr(struct lance_softc *sc, uint16_t port, uint16_t val) -{ - struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - - bus_write_2(lesc->sc_rres, CNET98S_RAP, port); - bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); - bus_write_2(lesc->sc_rres, CNET98S_BDP, val); -} - -#ifdef LEDEBUG -static uint16_t -le_cbus_rdbcr(struct lance_softc *sc, uint16_t port) -{ - struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - - bus_write_2(lesc->sc_rres, CNET98S_RAP, port); - bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); - return (bus_read_2(lesc->sc_rres, CNET98S_BDP)); -} -#endif - -static void -le_cbus_wrcsr(struct lance_softc *sc, uint16_t port, uint16_t val) -{ - struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - - bus_write_2(lesc->sc_rres, CNET98S_RAP, port); - bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); - bus_write_2(lesc->sc_rres, CNET98S_RDP, val); -} - -static uint16_t -le_cbus_rdcsr(struct lance_softc *sc, uint16_t port) -{ - struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - - bus_write_2(lesc->sc_rres, CNET98S_RAP, port); - bus_barrier(lesc->sc_rres, CNET98S_RAP, 2, BUS_SPACE_BARRIER_WRITE); - return (bus_read_2(lesc->sc_rres, CNET98S_RDP)); -} - -static void -le_cbus_hwreset(struct lance_softc *sc) -{ - struct le_cbus_softc *lesc = (struct le_cbus_softc *)sc; - - /* - * NB: These are Contec C-NET(98)S only. - */ - - /* Reset the chip. */ - bus_write_2(lesc->sc_rres, CNET98S_RESET, - bus_read_2(lesc->sc_rres, CNET98S_RESET)); - DELAY(500); - - /* ISA bus configuration */ - /* ISACSR0 - set Master Mode Read Active time to 300ns. */ - le_cbus_wrbcr(sc, LE_BCR0, 0x0006); - /* ISACSR1 - set Master Mode Write Active time to 300ns. */ - le_cbus_wrbcr(sc, LE_BCR1, 0x0006); -#ifdef LEDEBUG - device_printf(dev, "ISACSR2=0x%x\n", le_cbus_rdbcr(sc, LE_BCR2)); -#endif - /* ISACSR5 - LED1 */ - le_cbus_wrbcr(sc, LE_BCR5, LE_B4_PSE | LE_B4_XMTE); - /* ISACSR6 - LED2 */ - le_cbus_wrbcr(sc, LE_BCR6, LE_B4_PSE | LE_B4_RCVE); - /* ISACSR7 - LED3 */ - le_cbus_wrbcr(sc, LE_BCR7, LE_B4_PSE | LE_B4_COLE); -} - -static void -le_cbus_dma_callback(void *xsc, bus_dma_segment_t *segs, int nsegs, int error) -{ - struct lance_softc *sc = (struct lance_softc *)xsc; - - if (error != 0) - return; - KASSERT(nsegs == 1, ("%s: bad DMA segment count", __func__)); - sc->sc_addr = segs[0].ds_addr; -} - -static int -le_cbus_probe(device_t dev) -{ - struct le_cbus_softc *lesc; - struct lance_softc *sc; - int error, i; - - /* - * Skip PnP devices as some wedge when trying to probe them as - * C-NET(98)S. - */ - if (isa_get_vendorid(dev)) - return (ENXIO); - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - i = 0; - lesc->sc_rres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &i, - le_ioaddr_cnet98s, CNET98S_IOSIZE, RF_ACTIVE); - if (lesc->sc_rres == NULL) - return (ENXIO); - isa_load_resourcev(lesc->sc_rres, le_ioaddr_cnet98s, CNET98S_IOSIZE); - - /* Reset the chip. */ - bus_write_2(lesc->sc_rres, CNET98S_RESET, - bus_read_2(lesc->sc_rres, CNET98S_RESET)); - DELAY(500); - - /* Stop the chip and put it in a known state. */ - le_cbus_wrcsr(sc, LE_CSR0, LE_C0_STOP); - DELAY(100); - if (le_cbus_rdcsr(sc, LE_CSR0) != LE_C0_STOP) { - error = ENXIO; - goto fail; - } - le_cbus_wrcsr(sc, LE_CSR3, 0); - device_set_desc(dev, "C-NET(98)S"); - error = BUS_PROBE_DEFAULT; - - fail: - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(lesc->sc_rres), lesc->sc_rres); - return (error); -} - -static int -le_cbus_attach(device_t dev) -{ - struct le_cbus_softc *lesc; - struct lance_softc *sc; - int error, i; - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - LE_LOCK_INIT(sc, device_get_nameunit(dev)); - - i = 0; - lesc->sc_rres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &i, - le_ioaddr_cnet98s, CNET98S_IOSIZE, RF_ACTIVE); - if (lesc->sc_rres == NULL) { - device_printf(dev, "cannot allocate registers\n"); - error = ENXIO; - goto fail_mtx; - } - isa_load_resourcev(lesc->sc_rres, le_ioaddr_cnet98s, CNET98S_IOSIZE); - - i = 0; - if ((lesc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &i, RF_SHAREABLE | RF_ACTIVE)) == NULL) { - device_printf(dev, "cannot allocate interrupt\n"); - error = ENXIO; - goto fail_rres; - } - - error = bus_dma_tag_create( - bus_get_dma_tag(dev), /* parent */ - 1, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_24BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ - 0, /* nsegments */ - BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &lesc->sc_pdmat); - if (error != 0) { - device_printf(dev, "cannot allocate parent DMA tag\n"); - goto fail_ires; - } - - sc->sc_memsize = LE_CBUS_MEMSIZE; - /* - * For Am79C90, Am79C961 and Am79C961A the init block must be 2-byte - * aligned and the ring descriptors must be 8-byte aligned. - */ - error = bus_dma_tag_create( - lesc->sc_pdmat, /* parent */ - 8, 0, /* alignment, boundary */ - BUS_SPACE_MAXADDR_24BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - sc->sc_memsize, /* maxsize */ - 1, /* nsegments */ - sc->sc_memsize, /* maxsegsize */ - 0, /* flags */ - NULL, NULL, /* lockfunc, lockarg */ - &lesc->sc_dmat); - if (error != 0) { - device_printf(dev, "cannot allocate buffer DMA tag\n"); - goto fail_pdtag; - } - - error = bus_dmamem_alloc(lesc->sc_dmat, (void **)&sc->sc_mem, - BUS_DMA_WAITOK | BUS_DMA_COHERENT, &lesc->sc_dmam); - if (error != 0) { - device_printf(dev, "cannot allocate DMA buffer memory\n"); - goto fail_dtag; - } - - sc->sc_addr = 0; - error = bus_dmamap_load(lesc->sc_dmat, lesc->sc_dmam, sc->sc_mem, - sc->sc_memsize, le_cbus_dma_callback, sc, 0); - if (error != 0 || sc->sc_addr == 0) { - device_printf(dev, "cannot load DMA buffer map\n"); - goto fail_dmem; - } - - sc->sc_flags = 0; - sc->sc_conf3 = 0; - - /* - * Extract the physical MAC address from the ROM. - */ - for (i = 0; i < sizeof(sc->sc_enaddr); i++) - sc->sc_enaddr[i] = bus_read_1(lesc->sc_rres, i * 2); - - sc->sc_copytodesc = lance_copytobuf_contig; - sc->sc_copyfromdesc = lance_copyfrombuf_contig; - sc->sc_copytobuf = lance_copytobuf_contig; - sc->sc_copyfrombuf = lance_copyfrombuf_contig; - sc->sc_zerobuf = lance_zerobuf_contig; - - sc->sc_rdcsr = le_cbus_rdcsr; - sc->sc_wrcsr = le_cbus_wrcsr; - sc->sc_hwreset = le_cbus_hwreset; - sc->sc_hwinit = NULL; - sc->sc_hwintr = NULL; - sc->sc_nocarrier = NULL; - sc->sc_mediachange = NULL; - sc->sc_mediastatus = NULL; - sc->sc_supmedia = NULL; - - error = am7990_config(&lesc->sc_am7990, device_get_name(dev), - device_get_unit(dev)); - if (error != 0) { - device_printf(dev, "cannot attach Am7990\n"); - goto fail_dmap; - } - - error = bus_setup_intr(dev, lesc->sc_ires, INTR_TYPE_NET | INTR_MPSAFE, - NULL, am7990_intr, sc, &lesc->sc_ih); - if (error != 0) { - device_printf(dev, "cannot set up interrupt\n"); - goto fail_am7990; - } - - return (0); - - fail_am7990: - am7990_detach(&lesc->sc_am7990); - fail_dmap: - bus_dmamap_unload(lesc->sc_dmat, lesc->sc_dmam); - fail_dmem: - bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); - fail_dtag: - bus_dma_tag_destroy(lesc->sc_dmat); - fail_pdtag: - bus_dma_tag_destroy(lesc->sc_pdmat); - fail_ires: - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(lesc->sc_ires), lesc->sc_ires); - fail_rres: - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(lesc->sc_rres), lesc->sc_rres); - fail_mtx: - LE_LOCK_DESTROY(sc); - return (error); -} - -static int -le_cbus_detach(device_t dev) -{ - struct le_cbus_softc *lesc; - struct lance_softc *sc; - - lesc = device_get_softc(dev); - sc = &lesc->sc_am7990.lsc; - - bus_teardown_intr(dev, lesc->sc_ires, lesc->sc_ih); - am7990_detach(&lesc->sc_am7990); - bus_dmamap_unload(lesc->sc_dmat, lesc->sc_dmam); - bus_dmamem_free(lesc->sc_dmat, sc->sc_mem, lesc->sc_dmam); - bus_dma_tag_destroy(lesc->sc_dmat); - bus_dma_tag_destroy(lesc->sc_pdmat); - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(lesc->sc_ires), lesc->sc_ires); - bus_release_resource(dev, SYS_RES_IOPORT, - rman_get_rid(lesc->sc_rres), lesc->sc_rres); - LE_LOCK_DESTROY(sc); - - return (0); -} - -static int -le_cbus_suspend(device_t dev) -{ - struct le_cbus_softc *lesc; - - lesc = device_get_softc(dev); - - lance_suspend(&lesc->sc_am7990.lsc); - - return (0); -} - -static int -le_cbus_resume(device_t dev) -{ - struct le_cbus_softc *lesc; - - lesc = device_get_softc(dev); - - lance_resume(&lesc->sc_am7990.lsc); - - return (0); -} diff --git a/sys/dev/mse/mse_cbus.c b/sys/dev/mse/mse_cbus.c deleted file mode 100644 index 21924b60b9ee8..0000000000000 --- a/sys/dev/mse/mse_cbus.c +++ /dev/null @@ -1,301 +0,0 @@ -/*- - * Copyright (c) 2004 M. Warner Losh - * 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. - * - * 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. - * - * $FreeBSD$ - */ - -/*- - * Copyright 1992 by the University of Guelph - * - * Permission to use, copy and modify this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting - * documentation. - * University of Guelph makes no representations about the suitability of - * this software for any purpose. It is provided "as is" - * without express or implied warranty. - */ -/* - * Driver for the Logitech and ATI Inport Bus mice for use with 386bsd and - * the X386 port, courtesy of - * Rick Macklem, rick@snowhite.cis.uoguelph.ca - * Caveats: The driver currently uses spltty(), but doesn't use any - * generic tty code. It could use splmse() (that only masks off the - * bus mouse interrupt, but that would require hacking in i386/isa/icu.s. - * (This may be worth the effort, since the Logitech generates 30/60 - * interrupts/sec continuously while it is open.) - * NB: The ATI has NOT been tested yet! - */ - -/* - * Modification history: - * Sep 6, 1994 -- Lars Fredriksen(fredriks@mcs.com) - * improved probe based on input from Logitech. - * - * Oct 19, 1992 -- E. Stark (stark@cs.sunysb.edu) - * fixes to make it work with Microsoft InPort busmouse - * - * Jan, 1993 -- E. Stark (stark@cs.sunysb.edu) - * added patches for new "select" interface - * - * May 4, 1993 -- E. Stark (stark@cs.sunysb.edu) - * changed position of some spl()'s in mseread - * - * October 8, 1993 -- E. Stark (stark@cs.sunysb.edu) - * limit maximum negative x/y value to -127 to work around XFree problem - * that causes spurious button pushes. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/conf.h> -#include <sys/kernel.h> -#include <sys/module.h> -#include <sys/bus.h> -#include <sys/poll.h> -#include <sys/selinfo.h> -#include <sys/uio.h> -#include <sys/mouse.h> - -#include <machine/bus.h> -#include <machine/resource.h> -#include <sys/rman.h> - -#include <isa/isavar.h> - -#include <dev/mse/msevar.h> - -static int mse_cbus_probe(device_t dev); -static int mse_cbus_attach(device_t dev); - -static device_method_t mse_methods[] = { - DEVMETHOD(device_probe, mse_cbus_probe), - DEVMETHOD(device_attach, mse_cbus_attach), - DEVMETHOD(device_detach, mse_detach), - { 0, 0 } -}; - -static driver_t mse_driver = { - "mse", - mse_methods, - sizeof(mse_softc_t), -}; - -DRIVER_MODULE(mse, isa, mse_driver, mse_devclass, 0, 0); - -static struct isa_pnp_id mse_ids[] = { -#if 0 - { 0x001fa3b8, "PC-98 bus mouse" }, /* NEC1F00 */ -#endif - { 0 } -}; - -/* - * PC-9801 Bus mouse definitions - */ - -#define MODE MSE_PORTD -#define HC MSE_PORTD -#define INT MSE_PORTD - -#define XL 0x00 -#define XH 0x20 -#define YL 0x40 -#define YH 0x60 - -#define INT_ENABLE 0x8 -#define INT_DISABLE 0x9 -#define HC_NO_CLEAR 0xe -#define HC_CLEAR 0xf - -static bus_addr_t mse_port[] = {0, 2, 4, 6}; - -static int mse_probe98m(device_t dev, mse_softc_t *sc); -static void mse_disable98m(struct resource *port); -static void mse_get98m(struct resource *port, - int *dx, int *dy, int *but); -static void mse_enable98m(struct resource *port); - -static struct mse_types mse_types[] = { - { MSE_98BUSMOUSE, - mse_probe98m, mse_enable98m, mse_disable98m, mse_get98m, - { 2, MOUSE_IF_BUS, MOUSE_MOUSE, MOUSE_MODEL_GENERIC, 0, }, - { MOUSE_PROTO_BUS, -1, -1, 0, 0, MOUSE_MSC_PACKETSIZE, - { MOUSE_MSC_SYNCMASK, MOUSE_MSC_SYNC, }, }, }, - { 0, }, -}; - -static int -mse_cbus_probe(device_t dev) -{ - mse_softc_t *sc; - int error; - int rid; - int i; - - /* check PnP IDs */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, mse_ids); - if (error == ENXIO) - return error; - - sc = device_get_softc(dev); - rid = 0; - sc->sc_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, mse_port, - MSE_IOSIZE, RF_ACTIVE); - if (sc->sc_port == NULL) - return ENXIO; - if (isa_load_resourcev(sc->sc_port, mse_port, MSE_IOSIZE)) { - bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); - return ENXIO; - } - - /* - * Check for each mouse type in the table. - */ - i = 0; - while (mse_types[i].m_type) { - if ((*mse_types[i].m_probe)(dev, sc)) { - sc->sc_mousetype = mse_types[i].m_type; - sc->sc_enablemouse = mse_types[i].m_enable; - sc->sc_disablemouse = mse_types[i].m_disable; - sc->sc_getmouse = mse_types[i].m_get; - sc->hw = mse_types[i].m_hw; - sc->mode = mse_types[i].m_mode; - bus_release_resource(dev, SYS_RES_IOPORT, rid, - sc->sc_port); - device_set_desc(dev, "Bus/InPort Mouse"); - return 0; - } - i++; - } - bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); - return ENXIO; -} - -static int -mse_cbus_attach(device_t dev) -{ - mse_softc_t *sc; - int rid; - - sc = device_get_softc(dev); - - rid = 0; - sc->sc_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, mse_port, - MSE_IOSIZE, RF_ACTIVE); - if (sc->sc_port == NULL) - return ENXIO; - if (isa_load_resourcev(sc->sc_port, mse_port, MSE_IOSIZE)) { - bus_release_resource(dev, SYS_RES_IOPORT, rid, sc->sc_port); - return ENXIO; - } - - return (mse_common_attach(dev)); -} - -/* - * Routines for the PC98 bus mouse. - */ - -/* - * Test for a PC98 bus mouse and return 1 if it is. - * (do not enable interrupts) - */ -static int -mse_probe98m(device_t dev, mse_softc_t *sc) -{ - /* mode set */ - bus_write_1(sc->sc_port, MODE, 0x93); - - /* initialize */ - /* INT disable */ - bus_write_1(sc->sc_port, INT, INT_DISABLE); - /* HC = 0 */ - bus_write_1(sc->sc_port, HC, HC_NO_CLEAR); - /* HC = 1 */ - bus_write_1(sc->sc_port, HC, HC_CLEAR); - - return (1); -} - -/* - * Initialize PC98 bus mouse and enable interrupts. - */ -static void -mse_enable98m(struct resource *port) -{ - bus_write_1(port, INT, INT_ENABLE); /* INT enable */ - bus_write_1(port, HC, HC_NO_CLEAR); /* HC = 0 */ - bus_write_1(port, HC, HC_CLEAR); /* HC = 1 */ -} - -/* - * Disable interrupts for PC98 Bus mouse. - */ -static void -mse_disable98m(struct resource *port) -{ - bus_write_1(port, INT, INT_DISABLE); /* INT disable */ - bus_write_1(port, HC, HC_NO_CLEAR); /* HC = 0 */ - bus_write_1(port, HC, HC_CLEAR); /* HC = 1 */ -} - -/* - * Get current dx, dy and up/down button state. - */ -static void -mse_get98m(struct resource *port, int *dx, int *dy, int *but) -{ - register char x, y; - - bus_write_1(port, INT, INT_DISABLE); /* INT disable */ - - bus_write_1(port, HC, HC_CLEAR); /* HC = 1 */ - - /* X low */ - bus_write_1(port, MSE_PORTC, 0x90 | XL); - x = bus_read_1(port, MSE_PORTA) & 0x0f; - /* X high */ - bus_write_1(port, MSE_PORTC, 0x90 | XH); - x |= ((bus_read_1(port, MSE_PORTA) & 0x0f) << 4); - - /* Y low */ - bus_write_1(port, MSE_PORTC, 0x90 | YL); - y = (bus_read_1(port, MSE_PORTA) & 0x0f); - /* Y high */ - bus_write_1(port, MSE_PORTC, 0x90 | YH); - y |= ((bus_read_1(port, MSE_PORTA) & 0x0f) << 4); - - *but = (bus_read_1(port, MSE_PORTA) >> 5) & 7; - - *dx = x; - *dy = y; - - bus_write_1(port, HC, HC_NO_CLEAR); /* HC = 0 */ - - bus_write_1(port, INT, INT_ENABLE); /* INT enable */ -} diff --git a/sys/dev/mse/msevar.h b/sys/dev/mse/msevar.h index 74a393f0ef0a8..19b069ea27d59 100644 --- a/sys/dev/mse/msevar.h +++ b/sys/dev/mse/msevar.h @@ -87,9 +87,6 @@ typedef struct mse_softc { /* and Mouse Types */ #define MSE_NONE 0 /* don't move this! */ -/* pc98 bus mouse types */ -#define MSE_98BUSMOUSE 0x1 - /* isa bus mouse types */ #define MSE_LOGITECH 0x1 #define MSE_ATIINPORT 0x2 diff --git a/sys/dev/pccbb/pccbb_isa.c b/sys/dev/pccbb/pccbb_isa.c index 6ef441f35e94d..d2a0d03fc9333 100644 --- a/sys/dev/pccbb/pccbb_isa.c +++ b/sys/dev/pccbb/pccbb_isa.c @@ -113,8 +113,6 @@ static struct isa_pnp_id pcic_ids[] = { {EXCA_PNP_VLSI_82C146, NULL}, /* PNP0E02 */ {EXCA_PNP_82365_CARDBUS, NULL}, /* PNP0E03 */ {EXCA_PNP_SCM_SWAPBOX, NULL}, /* SCM0469 */ - {EXCA_NEC_PC9801_102, NULL}, /* NEC8091 */ - {EXCA_NEC_PC9821RA_E01, NULL}, /* NEC8121 */ {0} }; diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 3cc6ac343e9ce..3e7c7447a8f0d 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -207,7 +207,7 @@ vga_pci_unmap_bios(device_t dev, void *bios) int vga_pci_repost(device_t dev) { -#if defined(__amd64__) || (defined(__i386__) && !defined(PC98)) +#if defined(__amd64__) || defined(__i386__) x86regs_t regs; if (!vga_pci_is_boot_display(dev)) diff --git a/sys/dev/ppc/ppc.c b/sys/dev/ppc/ppc.c index 4c6761fb279c9..9515039036d98 100644 --- a/sys/dev/ppc/ppc.c +++ b/sys/dev/ppc/ppc.c @@ -67,11 +67,6 @@ static void ppcintr(void *arg); #define LOG_PPC(function, ppc, string) \ if (bootverbose) printf("%s: %s\n", function, string) -#if defined(__i386__) && defined(PC98) -#define PC98_IEEE_1284_DISABLE 0x100 -#define PC98_IEEE_1284_PORT 0x140 -#endif - #define DEVTOSOFTC(dev) ((struct ppc_data *)device_get_softc(dev)) /* @@ -1667,10 +1662,6 @@ ppc_probe(device_t dev, int rid) { #ifdef __i386__ static short next_bios_ppc = 0; -#ifdef PC98 - unsigned int pc98_ieee_mode = 0x00; - unsigned int tmp; -#endif #endif struct ppc_data *ppc; int error; @@ -1692,16 +1683,6 @@ ppc_probe(device_t dev, int rid) * If port not specified, use bios list. */ if (error) { -#ifdef PC98 - if (next_bios_ppc == 0) { - /* Use default IEEE-1284 port of NEC PC-98x1 */ - port = PC98_IEEE_1284_PORT; - next_bios_ppc += 1; - if (bootverbose) - device_printf(dev, - "parallel port found at 0x%jx\n", port); - } -#else if ((next_bios_ppc < BIOS_MAX_PPC) && (*(BIOS_PORTS + next_bios_ppc) != 0)) { port = *(BIOS_PORTS + next_bios_ppc++); @@ -1712,7 +1693,6 @@ ppc_probe(device_t dev, int rid) device_printf(dev, "parallel port not found.\n"); return (ENXIO); } -#endif /* PC98 */ bus_set_resource(dev, SYS_RES_IOPORT, rid, port, IO_LPTSIZE_EXTENDED); } @@ -1771,30 +1751,6 @@ ppc_probe(device_t dev, int rid) ppc->ppc_type = PPC_TYPE_GENERIC; -#if defined(__i386__) && defined(PC98) - /* - * IEEE STD 1284 Function Check and Enable - * for default IEEE-1284 port of NEC PC-98x1 - */ - if (ppc->ppc_base == PC98_IEEE_1284_PORT && - !(ppc->ppc_flags & PC98_IEEE_1284_DISABLE)) { - tmp = inb(ppc->ppc_base + PPC_1284_ENABLE); - pc98_ieee_mode = tmp; - if ((tmp & 0x10) == 0x10) { - outb(ppc->ppc_base + PPC_1284_ENABLE, tmp & ~0x10); - tmp = inb(ppc->ppc_base + PPC_1284_ENABLE); - if ((tmp & 0x10) == 0x10) - goto error; - } else { - outb(ppc->ppc_base + PPC_1284_ENABLE, tmp | 0x10); - tmp = inb(ppc->ppc_base + PPC_1284_ENABLE); - if ((tmp & 0x10) != 0x10) - goto error; - } - outb(ppc->ppc_base + PPC_1284_ENABLE, pc98_ieee_mode | 0x10); - } -#endif - /* * Try to detect the chipset and its mode. */ @@ -1804,12 +1760,6 @@ ppc_probe(device_t dev, int rid) return (0); error: -#if defined(__i386__) && defined(PC98) - if (ppc->ppc_base == PC98_IEEE_1284_PORT && - !(ppc->ppc_flags & PC98_IEEE_1284_DISABLE)) { - outb(ppc->ppc_base + PPC_1284_ENABLE, pc98_ieee_mode); - } -#endif if (ppc->res_irq != 0) { bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq, ppc->res_irq); diff --git a/sys/dev/ppc/ppcreg.h b/sys/dev/ppc/ppcreg.h index a7295033d7318..fa1f165d6daa0 100644 --- a/sys/dev/ppc/ppcreg.h +++ b/sys/dev/ppc/ppcreg.h @@ -130,18 +130,10 @@ struct ppc_data { #define PPC_SPP_CTR 2 /* SPP control register */ #define PPC_EPP_ADDR 3 /* EPP address register (8 bit) */ #define PPC_EPP_DATA 4 /* EPP data register (8, 16 or 32 bit) */ -#if defined(__i386__) && defined(PC98) -#define PPC_1284_ENABLE 0x09 /* IEEE STD 1284 Enable register */ -#define PPC_ECP_D_FIFO 0x0c /* ECP Data fifo register */ -#define PPC_ECP_CNFGA 0x0c /* Configuration register A */ -#define PPC_ECP_CNFGB 0x0d /* Configuration register B */ -#define PPC_ECP_ECR 0x0e /* ECP extended control register */ -#else #define PPC_ECP_D_FIFO 0x400 /* ECP Data fifo register */ #define PPC_ECP_CNFGA 0x400 /* Configuration register A */ #define PPC_ECP_CNFGB 0x401 /* Configuration register B */ #define PPC_ECP_ECR 0x402 /* ECP extended control register */ -#endif #define PPC_FIFO_EMPTY 0x1 /* ecr register - bit 0 */ #define PPC_FIFO_FULL 0x2 /* ecr register - bit 1 */ diff --git a/sys/dev/sio/sio_pccard.c b/sys/dev/sio/sio_pccard.c index 7bdb755d8051d..93757c73870c8 100644 --- a/sys/dev/sio/sio_pccard.c +++ b/sys/dev/sio/sio_pccard.c @@ -87,9 +87,6 @@ sio_pccard_attach(device_t dev) { int err; -#ifdef PC98 - SET_FLAG(dev, SET_IFTYPE(COM_IF_MODEM_CARD)); -#endif /* Do not probe IRQ - pccard doesn't turn on the interrupt line */ /* until bus_setup_intr */ if ((err = sioprobe(dev, 0, 0UL, 1)) > 0) diff --git a/sys/dev/sio/sio_pci.c b/sys/dev/sio/sio_pci.c index a693536d33cd1..34010acada1e9 100644 --- a/sys/dev/sio/sio_pci.c +++ b/sys/dev/sio/sio_pci.c @@ -118,9 +118,7 @@ sio_pci_probe(dev) if (id->desc == NULL) return (ENXIO); device_set_desc(dev, id->desc); -#ifdef PC98 - SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550)); -#endif + return (sioprobe(dev, id->rid, 0UL, 0)); } diff --git a/sys/dev/sio/sio_puc.c b/sys/dev/sio/sio_puc.c index 0ae0e7d6424d7..199254b082013 100644 --- a/sys/dev/sio/sio_puc.c +++ b/sys/dev/sio/sio_puc.c @@ -89,9 +89,7 @@ sio_puc_probe(device_t dev) if (BUS_READ_IVAR(parent, dev, PUC_IVAR_CLOCK, &rclk)) rclk = DEFAULT_RCLK; -#ifdef PC98 - SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550)); -#endif + error = sioprobe(dev, 0, rclk, 1); return ((error > 0) ? error : BUS_PROBE_LOW_PRIORITY); } diff --git a/sys/dev/sio/siovar.h b/sys/dev/sio/siovar.h index 22a6019d8e62e..1a0abddf7a098 100644 --- a/sys/dev/sio/siovar.h +++ b/sys/dev/sio/siovar.h @@ -29,36 +29,6 @@ * $FreeBSD$ */ -#ifdef PC98 -#define COM_IF_INTERNAL 0x00 -#define COM_IF_PC9861K_1 0x01 -#define COM_IF_PC9861K_2 0x02 -#define COM_IF_IND_SS_1 0x03 -#define COM_IF_IND_SS_2 0x04 -#define COM_IF_PIO9032B_1 0x05 -#define COM_IF_PIO9032B_2 0x06 -#define COM_IF_B98_01_1 0x07 -#define COM_IF_B98_01_2 0x08 -#define COM_IF_END1 COM_IF_B98_01_2 -#define COM_IF_RSA98 0x10 /* same as COM_IF_NS16550 */ -#define COM_IF_NS16550 0x11 -#define COM_IF_SECOND_CCU 0x12 /* same as COM_IF_NS16550 */ -#define COM_IF_MC16550II 0x13 -#define COM_IF_MCRS98 0x14 /* same as COM_IF_MC16550II */ -#define COM_IF_RSB3000 0x15 -#define COM_IF_RSB384 0x16 -#define COM_IF_MODEM_CARD 0x17 -#define COM_IF_RSA98III 0x18 -#define COM_IF_ESP98 0x19 -#define COM_IF_END2 COM_IF_ESP98 - -#define GET_IFTYPE(type) (((type) >> 24) & 0x1f) -#define SET_IFTYPE(type) ((type) << 24) - -#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit)) -#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit)) -#endif /* PC98 */ - int sioattach(device_t dev, int xrid, u_long rclk); int siodetach(device_t dev); int sioprobe(device_t dev, int xrid, u_long rclk, int noprobe); diff --git a/sys/dev/snc/dp83932.c b/sys/dev/snc/dp83932.c deleted file mode 100644 index acda11c2c00f6..0000000000000 --- a/sys/dev/snc/dp83932.c +++ /dev/null @@ -1,1198 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: dp83932.c,v 1.5 1999/07/29 05:08:44 kmatsuda Exp $ */ -/* $NetBSD: if_snc.c,v 1.18 1998/04/25 21:27:40 scottr Exp $ */ - -/*- - * Copyright (c) 1997, 1998, 1999 - * Kouichi Matsuda. 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 Kouichi Matsuda for - * NetBSD/pc98. - * 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. - */ - -/* - * Modified for FreeBSD(98) 4.0 from NetBSD/pc98 1.4.2 by Motomichi Matsuzaki. - */ - -/* - * Modified for NetBSD/pc98 1.2G from NetBSD/mac68k 1.2G by Kouichi Matsuda. - * Make adapted for NEC PC-9801-83, 84, PC-9801-103, 104, PC-9801N-25 and - * PC-9801N-J02, J02R, which uses National Semiconductor DP83934AVQB as - * Ethernet Controller and National Semiconductor NS46C46 as - * (64 * 16 bits) Microwire Serial EEPROM. - */ - -/*- - * National Semiconductor DP8393X SONIC Driver - * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) - * You may use, copy, and modify this program so long as you retain the - * copyright line. - * - * This driver has been substantially modified since Algorithmics donated - * it. - * - * Denton Gentry <denny1@home.com> - * and also - * Yanagisawa Takeshi <yanagisw@aa.ap.titech.ac.jp> - * did the work to get this running on the Macintosh. - */ - -#include "opt_inet.h" - -#include <sys/param.h> -#include <sys/kernel.h> -#include <sys/systm.h> -#include <sys/sockio.h> -#include <sys/mbuf.h> -#include <sys/protosw.h> -#include <sys/socket.h> -#include <sys/syslog.h> -#include <sys/errno.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_var.h> -#include <net/if_arp.h> -#include <net/if_dl.h> -#include <net/if_media.h> -#include <net/if_types.h> - -#include <net/bpf.h> - -#include <sys/bus.h> -#include <machine/bus.h> -#include <dev/snc/dp83932reg.h> -#include <dev/snc/dp83932var.h> - -static void sncwatchdog(void *); -static void sncinit(void *); -static void sncinit_locked(struct snc_softc *); -static int sncstop(struct snc_softc *sc); -static int sncioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -static void sncstart(struct ifnet *ifp); -static void sncstart_locked(struct ifnet *ifp); -static void sncreset(struct snc_softc *sc); - -static void caminitialise(struct snc_softc *); -static void camentry(struct snc_softc *, int, u_char *ea); -static void camprogram(struct snc_softc *); -static void initialise_tda(struct snc_softc *); -static void initialise_rda(struct snc_softc *); -static void initialise_rra(struct snc_softc *); -#ifdef SNCDEBUG -static void camdump(struct snc_softc *sc); -#endif - -static void sonictxint(struct snc_softc *); -static void sonicrxint(struct snc_softc *); - -static u_int sonicput(struct snc_softc *sc, struct mbuf *m0, int mtd_next); -static int sonic_read(struct snc_softc *, u_int32_t, int); -static struct mbuf *sonic_get(struct snc_softc *, u_int32_t, int); - -int snc_enable(struct snc_softc *); -void snc_disable(struct snc_softc *); - -int snc_mediachange(struct ifnet *); -void snc_mediastatus(struct ifnet *, struct ifmediareq *); - -#undef assert -#undef _assert - -#ifdef NDEBUG -#define assert(e) ((void)0) -#define _assert(e) ((void)0) -#else -#define _assert(e) assert(e) -#ifdef __STDC__ -#define assert(e) ((e) ? (void)0 : __assert("snc ", __FILE__, __LINE__, #e)) -#else /* PCC */ -#define assert(e) ((e) ? (void)0 : __assert("snc "__FILE__, __LINE__, "e")) -#endif -#endif - -#ifdef SNCDEBUG -#define SNC_SHOWTXHDR 0x01 /* show tx ether_header */ -#define SNC_SHOWRXHDR 0x02 /* show rx ether_header */ -#define SNC_SHOWCAMENT 0x04 /* show CAM entry */ -#endif /* SNCDEBUG */ -int sncdebug = 0; - - -int -sncconfig(struct snc_softc *sc, int *media, int nmedia, int defmedia, - u_int8_t *myea) -{ - struct ifnet *ifp; - int i; - -#ifdef SNCDEBUG - if ((sncdebug & SNC_SHOWCAMENT) != 0) { - camdump(sc); - } -#endif - - ifp = sc->sc_ifp = if_alloc(IFT_ETHER); - if (ifp == NULL) { - device_printf(sc->sc_dev, "can not if_alloc()\n"); - return (ENOMEM); - } - -#ifdef SNCDEBUG - device_printf(sc->sc_dev, - "buffers: rra=0x%x cda=0x%x rda=0x%x tda=0x%x\n", - sc->v_rra[0], sc->v_cda, - sc->v_rda, sc->mtda[0].mtd_vtxp); -#endif - - ifp->if_softc = sc; - if_initname(ifp, device_get_name(sc->sc_dev), - device_get_unit(sc->sc_dev)); - ifp->if_ioctl = sncioctl; - ifp->if_start = sncstart; - ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - ifp->if_init = sncinit; - IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); - - /* Initialize media goo. */ - ifmedia_init(&sc->sc_media, 0, snc_mediachange, - snc_mediastatus); - if (media != NULL) { - for (i = 0; i < nmedia; i++) - ifmedia_add(&sc->sc_media, media[i], 0, NULL); - ifmedia_set(&sc->sc_media, defmedia); - } else { - ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL); - ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL); - } - - ether_ifattach(ifp, myea); - return (0); -} - -void -sncshutdown(void *arg) -{ - struct snc_softc *sc = arg; - - SNC_ASSERT_LOCKED(sc); - sncstop(sc); -} - -/* - * Media change callback. - */ -int -snc_mediachange(struct ifnet *ifp) -{ - struct snc_softc *sc = ifp->if_softc; - int error; - - SNC_LOCK(sc); - if (sc->sc_mediachange) - error = (*sc->sc_mediachange)(sc); - else - error = EINVAL; - SNC_UNLOCK(sc); - return (error); -} - -/* - * Media status callback. - */ -void -snc_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) -{ - struct snc_softc *sc = ifp->if_softc; - - SNC_LOCK(sc); - if (sc->sc_enabled == 0) { - ifmr->ifm_active = IFM_ETHER | IFM_NONE; - ifmr->ifm_status = 0; - SNC_UNLOCK(sc); - return; - } - - if (sc->sc_mediastatus) - (*sc->sc_mediastatus)(sc, ifmr); - SNC_UNLOCK(sc); -} - - -static int -sncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) -{ - struct ifreq *ifr; - struct snc_softc *sc = ifp->if_softc; - int err = 0; - - switch (cmd) { - - case SIOCSIFFLAGS: - SNC_LOCK(sc); - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - /* - * If interface is marked down and it is running, - * then stop it. - */ - sncstop(sc); - snc_disable(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { - /* - * If interface is marked up and it is stopped, - * then start it. - */ - if ((err = snc_enable(sc)) != 0) - break; - sncinit_locked(sc); - } else if (sc->sc_enabled) { - /* - * reset the interface to pick up any other changes - * in flags - */ - sncreset(sc); - sncstart_locked(ifp); - } - SNC_UNLOCK(sc); - break; - - case SIOCADDMULTI: - case SIOCDELMULTI: - SNC_LOCK(sc); - if (sc->sc_enabled == 0) { - err = EIO; - SNC_UNLOCK(sc); - break; - } - sncreset(sc); - SNC_UNLOCK(sc); - err = 0; - break; - case SIOCGIFMEDIA: - case SIOCSIFMEDIA: - ifr = (struct ifreq *) data; - err = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); - break; - default: - err = ether_ioctl(ifp, cmd, data); - break; - } - return (err); -} - -/* - * Encapsulate a packet of type family for the local net. - */ -static void -sncstart(struct ifnet *ifp) -{ - struct snc_softc *sc = ifp->if_softc; - - SNC_LOCK(sc); - sncstart_locked(ifp); - SNC_UNLOCK(sc); -} - -static void -sncstart_locked(struct ifnet *ifp) -{ - struct snc_softc *sc = ifp->if_softc; - struct mbuf *m; - int mtd_next; - - if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING) - return; - -outloop: - /* Check for room in the xmit buffer. */ - if ((mtd_next = (sc->mtd_free + 1)) == NTDA) - mtd_next = 0; - - if (mtd_next == sc->mtd_hw) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - return; - } - - IF_DEQUEUE(&ifp->if_snd, m); - if (m == 0) - return; - - /* We need the header for m_pkthdr.len. */ - M_ASSERTPKTHDR(m); - - /* - * If there is nothing in the o/p queue, and there is room in - * the Tx ring, then send the packet directly. Otherwise append - * it to the o/p queue. - */ - if ((sonicput(sc, m, mtd_next)) == 0) { - IF_PREPEND(&ifp->if_snd, m); - return; - } - - /* - * If bpf is listening on this interface, let it see the packet - * before we commit it to the wire, but only if we are really - * committed to send it. - * - * XXX: Locking must protect m against premature m_freem() in - * sonictxint(). - */ - BPF_MTAP(ifp, m); - - sc->mtd_prev = sc->mtd_free; - sc->mtd_free = mtd_next; - - if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* # of pkts */ - - /* Jump back for possibly more punishment. */ - goto outloop; -} - -/* - * reset and restart the SONIC. Called in case of fatal - * hardware/software errors. - */ -static void -sncreset(struct snc_softc *sc) -{ - sncstop(sc); - sncinit_locked(sc); -} - -static void -sncinit(void *xsc) -{ - struct snc_softc *sc = xsc; - - SNC_LOCK(sc); - sncinit_locked(sc); - SNC_UNLOCK(sc); -} - -static void -sncinit_locked(struct snc_softc *sc) -{ - u_long s_rcr; - - if (sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) - /* already running */ - return; - - NIC_PUT(sc, SNCR_CR, CR_RST); /* DCR only accessible in reset mode! */ - - /* config it */ - NIC_PUT(sc, SNCR_DCR, (sc->sncr_dcr | - (sc->bitmode ? DCR_DW32 : DCR_DW16))); - NIC_PUT(sc, SNCR_DCR2, sc->sncr_dcr2); - - s_rcr = RCR_BRD | RCR_LBNONE; - if (sc->sc_ifp->if_flags & IFF_PROMISC) - s_rcr |= RCR_PRO; - if (sc->sc_ifp->if_flags & IFF_ALLMULTI) - s_rcr |= RCR_AMC; - NIC_PUT(sc, SNCR_RCR, s_rcr); - - NIC_PUT(sc, SNCR_IMR, (IMR_PRXEN | IMR_PTXEN | IMR_TXEREN | IMR_LCDEN)); - - /* clear pending interrupts */ - NIC_PUT(sc, SNCR_ISR, ISR_ALL); - - /* clear tally counters */ - NIC_PUT(sc, SNCR_CRCT, -1); - NIC_PUT(sc, SNCR_FAET, -1); - NIC_PUT(sc, SNCR_MPT, -1); - - initialise_tda(sc); - initialise_rda(sc); - initialise_rra(sc); - - /* enable the chip */ - NIC_PUT(sc, SNCR_CR, 0); - wbflush(); - - /* program the CAM */ - camprogram(sc); - - /* get it to read resource descriptors */ - NIC_PUT(sc, SNCR_CR, CR_RRRA); - wbflush(); - while ((NIC_GET(sc, SNCR_CR)) & CR_RRRA) - continue; - - /* enable rx */ - NIC_PUT(sc, SNCR_CR, CR_RXEN); - wbflush(); - - /* flag interface as "running" */ - sc->sc_ifp->if_drv_flags |= IFF_DRV_RUNNING; - sc->sc_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - callout_reset(&sc->sc_timer, hz, sncwatchdog, sc); - - return; -} - -/* - * close down an interface and free its buffers - * Called on final close of device, or if sncinit() fails - * part way through. - */ -static int -sncstop(struct snc_softc *sc) -{ - struct mtd *mtd; - - SNC_ASSERT_LOCKED(sc); - - /* stick chip in reset */ - NIC_PUT(sc, SNCR_CR, CR_RST); - wbflush(); - - /* free all receive buffers (currently static so nothing to do) */ - - /* free all pending transmit mbufs */ - while (sc->mtd_hw != sc->mtd_free) { - mtd = &sc->mtda[sc->mtd_hw]; - if (mtd->mtd_mbuf) - m_freem(mtd->mtd_mbuf); - if (++sc->mtd_hw == NTDA) sc->mtd_hw = 0; - } - - callout_stop(&sc->sc_timer); - sc->sc_tx_timeout = 0; - sc->sc_ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - - return (0); -} - -/* - * Called if any Tx packets remain unsent after 5 seconds, - * In all cases we just reset the chip, and any retransmission - * will be handled by higher level protocol timeouts. - */ -static void -sncwatchdog(void *arg) -{ - struct snc_softc *sc = arg; - struct mtd *mtd; - - SNC_ASSERT_LOCKED(sc); - if (sc->sc_tx_timeout && --sc->sc_tx_timeout == 0) { - if (sc->mtd_hw != sc->mtd_free) { - /* something still pending for transmit */ - mtd = &sc->mtda[sc->mtd_hw]; - if (SRO(sc, mtd->mtd_vtxp, TXP_STATUS) == 0) - log(LOG_ERR, "%s: Tx - timeout\n", - device_get_nameunit(sc->sc_dev)); - else - log(LOG_ERR, "%s: Tx - lost interrupt\n", - device_get_nameunit(sc->sc_dev)); - sncreset(sc); - } - } - callout_reset(&sc->sc_timer, hz, sncwatchdog, sc); -} - -/* - * stuff packet into sonic - */ -static u_int -sonicput(struct snc_softc *sc, struct mbuf *m0, int mtd_next) -{ - struct mtd *mtdp; - struct mbuf *m; - u_int32_t buff; - u_int32_t txp; - u_int len = 0; - u_int totlen = 0; - -#ifdef whyonearthwouldyoudothis - if (NIC_GET(sc, SNCR_CR) & CR_TXP) - return (0); -#endif - - /* grab the replacement mtd */ - mtdp = &sc->mtda[sc->mtd_free]; - - buff = mtdp->mtd_vbuf; - - /* this packet goes to mtdnext fill in the TDA */ - mtdp->mtd_mbuf = m0; - txp = mtdp->mtd_vtxp; - - /* Write to the config word. Every (NTDA/2)+1 packets we set an intr */ - if (sc->mtd_pint == 0) { - sc->mtd_pint = NTDA/2; - SWO(sc, txp, TXP_CONFIG, TCR_PINT); - } else { - sc->mtd_pint--; - SWO(sc, txp, TXP_CONFIG, 0); - } - - for (m = m0; m; m = m->m_next) { - len = m->m_len; - totlen += len; - (*sc->sc_copytobuf)(sc, mtod(m, caddr_t), buff, len); - buff += len; - } - if (totlen >= TXBSIZE) { - panic("%s: sonicput: packet overflow", - device_get_nameunit(sc->sc_dev)); - } - - SWO(sc, txp, TXP_FRAGOFF + (0 * TXP_FRAGSIZE) + TXP_FPTRLO, - LOWER(mtdp->mtd_vbuf)); - SWO(sc, txp, TXP_FRAGOFF + (0 * TXP_FRAGSIZE) + TXP_FPTRHI, - UPPER(mtdp->mtd_vbuf)); - - if (totlen < ETHERMIN + sizeof(struct ether_header)) { - int pad = ETHERMIN + sizeof(struct ether_header) - totlen; - (*sc->sc_zerobuf)(sc, mtdp->mtd_vbuf + totlen, pad); - totlen = ETHERMIN + sizeof(struct ether_header); - } - - SWO(sc, txp, TXP_FRAGOFF + (0 * TXP_FRAGSIZE) + TXP_FSIZE, - totlen); - SWO(sc, txp, TXP_FRAGCNT, 1); - SWO(sc, txp, TXP_PKTSIZE, totlen); - - /* link onto the next mtd that will be used */ - SWO(sc, txp, TXP_FRAGOFF + (1 * TXP_FRAGSIZE) + TXP_FPTRLO, - LOWER(sc->mtda[mtd_next].mtd_vtxp) | EOL); - - /* - * The previous txp.tlink currently contains a pointer to - * our txp | EOL. Want to clear the EOL, so write our - * pointer to the previous txp. - */ - SWO(sc, sc->mtda[sc->mtd_prev].mtd_vtxp, sc->mtd_tlinko, - LOWER(mtdp->mtd_vtxp)); - - /* make sure chip is running */ - wbflush(); - NIC_PUT(sc, SNCR_CR, CR_TXP); - wbflush(); - - /* 5 seconds to watch for failing to transmit */ - sc->sc_tx_timeout = 5; - - return (totlen); -} - -/* - * These are called from sonicioctl() when /etc/ifconfig is run to set - * the address or switch the i/f on. - */ -/* - * CAM support - */ -static void -caminitialise(struct snc_softc *sc) -{ - u_int32_t v_cda = sc->v_cda; - int i; - int camoffset; - - for (i = 0; i < MAXCAM; i++) { - camoffset = i * CDA_CAMDESC; - SWO(sc, v_cda, (camoffset + CDA_CAMEP), i); - SWO(sc, v_cda, (camoffset + CDA_CAMAP2), 0); - SWO(sc, v_cda, (camoffset + CDA_CAMAP1), 0); - SWO(sc, v_cda, (camoffset + CDA_CAMAP0), 0); - } - SWO(sc, v_cda, CDA_ENABLE, 0); - -#ifdef SNCDEBUG - if ((sncdebug & SNC_SHOWCAMENT) != 0) { - camdump(sc); - } -#endif -} - -static void -camentry(struct snc_softc *sc, int entry, u_char *ea) -{ - u_int32_t v_cda = sc->v_cda; - int camoffset = entry * CDA_CAMDESC; - - SWO(sc, v_cda, camoffset + CDA_CAMEP, entry); - SWO(sc, v_cda, camoffset + CDA_CAMAP2, (ea[5] << 8) | ea[4]); - SWO(sc, v_cda, camoffset + CDA_CAMAP1, (ea[3] << 8) | ea[2]); - SWO(sc, v_cda, camoffset + CDA_CAMAP0, (ea[1] << 8) | ea[0]); - SWO(sc, v_cda, CDA_ENABLE, - (SRO(sc, v_cda, CDA_ENABLE) | (1 << entry))); -} - -static void -camprogram(struct snc_softc *sc) -{ - struct ifmultiaddr *ifma; - struct ifnet *ifp; - int timeout; - int mcount = 0; - - caminitialise(sc); - - ifp = sc->sc_ifp; - - /* Always load our own address first. */ - camentry (sc, mcount, IF_LLADDR(sc->sc_ifp)); - mcount++; - - /* Assume we won't need allmulti bit. */ - ifp->if_flags &= ~IFF_ALLMULTI; - - /* Loop through multicast addresses */ - if_maddr_rlock(ifp); - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - if (mcount == MAXCAM) { - ifp->if_flags |= IFF_ALLMULTI; - break; - } - - /* program the CAM with the specified entry */ - camentry(sc, mcount, - LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); - mcount++; - } - if_maddr_runlock(ifp); - - NIC_PUT(sc, SNCR_CDP, LOWER(sc->v_cda)); - NIC_PUT(sc, SNCR_CDC, MAXCAM); - NIC_PUT(sc, SNCR_CR, CR_LCAM); - wbflush(); - - timeout = 10000; - while ((NIC_GET(sc, SNCR_CR) & CR_LCAM) && timeout--) - continue; - if (timeout == 0) { - /* XXX */ - panic("%s: CAM initialisation failed\n", - device_get_nameunit(sc->sc_dev)); - } - timeout = 10000; - while (((NIC_GET(sc, SNCR_ISR) & ISR_LCD) == 0) && timeout--) - continue; - - if (NIC_GET(sc, SNCR_ISR) & ISR_LCD) - NIC_PUT(sc, SNCR_ISR, ISR_LCD); - else - device_printf(sc->sc_dev, - "CAM initialisation without interrupt\n"); -} - -#ifdef SNCDEBUG -static void -camdump(struct snc_softc *sc) -{ - int i; - - printf("CAM entries:\n"); - NIC_PUT(sc, SNCR_CR, CR_RST); - wbflush(); - - for (i = 0; i < 16; i++) { - u_short ap2, ap1, ap0; - NIC_PUT(sc, SNCR_CEP, i); - wbflush(); - ap2 = NIC_GET(sc, SNCR_CAP2); - ap1 = NIC_GET(sc, SNCR_CAP1); - ap0 = NIC_GET(sc, SNCR_CAP0); - printf("%d: ap2=0x%x ap1=0x%x ap0=0x%x\n", i, ap2, ap1, ap0); - } - printf("CAM enable 0x%x\n", NIC_GET(sc, SNCR_CEP)); - - NIC_PUT(sc, SNCR_CR, 0); - wbflush(); -} -#endif - -static void -initialise_tda(struct snc_softc *sc) -{ - struct mtd *mtd; - int i; - - for (i = 0; i < NTDA; i++) { - mtd = &sc->mtda[i]; - mtd->mtd_mbuf = 0; - } - - sc->mtd_hw = 0; - sc->mtd_prev = NTDA - 1; - sc->mtd_free = 0; - sc->mtd_tlinko = TXP_FRAGOFF + 1*TXP_FRAGSIZE + TXP_FPTRLO; - sc->mtd_pint = NTDA/2; - - NIC_PUT(sc, SNCR_UTDA, UPPER(sc->mtda[0].mtd_vtxp)); - NIC_PUT(sc, SNCR_CTDA, LOWER(sc->mtda[0].mtd_vtxp)); -} - -static void -initialise_rda(struct snc_softc *sc) -{ - int i; - u_int32_t vv_rda = 0; - u_int32_t v_rda = 0; - - /* link the RDA's together into a circular list */ - for (i = 0; i < (sc->sc_nrda - 1); i++) { - v_rda = sc->v_rda + (i * RXPKT_SIZE(sc)); - vv_rda = sc->v_rda + ((i+1) * RXPKT_SIZE(sc)); - SWO(sc, v_rda, RXPKT_RLINK, LOWER(vv_rda)); - SWO(sc, v_rda, RXPKT_INUSE, 1); - } - v_rda = sc->v_rda + ((sc->sc_nrda - 1) * RXPKT_SIZE(sc)); - SWO(sc, v_rda, RXPKT_RLINK, LOWER(sc->v_rda) | EOL); - SWO(sc, v_rda, RXPKT_INUSE, 1); - - /* mark end of receive descriptor list */ - sc->sc_rdamark = sc->sc_nrda - 1; - - sc->sc_rxmark = 0; - - NIC_PUT(sc, SNCR_URDA, UPPER(sc->v_rda)); - NIC_PUT(sc, SNCR_CRDA, LOWER(sc->v_rda)); - wbflush(); -} - -static void -initialise_rra(struct snc_softc *sc) -{ - int i; - u_int v; - int bitmode = sc->bitmode; - - if (bitmode) - NIC_PUT(sc, SNCR_EOBC, RBASIZE(sc) / 2 - 2); - else - NIC_PUT(sc, SNCR_EOBC, RBASIZE(sc) / 2 - 1); - - NIC_PUT(sc, SNCR_URRA, UPPER(sc->v_rra[0])); - NIC_PUT(sc, SNCR_RSA, LOWER(sc->v_rra[0])); - /* rea must point just past the end of the rra space */ - NIC_PUT(sc, SNCR_REA, LOWER(sc->v_rea)); - NIC_PUT(sc, SNCR_RRP, LOWER(sc->v_rra[0])); - NIC_PUT(sc, SNCR_RSC, 0); - - /* fill up SOME of the rra with buffers */ - for (i = 0; i < NRBA; i++) { - v = SONIC_GETDMA(sc->rbuf[i]); - SWO(sc, sc->v_rra[i], RXRSRC_PTRHI, UPPER(v)); - SWO(sc, sc->v_rra[i], RXRSRC_PTRLO, LOWER(v)); - SWO(sc, sc->v_rra[i], RXRSRC_WCHI, UPPER(PAGE_SIZE/2)); - SWO(sc, sc->v_rra[i], RXRSRC_WCLO, LOWER(PAGE_SIZE/2)); - } - sc->sc_rramark = NRBA; - NIC_PUT(sc, SNCR_RWP, LOWER(sc->v_rra[sc->sc_rramark])); - wbflush(); -} - -void -sncintr(void *arg) -{ - struct snc_softc *sc = (struct snc_softc *)arg; - int isr; - - if (sc->sc_enabled == 0) - return; - - SNC_LOCK(sc); - while ((isr = (NIC_GET(sc, SNCR_ISR) & ISR_ALL)) != 0) { - /* scrub the interrupts that we are going to service */ - NIC_PUT(sc, SNCR_ISR, isr); - wbflush(); - - if (isr & (ISR_BR | ISR_LCD | ISR_TC)) - device_printf(sc->sc_dev, - "unexpected interrupt status 0x%x\n", - isr); - - if (isr & (ISR_TXDN | ISR_TXER | ISR_PINT)) - sonictxint(sc); - - if (isr & ISR_PKTRX) - sonicrxint(sc); - - if (isr & (ISR_HBL | ISR_RDE | ISR_RBE | ISR_RBAE | ISR_RFO)) { - if (isr & ISR_HBL) - /* - * The repeater is not providing a heartbeat. - * In itself this isn't harmful, lots of the - * cheap repeater hubs don't supply a heartbeat. - * So ignore the lack of heartbeat. Its only - * if we can't detect a carrier that we have a - * problem. - */ - ; - if (isr & ISR_RDE) - device_printf(sc->sc_dev, - "receive descriptors exhausted\n"); - if (isr & ISR_RBE) - device_printf(sc->sc_dev, - "receive buffers exhausted\n"); - if (isr & ISR_RBAE) - device_printf(sc->sc_dev, - "receive buffer area exhausted\n"); - if (isr & ISR_RFO) - device_printf(sc->sc_dev, - "receive FIFO overrun\n"); - } - if (isr & (ISR_CRC | ISR_FAE | ISR_MP)) { -#ifdef notdef - if (isr & ISR_CRC) - sc->sc_crctally++; - if (isr & ISR_FAE) - sc->sc_faetally++; - if (isr & ISR_MP) - sc->sc_mptally++; -#endif - } - sncstart_locked(sc->sc_ifp); - } - SNC_UNLOCK(sc); - return; -} - -/* - * Transmit interrupt routine - */ -static void -sonictxint(struct snc_softc *sc) -{ - struct mtd *mtd; - u_int32_t txp; - unsigned short txp_status; - int mtd_hw; - struct ifnet *ifp = sc->sc_ifp; - - mtd_hw = sc->mtd_hw; - - if (mtd_hw == sc->mtd_free) - return; - - while (mtd_hw != sc->mtd_free) { - mtd = &sc->mtda[mtd_hw]; - - txp = mtd->mtd_vtxp; - - if (SRO(sc, txp, TXP_STATUS) == 0) { - break; /* it hasn't really gone yet */ - } - -#ifdef SNCDEBUG - if ((sncdebug & SNC_SHOWTXHDR) != 0) - { - struct ether_header eh; - - (*sc->sc_copyfrombuf)(sc, &eh, mtd->mtd_vbuf, sizeof(eh)); - device_printf(sc->sc_dev, - "xmit status=0x%x len=%d type=0x%x from %6D", - SRO(sc, txp, TXP_STATUS), - SRO(sc, txp, TXP_PKTSIZE), - htons(eh.ether_type), - eh.ether_shost, ":"); - printf(" (to %6D)\n", eh.ether_dhost, ":"); - } -#endif /* SNCDEBUG */ - - sc->sc_tx_timeout = 0; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - if (mtd->mtd_mbuf != 0) { - m_freem(mtd->mtd_mbuf); - mtd->mtd_mbuf = 0; - } - if (++mtd_hw == NTDA) mtd_hw = 0; - - txp_status = SRO(sc, txp, TXP_STATUS); - - if_inc_counter(ifp, IFCOUNTER_COLLISIONS, - (txp_status & TCR_EXC) ? 16 : - ((txp_status & TCR_NC) >> 12)); - - if ((txp_status & TCR_PTX) == 0) { - if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); - device_printf(sc->sc_dev, "Tx packet status=0x%x\n", - txp_status); - - /* XXX - DG This looks bogus */ - if (mtd_hw != sc->mtd_free) { - printf("resubmitting remaining packets\n"); - mtd = &sc->mtda[mtd_hw]; - NIC_PUT(sc, SNCR_CTDA, LOWER(mtd->mtd_vtxp)); - NIC_PUT(sc, SNCR_CR, CR_TXP); - wbflush(); - break; - } - } - } - - sc->mtd_hw = mtd_hw; - return; -} - -/* - * Receive interrupt routine - */ -static void -sonicrxint(struct snc_softc *sc) -{ - u_int32_t rda; - int orra; - int len; - int rramark; - int rdamark; - u_int16_t rxpkt_ptr; - - rda = sc->v_rda + (sc->sc_rxmark * RXPKT_SIZE(sc)); - - while (SRO(sc, rda, RXPKT_INUSE) == 0) { - u_int status = SRO(sc, rda, RXPKT_STATUS); - - orra = RBASEQ(SRO(sc, rda, RXPKT_SEQNO)) & RRAMASK; - rxpkt_ptr = SRO(sc, rda, RXPKT_PTRLO); - /* - * Do not trunc ether_header length. - * Our sonic_read() and sonic_get() require it. - */ - len = SRO(sc, rda, RXPKT_BYTEC) - FCSSIZE; - if (status & RCR_PRX) { - /* XXX: Does PAGE_MASK require? */ - u_int32_t pkt = - sc->rbuf[orra & RBAMASK] + (rxpkt_ptr & PAGE_MASK); - if (sonic_read(sc, pkt, len)) - if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1); - else - if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); - } else - if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1); - - /* - * give receive buffer area back to chip. - * - * If this was the last packet in the RRA, give the RRA to - * the chip again. - * If sonic read didn't copy it out then we would have to - * wait !! - * (dont bother add it back in again straight away) - * - * Really, we're doing v_rra[rramark] = v_rra[orra] but - * we have to use the macros because SONIC might be in - * 16 or 32 bit mode. - */ - if (status & RCR_LPKT) { - u_int32_t tmp1, tmp2; - - rramark = sc->sc_rramark; - tmp1 = sc->v_rra[rramark]; - tmp2 = sc->v_rra[orra]; - SWO(sc, tmp1, RXRSRC_PTRLO, - SRO(sc, tmp2, RXRSRC_PTRLO)); - SWO(sc, tmp1, RXRSRC_PTRHI, - SRO(sc, tmp2, RXRSRC_PTRHI)); - SWO(sc, tmp1, RXRSRC_WCLO, - SRO(sc, tmp2, RXRSRC_WCLO)); - SWO(sc, tmp1, RXRSRC_WCHI, - SRO(sc, tmp2, RXRSRC_WCHI)); - - /* zap old rra for fun */ - SWO(sc, tmp2, RXRSRC_WCHI, 0); - SWO(sc, tmp2, RXRSRC_WCLO, 0); - - sc->sc_rramark = (++rramark) & RRAMASK; - NIC_PUT(sc, SNCR_RWP, LOWER(sc->v_rra[rramark])); - wbflush(); - } - - /* - * give receive descriptor back to chip simple - * list is circular - */ - rdamark = sc->sc_rdamark; - SWO(sc, rda, RXPKT_INUSE, 1); - SWO(sc, rda, RXPKT_RLINK, - SRO(sc, rda, RXPKT_RLINK) | EOL); - SWO(sc, (sc->v_rda + (rdamark * RXPKT_SIZE(sc))), RXPKT_RLINK, - SRO(sc, (sc->v_rda + (rdamark * RXPKT_SIZE(sc))), - RXPKT_RLINK) & ~EOL); - sc->sc_rdamark = sc->sc_rxmark; - - if (++sc->sc_rxmark >= sc->sc_nrda) - sc->sc_rxmark = 0; - rda = sc->v_rda + (sc->sc_rxmark * RXPKT_SIZE(sc)); - } -} - -/* - * sonic_read -- pull packet off interface and forward to - * appropriate protocol handler - */ -static int -sonic_read(struct snc_softc *sc, u_int32_t pkt, int len) -{ - struct ifnet *ifp = sc->sc_ifp; - struct ether_header *et; - struct mbuf *m; - - if (len <= sizeof(struct ether_header) || - len > ETHERMTU + sizeof(struct ether_header)) { - device_printf(sc->sc_dev, - "invalid packet length %d bytes\n", len); - return (0); - } - - /* Pull packet off interface. */ - m = sonic_get(sc, pkt, len); - if (m == 0) { - return (0); - } - - /* We assume that the header fit entirely in one mbuf. */ - et = mtod(m, struct ether_header *); - -#ifdef SNCDEBUG - if ((sncdebug & SNC_SHOWRXHDR) != 0) - { - device_printf(sc->sc_dev, "rcvd 0x%x len=%d type=0x%x from %6D", - pkt, len, htons(et->ether_type), - et->ether_shost, ":"); - printf(" (to %6D)\n", et->ether_dhost, ":"); - } -#endif /* SNCDEBUG */ - - /* Pass the packet up. */ - SNC_UNLOCK(sc); - (*ifp->if_input)(ifp, m); - SNC_LOCK(sc); - return (1); -} - - -/* - * munge the received packet into an mbuf chain - */ -static struct mbuf * -sonic_get(struct snc_softc *sc, u_int32_t pkt, int datalen) -{ - struct mbuf *m, *top, **mp; - int len; - /* - * Do not trunc ether_header length. - * Our sonic_read() and sonic_get() require it. - */ - - MGETHDR(m, M_NOWAIT, MT_DATA); - if (m == 0) - return (0); - m->m_pkthdr.rcvif = sc->sc_ifp; - m->m_pkthdr.len = datalen; - len = MHLEN; - top = 0; - mp = ⊤ - - while (datalen > 0) { - if (top) { - MGET(m, M_NOWAIT, MT_DATA); - if (m == 0) { - m_freem(top); - return (0); - } - len = MLEN; - } - if (datalen >= MINCLSIZE) { - if (!(MCLGET(m, M_NOWAIT))) { - if (top) m_freem(top); - return (0); - } - len = MCLBYTES; - } -#if 0 - /* XXX: Require? */ - if (!top) { - register int pad = - ALIGN(sizeof(struct ether_header)) - - sizeof(struct ether_header); - m->m_data += pad; - len -= pad; - } -#endif - m->m_len = len = min(datalen, len); - - (*sc->sc_copyfrombuf)(sc, mtod(m, caddr_t), pkt, len); - pkt += len; - datalen -= len; - *mp = m; - mp = &m->m_next; - } - - return (top); -} -/* - * Enable power on the interface. - */ -int -snc_enable(struct snc_softc *sc) -{ - -#ifdef SNCDEBUG - device_printf(sc->sc_dev, "snc_enable()\n"); -#endif /* SNCDEBUG */ - - if (sc->sc_enabled == 0 && sc->sc_enable != NULL) { - if ((*sc->sc_enable)(sc) != 0) { - device_printf(sc->sc_dev, "device enable failed\n"); - return (EIO); - } - } - - sc->sc_enabled = 1; - return (0); -} - -/* - * Disable power on the interface. - */ -void -snc_disable(struct snc_softc *sc) -{ - -#ifdef SNCDEBUG - device_printf(sc->sc_dev, "snc_disable()\n"); -#endif /* SNCDEBUG */ - - if (sc->sc_enabled != 0 && sc->sc_disable != NULL) { - (*sc->sc_disable)(sc); - sc->sc_enabled = 0; - } -} - - diff --git a/sys/dev/snc/dp83932reg.h b/sys/dev/snc/dp83932reg.h deleted file mode 100644 index 31ab550b83ca5..0000000000000 --- a/sys/dev/snc/dp83932reg.h +++ /dev/null @@ -1,271 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: dp83932reg.h,v 1.2 1999/02/12 05:50:13 kmatsuda Exp $ */ -/* $NetBSD: if_snreg.h,v 1.4 1997/06/15 20:20:12 scottr Exp $ */ - -/*- - * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) - * You may use, copy, and modify this program so long as you retain the - * copyright line. - */ - -/* - * if_snreg.h -- National Semiconductor DP8393X (SONIC) register defs - */ - -/* - * SONIC registers as seen by the processor - */ -#define SNCR_CR 0x00 /* Command */ -#define SNCR_DCR 0x01 /* Data Configuration */ -#define SNCR_RCR 0x02 /* Receive Control */ -#define SNCR_TCR 0x03 /* Transmit Control */ -#define SNCR_IMR 0x04 /* Interrupt Mask */ -#define SNCR_ISR 0x05 /* Interrupt Status */ -#define SNCR_UTDA 0x06 /* Upper Transmit Descriptor Address */ -#define SNCR_CTDA 0x07 /* Current Transmit Descriptor Address */ -#define SNCR_TPS 0x08 /* Transmit Packet Size */ -#define SNCR_TFC 0x09 /* Transmit Fragment Count */ -#define SNCR_TSA0 0x0a /* Transmit Start Address 0 */ -#define SNCR_TSA1 0x0b /* Transmit Start Address 1 */ -#define SNCR_TFS 0x0c /* Transmit Fragment Size */ -#define SNCR_URDA 0x0d /* Upper Receive Descriptor Address */ -#define SNCR_CRDA 0x0e /* Current Receive Descriptor Address */ -#define SNCR_CRBA0 0x0f /* Current Receive Buffer Address 0 */ -#define SNCR_CRBA1 0x10 /* Current Receive Buffer Address 1 */ -#define SNCR_RBWC0 0x11 /* Remaining Buffer Word Count 0 */ -#define SNCR_RBWC1 0x12 /* Remaining Buffer Word Count 1 */ -#define SNCR_EOBC 0x13 /* End Of Buffer Word Count */ -#define SNCR_URRA 0x14 /* Upper Receive Resource Address */ -#define SNCR_RSA 0x15 /* Resource Start Address */ -#define SNCR_REA 0x16 /* Resource End Address */ -#define SNCR_RRP 0x17 /* Resource Read Pointer */ -#define SNCR_RWP 0x18 /* Resource Write Pointer */ -#define SNCR_TRBA0 0x19 /* Temporary Receive Buffer Address 0 */ -#define SNCR_TRBA1 0x1a /* Temporary Receive Buffer Address 1 */ -#define SNCR_TBWC0 0x1b /* Temporary Buffer Word Count 0 */ -#define SNCR_TBWC1 0x1c /* Temporary Buffer Word Count 1 */ -#define SNCR_ADDR0 0x1d /* Address Generator 0 */ -#define SNCR_ADDR1 0x1e /* Address Generator 1 */ -#define SNCR_LLFA 0x1f /* Last Link Field Address */ -#define SNCR_TTDA 0x20 /* Temp Transmit Descriptor Address */ -#define SNCR_CEP 0x21 /* CAM Entry Pointer */ -#define SNCR_CAP2 0x22 /* CAM Address Port 2 */ -#define SNCR_CAP1 0x23 /* CAM Address Port 1 */ -#define SNCR_CAP0 0x24 /* CAM Address Port 0 */ -#define SNCR_CE 0x25 /* CAM Enable */ -#define SNCR_CDP 0x26 /* CAM Descriptor Pointer */ -#define SNCR_CDC 0x27 /* CAM Descriptor Count */ -#define SNCR_SR 0x28 /* Silicon Revision */ -#define SNCR_WT0 0x29 /* Watchdog Timer 0 */ -#define SNCR_WT1 0x2a /* Watchdog Timer 1 */ -#define SNCR_RSC 0x2b /* Receive Sequence Counter */ -#define SNCR_CRCT 0x2c /* CRC Error Tally */ -#define SNCR_FAET 0x2d /* FAE Tally */ -#define SNCR_MPT 0x2e /* Missed Packet Tally */ -#define SNCR_MDT 0x2f /* Maximum Deferral Timer */ -#define SNCR_RTC 0x30 /* Receive Test Control */ -#define SNCR_TTC 0x31 /* Transmit Test Control */ -#define SNCR_DTC 0x32 /* DMA Test Control */ -#define SNCR_CC0 0x33 /* CAM Comparison 0 */ -#define SNCR_CC1 0x34 /* CAM Comparison 1 */ -#define SNCR_CC2 0x35 /* CAM Comparison 2 */ -#define SNCR_CM 0x36 /* CAM Match */ -#define SNCR_RES1 0x37 /* reserved */ -#define SNCR_RES2 0x38 /* reserved */ -#define SNCR_RBC 0x39 /* Receiver Byte Count */ -#define SNCR_RES3 0x3a /* reserved */ -#define SNCR_TBO 0x3b /* Transmitter Backoff Counter */ -#define SNCR_TRC 0x3c /* Transmitter Random Counter */ -#define SNCR_TBM 0x3d /* Transmitter Backoff Mask */ -#define SNCR_RES4 0x3e /* Reserved */ -#define SNCR_DCR2 0x3f /* Data Configuration 2 (AVF) */ - -#define SNC_NREGS 0x40 - -/* - * Register Interpretations - */ - -/* - * The command register is used for issuing commands to the SONIC. - * With the exception of CR_RST, the bit is reset when the operation - * completes. - */ -#define CR_LCAM 0x0200 /* load CAM with descriptor at s_cdp */ -#define CR_RRRA 0x0100 /* read next RRA descriptor at s_rrp */ -#define CR_RST 0x0080 /* software reset */ -#define CR_ST 0x0020 /* start timer */ -#define CR_STP 0x0010 /* stop timer */ -#define CR_RXEN 0x0008 /* receiver enable */ -#define CR_RXDIS 0x0004 /* receiver disable */ -#define CR_TXP 0x0002 /* transmit packets */ -#define CR_HTX 0x0001 /* halt transmission */ - -/* - * The data configuration register establishes the SONIC's bus cycle - * operation. This register can only be accessed when the SONIC is in - * reset mode (s_cr.CR_RST is set.) - */ -#define DCR_EXBUS 0x8000 /* extended bus mode (AVF) */ -#define DCR_LBR 0x2000 /* latched bus retry */ -#define DCR_PO1 0x1000 /* programmable output 1 */ -#define DCR_PO0 0x0800 /* programmable output 0 */ -#define DCR_STERM 0x0400 /* synchronous termination */ -#define DCR_USR1 0x0200 /* reflects USR1 input pin */ -#define DCR_USR0 0x0100 /* reflects USR0 input pin */ -#define DCR_WC1 0x0080 /* wait state control 1 */ -#define DCR_WC0 0x0040 /* wait state control 0 */ -#define DCR_DW 0x0020 /* data width select */ -#define DCR_BMS 0x0010 /* DMA block mode select */ -#define DCR_RFT1 0x0008 /* receive FIFO threshold control 1 */ -#define DCR_RFT0 0x0004 /* receive FIFO threshold control 0 */ -#define DCR_TFT1 0x0002 /* transmit FIFO threshold control 1 */ -#define DCR_TFT0 0x0001 /* transmit FIFO threshold control 0 */ - -/* data configuration register aliases */ -#define DCR_SYNC DCR_STERM /* synchronous (memory cycle 2 clocks) */ -#define DCR_ASYNC 0 /* asynchronous (memory cycle 3 clocks) */ - -#define DCR_WAIT0 0 /* 0 wait states added */ -#define DCR_WAIT1 DCR_WC0 /* 1 wait state added */ -#define DCR_WAIT2 DCR_WC1 /* 2 wait states added */ -#define DCR_WAIT3 (DCR_WC1|DCR_WC0) /* 3 wait states added */ - -#define DCR_DW16 0 /* use 16-bit DMA accesses */ -#define DCR_DW32 DCR_DW /* use 32-bit DMA accesses */ - -#define DCR_DMAEF 0 /* DMA until TX/RX FIFO has emptied/filled */ -#define DCR_DMABLOCK DCR_BMS /* DMA until RX/TX threshold crossed */ - -#define DCR_RFT4 0 /* receive threshold 4 bytes */ -#define DCR_RFT8 DCR_RFT0 /* receive threshold 8 bytes */ -#define DCR_RFT16 DCR_RFT1 /* receive threshold 16 bytes */ -#define DCR_RFT24 (DCR_RFT1|DCR_RFT0) /* receive threshold 24 bytes */ - -#define DCR_TFT8 0 /* transmit threshold 8 bytes */ -#define DCR_TFT16 DCR_TFT0 /* transmit threshold 16 bytes */ -#define DCR_TFT24 DCR_TFT1 /* transmit threshold 24 bytes */ -#define DCR_TFT28 (DCR_TFT1|DCR_TFT0) /* transmit threshold 28 bytes */ - -/* - * The receive control register is used to filter incoming packets and - * provides status information on packets received. - * The contents of the register are copied into the RXpkt.status field - * when a packet is received. RCR_MC - RCR_PRX are then reset. - */ -#define RCR_ERR 0x8000 /* accept packets with CRC errors */ -#define RCR_RNT 0x4000 /* accept runt (length < 64) packets */ -#define RCR_BRD 0x2000 /* accept broadcast packets */ -#define RCR_PRO 0x1000 /* accept all physical address packets */ -#define RCR_AMC 0x0800 /* accept all multicast packets */ -#define RCR_LB1 0x0400 /* loopback control 1 */ -#define RCR_LB0 0x0200 /* loopback control 0 */ -#define RCR_MC 0x0100 /* multicast packet received */ -#define RCR_BC 0x0080 /* broadcast packet received */ -#define RCR_LPKT 0x0040 /* last packet in RBA (RBWC < EOBC) */ -#define RCR_CRS 0x0020 /* carrier sense activity */ -#define RCR_COL 0x0010 /* collision activity */ -#define RCR_CRC 0x0008 /* CRC error */ -#define RCR_FAE 0x0004 /* frame alignment error */ -#define RCR_LBK 0x0002 /* loopback packet received */ -#define RCR_PRX 0x0001 /* packet received without errors */ - -/* receiver control register aliases */ -/* the loopback control bits provide the following options */ -#define RCR_LBNONE 0 /* no loopback - normal operation */ -#define RCR_LBMAC RCR_LB0 /* MAC loopback */ -#define RCR_LBENDEC RCR_LB1 /* ENDEC loopback */ -#define RCR_LBTRANS (RCR_LB1|RCR_LB0) /* transceiver loopback */ - -/* - * The transmit control register controls the SONIC's transmit operations. - * TCR_PINT - TCR_EXDIS are loaded from the TXpkt.config field at the - * start of transmission. TCR_EXD-TCR_PTX are cleared at the beginning - * of transmission and updated when the transmission is completed. - */ -#define TCR_PINT 0x8000 /* interrupt when transmission starts */ -#define TCR_POWC 0x4000 /* program out of window collision timer */ -#define TCR_CRCI 0x2000 /* transmit packet without 4 byte FCS */ -#define TCR_EXDIS 0x1000 /* disable excessive deferral timer */ -#define TCR_EXD 0x0400 /* excessive deferrals occurred (>3.2ms) */ -#define TCR_DEF 0x0200 /* deferred transmissions occurred */ -#define TCR_NCRS 0x0100 /* carrier not present during transmission */ -#define TCR_CRSL 0x0080 /* carrier lost during transmission */ -#define TCR_EXC 0x0040 /* excessive collisions (>16) detected */ -#define TCR_OWC 0x0020 /* out of window (bad) collision occurred */ -#define TCR_PMB 0x0008 /* packet monitored bad - the tansmitted - * packet had a bad source address or CRC */ -#define TCR_FU 0x0004 /* FIFO underrun (memory access failed) */ -#define TCR_BCM 0x0002 /* byte count mismatch (TXpkt.pkt_size - * != sum(TXpkt.frag_size) */ -#define TCR_PTX 0x0001 /* packet transmitted without errors */ -#define TCR_NC 0xf000 /* after transmission, # of colls */ - -/* transmit control register aliases */ -#define TCR_OWCSFD 0 /* start after start of frame delimiter */ -#define TCR_OWCPRE TCR_POWC /* start after first bit of preamble */ - - -/* - * The interrupt mask register masks the interrupts that - * are generated from the interrupt status register. - * All reserved bits should be written with 0. - */ -#define IMR_BREN 0x4000 /* bus retry occurred enable */ -#define IMR_HBLEN 0x2000 /* heartbeat lost enable */ -#define IMR_LCDEN 0x1000 /* load CAM done interrupt enable */ -#define IMR_PINTEN 0x0800 /* programmable interrupt enable */ -#define IMR_PRXEN 0x0400 /* packet received enable */ -#define IMR_PTXEN 0x0200 /* packet transmitted enable */ -#define IMR_TXEREN 0x0100 /* transmit error enable */ -#define IMR_TCEN 0x0080 /* timer complete enable */ -#define IMR_RDEEN 0x0040 /* receive descriptors exhausted enable */ -#define IMR_RBEEN 0x0020 /* receive buffers exhausted enable */ -#define IMR_RBAEEN 0x0010 /* receive buffer area exceeded enable */ -#define IMR_CRCEN 0x0008 /* CRC tally counter rollover enable */ -#define IMR_FAEEN 0x0004 /* FAE tally counter rollover enable */ -#define IMR_MPEN 0x0002 /* MP tally counter rollover enable */ -#define IMR_RFOEN 0x0001 /* receive FIFO overrun enable */ - - -/* - * The interrupt status register indicates the source of an interrupt when - * the INT pin goes active. The interrupt is acknowledged by writing - * the appropriate bit(s) in this register. - */ -#define ISR_ALL 0x7fff /* all interrupts */ -#define ISR_BR 0x4000 /* bus retry occurred */ -#define ISR_HBL 0x2000 /* CD heartbeat lost */ -#define ISR_LCD 0x1000 /* load CAM command has completed */ -#define ISR_PINT 0x0800 /* programmed interrupt from TXpkt.config */ -#define ISR_PKTRX 0x0400 /* packet received */ -#define ISR_TXDN 0x0200 /* no remaining packets to be transmitted */ -#define ISR_TXER 0x0100 /* packet transmission caused error */ -#define ISR_TC 0x0080 /* timer complete */ -#define ISR_RDE 0x0040 /* receive descriptors exhausted */ -#define ISR_RBE 0x0020 /* receive buffers exhausted */ -#define ISR_RBAE 0x0010 /* receive buffer area exceeded */ -#define ISR_CRC 0x0008 /* CRC tally counter rollover */ -#define ISR_FAE 0x0004 /* FAE tally counter rollover */ -#define ISR_MP 0x0002 /* MP tally counter rollover */ -#define ISR_RFO 0x0001 /* receive FIFO overrun */ - -/* - * The second data configuration register allows additional user defined - * pins to be controlled. These bits are only available if s_dcr.DCR_EXBUS - * is set. - */ -#define DCR2_EXPO3 0x8000 /* EXUSR3 output */ -#define DCR2_EXPO2 0x4000 /* EXUSR2 output */ -#define DCR2_EXPO1 0x2000 /* EXUSR1 output */ -#define DCR2_EXPO0 0x1000 /* EXUSR0 output */ -#define DCR2_HD 0x0800 /* heart beat disable (83934/83936) */ -#define DCR2_JD 0x0200 /* TPI jabber timer disable (83934/83936) */ -#define DCR2_AUTO 0x0100 /* AUI/TPI auto selection (83934/83936) */ -#define DCR2_XWRAP 0x0040 /* TPI transceiver loopback (83934/83936) */ -#define DCR2_FD 0x0020 /* full duplex (83936) */ -#define DCR2_PHL 0x0010 /* extend HOLD signal by 1/2 clock */ -#define DCR2_LRDY 0x0008 /* set latched ready mode */ -#define DCR2_PCM 0x0004 /* packet compress on match */ -#define DCR2_PCNM 0x0002 /* packet compress on mismatch */ -#define DCR2_RJM 0x0001 /* reject on match */ diff --git a/sys/dev/snc/dp83932subr.c b/sys/dev/snc/dp83932subr.c deleted file mode 100644 index a34c554aa5e1a..0000000000000 --- a/sys/dev/snc/dp83932subr.c +++ /dev/null @@ -1,839 +0,0 @@ -/* $NecBSD: dp83932subr.c,v 1.5.6.2 1999/10/09 05:47:23 kmatsuda Exp $ */ -/* $NetBSD$ */ - -/*- - * Copyright (c) 1997, 1998, 1999 - * Kouichi Matsuda. 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 Kouichi Matsuda for - * NetBSD/pc98. - * 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/cdefs.h> -__FBSDID("$FreeBSD$"); -/* - * Routines of NEC PC-9801-83, 84, 103, 104, PC-9801N-25 and PC-9801N-J02, J02R - * Ethernet interface for NetBSD/pc98, ported by Kouichi Matsuda. - * - * These cards use National Semiconductor DP83934AVQB as Ethernet Controller - * and National Semiconductor NS46C46 as (64 * 16 bits) Microwire Serial EEPROM. - */ - -/* - * Modified for FreeBSD(98) 4.0 from NetBSD/pc98 1.4.2 by Motomichi Matsuzaki. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/protosw.h> -#include <sys/socket.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> - -#include <sys/bus.h> -#include <machine/bus.h> - -#include <dev/snc/dp83932reg.h> -#include <dev/snc/dp83932var.h> -#include <dev/snc/if_sncreg.h> -#include <dev/snc/dp83932subr.h> - -static __inline u_int16_t snc_nec16_select_bank - (struct snc_softc *, u_int32_t, u_int32_t); - -/* - * Interface exists: make available by filling in network interface - * record. System will initialize the interface when it is ready - * to accept packets. - */ -int -sncsetup(struct snc_softc *sc, u_int8_t *lladdr) -{ - u_int32_t p, pp; - int i; - int offset; - - /* - * Put the pup in reset mode (sncinit() will fix it later), - * stop the timer, disable all interrupts and clear any interrupts. - */ - NIC_PUT(sc, SNCR_CR, CR_STP); - wbflush(); - NIC_PUT(sc, SNCR_CR, CR_RST); - wbflush(); - NIC_PUT(sc, SNCR_IMR, 0); - wbflush(); - NIC_PUT(sc, SNCR_ISR, ISR_ALL); - wbflush(); - - /* - * because the SONIC is basically 16bit device it 'concatenates' - * a higher buffer address to a 16 bit offset--this will cause wrap - * around problems near the end of 64k !! - */ - p = pp = 0; - - for (i = 0; i < NRRA; i++) { - sc->v_rra[i] = SONIC_GETDMA(p); - p += RXRSRC_SIZE(sc); - } - sc->v_rea = SONIC_GETDMA(p); - - p = SOALIGN(sc, p); - - sc->v_cda = SONIC_GETDMA(p); - p += CDA_SIZE(sc); - - p = SOALIGN(sc, p); - - for (i = 0; i < NTDA; i++) { - struct mtd *mtdp = &sc->mtda[i]; - mtdp->mtd_vtxp = SONIC_GETDMA(p); - p += TXP_SIZE(sc); - } - - p = SOALIGN(sc, p); - - if ((p - pp) > PAGE_SIZE) { - device_printf (sc->sc_dev, "sizeof RRA (%ld) + CDA (%ld) +" - "TDA (%ld) > PAGE_SIZE (%d). Punt!\n", - (u_long)sc->v_cda - (u_long)sc->v_rra[0], - (u_long)sc->mtda[0].mtd_vtxp - (u_long)sc->v_cda, - (u_long)p - (u_long)sc->mtda[0].mtd_vtxp, - PAGE_SIZE); - return(1); - } - - p = pp + PAGE_SIZE; - pp = p; - - sc->sc_nrda = PAGE_SIZE / RXPKT_SIZE(sc); - sc->v_rda = SONIC_GETDMA(p); - - p = pp + PAGE_SIZE; - - for (i = 0; i < NRBA; i++) { - sc->rbuf[i] = p; - p += PAGE_SIZE; - } - - pp = p; - offset = TXBSIZE; - for (i = 0; i < NTDA; i++) { - struct mtd *mtdp = &sc->mtda[i]; - - mtdp->mtd_vbuf = SONIC_GETDMA(p); - offset += TXBSIZE; - if (offset < PAGE_SIZE) { - p += TXBSIZE; - } else { - p = pp + PAGE_SIZE; - pp = p; - offset = TXBSIZE; - } - } - - return (0); -} - -/* - * miscellaneous NEC/SONIC detect functions. - */ - -/* - * check if a specified irq is acceptable. - */ -u_int8_t -snc_nec16_validate_irq(int irq) -{ - const u_int8_t encoded_irq[16] = { - -1, -1, -1, 0, -1, 1, 2, -1, -1, 3, 4, -1, 5, 6, -1, -1 - }; - - return encoded_irq[irq]; -} - -/* - * specify irq to board. - */ -int -snc_nec16_register_irq(struct snc_softc *sc, int irq) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t encoded_irq; - - encoded_irq = snc_nec16_validate_irq(irq); - if (encoded_irq == (u_int8_t) -1) { - printf("snc_nec16_register_irq: unsupported irq (%d)\n", irq); - return 0; - } - - /* select SNECR_IRQSEL register */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_IRQSEL); - /* write encoded irq value */ - bus_space_write_1(iot, ioh, SNEC_CTRLB, encoded_irq); - - return 1; -} - -/* - * check if a specified memory base address is acceptable. - */ -int -snc_nec16_validate_mem(int maddr) -{ - - /* Check on Normal mode with max range, only */ - if ((maddr & ~0x1E000) != 0xC0000) { - printf("snc_nec16_validate_mem: " - "unsupported window base (0x%x)\n", maddr); - return 0; - } - - return 1; -} - -/* - * specify memory base address to board and map to first bank. - */ -int -snc_nec16_register_mem(struct snc_softc *sc, int maddr) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - - if (snc_nec16_validate_mem(maddr) == 0) - return 0; - - /* select SNECR_MEMSEL register */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMSEL); - /* write encoded memory base select value */ - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_MEMSEL_PHYS2EN(maddr)); - - /* - * set current bank to 0 (bottom) and map - */ - /* select SNECR_MEMBS register */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMBS); - /* select new bank */ - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_MEMBS_B2EB(0) | SNECR_MEMBS_BSEN); - /* set current bank to 0 */ - sc->curbank = 0; - - return 1; -} - -int -snc_nec16_check_memory(bus_space_tag_t iot, bus_space_handle_t ioh, - bus_space_tag_t memt, bus_space_handle_t memh) -{ - u_int16_t val; - int i, j; - - val = 0; - for (i = 0; i < SNEC_NBANK; i++) { - /* select new bank */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMBS); - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_MEMBS_B2EB(i) | SNECR_MEMBS_BSEN); - - /* write test pattern */ - for (j = 0; j < SNEC_NMEMS / 2; j++) { - bus_space_write_2(memt, memh, j * 2, val + j); - } - val += 0x1000; - } - - val = 0; - for (i = 0; i < SNEC_NBANK; i++) { - /* select new bank */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMBS); - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_MEMBS_B2EB(i) | SNECR_MEMBS_BSEN); - - /* read test pattern */ - for (j = 0; j < SNEC_NMEMS / 2; j++) { - if (bus_space_read_2(memt, memh, j * 2) != val + j) - break; - } - - if (j < SNEC_NMEMS / 2) { - printf("snc_nec16_check_memory: " - "memory check failed at 0x%04x%04x" - "val 0x%04x != expected 0x%04x\n", i, j, - bus_space_read_2(memt, memh, j * 2), - val + j); - return 0; - } - val += 0x1000; - } - - /* zero clear mem */ - for (i = 0; i < SNEC_NBANK; i++) { - /* select new bank */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMBS); - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_MEMBS_B2EB(i) | SNECR_MEMBS_BSEN); - - bus_space_set_region_4(memt, memh, 0, 0, SNEC_NMEMS >> 2); - } - - /* again read test if these are 0 */ - for (i = 0; i < SNEC_NBANK; i++) { - /* select new bank */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMBS); - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_MEMBS_B2EB(i) | SNECR_MEMBS_BSEN); - - /* check if cleared */ - for (j = 0; j < SNEC_NMEMS; j += 2) { - if (bus_space_read_2(memt, memh, j) != 0) - break; - } - - if (j != SNEC_NMEMS) { - printf("snc_nec16_check_memory: " - "memory zero clear failed at 0x%04x%04x\n", i, j); - return 0; - } - } - - return 1; -} - -int -snc_nec16_detectsubr(bus_space_tag_t iot, bus_space_handle_t ioh, - bus_space_tag_t memt, bus_space_handle_t memh, int irq, int maddr, - u_int8_t type) -{ - u_int16_t cr; - u_int8_t ident; - int rv = 0; - - if (snc_nec16_validate_irq(irq) == (u_int8_t) -1) - return 0; - /* XXX: maddr already checked */ - if (snc_nec16_validate_mem(maddr) == 0) - return 0; - - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_IDENT); - ident = bus_space_read_1(iot, ioh, SNEC_CTRLB); - if (ident == 0xff || ident == 0x00) { - /* not found */ - return 0; - } - - switch (type) { - case SNEC_TYPE_LEGACY: - rv = (ident == SNECR_IDENT_LEGACY_CBUS); - break; - case SNEC_TYPE_PNP: - rv = ((ident == SNECR_IDENT_PNP_CBUS) || - (ident == SNECR_IDENT_PNP_PCMCIABUS)); - break; - default: - break; - } - - if (rv == 0) { - printf("snc_nec16_detectsubr: parent bus mismatch\n"); - return 0; - } - - /* select SONIC register SNCR_CR */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNCR_CR); - bus_space_write_2(iot, ioh, SNEC_CTRL, CR_RXDIS | CR_STP | CR_RST); - DELAY(400); - - cr = bus_space_read_2(iot, ioh, SNEC_CTRL); - if (cr != (CR_RXDIS | CR_STP | CR_RST)) { -#ifdef DIAGNOSTIC - printf("snc_nec16_detectsubr: card reset failed, cr = 0x%04x\n", - cr); -#endif - return 0; - } - - if (snc_nec16_check_memory(iot, ioh, memt, memh) == 0) - return 0; - - return 1; -} - -/* XXX */ -#define SNC_VENDOR_NEC 0x00004c -#define SNC_NEC_SERIES_LEGACY_CBUS 0xa5 -#define SNC_NEC_SERIES_PNP_PCMCIA 0xd5 -#define SNC_NEC_SERIES_PNP_PCMCIA2 0x6d /* XXX */ -#define SNC_NEC_SERIES_PNP_CBUS 0x0d -#define SNC_NEC_SERIES_PNP_CBUS2 0x3d - -u_int8_t * -snc_nec16_detect_type(u_int8_t *myea) -{ - u_int32_t vendor = (myea[0] << 16) | (myea[1] << 8) | myea[2]; - u_int8_t series = myea[3]; - u_int8_t type = myea[4] & 0x80; - u_int8_t *typestr; - - switch (vendor) { - case SNC_VENDOR_NEC: - switch (series) { - case SNC_NEC_SERIES_LEGACY_CBUS: - if (type) - typestr = "NEC PC-9801-84"; - else - typestr = "NEC PC-9801-83"; - break; - case SNC_NEC_SERIES_PNP_CBUS: - case SNC_NEC_SERIES_PNP_CBUS2: - if (type) - typestr = "NEC PC-9801-104"; - else - typestr = "NEC PC-9801-103"; - break; - case SNC_NEC_SERIES_PNP_PCMCIA: - case SNC_NEC_SERIES_PNP_PCMCIA2: - /* XXX: right ? */ - if (type) - typestr = "NEC PC-9801N-J02R"; - else - typestr = "NEC PC-9801N-J02"; - break; - default: - typestr = "NEC unknown (PC-9801N-25?)"; - break; - } - break; - default: - typestr = "unknown (3rd vendor?)"; - break; - } - - return typestr; -} - -int -snc_nec16_get_enaddr(bus_space_tag_t iot, bus_space_handle_t ioh, - u_int8_t *myea) -{ - u_int8_t eeprom[SNEC_EEPROM_SIZE]; - u_int8_t rom_sum, sum = 0x00; - int i; - - snc_nec16_read_eeprom(iot, ioh, eeprom); - - for (i = SNEC_EEPROM_KEY0; i < SNEC_EEPROM_CKSUM; i++) { - sum = sum ^ eeprom[i]; - } - - rom_sum = eeprom[SNEC_EEPROM_CKSUM]; - - if (sum != rom_sum) { - printf("snc_nec16_get_enaddr: " - "checksum mismatch; calculated %02x != read %02x", - sum, rom_sum); - return 0; - } - - for (i = 0; i < ETHER_ADDR_LEN; i++) - myea[i] = eeprom[SNEC_EEPROM_SA0 + i]; - - return 1; -} - -/* - * read from NEC/SONIC NIC register. - */ -u_int16_t -snc_nec16_nic_get(struct snc_softc *sc, u_int8_t reg) -{ - u_int16_t val; - - /* select SONIC register */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, SNEC_ADDR, reg); - val = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SNEC_CTRL); - - return val; -} - -/* - * write to NEC/SONIC NIC register. - */ -void -snc_nec16_nic_put(struct snc_softc *sc, u_int8_t reg, u_int16_t val) -{ - - /* select SONIC register */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, SNEC_ADDR, reg); - bus_space_write_2(sc->sc_iot, sc->sc_ioh, SNEC_CTRL, val); -} - - -/* - * select memory bank and map - * where exists specified (internal buffer memory) offset. - */ -static __inline u_int16_t -snc_nec16_select_bank(struct snc_softc *sc, u_int32_t base, u_int32_t offset) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t bank; - u_int16_t noffset; - - /* bitmode is fixed to 16 bit. */ - bank = (base + offset * 2) >> 13; - noffset = (base + offset * 2) & (SNEC_NMEMS - 1); - -#ifdef SNCDEBUG - if (noffset % 2) { - device_printf(sc->sc_dev, "noffset is odd (0x%04x)\n", - noffset); - } -#endif /* SNCDEBUG */ - - if (sc->curbank != bank) { - /* select SNECR_MEMBS register */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_MEMBS); - /* select new bank */ - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_MEMBS_B2EB(bank) | SNECR_MEMBS_BSEN); - /* update current bank */ - sc->curbank = bank; - } - - return noffset; -} - -/* - * write to SONIC descriptors. - */ -void -snc_nec16_writetodesc(struct snc_softc *sc, u_int32_t base, u_int32_t offset, - u_int16_t val) -{ - bus_space_tag_t memt = sc->sc_memt; - bus_space_handle_t memh = sc->sc_memh; - u_int16_t noffset; - - noffset = snc_nec16_select_bank(sc, base, offset); - - bus_space_write_2(memt, memh, noffset, val); -} - -/* - * read from SONIC descriptors. - */ -u_int16_t -snc_nec16_readfromdesc(struct snc_softc *sc, u_int32_t base, u_int32_t offset) -{ - bus_space_tag_t memt = sc->sc_memt; - bus_space_handle_t memh = sc->sc_memh; - u_int16_t noffset; - - noffset = snc_nec16_select_bank(sc, base, offset); - - return bus_space_read_2(memt, memh, noffset); -} - -/* - * read from SONIC data buffer. - */ -void -snc_nec16_copyfrombuf(struct snc_softc *sc, void *dst, u_int32_t offset, - size_t size) -{ - bus_space_tag_t memt = sc->sc_memt; - bus_space_handle_t memh = sc->sc_memh; - u_int16_t noffset; - u_int8_t* bptr = dst; - - noffset = snc_nec16_select_bank(sc, offset, 0); - - /* XXX: should check if offset + size < 0x2000. */ - - bus_space_barrier(memt, memh, noffset, size, - BUS_SPACE_BARRIER_READ); - - if (size > 3) { - if (noffset & 3) { - size_t asize = 4 - (noffset & 3); - - bus_space_read_region_1(memt, memh, noffset, - bptr, asize); - bptr += asize; - noffset += asize; - size -= asize; - } - bus_space_read_region_4(memt, memh, noffset, - (u_int32_t *) bptr, size >> 2); - bptr += size & ~3; - noffset += size & ~3; - size &= 3; - } - if (size) - bus_space_read_region_1(memt, memh, noffset, bptr, size); -} - -/* - * write to SONIC data buffer. - */ -void -snc_nec16_copytobuf(struct snc_softc *sc, void *src, u_int32_t offset, - size_t size) -{ - bus_space_tag_t memt = sc->sc_memt; - bus_space_handle_t memh = sc->sc_memh; - u_int16_t noffset, onoffset; - size_t osize = size; - u_int8_t* bptr = src; - - noffset = snc_nec16_select_bank(sc, offset, 0); - onoffset = noffset; - - /* XXX: should check if offset + size < 0x2000. */ - - if (size > 3) { - if (noffset & 3) { - size_t asize = 4 - (noffset & 3); - - bus_space_write_region_1(memt, memh, noffset, - bptr, asize); - bptr += asize; - noffset += asize; - size -= asize; - } - bus_space_write_region_4(memt, memh, noffset, - (u_int32_t *)bptr, size >> 2); - bptr += size & ~3; - noffset += size & ~3; - size -= size & ~3; - } - if (size) - bus_space_write_region_1(memt, memh, noffset, bptr, size); - - bus_space_barrier(memt, memh, onoffset, osize, - BUS_SPACE_BARRIER_WRITE); -} - -/* - * write (fill) 0 to SONIC data buffer. - */ -void -snc_nec16_zerobuf(struct snc_softc *sc, u_int32_t offset, size_t size) -{ - bus_space_tag_t memt = sc->sc_memt; - bus_space_handle_t memh = sc->sc_memh; - u_int16_t noffset, onoffset; - size_t osize = size; - - noffset = snc_nec16_select_bank(sc, offset, 0); - onoffset = noffset; - - /* XXX: should check if offset + size < 0x2000. */ - - if (size > 3) { - if (noffset & 3) { - size_t asize = 4 - (noffset & 3); - - bus_space_set_region_1(memt, memh, noffset, 0, asize); - noffset += asize; - size -= asize; - } - bus_space_set_region_4(memt, memh, noffset, 0, size >> 2); - noffset += size & ~3; - size -= size & ~3; - } - if (size) - bus_space_set_region_1(memt, memh, noffset, 0, size); - - bus_space_barrier(memt, memh, onoffset, osize, - BUS_SPACE_BARRIER_WRITE); -} - - -/* - * Routines to read bytes sequentially from EEPROM through NEC PC-9801-83, - * 84, 103, 104, PC-9801N-25 and PC-9801N-J02, J02R for NetBSD/pc98. - * Ported by Kouichi Matsuda. - * - * This algorism is generic to read data sequentially from 4-Wire - * Microwire Serial EEPROM. - */ - -#define SNEC_EEP_DELAY 1000 - -void -snc_nec16_read_eeprom(bus_space_tag_t iot, bus_space_handle_t ioh, - u_int8_t *data) -{ - u_int8_t n, val, bit; - - /* Read bytes from EEPROM; two bytes per an iteration. */ - for (n = 0; n < SNEC_EEPROM_SIZE / 2; n++) { - /* select SNECR_EEP */ - bus_space_write_1(iot, ioh, SNEC_ADDR, SNECR_EEP); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, 0x00); - DELAY(SNEC_EEP_DELAY); - - /* Start EEPROM access. */ - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_EEP_CS); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_DI); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK | SNECR_EEP_DI); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_DI); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK | SNECR_EEP_DI); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_EEP_CS); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK); - DELAY(SNEC_EEP_DELAY); - - /* Pass the iteration count to the chip. */ - for (bit = 0x20; bit != 0x00; bit >>= 1) { - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_EEP_CS | - ((n & bit) ? SNECR_EEP_DI : 0x00)); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK | - ((n & bit) ? SNECR_EEP_DI : 0x00)); - DELAY(SNEC_EEP_DELAY); - } - - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_EEP_CS); - (void) bus_space_read_1(iot, ioh, SNEC_CTRLB); /* ACK */ - DELAY(SNEC_EEP_DELAY); - - /* Read a byte. */ - val = 0; - for (bit = 0x80; bit != 0x00; bit >>= 1) { - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_EEP_CS); - - if (bus_space_read_1(iot, ioh, SNEC_CTRLB) & SNECR_EEP_DO) - val |= bit; - } - *data++ = val; - - /* Read one more byte. */ - val = 0; - for (bit = 0x80; bit != 0x00; bit >>= 1) { - bus_space_write_1(iot, ioh, SNEC_CTRLB, - SNECR_EEP_CS | SNECR_EEP_SK); - DELAY(SNEC_EEP_DELAY); - - bus_space_write_1(iot, ioh, SNEC_CTRLB, SNECR_EEP_CS); - - if (bus_space_read_1(iot, ioh, SNEC_CTRLB) & SNECR_EEP_DO) - val |= bit; - } - *data++ = val; - - bus_space_write_1(iot, ioh, SNEC_CTRLB, 0x00); - DELAY(SNEC_EEP_DELAY); - } - -#ifdef SNCDEBUG - /* Report what we got. */ - data -= SNEC_EEPROM_SIZE; - log(LOG_INFO, "%s: EEPROM:" - " %02x%02x%02x%02x %02x%02x%02x%02x -" - " %02x%02x%02x%02x %02x%02x%02x%02x -" - " %02x%02x%02x%02x %02x%02x%02x%02x -" - " %02x%02x%02x%02x %02x%02x%02x%02x\n", - "snc_nec16_read_eeprom", - data[ 0], data[ 1], data[ 2], data[ 3], - data[ 4], data[ 5], data[ 6], data[ 7], - data[ 8], data[ 9], data[10], data[11], - data[12], data[13], data[14], data[15], - data[16], data[17], data[18], data[19], - data[20], data[21], data[22], data[23], - data[24], data[25], data[26], data[27], - data[28], data[29], data[30], data[31]); -#endif -} - -#ifdef SNCDEBUG -void -snc_nec16_dump_reg(bus_space_tag_t iot, bus_space_handle_t ioh) -{ - u_int8_t n; - u_int16_t val; - - printf("SONIC registers (word):"); - for (n = 0; n < SNC_NREGS; n++) { - /* select required SONIC register */ - bus_space_write_1(iot, ioh, SNEC_ADDR, n); - DELAY(10); - val = bus_space_read_2(iot, ioh, SNEC_CTRL); - if ((n % 0x10) == 0) - printf("\n%04x ", val); - else - printf("%04x ", val); - } - printf("\n"); - - printf("NEC/SONIC registers (byte):\n"); - for (n = SNECR_MEMBS; n <= SNECR_IDENT; n += 2) { - /* select required SONIC register */ - bus_space_write_1(iot, ioh, SNEC_ADDR, n); - DELAY(10); - val = (u_int16_t) bus_space_read_1(iot, ioh, SNEC_CTRLB); - printf("%04x ", val); - } - printf("\n"); -} - -#endif /* SNCDEBUG */ diff --git a/sys/dev/snc/dp83932subr.h b/sys/dev/snc/dp83932subr.h deleted file mode 100644 index f5df4f97970f5..0000000000000 --- a/sys/dev/snc/dp83932subr.h +++ /dev/null @@ -1,78 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: dp83932subr.h,v 1.5 1999/02/02 00:47:25 kmatsuda Exp $ */ -/* $NetBSD$ */ - -/*- - * Copyright (c) 1997, 1998, 1999 - * Kouichi Matsuda. 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 Kouichi Matsuda for - * NetBSD/pc98. - * 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. - */ -/* - * Routines of NEC PC-9801-83, 84, 103, 104, PC-9801N-25 and PC-9801N-J02, J02R - * Ethernet interface for NetBSD/pc98, ported by Kouichi Matsuda. - * - * These cards use National Semiconductor DP83934AVQB as Ethernet Controller - * and National Semiconductor NS46C46 as (64 * 16 bits) Microwire Serial EEPROM. - */ - -int sncsetup(struct snc_softc *, u_int8_t *); - -u_int8_t snc_nec16_validate_irq(int); -int snc_nec16_register_irq(struct snc_softc *, int); -int snc_nec16_validate_mem(int); -int snc_nec16_register_mem(struct snc_softc *, int); - -u_int16_t snc_nec16_nic_get(struct snc_softc *, u_int8_t); -void snc_nec16_nic_put(struct snc_softc *, u_int8_t, u_int16_t); - - -void snc_nec16_writetodesc - (struct snc_softc *, u_int32_t, u_int32_t, u_int16_t); -u_int16_t snc_nec16_readfromdesc - (struct snc_softc *, u_int32_t, u_int32_t); - -void snc_nec16_copyfrombuf(struct snc_softc *, void *, u_int32_t, size_t); -void snc_nec16_copytobuf(struct snc_softc *, void *, u_int32_t, size_t); -void snc_nec16_zerobuf(struct snc_softc *, u_int32_t, size_t); - -int snc_nec16_detectsubr - (bus_space_tag_t, bus_space_handle_t, bus_space_tag_t, - bus_space_handle_t, int, int, u_int8_t); -int snc_nec16_check_memory - (bus_space_tag_t, bus_space_handle_t, bus_space_tag_t, - bus_space_handle_t); - -int snc_nec16_get_enaddr - (bus_space_tag_t, bus_space_handle_t, u_int8_t *); -u_int8_t *snc_nec16_detect_type(u_int8_t *); -void snc_nec16_read_eeprom - (bus_space_tag_t, bus_space_handle_t, u_int8_t *); - -#ifdef SNCDEBUG -void snc_nec16_dump_reg(bus_space_tag_t, bus_space_handle_t); -#endif /* SNDEBUG */ diff --git a/sys/dev/snc/dp83932var.h b/sys/dev/snc/dp83932var.h deleted file mode 100644 index 6ee51085b9b02..0000000000000 --- a/sys/dev/snc/dp83932var.h +++ /dev/null @@ -1,286 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: dp83932var.h,v 1.3 1999/01/24 01:39:51 kmatsuda Exp $ */ -/* $NetBSD: if_snvar.h,v 1.12 1998/05/01 03:42:47 scottr Exp $ */ - -/*- - * [NetBSD for NEC PC-98 series] - * Copyright (c) 1997, 1998, 1999 - * Kouichi Matsuda. All rights reserved. - * - * Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk) - * You may use, copy, and modify this program so long as you retain the - * copyright line. - */ - -/* - * if_snvar.h -- National Semiconductor DP8393X (SONIC) NetBSD/mac68k vars - */ -/* - * Modified for NetBSD/pc98 1.2.1 from NetBSD/mac68k 1.2D by Kouichi Matsuda. - * Make adapted for NEC PC-9801-83, 84, PC-9801-103, 104, PC-9801N-25 and - * PC-9801N-J02, J02R, which uses National Semiconductor DP83934AVQB as - * Ethernet Controller and National Semiconductor NS46C46 as - * (64 * 16 bits) Microwire Serial EEPROM. - */ - -/* - * Vendor types - */ - -/* - * SONIC buffers need to be aligned 16 or 32 bit aligned. - * These macros calculate and verify alignment. - */ -#define ROUNDUP(p, N) (((int) p + N - 1) & ~(N - 1)) - -#define SOALIGN(m, array) (m ? (ROUNDUP(array, 4)) : (ROUNDUP(array, 2))) - -#define LOWER(x) ((unsigned)(x) & 0xffff) -#define UPPER(x) ((unsigned)(x) >> 16) - -/* - * Memory access macros. Since we handle SONIC in 16 bit mode (PB5X0) - * and 32 bit mode (everything else) using a single GENERIC kernel - * binary, all structures have to be accessed using macros which can - * adjust the offsets appropriately. - */ -/* m is not sc->bitmode, we treat m as sc. */ -#define SWO(m, a, o, x) (*(m)->sc_writetodesc)((m), (a), (o), (x)) -#define SRO(m, a, o) (*(m)->sc_readfromdesc)((m), (a), (o)) - -/* - * Register access macros. We use bus_space_* to talk to the Sonic - * registers. A mapping table is used in case a particular configuration - * hooked the regs up at non-word offsets. - */ -#define NIC_GET(sc, reg) (*(sc)->sc_nic_get)(sc, reg) -#define NIC_PUT(sc, reg, val) (*(sc)->sc_nic_put)(sc, reg, val) - -#define SONIC_GETDMA(p) (p) - -/* pc98 does not have any write buffers to flush... */ -#define wbflush() - -/* - * buffer sizes in 32 bit mode - * 1 TXpkt is 4 hdr words + (3 * FRAGMAX) + 1 link word == 23 words == 92 bytes - * - * 1 RxPkt is 7 words == 28 bytes - * 1 Rda is 4 words == 16 bytes - * - * The CDA is 17 words == 68 bytes - * - * total space in page 0 = NTDA * 92 + NRRA * 16 + NRDA * 28 + 68 - */ - -#define NRBA 16 /* # receive buffers < NRRA */ -#define RBAMASK (NRBA-1) -#define NTDA 16 /* # transmit descriptors */ -#define NRRA 64 /* # receive resource descriptors */ -#define RRAMASK (NRRA-1) /* the reason why NRRA must be power of two */ - -#define FCSSIZE 4 /* size of FCS appended to packets */ - -/* - * maximum receive packet size plus 2 byte pad to make each - * one aligned. 4 byte slop (required for eobc) - */ -#define RBASIZE(sc) (sizeof(struct ether_header) + ETHERMTU + FCSSIZE + \ - ((sc)->bitmode ? 6 : 2)) - -/* - * transmit buffer area - */ -#define TXBSIZE 1536 /* 6*2^8 -- the same size as the 8390 TXBUF */ - -#define SN_NPAGES 2 + NRBA + (NTDA/2) - -typedef struct mtd { - u_int32_t mtd_vtxp; - u_int32_t mtd_vbuf; - struct mbuf *mtd_mbuf; -} mtd_t; - -/* - * The snc_softc for PC-98 if_snc. - */ -typedef struct snc_softc { - struct ifnet * sc_ifp; - - device_t sc_dev; - - struct resource * ioport; - int ioport_rid; - struct resource * iomem; - int iomem_rid; - struct resource * irq; - int irq_rid; - void * irq_handle; - - bus_space_tag_t sc_iot; /* bus identifier for io */ - bus_space_tag_t sc_memt; /* bus identifier for mem */ - bus_space_handle_t sc_ioh; /* io handle */ - bus_space_handle_t sc_memh; /* bus memory handle */ - - int bitmode; /* 32 bit mode == 1, 16 == 0 */ - - u_int16_t sncr_dcr; /* DCR for this instance */ - u_int16_t sncr_dcr2; /* DCR2 for this instance */ - - int sc_rramark; /* index into v_rra of wp */ - u_int32_t v_rra[NRRA]; /* DMA addresses of v_rra */ - u_int32_t v_rea; /* ptr to the end of the rra space */ - - int sc_rxmark; /* current hw pos in rda ring */ - int sc_rdamark; /* current sw pos in rda ring */ - int sc_nrda; /* total number of RDAs */ - u_int32_t v_rda; - - u_int32_t rbuf[NRBA]; - - struct mtd mtda[NTDA]; - int mtd_hw; /* idx of first mtd given to hw */ - int mtd_prev; /* idx of last mtd given to hardware */ - int mtd_free; /* next free mtd to use */ - int mtd_tlinko; /* - * offset of tlink of last txp given - * to SONIC. Need to clear EOL on - * this word to add a desc. - */ - int mtd_pint; /* Counter to set TXP_PINT */ - - u_int32_t v_cda; - - u_int8_t curbank; /* current window bank */ - - struct ifmedia sc_media; /* supported media information */ - - /* - * NIC register access functions: - */ - u_int16_t (*sc_nic_get) - (struct snc_softc *, u_int8_t); - void (*sc_nic_put) - (struct snc_softc *, u_int8_t, u_int16_t); - - /* - * Memory functions: - * - * copy to/from descriptor - * copy to/from buffer - * zero bytes in buffer - */ - void (*sc_writetodesc) - (struct snc_softc *, u_int32_t, u_int32_t, u_int16_t); - u_int16_t (*sc_readfromdesc) - (struct snc_softc *, u_int32_t, u_int32_t); - void (*sc_copytobuf) - (struct snc_softc *, void *, u_int32_t, size_t); - void (*sc_copyfrombuf) - (struct snc_softc *, void *, u_int32_t, size_t); - void (*sc_zerobuf) - (struct snc_softc *, u_int32_t, size_t); - - /* - * Machine-dependent functions: - * - * hardware reset hook - may be NULL - * hardware init hook - may be NULL - * media change hook - may be NULL - */ - void (*sc_hwreset)(struct snc_softc *); - void (*sc_hwinit)(struct snc_softc *); - int (*sc_mediachange)(struct snc_softc *); - void (*sc_mediastatus)(struct snc_softc *, struct ifmediareq *); - - int sc_enabled; /* boolean; power enabled on interface */ - - int (*sc_enable)(struct snc_softc *); - void (*sc_disable)(struct snc_softc *); - - void *sc_sh; /* shutdownhook cookie */ - int gone; - struct mtx sc_lock; - struct callout sc_timer; - int sc_tx_timeout; -} snc_softc_t; - -#define SNC_LOCK(sc) mtx_lock(&(sc)->sc_lock) -#define SNC_UNLOCK(sc) mtx_unlock(&(sc)->sc_lock) -#define SNC_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_lock, MA_OWNED) - -/* - * Accessing SONIC data structures and registers as 32 bit values - * makes code endianness independent. The SONIC is however always in - * bigendian mode so it is necessary to ensure that data structures shared - * between the CPU and the SONIC are always in bigendian order. - */ - -/* - * Receive Resource Descriptor - * This structure describes the buffers into which packets - * will be received. Note that more than one packet may be - * packed into a single buffer if constraints permit. - */ -#define RXRSRC_PTRLO 0 /* buffer address LO */ -#define RXRSRC_PTRHI 1 /* buffer address HI */ -#define RXRSRC_WCLO 2 /* buffer size (16bit words) LO */ -#define RXRSRC_WCHI 3 /* buffer size (16bit words) HI */ - -#define RXRSRC_SIZE(sc) (sc->bitmode ? (4 * 4) : (4 * 2)) - -/* - * Receive Descriptor - * This structure holds information about packets received. - */ -#define RXPKT_STATUS 0 -#define RXPKT_BYTEC 1 -#define RXPKT_PTRLO 2 -#define RXPKT_PTRHI 3 -#define RXPKT_SEQNO 4 -#define RXPKT_RLINK 5 -#define RXPKT_INUSE 6 -#define RXPKT_SIZE(sc) (sc->bitmode ? (7 * 4) : (7 * 2)) - -#define RBASEQ(x) (((x)>>8)&0xff) -#define PSNSEQ(x) ((x) & 0xff) - -/* - * Transmit Descriptor - * This structure holds information about packets to be transmitted. - */ -#define FRAGMAX 8 /* maximum number of fragments in a packet */ - -#define TXP_STATUS 0 /* + transmitted packet status */ -#define TXP_CONFIG 1 /* transmission configuration */ -#define TXP_PKTSIZE 2 /* entire packet size in bytes */ -#define TXP_FRAGCNT 3 /* # fragments in packet */ - -#define TXP_FRAGOFF 4 /* offset to first fragment */ -#define TXP_FRAGSIZE 3 /* size of each fragment desc */ -#define TXP_FPTRLO 0 /* ptr to packet fragment LO */ -#define TXP_FPTRHI 1 /* ptr to packet fragment HI */ -#define TXP_FSIZE 2 /* fragment size */ - -#define TXP_WORDS (TXP_FRAGOFF + (FRAGMAX*TXP_FRAGSIZE) + 1) /* 1 for tlink */ -#define TXP_SIZE(sc) ((sc->bitmode) ? (TXP_WORDS*4) : (TXP_WORDS*2)) - -#define EOL 0x0001 /* end of list marker for link fields */ - -/* - * CDA, the CAM descriptor area. The SONIC has a 16 entry CAM to - * match incoming addresses against. It is programmed via DMA - * from a memory region. - */ -#define MAXCAM 16 /* number of user entries in CAM */ -#define CDA_CAMDESC 4 /* # words i na descriptor */ -#define CDA_CAMEP 0 /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */ -#define CDA_CAMAP0 1 /* CAM Address Port 1 xx-xx-YY-YY-xx-xx */ -#define CDA_CAMAP1 2 /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */ -#define CDA_CAMAP2 3 -#define CDA_ENABLE 64 /* mask enabling CAM entries */ -#define CDA_SIZE(sc) ((4*16 + 1) * ((sc->bitmode) ? 4 : 2)) - -int sncconfig(struct snc_softc *, int *, int, int, u_int8_t *); -void sncintr(void *); -void sncshutdown(void *); diff --git a/sys/dev/snc/if_snc.c b/sys/dev/snc/if_snc.c deleted file mode 100644 index 99f458354a7d1..0000000000000 --- a/sys/dev/snc/if_snc.c +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * Copyright (c) 1995, David Greenman - * 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 unmodified, 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. - * - * 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. - * - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * National Semiconductor DP8393X SONIC Driver - * - * This is the bus independent attachment on FreeBSD 4.x - * written by Motomichi Matsuzaki <mzaki@e-mail.ne.jp> - */ - -#include <sys/param.h> -#include <sys/socket.h> - -#include <sys/bus.h> -#include <machine/bus.h> -#include <sys/rman.h> -#include <machine/resource.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> -#include <net/if_var.h> - -#include <dev/snc/dp83932reg.h> -#include <dev/snc/dp83932var.h> -#include <dev/snc/dp83932subr.h> -#include <dev/snc/if_sncreg.h> -#include <dev/snc/if_sncvar.h> - -/* devclass for "snc" */ -devclass_t snc_devclass; - -/**************************************************************** - Resource management functions - ****************************************************************/ - -/* - * Allocate a port resource with the given resource id. - */ -int -snc_alloc_port(device_t dev, int rid) -{ - struct snc_softc *sc = device_get_softc(dev); - struct resource *res; - - res = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &rid, - SNEC_NREGS, RF_ACTIVE); - if (res) { - sc->ioport = res; - sc->ioport_rid = rid; - sc->sc_iot = rman_get_bustag(res); - sc->sc_ioh = rman_get_bushandle(res); - return (0); - } else { - device_printf(dev, "can't assign port\n"); - return (ENOENT); - } -} - -/* - * Allocate a memory resource with the given resource id. - */ -int -snc_alloc_memory(device_t dev, int rid) -{ - struct snc_softc *sc = device_get_softc(dev); - struct resource *res; - - res = bus_alloc_resource_anywhere(dev, SYS_RES_MEMORY, &rid, - SNEC_NMEMS, RF_ACTIVE); - if (res) { - sc->iomem = res; - sc->iomem_rid = rid; - sc->sc_memt = rman_get_bustag(res); - sc->sc_memh = rman_get_bushandle(res); - return (0); - } else { - device_printf(dev, "can't assign memory\n"); - return (ENOENT); - } -} - -/* - * Allocate an irq resource with the given resource id. - */ -int -snc_alloc_irq(device_t dev, int rid, int flags) -{ - struct snc_softc *sc = device_get_softc(dev); - struct resource *res; - - res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | flags); - if (res) { - sc->irq = res; - sc->irq_rid = rid; - return (0); - } else { - device_printf(dev, "can't assign irq\n"); - return (ENOENT); - } -} - -/* - * Release all resources - */ -void -snc_release_resources(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - - if (sc->ioport) { - bus_release_resource(dev, SYS_RES_IOPORT, - sc->ioport_rid, sc->ioport); - sc->ioport = 0; - } - if (sc->iomem) { - bus_release_resource(dev, SYS_RES_MEMORY, - sc->iomem_rid, sc->iomem); - sc->iomem = 0; - } - if (sc->irq) { - bus_release_resource(dev, SYS_RES_IRQ, - sc->irq_rid, sc->irq); - sc->irq = 0; - } - if (sc->sc_ifp) { - if_free(sc->sc_ifp); - sc->sc_ifp = 0; - } -} - -/**************************************************************** - Probe routine - ****************************************************************/ - -int -snc_probe(device_t dev, int type) -{ - struct snc_softc *sc = device_get_softc(dev); - - return snc_nec16_detectsubr(sc->sc_iot, sc->sc_ioh, - sc->sc_memt, sc->sc_memh, - rman_get_start(sc->irq), - rman_get_start(sc->iomem), - type); -} - -/**************************************************************** - Attach routine - ****************************************************************/ - -int -snc_attach(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - u_int8_t myea[ETHER_ADDR_LEN]; - int error; - - if (snc_nec16_register_irq(sc, rman_get_start(sc->irq)) == 0 || - snc_nec16_register_mem(sc, rman_get_start(sc->iomem)) == 0) { - snc_release_resources(dev); - return(ENOENT); - } - - snc_nec16_get_enaddr(sc->sc_iot, sc->sc_ioh, myea); - device_printf(dev, "%s Ethernet\n", snc_nec16_detect_type(myea)); - - sc->sc_dev = dev; - - sc->sncr_dcr = DCR_SYNC | DCR_WAIT0 | - DCR_DMABLOCK | DCR_RFT16 | DCR_TFT28; - sc->sncr_dcr2 = 0; /* XXX */ - sc->bitmode = 0; /* 16 bit card */ - - sc->sc_nic_put = snc_nec16_nic_put; - sc->sc_nic_get = snc_nec16_nic_get; - sc->sc_writetodesc = snc_nec16_writetodesc; - sc->sc_readfromdesc = snc_nec16_readfromdesc; - sc->sc_copytobuf = snc_nec16_copytobuf; - sc->sc_copyfrombuf = snc_nec16_copyfrombuf; - sc->sc_zerobuf = snc_nec16_zerobuf; - - /* sncsetup returns 1 if something fails */ - if (sncsetup(sc, myea)) { - snc_release_resources(dev); - return(ENOENT); - } - - mtx_init(&sc->sc_lock, device_get_nameunit(dev), MTX_NETWORK_LOCK, - MTX_DEF); - callout_init_mtx(&sc->sc_timer, &sc->sc_lock, 0); - error = sncconfig(sc, NULL, 0, 0, myea); - if (error) { - snc_release_resources(dev); - mtx_destroy(&sc->sc_lock); - return (error); - } - - error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, - NULL, sncintr, sc, &sc->irq_handle); - if (error) { - printf("snc_isa_attach: bus_setup_intr() failed\n"); - ether_ifdetach(sc->sc_ifp); - snc_release_resources(dev); - mtx_destroy(&sc->sc_lock); - return (error); - } - - return 0; -} - -/**************************************************************** - Shutdown routine - ****************************************************************/ - -int -snc_shutdown(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - - SNC_LOCK(sc); - sncshutdown(sc); - SNC_UNLOCK(sc); - - return (0); -} diff --git a/sys/dev/snc/if_snc_cbus.c b/sys/dev/snc/if_snc_cbus.c deleted file mode 100644 index 484b677967a3b..0000000000000 --- a/sys/dev/snc/if_snc_cbus.c +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * Copyright (c) 1995, David Greenman - * 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 unmodified, 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. - * - * 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. - * - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * National Semiconductor DP8393X SONIC Driver - * - * This is the C-bus specific attachment on FreeBSD - * written by Motomichi Matsuzaki <mzaki@e-mail.ne.jp> - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/socket.h> -#include <sys/kernel.h> - -#include <sys/module.h> -#include <sys/bus.h> -#include <machine/bus.h> -#include <machine/resource.h> - -#include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> - -#include <isa/isavar.h> -#include <sys/malloc.h> /* as dependency for isa/isa_common.h */ -#include <isa/isa_common.h> /* for snc_isapnp_reconfig() */ - -#include <dev/snc/dp83932var.h> -#include <dev/snc/if_sncreg.h> -#include <dev/snc/if_sncvar.h> - -static void snc_isapnp_reconfig (device_t); -static int snc_isa_probe (device_t); -static int snc_isa_attach (device_t); - -static struct isa_pnp_id snc_ids[] = { - { 0x6180a3b8, NULL }, /* NEC8061 NEC PC-9801-104 */ - { 0, NULL } -}; - -static void -snc_isapnp_reconfig(device_t dev) -{ - struct isa_device *idev = DEVTOISA(dev); - struct isa_config config; - rman_res_t start, count; - int rid; - - bzero(&config, sizeof(config)); - - for (rid = 0; rid < ISA_NMEM; rid++) { - if (bus_get_resource(dev, SYS_RES_MEMORY, rid, &start, &count)) - break; - config.ic_mem[rid].ir_start = start; - config.ic_mem[rid].ir_end = start; - config.ic_mem[rid].ir_size = count; - } - config.ic_nmem = rid; - for (rid = 0; rid < ISA_NPORT; rid++) { - if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &start, &count)) - break; - config.ic_port[rid].ir_start = start; - config.ic_port[rid].ir_end = start; - config.ic_port[rid].ir_size = count; - } - config.ic_nport = rid; - for (rid = 0; rid < ISA_NIRQ; rid++) { - if (bus_get_resource(dev, SYS_RES_IRQ, rid, &start, &count)) - break; - config.ic_irqmask[rid] = 1 << start; - } - config.ic_nirq = rid; - for (rid = 0; rid < ISA_NDRQ; rid++) { - if (bus_get_resource(dev, SYS_RES_DRQ, rid, &start, &count)) - break; - config.ic_drqmask[rid] = 1 << start; - } - config.ic_ndrq = rid; - - idev->id_config_cb(idev->id_config_arg, &config, 1); -} - -static int -snc_isa_probe(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - int type; - int error = 0; - - bzero(sc, sizeof(struct snc_softc)); - - /* Check isapnp ids */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, snc_ids); - - /* If the card had a PnP ID that didn't match any we know about */ - if (error == ENXIO) { - return(error); - } - - switch (error) { - case 0: /* Matched PnP */ - type = SNEC_TYPE_PNP; - break; - - case ENOENT: /* Legacy ISA */ - type = SNEC_TYPE_LEGACY; - break; - - default: /* If we had some other problem. */ - return(error); - } - - if (type == SNEC_TYPE_PNP && isa_get_portsize(dev) == 0) { - int port; - int rid = 0; - struct resource *res = NULL; - - for (port = 0x0888; port <= 0x3888; port += 0x1000) { - bus_set_resource(dev, SYS_RES_IOPORT, rid, - port, SNEC_NREGS); - res = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, - &rid, SNEC_NREGS, - 0 /* !RF_ACTIVE */); - if (res) break; - } - - printf("snc_isa_probe: broken PnP resource, "); - if (res) { - printf("use port 0x%x\n", port); - bus_release_resource(dev, SYS_RES_IOPORT, rid, res); - snc_isapnp_reconfig(dev); - } else { - printf("and can't find port\n"); - } - } - - error = snc_alloc_port(dev, 0); - error = max(error, snc_alloc_memory(dev, 0)); - error = max(error, snc_alloc_irq(dev, 0, 0)); - - if (!error && !snc_probe(dev, type)) - error = ENOENT; - - snc_release_resources(dev); - return (error); -} - -static int -snc_isa_attach(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - - bzero(sc, sizeof(struct snc_softc)); - - snc_alloc_port(dev, 0); - snc_alloc_memory(dev, 0); - snc_alloc_irq(dev, 0, 0); - - /* This interface is always enabled. */ - sc->sc_enabled = 1; - - return snc_attach(dev); -} - -static device_method_t snc_isa_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, snc_isa_probe), - DEVMETHOD(device_attach, snc_isa_attach), - DEVMETHOD(device_shutdown, snc_shutdown), - - { 0, 0 } -}; - -static driver_t snc_isa_driver = { - "snc", - snc_isa_methods, - sizeof(struct snc_softc) -}; - -DRIVER_MODULE(snc, isa, snc_isa_driver, snc_devclass, 0, 0); -MODULE_DEPEND(snc, isa, 1, 1, 1); -MODULE_DEPEND(snc, ether, 1, 1, 1); diff --git a/sys/dev/snc/if_snc_pccard.c b/sys/dev/snc/if_snc_pccard.c deleted file mode 100644 index 7f975be191635..0000000000000 --- a/sys/dev/snc/if_snc_pccard.c +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * Copyright (c) 1995, David Greenman - * 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 unmodified, 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. - * - * 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. - * - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * National Semiconductor DP8393X SONIC Driver - * - * This is the PC Card attachment on FreeBSD - * written by Motomichi Matsuzaki <mzaki@e-mail.ne.jp> and - * Hiroshi Yamashita <bluemoon@msj.biglobe.ne.jp> - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/socket.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/mutex.h> - -#include <sys/module.h> -#include <sys/bus.h> -#include <machine/bus.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> - -#include <dev/snc/dp83932var.h> -#include <dev/snc/if_sncvar.h> -#include <dev/snc/if_sncreg.h> - -#include <dev/pccard/pccardvar.h> -#include <dev/pccard/pccard_cis.h> -#include "pccarddevs.h" - -static const struct pccard_product snc_pccard_products[] = { - PCMCIA_CARD(NEC, PC9801N_J02), - PCMCIA_CARD(NEC, PC9801N_J02R), - { NULL } -}; - -/* - * PC Card (PCMCIA) specific code. - */ -static int snc_pccard_probe(device_t); -static int snc_pccard_attach(device_t); -static int snc_pccard_detach(device_t); - - -static device_method_t snc_pccard_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, snc_pccard_probe), - DEVMETHOD(device_attach, snc_pccard_attach), - DEVMETHOD(device_detach, snc_pccard_detach), - - { 0, 0 } -}; - -static driver_t snc_pccard_driver = { - "snc", - snc_pccard_methods, - sizeof(struct snc_softc) -}; - -DRIVER_MODULE(snc, pccard, snc_pccard_driver, snc_devclass, 0, 0); -MODULE_DEPEND(snc, ether, 1, 1, 1); -PCCARD_PNP_INFO(snc_pccard_products); - -/* - * snc_pccard_detach - detach this instance from the device. - */ -static int -snc_pccard_detach(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - struct ifnet *ifp = sc->sc_ifp; - - if (sc->gone) { - device_printf(dev, "already unloaded\n"); - return (0); - } - SNC_LOCK(sc); - sncshutdown(sc); - SNC_UNLOCK(sc); - callout_drain(&sc->sc_timer); - ether_ifdetach(ifp); - sc->gone = 1; - bus_teardown_intr(dev, sc->irq, sc->irq_handle); - snc_release_resources(dev); - mtx_destroy(&sc->sc_lock); - return (0); -} - -/* - * Probe the pccard. - */ -static int -snc_pccard_probe(device_t dev) -{ - const struct pccard_product *pp; - - if ((pp = pccard_product_lookup(dev, snc_pccard_products, - sizeof(snc_pccard_products[0]), NULL)) == NULL) - return (EIO); - if (pp->pp_name != NULL) - device_set_desc(dev, pp->pp_name); - return (0); -} - -static int -snc_pccard_attach(device_t dev) -{ - struct snc_softc *sc = device_get_softc(dev); - int error; - - /* - * Not sure that this belongs here or in snc_pccard_attach - */ - if ((error = snc_alloc_port(dev, 0)) != 0) - goto err; - if ((error = snc_alloc_memory(dev, 0)) != 0) - goto err; - if ((error = snc_alloc_irq(dev, 0, 0)) != 0) - goto err; - if ((error = snc_probe(dev, SNEC_TYPE_PNP)) != 0) - goto err; - /* This interface is always enabled. */ - sc->sc_enabled = 1; - /* pccard_get_ether(dev, ether_addr); */ - if ((error = snc_attach(dev)) != 0) - goto err; - return 0; -err:; - snc_release_resources(dev); - return error; -} diff --git a/sys/dev/snc/if_sncreg.h b/sys/dev/snc/if_sncreg.h deleted file mode 100644 index 5973881e89040..0000000000000 --- a/sys/dev/snc/if_sncreg.h +++ /dev/null @@ -1,140 +0,0 @@ -/* $FreeBSD$ */ -/* $NecBSD: if_snreg.h,v 1.3 1999/01/24 01:39:52 kmatsuda Exp $ */ -/* $NetBSD$ */ - -/*- - * Copyright (c) 1997, 1998, 1999 - * Kouichi Matsuda. 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 Kouichi Matsuda for - * NetBSD/pc98. - * 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. - */ -/* - * Modified for NetBSD/pc98 1.2.1 from NetBSD/mac68k 1.2D by Kouichi Matsuda. - * Make adapted for NEC PC-9801-83, 84, PC-9801-103, 104, PC-9801N-25 and - * PC-9801N-J02R, which uses National Semiconductor DP83934AVQB as - * Ethernet Controller and National Semiconductor NS46C46 as (64 * 16 bits) - * Microwire Serial EEPROM. - */ - -/* - * XXX: Should not be HERE. (Should be shared with...) - */ - -/* - * NEC/SONIC port mappings, offset from iobase. - */ -#define SNEC_CTRL 0 /* SONIC control port (word) */ -#define SNEC_CTRLB 1 /* NEC/SONIC control port (byte) */ -#define SNEC_RSVD0 2 /* not used */ -#define SNEC_ADDR 3 /* SONIC, NEC/SONIC register address set port */ -#define SNEC_RSVD1 4 /* not used */ -#define SNEC_RSVD2 5 /* not used */ - -#define SNEC_NREGS 6 - -/* bank memory size */ -#define SNEC_NMEMS (PAGE_SIZE * 2) -/* how many bank */ -#define SNEC_NBANK 0x10 -/* internal buffer size */ -#define SNEC_NBUF (SNEC_NMEMS * SNEC_NBANK) - - -/* - * NEC/SONIC specific internal registers. - */ - -/* - * Memory Bank Select Register (MEMBS) - */ -#define SNECR_MEMBS 0x80 -#define SNECR_MEMBS_BSEN 0x01 /* enable memory bank select */ -#define SNECR_MEMBS_EBNMSK 0x1c /* encoded bank select number */ -/* Translate bank number to encoded bank select number. */ -#define SNECR_MEMBS_B2EB(bank) (bank << 2) -#define SNECR_MEMBS_PCMCIABUS 0x80 /* bus type identification */ - -/* - * Memory Base Address Select Register (MEMSEL) - */ -#define SNECR_MEMSEL 0x82 -/* Translate base phys address to encoded select number. */ -#define SNECR_MEMSEL_PHYS2EN(maddr) ((maddr >> 13) & 0x0f) - -/* - * Encoded Irq Select Register (IRQSEL) - */ -#define SNECR_IRQSEL 0x84 - -/* - * EEPROM Access Register (EEP) - */ -#define SNECR_EEP 0x86 -#define SNECR_EEP_DI 0x10 /* EEPROM Serial Data Input (high) */ -#define SNECR_EEP_CS 0x20 /* EEPROM Chip Select (high) */ -#define SNECR_EEP_SK 0x40 /* EEPROM Serial Data Clock (high) */ -#define SNECR_EEP_DO 0x80 /* EEPROM Serial Data Output (high) */ - -/* EEPROM data locations */ -#define SNEC_EEPROM_KEY0 6 /* Station Address Check Sum Key #1 */ -#define SNEC_EEPROM_KEY1 7 /* Station Address Check Sum Key #2 */ -#define SNEC_EEPROM_SA0 8 /* Station Address #1 */ -#define SNEC_EEPROM_SA1 9 /* Station Address #2 */ -#define SNEC_EEPROM_SA2 10 /* Station Address #3 */ -#define SNEC_EEPROM_SA3 11 /* Station Address #4 */ -#define SNEC_EEPROM_SA4 12 /* Station Address #5 */ -#define SNEC_EEPROM_SA5 13 /* Station Address #6 */ -#define SNEC_EEPROM_CKSUM 14 /* Station Address Check Sum */ - -#define SNEC_EEPROM_SIZE 32 /* valid EEPROM data (max 128 bytes) */ - -/* - * Bus and Mode Identification Register (IDENT) - */ -#define SNECR_IDENT 0x88 - /* Bit 0: Bus Identification. */ -#define SNECR_IDENT_CBUS 0x01 /* on PC-98 C-Bus */ -#define SNECR_IDENT_PCMCIABUS 0x00 /* on PCMCIA Bus */ - /* Bit 2: always 1 */ -#define SNECR_IDENT_MAGIC 0x04 - /* Bit 4: Bus Configuration Mode Identification. */ -#define SNECR_IDENT_PNP 0x10 /* Plug and Play (C-Bus and PCMCIA) */ -#define SNECR_IDENT_LEGACY 0x00 /* Legacy C-Bus */ - -#define SNECR_IDENT_LEGACY_CBUS \ - (SNECR_IDENT_LEGACY | SNECR_IDENT_MAGIC | SNECR_IDENT_CBUS) -#define SNECR_IDENT_PNP_CBUS \ - (SNECR_IDENT_PNP | SNECR_IDENT_MAGIC | SNECR_IDENT_CBUS) -#define SNECR_IDENT_PNP_PCMCIABUS \ - (SNECR_IDENT_PNP | SNECR_IDENT_MAGIC | SNECR_IDENT_PCMCIABUS) - -/* - * XXX: parent bus type aliases - */ -#define SNEC_TYPE_LEGACY 0 -#define SNEC_TYPE_PNP 1 - diff --git a/sys/dev/snc/if_sncvar.h b/sys/dev/snc/if_sncvar.h deleted file mode 100644 index 05d699be0c3b0..0000000000000 --- a/sys/dev/snc/if_sncvar.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1995, David Greenman - * 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 unmodified, 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. - * - * 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. - * - * $FreeBSD$ - */ - -/* - * National Semiconductor DP8393X SONIC Driver - * - * This is the machine dependent attachment on FreeBSD 4.x - * written by Motomichi Matsuzaki <mzaki@e-mail.ne.jp> - */ - -extern devclass_t snc_devclass; - -void snc_release_resources (device_t); -int snc_alloc_port (device_t, int); -int snc_alloc_memory (device_t, int); -int snc_alloc_irq (device_t, int, int); - -int snc_probe (device_t, int); -int snc_attach (device_t); - -int snc_shutdown (device_t); diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c index 4f5548e91ff56..68ae2d9de065a 100644 --- a/sys/dev/sound/isa/mss.c +++ b/sys/dev/sound/isa/mss.c @@ -96,9 +96,7 @@ static driver_intr_t mss_intr; /* prototypes for local functions */ static int mss_detect(device_t dev, struct mss_info *mss); -#ifndef PC98 static int opti_detect(device_t dev, struct mss_info *mss); -#endif static char *ymf_test(device_t dev, struct mss_info *mss); static void ad_unmute(struct mss_info *mss); @@ -117,9 +115,7 @@ static void ad_leave_MCE(struct mss_info *mss); /* OPTi-specific functions */ static void opti_write(struct mss_info *mss, u_char reg, u_char data); -#ifndef PC98 static u_char opti_read(struct mss_info *mss, u_char reg); -#endif static int opti_init(device_t dev, struct mss_info *mss); /* io primitives */ @@ -1330,11 +1326,7 @@ mss_probe(device_t dev) rman_get_start(mss->io_base), tmpx)); goto no; } -#ifdef PC98 - if (irq > 12) { -#else if (irq > 11) { -#endif printf("MSS: Bad IRQ %d\n", irq); goto no; } @@ -1381,7 +1373,6 @@ mss_detect(device_t dev, struct mss_info *mss) name = "AD1848"; mss->bd_id = MD_AD1848; /* AD1848 or CS4248 */ -#ifndef PC98 if (opti_detect(dev, mss)) { switch (mss->bd_id) { case MD_OPTI924: @@ -1394,7 +1385,6 @@ mss_detect(device_t dev, struct mss_info *mss) printf("Found OPTi device %s\n", name); if (opti_init(dev, mss) == 0) goto gotit; } -#endif /* * Check that the I/O address is in use. @@ -1601,7 +1591,6 @@ no: return ENXIO; } -#ifndef PC98 static int opti_detect(device_t dev, struct mss_info *mss) { @@ -1647,7 +1636,6 @@ opti_detect(device_t dev, struct mss_info *mss) } return 0; } -#endif static char * ymf_test(device_t dev, struct mss_info *mss) @@ -1682,10 +1670,6 @@ ymf_test(device_t dev, struct mss_info *mss) if (!j) { bus_release_resource(dev, SYS_RES_IOPORT, mss->conf_rid, mss->conf_base); -#ifdef PC98 - /* PC98 need this. I don't know reason why. */ - bus_delete_resource(dev, SYS_RES_IOPORT, mss->conf_rid); -#endif mss->conf_base = NULL; continue; } @@ -1709,23 +1693,16 @@ mss_doattach(device_t dev, struct mss_info *mss) rdma = rman_get_start(mss->drq2); if (flags & DV_F_TRUE_MSS) { /* has IRQ/DMA registers, set IRQ and DMA addr */ -#ifdef PC98 /* CS423[12] in PC98 can use IRQ3,5,10,12 */ - static char interrupt_bits[13] = - {-1, -1, -1, 0x08, -1, 0x10, -1, -1, -1, -1, 0x18, -1, 0x20}; -#else static char interrupt_bits[12] = {-1, -1, -1, -1, -1, 0x28, -1, 0x08, -1, 0x10, 0x18, 0x20}; -#endif static char pdma_bits[4] = {1, 2, -1, 3}; static char valid_rdma[4] = {1, 0, -1, 0}; char bits; if (!mss->irq || (bits = interrupt_bits[rman_get_start(mss->irq)]) == -1) goto no; -#ifndef PC98 /* CS423[12] in PC98 don't support this. */ io_wr(mss, 0, bits | 0x40); /* config port */ if ((io_rd(mss, 3) & 0x40) == 0) device_printf(dev, "IRQ Conflict?\n"); -#endif /* Write IRQ+DMA setup */ if (pdma_bits[pdma] == -1) goto no; bits |= pdma_bits[pdma]; @@ -2184,7 +2161,6 @@ opti_write(struct mss_info *mss, u_char reg, u_char val) } } -#ifndef PC98 u_char opti_read(struct mss_info *mss, u_char reg) { @@ -2208,7 +2184,6 @@ opti_read(struct mss_info *mss, u_char reg) } return -1; } -#endif static device_method_t pnpmss_methods[] = { /* Device interface */ diff --git a/sys/dev/sound/isa/mss.h b/sys/dev/sound/isa/mss.h index aaa28c0e8f8ae..1b4147de9a903 100644 --- a/sys/dev/sound/isa/mss.h +++ b/sys/dev/sound/isa/mss.h @@ -215,20 +215,12 @@ mixer_ent mix_devices[32][2] = { MIX_NONE(SOUND_MIXER_VOLUME), MIX_NONE(SOUND_MIXER_BASS), MIX_NONE(SOUND_MIXER_TREBLE), -#ifdef PC98 /* PC98's synth is assigned to AUX#2 */ -MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5), -#else /* AT386's synth is assigned to AUX#1 */ MIX_ENT(SOUND_MIXER_SYNTH, 2, 1, 0, 5, 3, 1, 0, 5), -#endif MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6), MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0), MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5), MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1), -#ifdef PC98 /* PC98's cd-audio is assigned to AUX#1 */ -MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5), -#else /* AT386's cd-audio is assigned to AUX#2 */ MIX_ENT(SOUND_MIXER_CD, 4, 1, 0, 5, 5, 1, 0, 5), -#endif MIX_ENT(SOUND_MIXER_IMIX, 13, 1, 2, 6, 0, 0, 0, 0), MIX_NONE(SOUND_MIXER_ALTPCM), MIX_NONE(SOUND_MIXER_RECLEV), diff --git a/sys/dev/sound/isa/sbc.c b/sys/dev/sound/isa/sbc.c index 6a8e1d34f144f..25fcd15c7d1d8 100644 --- a/sys/dev/sound/isa/sbc.c +++ b/sys/dev/sound/isa/sbc.c @@ -98,20 +98,6 @@ static devclass_t sbc_devclass; static int io_range[3] = {0x10, 0x2, 0x4}; -#ifdef PC98 /* I/O address table for PC98 */ -static bus_addr_t pcm_iat[] = { - 0x000, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700, - 0x800, 0x900, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00, 0xf00 -}; -static bus_addr_t midi_iat[] = { - 0x000, 0x100 -}; -static bus_addr_t opl_iat[] = { - 0x000, 0x100, 0x200, 0x300 -}; -static bus_addr_t *sb_iat[] = { pcm_iat, midi_iat, opl_iat }; -#endif - static int sb_rd(struct resource *io, int reg); static void sb_wr(struct resource *io, int reg, u_int8_t val); static int sb_dspready(struct resource *io); @@ -297,17 +283,9 @@ sbc_probe(device_t dev) int rid = 0, ver; struct resource *io; -#ifdef PC98 - io = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, - pcm_iat, 16, RF_ACTIVE); -#else io = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT, &rid, 16, RF_ACTIVE); -#endif if (!io) goto bad; -#ifdef PC98 - isa_load_resourcev(io, pcm_iat, 16); -#endif if (sb_reset_dsp(io)) goto bad2; ver = sb_identify_board(io); if (ver == 0) goto bad2; @@ -399,20 +377,6 @@ sbc_attach(device_t dev) /* soft irq/dma configuration */ x = -1; irq = rman_get_start(scp->irq[0]); -#ifdef PC98 - /* SB16 in PC98 use different IRQ table */ - if (irq == 3) x = 1; - else if (irq == 5) x = 8; - else if (irq == 10) x = 2; - else if (irq == 12) x = 4; - if (x == -1) { - err = "bad irq (3/5/10/12 valid)"; - goto bad; - } - else sb_setmixer(scp->io[0], IRQ_NR, x); - /* SB16 in PC98 use different dma setting */ - sb_setmixer(scp->io[0], DMA_NR, dh == 0 ? 1 : 2); -#else if (irq == 5) x = 2; else if (irq == 7) x = 4; else if (irq == 9) x = 1; @@ -423,7 +387,6 @@ sbc_attach(device_t dev) } else sb_setmixer(scp->io[0], IRQ_NR, x); sb_setmixer(scp->io[0], DMA_NR, (1 << dh) | (1 << dl)); -#endif if (bootverbose) { device_printf(dev, "setting card to irq %d, drq %d", irq, dl); if (dl != dh) printf(", %d", dh); @@ -578,22 +541,13 @@ sbc_alloc_resource(device_t bus, device_t child, int type, int *rid, struct sbc_softc *scp; int *alloced, rid_max, alloced_max; struct resource **res; -#ifdef PC98 - int i; -#endif scp = device_get_softc(bus); switch (type) { case SYS_RES_IOPORT: alloced = scp->io_alloced; res = scp->io; -#ifdef PC98 - rid_max = 0; - for (i = 0; i < IO_MAX; i++) - rid_max += io_range[i]; -#else rid_max = IO_MAX - 1; -#endif alloced_max = 1; break; case SYS_RES_DRQ: @@ -694,26 +648,12 @@ alloc_resource(struct sbc_softc *scp) for (i = 0 ; i < IO_MAX ; i++) { if (scp->io[i] == NULL) { -#ifdef PC98 - scp->io_rid[i] = i > 0 ? - scp->io_rid[i - 1] + io_range[i - 1] : 0; - scp->io[i] = isa_alloc_resourcev(scp->dev, - SYS_RES_IOPORT, - &scp->io_rid[i], - sb_iat[i], - io_range[i], - RF_ACTIVE); - if (scp->io[i] != NULL) - isa_load_resourcev(scp->io[i], sb_iat[i], - io_range[i]); -#else scp->io_rid[i] = i; scp->io[i] = bus_alloc_resource_anywhere(scp->dev, SYS_RES_IOPORT, &scp->io_rid[i], io_range[i], RF_ACTIVE); -#endif if (i == 0 && scp->io[i] == NULL) return (1); scp->io_alloced[i] = 0; diff --git a/sys/dev/syscons/daemon/daemon_saver.c b/sys/dev/syscons/daemon/daemon_saver.c index 1a92ff9afef14..5b30a398e7bc4 100644 --- a/sys/dev/syscons/daemon/daemon_saver.c +++ b/sys/dev/syscons/daemon/daemon_saver.c @@ -371,15 +371,7 @@ daemon_init(video_adapter_t *adp) sprintf(message, "%s - %s %s", prison0.pr_hostname, ostype, osrelease); mtx_unlock(&prison0.pr_mtx); blanked = 0; - switch (adp->va_mode) { - case M_PC98_80x25: - case M_PC98_80x30: - attr_mask = ~FG_UNDERLINE; - break; - default: - attr_mask = ~0; - break; - } + attr_mask = ~0; return 0; } diff --git a/sys/dev/syscons/dragon/dragon_saver.c b/sys/dev/syscons/dragon/dragon_saver.c index 6294daa77615f..df29d8277f03e 100644 --- a/sys/dev/syscons/dragon/dragon_saver.c +++ b/sys/dev/syscons/dragon/dragon_saver.c @@ -47,17 +47,10 @@ static u_char *vid; static int blanked; -#ifdef PC98 -#define VIDEO_MODE M_PC98_EGC640x400 -#define VIDEO_MODE_NAME "M_PC98_EGC640x400" -#define SCRW 640 -#define SCRH 400 -#else #define VIDEO_MODE M_VGA_CG320 #define VIDEO_MODE_NAME "M_VGA_CG320" #define SCRW 320 #define SCRH 200 -#endif #define ORDER 13 #define CURVE 3 #define OUT 100 @@ -72,11 +65,7 @@ gpset(int x, int y, int val) if (x < 0 || y < 0 || SCRW <= x || SCRH <= y) { return 0; } -#ifdef PC98 - vid[(x + y * SCRW) >> 3] = (0x80 >> (x & 7)); /* write new dot */ -#else vid[x + y * SCRW] = val; -#endif return 1; } @@ -86,11 +75,6 @@ gdraw(int dx, int dy, int val) int i; int set = 0; -#ifdef PC98 - outb(0x7c, 0xcc); /* GRCG on & RMW mode(disable planeI,G) */ - outb(0x7e, (val & 1) ? 0xff: 0); /* tile B */ - outb(0x7e, (val & 2) ? 0xff: 0); /* tile R */ -#endif if (dx != 0) { i = cur_x; cur_x += dx; @@ -115,9 +99,6 @@ gdraw(int dx, int dy, int val) set |= gpset(cur_x, i, val); } } -#ifdef PC98 - outb(0x7c, 0); /* GRCG off */ -#endif return set; } diff --git a/sys/dev/syscons/fire/fire_saver.c b/sys/dev/syscons/fire/fire_saver.c index 4c995efcd6404..4b0a0e00a6045 100644 --- a/sys/dev/syscons/fire/fire_saver.c +++ b/sys/dev/syscons/fire/fire_saver.c @@ -143,10 +143,6 @@ fire_init(video_adapter_t *adp) if (!vidd_get_info(adp, M_VGA_CG320, &info)) { scrmode = M_VGA_CG320; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) { - scrmode = M_PC98_PEGC640x480; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) { - scrmode = M_PC98_PEGC640x400; } else { log(LOG_NOTICE, "%s: the console does not support M_VGA_CG320\n", diff --git a/sys/dev/syscons/logo/logo_saver.c b/sys/dev/syscons/logo/logo_saver.c index 5828d7e44bd61..071261ead62de 100644 --- a/sys/dev/syscons/logo/logo_saver.c +++ b/sys/dev/syscons/logo/logo_saver.c @@ -140,10 +140,6 @@ logo_init(video_adapter_t *adp) scrmode = M_VESA_CG800x600; } else if (!vidd_get_info(adp, M_VGA_CG320, &info)) { scrmode = M_VGA_CG320; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) { - scrmode = M_PC98_PEGC640x480; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) { - scrmode = M_PC98_PEGC640x400; } else { log(LOG_NOTICE, "%s: the console does not support M_VGA_CG320\n", diff --git a/sys/dev/syscons/plasma/plasma_saver.c b/sys/dev/syscons/plasma/plasma_saver.c index 761aa5cc57529..376c639231e0c 100644 --- a/sys/dev/syscons/plasma/plasma_saver.c +++ b/sys/dev/syscons/plasma/plasma_saver.c @@ -49,8 +49,6 @@ */ static int modes[] = { M_VGA_CG640, - M_PC98_PEGC640x480, - M_PC98_PEGC640x400, M_VGA_CG320, -1 }; diff --git a/sys/dev/syscons/rain/rain_saver.c b/sys/dev/syscons/rain/rain_saver.c index ff2892416b971..1ddbdc748451d 100644 --- a/sys/dev/syscons/rain/rain_saver.c +++ b/sys/dev/syscons/rain/rain_saver.c @@ -143,10 +143,6 @@ rain_init(video_adapter_t *adp) if (!vidd_get_info(adp, M_VGA_CG320, &info)) { scrmode = M_VGA_CG320; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) { - scrmode = M_PC98_PEGC640x480; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) { - scrmode = M_PC98_PEGC640x400; } else { log(LOG_NOTICE, "%s: the console does not support M_VGA_CG320\n", diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c index db26787c264ee..f96c157cb4b50 100644 --- a/sys/dev/syscons/scmouse.c +++ b/sys/dev/syscons/scmouse.c @@ -249,7 +249,6 @@ sc_remove_mouse_image(scr_stat *scp) i = scp->mouse_oldpos; mark_for_update(scp, i); mark_for_update(scp, i); -#ifndef PC98 if (i + scp->xsize + 1 < size) { mark_for_update(scp, i + scp->xsize + 1); } else if (i + scp->xsize < size) { @@ -257,7 +256,6 @@ sc_remove_mouse_image(scr_stat *scp) } else if (i + 1 < size) { mark_for_update(scp, i + 1); } -#endif /* PC98 */ scp->status &= ~MOUSE_VISIBLE; SC_VIDEO_UNLOCK(scp->sc); } diff --git a/sys/dev/syscons/scvidctl.c b/sys/dev/syscons/scvidctl.c index 6ae923dfe291e..0176147dcd513 100644 --- a/sys/dev/syscons/scvidctl.c +++ b/sys/dev/syscons/scvidctl.c @@ -655,12 +655,6 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) case SW_ENH_B80x25: case SW_ENH_C80x25: case SW_ENH_B80x43: case SW_ENH_C80x43: case SW_EGAMONO80x25: - -#ifdef PC98 - /* PC98 TEXT MODES */ - case SW_PC98_80x25: - case SW_PC98_80x30: -#endif if (!(adp->va_flags & V_ADP_MODECHANGE)) return ENODEV; return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0, 0); @@ -671,11 +665,6 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) case SW_CG640x350: case SW_ENH_CG640: case SW_BG640x480: case SW_CG640x480: case SW_VGA_CG320: case SW_VGA_MODEX: -#ifdef PC98 - /* PC98 GRAPHICS MODES */ - case SW_PC98_EGC640x400: case SW_PC98_PEGC640x400: - case SW_PC98_PEGC640x480: -#endif if (!(adp->va_flags & V_ADP_MODECHANGE)) return ENODEV; return sc_set_graphics_mode(scp, tp, cmd & 0xff); @@ -725,10 +714,8 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) vidd_load_palette(adp, scp->sc->palette); #endif -#ifndef PC98 /* move hardware cursor out of the way */ vidd_set_hw_cursor(adp, -1, -1); -#endif /* FALLTHROUGH */ @@ -744,7 +731,6 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) splx(s); return error; } -#ifndef PC98 scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN; splx(s); /* no restore fonts & palette */ @@ -752,14 +738,6 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) set_mode(scp); sc_clear_screen(scp); scp->status &= ~UNKNOWN_MODE; -#else /* PC98 */ - scp->status &= ~UNKNOWN_MODE; - /* no restore fonts & palette */ - if (scp == scp->sc->cur_scp) - set_mode(scp); - sc_clear_screen(scp); - splx(s); -#endif /* PC98 */ return 0; #ifdef SC_PIXEL_MODE @@ -798,10 +776,6 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td) } scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN; splx(s); -#ifdef PC98 - if (scp == scp->sc->cur_scp) - set_mode(scp); -#endif return 0; default: diff --git a/sys/dev/syscons/star/star_saver.c b/sys/dev/syscons/star/star_saver.c index 56bfc011eb508..e8e60415eed3d 100644 --- a/sys/dev/syscons/star/star_saver.c +++ b/sys/dev/syscons/star/star_saver.c @@ -58,9 +58,6 @@ star_saver(video_adapter_t *adp, int blank) static u_char pattern[] = {"...........++++*** "}; static char color16[] = {FG_DARKGREY, FG_LIGHTGREY, FG_WHITE, FG_LIGHTCYAN}; - static char color8[] = {FG_BLUE, FG_BROWN, - FG_LIGHTGREY, FG_CYAN}; - static char *colors; static u_short stars[NUM_STARS][2]; sc = sc_find_softc(adp, NULL); @@ -72,16 +69,6 @@ star_saver(video_adapter_t *adp, int blank) if (adp->va_info.vi_flags & V_INFO_GRAPHICS) return EAGAIN; if (!blanked) { - switch (adp->va_mode) { - case M_PC98_80x25: - case M_PC98_80x30: - colors = color8; - break; - default: - colors = color16; - break; - } - /* clear the screen and set the border color */ sc_vtb_clear(&scp->scr, sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8); @@ -97,7 +84,7 @@ star_saver(video_adapter_t *adp, int blank) cell = random() % NUM_STARS; sc_vtb_putc(&scp->scr, stars[cell][0], sc->scr_map[pattern[stars[cell][1]]], - colors[random()%sizeof(color16)] << 8); + color16[random()%sizeof(color16)] << 8); if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) { stars[cell][0] = random() % (scp->xsize*scp->ysize); stars[cell][1] = 0; diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 30c7a1a1327d0..5bbfebc52f20e 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -316,7 +316,6 @@ static char { KD_CGA, { "CGA", "CGA" } }, { KD_EGA, { "EGA", "EGA (mono)" } }, { KD_VGA, { "VGA", "VGA (mono)" } }, - { KD_PC98, { "PC-98x1", "PC-98x1" } }, { KD_TGA, { "TGA", "TGA" } }, { -1, { "Unknown", "Unknown" } }, }; @@ -2012,9 +2011,7 @@ sccnupdate(scr_stat *scp) static void scrn_timer(void *arg) { -#ifndef PC98 static time_t kbd_time_stamp = 0; -#endif sc_softc_t *sc; scr_stat *scp; int again, rate; @@ -2034,7 +2031,6 @@ scrn_timer(void *arg) if (suspend_in_progress || sc->font_loading_in_progress) goto done; -#ifndef PC98 if ((sc->kbd == NULL) && (sc->config & SC_AUTODETECT_KBD)) { /* try to allocate a keyboard automatically */ if (kbd_time_stamp != time_uptime) { @@ -2049,7 +2045,6 @@ scrn_timer(void *arg) } } } -#endif /* PC98 */ /* should we stop the screen saver? */ if (kdb_active || panicstr || shutdown_in_progress) @@ -2809,11 +2804,7 @@ exchange_scr(sc_softc_t *sc) /* set up the video for the new screen */ scp = sc->cur_scp = sc->new_scp; -#ifdef PC98 - if (sc->old_scp->mode != scp->mode || ISUNKNOWNSC(sc->old_scp) || ISUNKNOWNSC(sc->new_scp)) -#else if (sc->old_scp->mode != scp->mode || ISUNKNOWNSC(sc->old_scp)) -#endif set_mode(scp); #ifndef __sparc64__ else @@ -2988,11 +2979,7 @@ scinit(int unit, int flags) * static buffers for the console. This is less than ideal, * but is necessry evil for the time being. XXX */ -#ifdef PC98 - static u_short sc_buffer[ROW*COL*2];/* XXX */ -#else static u_short sc_buffer[ROW*COL]; /* XXX */ -#endif #ifndef SC_NO_FONT_LOADING static u_char font_8[256*8]; static u_char font_14[256*14]; @@ -3193,9 +3180,6 @@ scinit(int unit, int flags) /* initialize mapscrn arrays to a one to one map */ for (i = 0; i < sizeof(sc->scr_map); i++) sc->scr_map[i] = sc->scr_rmap[i] = i; -#ifdef PC98 - sc->scr_map[0x5c] = (u_char)0xfc; /* for backslash */ -#endif sc->flags |= SC_INIT_DONE; } diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h index 3454700c94750..24d386afc16bc 100644 --- a/sys/dev/syscons/syscons.h +++ b/sys/dev/syscons/syscons.h @@ -38,14 +38,6 @@ #include <sys/_lock.h> #include <sys/_mutex.h> -/* machine-dependent part of the header */ - -#ifdef PC98 -#include <pc98/cbus/sc_machdep.h> -#elif defined(__i386__) -/* nothing for the moment */ -#endif - /* default values for configuration options */ #ifndef MAXCONS diff --git a/sys/dev/syscons/warp/warp_saver.c b/sys/dev/syscons/warp/warp_saver.c index a800118774aa9..93383ddaebc9d 100644 --- a/sys/dev/syscons/warp/warp_saver.c +++ b/sys/dev/syscons/warp/warp_saver.c @@ -129,10 +129,6 @@ warp_init(video_adapter_t *adp) if (!vidd_get_info(adp, M_VGA_CG320, &info)) { scrmode = M_VGA_CG320; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x480, &info)) { - scrmode = M_PC98_PEGC640x480; - } else if (!vidd_get_info(adp, M_PC98_PEGC640x400, &info)) { - scrmode = M_PC98_PEGC640x400; } else { log(LOG_NOTICE, "%s: the console does not support M_VGA_CG320\n", diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h index c40846b758de0..987f4a0d1bdfb 100644 --- a/sys/dev/uart/uart.h +++ b/sys/dev/uart/uart.h @@ -71,10 +71,6 @@ extern struct uart_class uart_sab82532_class __attribute__((weak)); extern struct uart_class uart_sbbc_class __attribute__((weak)); extern struct uart_class uart_z8530_class __attribute__((weak)); -#ifdef PC98 -struct uart_class *uart_pc98_getdev(u_long port); -#endif - /* * Device flags. */ diff --git a/sys/dev/uart/uart_bus_isa.c b/sys/dev/uart/uart_bus_isa.c index 1fda15f2be022..e22bc78a4b9dd 100644 --- a/sys/dev/uart/uart_bus_isa.c +++ b/sys/dev/uart/uart_bus_isa.c @@ -146,18 +146,6 @@ static struct isa_pnp_id isa_ns8250_ids[] = { {0x0300695c, NULL}, /* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */ {0x01a0896a, NULL}, /* ZTIA001 - Zoom Internal V90 Faxmodem */ {0x61f7896a, NULL}, /* ZTIF761 - Zoom ComStar 33.6 */ - /* The following are found in PC98 hardware. */ - {0x4180a3b8, NULL}, /* NEC8041 - PC-9821CB-B04 */ - {0x0181a3b8, NULL}, /* NEC8101 - PC-9821CB2-B04 */ - {0x5181a3b8, NULL}, /* NEC8151 - Internal FAX/Modem for Cx3, Cb3 */ - {0x9181a3b8, NULL}, /* NEC8191 - PC-9801-120 */ - {0xe181a3b8, NULL}, /* NEC81E1 - Internal FAX/Modem */ - {0x1182a3b8, NULL}, /* NEC8211 - PC-9801-123 */ - {0x3182a3b8, NULL}, /* NEC8231 - Internal FAX/Modem (Voice) */ - {0x4182a3b8, NULL}, /* NEC8241 - PC-9821NR-B05 */ - {0x5182a3b8, NULL}, /* NEC8251 - Internel FAX/Modem */ - {0x7182a3b8, NULL}, /* NEC8271 - PC-9801-125 */ - {0x11802fbf, NULL}, /* OYO8011 - Internal FAX/Modem (Ring) */ {0} }; @@ -175,15 +163,8 @@ uart_isa_probe(device_t dev) return (ENXIO); /* Probe PnP _and_ non-PnP ns8250 here. */ -#ifdef PC98 - if (isa_get_logicalid(dev)) - sc->sc_class = &uart_ns8250_class; - else - sc->sc_class = uart_pc98_getdev(bus_get_resource_start(dev, - SYS_RES_IOPORT, 0)); -#else sc->sc_class = &uart_ns8250_class; -#endif + return (uart_bus_probe(dev, 0, 0, 0, 0)); } diff --git a/sys/dev/uart/uart_cpu_pc98.c b/sys/dev/uart/uart_cpu_pc98.c deleted file mode 100644 index c211b3dbe95d5..0000000000000 --- a/sys/dev/uart/uart_cpu_pc98.c +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 2008 TAKAHASHI Yoshihiro - * Copyright (c) 2003 M. Warner Losh, Marcel Moolenaar - * 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. - * - * 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/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/bus.h> - -#include <machine/bus.h> - -#include <dev/uart/uart.h> -#include <dev/uart/uart_cpu.h> - -bus_space_tag_t uart_bus_space_io = X86_BUS_SPACE_IO; -bus_space_tag_t uart_bus_space_mem = X86_BUS_SPACE_MEM; - -static struct { - u_long iobase; - struct uart_class *class; -} uart_pc98_devs[] = { - { 0x238, &uart_ns8250_class }, - { 0, NULL } -}; - -struct uart_class * -uart_pc98_getdev(u_long port) -{ - int i; - - for (i = 0; uart_pc98_devs[i].iobase; i++) { - if (port == uart_pc98_devs[i].iobase) - return (uart_pc98_devs[i].class); - } - return (NULL); -} - -int -uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) -{ - - if (bus_space_compare(b1->bst, b1->bsh, b2->bst, b2->bsh) == 0) - return (1); - - return (0); -} - -int -uart_cpu_getdev(int devtype, struct uart_devinfo *di) -{ - struct uart_class *class; - unsigned int i, ivar; - - class = &uart_ns8250_class; - if (class == NULL) - return (ENXIO); - - /* Check the environment. */ - if (uart_getenv(devtype, di, class) == 0) - return (0); - - /* - * There is a serial port on all pc98 hardware. It is 8251 or - * an enhance version of that. Some pc98 have the second serial - * port which is 16550A compatible. - */ - for (i = 0; i < 2; i++) { - if (resource_int_value("uart", i, "flags", &ivar)) - continue; - if (devtype == UART_DEV_CONSOLE && !UART_FLAGS_CONSOLE(ivar)) - continue; - if (devtype == UART_DEV_DBGPORT && !UART_FLAGS_DBGPORT(ivar)) - continue; - /* - * We have a possible device. Make sure it's enabled and - * that we have an I/O port. - */ - if (resource_int_value("uart", i, "disabled", &ivar) == 0 && - ivar != 0) - continue; - if (resource_int_value("uart", i, "port", &ivar) != 0 || - ivar == 0) - continue; - - class = uart_pc98_getdev(ivar); - if (class == NULL) - continue; - - di->ops = uart_getops(class); - di->bas.chan = 0; - di->bas.bst = uart_bus_space_io; - if (bus_space_map(di->bas.bst, ivar, uart_getrange(class), 0, - &di->bas.bsh) != 0) - continue; - di->bas.regshft = 0; - di->bas.rclk = 0; - if (resource_int_value("uart", i, "baud", &ivar) != 0) - ivar = 0; - di->baudrate = ivar; - di->databits = 8; - di->stopbits = 1; - di->parity = UART_PARITY_NONE; - return (0); - } - - return (ENXIO); -} |
