summaryrefslogtreecommitdiffstats
path: root/sys/dev/pccard
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pccard')
-rw-r--r--sys/dev/pccard/card_if.m40
-rw-r--r--sys/dev/pccard/pccard.c31
-rw-r--r--sys/dev/pccard/pccardvar.h4
3 files changed, 75 insertions, 0 deletions
diff --git a/sys/dev/pccard/card_if.m b/sys/dev/pccard/card_if.m
index 641e398..5e0bfd8 100644
--- a/sys/dev/pccard/card_if.m
+++ b/sys/dev/pccard/card_if.m
@@ -119,3 +119,43 @@ METHOD int deactivate_function {
device_t dev;
device_t child;
}
+
+#
+# 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.
+#
+METHOD int compat_probe {
+ device_t dev;
+}
+
+METHOD int compat_attach {
+ device_t dev;
+}
+
+#
+# Helper method for the above. When a compatibility driver is converted,
+# one must write a match routine. This routine is unused on OLDCARD but
+# is used as a discriminator for NEWCARD.
+#
+METHOD int compat_match {
+ device_t dev;
+}
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c
index 375b74c..39564fe 100644
--- a/sys/dev/pccard/pccard.c
+++ b/sys/dev/pccard/pccard.c
@@ -505,6 +505,28 @@ pccard_io_unmap(struct pccard_function *pf, int window)
}
#endif
+/*
+ * simulate the old "probe" routine. In the new world order, the driver
+ * needs to grab devices while in the old they were assigned to the device by
+ * the pccardd process. These symbols are exported to the upper layers.
+ */
+int
+pccard_compat_probe(device_t dev)
+{
+ return (CARD_COMPAT_MATCH(dev));
+}
+
+int
+pccard_compat_attach(device_t dev)
+{
+ int err;
+
+ err = CARD_COMPAT_PROBE(dev);
+ if (err == 0)
+ err = CARD_COMPAT_ATTACH(dev);
+ return (err);
+}
+
#define PCCARD_NPORT 2
#define PCCARD_NMEM 5
#define PCCARD_NIRQ 1
@@ -661,6 +683,14 @@ pccard_set_memory_offset(device_t dev, device_t child, int rid,
offset);
}
+static int
+pccard_read_ivar(device_t bus, device_t child, int which, u_char *result)
+{
+ /* PCCARD_IVAR_ETHADDR unhandled from oldcard */
+ return ENOENT;
+}
+
+
static device_method_t pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_probe),
@@ -682,6 +712,7 @@ static device_method_t pccard_methods[] = {
DEVMETHOD(bus_set_resource, pccard_set_resource),
DEVMETHOD(bus_get_resource, pccard_get_resource),
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
+ DEVMETHOD(bus_read_ivar, pccard_read_ivar),
/* Card Interface */
DEVMETHOD(card_set_res_flags, pccard_set_res_flags),
diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h
index 19a25a3..a91d2fb 100644
--- a/sys/dev/pccard/pccardvar.h
+++ b/sys/dev/pccard/pccardvar.h
@@ -269,6 +269,10 @@ void pccard_io_unmap(struct pccard_function *, int);
#define pccard_mem_unmap(pf, window) \
(pccard_chip_mem_unmap((pf)->sc->pct, (pf)->sc->pch, (window)))
+/* compat layer */
+int pccard_compat_probe(device_t dev);
+int pccard_compat_attach(device_t dev);
+
/* ivar interface */
enum {
PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */
OpenPOWER on IntegriCloud