summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_port.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/usb_port.h')
-rw-r--r--sys/dev/usb/usb_port.h207
1 files changed, 177 insertions, 30 deletions
diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h
index 5ac8f9a..7c8d8c4 100644
--- a/sys/dev/usb/usb_port.h
+++ b/sys/dev/usb/usb_port.h
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_port.h,v 1.5 1999/01/08 11:58:25 augustss Exp $ */
+/* $NetBSD: usb_port.h,v 1.11 1999/09/11 08:19:27 augustss Exp $ */
/* $FreeBSD$ */
/*
@@ -39,34 +39,49 @@
*/
-/*
+/*
* Macro's to cope with the differences between operating systems.
*/
+#if defined(__NetBSD__)
/*
* NetBSD
*/
-#if defined(__NetBSD__)
#include "opt_usbverbose.h"
+typedef struct device *device_ptr_t;
+#define USBBASEDEVICE struct device
+#define USBDEV(bdev) (&(bdev))
#define USBDEVNAME(bdev) ((bdev).dv_xname)
+#define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
-typedef struct device bdevice; /* base device */
+#define DECLARE_USB_DMA_T \
+ struct usb_dma_block; \
+ typedef struct { \
+ struct usb_dma_block *block; \
+ u_int offs; \
+ } usb_dma_t
#define usb_timeout(f, d, t, h) timeout((f), (d), (t))
#define usb_untimeout(f, d, h) untimeout((f), (d))
-#define USB_DECLARE_DRIVER_INIT(dname, _2) \
+#define logprintf printf
+
+#define USB_DECLARE_DRIVER_NAME_INIT(_1, dname, _2) \
int __CONCAT(dname,_match) __P((struct device *, struct cfdata *, void *)); \
void __CONCAT(dname,_attach) __P((struct device *, struct device *, void *)); \
+int __CONCAT(dname,_detach) __P((struct device *, int)); \
+int __CONCAT(dname,_activate) __P((struct device *, enum devact)); \
\
extern struct cfdriver __CONCAT(dname,_cd); \
\
struct cfattach __CONCAT(dname,_ca) = { \
sizeof(struct __CONCAT(dname,_softc)), \
__CONCAT(dname,_match), \
- __CONCAT(dname,_attach) \
+ __CONCAT(dname,_attach), \
+ __CONCAT(dname,_detach), \
+ __CONCAT(dname,_activate), \
}
#define USB_MATCH(dname) \
@@ -97,6 +112,16 @@ __CONCAT(dname,_attach)(parent, self, aux) \
#define USB_ATTACH_SETUP printf("\n")
+#define USB_DETACH(dname) \
+int \
+__CONCAT(dname,_detach)(self, flags) \
+ struct device *self; \
+ int flags;
+
+#define USB_DETACH_START(dname, sc) \
+ struct __CONCAT(dname,_softc) *sc = \
+ (struct __CONCAT(dname,_softc) *)self
+
#define USB_GET_SC_OPEN(dname, unit, sc) \
struct __CONCAT(dname,_softc) *sc; \
if (unit >= __CONCAT(dname,_cd).cd_ndevs) \
@@ -109,11 +134,107 @@ __CONCAT(dname,_attach)(parent, self, aux) \
struct __CONCAT(dname,_softc) *sc = __CONCAT(dname,_cd).cd_devs[unit]
#define USB_DO_ATTACH(dev, bdev, parent, args, print, sub) \
- ((dev)->softc = config_found_sm(parent, args, print, sub))
+ (config_found_sm(parent, args, print, sub))
+
+#elif defined(__OpenBSD__)
+/*
+ * OpenBSD
+ */
+#define memcpy(d, s, l) bcopy((s),(d),(l))
+#define memset(d, v, l) bzero((d),(l))
+#define bswap32(x) swap32(x)
+#define kthread_create1 kthread_create
+#define kthread_create kthread_create_deferred
+
+#define usbpoll usbselect
+#define uhidpoll uhidselect
+#define ugenpoll ugenselect
+
+typedef struct device device_ptr_t;
+#define USBBASEDEVICE struct device
+#define USBDEV(bdev) (&(bdev))
+#define USBDEVNAME(bdev) ((bdev).dv_xname)
+#define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
+
+#define DECLARE_USB_DMA_T \
+ struct usb_dma_block; \
+ typedef struct { \
+ struct usb_dma_block *block; \
+ u_int offs; \
+ } usb_dma_t
+
+#define usb_timeout(f, d, t, h) timeout((f), (d), (t))
+#define usb_untimeout(f, d, h) untimeout((f), (d))
+
+#define USB_DECLARE_DRIVER_NAME_INIT(_1, dname, _2) \
+int __CONCAT(dname,_match) __P((struct device *, void *, void *)); \
+void __CONCAT(dname,_attach) __P((struct device *, struct device *, void *)); \
+int __CONCAT(dname,_detach) __P((struct device *, int)); \
+int __CONCAT(dname,_activate) __P((struct device *, enum devact)); \
+\
+struct cfdriver __CONCAT(dname,_cd) = { \
+ NULL, #dname, DV_DULL \
+}; \
+\
+struct cfattach __CONCAT(dname,_ca) = { \
+ sizeof(struct __CONCAT(dname,_softc)), \
+ __CONCAT(dname,_match), \
+ __CONCAT(dname,_attach), \
+ __CONCAT(dname,_detach), \
+ __CONCAT(dname,_activate), \
+}
+
+#define USB_MATCH(dname) \
+int \
+__CONCAT(dname,_match)(parent, match, aux) \
+ struct device *parent; \
+ void *match; \
+ void *aux;
+
+#define USB_MATCH_START(dname, uaa) \
+ struct usb_attach_arg *uaa = aux
+
+#define USB_ATTACH(dname) \
+void \
+__CONCAT(dname,_attach)(parent, self, aux) \
+ struct device *parent; \
+ struct device *self; \
+ void *aux;
-#define logprintf printf
+#define USB_ATTACH_START(dname, sc, uaa) \
+ struct __CONCAT(dname,_softc) *sc = \
+ (struct __CONCAT(dname,_softc) *)self; \
+ struct usb_attach_arg *uaa = aux
+
+/* Returns from attach */
+#define USB_ATTACH_ERROR_RETURN return
+#define USB_ATTACH_SUCCESS_RETURN return
+
+#define USB_ATTACH_SETUP printf("\n")
+
+#define USB_DETACH(dname) \
+int \
+__CONCAT(dname,_detach)(self, flags) \
+ struct device *self; \
+ int flags;
+
+#define USB_DETACH_START(dname, sc) \
+ struct __CONCAT(dname,_softc) *sc = \
+ (struct __CONCAT(dname,_softc) *)self
+
+#define USB_GET_SC_OPEN(dname, unit, sc) \
+ struct __CONCAT(dname,_softc) *sc; \
+ if (unit >= __CONCAT(dname,_cd).cd_ndevs) \
+ return (ENXIO); \
+ sc = __CONCAT(dname,_cd).cd_devs[unit]; \
+ if (!sc) \
+ return (ENXIO)
+#define USB_GET_SC(dname, unit, sc) \
+ struct __CONCAT(dname,_softc) *sc = __CONCAT(dname,_cd).cd_devs[unit]
+#define USB_DO_ATTACH(dev, bdev, parent, args, print, sub) \
+ (config_found_sm(parent, args, print, sub))
#elif defined(__FreeBSD__)
/*
@@ -121,28 +242,30 @@ __CONCAT(dname,_attach)(parent, self, aux) \
*/
#include "opt_usb.h"
-/*
- * The following is not a type def to avoid error messages
- * because of includes in the wrong order.
- */
-#define bdevice device_t
-#define USBDEVNAME(bdev) (bdev? device_get_nameunit(bdev):"-")
+
+#define USBVERBOSE
+
+#define device_ptr_t device_t
+#define USBBASEDEVICE device_t
+#define USBDEV(bdev) (bdev)
+#define USBDEVNAME(bdev) device_get_nameunit(bdev)
+#define USBDEVPTRNAME(bdev) device_get_nameunit(bdev)
+
+#define DECLARE_USB_DMA_T typedef void * usb_dma_t
/* XXX Change this when FreeBSD has memset
*/
-#define memset(d, v, s) \
- do{ \
- if ((v) == 0) \
- bzero((d), (s));\
- else \
- panic("Non zero filler for memset, cannot handle!"); \
- } while (0)
+#define memcpy(d, s, l) bcopy((s),(d),(l))
+#define memset(d, v, l) bzero((d),(l))
+#define bswap32(x) swap32(x) /* XXX not available in FreeBSD */
+#define kthread_create1
+#define kthread_create
#define usb_timeout(f, d, t, h) ((h) = timeout((f), (d), (t)))
#define usb_untimeout(f, d, h) untimeout((f), (d), (h))
-#define USB_DECLARE_DRIVER_INIT(dname, init...) \
+#define USB_DECLARE_DRIVER_NAME_INIT(name, dname, init...) \
static device_probe_t __CONCAT(dname,_match); \
static device_attach_t __CONCAT(dname,_attach); \
static device_detach_t __CONCAT(dname,_detach); \
@@ -158,7 +281,7 @@ static device_method_t __CONCAT(dname,_methods)[] = { \
}; \
\
static driver_t __CONCAT(dname,_driver) = { \
- #dname, \
+ name, \
__CONCAT(dname,_methods), \
sizeof(struct __CONCAT(dname,_softc)) \
}
@@ -186,6 +309,13 @@ __CONCAT(dname,_attach)(device_t self)
sc->sc_dev = self; \
device_set_desc_copy(self, devinfo)
+#define USB_DETACH(dname) \
+static int \
+__CONCAT(dname,_detach)(device_t self)
+
+#define USB_DETACH_START(dname, sc) \
+ struct __CONCAT(dname,_softc) *sc = device_get_softc(self)
+
#define USB_GET_SC_OPEN(dname, unit, sc) \
struct __CONCAT(dname,_softc) *sc = \
devclass_get_softc(__CONCAT(dname,_devclass), unit); \
@@ -196,26 +326,43 @@ __CONCAT(dname,_attach)(device_t self)
struct __CONCAT(dname,_softc) *sc = \
devclass_get_softc(__CONCAT(dname,_devclass), unit)
-#define USB_DO_ATTACH(dev, bdev, parent, args, print, sub) \
- (device_probe_and_attach((bdev)) == 0 ? \
- ((dev)->softc = device_get_softc(bdev)) : 0)
+#define USB_DO_ATTACH(dev, bdev, parent, args, print, sub) \
+ (device_probe_and_attach((bdev)) == 0 ? (bdev) : 0)
/* conversion from one type of queue to the other */
-#define SIMPLEQ_REMOVE_HEAD STAILQ_REMOVE_HEAD
+/* XXX In FreeBSD SIMPLEQ_REMOVE_HEAD only removes the head element.
+ */
+#define SIMPLEQ_REMOVE_HEAD(h, e, f) do { \
+ if ( (e) != SIMPLEQ_FIRST((h)) ) \
+ panic("Removing other than first element"); \
+ STAILQ_REMOVE_HEAD(h, f); \
+} while (0)
#define SIMPLEQ_INSERT_HEAD STAILQ_INSERT_HEAD
#define SIMPLEQ_INSERT_TAIL STAILQ_INSERT_TAIL
#define SIMPLEQ_NEXT STAILQ_NEXT
#define SIMPLEQ_FIRST STAILQ_FIRST
#define SIMPLEQ_HEAD STAILQ_HEAD
#define SIMPLEQ_INIT STAILQ_INIT
+#define SIMPLEQ_HEAD_INITIALIZER STAILQ_HEAD_INITIALIZER
#define SIMPLEQ_ENTRY STAILQ_ENTRY
#include <sys/syslog.h>
-#define logprintf(args...) log(LOG_DEBUG, args);
+/*
+#define logprintf(args...) log(LOG_DEBUG, args)
+*/
+#define logprintf printf
#endif /* __FreeBSD__ */
+#define NONE {0,0}
-
+#define USB_DECLARE_DRIVER_NAME(name, dname) \
+ USB_DECLARE_DRIVER_NAME_INIT(#name, dname, NONE )
+#define USB_DECLARE_DRIVER_INIT(dname, init...) \
+ USB_DECLARE_DRIVER_NAME_INIT(#dname, dname, init)
#define USB_DECLARE_DRIVER(dname) \
- USB_DECLARE_DRIVER_INIT(dname, {0,0} )
+ USB_DECLARE_DRIVER_NAME_INIT(#dname, dname, NONE )
+
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+#elif defined(__FreeBSD__)
+#endif
OpenPOWER on IntegriCloud