summaryrefslogtreecommitdiffstats
path: root/sys/dev/ppbus/ppbconf.h
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-01-21 23:10:06 +0000
committerjhb <jhb@FreeBSD.org>2009-01-21 23:10:06 +0000
commit879505d4df9b978295c6bf69566f83157938bb81 (patch)
tree3630bd635674ccc163c264b6c7fe5990b52be744 /sys/dev/ppbus/ppbconf.h
parentd41b901b60d3c5cbda874071b1e5ab50fc8b4e03 (diff)
downloadFreeBSD-src-879505d4df9b978295c6bf69566f83157938bb81.zip
FreeBSD-src-879505d4df9b978295c6bf69566f83157938bb81.tar.gz
Add locking to ppc and ppbus and mark the whole lot MPSAFE:
- To avoid having a bunch of locks that end up always getting acquired as a group, give each ppc(4) device a mutex which it shares with all the child devices including ppbus(4), lpt(4), plip(4), etc. This mutex is then used for all the locking. - Rework the interrupt handling stuff yet again. Now ppbus drivers setup their interrupt handler during attach and tear it down during detach like most other drivers. ppbus(4) only invokes the interrupt handler of the device that currently owns the bus (if any) when an interrupt occurs, however. Also, interrupt handlers in general now accept their softc pointers as their argument rather than the device_t. Another feature of the ppbus interrupt handlers is that they are called with the parent ppc device's lock already held. This minimizes the number of lock operations during an interrupt. - Mark plip(4), lpt(4), pcfclock(4), ppi(4), vpo(4) MPSAFE. - lpbb(4) uses the ppc lock instead of Giant. - Other plip(4) changes: - Add a mutex to protect the global tables in plip(4) and free them on module unload. - Add a detach routine. - Split out the init/stop code from the ioctl routine into separate functions. - Other lpt(4) changes: - Use device_printf(). - Use a dedicated callout for the lptout timer. - Allocate the I/O buffers at attach and detach rather than during open and close as this simplifies the locking at the cost of 1024+32 bytes when the driver is attached. - Other ppi(4) changes: - Use an sx lock to serialize open and close. - Remove unused HADBUS flag. - Add a detach routine. - Use a malloc'd buffer for each read and write to avoid races with concurrent read/write. - Other pps(4) changes: - Use a callout rather than a callout handle with timeout(). - Conform to the new ppbus requirements (regular mutex, non-filter interrupt handler). pps(4) is probably going to have to become a standalone driver that doesn't use ppbus(4) to satisfy it's requirements for low latency as a result. - Use an sx lock to serialize open and close. - Other vpo(4) changes: - Use the parent ppc device's lock to create the CAM sim instead of Giant. - Other ppc(4) changes: - Fix ppc_isa's detach method to detach instead of calling attach. Tested by: no one :-(
Diffstat (limited to 'sys/dev/ppbus/ppbconf.h')
-rw-r--r--sys/dev/ppbus/ppbconf.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h
index 482d34f..9981a9a 100644
--- a/sys/dev/ppbus/ppbconf.h
+++ b/sys/dev/ppbus/ppbconf.h
@@ -199,8 +199,8 @@ struct ppb_device {
struct ppb_xfer
put_xfer[PPB_MAX_XFER];
- struct resource *intr_resource;
- void *intr_cookie;
+ driver_intr_t *intr_hook;
+ void *intr_arg;
};
/* EPP standards */
@@ -209,6 +209,8 @@ struct ppb_device {
/* Parallel Port Chipset IVARS */ /* elsewhere XXX */
#define PPC_IVAR_EPP_PROTO 0
+#define PPC_IVAR_LOCK 1
+#define PPC_IVAR_INTR_HANDLER 2
/*
* Maximum size of the PnP info string
@@ -239,15 +241,27 @@ struct ppb_data {
int mode; /* IEEE 1284-1994 mode
* NIBBLE, PS2, EPP or ECP */
- void *ppb_owner; /* device which owns the bus */
+ device_t ppb_owner; /* device which owns the bus */
+
+ struct mtx *ppc_lock; /* lock of parent device */
+ struct resource *ppc_irq_res;
};
+struct callout;
+
+typedef int (*ppc_intr_handler)(void *);
+
#ifdef _KERNEL
extern int ppb_attach_device(device_t);
extern int ppb_request_bus(device_t, device_t, int);
extern int ppb_release_bus(device_t, device_t);
/* bus related functions */
+extern void ppb_lock(device_t);
+extern void ppb_unlock(device_t);
+extern void _ppb_assert_locked(device_t, const char *, int);
+extern void ppb_init_callout(device_t, struct callout *, int);
+extern int ppb_sleep(device_t, void *, int, const char *, int);
extern int ppb_get_status(device_t, struct ppb_status *);
extern int ppb_poll_bus(device_t, int, char, char, int);
extern int ppb_reset_epp_timeout(device_t);
@@ -256,12 +270,12 @@ extern int ppb_get_epp_protocol(device_t);
extern int ppb_set_mode(device_t, int); /* returns old mode */
extern int ppb_get_mode(device_t); /* returns current mode */
extern int ppb_write(device_t, char *, int, int);
-#endif /* _KERNEL */
-
-/*
- * These are defined as macros for speedup.
-#define ppb_get_base_addr(dev) ((dev)->ppb->ppb_link->base)
-#define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol)
- */
+#ifdef INVARIANTS
+#define ppb_assert_locked(dev) _ppb_assert_locked(dev, __FILE__, __LINE__)
+#else
+#define ppb_assert_locked(dev)
#endif
+#endif /* _KERNEL */
+
+#endif /* !__PPBCONF_H */
OpenPOWER on IntegriCloud