1f9f848faSopenharmony_ci/*- 2f9f848faSopenharmony_ci * SPDX-License-Identifier: BSD-2-Clause 3f9f848faSopenharmony_ci * 4f9f848faSopenharmony_ci * Copyright (c) 2009 Andrew Thompson 5f9f848faSopenharmony_ci * 6f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without 7f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions 8f9f848faSopenharmony_ci * are met: 9f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 10f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer. 11f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 12f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer in the 13f9f848faSopenharmony_ci * documentation and/or other materials provided with the distribution. 14f9f848faSopenharmony_ci * 15f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16f9f848faSopenharmony_ci * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17f9f848faSopenharmony_ci * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18f9f848faSopenharmony_ci * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19f9f848faSopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20f9f848faSopenharmony_ci * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21f9f848faSopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22f9f848faSopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23f9f848faSopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24f9f848faSopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25f9f848faSopenharmony_ci */ 26f9f848faSopenharmony_ci#ifndef _USB_USBDI_H_ 27f9f848faSopenharmony_ci#define _USB_USBDI_H_ 28f9f848faSopenharmony_ci 29f9f848faSopenharmony_cistruct usb_fifo; 30f9f848faSopenharmony_cistruct usb_xfer; 31f9f848faSopenharmony_cistruct usb_device; 32f9f848faSopenharmony_cistruct usb_attach_arg; 33f9f848faSopenharmony_cistruct usb_interface; 34f9f848faSopenharmony_cistruct usb_endpoint; 35f9f848faSopenharmony_cistruct usb_page_cache; 36f9f848faSopenharmony_cistruct usb_page_search; 37f9f848faSopenharmony_cistruct usb_process; 38f9f848faSopenharmony_cistruct usb_proc_msg; 39f9f848faSopenharmony_cistruct usb_mbuf; 40f9f848faSopenharmony_cistruct usb_fs_privdata; 41f9f848faSopenharmony_cistruct mbuf; 42f9f848faSopenharmony_ci 43f9f848faSopenharmony_citypedef enum { /* keep in sync with usb_errstr_table */ 44f9f848faSopenharmony_ci USB_ERR_NORMAL_COMPLETION = 0, 45f9f848faSopenharmony_ci USB_ERR_PENDING_REQUESTS, /* 1 */ 46f9f848faSopenharmony_ci USB_ERR_NOT_STARTED, /* 2 */ 47f9f848faSopenharmony_ci USB_ERR_INVAL, /* 3 */ 48f9f848faSopenharmony_ci USB_ERR_NOMEM, /* 4 */ 49f9f848faSopenharmony_ci USB_ERR_CANCELLED, /* 5 */ 50f9f848faSopenharmony_ci USB_ERR_BAD_ADDRESS, /* 6 */ 51f9f848faSopenharmony_ci USB_ERR_BAD_BUFSIZE, /* 7 */ 52f9f848faSopenharmony_ci USB_ERR_BAD_FLAG, /* 8 */ 53f9f848faSopenharmony_ci USB_ERR_NO_CALLBACK, /* 9 */ 54f9f848faSopenharmony_ci USB_ERR_IN_USE, /* 10 */ 55f9f848faSopenharmony_ci USB_ERR_NO_ADDR, /* 11 */ 56f9f848faSopenharmony_ci USB_ERR_NO_PIPE, /* 12 */ 57f9f848faSopenharmony_ci USB_ERR_ZERO_NFRAMES, /* 13 */ 58f9f848faSopenharmony_ci USB_ERR_ZERO_MAXP, /* 14 */ 59f9f848faSopenharmony_ci USB_ERR_SET_ADDR_FAILED, /* 15 */ 60f9f848faSopenharmony_ci USB_ERR_NO_POWER, /* 16 */ 61f9f848faSopenharmony_ci USB_ERR_TOO_DEEP, /* 17 */ 62f9f848faSopenharmony_ci USB_ERR_IOERROR, /* 18 */ 63f9f848faSopenharmony_ci USB_ERR_NOT_CONFIGURED, /* 19 */ 64f9f848faSopenharmony_ci USB_ERR_TIMEOUT, /* 20 */ 65f9f848faSopenharmony_ci USB_ERR_SHORT_XFER, /* 21 */ 66f9f848faSopenharmony_ci USB_ERR_STALLED, /* 22 */ 67f9f848faSopenharmony_ci USB_ERR_INTERRUPTED, /* 23 */ 68f9f848faSopenharmony_ci USB_ERR_DMA_LOAD_FAILED, /* 24 */ 69f9f848faSopenharmony_ci USB_ERR_BAD_CONTEXT, /* 25 */ 70f9f848faSopenharmony_ci USB_ERR_NO_ROOT_HUB, /* 26 */ 71f9f848faSopenharmony_ci USB_ERR_NO_INTR_THREAD, /* 27 */ 72f9f848faSopenharmony_ci USB_ERR_NOT_LOCKED, /* 28 */ 73f9f848faSopenharmony_ci USB_ERR_MAX 74f9f848faSopenharmony_ci} usb_error_t; 75f9f848faSopenharmony_ci 76f9f848faSopenharmony_ci/* 77f9f848faSopenharmony_ci * Flags for transfers 78f9f848faSopenharmony_ci */ 79f9f848faSopenharmony_ci#define USB_FORCE_SHORT_XFER 0x0001 /* force a short transmit last */ 80f9f848faSopenharmony_ci#define USB_SHORT_XFER_OK 0x0004 /* allow short reads */ 81f9f848faSopenharmony_ci#define USB_DELAY_STATUS_STAGE 0x0010 /* insert delay before STATUS stage */ 82f9f848faSopenharmony_ci#define USB_USER_DATA_PTR 0x0020 /* internal flag */ 83f9f848faSopenharmony_ci#define USB_MULTI_SHORT_OK 0x0040 /* allow multiple short frames */ 84f9f848faSopenharmony_ci#define USB_MANUAL_STATUS 0x0080 /* manual ctrl status */ 85f9f848faSopenharmony_ci 86f9f848faSopenharmony_ci#define USB_NO_TIMEOUT 0 87f9f848faSopenharmony_ci#define USB_DEFAULT_TIMEOUT 5000 /* 5000 ms = 5 seconds */ 88f9f848faSopenharmony_ci 89f9f848faSopenharmony_ci#if defined(_KERNEL) 90f9f848faSopenharmony_ci/* typedefs */ 91f9f848faSopenharmony_ci 92f9f848faSopenharmony_citypedef void (usb_callback_t)(struct usb_xfer *, usb_error_t); 93f9f848faSopenharmony_citypedef void (usb_proc_callback_t)(struct usb_proc_msg *); 94f9f848faSopenharmony_citypedef usb_error_t (usb_handle_req_t)(struct usb_device *, 95f9f848faSopenharmony_ci struct usb_device_request *, const void **, uint16_t *); 96f9f848faSopenharmony_ci 97f9f848faSopenharmony_citypedef int (usb_fifo_open_t)(struct usb_fifo *fifo, int fflags); 98f9f848faSopenharmony_citypedef void (usb_fifo_close_t)(struct usb_fifo *fifo, int fflags); 99f9f848faSopenharmony_citypedef int (usb_fifo_ioctl_t)(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags); 100f9f848faSopenharmony_citypedef void (usb_fifo_cmd_t)(struct usb_fifo *fifo); 101f9f848faSopenharmony_citypedef void (usb_fifo_filter_t)(struct usb_fifo *fifo, struct usb_mbuf *m); 102f9f848faSopenharmony_ci 103f9f848faSopenharmony_ci/* USB events */ 104f9f848faSopenharmony_citypedef void (*usb_dev_configured_t)(void *, struct usb_device *, 105f9f848faSopenharmony_ci struct usb_attach_arg *); 106f9f848faSopenharmony_ci 107f9f848faSopenharmony_ci/* 108f9f848faSopenharmony_ci * The following macros are used used to convert milliseconds into 109f9f848faSopenharmony_ci * HZ. We use 1024 instead of 1000 milliseconds per second to save a 110f9f848faSopenharmony_ci * full division. 111f9f848faSopenharmony_ci */ 112f9f848faSopenharmony_ci#define USB_MS_HZ 1024 113f9f848faSopenharmony_ci 114f9f848faSopenharmony_ci#define USB_MS_TO_TICKS(ms) \ 115f9f848faSopenharmony_ci (((uint32_t)((((uint32_t)(ms)) * ((uint32_t)(hz))) + USB_MS_HZ - 1)) / USB_MS_HZ) 116f9f848faSopenharmony_ci 117f9f848faSopenharmony_ci/* 118f9f848faSopenharmony_ci * Common queue structure for USB transfers. 119f9f848faSopenharmony_ci */ 120f9f848faSopenharmony_cistruct usb_xfer_queue { 121f9f848faSopenharmony_ci TAILQ_HEAD(, usb_xfer) head; 122f9f848faSopenharmony_ci struct usb_xfer *curr; /* current USB transfer processed */ 123f9f848faSopenharmony_ci void (*command) (struct usb_xfer_queue *pq); 124f9f848faSopenharmony_ci uint8_t recurse_1:1; 125f9f848faSopenharmony_ci uint8_t recurse_2:1; 126f9f848faSopenharmony_ci}; 127f9f848faSopenharmony_ci 128f9f848faSopenharmony_ci/* 129f9f848faSopenharmony_ci * The following structure defines an USB endpoint 130f9f848faSopenharmony_ci * USB endpoint. 131f9f848faSopenharmony_ci */ 132f9f848faSopenharmony_cistruct usb_endpoint { 133f9f848faSopenharmony_ci /* queue of USB transfers */ 134f9f848faSopenharmony_ci struct usb_xfer_queue endpoint_q[USB_MAX_EP_STREAMS]; 135f9f848faSopenharmony_ci 136f9f848faSopenharmony_ci struct usb_endpoint_descriptor *edesc; 137f9f848faSopenharmony_ci struct usb_endpoint_ss_comp_descriptor *ecomp; 138f9f848faSopenharmony_ci const struct usb_pipe_methods *methods; /* set by HC driver */ 139f9f848faSopenharmony_ci 140f9f848faSopenharmony_ci uint16_t isoc_next; 141f9f848faSopenharmony_ci 142f9f848faSopenharmony_ci uint8_t toggle_next:1; /* next data toggle value */ 143f9f848faSopenharmony_ci uint8_t is_stalled:1; /* set if endpoint is stalled */ 144f9f848faSopenharmony_ci uint8_t is_synced:1; /* set if we a synchronised */ 145f9f848faSopenharmony_ci uint8_t unused:5; 146f9f848faSopenharmony_ci uint8_t iface_index; /* not used by "default endpoint" */ 147f9f848faSopenharmony_ci 148f9f848faSopenharmony_ci uint8_t refcount_alloc; /* allocation refcount */ 149f9f848faSopenharmony_ci uint8_t refcount_bw; /* bandwidth refcount */ 150f9f848faSopenharmony_ci#define USB_EP_REF_MAX 0x3f 151f9f848faSopenharmony_ci 152f9f848faSopenharmony_ci /* High-Speed resource allocation (valid if "refcount_bw" > 0) */ 153f9f848faSopenharmony_ci 154f9f848faSopenharmony_ci uint8_t usb_smask; /* USB start mask */ 155f9f848faSopenharmony_ci uint8_t usb_cmask; /* USB complete mask */ 156f9f848faSopenharmony_ci uint8_t usb_uframe; /* USB microframe */ 157f9f848faSopenharmony_ci 158f9f848faSopenharmony_ci /* USB endpoint mode, see USB_EP_MODE_XXX */ 159f9f848faSopenharmony_ci 160f9f848faSopenharmony_ci uint8_t ep_mode; 161f9f848faSopenharmony_ci}; 162f9f848faSopenharmony_ci 163f9f848faSopenharmony_ci/* 164f9f848faSopenharmony_ci * The following structure defines an USB interface. 165f9f848faSopenharmony_ci */ 166f9f848faSopenharmony_cistruct usb_interface { 167f9f848faSopenharmony_ci struct usb_interface_descriptor *idesc; 168f9f848faSopenharmony_ci device_t subdev; 169f9f848faSopenharmony_ci /* Current alternate interface index, from 0 to 255 */ 170f9f848faSopenharmony_ci uint8_t alt_index; 171f9f848faSopenharmony_ci uint8_t parent_iface_index; 172f9f848faSopenharmony_ci 173f9f848faSopenharmony_ci /* Linux compat */ 174f9f848faSopenharmony_ci struct usb_host_interface *altsetting; 175f9f848faSopenharmony_ci struct usb_host_interface *cur_altsetting; 176f9f848faSopenharmony_ci struct usb_device *linux_udev; 177f9f848faSopenharmony_ci void *bsd_priv_sc; /* device specific information */ 178f9f848faSopenharmony_ci char *pnpinfo; /* additional PnP-info for this interface */ 179f9f848faSopenharmony_ci uint8_t num_altsetting; /* number of alternate settings */ 180f9f848faSopenharmony_ci uint8_t bsd_iface_index; 181f9f848faSopenharmony_ci}; 182f9f848faSopenharmony_ci 183f9f848faSopenharmony_ci/* 184f9f848faSopenharmony_ci * The following structure defines a set of USB transfer flags. 185f9f848faSopenharmony_ci */ 186f9f848faSopenharmony_cistruct usb_xfer_flags { 187f9f848faSopenharmony_ci uint8_t force_short_xfer:1; /* force a short transmit transfer 188f9f848faSopenharmony_ci * last */ 189f9f848faSopenharmony_ci uint8_t short_xfer_ok:1; /* allow short receive transfers */ 190f9f848faSopenharmony_ci uint8_t short_frames_ok:1; /* allow short frames */ 191f9f848faSopenharmony_ci uint8_t pipe_bof:1; /* block pipe on failure */ 192f9f848faSopenharmony_ci uint8_t proxy_buffer:1; /* makes buffer size a factor of 193f9f848faSopenharmony_ci * "max_frame_size" */ 194f9f848faSopenharmony_ci uint8_t ext_buffer:1; /* uses external DMA buffer */ 195f9f848faSopenharmony_ci uint8_t manual_status:1; /* non automatic status stage on 196f9f848faSopenharmony_ci * control transfers */ 197f9f848faSopenharmony_ci uint8_t no_pipe_ok:1; /* set if "USB_ERR_NO_PIPE" error can 198f9f848faSopenharmony_ci * be ignored */ 199f9f848faSopenharmony_ci uint8_t stall_pipe:1; /* set if the endpoint belonging to 200f9f848faSopenharmony_ci * this USB transfer should be stalled 201f9f848faSopenharmony_ci * before starting this transfer! */ 202f9f848faSopenharmony_ci uint8_t pre_scale_frames:1; /* "usb_config->frames" is 203f9f848faSopenharmony_ci * assumed to give the 204f9f848faSopenharmony_ci * buffering time in 205f9f848faSopenharmony_ci * milliseconds and is 206f9f848faSopenharmony_ci * converted into the nearest 207f9f848faSopenharmony_ci * number of frames when the 208f9f848faSopenharmony_ci * USB transfer is setup. This 209f9f848faSopenharmony_ci * option only has effect for 210f9f848faSopenharmony_ci * ISOCHRONOUS transfers. 211f9f848faSopenharmony_ci */ 212f9f848faSopenharmony_ci}; 213f9f848faSopenharmony_ci 214f9f848faSopenharmony_ci/* 215f9f848faSopenharmony_ci * The following structure define an USB configuration, that basically 216f9f848faSopenharmony_ci * is used when setting up an USB transfer. 217f9f848faSopenharmony_ci */ 218f9f848faSopenharmony_cistruct usb_config { 219f9f848faSopenharmony_ci usb_callback_t *callback; /* USB transfer callback */ 220f9f848faSopenharmony_ci usb_frlength_t bufsize; /* total pipe buffer size in bytes */ 221f9f848faSopenharmony_ci usb_frcount_t frames; /* maximum number of USB frames */ 222f9f848faSopenharmony_ci usb_timeout_t interval; /* interval in milliseconds */ 223f9f848faSopenharmony_ci#define USB_DEFAULT_INTERVAL 0 224f9f848faSopenharmony_ci usb_timeout_t timeout; /* transfer timeout in milliseconds */ 225f9f848faSopenharmony_ci struct usb_xfer_flags flags; /* transfer flags */ 226f9f848faSopenharmony_ci usb_stream_t stream_id; /* USB3.0 specific */ 227f9f848faSopenharmony_ci enum usb_hc_mode usb_mode; /* host or device mode */ 228f9f848faSopenharmony_ci uint8_t type; /* pipe type */ 229f9f848faSopenharmony_ci uint8_t endpoint; /* pipe number */ 230f9f848faSopenharmony_ci uint8_t direction; /* pipe direction */ 231f9f848faSopenharmony_ci uint8_t ep_index; /* pipe index match to use */ 232f9f848faSopenharmony_ci uint8_t if_index; /* "ifaces" index to use */ 233f9f848faSopenharmony_ci}; 234f9f848faSopenharmony_ci 235f9f848faSopenharmony_ci/* 236f9f848faSopenharmony_ci * Use these macro when defining USB device ID arrays if you want to 237f9f848faSopenharmony_ci * have your driver module automatically loaded in host, device or 238f9f848faSopenharmony_ci * both modes respectively: 239f9f848faSopenharmony_ci */ 240f9f848faSopenharmony_ci#if USB_HAVE_ID_SECTION 241f9f848faSopenharmony_ci#define STRUCT_USB_HOST_ID \ 242f9f848faSopenharmony_ci struct usb_device_id __section("usb_host_id") 243f9f848faSopenharmony_ci#define STRUCT_USB_DEVICE_ID \ 244f9f848faSopenharmony_ci struct usb_device_id __section("usb_device_id") 245f9f848faSopenharmony_ci#define STRUCT_USB_DUAL_ID \ 246f9f848faSopenharmony_ci struct usb_device_id __section("usb_dual_id") 247f9f848faSopenharmony_ci#else 248f9f848faSopenharmony_ci#define STRUCT_USB_HOST_ID \ 249f9f848faSopenharmony_ci struct usb_device_id 250f9f848faSopenharmony_ci#define STRUCT_USB_DEVICE_ID \ 251f9f848faSopenharmony_ci struct usb_device_id 252f9f848faSopenharmony_ci#define STRUCT_USB_DUAL_ID \ 253f9f848faSopenharmony_ci struct usb_device_id 254f9f848faSopenharmony_ci#endif /* USB_HAVE_ID_SECTION */ 255f9f848faSopenharmony_ci 256f9f848faSopenharmony_ci/* 257f9f848faSopenharmony_ci * The following structure is used when looking up an USB driver for 258f9f848faSopenharmony_ci * an USB device. It is inspired by the Linux structure called 259f9f848faSopenharmony_ci * "usb_device_id". 260f9f848faSopenharmony_ci */ 261f9f848faSopenharmony_cistruct usb_device_id { 262f9f848faSopenharmony_ci /* Hook for driver specific information */ 263f9f848faSopenharmony_ci unsigned long driver_info; 264f9f848faSopenharmony_ci 265f9f848faSopenharmony_ci /* Used for product specific matches; the BCD range is inclusive */ 266f9f848faSopenharmony_ci uint16_t idVendor; 267f9f848faSopenharmony_ci uint16_t idProduct; 268f9f848faSopenharmony_ci uint16_t bcdDevice_lo; 269f9f848faSopenharmony_ci uint16_t bcdDevice_hi; 270f9f848faSopenharmony_ci 271f9f848faSopenharmony_ci /* Used for device class matches */ 272f9f848faSopenharmony_ci uint8_t bDeviceClass; 273f9f848faSopenharmony_ci uint8_t bDeviceSubClass; 274f9f848faSopenharmony_ci uint8_t bDeviceProtocol; 275f9f848faSopenharmony_ci 276f9f848faSopenharmony_ci /* Used for interface class matches */ 277f9f848faSopenharmony_ci uint8_t bInterfaceClass; 278f9f848faSopenharmony_ci uint8_t bInterfaceSubClass; 279f9f848faSopenharmony_ci uint8_t bInterfaceProtocol; 280f9f848faSopenharmony_ci 281f9f848faSopenharmony_ci /* Select which fields to match against */ 282f9f848faSopenharmony_ci uint8_t match_flag_vendor:1; 283f9f848faSopenharmony_ci uint8_t match_flag_product:1; 284f9f848faSopenharmony_ci uint8_t match_flag_dev_lo:1; 285f9f848faSopenharmony_ci uint8_t match_flag_dev_hi:1; 286f9f848faSopenharmony_ci 287f9f848faSopenharmony_ci uint8_t match_flag_dev_class:1; 288f9f848faSopenharmony_ci uint8_t match_flag_dev_subclass:1; 289f9f848faSopenharmony_ci uint8_t match_flag_dev_protocol:1; 290f9f848faSopenharmony_ci uint8_t match_flag_int_class:1; 291f9f848faSopenharmony_ci 292f9f848faSopenharmony_ci uint8_t match_flag_int_subclass:1; 293f9f848faSopenharmony_ci uint8_t match_flag_int_protocol:1; 294f9f848faSopenharmony_ci uint8_t match_flag_unused:6; 295f9f848faSopenharmony_ci 296f9f848faSopenharmony_ci#if USB_HAVE_COMPAT_LINUX 297f9f848faSopenharmony_ci /* which fields to match against */ 298f9f848faSopenharmony_ci uint16_t match_flags; 299f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_VENDOR 0x0001 300f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002 301f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004 302f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008 303f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010 304f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 305f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 306f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080 307f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 308f9f848faSopenharmony_ci#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 309f9f848faSopenharmony_ci#endif 310f9f848faSopenharmony_ci} __aligned(32); 311f9f848faSopenharmony_ci 312f9f848faSopenharmony_ci/* check that the size of the structure above is correct */ 313f9f848faSopenharmony_ciextern char usb_device_id_assert[(sizeof(struct usb_device_id) == 32) ? 1 : -1]; 314f9f848faSopenharmony_ci 315f9f848faSopenharmony_ci#define USB_VENDOR(vend) \ 316f9f848faSopenharmony_ci .match_flag_vendor = 1, .idVendor = (vend) 317f9f848faSopenharmony_ci 318f9f848faSopenharmony_ci#define USB_PRODUCT(prod) \ 319f9f848faSopenharmony_ci .match_flag_product = 1, .idProduct = (prod) 320f9f848faSopenharmony_ci 321f9f848faSopenharmony_ci#define USB_VP(vend,prod) \ 322f9f848faSopenharmony_ci USB_VENDOR(vend), USB_PRODUCT(prod) 323f9f848faSopenharmony_ci 324f9f848faSopenharmony_ci#define USB_VPI(vend,prod,info) \ 325f9f848faSopenharmony_ci USB_VENDOR(vend), USB_PRODUCT(prod), USB_DRIVER_INFO(info) 326f9f848faSopenharmony_ci 327f9f848faSopenharmony_ci#define USB_DEV_BCD_GTEQ(lo) /* greater than or equal */ \ 328f9f848faSopenharmony_ci .match_flag_dev_lo = 1, .bcdDevice_lo = (lo) 329f9f848faSopenharmony_ci 330f9f848faSopenharmony_ci#define USB_DEV_BCD_LTEQ(hi) /* less than or equal */ \ 331f9f848faSopenharmony_ci .match_flag_dev_hi = 1, .bcdDevice_hi = (hi) 332f9f848faSopenharmony_ci 333f9f848faSopenharmony_ci#define USB_DEV_CLASS(dc) \ 334f9f848faSopenharmony_ci .match_flag_dev_class = 1, .bDeviceClass = (dc) 335f9f848faSopenharmony_ci 336f9f848faSopenharmony_ci#define USB_DEV_SUBCLASS(dsc) \ 337f9f848faSopenharmony_ci .match_flag_dev_subclass = 1, .bDeviceSubClass = (dsc) 338f9f848faSopenharmony_ci 339f9f848faSopenharmony_ci#define USB_DEV_PROTOCOL(dp) \ 340f9f848faSopenharmony_ci .match_flag_dev_protocol = 1, .bDeviceProtocol = (dp) 341f9f848faSopenharmony_ci 342f9f848faSopenharmony_ci#define USB_IFACE_CLASS(ic) \ 343f9f848faSopenharmony_ci .match_flag_int_class = 1, .bInterfaceClass = (ic) 344f9f848faSopenharmony_ci 345f9f848faSopenharmony_ci#define USB_IFACE_SUBCLASS(isc) \ 346f9f848faSopenharmony_ci .match_flag_int_subclass = 1, .bInterfaceSubClass = (isc) 347f9f848faSopenharmony_ci 348f9f848faSopenharmony_ci#define USB_IFACE_PROTOCOL(ip) \ 349f9f848faSopenharmony_ci .match_flag_int_protocol = 1, .bInterfaceProtocol = (ip) 350f9f848faSopenharmony_ci 351f9f848faSopenharmony_ci#define USB_IF_CSI(class,subclass,info) \ 352f9f848faSopenharmony_ci USB_IFACE_CLASS(class), USB_IFACE_SUBCLASS(subclass), USB_DRIVER_INFO(info) 353f9f848faSopenharmony_ci 354f9f848faSopenharmony_ci#define USB_DRIVER_INFO(n) \ 355f9f848faSopenharmony_ci .driver_info = (n) 356f9f848faSopenharmony_ci 357f9f848faSopenharmony_ci#define USB_GET_DRIVER_INFO(did) \ 358f9f848faSopenharmony_ci (did)->driver_info 359f9f848faSopenharmony_ci 360f9f848faSopenharmony_ci/* 361f9f848faSopenharmony_ci * The following structure keeps information that is used to match 362f9f848faSopenharmony_ci * against an array of "usb_device_id" elements. 363f9f848faSopenharmony_ci */ 364f9f848faSopenharmony_cistruct usbd_lookup_info { 365f9f848faSopenharmony_ci uint16_t idVendor; 366f9f848faSopenharmony_ci uint16_t idProduct; 367f9f848faSopenharmony_ci uint16_t bcdDevice; 368f9f848faSopenharmony_ci uint8_t bDeviceClass; 369f9f848faSopenharmony_ci uint8_t bDeviceSubClass; 370f9f848faSopenharmony_ci uint8_t bDeviceProtocol; 371f9f848faSopenharmony_ci uint8_t bInterfaceClass; 372f9f848faSopenharmony_ci uint8_t bInterfaceSubClass; 373f9f848faSopenharmony_ci uint8_t bInterfaceProtocol; 374f9f848faSopenharmony_ci uint8_t bIfaceIndex; 375f9f848faSopenharmony_ci uint8_t bIfaceNum; 376f9f848faSopenharmony_ci uint8_t bConfigIndex; 377f9f848faSopenharmony_ci uint8_t bConfigNum; 378f9f848faSopenharmony_ci}; 379f9f848faSopenharmony_ci 380f9f848faSopenharmony_ci/* Structure used by probe and attach */ 381f9f848faSopenharmony_ci 382f9f848faSopenharmony_cistruct usb_attach_arg { 383f9f848faSopenharmony_ci struct usbd_lookup_info info; 384f9f848faSopenharmony_ci device_t temp_dev; /* for internal use */ 385f9f848faSopenharmony_ci unsigned long driver_info; /* for internal use */ 386f9f848faSopenharmony_ci void *driver_ivar; 387f9f848faSopenharmony_ci struct usb_device *device; /* current device */ 388f9f848faSopenharmony_ci struct usb_interface *iface; /* current interface */ 389f9f848faSopenharmony_ci enum usb_hc_mode usb_mode; /* host or device mode */ 390f9f848faSopenharmony_ci uint8_t port; 391f9f848faSopenharmony_ci uint8_t dev_state; 392f9f848faSopenharmony_ci#define UAA_DEV_READY 0 393f9f848faSopenharmony_ci#define UAA_DEV_DISABLED 1 394f9f848faSopenharmony_ci#define UAA_DEV_EJECTING 2 395f9f848faSopenharmony_ci}; 396f9f848faSopenharmony_ci 397f9f848faSopenharmony_ci/* 398f9f848faSopenharmony_ci * General purpose locking wrappers to ease supporting 399f9f848faSopenharmony_ci * USB polled mode: 400f9f848faSopenharmony_ci */ 401f9f848faSopenharmony_ci#ifdef INVARIANTS 402f9f848faSopenharmony_ci#define USB_MTX_ASSERT(_m, _t) do { \ 403f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 404f9f848faSopenharmony_ci mtx_assert(_m, _t); \ 405f9f848faSopenharmony_ci} while (0) 406f9f848faSopenharmony_ci#else 407f9f848faSopenharmony_ci#define USB_MTX_ASSERT(_m, _t) do { } while (0) 408f9f848faSopenharmony_ci#endif 409f9f848faSopenharmony_ci 410f9f848faSopenharmony_ci#define USB_MTX_LOCK(_m) do { \ 411f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 412f9f848faSopenharmony_ci mtx_lock(_m); \ 413f9f848faSopenharmony_ci} while (0) 414f9f848faSopenharmony_ci 415f9f848faSopenharmony_ci#define USB_MTX_UNLOCK(_m) do { \ 416f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 417f9f848faSopenharmony_ci mtx_unlock(_m); \ 418f9f848faSopenharmony_ci} while (0) 419f9f848faSopenharmony_ci 420f9f848faSopenharmony_ci#define USB_MTX_LOCK_SPIN(_m) do { \ 421f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 422f9f848faSopenharmony_ci mtx_lock_spin(_m); \ 423f9f848faSopenharmony_ci} while (0) 424f9f848faSopenharmony_ci 425f9f848faSopenharmony_ci#define USB_MTX_UNLOCK_SPIN(_m) do { \ 426f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 427f9f848faSopenharmony_ci mtx_unlock_spin(_m); \ 428f9f848faSopenharmony_ci} while (0) 429f9f848faSopenharmony_ci 430f9f848faSopenharmony_ci/* 431f9f848faSopenharmony_ci * The following is a wrapper for the callout structure to ease 432f9f848faSopenharmony_ci * porting the code to other platforms. 433f9f848faSopenharmony_ci */ 434f9f848faSopenharmony_cistruct usb_callout { 435f9f848faSopenharmony_ci struct callout co; 436f9f848faSopenharmony_ci}; 437f9f848faSopenharmony_ci#define usb_callout_init_mtx(c,m,f) callout_init_mtx(&(c)->co,m,f) 438f9f848faSopenharmony_ci#define usb_callout_reset(c,...) do { \ 439f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 440f9f848faSopenharmony_ci callout_reset(&(c)->co, __VA_ARGS__); \ 441f9f848faSopenharmony_ci} while (0) 442f9f848faSopenharmony_ci#define usb_callout_reset_sbt(c,...) do { \ 443f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) \ 444f9f848faSopenharmony_ci callout_reset_sbt(&(c)->co, __VA_ARGS__); \ 445f9f848faSopenharmony_ci} while (0) 446f9f848faSopenharmony_ci#define usb_callout_stop(c) do { \ 447f9f848faSopenharmony_ci if (!USB_IN_POLLING_MODE_FUNC()) { \ 448f9f848faSopenharmony_ci callout_stop(&(c)->co); \ 449f9f848faSopenharmony_ci } \ 450f9f848faSopenharmony_ci} while (0) 451f9f848faSopenharmony_ci#define usb_callout_drain(c) callout_drain(&(c)->co) 452f9f848faSopenharmony_ci#define usb_callout_pending(c) callout_pending(&(c)->co) 453f9f848faSopenharmony_ci 454f9f848faSopenharmony_ci/* USB transfer states */ 455f9f848faSopenharmony_ci 456f9f848faSopenharmony_ci#define USB_ST_SETUP 0 457f9f848faSopenharmony_ci#define USB_ST_TRANSFERRED 1 458f9f848faSopenharmony_ci#define USB_ST_ERROR 2 459f9f848faSopenharmony_ci 460f9f848faSopenharmony_ci/* USB handle request states */ 461f9f848faSopenharmony_ci#define USB_HR_NOT_COMPLETE 0 462f9f848faSopenharmony_ci#define USB_HR_COMPLETE_OK 1 463f9f848faSopenharmony_ci#define USB_HR_COMPLETE_ERR 2 464f9f848faSopenharmony_ci 465f9f848faSopenharmony_ci/* 466f9f848faSopenharmony_ci * The following macro will return the current state of an USB 467f9f848faSopenharmony_ci * transfer like defined by the "USB_ST_XXX" enums. 468f9f848faSopenharmony_ci */ 469f9f848faSopenharmony_ci#define USB_GET_STATE(xfer) (usbd_xfer_state(xfer)) 470f9f848faSopenharmony_ci 471f9f848faSopenharmony_ci/* 472f9f848faSopenharmony_ci * The following structure defines the USB process message header. 473f9f848faSopenharmony_ci */ 474f9f848faSopenharmony_cistruct usb_proc_msg { 475f9f848faSopenharmony_ci TAILQ_ENTRY(usb_proc_msg) pm_qentry; 476f9f848faSopenharmony_ci usb_proc_callback_t *pm_callback; 477f9f848faSopenharmony_ci usb_size_t pm_num; 478f9f848faSopenharmony_ci}; 479f9f848faSopenharmony_ci 480f9f848faSopenharmony_ci#define USB_FIFO_TX 0 481f9f848faSopenharmony_ci#define USB_FIFO_RX 1 482f9f848faSopenharmony_ci 483f9f848faSopenharmony_ci/* 484f9f848faSopenharmony_ci * Locking note for the following functions. All the 485f9f848faSopenharmony_ci * "usb_fifo_cmd_t" and "usb_fifo_filter_t" functions are called 486f9f848faSopenharmony_ci * locked. The others are called unlocked. 487f9f848faSopenharmony_ci */ 488f9f848faSopenharmony_cistruct usb_fifo_methods { 489f9f848faSopenharmony_ci usb_fifo_open_t *f_open; 490f9f848faSopenharmony_ci usb_fifo_close_t *f_close; 491f9f848faSopenharmony_ci usb_fifo_ioctl_t *f_ioctl; 492f9f848faSopenharmony_ci /* 493f9f848faSopenharmony_ci * NOTE: The post-ioctl callback is called after the USB reference 494f9f848faSopenharmony_ci * gets locked in the IOCTL handler: 495f9f848faSopenharmony_ci */ 496f9f848faSopenharmony_ci usb_fifo_ioctl_t *f_ioctl_post; 497f9f848faSopenharmony_ci usb_fifo_cmd_t *f_start_read; 498f9f848faSopenharmony_ci usb_fifo_cmd_t *f_stop_read; 499f9f848faSopenharmony_ci usb_fifo_cmd_t *f_start_write; 500f9f848faSopenharmony_ci usb_fifo_cmd_t *f_stop_write; 501f9f848faSopenharmony_ci usb_fifo_filter_t *f_filter_read; 502f9f848faSopenharmony_ci usb_fifo_filter_t *f_filter_write; 503f9f848faSopenharmony_ci const char *basename[4]; 504f9f848faSopenharmony_ci const char *postfix[4]; 505f9f848faSopenharmony_ci}; 506f9f848faSopenharmony_ci 507f9f848faSopenharmony_cistruct usb_fifo_sc { 508f9f848faSopenharmony_ci struct usb_fifo *fp[2]; 509f9f848faSopenharmony_ci struct usb_fs_privdata *dev; 510f9f848faSopenharmony_ci}; 511f9f848faSopenharmony_ci 512f9f848faSopenharmony_ciconst char *usbd_errstr(usb_error_t error); 513f9f848faSopenharmony_civoid *usbd_find_descriptor(struct usb_device *udev, void *id, 514f9f848faSopenharmony_ci uint8_t iface_index, uint8_t type, uint8_t type_mask, 515f9f848faSopenharmony_ci uint8_t subtype, uint8_t subtype_mask); 516f9f848faSopenharmony_cistruct usb_config_descriptor *usbd_get_config_descriptor( 517f9f848faSopenharmony_ci struct usb_device *udev); 518f9f848faSopenharmony_cistruct usb_device_descriptor *usbd_get_device_descriptor( 519f9f848faSopenharmony_ci struct usb_device *udev); 520f9f848faSopenharmony_cistruct usb_interface *usbd_get_iface(struct usb_device *udev, 521f9f848faSopenharmony_ci uint8_t iface_index); 522f9f848faSopenharmony_cistruct usb_interface_descriptor *usbd_get_interface_descriptor( 523f9f848faSopenharmony_ci struct usb_interface *iface); 524f9f848faSopenharmony_cistruct usb_endpoint *usbd_get_endpoint(struct usb_device *udev, uint8_t iface_index, 525f9f848faSopenharmony_ci const struct usb_config *setup); 526f9f848faSopenharmony_cistruct usb_endpoint *usbd_get_ep_by_addr(struct usb_device *udev, uint8_t ea_val); 527f9f848faSopenharmony_ciusb_error_t usbd_interface_count(struct usb_device *udev, uint8_t *count); 528f9f848faSopenharmony_cienum usb_hc_mode usbd_get_mode(struct usb_device *udev); 529f9f848faSopenharmony_cienum usb_dev_speed usbd_get_speed(struct usb_device *udev); 530f9f848faSopenharmony_civoid device_set_usb_desc(device_t dev); 531f9f848faSopenharmony_civoid usb_pause_mtx(struct mtx *mtx, int _ticks); 532f9f848faSopenharmony_ciusb_error_t usbd_set_pnpinfo(struct usb_device *udev, 533f9f848faSopenharmony_ci uint8_t iface_index, const char *pnpinfo); 534f9f848faSopenharmony_ciusb_error_t usbd_add_dynamic_quirk(struct usb_device *udev, 535f9f848faSopenharmony_ci uint16_t quirk); 536f9f848faSopenharmony_ciusb_error_t usbd_set_endpoint_mode(struct usb_device *udev, 537f9f848faSopenharmony_ci struct usb_endpoint *ep, uint8_t ep_mode); 538f9f848faSopenharmony_ciuint8_t usbd_get_endpoint_mode(struct usb_device *udev, 539f9f848faSopenharmony_ci struct usb_endpoint *ep); 540f9f848faSopenharmony_ci 541f9f848faSopenharmony_ciconst struct usb_device_id *usbd_lookup_id_by_info( 542f9f848faSopenharmony_ci const struct usb_device_id *id, usb_size_t sizeof_id, 543f9f848faSopenharmony_ci const struct usbd_lookup_info *info); 544f9f848faSopenharmony_ciint usbd_lookup_id_by_uaa(const struct usb_device_id *id, 545f9f848faSopenharmony_ci usb_size_t sizeof_id, struct usb_attach_arg *uaa); 546f9f848faSopenharmony_ci 547f9f848faSopenharmony_ciusb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx, 548f9f848faSopenharmony_ci struct usb_device_request *req, void *data, uint16_t flags, 549f9f848faSopenharmony_ci uint16_t *actlen, usb_timeout_t timeout); 550f9f848faSopenharmony_ci#define usbd_do_request(u,m,r,d) \ 551f9f848faSopenharmony_ci usbd_do_request_flags(u, m, r, d, 0, NULL, USB_DEFAULT_TIMEOUT) 552f9f848faSopenharmony_ci 553f9f848faSopenharmony_ciuint8_t usbd_clear_stall_callback(struct usb_xfer *xfer1, 554f9f848faSopenharmony_ci struct usb_xfer *xfer2); 555f9f848faSopenharmony_ciuint8_t usbd_get_interface_altindex(struct usb_interface *iface); 556f9f848faSopenharmony_ciusb_error_t usbd_set_alt_interface_index(struct usb_device *udev, 557f9f848faSopenharmony_ci uint8_t iface_index, uint8_t alt_index); 558f9f848faSopenharmony_ciuint32_t usbd_get_isoc_fps(struct usb_device *udev); 559f9f848faSopenharmony_ciusb_error_t usbd_transfer_setup(struct usb_device *udev, 560f9f848faSopenharmony_ci const uint8_t *ifaces, struct usb_xfer **pxfer, 561f9f848faSopenharmony_ci const struct usb_config *setup_start, uint16_t n_setup, 562f9f848faSopenharmony_ci void *priv_sc, struct mtx *priv_mtx); 563f9f848faSopenharmony_civoid usbd_transfer_submit(struct usb_xfer *xfer); 564f9f848faSopenharmony_civoid usbd_transfer_clear_stall(struct usb_xfer *xfer); 565f9f848faSopenharmony_civoid usbd_transfer_drain(struct usb_xfer *xfer); 566f9f848faSopenharmony_ciuint8_t usbd_transfer_pending(struct usb_xfer *xfer); 567f9f848faSopenharmony_civoid usbd_transfer_start(struct usb_xfer *xfer); 568f9f848faSopenharmony_civoid usbd_transfer_stop(struct usb_xfer *xfer); 569f9f848faSopenharmony_civoid usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup); 570f9f848faSopenharmony_civoid usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max); 571f9f848faSopenharmony_civoid usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index, 572f9f848faSopenharmony_ci uint8_t parent_index); 573f9f848faSopenharmony_ciuint8_t usbd_get_bus_index(struct usb_device *udev); 574f9f848faSopenharmony_ciuint8_t usbd_get_device_index(struct usb_device *udev); 575f9f848faSopenharmony_civoid usbd_set_power_mode(struct usb_device *udev, uint8_t power_mode); 576f9f848faSopenharmony_ciuint8_t usbd_filter_power_mode(struct usb_device *udev, uint8_t power_mode); 577f9f848faSopenharmony_ciuint8_t usbd_device_attached(struct usb_device *udev); 578f9f848faSopenharmony_ci 579f9f848faSopenharmony_ciusb_frlength_t 580f9f848faSopenharmony_ci usbd_xfer_old_frame_length(struct usb_xfer *xfer, usb_frcount_t frindex); 581f9f848faSopenharmony_civoid usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, 582f9f848faSopenharmony_ci int *aframes, int *nframes); 583f9f848faSopenharmony_cistruct usb_page_cache *usbd_xfer_get_frame(struct usb_xfer *, usb_frcount_t); 584f9f848faSopenharmony_civoid *usbd_xfer_get_frame_buffer(struct usb_xfer *, usb_frcount_t); 585f9f848faSopenharmony_civoid *usbd_xfer_softc(struct usb_xfer *xfer); 586f9f848faSopenharmony_civoid *usbd_xfer_get_priv(struct usb_xfer *xfer); 587f9f848faSopenharmony_civoid usbd_xfer_set_priv(struct usb_xfer *xfer, void *); 588f9f848faSopenharmony_civoid usbd_xfer_set_interval(struct usb_xfer *xfer, int); 589f9f848faSopenharmony_ciuint8_t usbd_xfer_state(struct usb_xfer *xfer); 590f9f848faSopenharmony_civoid usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, 591f9f848faSopenharmony_ci void *ptr, usb_frlength_t len); 592f9f848faSopenharmony_civoid usbd_xfer_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, 593f9f848faSopenharmony_ci void **ptr, int *len); 594f9f848faSopenharmony_civoid usbd_xfer_set_frame_offset(struct usb_xfer *xfer, usb_frlength_t offset, 595f9f848faSopenharmony_ci usb_frcount_t frindex); 596f9f848faSopenharmony_ciusb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer); 597f9f848faSopenharmony_ciusb_frlength_t usbd_xfer_max_framelen(struct usb_xfer *xfer); 598f9f848faSopenharmony_ciusb_frcount_t usbd_xfer_max_frames(struct usb_xfer *xfer); 599f9f848faSopenharmony_ciuint8_t usbd_xfer_get_fps_shift(struct usb_xfer *xfer); 600f9f848faSopenharmony_ciusb_frlength_t usbd_xfer_frame_len(struct usb_xfer *xfer, 601f9f848faSopenharmony_ci usb_frcount_t frindex); 602f9f848faSopenharmony_civoid usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, 603f9f848faSopenharmony_ci usb_frlength_t len); 604f9f848faSopenharmony_civoid usbd_xfer_set_timeout(struct usb_xfer *xfer, int timeout); 605f9f848faSopenharmony_civoid usbd_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n); 606f9f848faSopenharmony_civoid usbd_xfer_set_stall(struct usb_xfer *xfer); 607f9f848faSopenharmony_ciint usbd_xfer_is_stalled(struct usb_xfer *xfer); 608f9f848faSopenharmony_civoid usbd_xfer_set_flag(struct usb_xfer *xfer, int flag); 609f9f848faSopenharmony_civoid usbd_xfer_clr_flag(struct usb_xfer *xfer, int flag); 610f9f848faSopenharmony_ciuint16_t usbd_xfer_get_timestamp(struct usb_xfer *xfer); 611f9f848faSopenharmony_ciuint8_t usbd_xfer_maxp_was_clamped(struct usb_xfer *xfer); 612f9f848faSopenharmony_ci 613f9f848faSopenharmony_ciint copyin(const void *uaddr, void *kaddr, size_t len); 614f9f848faSopenharmony_ciint copyout(const void *kaddr, void *uaddr, size_t len); 615f9f848faSopenharmony_ciint usbd_copy_from_user(void *dest, uint32_t dest_len, const void *src, uint32_t src_len); 616f9f848faSopenharmony_ciint usbd_copy_to_user(void *dest, uint32_t dest_len, const void *src, uint32_t src_len); 617f9f848faSopenharmony_civoid usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset, 618f9f848faSopenharmony_ci const void *ptr, usb_frlength_t len); 619f9f848faSopenharmony_ciint usbd_copy_in_user(struct usb_page_cache *cache, usb_frlength_t offset, 620f9f848faSopenharmony_ci const void *ptr, usb_frlength_t len); 621f9f848faSopenharmony_civoid usbd_copy_out(struct usb_page_cache *cache, usb_frlength_t offset, 622f9f848faSopenharmony_ci void *ptr, usb_frlength_t len); 623f9f848faSopenharmony_ciint usbd_copy_out_user(struct usb_page_cache *cache, usb_frlength_t offset, 624f9f848faSopenharmony_ci void *ptr, usb_frlength_t len); 625f9f848faSopenharmony_civoid usbd_get_page(struct usb_page_cache *pc, usb_frlength_t offset, 626f9f848faSopenharmony_ci struct usb_page_search *res); 627f9f848faSopenharmony_civoid usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, 628f9f848faSopenharmony_ci struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len); 629f9f848faSopenharmony_civoid usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, 630f9f848faSopenharmony_ci usb_frlength_t len); 631f9f848faSopenharmony_civoid usbd_start_re_enumerate(struct usb_device *udev); 632f9f848faSopenharmony_ciusb_error_t 633f9f848faSopenharmony_ci usbd_start_set_config(struct usb_device *, uint8_t); 634f9f848faSopenharmony_ci 635f9f848faSopenharmony_ciint usb_fifo_attach(struct usb_device *udev, void *priv_sc, 636f9f848faSopenharmony_ci struct mtx *priv_mtx, struct usb_fifo_methods *pm, 637f9f848faSopenharmony_ci struct usb_fifo_sc *f_sc, uint16_t unit, int16_t subunit, 638f9f848faSopenharmony_ci uint8_t iface_index, uid_t uid, gid_t gid, int mode); 639f9f848faSopenharmony_civoid usb_fifo_detach(struct usb_fifo_sc *f_sc); 640f9f848faSopenharmony_ciint usb_fifo_alloc_buffer(struct usb_fifo *f, uint32_t bufsize, 641f9f848faSopenharmony_ci uint16_t nbuf); 642f9f848faSopenharmony_civoid usb_fifo_free_buffer(struct usb_fifo *f); 643f9f848faSopenharmony_ciuint32_t usb_fifo_put_bytes_max(struct usb_fifo *fifo); 644f9f848faSopenharmony_civoid usb_fifo_put_data(struct usb_fifo *fifo, struct usb_page_cache *pc, 645f9f848faSopenharmony_ci usb_frlength_t offset, usb_frlength_t len, uint8_t what); 646f9f848faSopenharmony_civoid usb_fifo_put_data_linear(struct usb_fifo *fifo, void *ptr, 647f9f848faSopenharmony_ci usb_size_t len, uint8_t what); 648f9f848faSopenharmony_ciuint8_t usb_fifo_put_data_buffer(struct usb_fifo *f, void *ptr, usb_size_t len); 649f9f848faSopenharmony_civoid usb_fifo_put_data_error(struct usb_fifo *fifo); 650f9f848faSopenharmony_ciuint8_t usb_fifo_get_data(struct usb_fifo *fifo, struct usb_page_cache *pc, 651f9f848faSopenharmony_ci usb_frlength_t offset, usb_frlength_t len, usb_frlength_t *actlen, 652f9f848faSopenharmony_ci uint8_t what); 653f9f848faSopenharmony_ciuint8_t usb_fifo_get_data_linear(struct usb_fifo *fifo, void *ptr, 654f9f848faSopenharmony_ci usb_size_t len, usb_size_t *actlen, uint8_t what); 655f9f848faSopenharmony_ciuint8_t usb_fifo_get_data_buffer(struct usb_fifo *f, void **pptr, 656f9f848faSopenharmony_ci usb_size_t *plen); 657f9f848faSopenharmony_civoid usb_fifo_reset(struct usb_fifo *f); 658f9f848faSopenharmony_civoid usb_fifo_wakeup(struct usb_fifo *f); 659f9f848faSopenharmony_civoid usb_fifo_get_data_error(struct usb_fifo *fifo); 660f9f848faSopenharmony_civoid *usb_fifo_softc(struct usb_fifo *fifo); 661f9f848faSopenharmony_civoid usb_fifo_set_close_zlp(struct usb_fifo *, uint8_t); 662f9f848faSopenharmony_civoid usb_fifo_set_write_defrag(struct usb_fifo *, uint8_t); 663f9f848faSopenharmony_civoid usb_fifo_free(struct usb_fifo *f); 664f9f848faSopenharmony_ci#endif /* _KERNEL */ 665f9f848faSopenharmony_ci#endif /* _USB_USBDI_H_ */ 666