Index: conf/files =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/conf/files,v retrieving revision 1.466 diff -u -r1.466 files --- conf/files 2001/01/08 01:59:15 1.466 +++ conf/files 2001/01/08 08:06:17 @@ -266,6 +266,9 @@ dev/cardbus/cardbus_cis.c optional cardbus dev/ccd/ccd.c count ccd dev/cs/if_cs.c optional cs +dev/cs/if_cs_isa.c optional cs isa +dev/cs/if_cs_pccard.c optional cs card +dev/cs/if_cs_pccard.c optional cs pccard #dev/dpt/dpt_control.c optional dpt dev/dpt/dpt_eisa.c optional dpt eisa dev/dpt/dpt_pci.c optional dpt pci Index: dev/cs/if_cs.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/dev/cs/if_cs.c,v retrieving revision 1.18 diff -u -r1.18 if_cs.c --- dev/cs/if_cs.c 2000/10/15 14:18:08 1.18 +++ dev/cs/if_cs.c 2001/01/08 08:06:22 @@ -57,13 +57,10 @@ #include #include #include - #include -#include - - #include +#include #ifdef CS_USE_64K_DMA #define CS_DMA_BUFFER_SIZE 65536 @@ -71,70 +68,20 @@ #define CS_DMA_BUFFER_SIZE 16384 #endif -/* - * cs_softc: per line info and status - */ -struct cs_softc { - - /* Ethernet common code */ - struct arpcom arpcom; - - /* Configuration words from EEPROM */ - int auto_neg_cnf; /* AutoNegotitation configuration */ - int adapter_cnf; /* Adapter configuration */ - int isa_config; /* ISA configuration */ - int chip_type; /* Type of chip */ - - struct ifmedia media; /* Media information */ - - int port_rid; /* resource id for port range */ - int port_used; /* nonzero if ports used */ - struct resource* port_res; /* resource for port range */ - int mem_rid; /* resource id for memory range */ - int mem_used; /* nonzero if memory used */ - struct resource* mem_res; /* resource for memory range */ - int irq_rid; /* resource id for irq */ - struct resource* irq_res; /* resource for irq */ - void* irq_handle; /* handle for irq handler */ - - int nic_addr; /* Base IO address of card */ - int send_cmd; - int line_ctl; /* */ - int send_underrun; - void *recv_ring; - - unsigned char *buffer; - int buf_len; -}; - static int cs_recv_delay = 570; SYSCTL_INT(_machdep, OID_AUTO, cs_recv_delay, CTLFLAG_RW, &cs_recv_delay, 0, ""); - -static int cs_isa_probe __P((device_t dev)); -static int cs_isa_attach __P((device_t dev)); - -static int cs_cs89x0_probe __P((device_t dev)); -driver_intr_t csintr; +static void cs_init (void *); +static int cs_ioctl (struct ifnet *, u_long, caddr_t); +static void cs_start (struct ifnet *); +static void cs_stop (struct cs_softc *); +static void cs_reset (struct cs_softc *); +static void cs_watchdog (struct ifnet *); + +static int cs_mediachange (struct ifnet *); +static void cs_mediastatus (struct ifnet *, struct ifmediareq *); +static int cs_mediaset (struct cs_softc *, int); -static int cs_attach __P((struct cs_softc *, int, int)); - -static void cs_init __P((void *)); -static int cs_ioctl __P((struct ifnet *, u_long, caddr_t)); -static void cs_start __P((struct ifnet *)); -static void cs_stop __P((struct cs_softc *)); -static void cs_reset __P((struct cs_softc *)); -static void cs_watchdog __P((struct ifnet *)); - -static int cs_alloc_port(device_t dev, int rid, int size); -static int cs_alloc_memory(device_t dev, int rid, int size); -static int cs_alloc_irq(device_t dev, int rid, int flags); -static void cs_release_resources(device_t dev); - -static int cs_mediachange __P((struct ifnet *)); -static void cs_mediastatus __P((struct ifnet *, struct ifmediareq *)); -static int cs_mediaset __P((struct cs_softc *, int)); - static void cs_write_mbufs(struct cs_softc*, struct mbuf*); static void cs_xmit_buf(struct cs_softc*); static int cs_get_packet(struct cs_softc*); @@ -149,24 +96,9 @@ static int enable_aui(struct cs_softc *); static int enable_bnc(struct cs_softc *); static int cs_duplex_auto(struct cs_softc *); - -static device_method_t cs_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, cs_isa_probe), - DEVMETHOD(device_attach, cs_isa_attach), - { 0, 0 } -}; - -static driver_t cs_driver = { - "cs", - cs_methods, - sizeof(struct cs_softc) -}; -static devclass_t cs_devclass; +devclass_t cs_devclass; -DRIVER_MODULE(cs, isa, cs_driver, cs_devclass, 0, 0); - static int get_eeprom_data( struct cs_softc *sc, int off, int len, int *buffer) { @@ -358,7 +290,7 @@ return 0; } -static int +int cs_cs89x0_probe(device_t dev) { int i; @@ -643,73 +575,10 @@ } } -static struct isa_pnp_id cs_ids[] = { - { 0x4060630e, NULL }, /* CSC6040 */ - { 0x10104d24, NULL }, /* IBM EtherJet */ - { 0, NULL } -}; - /* - * Determine if the device is present - */ -static int -cs_isa_probe(device_t dev) -{ - int error = 0; - - struct cs_softc *sc = device_get_softc(dev); - - bzero(sc, sizeof(struct cs_softc)); - - /* Check isapnp ids */ - error = ISA_PNP_PROBE(device_get_parent(dev), dev, cs_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; - } - - error=cs_cs89x0_probe(dev); - -end: - if (error == 0) - error = cs_alloc_irq(dev, 0, 0); - - cs_release_resources(dev); - return (error); -} - -static int cs_isa_attach(device_t dev) -{ - struct cs_softc *sc = device_get_softc(dev); - int flags = device_get_flags(dev); - int error; - - if (sc->port_used > 0) - cs_alloc_port(dev, sc->port_rid, sc->port_used); - if (sc->mem_used) - cs_alloc_memory(dev, sc->mem_rid, sc->mem_used); - cs_alloc_irq(dev, sc->irq_rid, 0); - - error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, - csintr, sc, &sc->irq_handle); - if (error) { - cs_release_resources(dev); - return (error); - } - - return cs_attach(sc, device_get_unit(dev), flags); -} - -/* * Install the interface into kernel networking data structures */ -static int +int cs_attach(struct cs_softc *sc, int unit, int flags) { int media=0; Index: dev/cs/if_cs_isa.c =================================================================== RCS file: if_cs_isa.c diff -N if_cs_isa.c --- /dev/null Mon Jan 8 00:05:23 2001 +++ if_cs_isa.c Mon Jan 8 00:06:22 2001 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko. + * 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 +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +static int cs_isa_probe (device_t); +static int cs_isa_attach (device_t); + +static struct isa_pnp_id cs_ids[] = { + { 0x4060630e, NULL }, /* CSC6040 */ + { 0x10104d24, NULL }, /* IBM EtherJet */ + { 0, NULL } +}; + +/* + * Determine if the device is present + */ +static int +cs_isa_probe(device_t dev) +{ + int error = 0; + + /* Check isapnp ids */ + error = ISA_PNP_PROBE(device_get_parent(dev), dev, cs_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; + + error = cs_cs89x0_probe(dev); +end: + if (error == 0) + error = cs_alloc_irq(dev, 0, 0); + + cs_release_resources(dev); + return (error); +} + +static int +cs_isa_attach(device_t dev) +{ + struct cs_softc *sc = device_get_softc(dev); + int flags = device_get_flags(dev); + int error; + + if (sc->port_used > 0) + cs_alloc_port(dev, sc->port_rid, sc->port_used); + if (sc->mem_used) + cs_alloc_memory(dev, sc->mem_rid, sc->mem_used); + cs_alloc_irq(dev, sc->irq_rid, 0); + + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, + csintr, sc, &sc->irq_handle); + if (error) { + cs_release_resources(dev); + return (error); + } + + return (cs_attach(sc, device_get_unit(dev), flags)); +} + +static device_method_t cs_isa_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, cs_isa_probe), + DEVMETHOD(device_attach, cs_isa_attach), +#ifdef CS_HAS_DETACH + DEVMETHOD(device_detach, cs_detach), +#endif + + { 0, 0 } +}; + +static driver_t cs_isa_driver = { + "cs", + cs_isa_methods, + sizeof(struct cs_softc), +}; + +extern devclass_t cs_devclass; + +DRIVER_MODULE(if_cs, isa, cs_isa_driver, cs_devclass, 0, 0); Index: dev/cs/if_cs_pccard.c =================================================================== RCS file: if_cs_pccard.c diff -N if_cs_pccard.c --- /dev/null Mon Jan 8 00:05:23 2001 +++ if_cs_pccard.c Mon Jan 8 00:06:22 2001 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 1999 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 ``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$ + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "card_if.h" + +static const struct pccard_product cs_pccard_products[] = { + { NULL } +}; +static int +cs_pccard_match(device_t dev) +{ + const struct pccard_product *pp; + + if ((pp = pccard_product_lookup(dev, cs_pccard_products, + sizeof(cs_pccard_products[0]), NULL)) != NULL) { + device_set_desc(dev, pp->pp_name); + return 0; + } + return EIO; +} + +static int +cs_pccard_probe(device_t dev) +{ + int error; + + error = cs_cs89x0_probe(dev); + cs_release_resources(dev); + return (error); +} + +static int +cs_pccard_attach(device_t dev) +{ + struct cs_softc *sc = device_get_softc(dev); + int flags = device_get_flags(dev); + int error; + + if (sc->port_used > 0) + cs_alloc_port(dev, sc->port_rid, sc->port_used); + if (sc->mem_used) + cs_alloc_memory(dev, sc->mem_rid, sc->mem_used); + error = cs_alloc_irq(dev, sc->irq_rid, 0); + if (error != 0) + goto bad; + + error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, + csintr, sc, &sc->irq_handle); + if (error != 0) + goto bad; + + return (cs_attach(sc, device_get_unit(dev), flags)); +bad: + cs_release_resources(dev); + return (error); +} + +static device_method_t cs_pccard_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pccard_compat_probe), + DEVMETHOD(device_attach, pccard_compat_attach), +#ifdef CS_HAS_DETACH + DEVMETHOD(device_detach, cs_detach), +#endif + + /* Card interface */ + DEVMETHOD(card_compat_match, cs_pccard_match), + DEVMETHOD(card_compat_probe, cs_pccard_probe), + DEVMETHOD(card_compat_attach, cs_pccard_attach), + + { 0, 0 } +}; + +static driver_t cs_pccard_driver = { + "cs", + cs_pccard_methods, + sizeof(struct cs_softc), +}; + +extern devclass_t cs_devclass; + +DRIVER_MODULE(if_cs, pccard, cs_pccard_driver, cs_devclass, 0, 0); +MODULE_DEPEND(if_cs, pccard, 1, 1, 1); Index: dev/cs/if_csvar.h =================================================================== RCS file: if_csvar.h diff -N if_csvar.h --- /dev/null Mon Jan 8 00:05:23 2001 +++ if_csvar.h Mon Jan 8 00:06:22 2001 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1999 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 ``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$ + */ + +#ifndef _IF_CSVAR_H +#define _IF_CSVAR_H + +#include +#include + +/* + * cs_softc: per line info and status + */ +struct cs_softc { + + /* Ethernet common code */ + struct arpcom arpcom; + + /* Configuration words from EEPROM */ + int auto_neg_cnf; /* AutoNegotitation configuration */ + int adapter_cnf; /* Adapter configuration */ + int isa_config; /* ISA configuration */ + int chip_type; /* Type of chip */ + + struct ifmedia media; /* Media information */ + + int port_rid; /* resource id for port range */ + int port_used; /* nonzero if ports used */ + struct resource* port_res; /* resource for port range */ + int mem_rid; /* resource id for memory range */ + int mem_used; /* nonzero if memory used */ + struct resource* mem_res; /* resource for memory range */ + int irq_rid; /* resource id for irq */ + struct resource* irq_res; /* resource for irq */ + void* irq_handle; /* handle for irq handler */ + + int nic_addr; /* Base IO address of card */ + int send_cmd; + int line_ctl; /* */ + int send_underrun; + void *recv_ring; + + unsigned char *buffer; + int buf_len; +}; + +int cs_alloc_port(device_t dev, int rid, int size); +int cs_alloc_memory(device_t dev, int rid, int size); +int cs_alloc_irq(device_t dev, int rid, int flags); +int cs_attach(struct cs_softc *, int, int); +int cs_cs89x0_probe(device_t dev); +void cs_release_resources(device_t dev); +driver_intr_t csintr; + +#endif /* _IF_CSVAR_H */