PERFORCE change 113526 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Thu Jan 25 18:59:31 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=113526
Change 113526 by hselasky at hselasky_mini_itx on 2007/01/25 18:59:18
Changes to make usb_subr.h more style compliant.
Reorder structure elements to achieve integer alignment.
Removed usbd_clear_endpoint_toggle() - unused.
s/u_int /uint32_t/g
s/int /int32_t/g
s/u_int8_t/uint8_t/g
s/u_int16_t/uint16_t/g
s/u_int32_t/uint32_t/g
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#30 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#30 (text+ko) ====
@@ -36,10 +36,10 @@
*/
#ifndef _USB_SUBR_H_
-#define _USB_SUBR_H_
+#define _USB_SUBR_H_
-#define USBD_STATUS_DESC(enum,value) #enum
-#define USBD_STATUS(m)\
+#define USBD_STATUS_DESC(enum,value) #enum
+#define USBD_STATUS(m)\
m(USBD_NORMAL_COMPLETION,=0 /* must be zero*/)\
/* errors */\
m(USBD_PENDING_REQUESTS,)\
@@ -82,22 +82,16 @@
struct module;
struct malloc_type;
struct proc;
+struct usb_hid_descriptor;
-typedef u_int8_t usbd_status;
+typedef uint8_t usbd_status;
typedef void (*usbd_callback_t)(struct usbd_xfer *);
struct usbd_bus_methods {
- void (*pipe_init)(struct usbd_device *udev,
- usb_endpoint_descriptor_t *edesc,
- struct usbd_pipe *pipe);
+ void (*pipe_init)(struct usbd_device *udev, usb_endpoint_descriptor_t *edesc, struct usbd_pipe *pipe);
void (*do_poll)(struct usbd_bus *);
-
- usbd_status (*xfer_setup)(struct usbd_device *udev,
- u_int8_t iface_index,
- struct usbd_xfer **pxfer,
- const struct usbd_config *setup_start,
- const struct usbd_config *setup_end);
+ usbd_status (*xfer_setup)(struct usbd_device *udev, uint8_t iface_index, struct usbd_xfer **pxfer, const struct usbd_config *setup_start, const struct usbd_config *setup_end);
};
struct usbd_pipe_methods {
@@ -110,14 +104,14 @@
};
struct usbd_port {
+ struct usbd_device *device; /* connected device */
+ struct usbd_device *parent; /* the ports hub */
+ uint16_t power; /* mA of current on port */
usb_port_status_t status;
- u_int16_t power; /* mA of current on port */
- u_int8_t portno;
- u_int8_t restartcnt;
- u_int8_t last_refcount;
-#define USBD_RESTART_MAX 5
- struct usbd_device *device; /* connected device */
- struct usbd_device *parent; /* the ports hub */
+ uint8_t portno;
+ uint8_t restartcnt;
+#define USBD_RESTART_MAX 5
+ uint8_t last_refcount;
};
struct usbd_hub {
@@ -127,36 +121,34 @@
struct usbd_port ports[0];
};
-/*****/
+#define USB_PAGE_SIZE PAGE_SIZE
-#define USB_PAGE_SIZE PAGE_SIZE
-
struct usbd_page {
- void *buffer;
- bus_size_t physaddr;
+ void *buffer;
+ bus_size_t physaddr;
#ifdef __FreeBSD__
- bus_dma_tag_t tag;
- bus_dmamap_t map;
- register_t intr_temp;
+ bus_dma_tag_t tag;
+ bus_dmamap_t map;
+ register_t intr_temp;
#endif
#ifdef __NetBSD__
- bus_dma_tag_t tag;
- bus_dmamap_t map;
- bus_dma_segment_t seg;
- register_t intr_temp;
- int32_t seg_count;
+ bus_dma_tag_t tag;
+ bus_dmamap_t map;
+ bus_dma_segment_t seg;
+ register_t intr_temp;
+ int32_t seg_count;
#endif
- u_int32_t length;
- uint16_t exit_level;
+ uint32_t length;
+ uint16_t exit_level;
};
struct usbd_page_search {
- void *buffer;
- struct usbd_page *page;
- bus_size_t physaddr;
- u_int32_t length;
+ void *buffer;
+ struct usbd_page *page;
+ bus_size_t physaddr;
+ uint32_t length;
};
struct usbd_page_info {
@@ -166,273 +158,254 @@
};
struct usbd_page_cache {
- struct usbd_page * page_start;
- struct usbd_page * page_end;
- struct usbd_page * page_cur;
-
- u_int32_t page_offset_buf;
- u_int32_t page_offset_cur;
+ struct usbd_page *page_start;
+ struct usbd_page *page_end;
+ struct usbd_page *page_cur;
+ uint32_t page_offset_buf;
+ uint32_t page_offset_cur;
};
struct usbd_bus {
- /* filled by HC driver */
- device_t bdev; /* base device, host adapter */
- struct usbd_bus_methods *methods;
- bus_dma_tag_t dma_tag;
+ struct usb_device_stats stats;
+ struct mtx mtx;
+ struct usbd_port root_port; /* dummy port for root hub */
+
+ device_t bdev; /* filled by HC driver */
+ bus_dma_tag_t dma_tag; /* filled by HC driver */
+ struct usbd_bus_methods *methods; /* filled by HC driver */
+ struct usbd_device *devices[USB_MAX_DEVICES];
+ struct proc *event_thread;
+
+ uint32_t no_intrs;
- /* filled by USB driver */
- struct usbd_port root_port; /* dummy port for root hub */
- struct usbd_device * devices[USB_MAX_DEVICES];
- u_int8_t is_exploring;
- u_int8_t wait_explore;
- u_int8_t needs_explore;/* a hub signalled a change
- * this variable is protected by
+ uint8_t is_exploring;
+ uint8_t wait_explore;
+ uint8_t needs_explore;/* Set if a hub signalled a change.
+ * This variable is protected by
* "usb_global_lock"
*/
- u_int8_t use_polling;
- u_int8_t usbrev; /* USB revision */
-#define USBREV_UNKNOWN 0
-#define USBREV_PRE_1_0 1
-#define USBREV_1_0 2
-#define USBREV_1_1 3
-#define USBREV_2_0 4
-#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0" }
-
- struct usb_device_stats stats;
- struct mtx mtx;
- struct proc * event_thread;
- u_int32_t no_intrs;
+ uint8_t use_polling;
+ uint8_t usbrev; /* USB revision */
+#define USBREV_UNKNOWN 0
+#define USBREV_PRE_1_0 1
+#define USBREV_1_0 2
+#define USBREV_1_1 3
+#define USBREV_2_0 4
+#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0" }
};
struct usbd_interface {
usb_interface_descriptor_t *idesc;
- u_int8_t alt_index;
+ uint8_t alt_index;
};
-#define usbd_clear_endpoint_toggle(pipe) { \
-(pipe)->clearstall = 0; (pipe)->toggle_next = 0; }
+struct usbd_pipe {
+ LIST_HEAD(, usbd_xfer) list_head;
-struct usbd_pipe {
usb_endpoint_descriptor_t *edesc;
- LIST_HEAD(, usbd_xfer) list_head;
- u_int16_t isoc_next;
- u_int8_t toggle_next;
- u_int8_t refcount;
- u_int8_t clearstall;
- u_int8_t iface_index;
- /* default pipe does not use ``iface_index'' */
+ struct usbd_pipe_methods *methods; /* set by HC driver */
+
+ uint16_t isoc_next;
- /* filled by HC driver */
- struct usbd_pipe_methods *methods;
+ uint8_t toggle_next;
+ uint8_t refcount;
+ uint8_t clearstall;
+ uint8_t iface_index; /* not used by "default pipe" */
};
struct usbd_device {
- struct usbd_bus *bus; /* our controller */
struct usbd_pipe default_pipe; /* pipe 0 */
- usb_endpoint_descriptor_t default_ep_desc; /* for pipe 0 */
- u_int8_t address; /* device addess */
- u_int8_t config; /* current configuration # */
- u_int8_t depth; /* distance from root hub */
- u_int8_t speed; /* low/full/high speed */
- u_int8_t self_powered; /* flag for self powered */
- u_int16_t power; /* mA the device uses */
- int16_t langid; /* language for strings */
-#define USBD_NOLANG (-1)
+ struct usbd_interface ifaces[USB_MAX_ENDPOINTS]; /* array of all interfaces */
+ struct usbd_interface ifaces_end[0];
+ struct usbd_pipe pipes[USB_MAX_ENDPOINTS]; /* array of all pipes */
+ struct usbd_pipe pipes_end[0];
+
+ struct usbd_bus *bus; /* our controller */
+ struct usbd_port *powersrc; /* upstream hub port, or 0 */
+ struct usbd_port *myhsport; /* closest high speed port */
+ struct usbd_device *myhub; /* upstream hub */
+ const struct usbd_quirks *quirks; /* device quirks, always set */
+ usb_config_descriptor_t *cdesc; /* full config descr */
+ struct usbd_hub *hub; /* only if this is a hub */
+ device_t subdevs[USB_MAX_ENDPOINTS]; /* array of all sub-devices */
+ device_t subdevs_end[0];
+
usb_event_cookie_t cookie; /* unique connection id */
- struct usbd_port * powersrc; /* upstream hub port, or 0 */
- struct usbd_port * myhsport; /* closest high speed port */
- struct usbd_device * myhub; /* upstream hub */
- usb_device_descriptor_t ddesc; /* device descriptor */
+ uint16_t power; /* mA the device uses */
+ int16_t langid; /* language for strings */
+#define USBD_NOLANG (-1)
- usb_config_descriptor_t *cdesc; /* full config descr */
- const struct usbd_quirks *quirks; /* device quirks, always set */
- struct usbd_hub * hub; /* only if this is a hub */
+ uint8_t address; /* device addess */
+ uint8_t config; /* current configuration # */
+ uint8_t depth; /* distance from root hub */
+ uint8_t speed; /* low/full/high speed */
+ uint8_t self_powered; /* flag for self powered */
- device_t subdevs[USB_MAX_ENDPOINTS]; /* array of all sub-devices */
- device_t subdevs_end[0];
- struct usbd_interface ifaces[USB_MAX_ENDPOINTS]; /* array of all interfaces */
- struct usbd_interface ifaces_end[0];
- struct usbd_pipe pipes[USB_MAX_ENDPOINTS]; /* array of all pipes */
- struct usbd_pipe pipes_end[0];
+ usb_endpoint_descriptor_t default_ep_desc; /* for pipe 0 */
+ usb_device_descriptor_t ddesc; /* device descriptor */
- u_int8_t ifaces_no_probe[(USB_MAX_ENDPOINTS + 7) / 8];
-#define USBD_SET_IFACE_NO_PROBE(udev, ii) \
+ uint8_t ifaces_no_probe[(USB_MAX_ENDPOINTS + 7) / 8];
+#define USBD_SET_IFACE_NO_PROBE(udev, ii) \
{ (udev)->ifaces_no_probe[(ii) >> 3] |= (1 << ((ii) & 7)); }
-#define USBD_CLR_IFACE_NO_PROBE(udev, ii) \
+#define USBD_CLR_IFACE_NO_PROBE(udev, ii) \
{ (udev)->ifaces_no_probe[(ii) >> 3] &= ~(1 << ((ii) & 7)); }
-#define USBD_GET_IFACE_NO_PROBE(udev, ii) \
+#define USBD_GET_IFACE_NO_PROBE(udev, ii) \
((udev)->ifaces_no_probe[(ii) >> 3] & (1 << ((ii) & 7)))
- u_int8_t probed; /* probe state */
-#define USBD_PROBED_NOTHING 0 /* default value */
-#define USBD_PROBED_SPECIFIC_AND_FOUND 1
-#define USBD_PROBED_IFACE_AND_FOUND 2
-#define USBD_PROBED_GENERIC_AND_FOUND 3
+ uint8_t probed; /* probe state */
+#define USBD_PROBED_NOTHING 0 /* default value */
+#define USBD_PROBED_SPECIFIC_AND_FOUND 1
+#define USBD_PROBED_IFACE_AND_FOUND 2
+#define USBD_PROBED_GENERIC_AND_FOUND 3
- u_int8_t serial[32];
- };
+ uint8_t serial[32]; /* serial number */
+};
struct usbd_config {
- u_int8_t type; /* pipe type */
- u_int8_t endpoint; /* pipe number */
+ usbd_callback_t callback;
- u_int8_t direction; /* pipe direction */
- u_int8_t interval; /* interrupt interval in milliseconds;
- * used by interrupt pipes
- */
-#define USBD_DEFAULT_INTERVAL 0
-
- u_int16_t timeout; /* milliseconds */
-
- u_int16_t frames; /* number of frames
- * used in isochronous
- * mode
- */
- u_int8_t index; /* pipe index to use, if more
- * than one descriptor matches
- * type, address, direction ...
- */
-
- u_int32_t flags; /* flags */
-#define USBD_SYNCHRONOUS 0x0001 /* wait for completion */
-#define USBD_FORCE_SHORT_XFER 0x0002 /* force a short packet last */
+ uint32_t flags; /* flags */
+#define USBD_SYNCHRONOUS 0x0001 /* wait for completion */
+#define USBD_FORCE_SHORT_XFER 0x0002 /* force a short packet last */
#if (USBD_SHORT_XFER_OK != 0x0004)
-#define USBD_SHORT_XFER_OK 0x0004 /* allow short reads
+#define USBD_SHORT_XFER_OK 0x0004 /* allow short reads
* NOTE: existing software
* expects USBD_SHORT_XFER_OK
* to have a value of 0x4. This
* flag is also exported by usb.h
*/
#endif
-#define USBD_CUSTOM_CLEARSTALL 0x0008 /* used to disable automatic clear-stall
+#define USBD_CUSTOM_CLEARSTALL 0x0008 /* used to disable automatic clear-stall
* when a device reset request is needed
* in addition to the clear stall request
*/
-#define USBD_DEV_OPEN 0x0010
-#define USBD_DEV_RECURSED_1 0x0020
-#define USBD_DEV_RECURSED_2 0x0040
-#define USBD_DEV_TRANSFERRING 0x0080
-#define USBD_BANDWIDTH_RECLAIMED 0x0100
-#define USBD_USE_POLLING 0x0200 /* used to make synchronous transfers
+#define USBD_DEV_OPEN 0x0010
+#define USBD_DEV_RECURSED_1 0x0020
+#define USBD_DEV_RECURSED_2 0x0040
+#define USBD_DEV_TRANSFERRING 0x0080
+#define USBD_BANDWIDTH_RECLAIMED 0x0100
+#define USBD_USE_POLLING 0x0200 /* used to make synchronous transfers
* use polling instead of sleep/wakeup
*/
-#define USBD_UNUSED_3 0x0400
-#define USBD_USE_DMA 0x0800
-#define USBD_UNUSED_4 0x1000
-#define USBD_UNUSED_5 0x2000
-#define USBD_UNUSED_6 0x4000
-#define USBD_UNUSED_7 0x8000
+#define USBD_UNUSED_3 0x0400
+#define USBD_USE_DMA 0x0800
+#define USBD_UNUSED_4 0x1000
+#define USBD_UNUSED_5 0x2000
+#define USBD_UNUSED_6 0x4000
+#define USBD_UNUSED_7 0x8000
- u_int32_t bufsize; /* total pipe buffer size in bytes */
- usbd_callback_t callback;
-};
+ uint32_t bufsize; /* total pipe buffer size in bytes */
-#define USBD_TRANSFER_IN_PROGRESS(xfer) \
- ((xfer)->flags & USBD_DEV_TRANSFERRING)
+ uint16_t timeout; /* milliseconds */
-struct usbd_xfer {
- struct usbd_pipe * pipe;
- struct usbd_device * udev;
- void * buffer;
- void * priv_sc;
- void * priv_fifo;
- struct mtx * priv_mtx;
- struct usbd_xfer * clearstall_xfer;
- u_int32_t length; /* bytes */
- u_int32_t actlen; /* bytes */
+ uint16_t frames; /* number of frames
+ * used in isochronous
+ * mode
+ */
+ uint8_t type; /* pipe type */
+ uint8_t endpoint; /* pipe number */
- u_int32_t flags;
+ uint8_t direction; /* pipe direction */
+ uint8_t interval; /* interrupt interval in milliseconds;
+ * used by interrupt pipes
+ */
+#define USBD_DEFAULT_INTERVAL 0
- u_int32_t timeout; /* milliseconds */
-#define USBD_NO_TIMEOUT 0
-#define USBD_DEFAULT_TIMEOUT 5000 /* 5000 ms = 5 seconds */
+ uint8_t index; /* pipe index to use, if more
+ * than one descriptor matches
+ * type, address, direction ...
+ */
+};
- usbd_status error;
- usbd_callback_t callback;
+#define USBD_TRANSFER_IN_PROGRESS(xfer) \
+ ((xfer)->flags & USBD_DEV_TRANSFERRING)
- /* for isochronous transfers */
- u_int16_t * frlengths;
- u_int16_t * frlengths_old;
- u_int32_t nframes;
+struct usbd_xfer {
+ struct __callout timeout_handle;
+ struct usbd_page_cache buf_data; /* buffer page cache */
+ struct usbd_page_cache buf_fixup; /* fixup buffer */
+ LIST_ENTRY(usbd_xfer) interrupt_list; /* used by HC driver */
+ LIST_ENTRY(usbd_xfer) pipe_list; /* used by HC driver */
- /*
- * used by HC driver
- */
+ struct usbd_pipe *pipe;
+ struct usbd_device *udev;
+ struct usbd_xfer *clearstall_xfer;
+ struct mtx *priv_mtx;
+ struct mtx *usb_mtx; /* used by HC driver */
+ struct usbd_memory_info *usb_root; /* used by HC driver */
+ struct thread *usb_thread; /* used by HC driver */
+ void *usb_sc; /* used by HC driver */
+ void *qh_start; /* used by HC driver */
+ void *td_start; /* used by HC driver */
+ void *td_transfer_first; /* used by HC driver */
+ void *td_transfer_last; /* used by HC driver */
+ void *td_transfer_cache; /* used by HC driver */
+ void *priv_sc;
+ void *priv_fifo;
+ void *buffer;
+ uint16_t *frlengths;
+ uint16_t *frlengths_old;
+ usbd_callback_t callback;
- void * usb_sc;
- struct mtx * usb_mtx;
- struct usbd_memory_info *usb_root;
- struct thread * usb_thread;
- u_int32_t usb_refcount;
+ uint32_t length; /* bytes */
+ uint32_t actlen; /* bytes */
+ uint32_t flags;
+ uint32_t timeout; /* milliseconds */
+#define USBD_NO_TIMEOUT 0
+#define USBD_DEFAULT_TIMEOUT 5000 /* 5000 ms = 5 seconds */
- /* pipe_list is used to start next transfer */
+ uint32_t nframes; /* for isochronous transfers */
+ uint32_t usb_refcount; /* used by HC driver */
- LIST_ENTRY(usbd_xfer) pipe_list;
+ uint16_t max_packet_size;
+ uint16_t max_frame_size;
+ uint16_t qh_pos;
- /* interrupt_list is used to check
- * for finished transfers
- */
-
- LIST_ENTRY(usbd_xfer) interrupt_list;
-
- struct __callout timeout_handle;
-
- u_int8_t address;
- u_int8_t endpoint;
- u_int8_t interval; /* milliseconds */
+ uint8_t address;
+ uint8_t endpoint;
+ uint8_t interval; /* milliseconds */
uint8_t max_packet_count;
- u_int16_t max_packet_size;
- u_int16_t max_frame_size;
- u_int16_t qh_pos;
-
- struct usbd_page_cache buf_data; /* buffer page cache */
- struct usbd_page_cache buf_fixup; /* fixup buffer */
-
- void *qh_start;
-
- void *td_start;
- void *td_transfer_first;
- void *td_transfer_last;
- void *td_transfer_cache;
+ usbd_status error;
};
struct usbd_memory_info {
- void * memory_base;
- u_int32_t memory_size;
- u_int32_t memory_refcount;
- u_int32_t setup_refcount;
- struct mtx * priv_mtx;
- struct mtx * usb_mtx;
- struct usbd_page * page_base;
- u_int32_t page_size;
+ void *memory_base;
+ struct mtx *priv_mtx;
+ struct mtx *usb_mtx;
+ struct usbd_page *page_base;
+
+ uint32_t memory_size;
+ uint32_t memory_refcount;
+ uint32_t setup_refcount;
+ uint32_t page_size;
};
struct usbd_callback_info {
- struct usbd_xfer *xfer;
- u_int32_t refcount;
+ struct usbd_xfer *xfer;
+ uint32_t refcount;
};
struct usbd_mbuf {
- u_int8_t *cur_data_ptr;
- u_int8_t *min_data_ptr;
- struct usbd_mbuf *usbd_nextpkt;
- struct usbd_mbuf *usbd_next;
+ uint8_t *cur_data_ptr;
+ uint8_t *min_data_ptr;
+ struct usbd_mbuf *usbd_nextpkt;
+ struct usbd_mbuf *usbd_next;
- u_int32_t cur_data_len;
- u_int32_t max_data_len;
+ uint32_t cur_data_len;
+ uint32_t max_data_len;
};
struct usbd_ifqueue {
- struct usbd_mbuf *ifq_head;
- struct usbd_mbuf *ifq_tail;
+ struct usbd_mbuf *ifq_head;
+ struct usbd_mbuf *ifq_tail;
- int32_t ifq_len;
- int32_t ifq_maxlen;
+ int32_t ifq_len;
+ int32_t ifq_maxlen;
};
-#define USBD_IF_ENQUEUE(ifq, m) do { \
+#define USBD_IF_ENQUEUE(ifq, m) do { \
(m)->usbd_nextpkt = NULL; \
if ((ifq)->ifq_tail == NULL) \
(ifq)->ifq_head = (m); \
@@ -442,7 +415,7 @@
(ifq)->ifq_len++; \
} while (0)
-#define USBD_IF_DEQUEUE(ifq, m) do { \
+#define USBD_IF_DEQUEUE(ifq, m) do { \
(m) = (ifq)->ifq_head; \
if (m) { \
if (((ifq)->ifq_head = (m)->usbd_nextpkt) == NULL) { \
@@ -453,7 +426,7 @@
} \
} while (0)
-#define USBD_IF_PREPEND(ifq, m) do { \
+#define USBD_IF_PREPEND(ifq, m) do { \
(m)->usbd_nextpkt = (ifq)->ifq_head; \
if ((ifq)->ifq_tail == NULL) { \
(ifq)->ifq_tail = (m); \
@@ -462,11 +435,11 @@
(ifq)->ifq_len++; \
} while (0)
-#define USBD_IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
-#define USBD_IF_QLEN(ifq) ((ifq)->ifq_len)
-#define USBD_IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
+#define USBD_IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
+#define USBD_IF_QLEN(ifq) ((ifq)->ifq_len)
+#define USBD_IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
-#define USBD_MBUF_RESET(m) do { \
+#define USBD_MBUF_RESET(m) do { \
(m)->cur_data_ptr = (m)->min_data_ptr; \
(m)->cur_data_len = (m)->max_data_len; \
} while (0)
@@ -477,676 +450,360 @@
struct usbd_config_td_softc;
struct usbd_config_td_cc;
-typedef void (usbd_config_td_command_t)
- (struct usbd_config_td_softc *sc,
- struct usbd_config_td_cc *cc,
- u_int16_t reference);
-
-typedef void (usbd_config_td_config_copy_t)
- (struct usbd_config_td_softc *sc,
- struct usbd_config_td_cc *cc,
- u_int16_t reference);
-
-typedef void (usbd_config_td_end_of_commands_t)
- (struct usbd_config_td_softc *sc);
+typedef void (usbd_config_td_command_t)(struct usbd_config_td_softc *sc, struct usbd_config_td_cc *cc, uint16_t reference);
+typedef void (usbd_config_td_config_copy_t)(struct usbd_config_td_softc *sc, struct usbd_config_td_cc *cc, uint16_t reference);
+typedef void (usbd_config_td_end_of_commands_t)(struct usbd_config_td_softc *sc);
struct usbd_config_td {
- struct usbd_ifqueue cmd_free;
- struct usbd_ifqueue cmd_used;
+ struct usbd_ifqueue cmd_free;
+ struct usbd_ifqueue cmd_used;
- struct proc * config_thread;
- struct mtx * p_mtx;
- void * p_softc;
- void * p_cmd_queue;
+ struct proc *config_thread;
+ struct mtx *p_mtx;
+ void *p_softc;
+ void *p_cmd_queue;
+ usbd_config_td_config_copy_t *p_config_copy;
+ usbd_config_td_end_of_commands_t *p_end_of_commands;
- usbd_config_td_config_copy_t *p_config_copy;
- usbd_config_td_end_of_commands_t *p_end_of_commands;
+ uint8_t wakeup_config_td;
+ uint8_t wakeup_config_td_gone;
- u_int8_t wakeup_config_td;
- u_int8_t wakeup_config_td_gone;
-
- u_int8_t flag_config_td_sleep;
- u_int8_t flag_config_td_gone;
+ uint8_t flag_config_td_sleep;
+ uint8_t flag_config_td_gone;
};
struct usbd_config_td_item {
- usbd_config_td_command_t *command_func;
- u_int16_t command_ref;
-} __attribute__((__aligned__(USB_HOST_ALIGN)));
+ usbd_config_td_command_t *command_func;
+ uint16_t command_ref;
+} __aligned(USB_HOST_ALIGN);
/*---------------------------------------------------------------------------*
* structures used by probe and attach
*---------------------------------------------------------------------------*/
struct usb_devno {
- u_int16_t ud_vendor;
- u_int16_t ud_product;
+ uint16_t ud_vendor;
+ uint16_t ud_product;
} __packed;
-#define usb_lookup(tbl, vendor, product) usb_match_device \
+#define usb_lookup(tbl, vendor, product) usb_match_device \
((const struct usb_devno *)(tbl), (sizeof (tbl) / sizeof ((tbl)[0])), \
sizeof ((tbl)[0]), (vendor), (product)) \
/**/
#define USB_PRODUCT_ANY 0xffff
-struct usb_attach_arg
-{
- int port;
- int configno;
- int iface_index;
- int vendor;
- int product;
- int release;
- int matchlvl;
- struct usbd_device *device; /* current device */
- struct usbd_interface *iface; /* current interface */
- int usegeneric;
- struct usbd_interface *ifaces_start; /* all interfaces */
- struct usbd_interface *ifaces_end; /* exclusive */
+struct usb_attach_arg {
+ struct usbd_device *device; /* current device */
+ struct usbd_interface *iface; /* current interface */
+ struct usbd_interface *ifaces_start; /* all interfaces */
+ struct usbd_interface *ifaces_end; /* exclusive */
+
+ uint16_t vendor;
+ uint16_t product;
+ uint16_t release;
+
+ uint8_t port;
+ uint8_t configno;
+ uint8_t iface_index;
+ uint8_t usegeneric;
};
/* return values for device_probe() method: */
-#define UMATCH_VENDOR_PRODUCT_REV (-10)
-#define UMATCH_VENDOR_PRODUCT (-20)
-#define UMATCH_VENDOR_DEVCLASS_DEVPROTO (-30)
-#define UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO (-40)
-#define UMATCH_DEVCLASS_DEVSUBCLASS (-50)
-#define UMATCH_VENDOR_PRODUCT_REV_CONF_IFACE (-60)
-#define UMATCH_VENDOR_PRODUCT_CONF_IFACE (-70)
-#define UMATCH_VENDOR_IFACESUBCLASS_IFACEPROTO (-80)
-#define UMATCH_VENDOR_IFACESUBCLASS (-90)
-#define UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO (-100)
-#define UMATCH_IFACECLASS_IFACESUBCLASS (-110)
-#define UMATCH_IFACECLASS (-120)
-#define UMATCH_IFACECLASS_GENERIC (-130)
-#define UMATCH_GENERIC (-140)
-#define UMATCH_NONE (ENXIO)
+#define UMATCH_VENDOR_PRODUCT_REV (-10)
+#define UMATCH_VENDOR_PRODUCT (-20)
+#define UMATCH_VENDOR_DEVCLASS_DEVPROTO (-30)
+#define UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO (-40)
+#define UMATCH_DEVCLASS_DEVSUBCLASS (-50)
+#define UMATCH_VENDOR_PRODUCT_REV_CONF_IFACE (-60)
+#define UMATCH_VENDOR_PRODUCT_CONF_IFACE (-70)
+#define UMATCH_VENDOR_IFACESUBCLASS_IFACEPROTO (-80)
+#define UMATCH_VENDOR_IFACESUBCLASS (-90)
+#define UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO (-100)
+#define UMATCH_IFACECLASS_IFACESUBCLASS (-110)
+#define UMATCH_IFACECLASS (-120)
+#define UMATCH_IFACECLASS_GENERIC (-130)
+#define UMATCH_GENERIC (-140)
+#define UMATCH_NONE (ENXIO)
/*---------------------------------------------------------------------------*
* prototypes
*---------------------------------------------------------------------------*/
-/* routines from usb_subr.c */
+/* prototypes from usb_subr.c */
-void
-usbd_devinfo(struct usbd_device *udev, int showclass,
- char *dst_ptr, u_int16_t dst_len);
-
-const char *
-usbd_errstr(usbd_status err);
-
-void
-usb_delay_ms(struct usbd_bus *bus, u_int ms);
-
-void
-usbd_delay_ms(struct usbd_device *udev, u_int ms);
-
-usb_descriptor_t *
-usbd_desc_foreach(usb_config_descriptor_t *cd, usb_descriptor_t *desc);
-
-struct usb_hid_descriptor;
-struct usb_hid_descriptor *
-usbd_get_hdesc(usb_config_descriptor_t *cd, usb_interface_descriptor_t *id);
-
-usb_interface_descriptor_t *
-usbd_find_idesc(usb_config_descriptor_t *cd, u_int16_t iface_index, u_int16_t alt_index);
-
-usb_endpoint_descriptor_t *
-usbd_find_edesc(usb_config_descriptor_t *cd, u_int16_t iface_index, u_int16_t alt_index,
- u_int16_t endptidx);
-
-usb_descriptor_t *
-usbd_find_descriptor(usb_config_descriptor_t *cd, int type, int subtype);
+#define USBD_SUBTYPE_ANY (-1)
-#define USBD_SUBTYPE_ANY (-1)
-
-int
-usbd_get_no_alts(usb_config_descriptor_t *cd, u_int8_t ifaceno);
-
-usbd_status
-usbd_search_and_set_config(struct usbd_device *udev, int no, int msg);
-
-usbd_status
-usbd_set_config_index(struct usbd_device *udev, int index, int msg);
-
-int
-usbd_fill_deviceinfo(struct usbd_device *udev, struct usb_device_info *di,
- int usedev);
-
-usbd_status
-usbd_fill_iface_data(struct usbd_device *udev, int iface_index, int alt_index);
-
-usbd_status
-usbd_probe_and_attach(device_t parent,
- int port, struct usbd_port *up);
-
-usbd_status
-usbd_new_device(device_t parent, struct usbd_bus *bus, int depth,
- int speed, int port, struct usbd_port *up);
-
-void
-usbd_free_device(struct usbd_port *up, u_int8_t free_subdev);
-
-void
-usb_detach_wait(device_t dv);
-
-void
-usb_detach_wakeup(device_t dv);
-
-struct usbd_interface *
-usbd_get_iface(struct usbd_device *udev, u_int8_t iface_index);
-
-void
-usbd_set_desc(device_t dev, struct usbd_device *udev);
-
-void *
-usbd_alloc_mbufs(struct malloc_type *type, struct usbd_ifqueue *ifq,
- u_int32_t block_size, u_int16_t block_number);
-void
-usbd_get_page(struct usbd_page_cache *cache, u_int32_t offset,
- struct usbd_page_search *res);
-void
-usbd_copy_in(struct usbd_page_cache *cache, u_int32_t offset,
- const void *ptr, u_int32_t len);
-void
-usbd_m_copy_in(struct usbd_page_cache *cache, u_int32_t dst_offset,
- struct mbuf *m, u_int32_t src_offset, u_int32_t src_len);
-void
-usbd_copy_out(struct usbd_page_cache *cache, u_int32_t offset,
- void *ptr, u_int32_t len);
-void
-usbd_bzero(struct usbd_page_cache *cache, u_int32_t offset, u_int32_t len);
-
-u_int8_t
-usbd_page_alloc(bus_dma_tag_t tag, struct usbd_page *page,
- u_int32_t npages);
-void
-usbd_page_free(struct usbd_page *page, u_int32_t npages);
-
-void usbd_page_get_info(struct usbd_page *page, u_int32_t size, struct usbd_page_info *info);
-
-void
-usbd_page_set_start(struct usbd_page_cache *pc, struct usbd_page *page_ptr,
- u_int32_t size);
-void
-usbd_page_set_end(struct usbd_page_cache *pc, struct usbd_page *page_ptr,
- u_int32_t size);
-u_int32_t
-usbd_page_fit_obj(struct usbd_page *page, u_int32_t size, u_int32_t obj_len);
-
-void * usbd_mem_alloc(bus_dma_tag_t parent, struct usbd_page *page, uint32_t size, uint8_t align_power);
-
-void usbd_mem_free(struct usbd_page *page);
-
-bus_dma_tag_t
-usbd_dma_tag_alloc(bus_dma_tag_t parent, u_int32_t size, u_int32_t alignment);
-
-void
-usbd_dma_tag_free(bus_dma_tag_t tag);
-
-void *
-usbd_mem_alloc_sub(bus_dma_tag_t tag, struct usbd_page *page,
- u_int32_t size, u_int32_t alignment);
-void
-usbd_mem_free_sub(struct usbd_page *page);
-
-void usbd_page_dma_exit(struct usbd_page *page);
-void usbd_page_dma_enter(struct usbd_page *page);
-
#ifdef __FreeBSD__
#if (__FreeBSD_version >= 700020)
-#define device_get_dma_tag(dev) bus_get_dma_tag(dev)
+#define device_get_dma_tag(dev) bus_get_dma_tag(dev)
#else
-#define device_get_dma_tag(dev) NULL /* XXX */
+#define device_get_dma_tag(dev) NULL /* XXX */
#endif
#endif
-void usbd_std_transfer_setup(struct usbd_xfer *xfer, const struct usbd_config *setup, u_int16_t max_packet_size, u_int16_t max_frame_size, uint8_t max_packet_count);
+void usbd_devinfo(struct usbd_device *udev, int32_t showclass, char *dst_ptr, uint16_t dst_len);
+const char * usbd_errstr(usbd_status err);
+void usb_delay_ms(struct usbd_bus *bus, uint32_t ms);
+void usbd_delay_ms(struct usbd_device *udev, uint32_t ms);
+usb_descriptor_t *usbd_desc_foreach(usb_config_descriptor_t *cd, usb_descriptor_t *desc);
+struct usb_hid_descriptor *usbd_get_hdesc(usb_config_descriptor_t *cd, usb_interface_descriptor_t *id);
+usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd, uint16_t iface_index, uint16_t alt_index);
+usb_endpoint_descriptor_t *usbd_find_edesc(usb_config_descriptor_t *cd, uint16_t iface_index, uint16_t alt_index, uint16_t endptidx);
+usb_descriptor_t *usbd_find_descriptor(usb_config_descriptor_t *cd, int32_t type, int32_t subtype);
+int usbd_get_no_alts(usb_config_descriptor_t *cd, uint8_t ifaceno);
+usbd_status usbd_search_and_set_config(struct usbd_device *udev, int32_t no, int32_t msg);
+usbd_status usbd_set_config_index(struct usbd_device *udev, int32_t index, int32_t msg);
+int usbd_fill_deviceinfo(struct usbd_device *udev, struct usb_device_info *di, int32_t usedev);
+usbd_status usbd_fill_iface_data(struct usbd_device *udev, int32_t iface_index, int32_t alt_index);
+usbd_status usbd_probe_and_attach(device_t parent, int32_t port, struct usbd_port *up);
+usbd_status usbd_new_device(device_t parent, struct usbd_bus *bus, int32_t depth, int32_t speed, int32_t port, struct usbd_port *up);
+void usbd_free_device(struct usbd_port *up, uint8_t free_subdev);
+void usb_detach_wait(device_t dv);
+void usb_detach_wakeup(device_t dv);
+struct usbd_interface *usbd_get_iface(struct usbd_device *udev, uint8_t iface_index);
+void usbd_set_desc(device_t dev, struct usbd_device *udev);
+void * usbd_alloc_mbufs(struct malloc_type *type, struct usbd_ifqueue *ifq, uint32_t block_size, uint16_t block_number);
+void usbd_get_page(struct usbd_page_cache *cache, uint32_t offset, struct usbd_page_search *res);
+void usbd_copy_in(struct usbd_page_cache *cache, uint32_t offset, const void *ptr, uint32_t len);
+void usbd_m_copy_in(struct usbd_page_cache *cache, uint32_t dst_offset, struct mbuf *m, uint32_t src_offset, uint32_t src_len);
+void usbd_copy_out(struct usbd_page_cache *cache, uint32_t offset, void *ptr, uint32_t len);
+void usbd_bzero(struct usbd_page_cache *cache, uint32_t offset, uint32_t len);
+uint8_t usbd_page_alloc(bus_dma_tag_t tag, struct usbd_page *page, uint32_t npages);
+void usbd_page_free(struct usbd_page *page, uint32_t npages);
+void usbd_page_get_info(struct usbd_page *page, uint32_t size, struct usbd_page_info *info);
+void usbd_page_set_start(struct usbd_page_cache *pc, struct usbd_page *page_ptr, uint32_t size);
+void usbd_page_set_end(struct usbd_page_cache *pc, struct usbd_page *page_ptr,uint32_t size);
+uint32_t usbd_page_fit_obj(struct usbd_page *page, uint32_t size, uint32_t obj_len);
+void * usbd_mem_alloc(bus_dma_tag_t parent, struct usbd_page *page, uint32_t size, uint8_t align_power);
+void usbd_mem_free(struct usbd_page *page);
+bus_dma_tag_t usbd_dma_tag_alloc(bus_dma_tag_t parent, uint32_t size, uint32_t alignment);
+void usbd_dma_tag_free(bus_dma_tag_t tag);
+void * usbd_mem_alloc_sub(bus_dma_tag_t tag, struct usbd_page *page, uint32_t size, uint32_t alignment);
+void usbd_mem_free_sub(struct usbd_page *page);
+void usbd_page_dma_exit(struct usbd_page *page);
+void usbd_page_dma_enter(struct usbd_page *page);
+void usbd_std_transfer_setup(struct usbd_xfer *xfer, const struct usbd_config *setup, uint16_t max_packet_size, uint16_t max_frame_size, uint8_t max_packet_count);
+uint8_t usbd_make_str_desc(void *ptr, uint16_t max_len, const char *s);
+uint32_t mtx_drop_recurse(struct mtx *mtx);
+void mtx_pickup_recurse(struct mtx *mtx, uint32_t recurse_level);
+uint8_t usbd_config_td_setup(struct usbd_config_td *ctd, void *priv_sc, struct mtx *priv_mtx, usbd_config_td_config_copy_t *p_func_cc, usbd_config_td_end_of_commands_t *p_func_eoc, uint16_t item_size, uint16_t item_count);
+void usbd_config_td_stop(struct usbd_config_td *ctd);
+void usbd_config_td_unsetup(struct usbd_config_td *ctd);
+void usbd_config_td_queue_command(struct usbd_config_td *ctd, usbd_config_td_command_t *command_func, uint16_t command_ref);
+uint8_t usbd_config_td_is_gone(struct usbd_config_td *ctd);
+uint8_t usbd_config_td_sleep(struct usbd_config_td *ctd, uint32_t timeout);
+struct mbuf * usbd_ether_get_mbuf(void);
+int32_t device_delete_all_children(device_t dev);
+uint16_t usbd_get_max_packet_size(usb_endpoint_descriptor_t *edesc);
+uint16_t usbd_get_max_packet_count(usb_endpoint_descriptor_t *edesc);
+uint16_t usbd_get_max_frame_size(usb_endpoint_descriptor_t *edesc);
+void usbd_set_max_packet_size_count(usb_endpoint_descriptor_t *edesc, uint16_t size, uint16_t count);
-u_int8_t
-usbd_make_str_desc(void *ptr, u_int16_t max_len, const char *s);
-
-u_int32_t
-mtx_drop_recurse(struct mtx *mtx);
+/* prototypes from usb.c */
-void
-mtx_pickup_recurse(struct mtx *mtx, u_int32_t recurse_level);
-
-u_int8_t
-usbd_config_td_setup(struct usbd_config_td *ctd, void *priv_sc,
- struct mtx *priv_mtx,
- usbd_config_td_config_copy_t *p_func_cc,
- usbd_config_td_end_of_commands_t *p_func_eoc,
- u_int16_t item_size, u_int16_t item_count);
-void
-usbd_config_td_stop(struct usbd_config_td *ctd);
-
-void
-usbd_config_td_unsetup(struct usbd_config_td *ctd);
-
-void
-usbd_config_td_queue_command(struct usbd_config_td *ctd,
- usbd_config_td_command_t *command_func,
- u_int16_t command_ref);
-u_int8_t
-usbd_config_td_is_gone(struct usbd_config_td *ctd);
-
-u_int8_t
-usbd_config_td_sleep(struct usbd_config_td *ctd, u_int32_t timeout);
-
-struct mbuf *
-usbd_ether_get_mbuf(void);
-
-int32_t device_delete_all_children(device_t dev);
-
-uint16_t usbd_get_max_packet_size(usb_endpoint_descriptor_t *edesc);
-uint16_t usbd_get_max_packet_count(usb_endpoint_descriptor_t *edesc);
-uint16_t usbd_get_max_frame_size(usb_endpoint_descriptor_t *edesc);
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list