summaryrefslogtreecommitdiffstats
path: root/sys/pccard
diff options
context:
space:
mode:
authornate <nate@FreeBSD.org>1997-10-26 04:36:24 +0000
committernate <nate@FreeBSD.org>1997-10-26 04:36:24 +0000
commitc68183d0b8cb8cb595c0fac05b6d989132543595 (patch)
tree3e3880b90341465871c326ce768b275780757e2d /sys/pccard
parentbc21da1f3f59930a96cd6829bfaf0147d28b7754 (diff)
downloadFreeBSD-src-c68183d0b8cb8cb595c0fac05b6d989132543595.zip
FreeBSD-src-c68183d0b8cb8cb595c0fac05b6d989132543595.tar.gz
- Do a bunch of gratuitous changes intended to make the code easier to
follow. * Rename/reorder all of the pccard structures, change many of the member names to be descriptive, and follow more closely other 'bus' drivers naming schemes. * Rename a bunch of parameter and local variable names to be more consistant in the code. * Renamed the PCCARD 'crd' device to be the 'card' device * KNF and make the code consistant where it was obvious. * ifdef'd out some unused code
Diffstat (limited to 'sys/pccard')
-rw-r--r--sys/pccard/card.h4
-rw-r--r--sys/pccard/cardinfo.h4
-rw-r--r--sys/pccard/driver.h6
-rw-r--r--sys/pccard/pccard.c585
-rw-r--r--sys/pccard/pcic.c151
-rw-r--r--sys/pccard/skel.c16
-rw-r--r--sys/pccard/slot.h45
7 files changed, 408 insertions, 403 deletions
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 *);
OpenPOWER on IntegriCloud