1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pccard.c - Interface code for PC-CARD controllers.
|
|
|
|
*
|
|
|
|
* June 1995, Andrew McRae (andrew@mega.com.au)
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Copyright (c) 1995 Andrew McRae. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1998-01-02 13:35:06 +00:00
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1995-08-24 08:56:20 +00:00
|
|
|
*/
|
|
|
|
|
1998-09-08 18:09:51 +00:00
|
|
|
#include "opt_pcic.h"
|
1998-01-24 02:54:56 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/malloc.h>
|
1999-01-27 10:10:03 +00:00
|
|
|
#include <sys/select.h>
|
1997-04-20 07:21:12 +00:00
|
|
|
#include <sys/sysctl.h>
|
1995-12-08 11:19:42 +00:00
|
|
|
#include <sys/conf.h>
|
1999-09-06 06:34:44 +00:00
|
|
|
#include <sys/module.h>
|
1997-01-13 21:51:13 +00:00
|
|
|
#include <sys/uio.h>
|
1997-09-14 03:19:42 +00:00
|
|
|
#include <sys/poll.h>
|
1999-09-06 06:34:44 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
#include <i386/isa/isa_device.h>
|
|
|
|
#include <i386/isa/icu.h>
|
1998-11-09 09:30:55 +00:00
|
|
|
#include <i386/isa/intr_machdep.h>
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1997-11-18 21:04:01 +00:00
|
|
|
#include <pccard/cardinfo.h>
|
1995-12-16 00:11:11 +00:00
|
|
|
#include <pccard/driver.h>
|
1999-03-10 15:00:54 +00:00
|
|
|
#include <pccard/pcic.h>
|
1995-11-14 20:49:24 +00:00
|
|
|
#include <pccard/slot.h>
|
1999-09-06 06:34:44 +00:00
|
|
|
#include <pccard/pccard_nbk.h>
|
1995-11-14 20:49:24 +00:00
|
|
|
|
1996-06-25 20:31:01 +00:00
|
|
|
#include <machine/md_var.h>
|
1996-06-05 05:30:09 +00:00
|
|
|
|
1997-10-23 22:54:47 +00:00
|
|
|
/*
|
1997-10-24 15:27:16 +00:00
|
|
|
* XXX We shouldn't be using processor-specific/bus-specific code in
|
|
|
|
* here, but we need the start of the ISA hole (IOM_BEGIN).
|
1997-10-23 22:54:47 +00:00
|
|
|
*/
|
1998-05-05 13:21:08 +00:00
|
|
|
#ifdef PC98
|
|
|
|
#include <pc98/pc98/pc98.h>
|
|
|
|
#else
|
1997-10-24 15:27:16 +00:00
|
|
|
#include <i386/isa/isa.h>
|
1998-05-05 13:21:08 +00:00
|
|
|
#endif
|
1997-10-23 22:54:47 +00:00
|
|
|
|
1997-04-20 07:21:12 +00:00
|
|
|
SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard");
|
|
|
|
|
|
|
|
static int pcic_resume_reset =
|
1998-09-08 18:09:51 +00:00
|
|
|
#ifdef PCIC_RESUME_RESET /* opt_pcic.h */
|
1997-04-20 07:21:12 +00:00
|
|
|
1;
|
|
|
|
#else
|
|
|
|
0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SYSCTL_INT(_machdep_pccard, OID_AUTO, pcic_resume_reset, CTLFLAG_RW,
|
|
|
|
&pcic_resume_reset, 0, "");
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
#define PCCARD_MEMSIZE (4*1024)
|
|
|
|
|
|
|
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
static int allocate_driver(struct slot *, struct dev_desc *);
|
1995-11-09 20:44:36 +00:00
|
|
|
static void inserted(void *);
|
|
|
|
static void disable_slot(struct slot *);
|
1999-12-01 07:38:54 +00:00
|
|
|
static void disable_slot_spl0(struct slot *);
|
|
|
|
static void disable_slot_to(void *);
|
1995-11-09 20:44:36 +00:00
|
|
|
static int invalid_io_memory(unsigned long, int);
|
1996-04-23 16:03:08 +00:00
|
|
|
static void power_off_slot(void *);
|
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
static struct slot *pccard_slots[MAXSLOT]; /* slot entries */
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* The driver interface for read/write uses a block
|
|
|
|
* of memory in the ISA I/O memory space allocated via
|
|
|
|
* an ioctl setting.
|
|
|
|
*/
|
|
|
|
static unsigned long pccard_mem; /* Physical memory */
|
|
|
|
static unsigned char *pccard_kmem; /* Kernel virtual address */
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static d_open_t crdopen;
|
|
|
|
static d_close_t crdclose;
|
|
|
|
static d_read_t crdread;
|
|
|
|
static d_write_t crdwrite;
|
|
|
|
static d_ioctl_t crdioctl;
|
1997-09-14 03:19:42 +00:00
|
|
|
static d_poll_t crdpoll;
|
1995-12-08 11:19:42 +00:00
|
|
|
|
|
|
|
#define CDEV_MAJOR 50
|
1999-05-30 16:53:49 +00:00
|
|
|
static struct cdevsw crd_cdevsw = {
|
|
|
|
/* open */ crdopen,
|
|
|
|
/* close */ crdclose,
|
|
|
|
/* read */ crdread,
|
|
|
|
/* write */ crdwrite,
|
|
|
|
/* ioctl */ crdioctl,
|
|
|
|
/* poll */ crdpoll,
|
|
|
|
/* mmap */ nommap,
|
|
|
|
/* strategy */ nostrategy,
|
|
|
|
/* name */ "crd",
|
|
|
|
/* maj */ CDEV_MAJOR,
|
|
|
|
/* dump */ nodump,
|
|
|
|
/* psize */ nopsize,
|
|
|
|
/* flags */ 0,
|
|
|
|
/* bmaj */ -1
|
|
|
|
};
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1996-04-23 16:03:08 +00:00
|
|
|
/*
|
|
|
|
* Power off the slot.
|
|
|
|
* (doing it immediately makes the removal of some cards unstable)
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
power_off_slot(void *arg)
|
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = (struct slot *)arg;
|
1999-10-25 02:41:58 +00:00
|
|
|
int s;
|
1996-04-23 16:03:08 +00:00
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
/*
|
|
|
|
* The following will generate an interrupt. So, to hold off
|
|
|
|
* the interrupt unitl after disable runs so that we can get rid
|
|
|
|
* rid of the interrupt before it becomes unsafe to touch the
|
|
|
|
* device.
|
|
|
|
*/
|
|
|
|
s = splhigh();
|
1996-04-23 16:03:08 +00:00
|
|
|
/* Power off the slot. */
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->pwr_off_pending = 0;
|
|
|
|
slt->ctrl->disable(slt);
|
1999-10-25 02:41:58 +00:00
|
|
|
splx(s);
|
1997-10-23 22:54:47 +00:00
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* disable_slot - Disables the slot by removing
|
|
|
|
* the power and unmapping the I/O
|
|
|
|
*/
|
|
|
|
static void
|
1997-10-26 04:36:24 +00:00
|
|
|
disable_slot(struct slot *slt)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1999-12-01 07:38:54 +00:00
|
|
|
/* XXX Need to store pccarddev in slt. */
|
1999-09-06 06:34:44 +00:00
|
|
|
device_t pccarddev;
|
1999-12-01 07:38:54 +00:00
|
|
|
device_t *kids;
|
|
|
|
int nkids;
|
1995-11-09 20:44:36 +00:00
|
|
|
int i;
|
1999-12-01 07:38:54 +00:00
|
|
|
int ret;
|
1999-09-06 06:34:44 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Note that a race condition is possible here; if a
|
|
|
|
* driver is accessing the device and it is removed, then
|
|
|
|
* all bets are off...
|
|
|
|
*/
|
1999-12-01 07:38:54 +00:00
|
|
|
pccarddev = devclass_get_device(pccard_devclass, slt->slotnum);
|
|
|
|
device_get_children(pccarddev, &kids, &nkids);
|
|
|
|
for (i = 0; i < nkids; i++) {
|
|
|
|
if ((ret = device_delete_child(pccarddev, kids[i])) != 0)
|
1999-12-02 19:51:34 +00:00
|
|
|
printf("pccard: delete of %s failed: %d\n",
|
|
|
|
device_get_nameunit(kids[i]), ret);
|
1999-12-01 07:38:54 +00:00
|
|
|
}
|
1999-12-02 19:51:34 +00:00
|
|
|
free(kids, M_TEMP);
|
1997-10-23 22:54:47 +00:00
|
|
|
|
|
|
|
/* Power off the slot 1/2 second after removal of the card */
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->poff_ch = timeout(power_off_slot, (caddr_t)slt, hz / 2);
|
|
|
|
slt->pwr_off_pending = 1;
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
|
|
|
|
1999-12-01 07:38:54 +00:00
|
|
|
static void
|
|
|
|
disable_slot_to(void *argp)
|
|
|
|
{
|
|
|
|
struct slot *slt = (struct slot *) argp;
|
|
|
|
|
|
|
|
disable_slot(slt);
|
|
|
|
slt->state = empty;
|
|
|
|
printf("pccard: card removed, slot %d\n", slt->slotnum);
|
|
|
|
pccard_remove_beep();
|
|
|
|
selwakeup(&slt->selp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disables the slot later when we drop to spl0 via a timeout.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
disable_slot_spl0(struct slot *slt)
|
|
|
|
{
|
|
|
|
slt->disable_ch = timeout(disable_slot_to, (caddr_t) slt, 0);
|
|
|
|
}
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* pccard_alloc_slot - Called from controller probe
|
|
|
|
* routine, this function allocates a new PC-CARD slot
|
|
|
|
* and initialises the data structures using the data provided.
|
|
|
|
* It returns the allocated structure to the probe routine
|
|
|
|
* to allow the controller specific data to be initialised.
|
|
|
|
*/
|
|
|
|
struct slot *
|
1997-10-26 04:36:24 +00:00
|
|
|
pccard_alloc_slot(struct slot_ctrl *ctrl)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt;
|
|
|
|
int slotno;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
for (slotno = 0; slotno < MAXSLOT; slotno++)
|
|
|
|
if (pccard_slots[slotno] == 0)
|
|
|
|
break;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slotno == MAXSLOT)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
1997-10-26 04:36:24 +00:00
|
|
|
|
|
|
|
MALLOC(slt, struct slot *, sizeof(*slt), M_DEVBUF, M_WAITOK);
|
|
|
|
bzero(slt, sizeof(*slt));
|
1999-08-23 20:59:21 +00:00
|
|
|
make_dev(&crd_cdevsw, slotno, 0, 0, 0600, "card%d", slotno);
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->ctrl = ctrl;
|
|
|
|
slt->slotnum = slotno;
|
|
|
|
pccard_slots[slotno] = slt;
|
1997-10-26 02:55:31 +00:00
|
|
|
callout_handle_init(&slt->insert_ch);
|
|
|
|
callout_handle_init(&slt->poff_ch);
|
1999-12-01 07:38:54 +00:00
|
|
|
callout_handle_init(&slt->disable_ch);
|
1997-10-26 04:36:24 +00:00
|
|
|
return(slt);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* allocate_driver - Create a new device entry for this
|
|
|
|
* slot, and attach a driver to it.
|
|
|
|
*/
|
|
|
|
static int
|
1997-10-26 04:36:24 +00:00
|
|
|
allocate_driver(struct slot *slt, struct dev_desc *desc)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct pccard_devinfo *devi;
|
1999-09-06 06:34:44 +00:00
|
|
|
device_t pccarddev;
|
1999-10-15 17:29:21 +00:00
|
|
|
int err, irq = 0;
|
1999-10-25 02:41:58 +00:00
|
|
|
device_t child;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1999-12-08 05:34:17 +00:00
|
|
|
pccarddev = devclass_get_device(pccard_devclass, slt->slotnum);
|
1999-10-25 02:41:58 +00:00
|
|
|
irq = ffs(desc->irqmask) - 1;
|
1997-10-26 04:36:24 +00:00
|
|
|
MALLOC(devi, struct pccard_devinfo *, sizeof(*devi), M_DEVBUF, M_WAITOK);
|
|
|
|
bzero(devi, sizeof(*devi));
|
1999-10-25 02:41:58 +00:00
|
|
|
strcpy(devi->name, desc->name);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Create an entry for the device under this slot.
|
|
|
|
*/
|
1998-04-09 14:01:13 +00:00
|
|
|
devi->running = 1;
|
1997-10-26 04:36:24 +00:00
|
|
|
devi->slt = slt;
|
|
|
|
bcopy(desc->misc, devi->misc, sizeof(desc->misc));
|
1999-10-25 02:41:58 +00:00
|
|
|
resource_list_init(&devi->resources);
|
1999-12-08 07:55:20 +00:00
|
|
|
child = device_add_child(pccarddev, devi->name, desc->unit);
|
1999-10-25 23:17:24 +00:00
|
|
|
device_set_flags(child, desc->flags);
|
1999-12-03 08:41:24 +00:00
|
|
|
device_set_ivars(child, devi);
|
1999-10-25 23:17:24 +00:00
|
|
|
err = bus_set_resource(child, SYS_RES_IOPORT, 0, desc->iobase,
|
|
|
|
desc->iosize);
|
|
|
|
if (err)
|
|
|
|
goto err;
|
|
|
|
if (irq)
|
|
|
|
err = bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
|
|
|
|
if (err)
|
|
|
|
goto err;
|
|
|
|
if (desc->memsize) {
|
|
|
|
err = bus_set_resource(child, SYS_RES_MEMORY, 0, desc->mem,
|
|
|
|
desc->memsize);
|
|
|
|
if (err)
|
|
|
|
goto err;
|
|
|
|
}
|
1999-10-25 02:41:58 +00:00
|
|
|
err = device_probe_and_attach(child);
|
1999-10-25 23:17:24 +00:00
|
|
|
err:
|
1999-10-25 02:41:58 +00:00
|
|
|
if (err)
|
|
|
|
device_delete_child(pccarddev, child);
|
1999-10-25 23:17:24 +00:00
|
|
|
return (err);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* card insert routine - Called from a timeout to debounce
|
|
|
|
* insertion events.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
inserted(void *arg)
|
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = arg;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->state = filled;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Enable 5V to the card so that the CIS can be read.
|
|
|
|
*/
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->pwr.vcc = 50;
|
|
|
|
slt->pwr.vpp = 0;
|
1997-10-23 22:54:47 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
1999-12-01 07:38:54 +00:00
|
|
|
untimeout(power_off_slot, (caddr_t)slt, slt->disable_ch);
|
1997-10-26 04:36:24 +00:00
|
|
|
untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch);
|
|
|
|
power_off_slot(slt);
|
|
|
|
slt->ctrl->power(slt);
|
1997-10-23 22:54:47 +00:00
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
printf("pccard: card inserted, slot %d\n", slt->slotnum);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Now start resetting the card.
|
|
|
|
*/
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->ctrl->reset(slt);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Card event callback. Called at splhigh to prevent
|
|
|
|
* device interrupts from interceding.
|
|
|
|
*/
|
|
|
|
void
|
1997-10-26 04:36:24 +00:00
|
|
|
pccard_event(struct slot *slt, enum card_event event)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->insert_seq) {
|
|
|
|
slt->insert_seq = 0;
|
|
|
|
untimeout(inserted, (void *)slt, slt->insert_ch);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1997-10-26 04:36:24 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
switch(event) {
|
1995-08-24 08:56:20 +00:00
|
|
|
case card_removed:
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* The slot and devices are disabled, but the
|
|
|
|
* data structures are not unlinked.
|
|
|
|
*/
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->state == filled) {
|
1999-12-01 07:38:54 +00:00
|
|
|
disable_slot_spl0(slt);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
case card_inserted:
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->insert_seq = 1;
|
|
|
|
slt->insert_ch = timeout(inserted, (void *)slt, hz/4);
|
1999-05-02 04:19:27 +00:00
|
|
|
pccard_insert_beep();
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1996-06-05 05:30:09 +00:00
|
|
|
/*
|
|
|
|
* Device driver interface.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-08-24 08:56:20 +00:00
|
|
|
crdopen(dev_t dev, int oflags, int devtype, struct proc *p)
|
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
if (minor(dev) >= MAXSLOT)
|
|
|
|
return(ENXIO);
|
1997-10-26 04:36:24 +00:00
|
|
|
slt = pccard_slots[minor(dev)];
|
|
|
|
if (slt == 0)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(ENXIO);
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->rwmem == 0)
|
|
|
|
slt->rwmem = MDF_ATTR;
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Close doesn't de-allocate any resources, since
|
|
|
|
* slots may be assigned to drivers already.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-08-24 08:56:20 +00:00
|
|
|
crdclose(dev_t dev, int fflag, int devtype, struct proc *p)
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* read interface. Map memory at lseek offset,
|
|
|
|
* then transfer to user space.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-08-24 08:56:20 +00:00
|
|
|
crdread(dev_t dev, struct uio *uio, int ioflag)
|
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = pccard_slots[minor(dev)];
|
1995-11-09 20:44:36 +00:00
|
|
|
struct mem_desc *mp, oldmap;
|
1997-10-26 04:36:24 +00:00
|
|
|
unsigned char *p;
|
1995-11-09 20:44:36 +00:00
|
|
|
unsigned int offs;
|
1997-10-26 04:36:24 +00:00
|
|
|
int error = 0, win, count;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt == 0 || slt->state != filled)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(ENXIO);
|
|
|
|
if (pccard_mem == 0)
|
|
|
|
return(ENOMEM);
|
1997-10-26 04:36:24 +00:00
|
|
|
for (win = 0; win < slt->ctrl->maxmem; win++)
|
|
|
|
if ((slt->mem[win].flags & MDF_ACTIVE) == 0)
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (win >= slt->ctrl->maxmem)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EBUSY);
|
1997-10-26 04:36:24 +00:00
|
|
|
mp = &slt->mem[win];
|
1995-08-24 08:56:20 +00:00
|
|
|
oldmap = *mp;
|
1997-10-26 04:36:24 +00:00
|
|
|
mp->flags = slt->rwmem|MDF_ACTIVE;
|
1995-11-09 20:44:36 +00:00
|
|
|
while (uio->uio_resid && error == 0) {
|
1995-08-24 08:56:20 +00:00
|
|
|
mp->card = uio->uio_offset;
|
|
|
|
mp->size = PCCARD_MEMSIZE;
|
1998-08-16 01:21:52 +00:00
|
|
|
mp->start = (caddr_t)(void *)(uintptr_t)pccard_mem;
|
1999-01-27 23:45:44 +00:00
|
|
|
if ((error = slt->ctrl->mapmem(slt, win)) != 0)
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
offs = (unsigned int)uio->uio_offset & (PCCARD_MEMSIZE - 1);
|
|
|
|
p = pccard_kmem + offs;
|
|
|
|
count = MIN(PCCARD_MEMSIZE - offs, uio->uio_resid);
|
|
|
|
error = uiomove(p, count, uio);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Restore original map.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
*mp = oldmap;
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->ctrl->mapmem(slt, win);
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* crdwrite - Write data to card memory.
|
|
|
|
* Handles wrap around so that only one memory
|
|
|
|
* window is used.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1995-08-24 08:56:20 +00:00
|
|
|
crdwrite(dev_t dev, struct uio *uio, int ioflag)
|
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = pccard_slots[minor(dev)];
|
1995-11-09 20:44:36 +00:00
|
|
|
struct mem_desc *mp, oldmap;
|
1997-10-26 04:36:24 +00:00
|
|
|
unsigned char *p;
|
1995-11-09 20:44:36 +00:00
|
|
|
unsigned int offs;
|
1997-10-26 04:36:24 +00:00
|
|
|
int error = 0, win, count;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt == 0 || slt->state != filled)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(ENXIO);
|
|
|
|
if (pccard_mem == 0)
|
|
|
|
return(ENOMEM);
|
1997-10-26 04:36:24 +00:00
|
|
|
for (win = 0; win < slt->ctrl->maxmem; win++)
|
1999-10-25 02:41:58 +00:00
|
|
|
if ((slt->mem[win].flags & MDF_ACTIVE) == 0)
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (win >= slt->ctrl->maxmem)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EBUSY);
|
1997-10-26 04:36:24 +00:00
|
|
|
mp = &slt->mem[win];
|
1995-08-24 08:56:20 +00:00
|
|
|
oldmap = *mp;
|
1997-10-26 04:36:24 +00:00
|
|
|
mp->flags = slt->rwmem|MDF_ACTIVE;
|
1995-11-09 20:44:36 +00:00
|
|
|
while (uio->uio_resid && error == 0) {
|
1995-08-24 08:56:20 +00:00
|
|
|
mp->card = uio->uio_offset;
|
|
|
|
mp->size = PCCARD_MEMSIZE;
|
1998-08-16 01:21:52 +00:00
|
|
|
mp->start = (caddr_t)(void *)(uintptr_t)pccard_mem;
|
1999-01-27 23:45:44 +00:00
|
|
|
if ((error = slt->ctrl->mapmem(slt, win)) != 0)
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
|
|
|
offs = (unsigned int)uio->uio_offset & (PCCARD_MEMSIZE - 1);
|
|
|
|
p = pccard_kmem + offs;
|
|
|
|
count = MIN(PCCARD_MEMSIZE - offs, uio->uio_resid);
|
|
|
|
error = uiomove(p, count, uio);
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Restore original map.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
*mp = oldmap;
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->ctrl->mapmem(slt, win);
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
return(error);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* ioctl calls - allows setting/getting of memory and I/O
|
|
|
|
* descriptors, and assignment of drivers.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1998-06-07 17:13:14 +00:00
|
|
|
crdioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = pccard_slots[minor(dev)];
|
1995-11-09 20:44:36 +00:00
|
|
|
struct mem_desc *mp;
|
|
|
|
struct io_desc *ip;
|
1997-10-26 04:36:24 +00:00
|
|
|
int s, err;
|
1999-12-02 05:46:22 +00:00
|
|
|
int pwval;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt == 0 && cmd != PIOCRWMEM)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(ENXIO);
|
1995-11-09 20:44:36 +00:00
|
|
|
switch(cmd) {
|
1995-08-24 08:56:20 +00:00
|
|
|
default:
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->ctrl->ioctl)
|
|
|
|
return(slt->ctrl->ioctl(slt, cmd, data));
|
1999-08-01 18:12:51 +00:00
|
|
|
return(ENOTTY);
|
1997-10-26 04:36:24 +00:00
|
|
|
/*
|
|
|
|
* Get slot state.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCGSTATE:
|
|
|
|
s = splhigh();
|
1997-10-26 04:36:24 +00:00
|
|
|
((struct slotstate *)data)->state = slt->state;
|
1998-04-20 15:21:02 +00:00
|
|
|
((struct slotstate *)data)->laststate = slt->laststate;
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->laststate = slt->state;
|
1995-08-24 08:56:20 +00:00
|
|
|
splx(s);
|
1997-10-26 04:36:24 +00:00
|
|
|
((struct slotstate *)data)->maxmem = slt->ctrl->maxmem;
|
|
|
|
((struct slotstate *)data)->maxio = slt->ctrl->maxio;
|
1999-10-25 02:41:58 +00:00
|
|
|
((struct slotstate *)data)->irqs = 0;
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Get memory context.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCGMEM:
|
|
|
|
s = ((struct mem_desc *)data)->window;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (s < 0 || s >= slt->ctrl->maxmem)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EINVAL);
|
1997-10-26 04:36:24 +00:00
|
|
|
mp = &slt->mem[s];
|
1995-08-24 08:56:20 +00:00
|
|
|
((struct mem_desc *)data)->flags = mp->flags;
|
|
|
|
((struct mem_desc *)data)->start = mp->start;
|
|
|
|
((struct mem_desc *)data)->size = mp->size;
|
|
|
|
((struct mem_desc *)data)->card = mp->card;
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Set memory context. If context already active, then unmap it.
|
|
|
|
* It is hard to see how the parameters can be checked.
|
|
|
|
* At the very least, we only allow root to set the context.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCSMEM:
|
1999-04-27 11:18:52 +00:00
|
|
|
if (suser(p))
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EPERM);
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->state != filled)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(ENXIO);
|
|
|
|
s = ((struct mem_desc *)data)->window;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (s < 0 || s >= slt->ctrl->maxmem)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EINVAL);
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->mem[s] = *((struct mem_desc *)data);
|
|
|
|
return(slt->ctrl->mapmem(slt, s));
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Get I/O port context.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCGIO:
|
|
|
|
s = ((struct io_desc *)data)->window;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (s < 0 || s >= slt->ctrl->maxio)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EINVAL);
|
1997-10-26 04:36:24 +00:00
|
|
|
ip = &slt->io[s];
|
1995-08-24 08:56:20 +00:00
|
|
|
((struct io_desc *)data)->flags = ip->flags;
|
|
|
|
((struct io_desc *)data)->start = ip->start;
|
|
|
|
((struct io_desc *)data)->size = ip->size;
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Set I/O port context.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCSIO:
|
1999-04-27 11:18:52 +00:00
|
|
|
if (suser(p))
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EPERM);
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt->state != filled)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(ENXIO);
|
|
|
|
s = ((struct io_desc *)data)->window;
|
1997-10-26 04:36:24 +00:00
|
|
|
if (s < 0 || s >= slt->ctrl->maxio)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EINVAL);
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->io[s] = *((struct io_desc *)data);
|
1999-10-25 02:41:58 +00:00
|
|
|
/* XXX Don't actually map */
|
|
|
|
return 0;
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
1997-10-26 04:36:24 +00:00
|
|
|
* Set memory window flags for read/write interface.
|
1995-11-09 20:44:36 +00:00
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCRWFLAG:
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->rwmem = *(int *)data;
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
1997-10-26 04:36:24 +00:00
|
|
|
* Set the memory window to be used for the read/write interface.
|
1995-11-09 20:44:36 +00:00
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCRWMEM:
|
1995-11-09 20:44:36 +00:00
|
|
|
if (*(unsigned long *)data == 0) {
|
1995-08-24 08:56:20 +00:00
|
|
|
if (pccard_mem)
|
|
|
|
*(unsigned long *)data = pccard_mem;
|
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
}
|
1999-04-27 11:18:52 +00:00
|
|
|
if (suser(p))
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EPERM);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Validate the memory by checking it against the I/O
|
|
|
|
* memory range. It must also start on an aligned block size.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
if (invalid_io_memory(*(unsigned long *)data, PCCARD_MEMSIZE))
|
|
|
|
return(EINVAL);
|
|
|
|
if (*(unsigned long *)data & (PCCARD_MEMSIZE-1))
|
|
|
|
return(EINVAL);
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* Map it to kernel VM.
|
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
pccard_mem = *(unsigned long *)data;
|
1998-08-16 01:21:52 +00:00
|
|
|
pccard_kmem =
|
|
|
|
(unsigned char *)(void *)(uintptr_t)
|
|
|
|
(pccard_mem + atdevbase - IOM_BEGIN);
|
1995-08-24 08:56:20 +00:00
|
|
|
break;
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
1997-10-26 04:36:24 +00:00
|
|
|
* Set power values.
|
1995-11-09 20:44:36 +00:00
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCSPOW:
|
1997-10-26 04:36:24 +00:00
|
|
|
slt->pwr = *(struct power *)data;
|
|
|
|
return(slt->ctrl->power(slt));
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
1997-10-26 04:36:24 +00:00
|
|
|
* Allocate a driver to this slot.
|
1995-11-09 20:44:36 +00:00
|
|
|
*/
|
1995-08-24 08:56:20 +00:00
|
|
|
case PIOCSDRV:
|
1999-04-27 11:18:52 +00:00
|
|
|
if (suser(p))
|
1995-08-24 08:56:20 +00:00
|
|
|
return(EPERM);
|
1997-10-26 04:36:24 +00:00
|
|
|
err = allocate_driver(slt, (struct dev_desc *)data);
|
1996-02-21 23:20:21 +00:00
|
|
|
if (!err)
|
1997-10-26 06:06:54 +00:00
|
|
|
pccard_success_beep();
|
1996-02-21 23:20:21 +00:00
|
|
|
else
|
1997-10-26 06:06:54 +00:00
|
|
|
pccard_failure_beep();
|
1996-02-21 23:20:21 +00:00
|
|
|
return err;
|
1999-12-02 05:46:22 +00:00
|
|
|
/*
|
|
|
|
* Virtual removal/insertion
|
|
|
|
*/
|
|
|
|
case PIOCSVIR:
|
|
|
|
pwval = *(int *)data;
|
|
|
|
if (!pwval) {
|
|
|
|
if (slt->state != filled)
|
|
|
|
return EINVAL;
|
|
|
|
} else {
|
|
|
|
if (slt->state != empty)
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
pccard_event(slt, pwval == 0 ? card_removed : card_inserted);
|
|
|
|
break;
|
1999-02-13 11:32:00 +00:00
|
|
|
case PIOCSBEEP:
|
|
|
|
if (pccard_beep_select(*(int *)data)) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
1997-10-23 22:54:47 +00:00
|
|
|
}
|
1995-08-24 08:56:20 +00:00
|
|
|
return(0);
|
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
1997-09-14 03:19:42 +00:00
|
|
|
* poll - Poll on exceptions will return true
|
1995-08-24 08:56:20 +00:00
|
|
|
* when a change in card status occurs.
|
|
|
|
*/
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1997-09-14 03:19:42 +00:00
|
|
|
crdpoll(dev_t dev, int events, struct proc *p)
|
1995-08-24 08:56:20 +00:00
|
|
|
{
|
1995-11-09 20:44:36 +00:00
|
|
|
int s;
|
1997-10-26 04:36:24 +00:00
|
|
|
struct slot *slt = pccard_slots[minor(dev)];
|
1997-09-14 03:19:42 +00:00
|
|
|
int revents = 0;
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1997-09-14 03:19:42 +00:00
|
|
|
if (events & (POLLIN | POLLRDNORM))
|
|
|
|
revents |= events & (POLLIN | POLLRDNORM);
|
|
|
|
|
|
|
|
if (events & (POLLOUT | POLLWRNORM))
|
|
|
|
revents |= events & (POLLIN | POLLRDNORM);
|
|
|
|
|
|
|
|
s = splhigh();
|
1995-11-09 20:44:36 +00:00
|
|
|
/*
|
|
|
|
* select for exception - card event.
|
|
|
|
*/
|
1997-09-14 03:19:42 +00:00
|
|
|
if (events & POLLRDBAND)
|
1997-10-26 04:36:24 +00:00
|
|
|
if (slt == 0 || slt->laststate != slt->state)
|
1997-09-14 03:19:42 +00:00
|
|
|
revents |= POLLRDBAND;
|
|
|
|
|
|
|
|
if (revents == 0)
|
1997-10-26 04:36:24 +00:00
|
|
|
selrecord(p, &slt->selp);
|
1997-09-14 03:19:42 +00:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return (revents);
|
1995-08-24 08:56:20 +00:00
|
|
|
}
|
1995-11-09 20:44:36 +00:00
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* invalid_io_memory - verify that the ISA I/O memory block
|
|
|
|
* is a valid and unallocated address.
|
|
|
|
* A simple check of the range is done, and then a
|
|
|
|
* search of the current devices is done to check for
|
|
|
|
* overlapping regions.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
invalid_io_memory(unsigned long adr, int size)
|
|
|
|
{
|
1997-10-24 15:27:16 +00:00
|
|
|
/* XXX - What's magic about 0xC0000?? */
|
|
|
|
if (adr < 0xC0000 || (adr+size) > IOM_END)
|
1995-08-24 08:56:20 +00:00
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
1999-12-08 07:55:20 +00:00
|
|
|
|
|
|
|
static struct slot *
|
|
|
|
pccard_dev2slot(device_t dev)
|
|
|
|
{
|
|
|
|
return pccard_slots[device_get_unit(dev)];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* APM hooks for suspending and resuming.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
pccard_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
struct slot *slt = pccard_dev2slot(dev);
|
|
|
|
|
|
|
|
/* This code stolen from pccard_event:card_removed */
|
|
|
|
if (slt->state == filled) {
|
|
|
|
int s = splhigh();
|
|
|
|
disable_slot(slt);
|
|
|
|
slt->laststate = filled;
|
|
|
|
slt->state = suspend;
|
|
|
|
splx(s);
|
|
|
|
printf("pccard: card disabled, slot %d\n", slt->slotnum);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Disable any pending timeouts for this slot since we're
|
|
|
|
* powering it down/disabling now.
|
|
|
|
*/
|
|
|
|
untimeout(power_off_slot, (caddr_t)slt, slt->disable_ch);
|
|
|
|
untimeout(power_off_slot, (caddr_t)slt, slt->poff_ch);
|
|
|
|
slt->ctrl->disable(slt);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pccard_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct slot *slt = pccard_dev2slot(dev);
|
|
|
|
|
|
|
|
if (pcic_resume_reset)
|
|
|
|
slt->ctrl->resume(slt);
|
|
|
|
/* This code stolen from pccard_event:card_inserted */
|
|
|
|
if (slt->state == suspend) {
|
|
|
|
slt->laststate = suspend;
|
|
|
|
slt->state = empty;
|
|
|
|
slt->insert_seq = 1;
|
|
|
|
untimeout(inserted, (void *)slt, slt->insert_ch);
|
|
|
|
inserted((void *) slt);
|
|
|
|
selwakeup(&slt->selp);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|