diff options
32 files changed, 932 insertions, 937 deletions
diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c index 55df9bb..0728769 100644 --- a/sys/amd64/amd64/autoconf.c +++ b/sys/amd64/amd64/autoconf.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 - * $Id: autoconf.c,v 1.76 1997/09/21 21:38:03 gibbs Exp $ + * $Id: autoconf.c,v 1.77 1997/09/23 17:14:37 bde Exp $ */ /* @@ -84,8 +84,8 @@ #include <pci/pcivar.h> #endif -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <pccard/driver.h> #endif @@ -223,7 +223,7 @@ configure(dummy) isa_configure(); #endif -#if NCRD > 0 +#if NCARD > 0 /* After everyone else has a chance at grabbing resources */ pccard_configure(); #endif diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 21666fb..93b47ce 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -11,7 +11,7 @@ # device lines is present in the ./LINT configuration file. If you are # in doubt as to the purpose or necessity of a line, check first in LINT. # -# $Id: GENERIC,v 1.97 1997/10/08 17:05:03 nate Exp $ +# $Id: GENERIC,v 1.98 1997/10/18 10:59:06 joerg Exp $ machine "i386" cpu "I386_CPU" @@ -109,9 +109,9 @@ device npx0 at isa? port "IO_NPX" irq 13 vector npxintr device apm0 at isa? disable flags 0x31 # Advanced Power Management # PCCARD (PCMCIA) support -#controller crd0 -#device pcic0 at crd? -#device pcic1 at crd? +#controller card0 +#device pcic0 at card? +#device pcic1 at card? device sio0 at isa? port "IO_COM1" flags 0x10 tty irq 4 vector siointr device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 880e7a1..0023a96 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.374 1997/10/18 10:10:36 peter Exp $ +# $Id: LINT,v 1.375 1997/10/18 10:59:16 joerg Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1287,11 +1287,11 @@ device bktr0 # # PCCARD/PCMCIA # -# crd: slot controller +# card: slot controller # pcic: slots -controller crd0 -controller pcic0 at crd? -controller pcic1 at crd? +controller card0 +controller pcic0 at card? +controller pcic1 at card? # # Laptop/Notebook options: diff --git a/sys/conf/files b/sys/conf/files index c7c8c99..157dbdc 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -353,7 +353,7 @@ nfs/nfs_vfsops.c optional nfs nfs/nfs_vnops.c optional nfs nfs/bootp_subr.c optional bootp nfs/krpc_subr.c optional bootp -pccard/pccard.c optional crd +pccard/pccard.c optional card pccard/pcic.c optional pcic device-driver pci/aic7870.c optional ahc device-driver \ dependency "aic7xxx_reg.h $S/pci/aic7870.c" diff --git a/sys/conf/majors b/sys/conf/majors index e5ebe05..5344a0e 100644 --- a/sys/conf/majors +++ b/sys/conf/majors @@ -1,4 +1,4 @@ -$Id: majors.i386,v 1.17 1997/08/28 12:18:09 jkh Exp $ +$Id: majors.i386,v 1.18 1997/09/23 08:45:33 jkh Exp $ Hopefully, this list will one day be obsoleted by DEVFS, but for now this is the current allocation of device major numbers. @@ -88,7 +88,7 @@ chrdev name comments 47 gsc Genius Scanner 48 cy Cyclades 49 ssc SCSI super device -50 crd pcmcia cards +50 card pcmcia cards 51 joy joystick 52 tun IP tunnel device 53 snp tty snoop diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index 7b632b7..d839eba 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.121 1997/09/10 00:17:39 davidg Exp $ + * $Id: if_ed.c,v 1.122 1997/10/03 16:26:15 davidg Exp $ */ /* @@ -151,8 +151,8 @@ static int ed_probe_HP_pclanp __P((struct isa_device *)); void *ed_attach_NE2000_pci __P((int, int)); #endif -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 static int ed_probe_pccard __P((struct isa_device *, u_char *)); #endif @@ -182,7 +182,7 @@ static void ed_setrcr(struct ed_softc *); static u_long ds_crc(u_char *ep); -#if NCRD > 0 +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/driver.h> @@ -191,68 +191,46 @@ static u_long ds_crc(u_char *ep); /* * PC-Card (PCMCIA) specific code. */ -static int card_intr(struct pccard_dev *); /* Interrupt handler */ -static void edunload(struct pccard_dev *); /* Disable driver */ -static void edsuspend(struct pccard_dev *); /* Suspend driver */ -static int edinit(struct pccard_dev *, int); /* init device */ +static int edinit(struct pccard_devinfo *, int); /* init device */ +static void edunload(struct pccard_devinfo *); /* Disable driver */ +static int card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void edsuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv ed_info = { +static struct pccard_device ed_info = { "ed", - card_intr, + edinit, edunload, + card_intr, edsuspend, - edinit, 0, /* Attributes - presently unused */ &net_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * edinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -edsuspend(struct pccard_dev *dp) -{ - struct ed_softc *sc = &ed_softc[dp->isahd.id_unit]; - /* - * Some 'ed' cards will generate a interrupt as they go away, - * and by the time the interrupt handler gets to the card, - * the interrupt can't be cleared. - * By setting gone here, we tell the handler to ignore the - * interrupt when it happens. - */ - sc->gone = 1; /* avoid spinning endlessly in interrupt handler */ - - printf("ed%d: suspending\n", dp->isahd.id_unit); -} - -/* * Initialize the device - called from Slot manager. + * * If first is set, then check for the device's existence * before initializing it. Once initialized, the device table may * be set up. */ static int -edinit(struct pccard_dev *dp, int first) +edinit(struct pccard_devinfo *devi, int first) { - struct ed_softc *sc = &ed_softc[dp->isahd.id_unit]; + struct ed_softc *sc = &ed_softc[devi->isahd.id_unit]; /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= NED) + if (devi->isahd.id_unit >= NED) return(ENODEV); /* * Probe the device. If a value is returned, the * device was found at the location. */ sc->gone = 0; - if (ed_probe_pccard(&dp->isahd,dp->misc)==0) + if (ed_probe_pccard(&devi->isahd, devi->misc) == 0) return(ENXIO); - if (ed_attach_isa(&dp->isahd)==0) + if (ed_attach_isa(&devi->isahd) == 0) return(ENXIO); } else { sc->gone = 0; /* reenable after a suspend */ @@ -277,19 +255,19 @@ edinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -edunload(struct pccard_dev *dp) +edunload(struct pccard_devinfo *devi) { - struct ed_softc *sc = &ed_softc[dp->isahd.id_unit]; + struct ed_softc *sc = &ed_softc[devi->isahd.id_unit]; struct ifnet *ifp = &sc->arpcom.ac_if; if (sc->gone) { - printf("ed%d: already unloaded\n", dp->isahd.id_unit); + printf("ed%d: already unloaded\n", devi->isahd.id_unit); return; } ifp->if_flags &= ~IFF_RUNNING; if_down(ifp); sc->gone = 1; - printf("ed%d: unload\n", dp->isahd.id_unit); + printf("ed%d: unload\n", devi->isahd.id_unit); } /* @@ -297,12 +275,35 @@ edunload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -card_intr(struct pccard_dev *dp) +card_intr(struct pccard_devinfo *devi) { - edintr_sc(&ed_softc[dp->isahd.id_unit]); + edintr_sc(&ed_softc[devi->isahd.id_unit]); return(1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * edinit with first = 0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +edsuspend(struct pccard_devinfo *devi) +{ + struct ed_softc *sc = &ed_softc[devi->isahd.id_unit]; + /* + * Some 'ed' cards will generate a interrupt as they go away, + * and by the time the interrupt handler gets to the card, + * the interrupt can't be cleared. + * By setting gone here, we tell the handler to ignore the + * interrupt when it happens. + */ + sc->gone = 1; /* avoid spinning endlessly in interrupt handler */ + + printf("ed%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ struct isa_driver eddriver = { ed_probe, @@ -378,7 +379,7 @@ ed_probe(isa_dev) { int nports; -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. @@ -1321,8 +1322,7 @@ ed_probe_Novell(isa_dev) isa_dev->id_unit, isa_dev->id_flags); } -#if NCRD > 0 - +#if NCARD > 0 /* * Probe framework for pccards. Replicates the standard framework, * minus the pccard driver registration and ignores the ether address @@ -1346,7 +1346,7 @@ ed_probe_pccard(isa_dev, ether) return (0); } -#endif /* NCRD > 0 */ +#endif /* NCARD > 0 */ #define ED_HPP_TEST_SIZE 16 diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index 992fac3..84d578e 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -38,7 +38,7 @@ */ /* - * $Id: if_ep.c,v 1.60 1997/09/02 01:18:13 bde Exp $ + * $Id: if_ep.c,v 1.61 1997/10/14 06:56:08 itojun Exp $ * * Promiscuous mode added and interrupt logic slightly changed * to reduce the number of adapter failures. Transceiver select @@ -142,9 +142,9 @@ struct isa_driver epdriver = { 0 }; -#include "crd.h" +#include "card.h" -#if NCRD > 0 +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/driver.h> @@ -153,42 +153,31 @@ struct isa_driver epdriver = { /* * PC-Card (PCMCIA) specific code. */ -static int card_intr __P((struct pccard_dev *)); -static void ep_unload __P((struct pccard_dev *)); -static void ep_suspend __P((struct pccard_dev *)); -static int ep_pccard_init __P((struct pccard_dev *, int)); -static int ep_pccard_attach __P((struct pccard_dev *)); +static int ep_pccard_init __P((struct pccard_devinfo *, int)); +static int ep_pccard_attach __P((struct pccard_devinfo *)); +static void ep_unload __P((struct pccard_devinfo *)); +static int card_intr __P((struct pccard_devinfo *)); +static void ep_suspend __P((struct pccard_devinfo *)); -static struct pccard_drv ep_info = { +static struct pccard_device ep_info = { "ep", - card_intr, + ep_pccard_init, ep_unload, + card_intr, ep_suspend, - ep_pccard_init, 0, /* Attributes - presently unused */ &net_imask }; -/* Resume is done by executing ep_pccard_init(dp, 0). */ -static void -ep_suspend(dp) - struct pccard_dev *dp; -{ - struct ep_softc *sc = ep_softc[dp->isahd.id_unit]; - - printf("ep%d: suspending\n", dp->isahd.id_unit); - sc->gone = 1; -} - /* - * + * Initialize the device - called from Slot manager. */ static int -ep_pccard_init(dp, first) - struct pccard_dev *dp; +ep_pccard_init(devi, first) + struct pccard_devinfo *devi; int first; { - struct isa_device *is = &dp->isahd; + struct isa_device *is = &devi->isahd; struct ep_softc *sc = ep_softc[is->id_unit]; struct ep_board *epb; int i; @@ -210,41 +199,36 @@ ep_pccard_init(dp, first) epb->epb_used = 1; epb->prod_id = get_e(sc, EEPROM_PROD_ID); - if (epb->prod_id != 0x9058) { /* 3C589's product id */ - if (first) { + /* 3C589's product id? */ + if (epb->prod_id != 0x9058) { + if (first) printf("ep%d: failed to come ready.\n", is->id_unit); - } else { + else printf("ep%d: failed to resume.\n", is->id_unit); - } return (ENXIO); } epb->res_cfg = get_e(sc, EEPROM_RESOURCE_CFG); - for (i = 0; i < 3; i++) { - sc->epb->eth_addr[i] = get_e(sc, EEPROM_NODE_ADDR_0 + i); - } + for (i = 0; i < 3; i++) + sc->epb->eth_addr[i] = get_e(sc, EEPROM_NODE_ADDR_0 + i); if (first) { - if (ep_pccard_attach(dp) == 0) { + if (ep_pccard_attach(devi) == 0) return (ENXIO); - } sc->arpcom.ac_if.if_snd.ifq_maxlen = ifqmaxlen; - } - - if (!first) { + } else { sc->gone = 0; printf("ep%d: resumed.\n", is->id_unit); epinit(sc); } - return (0); } static int -ep_pccard_attach(dp) - struct pccard_dev *dp; +ep_pccard_attach(devi) + struct pccard_devinfo *devi; { - struct isa_device *is = &dp->isahd; + struct isa_device *is = &devi->isahd; struct ep_softc *sc = ep_softc[is->id_unit]; u_short config; @@ -275,18 +259,18 @@ ep_pccard_attach(dp) } static void -ep_unload(dp) - struct pccard_dev *dp; +ep_unload(devi) + struct pccard_devinfo *devi; { - struct ep_softc *sc = ep_softc[dp->isahd.id_unit]; + struct ep_softc *sc = ep_softc[devi->isahd.id_unit]; if (sc->gone) { - printf("ep%d: already unloaded\n", dp->isahd.id_unit); + printf("ep%d: already unloaded\n", devi->isahd.id_unit); return; } sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING; sc->gone = 1; - printf("ep%d: unload\n", dp->isahd.id_unit); + printf("ep%d: unload\n", devi->isahd.id_unit); } /* @@ -294,14 +278,24 @@ ep_unload(dp) * front end of PC-Card handler. */ static int -card_intr(dp) - struct pccard_dev *dp; +card_intr(devi) + struct pccard_devinfo *devi; { - epintr(dp->isahd.id_unit); + epintr(devi->isahd.id_unit); return(1); } -#endif /* NCRD > 0 */ +/* Resume is done by executing ep_pccard_init(devi, 0). */ +static void +ep_suspend(devi) + struct pccard_devinfo *devi; +{ + struct ep_softc *sc = ep_softc[devi->isahd.id_unit]; + + printf("ep%d: suspending\n", devi->isahd.id_unit); + sc->gone = 1; +} +#endif /* NCARD > 0 */ static int eeprom_rdy(sc) @@ -309,7 +303,8 @@ eeprom_rdy(sc) { int i; - for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++); + for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) + continue; if (i >= MAX_EEPROMBUSY) { printf("ep%d: eeprom failed to come ready.\n", sc->unit); return (0); @@ -500,9 +495,9 @@ ep_isa_probe(is) struct ep_board *epb; u_short k; -#if NCRD > 0 +#if NCARD > 0 pccard_add_driver(&ep_info); -#endif /* NCRD > 0 */ +#endif if ((epb = ep_look_for_board_at(is)) == 0) return (0); diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index b53bfe7..00c1b70 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -21,7 +21,7 @@ */ /* - * $Id: if_fe.c,v 1.28 1997/03/24 11:32:49 bde Exp $ + * $Id: if_fe.c,v 1.29 1997/07/20 14:09:59 bde Exp $ * * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. * To be used with FreeBSD 2.x @@ -71,7 +71,6 @@ */ #include "fe.h" -#include "crd.h" #include "bpfilter.h" #include <sys/param.h> @@ -120,7 +119,8 @@ #include <i386/isa/icu.h> /* PCCARD suport */ -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/slot.h> @@ -247,7 +247,7 @@ static int fe_probe_fmv ( DEVICE *, struct fe_softc * ); static int fe_probe_ati ( DEVICE *, struct fe_softc * ); static void fe_init_ati ( struct fe_softc * ); static int fe_probe_gwy ( DEVICE *, struct fe_softc * ); -#if NCRD > 0 +#if NCARD > 0 static int fe_probe_mbh ( DEVICE *, struct fe_softc * ); static void fe_init_mbh ( struct fe_softc * ); static int fe_probe_tdk ( DEVICE *, struct fe_softc * ); @@ -318,52 +318,41 @@ outblk ( struct fe_softc * sc, int offs, u_char const * mem, int len ) } /* PCCARD Support */ -#if NCRD > 0 +#if NCARD > 0 /* * PC-Card (PCMCIA) specific code. */ -static int fe_card_intr(struct pccard_dev *); /* Interrupt handler */ -static void feunload(struct pccard_dev *); /* Disable driver */ -static void fesuspend(struct pccard_dev *); /* Suspend driver */ -static int feinit(struct pccard_dev *, int); /* init device */ +static int feinit(struct pccard_devinfo *, int); /* init device */ +static void feunload(struct pccard_devinfo *); /* Disable driver */ +static int fe_card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void fesuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv fe_info = { +static struct pccard_device fe_info = { "fe", - fe_card_intr, + feinit, feunload, + fe_card_intr, fesuspend, - feinit, 0, /* Attributes - presently unused */ &net_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * feinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -fesuspend(struct pccard_dev *dp) -{ - printf("fe%d: suspending\n", dp->isahd.id_unit); -} - -/* - * Initialize the device - called from Slot manager. + * Initialize the device - called from Slot manager. + * * if first is set, then initially check for * the device's existence before initializing it. * Once initialized, the device table may be set up. */ static int -feinit(struct pccard_dev *dp, int first) +feinit(struct pccard_devinfo *devi, int first) { - /* validate unit number. */ struct fe_softc *sc; + + /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= NFE) + if (devi->isahd.id_unit >= NFE) return (ENODEV); /* * Probe the device. If a value is returned, @@ -373,28 +362,28 @@ feinit(struct pccard_dev *dp, int first) printf("Start Probe\n"); #endif /* Initialize "minimum" parts of our softc. */ - sc = &fe_softc[dp->isahd.id_unit]; - sc->sc_unit = dp->isahd.id_unit; - sc->iobase = dp->isahd.id_iobase; + sc = &fe_softc[devi->isahd.id_unit]; + sc->sc_unit = devi->isahd.id_unit; + sc->iobase = devi->isahd.id_iobase; /* Use Ethernet address got from CIS, if one is available. */ - if ((dp->misc[0] & 0x03) == 0x00 - && (dp->misc[0] | dp->misc[1] | dp->misc[2]) != 0) { + if ((devi->misc[0] & 0x03) == 0x00 + && (devi->misc[0] | devi->misc[1] | devi->misc[2]) != 0) { /* Yes, it looks like a valid Ether address. */ - bcopy(dp->misc, sc->sc_enaddr, ETHER_ADDR_LEN); + bcopy(devi->misc, sc->sc_enaddr, ETHER_ADDR_LEN); } else { /* Indicate we have no Ether address in CIS. */ bzero(sc->sc_enaddr, ETHER_ADDR_LEN); } /* Probe supported PC card models. */ - if (fe_probe_tdk(&dp->isahd, sc) == 0 - && fe_probe_mbh(&dp->isahd, sc) == 0) + if (fe_probe_tdk(&devi->isahd, sc) == 0 && + fe_probe_mbh(&devi->isahd, sc) == 0) return (ENXIO); #if FE_DEBUG >= 2 printf("Start attach\n"); #endif - if (fe_attach(&dp->isahd) == 0) + if (fe_attach(&devi->isahd) == 0) return (ENXIO); } /* @@ -417,11 +406,11 @@ feinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -feunload(struct pccard_dev *dp) +feunload(struct pccard_devinfo *devi) { - struct fe_softc *sc = &fe_softc[dp->isahd.id_unit]; - printf("fe%d: unload\n", dp->isahd.id_unit); - fe_stop(dp->isahd.id_unit); + struct fe_softc *sc = &fe_softc[devi->isahd.id_unit]; + printf("fe%d: unload\n", devi->isahd.id_unit); + fe_stop(devi->isahd.id_unit); } /* @@ -429,12 +418,25 @@ feunload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -fe_card_intr(struct pccard_dev *dp) +fe_card_intr(struct pccard_devinfo *devi) { - feintr(dp->isahd.id_unit); + feintr(devi->isahd.id_unit); return (1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * feinit with first=0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +fesuspend(struct pccard_devinfo *devi) +{ + printf("fe%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ /* @@ -476,7 +478,7 @@ static struct fe_probe_list const fe_probe_list [] = static int fe_probe ( DEVICE * dev ) { -#if NCRD > 0 +#if NCARD > 0 static int fe_already_init; #endif struct fe_softc * sc; @@ -490,7 +492,7 @@ fe_probe ( DEVICE * dev ) sc = &fe_softc[ dev->id_unit ]; sc->sc_unit = dev->id_unit; -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. @@ -499,7 +501,7 @@ fe_probe ( DEVICE * dev ) pccard_add_driver(&fe_info); fe_already_init = 1; } -#endif /* NCRD > 0 */ +#endif /* Probe each possibility, one at a time. */ for ( list = fe_probe_list; list->probe != NULL; list++ ) { @@ -1239,7 +1241,7 @@ fe_probe_gwy ( DEVICE * dev, struct fe_softc * sc ) return 32; } -#if NCRD > 0 +#if NCARD > 0 /* * Probe and initialization for Fujitsu MBH10302 PCMCIA Ethernet interface. * Note that this is for 10302 only; MBH10304 is handled by fe_probe_tdk(). @@ -1371,9 +1373,6 @@ fe_init_mbh ( struct fe_softc * sc ) outb( sc->ioaddr[ FE_MBH0 ], FE_MBH0_MAGIC | FE_MBH0_INTR_ENABLE ); } -#endif /* NCRD > 0 */ - -#if NCRD > 0 /* * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface. * by MASUI Kenji <masui@cs.titech.ac.jp> @@ -1476,7 +1475,7 @@ fe_probe_tdk ( DEVICE * dev, struct fe_softc * sc ) */ return 16; } -#endif +#endif /* NCARD > 0 */ /* * Install interface into kernel networking data structures @@ -1484,7 +1483,7 @@ fe_probe_tdk ( DEVICE * dev, struct fe_softc * sc ) static int fe_attach ( DEVICE * dev ) { -#if NCRD > 0 +#if NCARD > 0 static int already_ifattach[NFE]; #endif struct fe_softc *sc = &fe_softc[dev->id_unit]; @@ -1552,14 +1551,14 @@ fe_attach ( DEVICE * dev ) } /* Attach and stop the interface. */ -#if NCRD > 0 +#if NCARD > 0 if (already_ifattach[dev->id_unit] != 1) { if_attach(&sc->sc_if); already_ifattach[dev->id_unit] = 1; } #else if_attach(&sc->sc_if); -#endif /* NCRD > 0 */ +#endif fe_stop(sc->sc_unit); /* This changes the state to IDLE. */ ether_ifattach(&sc->sc_if); diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 39c6470..9697556 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.183 1997/09/21 21:41:40 gibbs Exp $ + * $Id: sio.c,v 1.184 1997/10/12 20:23:30 phk Exp $ */ #include "opt_comconsole.h" @@ -87,8 +87,8 @@ #endif #include <i386/isa/ic/ns16550.h> -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <pccard/card.h> #include <pccard/driver.h> #include <pccard/slot.h> @@ -470,63 +470,50 @@ sysctl_machdep_comdefaultrate SYSCTL_HANDLER_ARGS SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); -#if NCRD > 0 +#if NCARD > 0 /* * PC-Card (PCMCIA) specific code. */ -static int card_intr(struct pccard_dev *); /* Interrupt handler */ -static void siounload(struct pccard_dev *); /* Disable driver */ -static void siosuspend(struct pccard_dev *); /* Suspend driver */ -static int sioinit(struct pccard_dev *, int); /* init device */ +static int sioinit(struct pccard_devinfo *, int); /* init device */ +static void siounload(struct pccard_devinfo *); /* Disable driver */ +static int card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void siosuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv sio_info = { +static struct pccard_device sio_info = { driver_name, - card_intr, + sioinit, siounload, + card_intr, siosuspend, - sioinit, 0, /* Attributes - presently unused */ &tty_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * sioinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -siosuspend(struct pccard_dev *dp) -{ - printf("sio%d: suspending\n", dp->isahd.id_unit); -} - -/* * Initialize the device - called from Slot manager. + * * If first is set, then check for the device's existence * before initializing it. Once initialized, the device table may * be set up. */ int -sioinit(struct pccard_dev *dp, int first) +sioinit(struct pccard_devinfo *devi, int first) { - /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= (NSIOTOT)) + if (devi->isahd.id_unit >= (NSIOTOT)) return(ENODEV); /* Make sure it isn't already probed. */ - if (com_addr(dp->isahd.id_unit)) + if (com_addr(devi->isahd.id_unit)) return(EBUSY); /* * Probe the device. If a value is returned, the * device was found at the location. */ - if (sioprobe(&dp->isahd)==0) + if (sioprobe(&devi->isahd) == 0) return(ENXIO); - if (sioattach(&dp->isahd)==0) + if (sioattach(&devi->isahd) == 0) return(ENXIO); } /* @@ -549,18 +536,18 @@ sioinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -siounload(struct pccard_dev *dp) +siounload(struct pccard_devinfo *devi) { struct com_s *com; - com = com_addr(dp->isahd.id_unit); + com = com_addr(devi->isahd.id_unit); if (!com->iobase) { - printf("sio%d already unloaded!\n",dp->isahd.id_unit); + printf("sio%d already unloaded!\n",devi->isahd.id_unit); return; } if (com->tp && (com->tp->t_state & TS_ISOPEN)) { com->gone = 1; - printf("sio%d: unload\n", dp->isahd.id_unit); + printf("sio%d: unload\n", devi->isahd.id_unit); com->tp->t_gen++; ttyclose(com->tp); ttwakeup(com->tp); @@ -569,7 +556,7 @@ siounload(struct pccard_dev *dp) com_addr(com->unit) = NULL; bzero(com, sizeof *com); free(com,M_TTYS); - printf("sio%d: unload,gone\n", dp->isahd.id_unit); + printf("sio%d: unload,gone\n", devi->isahd.id_unit); } } @@ -578,17 +565,30 @@ siounload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -card_intr(struct pccard_dev *dp) +card_intr(struct pccard_devinfo *devi) { struct com_s *com; COM_LOCK(); - com = com_addr(dp->isahd.id_unit); - if (com && !com_addr(dp->isahd.id_unit)->gone) - siointr1(com_addr(dp->isahd.id_unit)); + com = com_addr(devi->isahd.id_unit); + if (com && !com_addr(devi->isahd.id_unit)->gone) + siointr1(com_addr(devi->isahd.id_unit)); COM_UNLOCK(); return(1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * sioinit with first=0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +siosuspend(struct pccard_devinfo *devi) +{ + printf("sio%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ static int sioprobe(dev) @@ -613,7 +613,7 @@ sioprobe(dev) for (xdev = isa_devtab_tty; xdev->id_driver != NULL; xdev++) if (xdev->id_driver == &siodriver && xdev->id_enabled) outb(xdev->id_iobase + com_mcr, 0); -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index 21666fb..93b47ce 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -11,7 +11,7 @@ # device lines is present in the ./LINT configuration file. If you are # in doubt as to the purpose or necessity of a line, check first in LINT. # -# $Id: GENERIC,v 1.97 1997/10/08 17:05:03 nate Exp $ +# $Id: GENERIC,v 1.98 1997/10/18 10:59:06 joerg Exp $ machine "i386" cpu "I386_CPU" @@ -109,9 +109,9 @@ device npx0 at isa? port "IO_NPX" irq 13 vector npxintr device apm0 at isa? disable flags 0x31 # Advanced Power Management # PCCARD (PCMCIA) support -#controller crd0 -#device pcic0 at crd? -#device pcic1 at crd? +#controller card0 +#device pcic0 at card? +#device pcic1 at card? device sio0 at isa? port "IO_COM1" flags 0x10 tty irq 4 vector siointr device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index 880e7a1..0023a96 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.374 1997/10/18 10:10:36 peter Exp $ +# $Id: LINT,v 1.375 1997/10/18 10:59:16 joerg Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1287,11 +1287,11 @@ device bktr0 # # PCCARD/PCMCIA # -# crd: slot controller +# card: slot controller # pcic: slots -controller crd0 -controller pcic0 at crd? -controller pcic1 at crd? +controller card0 +controller pcic0 at card? +controller pcic1 at card? # # Laptop/Notebook options: diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 880e7a1..0023a96 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.374 1997/10/18 10:10:36 peter Exp $ +# $Id: LINT,v 1.375 1997/10/18 10:59:16 joerg Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1287,11 +1287,11 @@ device bktr0 # # PCCARD/PCMCIA # -# crd: slot controller +# card: slot controller # pcic: slots -controller crd0 -controller pcic0 at crd? -controller pcic1 at crd? +controller card0 +controller pcic0 at card? +controller pcic1 at card? # # Laptop/Notebook options: diff --git a/sys/i386/conf/SMP-GENERIC b/sys/i386/conf/SMP-GENERIC index 278c4a5..38b02ad 100644 --- a/sys/i386/conf/SMP-GENERIC +++ b/sys/i386/conf/SMP-GENERIC @@ -11,7 +11,7 @@ # device lines is present in the ./LINT configuration file. If you are # in doubt as to the purpose or necessity of a line, check first in LINT. # -# $Id: SMP-GENERIC,v 1.1 1997/07/26 00:54:07 smp Exp smp $ +# $Id: SMP-GENERIC,v 1.7 1997/07/26 01:46:02 fsmp Exp $ machine "i386" # SMP does NOT support 386/486 CPUs. @@ -127,9 +127,9 @@ device npx0 at isa? port "IO_NPX" irq 13 vector npxintr device apm0 at isa? disable flags 0x31 # Advanced Power Management # PCCARD (PCMCIA) support -#controller crd0 -#device pcic0 at crd? -#device pcic1 at crd? +#controller card0 +#device pcic0 at card? +#device pcic1 at card? device sio0 at isa? port "IO_COM1" tty irq 4 vector siointr device sio1 at isa? port "IO_COM2" tty irq 3 vector siointr diff --git a/sys/i386/conf/majors.i386 b/sys/i386/conf/majors.i386 index e5ebe05..5344a0e 100644 --- a/sys/i386/conf/majors.i386 +++ b/sys/i386/conf/majors.i386 @@ -1,4 +1,4 @@ -$Id: majors.i386,v 1.17 1997/08/28 12:18:09 jkh Exp $ +$Id: majors.i386,v 1.18 1997/09/23 08:45:33 jkh Exp $ Hopefully, this list will one day be obsoleted by DEVFS, but for now this is the current allocation of device major numbers. @@ -88,7 +88,7 @@ chrdev name comments 47 gsc Genius Scanner 48 cy Cyclades 49 ssc SCSI super device -50 crd pcmcia cards +50 card pcmcia cards 51 joy joystick 52 tun IP tunnel device 53 snp tty snoop diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c index 55df9bb..0728769 100644 --- a/sys/i386/i386/autoconf.c +++ b/sys/i386/i386/autoconf.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91 - * $Id: autoconf.c,v 1.76 1997/09/21 21:38:03 gibbs Exp $ + * $Id: autoconf.c,v 1.77 1997/09/23 17:14:37 bde Exp $ */ /* @@ -84,8 +84,8 @@ #include <pci/pcivar.h> #endif -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <pccard/driver.h> #endif @@ -223,7 +223,7 @@ configure(dummy) isa_configure(); #endif -#if NCRD > 0 +#if NCARD > 0 /* After everyone else has a chance at grabbing resources */ pccard_configure(); #endif diff --git a/sys/i386/isa/aic6360.c b/sys/i386/isa/aic6360.c index eede184..8622ef4 100644 --- a/sys/i386/isa/aic6360.c +++ b/sys/i386/isa/aic6360.c @@ -31,7 +31,7 @@ */ /* - * $Id: aic6360.c,v 1.31 1997/09/21 21:40:51 gibbs Exp $ + * $Id: aic6360.c,v 1.32 1997/10/21 17:57:31 nate Exp $ * * Acknowledgements: Many of the algorithms used in this driver are * inspired by the work of Julian Elischer (julian@tfs.com) and @@ -698,69 +698,58 @@ static struct scsi_device aic_dev = { /* PCCARD suport */ -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/driver.h> #include <pccard/slot.h> -static int aic_card_intr(struct pccard_dev *); /* Interrupt handler */ -void aicunload(struct pccard_dev *); /* Disable driver */ -void aicsuspend(struct pccard_dev *); /* Suspend driver */ -static int aicinit(struct pccard_dev *, int); /* init device */ +static int aicinit(struct pccard_devinfo *, int); /* init device */ +void aicunload(struct pccard_devinfo *); /* Disable driver */ +static int aic_card_intr(struct pccard_devinfo *); /* Interrupt handler */ +void aicsuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv aic_info = { +static struct pccard_device aic_info = { "aic", - aic_card_intr, + aicinit, aicunload, + aic_card_intr, aicsuspend, - aicinit, 0, /* Attributes - presently unused */ &bio_imask /* Interrupt mask for device */ }; /* - * Called when a power down is wanted. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * feinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -void -aicsuspend(struct pccard_dev *dp) -{ - printf("aic%d: suspending\n", dp->isahd.id_unit); -} - -/* * Initialize the device - called from Slot manager. + * * if first is set, then initially check for * the device's existence before initialising it. * Once initialised, the device table may be set up. */ int -aicinit(struct pccard_dev *dp, int first) +aicinit(struct pccard_devinfo *devi, int first) { static int already_aicinit[NAIC]; + /* validate unit number */ if (first) { - if (dp->isahd.id_unit >= NAIC) + if (devi->isahd.id_unit >= NAIC) return(ENODEV); /* Make sure it isn't already initialised */ - if (already_aicinit[dp->isahd.id_unit] == 1) { - if (aicattach(&dp->isahd) == 0) + if (already_aicinit[devi->isahd.id_unit] == 1) { + if (aicattach(&devi->isahd) == 0) return(ENXIO); return(0); - } + } /* * Probe the device. If a value is returned, the * device was found at the location. */ - if (aicprobe(&dp->isahd) == 0) + if (aicprobe(&devi->isahd) == 0) return(ENXIO); - if (aicattach(&dp->isahd) == 0) + if (aicattach(&devi->isahd) == 0) return(ENXIO); } /* @@ -770,7 +759,7 @@ aicinit(struct pccard_dev *dp, int first) * reset (and possibly restart) the hardware, but * I am not sure of the best way to do this... */ - already_aicinit[dp->isahd.id_unit] = 1; + already_aicinit[devi->isahd.id_unit] = 1; return(0); } @@ -784,14 +773,14 @@ aicinit(struct pccard_dev *dp, int first) * read and write do not hang. */ void -aicunload(struct pccard_dev *dp) +aicunload(struct pccard_devinfo *devi) { - printf("aic%d: unload\n", dp->isahd.id_unit); + printf("aic%d: unload\n", devi->isahd.id_unit); #if 0 - aicstop(dp->isahd.id_unit); + aicstop(devi->isahd.id_unit); #endif #ifdef SCSI_DETACH - aicdetach(&dp->isahd); + aicdetach(&devi->isahd); #endif } @@ -799,12 +788,25 @@ aicunload(struct pccard_dev *dp) * card_intr - Shared interrupt called from front end of PC-Card handler. */ static int -aic_card_intr(struct pccard_dev *dp) +aic_card_intr(struct pccard_devinfo *devi) { - aicintr(dp->isahd.id_unit); + aicintr(devi->isahd.id_unit); return(1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is wanted. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * feinit with first=0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +void +aicsuspend(struct pccard_devinfo *devi) +{ + printf("aic%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ /* * INITIALIZATION ROUTINES (probe, attach ++) @@ -819,7 +821,7 @@ aicprobe(dev) struct isa_device *dev; { struct aic_data *aic; -#if NCRD > 0 +#if NCARD > 0 int unit = dev->id_unit; int aic_reg_drv[NAIC]; static int aic_already_init; @@ -833,7 +835,7 @@ aicprobe(dev) } dev->id_unit = unit; -#if NCRD > 0 +#if NCARD > 0 if (!aic_reg_drv[unit]) aic_reg_drv[unit] = 1; @@ -1427,7 +1429,7 @@ aic_done(acb) * longer busy. This code is sickening, but it works. */ if (acb == aic->nexus) { -#if NAPM > 0 && NCRD > 0 +#if NAPM > 0 && NCARD > 0 /* SlimSCSI dies without this when it resumes from suspend */ aic->nexus = NULL; #endif diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c index 7b632b7..d839eba 100644 --- a/sys/i386/isa/if_ed.c +++ b/sys/i386/isa/if_ed.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ed.c,v 1.121 1997/09/10 00:17:39 davidg Exp $ + * $Id: if_ed.c,v 1.122 1997/10/03 16:26:15 davidg Exp $ */ /* @@ -151,8 +151,8 @@ static int ed_probe_HP_pclanp __P((struct isa_device *)); void *ed_attach_NE2000_pci __P((int, int)); #endif -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 static int ed_probe_pccard __P((struct isa_device *, u_char *)); #endif @@ -182,7 +182,7 @@ static void ed_setrcr(struct ed_softc *); static u_long ds_crc(u_char *ep); -#if NCRD > 0 +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/driver.h> @@ -191,68 +191,46 @@ static u_long ds_crc(u_char *ep); /* * PC-Card (PCMCIA) specific code. */ -static int card_intr(struct pccard_dev *); /* Interrupt handler */ -static void edunload(struct pccard_dev *); /* Disable driver */ -static void edsuspend(struct pccard_dev *); /* Suspend driver */ -static int edinit(struct pccard_dev *, int); /* init device */ +static int edinit(struct pccard_devinfo *, int); /* init device */ +static void edunload(struct pccard_devinfo *); /* Disable driver */ +static int card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void edsuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv ed_info = { +static struct pccard_device ed_info = { "ed", - card_intr, + edinit, edunload, + card_intr, edsuspend, - edinit, 0, /* Attributes - presently unused */ &net_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * edinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -edsuspend(struct pccard_dev *dp) -{ - struct ed_softc *sc = &ed_softc[dp->isahd.id_unit]; - /* - * Some 'ed' cards will generate a interrupt as they go away, - * and by the time the interrupt handler gets to the card, - * the interrupt can't be cleared. - * By setting gone here, we tell the handler to ignore the - * interrupt when it happens. - */ - sc->gone = 1; /* avoid spinning endlessly in interrupt handler */ - - printf("ed%d: suspending\n", dp->isahd.id_unit); -} - -/* * Initialize the device - called from Slot manager. + * * If first is set, then check for the device's existence * before initializing it. Once initialized, the device table may * be set up. */ static int -edinit(struct pccard_dev *dp, int first) +edinit(struct pccard_devinfo *devi, int first) { - struct ed_softc *sc = &ed_softc[dp->isahd.id_unit]; + struct ed_softc *sc = &ed_softc[devi->isahd.id_unit]; /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= NED) + if (devi->isahd.id_unit >= NED) return(ENODEV); /* * Probe the device. If a value is returned, the * device was found at the location. */ sc->gone = 0; - if (ed_probe_pccard(&dp->isahd,dp->misc)==0) + if (ed_probe_pccard(&devi->isahd, devi->misc) == 0) return(ENXIO); - if (ed_attach_isa(&dp->isahd)==0) + if (ed_attach_isa(&devi->isahd) == 0) return(ENXIO); } else { sc->gone = 0; /* reenable after a suspend */ @@ -277,19 +255,19 @@ edinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -edunload(struct pccard_dev *dp) +edunload(struct pccard_devinfo *devi) { - struct ed_softc *sc = &ed_softc[dp->isahd.id_unit]; + struct ed_softc *sc = &ed_softc[devi->isahd.id_unit]; struct ifnet *ifp = &sc->arpcom.ac_if; if (sc->gone) { - printf("ed%d: already unloaded\n", dp->isahd.id_unit); + printf("ed%d: already unloaded\n", devi->isahd.id_unit); return; } ifp->if_flags &= ~IFF_RUNNING; if_down(ifp); sc->gone = 1; - printf("ed%d: unload\n", dp->isahd.id_unit); + printf("ed%d: unload\n", devi->isahd.id_unit); } /* @@ -297,12 +275,35 @@ edunload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -card_intr(struct pccard_dev *dp) +card_intr(struct pccard_devinfo *devi) { - edintr_sc(&ed_softc[dp->isahd.id_unit]); + edintr_sc(&ed_softc[devi->isahd.id_unit]); return(1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * edinit with first = 0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +edsuspend(struct pccard_devinfo *devi) +{ + struct ed_softc *sc = &ed_softc[devi->isahd.id_unit]; + /* + * Some 'ed' cards will generate a interrupt as they go away, + * and by the time the interrupt handler gets to the card, + * the interrupt can't be cleared. + * By setting gone here, we tell the handler to ignore the + * interrupt when it happens. + */ + sc->gone = 1; /* avoid spinning endlessly in interrupt handler */ + + printf("ed%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ struct isa_driver eddriver = { ed_probe, @@ -378,7 +379,7 @@ ed_probe(isa_dev) { int nports; -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. @@ -1321,8 +1322,7 @@ ed_probe_Novell(isa_dev) isa_dev->id_unit, isa_dev->id_flags); } -#if NCRD > 0 - +#if NCARD > 0 /* * Probe framework for pccards. Replicates the standard framework, * minus the pccard driver registration and ignores the ether address @@ -1346,7 +1346,7 @@ ed_probe_pccard(isa_dev, ether) return (0); } -#endif /* NCRD > 0 */ +#endif /* NCARD > 0 */ #define ED_HPP_TEST_SIZE 16 diff --git a/sys/i386/isa/if_ep.c b/sys/i386/isa/if_ep.c index 992fac3..84d578e 100644 --- a/sys/i386/isa/if_ep.c +++ b/sys/i386/isa/if_ep.c @@ -38,7 +38,7 @@ */ /* - * $Id: if_ep.c,v 1.60 1997/09/02 01:18:13 bde Exp $ + * $Id: if_ep.c,v 1.61 1997/10/14 06:56:08 itojun Exp $ * * Promiscuous mode added and interrupt logic slightly changed * to reduce the number of adapter failures. Transceiver select @@ -142,9 +142,9 @@ struct isa_driver epdriver = { 0 }; -#include "crd.h" +#include "card.h" -#if NCRD > 0 +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/driver.h> @@ -153,42 +153,31 @@ struct isa_driver epdriver = { /* * PC-Card (PCMCIA) specific code. */ -static int card_intr __P((struct pccard_dev *)); -static void ep_unload __P((struct pccard_dev *)); -static void ep_suspend __P((struct pccard_dev *)); -static int ep_pccard_init __P((struct pccard_dev *, int)); -static int ep_pccard_attach __P((struct pccard_dev *)); +static int ep_pccard_init __P((struct pccard_devinfo *, int)); +static int ep_pccard_attach __P((struct pccard_devinfo *)); +static void ep_unload __P((struct pccard_devinfo *)); +static int card_intr __P((struct pccard_devinfo *)); +static void ep_suspend __P((struct pccard_devinfo *)); -static struct pccard_drv ep_info = { +static struct pccard_device ep_info = { "ep", - card_intr, + ep_pccard_init, ep_unload, + card_intr, ep_suspend, - ep_pccard_init, 0, /* Attributes - presently unused */ &net_imask }; -/* Resume is done by executing ep_pccard_init(dp, 0). */ -static void -ep_suspend(dp) - struct pccard_dev *dp; -{ - struct ep_softc *sc = ep_softc[dp->isahd.id_unit]; - - printf("ep%d: suspending\n", dp->isahd.id_unit); - sc->gone = 1; -} - /* - * + * Initialize the device - called from Slot manager. */ static int -ep_pccard_init(dp, first) - struct pccard_dev *dp; +ep_pccard_init(devi, first) + struct pccard_devinfo *devi; int first; { - struct isa_device *is = &dp->isahd; + struct isa_device *is = &devi->isahd; struct ep_softc *sc = ep_softc[is->id_unit]; struct ep_board *epb; int i; @@ -210,41 +199,36 @@ ep_pccard_init(dp, first) epb->epb_used = 1; epb->prod_id = get_e(sc, EEPROM_PROD_ID); - if (epb->prod_id != 0x9058) { /* 3C589's product id */ - if (first) { + /* 3C589's product id? */ + if (epb->prod_id != 0x9058) { + if (first) printf("ep%d: failed to come ready.\n", is->id_unit); - } else { + else printf("ep%d: failed to resume.\n", is->id_unit); - } return (ENXIO); } epb->res_cfg = get_e(sc, EEPROM_RESOURCE_CFG); - for (i = 0; i < 3; i++) { - sc->epb->eth_addr[i] = get_e(sc, EEPROM_NODE_ADDR_0 + i); - } + for (i = 0; i < 3; i++) + sc->epb->eth_addr[i] = get_e(sc, EEPROM_NODE_ADDR_0 + i); if (first) { - if (ep_pccard_attach(dp) == 0) { + if (ep_pccard_attach(devi) == 0) return (ENXIO); - } sc->arpcom.ac_if.if_snd.ifq_maxlen = ifqmaxlen; - } - - if (!first) { + } else { sc->gone = 0; printf("ep%d: resumed.\n", is->id_unit); epinit(sc); } - return (0); } static int -ep_pccard_attach(dp) - struct pccard_dev *dp; +ep_pccard_attach(devi) + struct pccard_devinfo *devi; { - struct isa_device *is = &dp->isahd; + struct isa_device *is = &devi->isahd; struct ep_softc *sc = ep_softc[is->id_unit]; u_short config; @@ -275,18 +259,18 @@ ep_pccard_attach(dp) } static void -ep_unload(dp) - struct pccard_dev *dp; +ep_unload(devi) + struct pccard_devinfo *devi; { - struct ep_softc *sc = ep_softc[dp->isahd.id_unit]; + struct ep_softc *sc = ep_softc[devi->isahd.id_unit]; if (sc->gone) { - printf("ep%d: already unloaded\n", dp->isahd.id_unit); + printf("ep%d: already unloaded\n", devi->isahd.id_unit); return; } sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING; sc->gone = 1; - printf("ep%d: unload\n", dp->isahd.id_unit); + printf("ep%d: unload\n", devi->isahd.id_unit); } /* @@ -294,14 +278,24 @@ ep_unload(dp) * front end of PC-Card handler. */ static int -card_intr(dp) - struct pccard_dev *dp; +card_intr(devi) + struct pccard_devinfo *devi; { - epintr(dp->isahd.id_unit); + epintr(devi->isahd.id_unit); return(1); } -#endif /* NCRD > 0 */ +/* Resume is done by executing ep_pccard_init(devi, 0). */ +static void +ep_suspend(devi) + struct pccard_devinfo *devi; +{ + struct ep_softc *sc = ep_softc[devi->isahd.id_unit]; + + printf("ep%d: suspending\n", devi->isahd.id_unit); + sc->gone = 1; +} +#endif /* NCARD > 0 */ static int eeprom_rdy(sc) @@ -309,7 +303,8 @@ eeprom_rdy(sc) { int i; - for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++); + for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) + continue; if (i >= MAX_EEPROMBUSY) { printf("ep%d: eeprom failed to come ready.\n", sc->unit); return (0); @@ -500,9 +495,9 @@ ep_isa_probe(is) struct ep_board *epb; u_short k; -#if NCRD > 0 +#if NCARD > 0 pccard_add_driver(&ep_info); -#endif /* NCRD > 0 */ +#endif if ((epb = ep_look_for_board_at(is)) == 0) return (0); diff --git a/sys/i386/isa/if_fe.c b/sys/i386/isa/if_fe.c index b53bfe7..00c1b70 100644 --- a/sys/i386/isa/if_fe.c +++ b/sys/i386/isa/if_fe.c @@ -21,7 +21,7 @@ */ /* - * $Id: if_fe.c,v 1.28 1997/03/24 11:32:49 bde Exp $ + * $Id: if_fe.c,v 1.29 1997/07/20 14:09:59 bde Exp $ * * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. * To be used with FreeBSD 2.x @@ -71,7 +71,6 @@ */ #include "fe.h" -#include "crd.h" #include "bpfilter.h" #include <sys/param.h> @@ -120,7 +119,8 @@ #include <i386/isa/icu.h> /* PCCARD suport */ -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <sys/select.h> #include <pccard/card.h> #include <pccard/slot.h> @@ -247,7 +247,7 @@ static int fe_probe_fmv ( DEVICE *, struct fe_softc * ); static int fe_probe_ati ( DEVICE *, struct fe_softc * ); static void fe_init_ati ( struct fe_softc * ); static int fe_probe_gwy ( DEVICE *, struct fe_softc * ); -#if NCRD > 0 +#if NCARD > 0 static int fe_probe_mbh ( DEVICE *, struct fe_softc * ); static void fe_init_mbh ( struct fe_softc * ); static int fe_probe_tdk ( DEVICE *, struct fe_softc * ); @@ -318,52 +318,41 @@ outblk ( struct fe_softc * sc, int offs, u_char const * mem, int len ) } /* PCCARD Support */ -#if NCRD > 0 +#if NCARD > 0 /* * PC-Card (PCMCIA) specific code. */ -static int fe_card_intr(struct pccard_dev *); /* Interrupt handler */ -static void feunload(struct pccard_dev *); /* Disable driver */ -static void fesuspend(struct pccard_dev *); /* Suspend driver */ -static int feinit(struct pccard_dev *, int); /* init device */ +static int feinit(struct pccard_devinfo *, int); /* init device */ +static void feunload(struct pccard_devinfo *); /* Disable driver */ +static int fe_card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void fesuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv fe_info = { +static struct pccard_device fe_info = { "fe", - fe_card_intr, + feinit, feunload, + fe_card_intr, fesuspend, - feinit, 0, /* Attributes - presently unused */ &net_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * feinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -fesuspend(struct pccard_dev *dp) -{ - printf("fe%d: suspending\n", dp->isahd.id_unit); -} - -/* - * Initialize the device - called from Slot manager. + * Initialize the device - called from Slot manager. + * * if first is set, then initially check for * the device's existence before initializing it. * Once initialized, the device table may be set up. */ static int -feinit(struct pccard_dev *dp, int first) +feinit(struct pccard_devinfo *devi, int first) { - /* validate unit number. */ struct fe_softc *sc; + + /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= NFE) + if (devi->isahd.id_unit >= NFE) return (ENODEV); /* * Probe the device. If a value is returned, @@ -373,28 +362,28 @@ feinit(struct pccard_dev *dp, int first) printf("Start Probe\n"); #endif /* Initialize "minimum" parts of our softc. */ - sc = &fe_softc[dp->isahd.id_unit]; - sc->sc_unit = dp->isahd.id_unit; - sc->iobase = dp->isahd.id_iobase; + sc = &fe_softc[devi->isahd.id_unit]; + sc->sc_unit = devi->isahd.id_unit; + sc->iobase = devi->isahd.id_iobase; /* Use Ethernet address got from CIS, if one is available. */ - if ((dp->misc[0] & 0x03) == 0x00 - && (dp->misc[0] | dp->misc[1] | dp->misc[2]) != 0) { + if ((devi->misc[0] & 0x03) == 0x00 + && (devi->misc[0] | devi->misc[1] | devi->misc[2]) != 0) { /* Yes, it looks like a valid Ether address. */ - bcopy(dp->misc, sc->sc_enaddr, ETHER_ADDR_LEN); + bcopy(devi->misc, sc->sc_enaddr, ETHER_ADDR_LEN); } else { /* Indicate we have no Ether address in CIS. */ bzero(sc->sc_enaddr, ETHER_ADDR_LEN); } /* Probe supported PC card models. */ - if (fe_probe_tdk(&dp->isahd, sc) == 0 - && fe_probe_mbh(&dp->isahd, sc) == 0) + if (fe_probe_tdk(&devi->isahd, sc) == 0 && + fe_probe_mbh(&devi->isahd, sc) == 0) return (ENXIO); #if FE_DEBUG >= 2 printf("Start attach\n"); #endif - if (fe_attach(&dp->isahd) == 0) + if (fe_attach(&devi->isahd) == 0) return (ENXIO); } /* @@ -417,11 +406,11 @@ feinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -feunload(struct pccard_dev *dp) +feunload(struct pccard_devinfo *devi) { - struct fe_softc *sc = &fe_softc[dp->isahd.id_unit]; - printf("fe%d: unload\n", dp->isahd.id_unit); - fe_stop(dp->isahd.id_unit); + struct fe_softc *sc = &fe_softc[devi->isahd.id_unit]; + printf("fe%d: unload\n", devi->isahd.id_unit); + fe_stop(devi->isahd.id_unit); } /* @@ -429,12 +418,25 @@ feunload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -fe_card_intr(struct pccard_dev *dp) +fe_card_intr(struct pccard_devinfo *devi) { - feintr(dp->isahd.id_unit); + feintr(devi->isahd.id_unit); return (1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * feinit with first=0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +fesuspend(struct pccard_devinfo *devi) +{ + printf("fe%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ /* @@ -476,7 +478,7 @@ static struct fe_probe_list const fe_probe_list [] = static int fe_probe ( DEVICE * dev ) { -#if NCRD > 0 +#if NCARD > 0 static int fe_already_init; #endif struct fe_softc * sc; @@ -490,7 +492,7 @@ fe_probe ( DEVICE * dev ) sc = &fe_softc[ dev->id_unit ]; sc->sc_unit = dev->id_unit; -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. @@ -499,7 +501,7 @@ fe_probe ( DEVICE * dev ) pccard_add_driver(&fe_info); fe_already_init = 1; } -#endif /* NCRD > 0 */ +#endif /* Probe each possibility, one at a time. */ for ( list = fe_probe_list; list->probe != NULL; list++ ) { @@ -1239,7 +1241,7 @@ fe_probe_gwy ( DEVICE * dev, struct fe_softc * sc ) return 32; } -#if NCRD > 0 +#if NCARD > 0 /* * Probe and initialization for Fujitsu MBH10302 PCMCIA Ethernet interface. * Note that this is for 10302 only; MBH10304 is handled by fe_probe_tdk(). @@ -1371,9 +1373,6 @@ fe_init_mbh ( struct fe_softc * sc ) outb( sc->ioaddr[ FE_MBH0 ], FE_MBH0_MAGIC | FE_MBH0_INTR_ENABLE ); } -#endif /* NCRD > 0 */ - -#if NCRD > 0 /* * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface. * by MASUI Kenji <masui@cs.titech.ac.jp> @@ -1476,7 +1475,7 @@ fe_probe_tdk ( DEVICE * dev, struct fe_softc * sc ) */ return 16; } -#endif +#endif /* NCARD > 0 */ /* * Install interface into kernel networking data structures @@ -1484,7 +1483,7 @@ fe_probe_tdk ( DEVICE * dev, struct fe_softc * sc ) static int fe_attach ( DEVICE * dev ) { -#if NCRD > 0 +#if NCARD > 0 static int already_ifattach[NFE]; #endif struct fe_softc *sc = &fe_softc[dev->id_unit]; @@ -1552,14 +1551,14 @@ fe_attach ( DEVICE * dev ) } /* Attach and stop the interface. */ -#if NCRD > 0 +#if NCARD > 0 if (already_ifattach[dev->id_unit] != 1) { if_attach(&sc->sc_if); already_ifattach[dev->id_unit] = 1; } #else if_attach(&sc->sc_if); -#endif /* NCRD > 0 */ +#endif fe_stop(sc->sc_unit); /* This changes the state to IDLE. */ ether_ifattach(&sc->sc_if); diff --git a/sys/i386/isa/if_ze.c b/sys/i386/isa/if_ze.c index c854a48..94349bb 100644 --- a/sys/i386/isa/if_ze.c +++ b/sys/i386/isa/if_ze.c @@ -47,13 +47,13 @@ */ /* - * $Id: if_ze.c,v 1.44 1997/07/20 14:10:02 bde Exp $ + * $Id: if_ze.c,v 1.45 1997/07/20 23:07:39 fsmp Exp $ */ /* XXX - Don't mix different PCCARD support code */ -#include "crd.h" +#include "card.h" #include "pcic.h" -#if NCRD > 0 || NPCIC > 0 +#if NCARD > 0 || NPCIC > 0 #ifndef LINT_PCCARD_HACK #error "Dedicated PCMCIA drivers and generic PCMCIA support can't be mixed" #else diff --git a/sys/i386/isa/if_zp.c b/sys/i386/isa/if_zp.c index 7c9ecb3..5126c81 100644 --- a/sys/i386/isa/if_zp.c +++ b/sys/i386/isa/if_zp.c @@ -34,7 +34,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * From: if_ep.c,v 1.9 1994/01/25 10:46:29 deraadt Exp $ - * $Id: if_zp.c,v 1.38 1997/07/20 14:10:02 bde Exp $ + * $Id: if_zp.c,v 1.39 1997/09/21 21:41:14 gibbs Exp $ */ /*- * TODO: @@ -101,9 +101,9 @@ */ /* XXX - Don't mix different PCCARD support code */ -#include "crd.h" +#include "card.h" #include "pcic.h" -#if NCRD > 0 || NPCIC > 0 +#if NCARD > 0 || NPCIC > 0 #ifndef LINT_PCCARD_HACK #error "Dedicated PCMCIA drivers and generic PCMCIA support can't be mixed" #else diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c index 39c6470..9697556 100644 --- a/sys/i386/isa/sio.c +++ b/sys/i386/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.183 1997/09/21 21:41:40 gibbs Exp $ + * $Id: sio.c,v 1.184 1997/10/12 20:23:30 phk Exp $ */ #include "opt_comconsole.h" @@ -87,8 +87,8 @@ #endif #include <i386/isa/ic/ns16550.h> -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <pccard/card.h> #include <pccard/driver.h> #include <pccard/slot.h> @@ -470,63 +470,50 @@ sysctl_machdep_comdefaultrate SYSCTL_HANDLER_ARGS SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); -#if NCRD > 0 +#if NCARD > 0 /* * PC-Card (PCMCIA) specific code. */ -static int card_intr(struct pccard_dev *); /* Interrupt handler */ -static void siounload(struct pccard_dev *); /* Disable driver */ -static void siosuspend(struct pccard_dev *); /* Suspend driver */ -static int sioinit(struct pccard_dev *, int); /* init device */ +static int sioinit(struct pccard_devinfo *, int); /* init device */ +static void siounload(struct pccard_devinfo *); /* Disable driver */ +static int card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void siosuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv sio_info = { +static struct pccard_device sio_info = { driver_name, - card_intr, + sioinit, siounload, + card_intr, siosuspend, - sioinit, 0, /* Attributes - presently unused */ &tty_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * sioinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -siosuspend(struct pccard_dev *dp) -{ - printf("sio%d: suspending\n", dp->isahd.id_unit); -} - -/* * Initialize the device - called from Slot manager. + * * If first is set, then check for the device's existence * before initializing it. Once initialized, the device table may * be set up. */ int -sioinit(struct pccard_dev *dp, int first) +sioinit(struct pccard_devinfo *devi, int first) { - /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= (NSIOTOT)) + if (devi->isahd.id_unit >= (NSIOTOT)) return(ENODEV); /* Make sure it isn't already probed. */ - if (com_addr(dp->isahd.id_unit)) + if (com_addr(devi->isahd.id_unit)) return(EBUSY); /* * Probe the device. If a value is returned, the * device was found at the location. */ - if (sioprobe(&dp->isahd)==0) + if (sioprobe(&devi->isahd) == 0) return(ENXIO); - if (sioattach(&dp->isahd)==0) + if (sioattach(&devi->isahd) == 0) return(ENXIO); } /* @@ -549,18 +536,18 @@ sioinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -siounload(struct pccard_dev *dp) +siounload(struct pccard_devinfo *devi) { struct com_s *com; - com = com_addr(dp->isahd.id_unit); + com = com_addr(devi->isahd.id_unit); if (!com->iobase) { - printf("sio%d already unloaded!\n",dp->isahd.id_unit); + printf("sio%d already unloaded!\n",devi->isahd.id_unit); return; } if (com->tp && (com->tp->t_state & TS_ISOPEN)) { com->gone = 1; - printf("sio%d: unload\n", dp->isahd.id_unit); + printf("sio%d: unload\n", devi->isahd.id_unit); com->tp->t_gen++; ttyclose(com->tp); ttwakeup(com->tp); @@ -569,7 +556,7 @@ siounload(struct pccard_dev *dp) com_addr(com->unit) = NULL; bzero(com, sizeof *com); free(com,M_TTYS); - printf("sio%d: unload,gone\n", dp->isahd.id_unit); + printf("sio%d: unload,gone\n", devi->isahd.id_unit); } } @@ -578,17 +565,30 @@ siounload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -card_intr(struct pccard_dev *dp) +card_intr(struct pccard_devinfo *devi) { struct com_s *com; COM_LOCK(); - com = com_addr(dp->isahd.id_unit); - if (com && !com_addr(dp->isahd.id_unit)->gone) - siointr1(com_addr(dp->isahd.id_unit)); + com = com_addr(devi->isahd.id_unit); + if (com && !com_addr(devi->isahd.id_unit)->gone) + siointr1(com_addr(devi->isahd.id_unit)); COM_UNLOCK(); return(1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * sioinit with first=0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +siosuspend(struct pccard_devinfo *devi) +{ + printf("sio%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ static int sioprobe(dev) @@ -613,7 +613,7 @@ sioprobe(dev) for (xdev = isa_devtab_tty; xdev->id_driver != NULL; xdev++) if (xdev->id_driver == &siodriver && xdev->id_enabled) outb(xdev->id_iobase + com_mcr, 0); -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. diff --git a/sys/isa/sio.c b/sys/isa/sio.c index 39c6470..9697556 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.183 1997/09/21 21:41:40 gibbs Exp $ + * $Id: sio.c,v 1.184 1997/10/12 20:23:30 phk Exp $ */ #include "opt_comconsole.h" @@ -87,8 +87,8 @@ #endif #include <i386/isa/ic/ns16550.h> -#include "crd.h" -#if NCRD > 0 +#include "card.h" +#if NCARD > 0 #include <pccard/card.h> #include <pccard/driver.h> #include <pccard/slot.h> @@ -470,63 +470,50 @@ sysctl_machdep_comdefaultrate SYSCTL_HANDLER_ARGS SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); -#if NCRD > 0 +#if NCARD > 0 /* * PC-Card (PCMCIA) specific code. */ -static int card_intr(struct pccard_dev *); /* Interrupt handler */ -static void siounload(struct pccard_dev *); /* Disable driver */ -static void siosuspend(struct pccard_dev *); /* Suspend driver */ -static int sioinit(struct pccard_dev *, int); /* init device */ +static int sioinit(struct pccard_devinfo *, int); /* init device */ +static void siounload(struct pccard_devinfo *); /* Disable driver */ +static int card_intr(struct pccard_devinfo *); /* Interrupt handler */ +static void siosuspend(struct pccard_devinfo *); /* Suspend driver */ -static struct pccard_drv sio_info = { +static struct pccard_device sio_info = { driver_name, - card_intr, + sioinit, siounload, + card_intr, siosuspend, - sioinit, 0, /* Attributes - presently unused */ &tty_imask /* Interrupt mask for device */ /* XXX - Should this also include net_imask? */ }; /* - * Called when a power down is requested. Shuts down the - * device and configures the device as unavailable (but - * still loaded...). A resume is done by calling - * sioinit with first=0. This is called when the user suspends - * the system, or the APM code suspends the system. - */ -static void -siosuspend(struct pccard_dev *dp) -{ - printf("sio%d: suspending\n", dp->isahd.id_unit); -} - -/* * Initialize the device - called from Slot manager. + * * If first is set, then check for the device's existence * before initializing it. Once initialized, the device table may * be set up. */ int -sioinit(struct pccard_dev *dp, int first) +sioinit(struct pccard_devinfo *devi, int first) { - /* validate unit number. */ if (first) { - if (dp->isahd.id_unit >= (NSIOTOT)) + if (devi->isahd.id_unit >= (NSIOTOT)) return(ENODEV); /* Make sure it isn't already probed. */ - if (com_addr(dp->isahd.id_unit)) + if (com_addr(devi->isahd.id_unit)) return(EBUSY); /* * Probe the device. If a value is returned, the * device was found at the location. */ - if (sioprobe(&dp->isahd)==0) + if (sioprobe(&devi->isahd) == 0) return(ENXIO); - if (sioattach(&dp->isahd)==0) + if (sioattach(&devi->isahd) == 0) return(ENXIO); } /* @@ -549,18 +536,18 @@ sioinit(struct pccard_dev *dp, int first) * read and write do not hang. */ static void -siounload(struct pccard_dev *dp) +siounload(struct pccard_devinfo *devi) { struct com_s *com; - com = com_addr(dp->isahd.id_unit); + com = com_addr(devi->isahd.id_unit); if (!com->iobase) { - printf("sio%d already unloaded!\n",dp->isahd.id_unit); + printf("sio%d already unloaded!\n",devi->isahd.id_unit); return; } if (com->tp && (com->tp->t_state & TS_ISOPEN)) { com->gone = 1; - printf("sio%d: unload\n", dp->isahd.id_unit); + printf("sio%d: unload\n", devi->isahd.id_unit); com->tp->t_gen++; ttyclose(com->tp); ttwakeup(com->tp); @@ -569,7 +556,7 @@ siounload(struct pccard_dev *dp) com_addr(com->unit) = NULL; bzero(com, sizeof *com); free(com,M_TTYS); - printf("sio%d: unload,gone\n", dp->isahd.id_unit); + printf("sio%d: unload,gone\n", devi->isahd.id_unit); } } @@ -578,17 +565,30 @@ siounload(struct pccard_dev *dp) * front end of PC-Card handler. */ static int -card_intr(struct pccard_dev *dp) +card_intr(struct pccard_devinfo *devi) { struct com_s *com; COM_LOCK(); - com = com_addr(dp->isahd.id_unit); - if (com && !com_addr(dp->isahd.id_unit)->gone) - siointr1(com_addr(dp->isahd.id_unit)); + com = com_addr(devi->isahd.id_unit); + if (com && !com_addr(devi->isahd.id_unit)->gone) + siointr1(com_addr(devi->isahd.id_unit)); COM_UNLOCK(); return(1); } -#endif /* NCRD > 0 */ + +/* + * Called when a power down is requested. Shuts down the + * device and configures the device as unavailable (but + * still loaded...). A resume is done by calling + * sioinit with first=0. This is called when the user suspends + * the system, or the APM code suspends the system. + */ +static void +siosuspend(struct pccard_devinfo *devi) +{ + printf("sio%d: suspending\n", devi->isahd.id_unit); +} +#endif /* NCARD > 0 */ static int sioprobe(dev) @@ -613,7 +613,7 @@ sioprobe(dev) for (xdev = isa_devtab_tty; xdev->id_driver != NULL; xdev++) if (xdev->id_driver == &siodriver && xdev->id_enabled) outb(xdev->id_iobase + com_mcr, 0); -#if NCRD > 0 +#if NCARD > 0 /* * If PC-Card probe required, then register driver with * slot manager. diff --git a/sys/pccard/card.h b/sys/pccard/card.h index 7076c95..8be4c25 100644 --- a/sys/pccard/card.h +++ b/sys/pccard/card.h @@ -41,7 +41,7 @@ #define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */ #define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */ #define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */ -#define PIOCSDRV _IOW('P', 6, struct drv_desc) /* Set driver */ +#define PIOCSDRV _IOW('P', 6, struct dev_desc) /* Set driver */ #define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */ #define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */ #define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */ @@ -94,7 +94,7 @@ struct io_desc { /* * Device descriptor for allocation of driver. */ -struct drv_desc { +struct dev_desc { char name[16]; /* Driver name */ int unit; /* Driver unit number */ unsigned long mem; /* Memory address of driver */ diff --git a/sys/pccard/cardinfo.h b/sys/pccard/cardinfo.h index 7076c95..8be4c25 100644 --- a/sys/pccard/cardinfo.h +++ b/sys/pccard/cardinfo.h @@ -41,7 +41,7 @@ #define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */ #define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */ #define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */ -#define PIOCSDRV _IOW('P', 6, struct drv_desc) /* Set driver */ +#define PIOCSDRV _IOW('P', 6, struct dev_desc) /* Set driver */ #define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */ #define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */ #define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */ @@ -94,7 +94,7 @@ struct io_desc { /* * Device descriptor for allocation of driver. */ -struct drv_desc { +struct dev_desc { char name[16]; /* Driver name */ int unit; /* Driver unit number */ unsigned long mem; /* Memory address of driver */ diff --git a/sys/pccard/driver.h b/sys/pccard/driver.h index 7b70b14..3f501e2 100644 --- a/sys/pccard/driver.h +++ b/sys/pccard/driver.h @@ -8,15 +8,15 @@ #define _PCCARD_DRIVER_H_ struct lkm_table; -struct pccard_drv; +struct pccard_device; -void pccard_add_driver __P((struct pccard_drv *)); +void pccard_add_driver __P((struct pccard_device *)); #ifdef _I386_ISA_ISA_DEVICE_H_ /* XXX actually if inthand2_t is declared */ int pccard_alloc_intr __P((u_int imask, inthand2_t *hand, int unit, u_int *maskp, u_int *pcic_imask)); #endif void pccard_configure __P((void)); -void pccard_remove_driver __P((struct pccard_drv *dp)); +void pccard_remove_driver __P((struct pccard_device *)); int pcic_probe __P((void)); /* XXX should be linker set */ #endif /* !_PCCARD_DRIVER_H_ */ diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index fc3d3f3..16fbddb 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -91,13 +91,13 @@ SYSCTL_INT(_machdep_pccard, OID_AUTO, apm_pccard_resume, CTLFLAG_RW, #define MIN(a,b) ((a)<(b)?(a):(b)) -static int allocate_driver(struct slot *, struct drv_desc *); +static int allocate_driver(struct slot *, struct dev_desc *); static void inserted(void *); -static void unregister_device_interrupt(struct pccard_dev *devp); +static void unregister_device_interrupt(struct pccard_devinfo *); static void disable_slot(struct slot *); static int invalid_io_memory(unsigned long, int); -static struct pccard_drv *find_driver(char *); -static void remove_device(struct pccard_dev *); +static struct pccard_device *find_driver(char *); +static void remove_device(struct pccard_devinfo *); static void slot_irq_handler(int); static void power_off_slot(void *); @@ -117,7 +117,7 @@ static struct apmhook r_hook[MAXSLOT]; /* APM resume */ static struct slot *pccard_slots[MAXSLOT]; /* slot entries */ static struct slot *slot_list; static struct slot_ctrl *cont_list; -static struct pccard_drv *drivers; /* Card drivers */ +static struct pccard_device *drivers; /* Card drivers */ /* * The driver interface for read/write uses a block @@ -166,52 +166,54 @@ pccard_configure() * drivers available for allocation. */ void -pccard_add_driver(struct pccard_drv *dp) +pccard_add_driver(struct pccard_device *drv) { /* * If already loaded, then reject the driver. */ - if (find_driver(dp->name)) { - printf("Driver %s already loaded\n", dp->name); + if (find_driver(drv->name)) { + printf("Driver %s already loaded\n", drv->name); return; } - printf("pccard driver %s added\n", dp->name); - dp->next = drivers; - drivers = dp; + printf("pccard driver %s added\n", drv->name); + drv->next = drivers; + drivers = drv; } +#ifdef unused /* * pccard_remove_driver - called to unlink driver * from devices. Usually called when drivers are * are unloaded from kernel. */ void -pccard_remove_driver(struct pccard_drv *dp) +pccard_remove_driver(struct pccard_device *drv) { - struct slot *sp; - struct pccard_dev *devp, *next; - struct pccard_drv *drvp; - - for (sp = slot_list; sp; sp = sp->next) - for (devp = sp->devices; devp; devp = next) { - next = devp->next; - if (devp->drv == dp) - remove_device(devp); + struct slot *slt; + struct pccard_devinfo *devi, *next; + struct pccard_device *drvlist; + + for (slt = slot_list; slt; slt = slt->next) + for (devi = slt->devices; devi; devi = next) { + next = devi->next; + if (devi->drv == drv) + remove_device(devi); } /* * Once all the devices belonging to this driver have been * freed, then remove the driver from the list * of registered drivers. */ - if (drivers == dp) - drivers = dp->next; + if (drivers == drv) + drivers = drv->next; else - for (drvp = drivers; drvp->next; drvp = drvp->next) - if (drvp->next == dp) { - drvp->next = dp->next; + for (drvlist = drivers; drvlist->next; drvlist = drvlist->next) + if (drvlist->next == drv) { + drvlist->next = drv->next; break; } } +#endif /* * pccard_remove_controller - Called when the slot @@ -221,61 +223,61 @@ pccard_remove_driver(struct pccard_drv *dp) * remove the controller structure. Messy... */ void -pccard_remove_controller(struct slot_ctrl *cp) +pccard_remove_controller(struct slot_ctrl *ctrl) { - struct slot *sp, *next, *last = 0; + struct slot *slt, *next, *last = 0; struct slot_ctrl *cl; - struct pccard_dev *dp; + struct pccard_devinfo *devi; - for (sp = slot_list; sp; sp = next) { - next = sp->next; + for (slt = slot_list; slt; slt = next) { + next = slt->next; /* * If this slot belongs to this controller, * remove this slot. */ - if (sp->ctrl == cp) { - pccard_slots[sp->slot] = 0; - if (sp->insert_seq) - untimeout(inserted, (void *)sp, sp->insert_ch); + if (slt->ctrl == ctrl) { + pccard_slots[slt->slotnum] = 0; + if (slt->insert_seq) + untimeout(inserted, (void *)slt, slt->insert_ch); /* * Unload the drivers attached to this slot. */ - while (dp = sp->devices) - remove_device(dp); + while (devi = slt->devices) + remove_device(devi); /* * Disable the slot and unlink the slot from the * slot list. */ - disable_slot(sp); + disable_slot(slt); if (last) last->next = next; else slot_list = next; #if NAPM > 0 apm_hook_disestablish(APM_HOOK_SUSPEND, - &s_hook[sp->slot]); + &s_hook[slt->slotnum]); apm_hook_disestablish(APM_HOOK_RESUME, - &r_hook[sp->slot]); + &r_hook[slt->slotnum]); #endif - if (cp->extra && sp->cdata) - FREE(sp->cdata, M_DEVBUF); - FREE(sp, M_DEVBUF); + if (ctrl->extra && slt->cdata) + FREE(slt->cdata, M_DEVBUF); + FREE(slt, M_DEVBUF); /* - * xx Can't use sp after we have freed it. + * Can't use slot after we have freed it. */ } else { - last = sp; + last = slt; } } /* * Unlink controller structure from controller list. */ - if (cont_list == cp) - cont_list = cp->next; + if (cont_list == ctrl) + cont_list = ctrl->next; else for (cl = cont_list; cl->next; cl = cl->next) - if (cl->next == cp) { - cl->next = cp->next; + if (cl->next == ctrl) { + cl->next = ctrl->next; break; } } @@ -287,12 +289,11 @@ pccard_remove_controller(struct slot_ctrl *cp) static void power_off_slot(void *arg) { - struct slot *sp = (struct slot *)arg; - - sp->pwr_off_pending = 0; + struct slot *slt = (struct slot *)arg; /* Power off the slot. */ - sp->ctrl->disable(sp); + slt->pwr_off_pending = 0; + slt->ctrl->disable(slt); } /* @@ -300,29 +301,29 @@ power_off_slot(void *arg) * the device driver which is handling it, so we can remove it. */ static void -unregister_device_interrupt(struct pccard_dev *devp) +unregister_device_interrupt(struct pccard_devinfo *devi) { - struct slot *sp = devp->sp; + struct slot *slt = devi->slt; int s; - s = splhigh(); - if (devp->running) { - devp->drv->unload(devp); - devp->running = 0; - if (devp->isahd.id_irq && --sp->irqref <= 0) { - printf("Return IRQ=%d\n",sp->irq); - sp->ctrl->mapirq(sp, 0); - INTRDIS(1<<sp->irq); - unregister_intr(sp->irq, slot_irq_handler); - if (devp->drv->imask) - INTRUNMASK(*devp->drv->imask,(1<<sp->irq)); + if (devi->running) { + s = splhigh(); + devi->drv->disable(devi); + devi->running = 0; + if (devi->isahd.id_irq && --slt->irqref <= 0) { + printf("Return IRQ=%d\n",slt->irq); + slt->ctrl->mapirq(slt, 0); + INTRDIS(1<<slt->irq); + unregister_intr(slt->irq, slot_irq_handler); + if (devi->drv->imask) + INTRUNMASK(*devi->drv->imask,(1<<slt->irq)); /* Remove from the PCIC controller imask */ - if (sp->ctrl->imask) - INTRUNMASK(*(sp->ctrl->imask), (1<<sp->irq)); - sp->irq = 0; + if (slt->ctrl->imask) + INTRUNMASK(*(slt->ctrl->imask), (1<<slt->irq)); + slt->irq = 0; } + splx(s); } - splx(s); } /* @@ -330,10 +331,10 @@ unregister_device_interrupt(struct pccard_dev *devp) * the power and unmapping the I/O */ static void -disable_slot(struct slot *sp) +disable_slot(struct slot *slt) { + struct pccard_devinfo *devi; int i; - struct pccard_dev *devp; /* * Unload all the drivers on this slot. Note we can't * remove the device structures themselves, because this @@ -345,23 +346,23 @@ disable_slot(struct slot *sp) * driver is accessing the device and it is removed, then * all bets are off... */ - for (devp = sp->devices; devp; devp = devp->next) - unregister_device_interrupt(devp); + for (devi = slt->devices; devi; devi = devi->next) + unregister_device_interrupt(devi); /* Power off the slot 1/2 second after removal of the card */ - sp->poff_ch = timeout(power_off_slot, (caddr_t)sp, hz / 2); - sp->pwr_off_pending = 1; + slt->poff_ch = timeout(power_off_slot, (caddr_t)slt, hz / 2); + slt->pwr_off_pending = 1; /* De-activate all contexts. */ - for (i = 0; i < sp->ctrl->maxmem; i++) - if (sp->mem[i].flags & MDF_ACTIVE) { - sp->mem[i].flags = 0; - (void)sp->ctrl->mapmem(sp, i); + for (i = 0; i < slt->ctrl->maxmem; i++) + if (slt->mem[i].flags & MDF_ACTIVE) { + slt->mem[i].flags = 0; + (void)slt->ctrl->mapmem(slt, i); } - for (i = 0; i < sp->ctrl->maxio; i++) - if (sp->io[i].flags & IODF_ACTIVE) { - sp->io[i].flags = 0; - (void)sp->ctrl->mapio(sp, i); + for (i = 0; i < slt->ctrl->maxio; i++) + if (slt->io[i].flags & IODF_ACTIVE) { + slt->io[i].flags = 0; + (void)slt->ctrl->mapio(slt, i); } } @@ -372,53 +373,52 @@ disable_slot(struct slot *sp) static int slot_suspend(void *arg) { - struct slot *sp = arg; - struct pccard_dev *dp; + struct slot *slt = arg; + struct pccard_devinfo *devi; - if (sp->state == filled) { - for (dp = sp->devices; dp; dp = dp->next) - (void)dp->drv->suspend(dp); + if (slt->state == filled) { + for (devi = slt->devices; devi; devi = devi->next) + (void)devi->drv->suspend(devi); } - sp->ctrl->disable(sp); + slt->ctrl->disable(slt); return (0); } static int slot_resume(void *arg) { - struct slot *sp = arg; + struct slot *slt = arg; if (pcic_resume_reset) - sp->ctrl->resume(sp); + slt->ctrl->resume(slt); if (apm_pccard_resume) { /* Fake card removal/insertion events */ - if (sp->state == filled) { + if (slt->state == filled) { int s; s = splhigh(); - disable_slot(sp); - sp->state = empty; + disable_slot(slt); + slt->state = empty; splx(s); - sp->insert_seq = 1; - sp->insert_ch = timeout(inserted, (void *)sp, hz); - selwakeup(&sp->selp); + slt->insert_seq = 1; + slt->insert_ch = timeout(inserted, (void *)slt, hz); + selwakeup(&slt->selp); } } else { - struct pccard_dev *dp; - - sp->ctrl->power(sp); - if (sp->irq) - sp->ctrl->mapirq(sp, sp->irq); - if (sp->state == filled) { - for (dp = sp->devices; dp; dp = dp->next) - (void)dp->drv->init(dp, 0); + struct pccard_devinfo *devi; + + slt->ctrl->power(slt); + if (slt->irq) + slt->ctrl->mapirq(slt, slt->irq); + if (slt->state == filled) { + for (devi = slt->devices; devi; devi = devi->next) + (void)devi->drv->enable(devi, 0); } - } + } return (0); } #endif /* NAPM > 0 */ - /* * pccard_alloc_slot - Called from controller probe * routine, this function allocates a new PC-CARD slot @@ -427,44 +427,45 @@ slot_resume(void *arg) * to allow the controller specific data to be initialised. */ struct slot * -pccard_alloc_slot(struct slot_ctrl *cp) +pccard_alloc_slot(struct slot_ctrl *ctrl) { - struct slot *sp; - int slotno; + struct slot *slt; + int slotno; for (slotno = 0; slotno < MAXSLOT; slotno++) if (pccard_slots[slotno] == 0) break; - if (slotno >= MAXSLOT) + if (slotno == MAXSLOT) return(0); - MALLOC(sp, struct slot *, sizeof(*sp), M_DEVBUF, M_WAITOK); - bzero(sp, sizeof(*sp)); + + MALLOC(slt, struct slot *, sizeof(*slt), M_DEVBUF, M_WAITOK); + bzero(slt, sizeof(*slt)); #ifdef DEVFS - sp->devfs_token = devfs_add_devswf( &crd_cdevsw, + slt->devfs_token = devfs_add_devswf(&crd_cdevsw, 0, DV_CHR, 0, 0, 0600, "card%d", slotno); #endif - if (cp->extra) { - MALLOC(sp->cdata, void *, cp->extra, M_DEVBUF, M_WAITOK); - bzero(sp->cdata, cp->extra); + if (ctrl->extra) { + MALLOC(slt->cdata, void *, ctrl->extra, M_DEVBUF, M_WAITOK); + bzero(slt->cdata, ctrl->extra); } - sp->ctrl = cp; - sp->slot = slotno; - pccard_slots[slotno] = sp; - sp->next = slot_list; - slot_list = sp; + slt->ctrl = ctrl; + slt->slotnum = slotno; + pccard_slots[slotno] = slt; + slt->next = slot_list; + slot_list = slt; /* * If this controller hasn't been seen before, then * link it into the list of controllers. */ - if (cp->slots++ == 0) { - cp->next = cont_list; - cont_list = cp; - if (cp->maxmem > NUM_MEM_WINDOWS) - cp->maxmem = NUM_MEM_WINDOWS; - if (cp->maxio > NUM_IO_WINDOWS) - cp->maxio = NUM_IO_WINDOWS; + if (ctrl->slots++ == 0) { + ctrl->next = cont_list; + cont_list = ctrl; + if (ctrl->maxmem > NUM_MEM_WINDOWS) + ctrl->maxmem = NUM_MEM_WINDOWS; + if (ctrl->maxio > NUM_IO_WINDOWS) + ctrl->maxio = NUM_IO_WINDOWS; printf("PC-Card %s (%d mem & %d I/O windows)\n", - cp->name, cp->maxmem, cp->maxio); + ctrl->name, ctrl->maxmem, ctrl->maxio); } callout_handle_init(&slt->insert_ch); callout_handle_init(&slt->poff_ch); @@ -472,21 +473,21 @@ pccard_alloc_slot(struct slot_ctrl *cp) { struct apmhook *ap; - ap = &s_hook[sp->slot]; + ap = &s_hook[slt->slotnum]; ap->ah_fun = slot_suspend; - ap->ah_arg = (void *)sp; - ap->ah_name = cp->name; + ap->ah_arg = (void *)slt; + ap->ah_name = ctrl->name; ap->ah_order = APM_MID_ORDER; apm_hook_establish(APM_HOOK_SUSPEND, ap); - ap = &r_hook[sp->slot]; + ap = &r_hook[slt->slotnum]; ap->ah_fun = slot_resume; - ap->ah_arg = (void *)sp; - ap->ah_name = cp->name; + ap->ah_arg = (void *)slt; + ap->ah_name = ctrl->name; ap->ah_order = APM_MID_ORDER; apm_hook_establish(APM_HOOK_RESUME, ap); } #endif /* NAPM > 0 */ - return(sp); + return(slt); } /* @@ -506,16 +507,16 @@ pccard_alloc_intr(u_int imask, inthand2_t *hand, int unit, if (!(mask & imask)) continue; if (maskp) - INTRMASK (*maskp, mask); - if (register_intr(irq, 0, 0, hand, maskp, unit)==0) { + INTRMASK(*maskp, mask); + if (register_intr(irq, 0, 0, hand, maskp, unit) == 0) { /* add this to the PCIC controller's mask */ INTRMASK(*pcic_imask, (1 << irq)); - INTREN (mask); + INTREN(mask); return(irq); } - /* Well no luck, remove from mask again... */ + /* No luck, remove from mask again... */ if (maskp) - INTRUNMASK (*maskp, mask); + INTRUNMASK(*maskp, mask); } return(-1); } @@ -525,123 +526,122 @@ pccard_alloc_intr(u_int imask, inthand2_t *hand, int unit, * slot, and attach a driver to it. */ static int -allocate_driver(struct slot *sp, struct drv_desc *drvp) +allocate_driver(struct slot *slt, struct dev_desc *desc) { - struct pccard_dev *devp; - struct pccard_drv *dp; + struct pccard_devinfo *devi; + struct pccard_device *drv; int err, irq = 0, s; - dp = find_driver(drvp->name); - if (dp == 0) + drv = find_driver(desc->name); + if (drv == 0) return(ENXIO); /* * If an instance of this driver is already installed, * but not running, then remove it. If it is running, * then reject the request. */ - for (devp = sp->devices; devp; devp = devp->next) - if (devp->drv == dp && devp->isahd.id_unit == drvp->unit) { - if (devp->running) + for (devi = slt->devices; devi; devi = devi->next) + if (devi->drv == drv && devi->isahd.id_unit == desc->unit) { + if (devi->running) return(EBUSY); - remove_device(devp); + remove_device(devi); break; } /* * If an interrupt mask has been given, then check it * against the slot interrupt (if one has been allocated). */ - if (drvp->irqmask && dp->imask) { - if ((sp->ctrl->irqs & drvp->irqmask)==0) + if (desc->irqmask && drv->imask) { + if ((slt->ctrl->irqs & desc->irqmask) == 0) return(EINVAL); - if (sp->irq) { - if (((1 << sp->irq)&drvp->irqmask)==0) + if (slt->irq) { + if (((1 << slt->irq) & desc->irqmask) == 0) return(EINVAL); - sp->irqref++; - irq = sp->irq; + slt->irqref++; + irq = slt->irq; } else { /* * Attempt to allocate an interrupt. * XXX We lose at the moment if the second * device relies on a different interrupt mask. */ - irq = pccard_alloc_intr(drvp->irqmask, - slot_irq_handler, (int)sp, - dp->imask, sp->ctrl->imask); + irq = pccard_alloc_intr(desc->irqmask, + slot_irq_handler, (int)slt, + drv->imask, slt->ctrl->imask); if (irq < 0) return(EINVAL); - sp->irq = irq; - sp->irqref = 1; - sp->ctrl->mapirq(sp, sp->irq); + slt->irq = irq; + slt->irqref = 1; + slt->ctrl->mapirq(slt, slt->irq); } } - MALLOC(devp, struct pccard_dev *, sizeof(*devp), M_DEVBUF, M_WAITOK); - bzero(devp, sizeof(*devp)); + MALLOC(devi, struct pccard_devinfo *, sizeof(*devi), M_DEVBUF, M_WAITOK); + bzero(devi, sizeof(*devi)); /* * Create an entry for the device under this slot. */ - devp->drv = dp; - devp->sp = sp; - devp->isahd.id_irq = irq; - devp->isahd.id_unit = drvp->unit; - devp->isahd.id_msize = drvp->memsize; - devp->isahd.id_iobase = drvp->iobase; - bcopy(drvp->misc, devp->misc, sizeof drvp->misc); + devi->drv = drv; + devi->slt = slt; + devi->isahd.id_irq = irq; + devi->isahd.id_unit = desc->unit; + devi->isahd.id_msize = desc->memsize; + devi->isahd.id_iobase = desc->iobase; + bcopy(desc->misc, devi->misc, sizeof(desc->misc)); if (irq) - devp->isahd.id_irq = 1 << irq; - devp->isahd.id_flags = drvp->flags; + devi->isahd.id_irq = 1 << irq; + devi->isahd.id_flags = desc->flags; /* * Convert the memory to kernel space. */ - if (drvp->mem) - devp->isahd.id_maddr = - (caddr_t)(drvp->mem + atdevbase - IOM_BEGIN); + if (desc->mem) + devi->isahd.id_maddr = + (caddr_t)(desc->mem + atdevbase - IOM_BEGIN); else - devp->isahd.id_maddr = 0; - devp->next = sp->devices; - sp->devices = devp; + devi->isahd.id_maddr = 0; + devi->next = slt->devices; + slt->devices = devi; s = splhigh(); - err = dp->init(devp, 1); + err = drv->enable(devi, 1); splx(s); /* - * If the init functions returns no error, then the + * If the enable functions returns no error, then the * device has been successfully installed. If so, then * attach it to the slot, otherwise free it and return * the error. */ if (err) - remove_device(devp); + remove_device(devi); else - devp->running = 1; + devi->running = 1; return(err); } static void -remove_device(struct pccard_dev *devp) +remove_device(struct pccard_devinfo *devi) { - struct slot *sp = devp->sp; - struct pccard_dev *list; - int s; + struct slot *slt = devi->slt; + struct pccard_devinfo *list; /* * If an interrupt is enabled on this slot, * then unregister it if no-one else is using it. */ - unregister_device_interrupt(devp); + unregister_device_interrupt(devi); /* * Remove from device list on this slot. */ - if (sp->devices == devp) - sp->devices = devp->next; + if (slt->devices == devi) + slt->devices = devi->next; else - for (list = sp->devices; list->next; list = list->next) - if (list->next == devp) { - list->next = devp->next; + for (list = slt->devices; list->next; list = list->next) + if (list->next == devi) { + list->next = devi->next; break; } /* * Finally, free the memory space. */ - FREE(devp, M_DEVBUF); + FREE(devi, M_DEVBUF); } /* @@ -651,34 +651,33 @@ remove_device(struct pccard_dev *devp) static void inserted(void *arg) { - struct slot *sp = arg; + struct slot *slt = arg; - sp->state = filled; + slt->state = filled; /* * Enable 5V to the card so that the CIS can be read. */ - sp->pwr.vcc = 50; - sp->pwr.vpp = 0; + slt->pwr.vcc = 50; + slt->pwr.vpp = 0; /* * Disable any pending timeouts for this slot, and explicitly * power it off right now. Then, re-enable the power using * the (possibly new) power settings. */ - untimeout(power_off_slot, (caddr_t)sp, sp->poff_ch); - power_off_slot(sp); - sp->ctrl->power(sp); + untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch); + power_off_slot(slt); + slt->ctrl->power(slt); - printf("Card inserted, slot %d\n", sp->slot); + printf("Card inserted, slot %d\n", slt->slotnum); /* * Now start resetting the card. */ - sp->ctrl->reset(sp); + slt->ctrl->reset(slt); } /* * Insert/Remove beep */ - static int beepok = 0; static void enable_beep(void *dummy) @@ -691,34 +690,35 @@ static void enable_beep(void *dummy) * device interrupts from interceding. */ void -pccard_event(struct slot *sp, enum card_event event) +pccard_event(struct slot *slt, enum card_event event) { - if (sp->insert_seq) { - sp->insert_seq = 0; - untimeout(inserted, (void *)sp, sp->insert_ch); + if (slt->insert_seq) { + slt->insert_seq = 0; + untimeout(inserted, (void *)slt, slt->insert_ch); } + switch(event) { case card_removed: /* * The slot and devices are disabled, but the * data structures are not unlinked. */ - if (sp->state == filled) { + if (slt->state == filled) { int s = splhigh(); - disable_slot(sp); - sp->state = empty; + disable_slot(slt); + slt->state = empty; splx(s); - printf("Card removed, slot %d\n", sp->slot); + printf("Card removed, slot %d\n", slt->slotnum); if (beepok) sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0); beepok = 0; timeout(enable_beep, (void *)NULL, hz/5); - selwakeup(&sp->selp); + selwakeup(&slt->selp); } break; case card_inserted: - sp->insert_seq = 1; - sp->insert_ch = timeout(inserted, (void *)sp, hz/4); + slt->insert_seq = 1; + slt->insert_ch = timeout(inserted, (void *)slt, hz/4); if (beepok) sysbeep(PCCARD_BEEP_PITCH0, PCCARD_BEEP_DURATION0); beepok = 0; @@ -731,24 +731,25 @@ pccard_event(struct slot *sp, enum card_event event) * slot_irq_handler - Interrupt handler for shared irq devices. */ static void -slot_irq_handler(int sp) +slot_irq_handler(int arg) { - struct pccard_dev *dp; + struct pccard_devinfo *devi; + struct slot *slt = (struct slot *)arg; /* * For each device that has the shared interrupt, * call the interrupt handler. If the interrupt was * caught, the handler returns true. */ - for (dp = ((struct slot *)sp)->devices; dp; dp = dp->next) - if (dp->isahd.id_irq && dp->running && dp->drv->handler(dp)) + for (devi = slt->devices; devi; devi = devi->next) + if (devi->isahd.id_irq && devi->running && + devi->drv->handler(devi)) return; /* * XXX - Should 'debounce' these for drivers that have recently * been removed. */ - printf("Slot %d, unfielded interrupt (%d)\n", - ((struct slot *)sp)->slot, ((struct slot *)sp)->irq); + printf("Slot %d, unfielded interrupt (%d)\n", slt->slotnum, slt->irq); } /* @@ -757,15 +758,15 @@ slot_irq_handler(int sp) static int crdopen(dev_t dev, int oflags, int devtype, struct proc *p) { - struct slot *sp; + struct slot *slt; if (minor(dev) >= MAXSLOT) return(ENXIO); - sp = pccard_slots[minor(dev)]; - if (sp==0) + slt = pccard_slots[minor(dev)]; + if (slt == 0) return(ENXIO); - if (sp->rwmem == 0) - sp->rwmem = MDF_ATTR; + if (slt->rwmem == 0) + slt->rwmem = MDF_ATTR; return(0); } @@ -786,24 +787,24 @@ crdclose(dev_t dev, int fflag, int devtype, struct proc *p) static int crdread(dev_t dev, struct uio *uio, int ioflag) { - struct slot *sp = pccard_slots[minor(dev)]; - unsigned char *p; - int error = 0, win, count; + struct slot *slt = pccard_slots[minor(dev)]; struct mem_desc *mp, oldmap; + unsigned char *p; unsigned int offs; + int error = 0, win, count; - if (sp == 0 || sp->state != filled) + if (slt == 0 || slt->state != filled) return(ENXIO); if (pccard_mem == 0) return(ENOMEM); - for (win = 0; win < sp->ctrl->maxmem; win++) - if ((sp->mem[win].flags & MDF_ACTIVE)==0) + for (win = 0; win < slt->ctrl->maxmem; win++) + if ((slt->mem[win].flags & MDF_ACTIVE) == 0) break; - if (win >= sp->ctrl->maxmem) + if (win >= slt->ctrl->maxmem) return(EBUSY); - mp = &sp->mem[win]; + mp = &slt->mem[win]; oldmap = *mp; - mp->flags = sp->rwmem|MDF_ACTIVE; + mp->flags = slt->rwmem|MDF_ACTIVE; #if 0 printf("Rd at offs %d, size %d\n", (int)uio->uio_offset, uio->uio_resid); @@ -812,7 +813,7 @@ crdread(dev_t dev, struct uio *uio, int ioflag) mp->card = uio->uio_offset; mp->size = PCCARD_MEMSIZE; mp->start = (caddr_t)pccard_mem; - if (error = sp->ctrl->mapmem(sp, win)) + if (error = slt->ctrl->mapmem(slt, win)) break; offs = (unsigned int)uio->uio_offset & (PCCARD_MEMSIZE - 1); p = pccard_kmem + offs; @@ -823,7 +824,7 @@ crdread(dev_t dev, struct uio *uio, int ioflag) * Restore original map. */ *mp = oldmap; - sp->ctrl->mapmem(sp, win); + slt->ctrl->mapmem(slt, win); return(error); } @@ -836,24 +837,24 @@ crdread(dev_t dev, struct uio *uio, int ioflag) static int crdwrite(dev_t dev, struct uio *uio, int ioflag) { - struct slot *sp = pccard_slots[minor(dev)]; - unsigned char *p; - int error = 0, win, count; + struct slot *slt = pccard_slots[minor(dev)]; struct mem_desc *mp, oldmap; + unsigned char *p; unsigned int offs; + int error = 0, win, count; - if (sp == 0 || sp->state != filled) + if (slt == 0 || slt->state != filled) return(ENXIO); if (pccard_mem == 0) return(ENOMEM); - for (win = 0; win < sp->ctrl->maxmem; win++) - if ((sp->mem[win].flags & MDF_ACTIVE)==0) + for (win = 0; win < slt->ctrl->maxmem; win++) + if ((slt->mem[win].flags & MDF_ACTIVE)==0) break; - if (win >= sp->ctrl->maxmem) + if (win >= slt->ctrl->maxmem) return(EBUSY); - mp = &sp->mem[win]; + mp = &slt->mem[win]; oldmap = *mp; - mp->flags = sp->rwmem|MDF_ACTIVE; + mp->flags = slt->rwmem|MDF_ACTIVE; #if 0 printf("Wr at offs %d, size %d\n", (int)uio->uio_offset, uio->uio_resid); @@ -862,7 +863,7 @@ crdwrite(dev_t dev, struct uio *uio, int ioflag) mp->card = uio->uio_offset; mp->size = PCCARD_MEMSIZE; mp->start = (caddr_t)pccard_mem; - if (error = sp->ctrl->mapmem(sp, win)) + if (error = slt->ctrl->mapmem(slt, win)) break; offs = (unsigned int)uio->uio_offset & (PCCARD_MEMSIZE - 1); p = pccard_kmem + offs; @@ -876,7 +877,7 @@ crdwrite(dev_t dev, struct uio *uio, int ioflag) * Restore original map. */ *mp = oldmap; - sp->ctrl->mapmem(sp, win); + slt->ctrl->mapmem(slt, win); return(error); } @@ -888,38 +889,41 @@ crdwrite(dev_t dev, struct uio *uio, int ioflag) static int crdioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p) { - int s, err; - struct slot *sp = pccard_slots[minor(dev)]; + struct slot *slt = pccard_slots[minor(dev)]; struct mem_desc *mp; struct io_desc *ip; + int s, err; /* beep is disabled until the 1st call of crdioctl() */ enable_beep(NULL); - if (sp == 0 && cmd != PIOCRWMEM) + if (slt == 0 && cmd != PIOCRWMEM) return(ENXIO); switch(cmd) { default: - if (sp->ctrl->ioctl) - return(sp->ctrl->ioctl(sp, cmd, data)); + if (slt->ctrl->ioctl) + return(slt->ctrl->ioctl(slt, cmd, data)); return(EINVAL); + /* + * Get slot state. + */ case PIOCGSTATE: s = splhigh(); - ((struct slotstate *)data)->state = sp->state; - sp->laststate = sp->state; + ((struct slotstate *)data)->state = slt->state; + slt->laststate = slt->state; splx(s); - ((struct slotstate *)data)->maxmem = sp->ctrl->maxmem; - ((struct slotstate *)data)->maxio = sp->ctrl->maxio; - ((struct slotstate *)data)->irqs = sp->ctrl->irqs; + ((struct slotstate *)data)->maxmem = slt->ctrl->maxmem; + ((struct slotstate *)data)->maxio = slt->ctrl->maxio; + ((struct slotstate *)data)->irqs = slt->ctrl->irqs; break; /* * Get memory context. */ case PIOCGMEM: s = ((struct mem_desc *)data)->window; - if (s < 0 || s >= sp->ctrl->maxmem) + if (s < 0 || s >= slt->ctrl->maxmem) return(EINVAL); - mp = &sp->mem[s]; + mp = &slt->mem[s]; ((struct mem_desc *)data)->flags = mp->flags; ((struct mem_desc *)data)->start = mp->start; ((struct mem_desc *)data)->size = mp->size; @@ -933,21 +937,21 @@ crdioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p) case PIOCSMEM: if (suser(p->p_ucred, &p->p_acflag)) return(EPERM); - if (sp->state != filled) + if (slt->state != filled) return(ENXIO); s = ((struct mem_desc *)data)->window; - if (s < 0 || s >= sp->ctrl->maxmem) + if (s < 0 || s >= slt->ctrl->maxmem) return(EINVAL); - sp->mem[s] = *((struct mem_desc *)data); - return(sp->ctrl->mapmem(sp, s)); + slt->mem[s] = *((struct mem_desc *)data); + return(slt->ctrl->mapmem(slt, s)); /* * Get I/O port context. */ case PIOCGIO: s = ((struct io_desc *)data)->window; - if (s < 0 || s >= sp->ctrl->maxio) + if (s < 0 || s >= slt->ctrl->maxio) return(EINVAL); - ip = &sp->io[s]; + ip = &slt->io[s]; ((struct io_desc *)data)->flags = ip->flags; ((struct io_desc *)data)->start = ip->start; ((struct io_desc *)data)->size = ip->size; @@ -958,23 +962,22 @@ crdioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p) case PIOCSIO: if (suser(p->p_ucred, &p->p_acflag)) return(EPERM); - if (sp->state != filled) + if (slt->state != filled) return(ENXIO); s = ((struct io_desc *)data)->window; - if (s < 0 || s >= sp->ctrl->maxio) + if (s < 0 || s >= slt->ctrl->maxio) return(EINVAL); - sp->io[s] = *((struct io_desc *)data); - return(sp->ctrl->mapio(sp, s)); + slt->io[s] = *((struct io_desc *)data); + return(slt->ctrl->mapio(slt, s)); break; /* - * Set memory window flags for read/write interface. + * Set memory window flags for read/write interface. */ case PIOCRWFLAG: - sp->rwmem = *(int *)data; + slt->rwmem = *(int *)data; break; /* - * Set the memory window to be used for the read/write - * interface. + * Set the memory window to be used for the read/write interface. */ case PIOCRWMEM: if (*(unsigned long *)data == 0) { @@ -1000,18 +1003,18 @@ crdioctl(dev_t dev, int cmd, caddr_t data, int fflag, struct proc *p) + atdevbase - IOM_BEGIN); break; /* - * Set power values + * Set power values. */ case PIOCSPOW: - sp->pwr = *(struct power *)data; - return(sp->ctrl->power(sp)); + slt->pwr = *(struct power *)data; + return(slt->ctrl->power(slt)); /* - * Allocate a driver to this slot. + * Allocate a driver to this slot. */ case PIOCSDRV: if (suser(p->p_ucred, &p->p_acflag)) return(EPERM); - err = allocate_driver(sp, (struct drv_desc *)data); + err = allocate_driver(slt, (struct dev_desc *)data); if (!err) sysbeep(PCCARD_BEEP_PITCH1, PCCARD_BEEP_DURATION1); else @@ -1029,7 +1032,7 @@ static int crdpoll(dev_t dev, int events, struct proc *p) { int s; - struct slot *sp = pccard_slots[minor(dev)]; + struct slot *slt = pccard_slots[minor(dev)]; int revents = 0; if (events & (POLLIN | POLLRDNORM)) @@ -1043,11 +1046,11 @@ crdpoll(dev_t dev, int events, struct proc *p) * select for exception - card event. */ if (events & POLLRDBAND) - if (sp == 0 || sp->laststate != sp->state) + if (slt == 0 || slt->laststate != slt->state) revents |= POLLRDBAND; if (revents == 0) - selrecord(p, &sp->selp); + selrecord(p, &slt->selp); splx(s); return (revents); @@ -1069,14 +1072,14 @@ invalid_io_memory(unsigned long adr, int size) return(0); } -static struct pccard_drv * +static struct pccard_device * find_driver(char *name) { - struct pccard_drv *dp; + struct pccard_device *drv; - for (dp = drivers; dp; dp = dp->next) - if (strcmp(dp->name, name)==0) - return(dp); + for (drv = drivers; drv; drv = drv->next) + if (strcmp(drv->name, name)==0) + return(drv); return(0); } @@ -1087,9 +1090,9 @@ crd_drvinit(void *unused) { dev_t dev; - if( ! crd_devsw_installed ) { + if (!crd_devsw_installed) { dev = makedev(CDEV_MAJOR, 0); - cdevsw_add(&dev,&crd_cdevsw, NULL); + cdevsw_add(&dev, &crd_cdevsw, NULL); crd_devsw_installed = 1; } } diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index 31a707d..14a9c5f 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -158,15 +158,15 @@ static u_int build_freelist(u_int); * Per-slot data table. */ static struct pcic_slot { - int slot; /* My slot number */ + int slotnum; /* My slot number */ int index; /* Index register */ int data; /* Data register */ int offset; /* Offset value for index */ char controller; /* Device type */ char revision; /* Device Revision */ - struct slot *slotp; /* Back ptr to slot */ - u_char (*getb)(struct pcic_slot *sp, int reg); - void (*putb)(struct pcic_slot *sp, int reg, u_char val); + struct slot *slt; /* Back ptr to slot */ + u_char (*getb)(struct pcic_slot *, int); + void (*putb)(struct pcic_slot *, int, u_char); u_char *regs; /* Pointer to regs in mem */ } pcic_slots[PCIC_MAX_SLOTS]; @@ -329,7 +329,7 @@ pcic_unload(struct lkm_table *lkmtp, int cmd) untimeout(pcictimeout,0, pcictimeout_ch); if (pcic_irq) { for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++) { - if (sp->slotp) + if (sp->slt) sp->putb(sp, PCIC_STAT_INT, 0); } unregister_intr(pcic_irq, pcicintr); @@ -400,10 +400,10 @@ build_freelist(u_int pcic_mask) * entry point from main code to map/unmap memory context. */ static int -pcic_memory(struct slot *slotp, int win) +pcic_memory(struct slot *slt, int win) { - struct pcic_slot *sp = slotp->cdata; - struct mem_desc *mp = &slotp->mem[win]; + struct pcic_slot *sp = slt->cdata; + struct mem_desc *mp = &slt->mem[win]; int reg = mp->window * PCIC_MEMSIZE + PCIC_MEMBASE; #ifdef PC98 @@ -481,7 +481,7 @@ pcic_memory(struct slot *slotp, int win) setb(sp, reg+5, PCIC_WP); #if 0 printf("Slot number %d, reg 0x%x, offs 0x%x\n", - sp->slot, reg, sp->offset); + sp->slotnum, reg, sp->offset); printf("Map window to sys addr 0x%x for %d bytes, card 0x%x\n", mp->start, mp->size, mp->card); printf("regs are: 0x%02x%02x 0x%02x%02x 0x%02x%02x flags 0x%x\n", @@ -511,11 +511,11 @@ pcic_memory(struct slot *slotp, int win) * pcic_io - map or unmap I/O context */ static int -pcic_io(struct slot *slotp, int win) +pcic_io(struct slot *slt, int win) { int mask, reg; - struct pcic_slot *sp = slotp->cdata; - struct io_desc *ip = &slotp->io[win]; + struct pcic_slot *sp = slt->cdata; + struct io_desc *ip = &slt->io[win]; #ifdef PC98 if (sp->controller == PCIC_PC98){ unsigned char x; @@ -625,9 +625,9 @@ printf("Map I/O 0x%x (size 0x%x) on Window %d\n", ip->start, ip->size, win); int pcic_probe(void) { - int slot, i, validslots = 0; + int slotnum, i, validslots = 0; u_int free_irqs; - struct slot *slotp; + struct slot *slt; struct pcic_slot *sp; unsigned char c; static int maybe_vlsi = 0; @@ -655,20 +655,20 @@ pcic_probe(void) bzero(pcic_slots, sizeof(pcic_slots)); #endif sp = pcic_slots; - for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++) { + for (slotnum = 0; slotnum < PCIC_MAX_SLOTS; slotnum++, sp++) { /* * Initialise the PCIC slot table. */ sp->getb = getb1; sp->putb = putb1; - if (slot < 4) { + if (slotnum < 4) { sp->index = PCIC_INDEX_0; sp->data = PCIC_DATA_0; - sp->offset = slot * PCIC_SLOT_SIZE; + sp->offset = slotnum * PCIC_SLOT_SIZE; } else { sp->index = PCIC_INDEX_1; sp->data = PCIC_DATA_1; - sp->offset = (slot - 4) * PCIC_SLOT_SIZE; + sp->offset = (slotnum - 4) * PCIC_SLOT_SIZE; } /* * XXX - Screwed up slot 1 on the VLSI chips. According to @@ -677,7 +677,7 @@ pcic_probe(void) * ones would need to be probed at the new offset we set after * we assume it's broken. */ - if (slot == 1 && maybe_vlsi && sp->getb(sp, PCIC_ID_REV) != 0x84) { + if (slotnum == 1 && maybe_vlsi && sp->getb(sp, PCIC_ID_REV) != 0x84) { sp->index += 4; sp->data += 4; sp->offset = PCIC_SLOT_SIZE << 1; @@ -797,12 +797,12 @@ pcic_probe(void) * Allocate a slot and initialise the data structures. */ validslots++; - sp->slot = slot; - slotp = pccard_alloc_slot(&cinfo); - if (slotp == 0) + sp->slotnum = slotnum; + slt = pccard_alloc_slot(&cinfo); + if (slt == 0) continue; - slotp->cdata = sp; - sp->slotp = slotp; + slt->cdata = sp; + sp->slt = slt; /* * If we haven't allocated an interrupt for the controller, * then attempt to get one. @@ -832,10 +832,10 @@ pcic_probe(void) */ setb(sp, PCIC_POWER, PCIC_PCPWRE| PCIC_DISRST); if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) != PCIC_CD) { - slotp->laststate = slotp->state = empty; + slt->laststate = slt->state = empty; } else { - slotp->laststate = slotp->state = filled; - pccard_event(sp->slotp, card_inserted); + slt->laststate = slt->state = filled; + pccard_event(sp->slt, card_inserted); } /* * Assign IRQ for slot changes @@ -845,7 +845,8 @@ pcic_probe(void) } #ifdef PC98 if (validslots == 0){ - sp = pcic_slots; slot = 0; + sp = pcic_slots; + slotnum = 0; if (inb(PCIC98_REG0) != 0xff){ sp->controller = PCIC_PC98; sp->revision = 0; @@ -855,23 +856,23 @@ pcic_probe(void) /* cinfo.irqs = PCIC_INT_MASK_ALLOWED;*/ cinfo.irqs = 0x1468; validslots++; - sp->slot = slot; + sp->slotnum = slotnum; - slotp = pccard_alloc_slot(&cinfo); - if (slotp == 0){ - printf("pcic98: slotp == NULL\n"); + slt = pccard_alloc_slot(&cinfo); + if (slt == 0){ + printf("pcic98: slt == NULL\n"); goto pcic98_probe_end; } - slotp->cdata = sp; - sp->slotp = slotp; + slt->cdata = sp; + sp->slt = slt; /* Check for a card in this slot */ if (inb(PCIC98_REG1) & PCIC98_CARDEXIST){ /* PCMCIA card exist */ - slotp->laststate = slotp->state = filled; - pccard_event(sp->slotp, card_inserted); + slt->laststate = slt->state = filled; + pccard_event(sp->slt, card_inserted); } else { - slotp->laststate = slotp->state = empty; + slt->laststate = slt->state = empty; } } pcic98_probe_end: @@ -886,9 +887,9 @@ pcic_probe(void) * ioctl calls - Controller specific ioctls */ static int -pcic_ioctl(struct slot *slotp, int cmd, caddr_t data) +pcic_ioctl(struct slot *slt, int cmd, caddr_t data) { - struct pcic_slot *sp = slotp->cdata; + struct pcic_slot *sp = slt->cdata; switch(cmd) { default: @@ -913,16 +914,16 @@ pcic_ioctl(struct slot *slotp, int cmd, caddr_t data) * the parameters in the power structure(s). */ static int -pcic_power(struct slot *slotp) +pcic_power(struct slot *slt) { unsigned char reg = PCIC_DISRST|PCIC_PCPWRE; - struct pcic_slot *sp = slotp->cdata; + struct pcic_slot *sp = slt->cdata; switch(sp->controller) { #ifdef PC98 case PCIC_PC98: reg = inb(PCIC98_REG6) & (~PCIC98_VPP12V); - switch(slotp->pwr.vpp) { + switch(slt->pwr.vpp) { default: return(EINVAL); case 50: @@ -935,7 +936,7 @@ pcic_power(struct slot *slotp) DELAY (100*1000); reg = inb(PCIC98_REG2) & (~PCIC98_VCC3P3V); - switch(slotp->pwr.vcc) { + switch(slt->pwr.vcc) { default: return(EINVAL); case 33: @@ -955,7 +956,7 @@ pcic_power(struct slot *slotp) case PCIC_RF5C396: case PCIC_VLSI: case PCIC_IBM_KING: - switch(slotp->pwr.vpp) { + switch(slt->pwr.vpp) { default: return(EINVAL); case 0: @@ -968,7 +969,7 @@ pcic_power(struct slot *slotp) reg |= PCIC_VPP_12V; break; } - switch(slotp->pwr.vcc) { + switch(slt->pwr.vcc) { default: return(EINVAL); case 0: @@ -1002,7 +1003,7 @@ pcic_power(struct slot *slotp) } sp->putb(sp, PCIC_POWER, reg); DELAY(300*1000); - if (slotp->pwr.vcc) { + if (slt->pwr.vcc) { reg |= PCIC_OUTENA; sp->putb(sp, PCIC_POWER, reg); DELAY(100*1000); @@ -1010,10 +1011,10 @@ pcic_power(struct slot *slotp) /* Some chips are smarter than us it seems, so if we weren't * allowed to use 5V, try 3.3 instead */ - if (!(sp->getb(sp, PCIC_STATUS) & 0x40) && slotp->pwr.vcc == 50) { - slotp->pwr.vcc = 33; - slotp->pwr.vpp = 0; - return (pcic_power(slotp)); + if (!(sp->getb(sp, PCIC_STATUS) & 0x40) && slt->pwr.vcc == 50) { + slt->pwr.vcc = 33; + slt->pwr.vpp = 0; + return (pcic_power(slt)); } return(0); } @@ -1023,9 +1024,9 @@ pcic_power(struct slot *slotp) * 3, 4, 5, 7, 9, 10, 11, 12, 14, 15 */ static void -pcic_mapirq (struct slot *slotp, int irq) +pcic_mapirq (struct slot *slt, int irq) { - struct pcic_slot *sp = slotp->cdata; + struct pcic_slot *sp = slt->cdata; #ifdef PC98 if (sp->controller == PCIC_PC98){ unsigned char x; @@ -1068,8 +1069,8 @@ pcic_mapirq (struct slot *slotp, int irq) static void pcic_reset(void *chan) { - struct slot *slotp = chan; - struct pcic_slot *sp = slotp->cdata; + struct slot *slt = chan; + struct pcic_slot *sp = slt->cdata; #ifdef PC98 if (sp->controller == PCIC_PC98){ @@ -1080,30 +1081,30 @@ pcic_reset(void *chan) outb(PCIC98_REG6, inb(PCIC98_REG6) & (~PCIC98_VPP12V)); outb(PCIC98_REG1, 0); - selwakeup(&slotp->selp); + selwakeup(&slt->selp); return; } #endif - switch (slotp->insert_seq) { + switch (slt->insert_seq) { case 0: /* Something funny happended on the way to the pub... */ return; case 1: /* Assert reset */ clrb(sp, PCIC_INT_GEN, PCIC_CARDRESET); - slotp->insert_seq = 2; - timeout(pcic_reset, (void*) slotp, hz/4); + slt->insert_seq = 2; + timeout(pcic_reset, (void*) slt, hz/4); return; case 2: /* Deassert it again */ setb(sp, PCIC_INT_GEN, PCIC_CARDRESET|PCIC_IOCARD); - slotp->insert_seq = 3; - timeout(pcic_reset, (void*) slotp, hz/4); + slt->insert_seq = 3; + timeout(pcic_reset, (void*) slt, hz/4); return; case 3: /* Wait if card needs more time */ if (!sp->getb(sp, PCIC_STATUS) & PCIC_READY) { - timeout(pcic_reset, (void*) slotp, hz/10); + timeout(pcic_reset, (void*) slt, hz/10); return; } } - slotp->insert_seq = 0; + slt->insert_seq = 0; if (sp->controller == PCIC_PD672X || sp->controller == PCIC_PD6710) { sp->putb(sp, PCIC_TIME_SETUP0, 0x1); sp->putb(sp, PCIC_TIME_CMD0, 0x6); @@ -1112,16 +1113,16 @@ pcic_reset(void *chan) sp->putb(sp, PCIC_TIME_CMD1, 0xf); sp->putb(sp, PCIC_TIME_RECOV1, 0); } - selwakeup(&slotp->selp); + selwakeup(&slt->selp); } /* * pcic_disable - Disable the slot. */ static void -pcic_disable(struct slot *slotp) +pcic_disable(struct slot *slt) { - struct pcic_slot *sp = slotp->cdata; + struct pcic_slot *sp = slt->cdata; #ifdef PC98 if (sp->controller == PCIC_PC98){ @@ -1162,12 +1163,12 @@ pcicintr(int unit) s = splhigh(); /* Check for a card in this slot */ if (inb(PCIC98_REG1) & PCIC98_CARDEXIST){ - if (sp->slotp->laststate != filled){ - pccard_event(sp->slotp, card_inserted); + if (sp->slt->laststate != filled){ + pccard_event(sp->slt, card_inserted); } } else { - if (sp->slotp->laststate != empty){ - pccard_event(sp->slotp, card_removed); + if (sp->slt->laststate != empty){ + pccard_event(sp->slt, card_removed); } } splx(s); @@ -1176,15 +1177,13 @@ pcicintr(int unit) #endif /* PC98 */ s = splhigh(); for (slot = 0; slot < PCIC_MAX_SLOTS; slot++, sp++) - if (sp->slotp && (chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) + if (sp->slt && (chg = sp->getb(sp, PCIC_STAT_CHG)) != 0) if (chg & PCIC_CDTCH) { if ((sp->getb(sp, PCIC_STATUS) & PCIC_CD) == PCIC_CD) { - pccard_event(sp->slotp, - card_inserted); + pccard_event(sp->slt, card_inserted); } else { - pccard_event(sp->slotp, - card_removed); + pccard_event(sp->slt, card_removed); } } splx(s); @@ -1194,9 +1193,9 @@ pcicintr(int unit) * pcic_resume - Suspend/resume support for PCIC */ static void -pcic_resume(struct slot *slotp) +pcic_resume(struct slot *slt) { - struct pcic_slot *sp = slotp->cdata; + struct pcic_slot *sp = slt->cdata; if (pcic_irq > 0) sp->putb(sp, PCIC_STAT_INT, (pcic_irq << 4) | 0xF); if (sp->controller == PCIC_PD672X) { diff --git a/sys/pccard/skel.c b/sys/pccard/skel.c index 07216b8..741bd88 100644 --- a/sys/pccard/skel.c +++ b/sys/pccard/skel.c @@ -47,10 +47,10 @@ MOD_MISC( "skel") -static int skelintr(struct pccard_dev *); /* Interrupt handler */ -static void skelunload(struct pccard_dev *); /* Disable driver */ -static void skelsuspend(struct pccard_dev *); /* Suspend driver */ -static int skelinit(struct pccard_dev *, int); /* init device */ +static int skelintr(struct pccard_devinfo *); /* Interrupt handler */ +static void skelunload(struct pccard_devinfo *); /* Disable driver */ +static void skelsuspend(struct pccard_devinfo *); /* Suspend driver */ +static int skelinit(struct pccard_devinfo *, int); /* init device */ static struct pccard_drv skel_info = { @@ -143,7 +143,7 @@ int ver; * the device was successfully installed. */ static void -skelunload(struct pccard_dev *dp) +skelunload(struct pccard_devinfo *dp) { printf("skel%d: unload\n", dp->unit); opened &= ~(1 << dp->unit); @@ -155,7 +155,7 @@ skelunload(struct pccard_dev *dp) * skelinit with first=0. */ static void -skelsuspend(struct pccard_dev *dp) +skelsuspend(struct pccard_devinfo *dp) { printf("skel%d: suspending\n", dp->unit); } @@ -166,7 +166,7 @@ skelsuspend(struct pccard_dev *dp) * Once initialised, the device table may be set up. */ static int -skelinit(struct pccard_dev *dp, int first) +skelinit(struct pccard_devinfo *dp, int first) { if (first && ((1 << dp->unit)&opened)) return(EBUSY); @@ -181,7 +181,7 @@ skelinit(struct pccard_dev *dp, int first) * Returns true if the interrupt is for us. */ static int -skelintr(struct pccard_dev *dp) +skelintr(struct pccard_devinfo *dp) { return(0); } diff --git a/sys/pccard/slot.h b/sys/pccard/slot.h index 7ad82c3..113635a 100644 --- a/sys/pccard/slot.h +++ b/sys/pccard/slot.h @@ -73,49 +73,50 @@ struct slot_ctrl { * with the mainline PC-CARD code. These drivers are * then available for linking to the devices. */ -struct pccard_dev; +struct pccard_devinfo; -struct pccard_drv { - char *name; /* Driver name */ - int (*handler)(struct pccard_dev *); /* Interrupt handler */ - void (*unload)(struct pccard_dev *); /* Disable driver */ - void (*suspend)(struct pccard_dev *); /* Suspend driver */ - int (*init)(struct pccard_dev *, int); /* init device */ - int attr; /* driver attributes */ - unsigned int *imask; /* Interrupt mask ptr */ +struct pccard_device { + char *name; /* Driver name */ + int (*enable)(struct pccard_devinfo *, int); /* init/enable driver */ + void (*disable)(struct pccard_devinfo *); /* disable driver */ + int (*handler)(struct pccard_devinfo *); /* interrupt handler */ + void (*suspend)(struct pccard_devinfo *); /* Suspend driver */ + int attr; /* driver attributes */ + unsigned int *imask; /* Interrupt mask ptr */ - struct pccard_drv *next; + struct pccard_device *next; }; /* * Device structure for cards. Each card may have one - * or more drivers attached to it; each driver is assumed + * or more pccard drivers attached to it; each driver is assumed * to require at most one interrupt handler, one I/O block * and one memory block. This structure is used to link the different * devices together. */ -struct pccard_dev { - struct pccard_dev *next; /* List of drivers */ +struct pccard_devinfo { + struct pccard_device *drv; struct isa_device isahd; /* Device details */ - struct pccard_drv *drv; +#if 0 void *arg; /* Device argument */ - struct slot *sp; /* Back pointer to slot */ +#endif int running; /* Current state of driver */ u_char misc[128]; /* For any random info */ + struct slot *slt; /* Back pointer to slot */ + + struct pccard_devinfo *next; /* List of drivers */ }; /* * Per-slot structure. */ struct slot { - struct slot *next; /* Master list */ - int slot; /* Slot number */ + int slotnum; /* Slot number */ int flags; /* Slot flags (see below) */ int rwmem; /* Read/write flags */ - int ex_sel; /* PID for select */ int irq; /* IRQ allocated (0 = none) */ int irqref; /* Reference count of driver IRQs */ - struct pccard_dev *devices; /* List of drivers attached */ + struct pccard_devinfo *devices; /* List of drivers attached */ /* * flags. */ @@ -134,10 +135,12 @@ struct slot { #ifdef DEVFS void *devfs_token; #endif /* DEVFS*/ + + struct slot *next; /* Master list */ }; enum card_event { card_removed, card_inserted }; struct slot *pccard_alloc_slot(struct slot_ctrl *); -void pccard_event(struct slot *, enum card_event); -void pccard_remove_controller(struct slot_ctrl *); +void pccard_event(struct slot *, enum card_event); +void pccard_remove_controller(struct slot_ctrl *); diff --git a/usr.sbin/pccard/pccardc/enabler.c b/usr.sbin/pccard/pccardc/enabler.c index c0b6049..ddd1dfd 100644 --- a/usr.sbin/pccard/pccardc/enabler.c +++ b/usr.sbin/pccard/pccardc/enabler.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: enabler.c,v 1.8 1997/10/06 11:35:54 charnier Exp $"; #endif /* not lint */ #include <err.h> @@ -47,7 +47,7 @@ enabler_main(argc, argv) int argc; char *argv[]; { - struct drv_desc drv; + struct dev_desc drv; struct mem_desc mem; struct io_desc io; int fd, slot, i, card_addr; diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c index d928d97..e2237f3 100644 --- a/usr.sbin/pccard/pccardd/cardd.c +++ b/usr.sbin/pccard/pccardd/cardd.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: cardd.c,v 1.18 1997/10/06 11:36:06 charnier Exp $"; #endif /* not lint */ #include <fcntl.h> @@ -553,7 +553,7 @@ setup_slot(struct slot *sp) { struct mem_desc mem; struct io_desc io; - struct drv_desc drv; + struct dev_desc drv; struct driver *drvp = sp->config->driver; char c; off_t offs; |