Remove the old, and now deprecated lnc driver. The Lance style hardware
is supported by the le and pnc drivers. Reviewed by: jmg
This commit is contained in:
parent
3f0c418ad9
commit
db49408b2b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=158545
1560
sys/dev/lnc/if_lnc.c
1560
sys/dev/lnc/if_lnc.c
File diff suppressed because it is too large
Load Diff
@ -1,307 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <machine/clock.h> /* DELAY() */
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
||||
#include <isa/isavar.h>
|
||||
|
||||
#include <dev/lnc/if_lncvar.h>
|
||||
#include <dev/lnc/if_lncreg.h>
|
||||
|
||||
static struct isa_pnp_id lnc_pnp_ids[] = {
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static bus_addr_t lnc_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 int
|
||||
lnc_legacy_probe(device_t dev)
|
||||
{
|
||||
struct lnc_softc *sc = device_get_softc(dev);
|
||||
u_int16_t tmp;
|
||||
|
||||
sc->portrid = 0;
|
||||
sc->portres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &sc->portrid,
|
||||
lnc_ioaddr_cnet98s, CNET98S_IOSIZE,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->portres) {
|
||||
device_printf(dev, "Failed to allocate I/O ports\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
isa_load_resourcev(sc->portres, lnc_ioaddr_cnet98s, CNET98S_IOSIZE);
|
||||
|
||||
sc->lnc_btag = rman_get_bustag(sc->portres);
|
||||
sc->lnc_bhandle = rman_get_bushandle(sc->portres);
|
||||
|
||||
/* Reset */
|
||||
tmp = lnc_inw(CNET98S_RESET);
|
||||
lnc_outw(CNET98S_RESET, tmp);
|
||||
DELAY(500);
|
||||
|
||||
sc->rap = CNET98S_RAP;
|
||||
sc->rdp = CNET98S_RDP;
|
||||
sc->nic.mem_mode = DMA_FIXED;
|
||||
|
||||
if ((sc->nic.ic = lance_probe(sc))) {
|
||||
sc->nic.ident = CNET98S;
|
||||
device_set_desc(dev, "C-NET(98)S");
|
||||
lnc_release_resources(dev);
|
||||
return (0);
|
||||
} else {
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
lnc_isa_probe(device_t dev)
|
||||
{
|
||||
int pnp;
|
||||
|
||||
pnp = ISA_PNP_PROBE(device_get_parent(dev), dev, lnc_pnp_ids);
|
||||
if (pnp == ENOENT) {
|
||||
/* It's not a PNP card, see if we support it by probing it */
|
||||
return (lnc_legacy_probe(dev));
|
||||
} else if (pnp == ENXIO) {
|
||||
return (ENXIO);
|
||||
} else {
|
||||
/* Found PNP card we support */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
lnc_alloc_callback(void *arg, bus_dma_segment_t *seg, int nseg, int error)
|
||||
{
|
||||
/* Do nothing */
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
lnc_isa_attach(device_t dev)
|
||||
{
|
||||
lnc_softc_t *sc = device_get_softc(dev);
|
||||
int err = 0;
|
||||
bus_size_t lnc_mem_size;
|
||||
|
||||
device_printf(dev, "Attaching %s\n", device_get_desc(dev));
|
||||
|
||||
sc->portrid = 0;
|
||||
sc->portres = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &sc->portrid,
|
||||
lnc_ioaddr_cnet98s, CNET98S_IOSIZE,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->portres) {
|
||||
device_printf(dev, "Failed to allocate I/O ports\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
isa_load_resourcev(sc->portres, lnc_ioaddr_cnet98s, CNET98S_IOSIZE);
|
||||
|
||||
sc->lnc_btag = rman_get_bustag(sc->portres);
|
||||
sc->lnc_bhandle = rman_get_bushandle(sc->portres);
|
||||
|
||||
sc->drqrid = 0;
|
||||
sc->drqres = NULL;
|
||||
|
||||
if (isa_get_irq(dev) == -1)
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0, 6, 1);
|
||||
|
||||
sc->irqrid = 0;
|
||||
sc->irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqrid,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->irqres) {
|
||||
device_printf(dev, "Failed to allocate irq\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
err = bus_setup_intr(dev, sc->irqres, INTR_TYPE_NET, lncintr,
|
||||
sc, &sc->intrhand);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Failed to setup irq handler\n");
|
||||
lnc_release_resources(dev);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* XXX temp setting for nic */
|
||||
sc->nic.mem_mode = DMA_FIXED;
|
||||
sc->nrdre = NRDRE;
|
||||
sc->ntdre = NTDRE;
|
||||
|
||||
if (sc->nic.ident == CNET98S) {
|
||||
sc->rap = CNET98S_RAP;
|
||||
sc->rdp = CNET98S_RDP;
|
||||
} else if (sc->nic.ident == NE2100) {
|
||||
sc->rap = PCNET_RAP;
|
||||
sc->rdp = PCNET_RDP;
|
||||
sc->bdp = PCNET_BDP;
|
||||
} else {
|
||||
sc->rap = BICC_RAP;
|
||||
sc->rdp = BICC_RDP;
|
||||
}
|
||||
|
||||
/* Create a DMA tag describing the ring memory we need */
|
||||
|
||||
lnc_mem_size = ((NDESC(sc->nrdre) + NDESC(sc->ntdre)) *
|
||||
sizeof(struct host_ring_entry));
|
||||
|
||||
lnc_mem_size += (NDESC(sc->nrdre) * RECVBUFSIZE) +
|
||||
(NDESC(sc->ntdre) * TRANSBUFSIZE);
|
||||
|
||||
err = bus_dma_tag_create(NULL, /* parent */
|
||||
4, /* alignement */
|
||||
0, /* boundary */
|
||||
BUS_SPACE_MAXADDR_24BIT, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
lnc_mem_size, /* segsize */
|
||||
1, /* nsegments */
|
||||
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
|
||||
0, /* flags */
|
||||
busdma_lock_mutex, /* lockfunc */
|
||||
&Giant, /* lockarg */
|
||||
&sc->dmat);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Can't create DMA tag\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
err = bus_dmamem_alloc(sc->dmat, (void **)&sc->recv_ring,
|
||||
BUS_DMA_NOWAIT, &sc->dmamap);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Couldn't allocate memory\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
err = bus_dmamap_load(sc->dmat, sc->dmamap, sc->recv_ring, lnc_mem_size,
|
||||
lnc_alloc_callback, sc->recv_ring, BUS_DMA_NOWAIT);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Couldn't load DMA map\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
/* Call generic attach code */
|
||||
if (! lnc_attach_common(dev)) {
|
||||
device_printf(dev, "Generic attach code failed\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* ISA Configuration
|
||||
*
|
||||
* XXX - Following parameters are Contec C-NET(98)S only.
|
||||
* So, check the Ethernet address here.
|
||||
*
|
||||
* Contec uses 00 80 4c ?? ?? ??
|
||||
*/
|
||||
if (IF_LLADDR(sc->ifp)[0] == (char)0x00 &&
|
||||
IF_LLADDR(sc->ifp)[1] == (char)0x80 &&
|
||||
IF_LLADDR(sc->ifp)[2] == (char)0x4c) {
|
||||
lnc_outw(sc->rap, MSRDA);
|
||||
lnc_outw(CNET98S_IDP, 0x0006);
|
||||
lnc_outw(sc->rap, MSWRA);
|
||||
lnc_outw(CNET98S_IDP, 0x0006);
|
||||
#ifdef DIAGNOSTIC
|
||||
lnc_outw(sc->rap, MC);
|
||||
printf("ISACSR2 = %x\n", lnc_inw(CNET98S_IDP));
|
||||
#endif
|
||||
lnc_outw(sc->rap, LED1);
|
||||
lnc_outw(CNET98S_IDP, LED_PSE | LED_XMTE);
|
||||
lnc_outw(sc->rap, LED2);
|
||||
lnc_outw(CNET98S_IDP, LED_PSE | LED_RCVE);
|
||||
lnc_outw(sc->rap, LED3);
|
||||
lnc_outw(CNET98S_IDP, LED_PSE | LED_COLE);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t lnc_isa_methods[] = {
|
||||
/* DEVMETHOD(device_identify, lnc_isa_identify), */
|
||||
DEVMETHOD(device_probe, lnc_isa_probe),
|
||||
DEVMETHOD(device_attach, lnc_isa_attach),
|
||||
DEVMETHOD(device_detach, lnc_detach_common),
|
||||
#ifdef notyet
|
||||
DEVMETHOD(device_suspend, lnc_isa_suspend),
|
||||
DEVMETHOD(device_resume, lnc_isa_resume),
|
||||
DEVMETHOD(device_shutdown, lnc_isa_shutdown),
|
||||
#endif
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t lnc_isa_driver = {
|
||||
"lnc",
|
||||
lnc_isa_methods,
|
||||
sizeof(struct lnc_softc),
|
||||
};
|
||||
|
||||
DRIVER_MODULE(lnc, isa, lnc_isa_driver, lnc_devclass, 0, 0);
|
||||
MODULE_DEPEND(lnc, isa, 1, 1, 1);
|
||||
MODULE_DEPEND(lnc, ether, 1, 1, 1);
|
@ -1,278 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1994-2000
|
||||
* Paul Richards. 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,
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
|
||||
#include <isa/isavar.h>
|
||||
|
||||
#include <dev/lnc/if_lncvar.h>
|
||||
#include <dev/lnc/if_lncreg.h>
|
||||
|
||||
static struct isa_pnp_id lnc_pnp_ids[] = {
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static int
|
||||
lnc_legacy_probe(device_t dev)
|
||||
{
|
||||
struct lnc_softc *sc = device_get_softc(dev);
|
||||
|
||||
sc->portrid = 0;
|
||||
sc->portres = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->portrid,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->portres) {
|
||||
device_printf(dev, "Failed to allocate I/O ports\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
sc->lnc_btag = rman_get_bustag(sc->portres);
|
||||
sc->lnc_bhandle = rman_get_bushandle(sc->portres);
|
||||
|
||||
/*
|
||||
* There isn't any way to determine if a NIC is a BICC. Basically, if
|
||||
* the lance probe succeeds using the i/o addresses of the BICC then
|
||||
* we assume it's a BICC.
|
||||
*
|
||||
*/
|
||||
sc->rap = BICC_RAP;
|
||||
sc->rdp = BICC_RDP;
|
||||
sc->nic.mem_mode = DMA_FIXED;
|
||||
/* XXX Should set BICC_IOSIZE et al somewhere to alloc
|
||||
resources correctly */
|
||||
|
||||
if ((sc->nic.ic = lance_probe(sc))) {
|
||||
device_set_desc(dev, "BICC Isolan");
|
||||
sc->nic.ident = BICC;
|
||||
lnc_release_resources(dev);
|
||||
return (0);
|
||||
} else {
|
||||
/* It's not a BICC so try the standard NE2100 ports */
|
||||
sc->rap = PCNET_RAP;
|
||||
sc->rdp = PCNET_RDP;
|
||||
if ((sc->nic.ic = lance_probe(sc))) {
|
||||
sc->nic.ident = NE2100;
|
||||
device_set_desc(dev, "NE2100");
|
||||
lnc_release_resources(dev);
|
||||
return (0);
|
||||
} else {
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
lnc_isa_probe(device_t dev)
|
||||
{
|
||||
int pnp;
|
||||
|
||||
pnp = ISA_PNP_PROBE(device_get_parent(dev), dev, lnc_pnp_ids);
|
||||
if (pnp == ENOENT) {
|
||||
/* It's not a PNP card, see if we support it by probing it */
|
||||
return (lnc_legacy_probe(dev));
|
||||
} else if (pnp == ENXIO) {
|
||||
return (ENXIO);
|
||||
} else {
|
||||
/* Found PNP card we support */
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
lnc_alloc_callback(void *arg, bus_dma_segment_t *seg, int nseg, int error)
|
||||
{
|
||||
/* Do nothing */
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
lnc_isa_attach(device_t dev)
|
||||
{
|
||||
lnc_softc_t *sc = device_get_softc(dev);
|
||||
int err = 0;
|
||||
bus_size_t lnc_mem_size;
|
||||
|
||||
device_printf(dev, "Attaching %s\n", device_get_desc(dev));
|
||||
|
||||
sc->portrid = 0;
|
||||
sc->portres = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->portrid,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->portres) {
|
||||
device_printf(dev, "Failed to allocate I/O ports\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
sc->drqrid = 0;
|
||||
sc->drqres = bus_alloc_resource_any(dev, SYS_RES_DRQ, &sc->drqrid,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->drqres) {
|
||||
device_printf(dev, "Failed to allocate DMA channel\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
if (isa_get_irq(dev) == -1)
|
||||
bus_set_resource(dev, SYS_RES_IRQ, 0, 10, 1);
|
||||
|
||||
sc->irqrid = 0;
|
||||
sc->irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqrid,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->irqres) {
|
||||
device_printf(dev, "Failed to allocate irq\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
err = bus_setup_intr(dev, sc->irqres, INTR_TYPE_NET, lncintr,
|
||||
sc, &sc->intrhand);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Failed to setup irq handler\n");
|
||||
lnc_release_resources(dev);
|
||||
return (err);
|
||||
}
|
||||
|
||||
/* XXX temp setting for nic */
|
||||
sc->nic.mem_mode = DMA_FIXED;
|
||||
sc->nrdre = NRDRE;
|
||||
sc->ntdre = NTDRE;
|
||||
|
||||
if (sc->nic.ident == NE2100) {
|
||||
sc->rap = PCNET_RAP;
|
||||
sc->rdp = PCNET_RDP;
|
||||
sc->bdp = PCNET_BDP;
|
||||
} else {
|
||||
sc->rap = BICC_RAP;
|
||||
sc->rdp = BICC_RDP;
|
||||
}
|
||||
|
||||
/* Create a DMA tag describing the ring memory we need */
|
||||
|
||||
lnc_mem_size = ((NDESC(sc->nrdre) + NDESC(sc->ntdre)) *
|
||||
sizeof(struct host_ring_entry));
|
||||
|
||||
lnc_mem_size += (NDESC(sc->nrdre) * RECVBUFSIZE) +
|
||||
(NDESC(sc->ntdre) * TRANSBUFSIZE);
|
||||
|
||||
err = bus_dma_tag_create(NULL, /* parent */
|
||||
4, /* alignement */
|
||||
0, /* boundary */
|
||||
BUS_SPACE_MAXADDR_24BIT, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
lnc_mem_size, /* segsize */
|
||||
1, /* nsegments */
|
||||
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
|
||||
0, /* flags */
|
||||
busdma_lock_mutex, /* lockfunc */
|
||||
&Giant, /* lockarg */
|
||||
&sc->dmat);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Can't create DMA tag\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
err = bus_dmamem_alloc(sc->dmat, (void **)&sc->recv_ring,
|
||||
BUS_DMA_NOWAIT, &sc->dmamap);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Couldn't allocate memory\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
err = bus_dmamap_load(sc->dmat, sc->dmamap, sc->recv_ring, lnc_mem_size,
|
||||
lnc_alloc_callback, sc->recv_ring, BUS_DMA_NOWAIT);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Couldn't load DMA map\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
isa_dmacascade(rman_get_start(sc->drqres));
|
||||
|
||||
/* Call generic attach code */
|
||||
if (! lnc_attach_common(dev)) {
|
||||
device_printf(dev, "Generic attach code failed\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t lnc_isa_methods[] = {
|
||||
/* DEVMETHOD(device_identify, lnc_isa_identify), */
|
||||
DEVMETHOD(device_probe, lnc_isa_probe),
|
||||
DEVMETHOD(device_attach, lnc_isa_attach),
|
||||
DEVMETHOD(device_detach, lnc_detach_common),
|
||||
#ifdef notyet
|
||||
DEVMETHOD(device_suspend, lnc_isa_suspend),
|
||||
DEVMETHOD(device_resume, lnc_isa_resume),
|
||||
DEVMETHOD(device_shutdown, lnc_isa_shutdown),
|
||||
#endif
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t lnc_isa_driver = {
|
||||
"lnc",
|
||||
lnc_isa_methods,
|
||||
sizeof(struct lnc_softc),
|
||||
};
|
||||
|
||||
DRIVER_MODULE(lnc, isa, lnc_isa_driver, lnc_devclass, 0, 0);
|
||||
MODULE_DEPEND(lnc, isa, 1, 1, 1);
|
||||
MODULE_DEPEND(lnc, ether, 1, 1, 1);
|
@ -1,213 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1994-2000
|
||||
* Paul Richards. 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,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcivar.h>
|
||||
|
||||
#include <dev/lnc/if_lncreg.h>
|
||||
#include <dev/lnc/if_lncvar.h>
|
||||
|
||||
#define AMD_VENDOR_ID 0x1022
|
||||
#define PCI_DEVICE_ID_PCNet_PCI 0x2000
|
||||
#define PCI_DEVICE_ID_PCHome_PCI 0x2001
|
||||
|
||||
static int
|
||||
lnc_pci_probe(device_t dev)
|
||||
{
|
||||
if (pci_get_vendor(dev) != AMD_VENDOR_ID)
|
||||
return (ENXIO);
|
||||
|
||||
switch(pci_get_device(dev)) {
|
||||
case PCI_DEVICE_ID_PCNet_PCI:
|
||||
device_set_desc(dev, "PCNet/PCI Ethernet adapter");
|
||||
return(BUS_PROBE_DEFAULT);
|
||||
break;
|
||||
case PCI_DEVICE_ID_PCHome_PCI:
|
||||
device_set_desc(dev, "PCHome/PCI Ethernet adapter");
|
||||
return(BUS_PROBE_DEFAULT);
|
||||
break;
|
||||
default:
|
||||
return (ENXIO);
|
||||
break;
|
||||
}
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static void
|
||||
lnc_alloc_callback(void *arg, bus_dma_segment_t *seg, int nseg, int error)
|
||||
{
|
||||
/* Do nothing */
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
lnc_pci_attach(device_t dev)
|
||||
{
|
||||
lnc_softc_t *sc = device_get_softc(dev);
|
||||
unsigned command;
|
||||
int err = 0;
|
||||
bus_size_t lnc_mem_size;
|
||||
|
||||
device_printf(dev, "Attaching %s\n", device_get_desc(dev));
|
||||
|
||||
command = pci_read_config(dev, PCIR_COMMAND, 4);
|
||||
command |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
|
||||
pci_write_config(dev, PCIR_COMMAND, command, 4);
|
||||
|
||||
sc->portrid = PCIR_BAR(0);
|
||||
sc->portres = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->portrid,
|
||||
RF_ACTIVE);
|
||||
|
||||
if (! sc->portres) {
|
||||
device_printf(dev, "Cannot allocate I/O ports\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
sc->irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqrid,
|
||||
RF_ACTIVE|RF_SHAREABLE);
|
||||
|
||||
if (! sc->irqres) {
|
||||
device_printf(dev, "Cannot allocate irq\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
err = bus_setup_intr(dev, sc->irqres, INTR_TYPE_NET, lncintr,
|
||||
sc, &sc->intrhand);
|
||||
if (err) {
|
||||
device_printf(dev, "Cannot setup irq handler\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
sc->lnc_btag = rman_get_bustag(sc->portres);
|
||||
sc->lnc_bhandle = rman_get_bushandle(sc->portres);
|
||||
|
||||
/* XXX temp setting for nic */
|
||||
sc->nic.ic = PCnet_PCI;
|
||||
sc->nic.ident = NE2100;
|
||||
sc->nic.mem_mode = DMA_FIXED;
|
||||
sc->nrdre = NRDRE;
|
||||
sc->ntdre = NTDRE;
|
||||
sc->rap = PCNET_RAP;
|
||||
sc->rdp = PCNET_RDP;
|
||||
sc->bdp = PCNET_BDP;
|
||||
|
||||
/* Create a DMA tag describing the ring memory we need */
|
||||
|
||||
lnc_mem_size = ((NDESC(sc->nrdre) + NDESC(sc->ntdre)) *
|
||||
sizeof(struct host_ring_entry));
|
||||
|
||||
lnc_mem_size += sizeof(struct init_block) + (sizeof(struct mds) *
|
||||
(NDESC(sc->nrdre) + NDESC(sc->ntdre))) + MEM_SLEW;
|
||||
|
||||
lnc_mem_size += (NDESC(sc->nrdre) * RECVBUFSIZE) +
|
||||
(NDESC(sc->ntdre) * TRANSBUFSIZE);
|
||||
|
||||
err = bus_dma_tag_create(NULL, /* parent */
|
||||
1, /* alignement */
|
||||
0, /* boundary */
|
||||
BUS_SPACE_MAXADDR_24BIT, /* lowaddr */
|
||||
BUS_SPACE_MAXADDR, /* highaddr */
|
||||
NULL, NULL, /* filter, filterarg */
|
||||
lnc_mem_size, /* segsize */
|
||||
1, /* nsegments */
|
||||
BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
|
||||
0, /* flags */
|
||||
busdma_lock_mutex, /* lockfunc */
|
||||
&Giant, /* lockarg */
|
||||
&sc->dmat);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Can't create DMA tag\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
err = bus_dmamem_alloc(sc->dmat, (void **)&sc->recv_ring,
|
||||
BUS_DMA_NOWAIT, &sc->dmamap);
|
||||
|
||||
if (err) {
|
||||
device_printf(dev, "Couldn't allocate memory\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
bus_dmamap_load(sc->dmat, sc->dmamap, sc->recv_ring, lnc_mem_size,
|
||||
lnc_alloc_callback, sc->recv_ring, BUS_DMA_NOWAIT);
|
||||
|
||||
/* Call generic attach code */
|
||||
if (! lnc_attach_common(dev)) {
|
||||
device_printf(dev, "Generic attach code failed\n");
|
||||
lnc_release_resources(dev);
|
||||
return (ENXIO);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t lnc_pci_methods[] = {
|
||||
DEVMETHOD(device_probe, lnc_pci_probe),
|
||||
DEVMETHOD(device_attach, lnc_pci_attach),
|
||||
DEVMETHOD(device_detach, lnc_detach_common),
|
||||
#ifdef notyet
|
||||
DEVMETHOD(device_suspend, lnc_pci_suspend),
|
||||
DEVMETHOD(device_resume, lnc_pci_resume),
|
||||
DEVMETHOD(device_shutdown, lnc_pci_shutdown),
|
||||
#endif
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t lnc_pci_driver = {
|
||||
"lnc",
|
||||
lnc_pci_methods,
|
||||
sizeof(struct lnc_softc),
|
||||
};
|
||||
|
||||
DRIVER_MODULE(lnc, pci, lnc_pci_driver, lnc_devclass, 0, 0);
|
||||
MODULE_DEPEND(lnc, pci, 1, 1, 1);
|
||||
MODULE_DEPEND(lnc, ether, 1, 1, 1);
|
@ -1,209 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1994-2000
|
||||
* Paul Richards. 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,
|
||||
* 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Am7990, Local Area Network Controller for Ethernet (LANCE)
|
||||
*
|
||||
* The LANCE has four Control and Status Registers(CSRs) which are accessed
|
||||
* through two bus addressable ports, the address port (RAP) and the data
|
||||
* port (RDP).
|
||||
*
|
||||
*/
|
||||
|
||||
#define CSR0 0
|
||||
#define CSR1 1
|
||||
#define CSR2 2
|
||||
#define CSR3 3
|
||||
#define CSR88 88
|
||||
#define CSR89 89
|
||||
|
||||
#define BCR49 49
|
||||
#define BCR32 32
|
||||
#define BCR33 33
|
||||
#define BCR34 34
|
||||
|
||||
|
||||
/* Control and Status Register Masks */
|
||||
|
||||
/* CSR0 */
|
||||
|
||||
#define ERR 0x8000
|
||||
#define BABL 0x4000
|
||||
#define CERR 0x2000
|
||||
#define MISS 0x1000
|
||||
#define MERR 0x0800
|
||||
#define RINT 0x0400
|
||||
#define TINT 0x0200
|
||||
#define IDON 0x0100
|
||||
#define INTR 0x0080
|
||||
#define INEA 0x0040
|
||||
#define RXON 0x0020
|
||||
#define TXON 0x0010
|
||||
#define TDMD 0x0008
|
||||
#define STOP 0x0004
|
||||
#define STRT 0x0002
|
||||
#define INIT 0x0001
|
||||
|
||||
/*
|
||||
* CSR3
|
||||
*
|
||||
* Bits 3-15 are reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#define BSWP 0x0004
|
||||
#define ACON 0x0002
|
||||
#define BCON 0x0001
|
||||
|
||||
/* ISA Bus Configuration Registers */
|
||||
#define MSRDA 0x0000 /* ISACSR0: Master Mode Read Activity */
|
||||
#define MSWRA 0x0001 /* ISACSR1: Master Mode Write Activity */
|
||||
#define MC 0x0002 /* ISACSR2: Miscellaneous Configuration */
|
||||
|
||||
#define LED1 0x0005 /* ISACSR5: LED1 Status */
|
||||
#define LED2 0x0006 /* ISACSR6: LED2 Status */
|
||||
#define LED3 0x0007 /* ISACSR7: LED3 Status */
|
||||
|
||||
#define LED_PSE 0x0080 /* Pulse Stretcher */
|
||||
#define LED_XMTE 0x0010 /* Transmit Status */
|
||||
#define LED_RVPOLE 0x0008 /* Receive Polarity */
|
||||
#define LED_RCVE 0x0004 /* Receive Status */
|
||||
#define LED_JABE 0x0002 /* Jabber */
|
||||
#define LED_COLE 0x0001 /* Collision */
|
||||
|
||||
/* Initialisation block */
|
||||
|
||||
struct init_block {
|
||||
u_short mode; /* Mode register */
|
||||
u_char padr[6]; /* Ethernet address */
|
||||
u_char ladrf[8]; /* Logical address filter (multicast) */
|
||||
u_short rdra; /* Low order pointer to receive ring */
|
||||
u_short rlen; /* High order pointer and no. rings */
|
||||
u_short tdra; /* Low order pointer to transmit ring */
|
||||
u_short tlen; /* High order pointer and no rings */
|
||||
};
|
||||
|
||||
/* Initialisation Block Mode Register Masks */
|
||||
|
||||
#define PROM 0x8000 /* Promiscuous Mode */
|
||||
#define DRCVBC 0x4000 /* Disable Receive Broadcast */
|
||||
#define DRCVPA 0x2000 /* Disable Receive Physical Address */
|
||||
#define DLNKTST 0x1000 /* Disable Link Status */
|
||||
#define DAPC 0x0800 /* Disable Automatic Polarity Correction */
|
||||
#define MENDECL 0x0400 /* MENDEC Loopback Mode */
|
||||
#define LRT 0x0200 /* Low Receive Threshold (T-MAU mode only) */
|
||||
#define TSEL 0x0200 /* Transmit Mode Select (AUI mode only) */
|
||||
#define PORTSEL 0x0180 /* Port Select bits */
|
||||
#define INTL 0x0040 /* Internal Loopback */
|
||||
#define DRTY 0x0020 /* Disable Retry */
|
||||
#define FCOLL 0x0010 /* Force Collision */
|
||||
#define DXMTFCS 0x0008 /* Disable transmit CRC (FCS) */
|
||||
#define LOOP 0x0004 /* Loopback Enabl */
|
||||
#define DTX 0x0002 /* Disable the transmitter */
|
||||
#define DRX 0x0001 /* Disable the receiver */
|
||||
|
||||
/*
|
||||
* Message Descriptor Structure
|
||||
*
|
||||
* Each transmit or receive descriptor ring entry (RDRE's and TDRE's)
|
||||
* is composed of 4, 16-bit, message descriptors. They contain the following
|
||||
* information.
|
||||
*
|
||||
* 1. The address of the actual message data buffer in user (host) memory.
|
||||
* 2. The length of that message buffer.
|
||||
* 3. The status information for that particular buffer. The eight most
|
||||
* significant bits of md1 are collectively termed the STATUS of the
|
||||
* descriptor.
|
||||
*
|
||||
* Descriptor md0 contains LADR 0-15, the low order 16 bits of the 24-bit
|
||||
* address of the actual data buffer. Bits 0-7 of descriptor md1 contain
|
||||
* HADR, the high order 8-bits of the 24-bit data buffer address. Bits 8-15
|
||||
* of md1 contain the status flags of the buffer. Descriptor md2 contains the
|
||||
* buffer byte count in bits 0-11 as a two's complement number and must have
|
||||
* 1's written to bits 12-15. For the receive entry md3 has the Message Byte
|
||||
* Count in bits 0-11, this is the length of the received message and is valid
|
||||
* only when ERR is cleared and ENP is set. For the transmit entry it contains
|
||||
* more status information.
|
||||
*
|
||||
*/
|
||||
|
||||
struct mds {
|
||||
u_short md0;
|
||||
u_short md1;
|
||||
short md2;
|
||||
u_short md3;
|
||||
};
|
||||
|
||||
/* Receive STATUS flags for md1 */
|
||||
|
||||
#define OWN 0x8000 /* Owner bit, 0=host, 1=Lance */
|
||||
#define MDERR 0x4000 /* Error */
|
||||
#define FRAM 0x2000 /* Framing error error */
|
||||
#define OFLO 0x1000 /* Silo overflow */
|
||||
#define CRC 0x0800 /* CRC error */
|
||||
#define RBUFF 0x0400 /* Buffer error */
|
||||
#define STP 0x0200 /* Start of packet */
|
||||
#define ENP 0x0100 /* End of packet */
|
||||
#define HADR 0x00FF /* High order address bits */
|
||||
|
||||
/* Receive STATUS flags for md2 */
|
||||
|
||||
#define BCNT 0x0FFF /* Size of data buffer as 2's comp. no. */
|
||||
|
||||
/* Receive STATUS flags for md3 */
|
||||
|
||||
#define MCNT 0x0FFF /* Total size of data for received packet */
|
||||
|
||||
/* Transmit STATUS flags for md1 */
|
||||
|
||||
#define ADD_FCS 0x2000 /* Controls generation of FCS */
|
||||
#define MORE 0x1000 /* Indicates more than one retry was needed */
|
||||
#define ONE 0x0800 /* Exactly one retry was needed */
|
||||
#define DEF 0x0400 /* Packet transmit deferred -- channel busy */
|
||||
|
||||
/*
|
||||
* Transmit status flags for md2
|
||||
*
|
||||
* Same as for receive descriptor.
|
||||
*
|
||||
* BCNT 0x0FFF Size of data buffer as 2's complement number.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Transmit status flags for md3 */
|
||||
|
||||
#define TBUFF 0x8000 /* Buffer error */
|
||||
#define UFLO 0x4000 /* Silo underflow */
|
||||
#define LCOL 0x1000 /* Late collision */
|
||||
#define LCAR 0x0800 /* Loss of carrier */
|
||||
#define RTRY 0x0400 /* Tried 16 times */
|
||||
#define TDR 0x03FF /* Time domain reflectometry */
|
@ -1,266 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1994-1998
|
||||
* Paul Richards. 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,
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Paul Richards.
|
||||
* 4. 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialize multicast address hashing registers to accept
|
||||
* all multicasts (only used when in promiscuous mode)
|
||||
*/
|
||||
#define MULTI_INIT_ADDR 0xff
|
||||
|
||||
#define NORMAL 0
|
||||
|
||||
#define NRDRE 3
|
||||
#define NTDRE 3
|
||||
#define RECVBUFSIZE 1518 /* Packet size rounded to dword boundary */
|
||||
#define TRANSBUFSIZE 1518
|
||||
#define MBUF_CACHE_LIMIT 0
|
||||
|
||||
#define MEM_SLEW 8
|
||||
|
||||
/* LNC Flags */
|
||||
#define LNC_INITIALISED 1
|
||||
#define LNC_ALLMULTI 2
|
||||
|
||||
/* BICC port addresses */
|
||||
#define BICC_IOSIZE 16
|
||||
#define BICC_RDP 0x0c /* Register Data Port */
|
||||
#define BICC_RAP 0x0e /* Register Address Port */
|
||||
|
||||
/* NE2100 port addresses */
|
||||
#define NE2100_IOSIZE 24
|
||||
#define PCNET_RDP 0x10 /* Register Data Port */
|
||||
#define PCNET_RAP 0x12 /* Register Address Port */
|
||||
#define PCNET_RESET 0x14
|
||||
#define PCNET_BDP 0x16
|
||||
#define PCNET_VSW 0x18
|
||||
|
||||
/* DEPCA port addresses */
|
||||
#define DEPCA_IOSIZE 16
|
||||
#define DEPCA_CTRL 0x00 /* NIC Control and status register */
|
||||
#define DEPCA_RDP 0x04 /* Register Data Port */
|
||||
#define DEPCA_RAP 0x06 /* Register Address Port */
|
||||
#define DEPCA_ADP 0x0c
|
||||
|
||||
/* DEPCA specific defines */
|
||||
#define DEPCA_ADDR_ROM_SIZE 32
|
||||
|
||||
/* C-NET(98)S port addresses */
|
||||
/* Notice, we can ignore fragmantation by using isa_alloc_resourcev(). */
|
||||
#define CNET98S_IOSIZE 32
|
||||
#define CNET98S_RDP 0x10 /* Register Data Port */
|
||||
#define CNET98S_RAP 0x12 /* Register Address Port */
|
||||
#define CNET98S_RESET 0x14
|
||||
#define CNET98S_IDP 0x16
|
||||
#define CNET98S_EEPROM 0x1e
|
||||
|
||||
/* Chip types */
|
||||
#define LANCE 1 /* Am7990 */
|
||||
#define C_LANCE 2 /* Am79C90 */
|
||||
#define PCnet_ISA 3 /* Am79C960 */
|
||||
#define PCnet_ISAplus 4 /* Am79C961 */
|
||||
#define PCnet_ISA_II 5 /* Am79C961A */
|
||||
#define PCnet_32 6 /* Am79C965 */
|
||||
#define PCnet_PCI 7 /* Am79C970 */
|
||||
#define PCnet_PCI_II 8 /* Am79C970A */
|
||||
#define PCnet_FAST 9 /* Am79C971 */
|
||||
#define PCnet_FASTplus 10 /* Am79C972 */
|
||||
#define PCnet_Home 11 /* Am79C978 */
|
||||
|
||||
|
||||
/* CSR88-89: Chip ID masks */
|
||||
#define AMD_MASK 0x003
|
||||
#define PART_MASK 0xffff
|
||||
#define Am79C960 0x0003
|
||||
#define Am79C961 0x2260
|
||||
#define Am79C961A 0x2261
|
||||
#define Am79C965 0x2430
|
||||
#define Am79C970 0x0242
|
||||
#define Am79C970A 0x2621
|
||||
#define Am79C971 0x2623
|
||||
#define Am79C972 0x2624
|
||||
#define Am79C973 0x2625
|
||||
#define Am79C978 0x2626
|
||||
|
||||
/* Board types */
|
||||
#define UNKNOWN 0
|
||||
#define BICC 1
|
||||
#define NE2100 2
|
||||
#define DEPCA 3
|
||||
#define CNET98S 4 /* PC-98 */
|
||||
|
||||
/* mem_mode values */
|
||||
#define DMA_FIXED 1
|
||||
#define DMA_MBUF 2
|
||||
#define SHMEM 4
|
||||
|
||||
#define MEM_MODES \
|
||||
"\20\3SHMEM\2DMA_MBUF\1DMA_FIXED"
|
||||
|
||||
#define CSR0_FLAGS \
|
||||
"\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\12TINT\11IDON\
|
||||
\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT"
|
||||
|
||||
#define INIT_MODE \
|
||||
"\20\20PROM\07INTL\06DRTY\05COLL\04DTCR\03LOOP\02DTX\01DRX"
|
||||
|
||||
#define RECV_MD1 \
|
||||
"\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP"
|
||||
|
||||
#define TRANS_MD1 \
|
||||
"\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP"
|
||||
|
||||
#define TRANS_MD3 \
|
||||
"\20\6BUFF\5UFLO\4RES\3LCOL\2LCAR\1RTRY"
|
||||
|
||||
#ifdef LNC_KEEP_STATS
|
||||
#define LNCSTATS_STRUCT \
|
||||
struct lnc_stats { \
|
||||
int idon; \
|
||||
int rint; \
|
||||
int tint; \
|
||||
int cerr; \
|
||||
int babl; \
|
||||
int miss; \
|
||||
int merr; \
|
||||
int rxoff; \
|
||||
int txoff; \
|
||||
int terr; \
|
||||
int lcol; \
|
||||
int lcar; \
|
||||
int tbuff; \
|
||||
int def; \
|
||||
int more; \
|
||||
int one; \
|
||||
int uflo; \
|
||||
int rtry; \
|
||||
int rerr; \
|
||||
int fram; \
|
||||
int oflo; \
|
||||
int crc; \
|
||||
int rbuff; \
|
||||
int drop_packet; \
|
||||
int trans_ring_full; \
|
||||
} lnc_stats;
|
||||
#define LNCSTATS(X) ++(sc->lnc_stats.X);
|
||||
#else
|
||||
#define LNCSTATS_STRUCT
|
||||
#define LNCSTATS(X)
|
||||
#endif
|
||||
|
||||
struct nic_info {
|
||||
int ident; /* Type of card */
|
||||
int ic; /* Type of ic, Am7990, Am79C960 etc. */
|
||||
int mem_mode;
|
||||
int iobase;
|
||||
int mode; /* Mode setting at initialization */
|
||||
};
|
||||
|
||||
typedef struct lnc_softc {
|
||||
struct resource *irqres;
|
||||
int irqrid;
|
||||
struct resource *drqres;
|
||||
int drqrid;
|
||||
struct resource *portres;
|
||||
int portrid;
|
||||
bus_space_tag_t lnc_btag;
|
||||
bus_space_handle_t lnc_bhandle;
|
||||
void *intrhand;
|
||||
bus_dma_tag_t dmat;
|
||||
bus_dmamap_t dmamap;
|
||||
struct ifnet *ifp;
|
||||
struct nic_info nic; /* NIC specific info */
|
||||
int nrdre;
|
||||
struct host_ring_entry *recv_ring; /* start of alloc'd mem */
|
||||
int recv_next;
|
||||
int ntdre;
|
||||
struct host_ring_entry *trans_ring;
|
||||
int trans_next;
|
||||
struct init_block *init_block; /* Initialisation block */
|
||||
int pending_transmits; /* No. of transmit descriptors in
|
||||
use */
|
||||
int next_to_send;
|
||||
struct mbuf *mbufs;
|
||||
int mbuf_count;
|
||||
int flags;
|
||||
int rap;
|
||||
int rdp;
|
||||
int bdp;
|
||||
#ifdef DEBUG
|
||||
int lnc_debug;
|
||||
#endif
|
||||
LNCSTATS_STRUCT
|
||||
} lnc_softc_t;
|
||||
|
||||
struct host_ring_entry {
|
||||
struct mds *md;
|
||||
union {
|
||||
struct mbuf *mbuf;
|
||||
char *data;
|
||||
}buff;
|
||||
};
|
||||
|
||||
#define NDESC(len2) (1 << len2)
|
||||
|
||||
#define INC_MD_PTR(ptr, no_entries) \
|
||||
if (++ptr >= NDESC(no_entries)) \
|
||||
ptr = 0;
|
||||
|
||||
#define DEC_MD_PTR(ptr, no_entries) \
|
||||
if (--ptr < 0) \
|
||||
ptr = NDESC(no_entries) - 1;
|
||||
|
||||
#define RECV_NEXT (sc->recv_ring->base + sc->recv_next)
|
||||
#define TRANS_NEXT (sc->trans_ring->base + sc->trans_next)
|
||||
|
||||
#define lnc_inb(port) \
|
||||
bus_space_read_1(sc->lnc_btag, sc->lnc_bhandle, (port))
|
||||
#define lnc_inw(port) \
|
||||
bus_space_read_2(sc->lnc_btag, sc->lnc_bhandle, (port))
|
||||
#define lnc_outw(port, val) \
|
||||
bus_space_write_2(sc->lnc_btag, sc->lnc_bhandle, (port), (val))
|
||||
|
||||
/* Functional declarations */
|
||||
extern int lance_probe(struct lnc_softc *);
|
||||
extern void lnc_release_resources(device_t);
|
||||
extern int lnc_attach_common(device_t);
|
||||
extern int lnc_detach_common(device_t);
|
||||
extern void lnc_stop(struct lnc_softc *);
|
||||
|
||||
extern void write_csr(struct lnc_softc *, u_short, u_short);
|
||||
extern u_short read_csr(struct lnc_softc *, u_short);
|
||||
|
||||
/* Variable declarations */
|
||||
extern driver_intr_t lncintr;
|
||||
extern devclass_t lnc_devclass;
|
Loading…
Reference in New Issue
Block a user