2005-01-07 02:29:27 +00:00
|
|
|
/*-
|
2001-05-25 18:03:07 +00:00
|
|
|
* Copyright (c) 1999, 2001 M. Warner Losh. All rights reserved.
|
1999-09-06 06:34:44 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-09-06 11:23:05 +00:00
|
|
|
* $FreeBSD$
|
1999-09-06 06:34:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains various kludges to allow the legacy pccard system to
|
2000-04-25 06:07:27 +00:00
|
|
|
* work in the newbus system until the pccard system can be converted
|
1999-09-06 06:34:44 +00:00
|
|
|
* wholesale to newbus. As that is a while off, I'm providing this glue to
|
|
|
|
* allow newbus drivers to have pccard attachments.
|
|
|
|
*
|
|
|
|
* We do *NOT* implement ISA ivars at all. We are not an isa bus, and drivers
|
|
|
|
* that abuse isa_{set,get}_* must be fixed in order to work with pccard.
|
|
|
|
* We use ivars for something else anyway, so it becomes fairly awkward
|
|
|
|
* to do so.
|
|
|
|
*
|
|
|
|
* Here's a summary of the glue that we do to make things work.
|
|
|
|
*
|
|
|
|
* First, we have pccard node in the device and driver trees. The pccard
|
|
|
|
* device lives in the instance tree attached to the nexus. The pccard
|
|
|
|
* attachments will be attached to that node. This allows one to pass things
|
|
|
|
* up the tree that terminates at the nexus, like other buses. The pccard
|
|
|
|
* code will create a device instance for each of the drivers that are to
|
|
|
|
* be attached.
|
|
|
|
*
|
|
|
|
* These compatibility nodes are called pccnbk. PCCard New Bus Kludge.
|
|
|
|
*/
|
|
|
|
|
2003-06-12 04:46:43 +00:00
|
|
|
#define OBSOLETE_IN_6
|
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/kernel.h>
|
2001-05-08 22:51:05 +00:00
|
|
|
#include <sys/sysctl.h>
|
1999-09-06 06:34:44 +00:00
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
2001-05-15 23:43:02 +00:00
|
|
|
/* XXX Shouldn't reach into the MD code here */
|
|
|
|
#ifdef PC98
|
|
|
|
#include <pc98/pc98/pc98.h>
|
|
|
|
#else
|
2001-05-08 22:51:05 +00:00
|
|
|
#include <i386/isa/isa.h>
|
2001-05-15 23:43:02 +00:00
|
|
|
#endif
|
2001-05-08 22:51:05 +00:00
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
#include <pccard/cardinfo.h>
|
|
|
|
#include <pccard/slot.h>
|
|
|
|
|
2000-01-21 03:08:46 +00:00
|
|
|
#include <dev/pccard/pccardvar.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
2000-04-20 08:37:46 +00:00
|
|
|
#include "card_if.h"
|
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
devclass_t pccard_devclass;
|
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
#define PCCARD_NPORT 2
|
|
|
|
#define PCCARD_NMEM 5
|
|
|
|
#define PCCARD_NIRQ 1
|
|
|
|
#define PCCARD_NDRQ 0
|
|
|
|
|
1999-12-08 07:55:20 +00:00
|
|
|
#define PCCARD_DEVINFO(d) (struct pccard_devinfo *) device_get_ivars(d)
|
|
|
|
|
2001-05-08 22:51:05 +00:00
|
|
|
SYSCTL_NODE(_machdep, OID_AUTO, pccard, CTLFLAG_RW, 0, "pccard");
|
|
|
|
|
2002-07-17 05:50:06 +00:00
|
|
|
#ifdef UNSAFE
|
2001-05-14 05:56:12 +00:00
|
|
|
static u_long mem_start = IOM_BEGIN;
|
|
|
|
static u_long mem_end = IOM_END;
|
2002-07-17 05:50:06 +00:00
|
|
|
#else
|
|
|
|
static u_long mem_start = 0xd0000;
|
|
|
|
static u_long mem_end = 0xeffff;
|
|
|
|
#endif
|
2001-05-08 22:51:05 +00:00
|
|
|
|
2001-05-14 05:56:12 +00:00
|
|
|
SYSCTL_ULONG(_machdep_pccard, OID_AUTO, mem_start, CTLFLAG_RW,
|
|
|
|
&mem_start, 0, "");
|
|
|
|
SYSCTL_ULONG(_machdep_pccard, OID_AUTO, mem_end, CTLFLAG_RW,
|
|
|
|
&mem_end, 0, "");
|
2001-05-08 22:51:05 +00:00
|
|
|
|
2001-07-28 04:25:11 +00:00
|
|
|
#if __FreeBSD_version >= 500000
|
Implement indirection in the pccard probe/attach. This should make it
possible to have different probe/attach semantics between the two
systems and yet still use the same driver for both.
Compatibility methods for OLDCARD drivers. We use these routines to make
it possible to call the OLDCARD driver's probe routine in the context that
it expects. For OLDCARD these are implemented as pass throughs to the
device_{probe,attach} routines. For NEWCARD they are implemented such
such that probe becomes strictly a matching routine and attach does both
the old probe and old attach.
compat devices should use the following:
/* Device interface */
DEVMETHOD(device_probe), pccard_compat_probe),
DEVMETHOD(device_attach), pccard_compat_attach),
/* Card interface */
DEVMETHOD(card_compat_match, foo_match), /* newly written */
DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
This will allow a single driver binary image to be used for both
OLDCARD and NEWCARD.
Drivers wishing to not retain OLDCARD compatibility needn't do this.
ep driver minorly updated.
sn driver updated more than minorly. Add module dependencies to allow
module to load. Also change name to if_sn. Add some debugging code.
attempt to fix the cannot allocate memory problem I'd been seeing.
Minor formatting nits.
2000-09-19 04:39:20 +00:00
|
|
|
/*
|
|
|
|
* glue for NEWCARD/OLDCARD compat layer
|
|
|
|
*/
|
2001-03-22 06:00:07 +00:00
|
|
|
static int
|
|
|
|
pccard_compat_do_probe(device_t bus, device_t dev)
|
Implement indirection in the pccard probe/attach. This should make it
possible to have different probe/attach semantics between the two
systems and yet still use the same driver for both.
Compatibility methods for OLDCARD drivers. We use these routines to make
it possible to call the OLDCARD driver's probe routine in the context that
it expects. For OLDCARD these are implemented as pass throughs to the
device_{probe,attach} routines. For NEWCARD they are implemented such
such that probe becomes strictly a matching routine and attach does both
the old probe and old attach.
compat devices should use the following:
/* Device interface */
DEVMETHOD(device_probe), pccard_compat_probe),
DEVMETHOD(device_attach), pccard_compat_attach),
/* Card interface */
DEVMETHOD(card_compat_match, foo_match), /* newly written */
DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
This will allow a single driver binary image to be used for both
OLDCARD and NEWCARD.
Drivers wishing to not retain OLDCARD compatibility needn't do this.
ep driver minorly updated.
sn driver updated more than minorly. Add module dependencies to allow
module to load. Also change name to if_sn. Add some debugging code.
attempt to fix the cannot allocate memory problem I'd been seeing.
Minor formatting nits.
2000-09-19 04:39:20 +00:00
|
|
|
{
|
|
|
|
return (CARD_COMPAT_PROBE(dev));
|
|
|
|
}
|
|
|
|
|
2001-03-22 06:00:07 +00:00
|
|
|
static int
|
|
|
|
pccard_compat_do_attach(device_t bus, device_t dev)
|
Implement indirection in the pccard probe/attach. This should make it
possible to have different probe/attach semantics between the two
systems and yet still use the same driver for both.
Compatibility methods for OLDCARD drivers. We use these routines to make
it possible to call the OLDCARD driver's probe routine in the context that
it expects. For OLDCARD these are implemented as pass throughs to the
device_{probe,attach} routines. For NEWCARD they are implemented such
such that probe becomes strictly a matching routine and attach does both
the old probe and old attach.
compat devices should use the following:
/* Device interface */
DEVMETHOD(device_probe), pccard_compat_probe),
DEVMETHOD(device_attach), pccard_compat_attach),
/* Card interface */
DEVMETHOD(card_compat_match, foo_match), /* newly written */
DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
This will allow a single driver binary image to be used for both
OLDCARD and NEWCARD.
Drivers wishing to not retain OLDCARD compatibility needn't do this.
ep driver minorly updated.
sn driver updated more than minorly. Add module dependencies to allow
module to load. Also change name to if_sn. Add some debugging code.
attempt to fix the cannot allocate memory problem I'd been seeing.
Minor formatting nits.
2000-09-19 04:39:20 +00:00
|
|
|
{
|
|
|
|
return (CARD_COMPAT_ATTACH(dev));
|
|
|
|
}
|
2001-07-28 04:25:11 +00:00
|
|
|
#endif
|
Implement indirection in the pccard probe/attach. This should make it
possible to have different probe/attach semantics between the two
systems and yet still use the same driver for both.
Compatibility methods for OLDCARD drivers. We use these routines to make
it possible to call the OLDCARD driver's probe routine in the context that
it expects. For OLDCARD these are implemented as pass throughs to the
device_{probe,attach} routines. For NEWCARD they are implemented such
such that probe becomes strictly a matching routine and attach does both
the old probe and old attach.
compat devices should use the following:
/* Device interface */
DEVMETHOD(device_probe), pccard_compat_probe),
DEVMETHOD(device_attach), pccard_compat_attach),
/* Card interface */
DEVMETHOD(card_compat_match, foo_match), /* newly written */
DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
This will allow a single driver binary image to be used for both
OLDCARD and NEWCARD.
Drivers wishing to not retain OLDCARD compatibility needn't do this.
ep driver minorly updated.
sn driver updated more than minorly. Add module dependencies to allow
module to load. Also change name to if_sn. Add some debugging code.
attempt to fix the cannot allocate memory problem I'd been seeing.
Minor formatting nits.
2000-09-19 04:39:20 +00:00
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
static int
|
|
|
|
pccard_probe(device_t dev)
|
|
|
|
{
|
2002-07-31 20:01:11 +00:00
|
|
|
device_set_desc(dev, "PC Card 16-bit bus (classic)");
|
2001-05-13 01:44:27 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pccard_attach(device_t dev)
|
|
|
|
{
|
|
|
|
return (0);
|
1999-09-06 06:34:44 +00:00
|
|
|
}
|
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
static void
|
|
|
|
pccard_print_resources(struct resource_list *rl, const char *name, int type,
|
1999-12-08 07:55:20 +00:00
|
|
|
int count, const char *format)
|
1999-10-25 02:41:58 +00:00
|
|
|
{
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
int printed;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printed = 0;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
rle = resource_list_find(rl, type, i);
|
|
|
|
if (rle) {
|
|
|
|
if (printed == 0)
|
|
|
|
printf(" %s ", name);
|
|
|
|
else if (printed > 0)
|
|
|
|
printf(",");
|
|
|
|
printed++;
|
|
|
|
printf(format, rle->start);
|
|
|
|
if (rle->count > 1) {
|
|
|
|
printf("-");
|
|
|
|
printf(format, rle->start + rle->count - 1);
|
|
|
|
}
|
|
|
|
} else if (i > 3) {
|
|
|
|
/* check the first few regardless */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
static int
|
|
|
|
pccard_print_child(device_t dev, device_t child)
|
|
|
|
{
|
1999-12-08 07:55:20 +00:00
|
|
|
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
|
1999-10-25 02:41:58 +00:00
|
|
|
struct resource_list *rl = &devi->resources;
|
2001-09-09 17:28:02 +00:00
|
|
|
int retval = 0;
|
|
|
|
int flags = device_get_flags(child);
|
1999-09-06 06:34:44 +00:00
|
|
|
|
|
|
|
retval += bus_print_child_header(dev, child);
|
|
|
|
retval += printf(" at");
|
|
|
|
|
|
|
|
if (devi) {
|
1999-10-25 02:41:58 +00:00
|
|
|
pccard_print_resources(rl, "port", SYS_RES_IOPORT,
|
|
|
|
PCCARD_NPORT, "%#lx");
|
|
|
|
pccard_print_resources(rl, "iomem", SYS_RES_MEMORY,
|
|
|
|
PCCARD_NMEM, "%#lx");
|
|
|
|
pccard_print_resources(rl, "irq", SYS_RES_IRQ, PCCARD_NIRQ,
|
|
|
|
"%ld");
|
2000-04-25 06:07:27 +00:00
|
|
|
pccard_print_resources(rl, "drq", SYS_RES_DRQ, PCCARD_NDRQ,
|
1999-10-25 02:41:58 +00:00
|
|
|
"%ld");
|
2001-09-09 17:28:02 +00:00
|
|
|
if (flags != 0)
|
|
|
|
retval += printf(" flags 0x%x", flags);
|
1999-09-06 06:34:44 +00:00
|
|
|
retval += printf(" slot %d", devi->slt->slotnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
retval += bus_print_child_footer(dev, child);
|
|
|
|
|
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
static int
|
|
|
|
pccard_set_resource(device_t dev, device_t child, int type, int rid,
|
2000-04-25 06:07:27 +00:00
|
|
|
u_long start, u_long count)
|
1999-10-25 02:41:58 +00:00
|
|
|
{
|
1999-12-08 07:55:20 +00:00
|
|
|
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
|
1999-10-25 02:41:58 +00:00
|
|
|
struct resource_list *rl = &devi->resources;
|
|
|
|
|
|
|
|
if (type != SYS_RES_IOPORT && type != SYS_RES_MEMORY
|
|
|
|
&& type != SYS_RES_IRQ && type != SYS_RES_DRQ)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (EINVAL);
|
1999-10-25 02:41:58 +00:00
|
|
|
if (rid < 0)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (EINVAL);
|
1999-10-25 02:41:58 +00:00
|
|
|
if (type == SYS_RES_IOPORT && rid >= PCCARD_NPORT)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (EINVAL);
|
1999-10-25 02:41:58 +00:00
|
|
|
if (type == SYS_RES_MEMORY && rid >= PCCARD_NMEM)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (EINVAL);
|
1999-10-25 02:41:58 +00:00
|
|
|
if (type == SYS_RES_IRQ && rid >= PCCARD_NIRQ)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (EINVAL);
|
1999-10-25 02:41:58 +00:00
|
|
|
if (type == SYS_RES_DRQ && rid >= PCCARD_NDRQ)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (EINVAL);
|
1999-10-25 02:41:58 +00:00
|
|
|
|
|
|
|
resource_list_add(rl, type, rid, start, start + count - 1, count);
|
2000-04-25 06:07:27 +00:00
|
|
|
|
2001-05-14 06:15:24 +00:00
|
|
|
return (0);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pccard_get_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
u_long *startp, u_long *countp)
|
|
|
|
{
|
1999-12-08 07:55:20 +00:00
|
|
|
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
|
1999-10-25 02:41:58 +00:00
|
|
|
struct resource_list *rl = &devi->resources;
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
|
|
|
|
rle = resource_list_find(rl, type, rid);
|
|
|
|
if (!rle)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (ENOENT);
|
1999-10-25 02:41:58 +00:00
|
|
|
|
1999-11-20 14:56:55 +00:00
|
|
|
if (startp)
|
|
|
|
*startp = rle->start;
|
|
|
|
if (countp)
|
|
|
|
*countp = rle->count;
|
1999-10-25 02:41:58 +00:00
|
|
|
|
2001-05-14 06:15:24 +00:00
|
|
|
return (0);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
|
|
|
|
1999-10-15 03:10:13 +00:00
|
|
|
static void
|
1999-10-25 02:41:58 +00:00
|
|
|
pccard_delete_resource(device_t dev, device_t child, int type, int rid)
|
1999-10-15 03:10:13 +00:00
|
|
|
{
|
1999-12-08 07:55:20 +00:00
|
|
|
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
|
1999-10-25 02:41:58 +00:00
|
|
|
struct resource_list *rl = &devi->resources;
|
|
|
|
resource_list_delete(rl, type, rid);
|
|
|
|
}
|
1999-09-06 06:34:44 +00:00
|
|
|
|
1999-10-25 02:41:58 +00:00
|
|
|
static struct resource *
|
|
|
|
pccard_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Consider adding a resource definition. We allow rid 0 for
|
2001-05-08 22:51:05 +00:00
|
|
|
* irq, 0-4 for memory and 0-1 for ports
|
1999-10-25 02:41:58 +00:00
|
|
|
*/
|
|
|
|
int passthrough = (device_get_parent(child) != bus);
|
2000-04-25 06:07:27 +00:00
|
|
|
int isdefault;
|
1999-10-25 02:41:58 +00:00
|
|
|
struct pccard_devinfo *devi = device_get_ivars(child);
|
|
|
|
struct resource_list *rl = &devi->resources;
|
|
|
|
struct resource_list_entry *rle;
|
2000-02-21 06:52:20 +00:00
|
|
|
struct resource *res;
|
|
|
|
|
2000-04-25 06:07:27 +00:00
|
|
|
if (start == 0 && end == ~0 && type == SYS_RES_MEMORY && count != 1) {
|
2001-05-14 05:56:12 +00:00
|
|
|
start = mem_start;
|
|
|
|
end = mem_end;
|
2000-04-25 06:07:27 +00:00
|
|
|
}
|
|
|
|
isdefault = (start == 0UL && end == ~0UL);
|
1999-10-25 02:41:58 +00:00
|
|
|
if (!passthrough && !isdefault) {
|
|
|
|
rle = resource_list_find(rl, type, *rid);
|
|
|
|
if (!rle) {
|
|
|
|
if (*rid < 0)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
1999-10-25 02:41:58 +00:00
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_IRQ:
|
|
|
|
if (*rid >= PCCARD_NIRQ)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_DRQ:
|
|
|
|
if (*rid >= PCCARD_NDRQ)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_MEMORY:
|
|
|
|
if (*rid >= PCCARD_NMEM)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_IOPORT:
|
|
|
|
if (*rid >= PCCARD_NPORT)
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
1999-10-25 02:41:58 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
|
|
|
resource_list_add(rl, type, *rid, start, end, count);
|
|
|
|
}
|
|
|
|
}
|
2000-04-25 06:07:27 +00:00
|
|
|
res = resource_list_alloc(rl, bus, child, type, rid, start, end,
|
2000-02-21 06:52:20 +00:00
|
|
|
count, flags);
|
2000-04-25 06:07:27 +00:00
|
|
|
return (res);
|
1999-10-25 02:41:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pccard_release_resource(device_t bus, device_t child, int type, int rid,
|
|
|
|
struct resource *r)
|
|
|
|
{
|
1999-12-08 07:55:20 +00:00
|
|
|
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
|
1999-10-25 02:41:58 +00:00
|
|
|
struct resource_list *rl = &devi->resources;
|
2001-05-14 06:15:24 +00:00
|
|
|
return (resource_list_release(rl, bus, child, type, rid, r));
|
1999-10-15 03:10:13 +00:00
|
|
|
}
|
1999-09-06 06:34:44 +00:00
|
|
|
|
2000-01-21 03:08:46 +00:00
|
|
|
static int
|
2001-08-10 06:00:44 +00:00
|
|
|
pccard_read_ivar(device_t bus, device_t child, int which, uintptr_t *result)
|
2000-01-21 03:08:46 +00:00
|
|
|
{
|
|
|
|
struct pccard_devinfo *devi = PCCARD_DEVINFO(child);
|
|
|
|
|
|
|
|
switch (which) {
|
|
|
|
case PCCARD_IVAR_ETHADDR:
|
|
|
|
bcopy(devi->misc, result, ETHER_ADDR_LEN);
|
2001-05-14 06:15:24 +00:00
|
|
|
return (0);
|
2002-02-20 14:42:36 +00:00
|
|
|
case PCCARD_IVAR_VENDOR:
|
|
|
|
*(u_int32_t *) result = devi->manufacturer;
|
|
|
|
return (0);
|
|
|
|
case PCCARD_IVAR_PRODUCT:
|
|
|
|
*(u_int32_t *) result = devi->product;
|
|
|
|
return (0);
|
|
|
|
case PCCARD_IVAR_PRODEXT:
|
|
|
|
*(u_int16_t *) result = devi->prodext;
|
|
|
|
return (0);
|
2003-04-23 23:39:21 +00:00
|
|
|
case PCCARD_IVAR_VENDOR_STR:
|
|
|
|
*(char **) result = devi->manufstr;
|
|
|
|
break;
|
|
|
|
case PCCARD_IVAR_PRODUCT_STR:
|
|
|
|
*(char **) result = devi->versstr;
|
|
|
|
break;
|
|
|
|
case PCCARD_IVAR_CIS3_STR:
|
|
|
|
*(char **) result = devi->cis3str;
|
|
|
|
break;
|
|
|
|
case PCCARD_IVAR_CIS4_STR:
|
|
|
|
*(char **) result = devi->cis4str;
|
|
|
|
break;
|
2000-01-21 03:08:46 +00:00
|
|
|
}
|
2001-05-14 06:15:24 +00:00
|
|
|
return (ENOENT);
|
2000-01-21 03:08:46 +00:00
|
|
|
}
|
|
|
|
|
2000-04-20 08:37:46 +00:00
|
|
|
static int
|
|
|
|
pccard_set_res_flags(device_t bus, device_t child, int restype, int rid,
|
|
|
|
u_long value)
|
|
|
|
{
|
2001-05-14 06:15:24 +00:00
|
|
|
return (CARD_SET_RES_FLAGS(device_get_parent(bus), child, restype,
|
|
|
|
rid, value));
|
2000-04-20 08:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pccard_get_res_flags(device_t bus, device_t child, int restype, int rid,
|
|
|
|
u_long *value)
|
|
|
|
{
|
2001-05-14 06:15:24 +00:00
|
|
|
return (CARD_GET_RES_FLAGS(device_get_parent(bus), child, restype,
|
|
|
|
rid, value));
|
2000-04-20 08:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pccard_set_memory_offset(device_t bus, device_t child, int rid,
|
2001-07-28 04:25:11 +00:00
|
|
|
u_int32_t offset
|
|
|
|
#if __FreeBSD_version >= 500000
|
|
|
|
, u_int32_t *deltap
|
|
|
|
#endif
|
|
|
|
)
|
2000-04-20 08:37:46 +00:00
|
|
|
{
|
2001-05-14 06:15:24 +00:00
|
|
|
return (CARD_SET_MEMORY_OFFSET(device_get_parent(bus), child, rid,
|
2001-07-28 04:25:11 +00:00
|
|
|
offset
|
|
|
|
#if __FreeBSD_version >= 500000
|
|
|
|
, deltap
|
|
|
|
#endif
|
|
|
|
));
|
2000-04-20 08:37:46 +00:00
|
|
|
}
|
|
|
|
|
2000-08-10 17:35:11 +00:00
|
|
|
static int
|
|
|
|
pccard_get_memory_offset(device_t bus, device_t child, int rid,
|
|
|
|
u_int32_t *offset)
|
|
|
|
{
|
2001-05-14 06:15:24 +00:00
|
|
|
return (CARD_GET_MEMORY_OFFSET(device_get_parent(bus), child, rid,
|
|
|
|
offset));
|
2000-08-10 17:35:11 +00:00
|
|
|
}
|
|
|
|
|
2001-07-28 04:25:11 +00:00
|
|
|
#if __FreeBSD_version >= 500000
|
2002-05-30 18:48:44 +00:00
|
|
|
static const struct pccard_product *
|
|
|
|
pccard_do_product_lookup(device_t bus, device_t dev,
|
|
|
|
const struct pccard_product *tab,
|
|
|
|
size_t ent_size, pccard_product_match_fn matchfn)
|
2000-09-28 07:22:30 +00:00
|
|
|
{
|
2001-05-14 06:15:24 +00:00
|
|
|
return (NULL);
|
2000-09-28 07:22:30 +00:00
|
|
|
}
|
2001-07-28 04:25:11 +00:00
|
|
|
#endif
|
2000-09-28 07:22:30 +00:00
|
|
|
|
1999-09-06 06:34:44 +00:00
|
|
|
static device_method_t pccard_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, pccard_probe),
|
2001-05-13 01:44:27 +00:00
|
|
|
DEVMETHOD(device_attach, pccard_attach),
|
1999-09-06 06:34:44 +00:00
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
1999-12-08 07:55:20 +00:00
|
|
|
DEVMETHOD(device_suspend, pccard_suspend),
|
|
|
|
DEVMETHOD(device_resume, pccard_resume),
|
1999-09-06 06:34:44 +00:00
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, pccard_print_child),
|
|
|
|
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
|
1999-10-25 02:41:58 +00:00
|
|
|
DEVMETHOD(bus_alloc_resource, pccard_alloc_resource),
|
|
|
|
DEVMETHOD(bus_release_resource, pccard_release_resource),
|
1999-09-06 06:34:44 +00:00
|
|
|
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
|
|
|
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
1999-10-25 02:41:58 +00:00
|
|
|
DEVMETHOD(bus_set_resource, pccard_set_resource),
|
|
|
|
DEVMETHOD(bus_get_resource, pccard_get_resource),
|
|
|
|
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
|
2000-01-21 03:08:46 +00:00
|
|
|
DEVMETHOD(bus_read_ivar, pccard_read_ivar),
|
1999-10-25 02:41:58 +00:00
|
|
|
|
2000-04-20 08:37:46 +00:00
|
|
|
/* Card interface */
|
|
|
|
DEVMETHOD(card_set_res_flags, pccard_set_res_flags),
|
|
|
|
DEVMETHOD(card_get_res_flags, pccard_get_res_flags),
|
|
|
|
DEVMETHOD(card_set_memory_offset, pccard_set_memory_offset),
|
2000-08-10 17:35:11 +00:00
|
|
|
DEVMETHOD(card_get_memory_offset, pccard_get_memory_offset),
|
2001-07-28 04:25:11 +00:00
|
|
|
#if __FreeBSD_version >= 500000
|
2001-03-22 06:00:07 +00:00
|
|
|
DEVMETHOD(card_compat_do_probe, pccard_compat_do_probe),
|
|
|
|
DEVMETHOD(card_compat_do_attach, pccard_compat_do_attach),
|
2002-05-30 18:48:44 +00:00
|
|
|
DEVMETHOD(card_do_product_lookup, pccard_do_product_lookup),
|
2001-07-28 04:25:11 +00:00
|
|
|
#endif
|
1999-09-06 06:34:44 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t pccard_driver = {
|
|
|
|
"pccard",
|
|
|
|
pccard_methods,
|
2001-05-13 01:44:27 +00:00
|
|
|
sizeof(struct slot)
|
1999-09-06 06:34:44 +00:00
|
|
|
};
|
|
|
|
|
1999-10-15 17:29:21 +00:00
|
|
|
DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0);
|
2001-05-13 01:44:27 +00:00
|
|
|
DRIVER_MODULE(pccard, mecia, pccard_driver, pccard_devclass, 0, 0);
|
Implement indirection in the pccard probe/attach. This should make it
possible to have different probe/attach semantics between the two
systems and yet still use the same driver for both.
Compatibility methods for OLDCARD drivers. We use these routines to make
it possible to call the OLDCARD driver's probe routine in the context that
it expects. For OLDCARD these are implemented as pass throughs to the
device_{probe,attach} routines. For NEWCARD they are implemented such
such that probe becomes strictly a matching routine and attach does both
the old probe and old attach.
compat devices should use the following:
/* Device interface */
DEVMETHOD(device_probe), pccard_compat_probe),
DEVMETHOD(device_attach), pccard_compat_attach),
/* Card interface */
DEVMETHOD(card_compat_match, foo_match), /* newly written */
DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
This will allow a single driver binary image to be used for both
OLDCARD and NEWCARD.
Drivers wishing to not retain OLDCARD compatibility needn't do this.
ep driver minorly updated.
sn driver updated more than minorly. Add module dependencies to allow
module to load. Also change name to if_sn. Add some debugging code.
attempt to fix the cannot allocate memory problem I'd been seeing.
Minor formatting nits.
2000-09-19 04:39:20 +00:00
|
|
|
MODULE_VERSION(pccard, 1);
|