The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/usb/usb_device.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $FreeBSD: releng/8.3/sys/dev/usb/usb_device.h 225470 2011-09-10 16:52:15Z hselasky $ */
    2 /*-
    3  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #ifndef _USB_DEVICE_H_
   28 #define _USB_DEVICE_H_
   29 
   30 struct usb_symlink;             /* UGEN */
   31 struct usb_device;              /* linux compat */
   32 struct usb_fs_privdata;
   33 
   34 #define USB_CTRL_XFER_MAX 2
   35 
   36 /* "usb_parse_config()" commands */
   37 
   38 #define USB_CFG_ALLOC 0
   39 #define USB_CFG_FREE 1
   40 #define USB_CFG_INIT 2
   41 
   42 /* "usb_unconfigure()" flags */
   43 
   44 #define USB_UNCFG_FLAG_NONE 0x00
   45 #define USB_UNCFG_FLAG_FREE_EP0 0x02            /* endpoint zero is freed */
   46 
   47 struct usb_clear_stall_msg {
   48         struct usb_proc_msg hdr;
   49         struct usb_device *udev;
   50 };
   51 
   52 /* The following four structures makes up a tree, where we have the
   53  * leaf structure, "usb_host_endpoint", first, and the root structure,
   54  * "usb_device", last. The four structures below mirror the structure
   55  * of the USB descriptors belonging to an USB configuration. Please
   56  * refer to the USB specification for a definition of "endpoints" and
   57  * "interfaces".
   58  */
   59 struct usb_host_endpoint {
   60         struct usb_endpoint_descriptor desc;
   61         TAILQ_HEAD(, urb) bsd_urb_list;
   62         struct usb_xfer *bsd_xfer[2];
   63         uint8_t *extra;                 /* Extra descriptors */
   64         usb_frlength_t fbsd_buf_size;
   65         uint16_t extralen;
   66         uint8_t bsd_iface_index;
   67 } __aligned(USB_HOST_ALIGN);
   68 
   69 struct usb_host_interface {
   70         struct usb_interface_descriptor desc;
   71         /* the following array has size "desc.bNumEndpoint" */
   72         struct usb_host_endpoint *endpoint;
   73         const char *string;             /* iInterface string, if present */
   74         uint8_t *extra;                 /* Extra descriptors */
   75         uint16_t extralen;
   76         uint8_t bsd_iface_index;
   77 } __aligned(USB_HOST_ALIGN);
   78 
   79 /*
   80  * The following structure defines the USB device flags.
   81  */
   82 struct usb_device_flags {
   83         enum usb_hc_mode usb_mode;      /* host or device mode */
   84         uint8_t self_powered:1;         /* set if USB device is self powered */
   85         uint8_t no_strings:1;           /* set if USB device does not support
   86                                          * strings */
   87         uint8_t remote_wakeup:1;        /* set if remote wakeup is enabled */
   88         uint8_t uq_bus_powered:1;       /* set if BUS powered quirk is present */
   89 
   90         /*
   91          * NOTE: Although the flags below will reach the same value
   92          * over time, but the instant values may differ, and
   93          * consequently the flags cannot be merged into one!
   94          */
   95         uint8_t peer_suspended:1;       /* set if peer is suspended */
   96         uint8_t self_suspended:1;       /* set if self is suspended */
   97 };
   98 
   99 /*
  100  * The following structure is used for power-save purposes. The data
  101  * in this structure is protected by the USB BUS lock.
  102  */
  103 struct usb_power_save {
  104         usb_ticks_t last_xfer_time;     /* copy of "ticks" */
  105         usb_size_t type_refs[4];        /* transfer reference count */
  106         usb_size_t read_refs;           /* data read references */
  107         usb_size_t write_refs;          /* data write references */
  108 };
  109 
  110 /*
  111  * The following structure defines an USB device. There exists one of
  112  * these structures for every USB device.
  113  */
  114 struct usb_device {
  115         struct usb_clear_stall_msg cs_msg[2];   /* generic clear stall
  116                                                  * messages */
  117         struct sx ctrl_sx;
  118         struct sx enum_sx;
  119         struct sx sr_sx;
  120         struct mtx device_mtx;
  121         struct cv ctrlreq_cv;
  122         struct cv ref_cv;
  123         struct usb_interface *ifaces;
  124         struct usb_endpoint ctrl_ep;    /* Control Endpoint 0 */
  125         struct usb_endpoint *endpoints;
  126         struct usb_power_save pwr_save;/* power save data */
  127         struct usb_bus *bus;            /* our USB BUS */
  128         device_t parent_dev;            /* parent device */
  129         struct usb_device *parent_hub;
  130         struct usb_device *parent_hs_hub;       /* high-speed parent HUB */
  131         struct usb_config_descriptor *cdesc;    /* full config descr */
  132         struct usb_hub *hub;            /* only if this is a hub */
  133         struct usb_xfer *ctrl_xfer[USB_CTRL_XFER_MAX];
  134         struct usb_temp_data *usb_template_ptr;
  135         struct usb_endpoint *ep_curr;   /* current clear stall endpoint */
  136 #if USB_HAVE_UGEN
  137         struct usb_fifo *fifo[USB_FIFO_MAX];
  138         struct usb_symlink *ugen_symlink;       /* our generic symlink */
  139         struct usb_fs_privdata *ctrl_dev;       /* Control Endpoint 0 device node */
  140         LIST_HEAD(,usb_fs_privdata) pd_list;
  141         char    ugen_name[20];          /* name of ugenX.X device */
  142 #endif
  143         usb_ticks_t plugtime;           /* copy of "ticks" */
  144 
  145         enum usb_dev_state state;
  146         enum usb_dev_speed speed;
  147         uint16_t refcount;
  148 #define USB_DEV_REF_MAX 0xffff
  149 
  150         uint16_t power;                 /* mA the device uses */
  151         uint16_t langid;                /* language for strings */
  152 
  153         uint8_t address;                /* device addess */
  154         uint8_t device_index;           /* device index in "bus->devices" */
  155         uint8_t controller_slot_id;     /* controller specific value */
  156         uint8_t curr_config_index;      /* current configuration index */
  157         uint8_t curr_config_no;         /* current configuration number */
  158         uint8_t depth;                  /* distance from root HUB */
  159         uint8_t port_index;             /* parent HUB port index */
  160         uint8_t port_no;                /* parent HUB port number */
  161         uint8_t hs_hub_addr;            /* high-speed HUB address */
  162         uint8_t hs_port_no;             /* high-speed HUB port number */
  163         uint8_t driver_added_refcount;  /* our driver added generation count */
  164         uint8_t power_mode;             /* see USB_POWER_XXX */
  165         uint8_t re_enumerate_wait;      /* set if re-enum. is in progress */
  166         uint8_t ifaces_max;             /* number of interfaces present */
  167         uint8_t endpoints_max;          /* number of endpoints present */
  168 
  169         /* the "flags" field is write-protected by "bus->mtx" */
  170 
  171         struct usb_device_flags flags;
  172 
  173         struct usb_endpoint_descriptor ctrl_ep_desc;    /* for endpoint 0 */
  174         struct usb_endpoint_ss_comp_descriptor ctrl_ep_comp_desc;       /* for endpoint 0 */
  175         struct usb_device_descriptor ddesc;     /* device descriptor */
  176 
  177         char    *serial;                /* serial number, can be NULL */
  178         char    *manufacturer;          /* manufacturer string, can be NULL */
  179         char    *product;               /* product string, can be NULL */
  180 
  181 #if USB_HAVE_COMPAT_LINUX
  182         /* Linux compat */
  183         struct usb_device_descriptor descriptor;
  184         struct usb_host_endpoint ep0;
  185         struct usb_interface *linux_iface_start;
  186         struct usb_interface *linux_iface_end;
  187         struct usb_host_endpoint *linux_endpoint_start;
  188         struct usb_host_endpoint *linux_endpoint_end;
  189         uint16_t devnum;
  190 #endif
  191 
  192         uint32_t clear_stall_errors;    /* number of clear-stall failures */
  193 
  194         uint16_t autoQuirk[USB_MAX_AUTO_QUIRK];         /* dynamic quirks */
  195 };
  196 
  197 /* globals */
  198 
  199 extern int usb_template;
  200 
  201 /* function prototypes */
  202 
  203 const char *usb_statestr(enum usb_dev_state state);
  204 struct usb_device *usb_alloc_device(device_t parent_dev, struct usb_bus *bus,
  205                     struct usb_device *parent_hub, uint8_t depth,
  206                     uint8_t port_index, uint8_t port_no,
  207                     enum usb_dev_speed speed, enum usb_hc_mode mode);
  208 #if USB_HAVE_UGEN
  209 struct usb_fs_privdata *usb_make_dev(struct usb_device *, const char *,
  210                     int, int, int, uid_t, gid_t, int);
  211 void    usb_destroy_dev(struct usb_fs_privdata *);
  212 #endif
  213 usb_error_t     usb_probe_and_attach(struct usb_device *udev,
  214                     uint8_t iface_index);
  215 void            usb_detach_device(struct usb_device *, uint8_t, uint8_t);
  216 usb_error_t     usb_reset_iface_endpoints(struct usb_device *udev,
  217                     uint8_t iface_index);
  218 usb_error_t     usbd_set_config_index(struct usb_device *udev, uint8_t index);
  219 usb_error_t     usbd_set_endpoint_stall(struct usb_device *udev,
  220                     struct usb_endpoint *ep, uint8_t do_stall);
  221 usb_error_t     usb_suspend_resume(struct usb_device *udev,
  222                     uint8_t do_suspend);
  223 void    usb_devinfo(struct usb_device *udev, char *dst_ptr, uint16_t dst_len);
  224 void    usb_free_device(struct usb_device *, uint8_t);
  225 void    usb_linux_free_device(struct usb_device *dev);
  226 uint8_t usb_peer_can_wakeup(struct usb_device *udev);
  227 struct usb_endpoint *usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep);
  228 void    usb_set_device_state(struct usb_device *, enum usb_dev_state);
  229 enum usb_dev_state usb_get_device_state(struct usb_device *);
  230 
  231 void    usbd_enum_lock(struct usb_device *);
  232 void    usbd_enum_unlock(struct usb_device *);
  233 void    usbd_sr_lock(struct usb_device *);
  234 void    usbd_sr_unlock(struct usb_device *);
  235 uint8_t usbd_enum_is_locked(struct usb_device *);
  236 
  237 #endif                                  /* _USB_DEVICE_H_ */

Cache object: 80d5c9022989356098c69cccb861340a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.