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/pc/usb.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 /*
    2  * common USB definitions.
    3  */
    4 typedef struct Udev Udev;       /* USB device */
    5 typedef struct Ep Ep;           /* Endpoint */
    6 typedef struct Hci Hci;         /* Host Controller Interface */
    7 typedef struct Hciimpl Hciimpl; /* Link to the controller impl. */
    8 
    9 enum
   10 {
   11         /* fundamental constants */
   12         Ndeveps = 16,           /* max nb. of endpoints per device */
   13 
   14         /* tunable parameters */
   15         Nhcis   = 16,           /* max nb. of HCIs */
   16         Neps    = 64,           /* max nb. of endpoints */
   17         Maxctllen = 8*1024,     /* max allowed sized for ctl. xfers */
   18 
   19         /* transfer types. keep this order */
   20         Tnone = 0,              /* no tranfer type configured */
   21         Tctl,                   /* wr req + rd/wr data + wr/rd sts */
   22         Tiso,                   /* stream rd or wr (real time) */
   23         Tbulk,                  /* stream rd or wr */
   24         Tintr,                  /* msg rd or wr */
   25         Nttypes,                /* number of transfer types */
   26 
   27         Epmax   = 0xF,          /* max ep. addr */
   28         Devmax  = 0x7F,         /* max dev. addr */
   29 
   30         /* Speeds */
   31         Fullspeed = 0,
   32         Lowspeed,
   33         Highspeed,
   34         Nospeed,
   35 
   36         /* request type */
   37         Rh2d = 0<<7,
   38         Rd2h = 1<<7,
   39         Rstd = 0<<5,
   40         Rclass =  1<<5,
   41         Rdev = 0,
   42         Rep = 2,
   43         Rother = 3,
   44 
   45         /* req offsets */
   46         Rtype   = 0,
   47         Rreq    = 1,
   48         Rvalue  = 2,
   49         Rindex  = 4,
   50         Rcount  = 6,
   51         Rsetuplen = 8,
   52 
   53         /* standard requests */
   54         Rgetstatus      = 0,
   55         Rclearfeature   = 1,
   56         Rsetfeature     = 3,
   57         Rsetaddr        = 5,
   58         Rgetdesc        = 6,
   59 
   60         /* device states */
   61         Dconfig  = 0,           /* configuration in progress */
   62         Denabled,               /* address assigned */
   63         Ddetach,                /* device is detached */
   64 
   65         /* (root) Hub reply to port status (reported to usbd) */
   66         HPpresent       = 0x1,
   67         HPenable        = 0x2,
   68         HPsuspend       = 0x4,
   69         HPovercurrent   = 0x8,
   70         HPreset         = 0x10,
   71         HPpower         = 0x100,
   72         HPslow          = 0x200,
   73         HPhigh          = 0x400,
   74         HPstatuschg     = 0x10000,
   75         HPchange        = 0x20000,
   76 };
   77 
   78 /*
   79  * Services provided by the driver.
   80  * epopen allocates hardware structures to prepare the endpoint
   81  * for I/O. This happens when the user opens the data file.
   82  * epclose releases them. This happens when the data file is closed.
   83  * epwrite tries to write the given bytes, waiting until all of them
   84  * have been written (or failed) before returning; but not for Iso.
   85  * epread does the same for reading.
   86  * It can be assumed that endpoints are DMEXCL but concurrent
   87  * read/writes may be issued and the controller must take care.
   88  * For control endpoints, device-to-host requests must be followed by
   89  * a read of the expected length if needed.
   90  * The port requests are called when usbd issues commands for root
   91  * hubs. Port status must return bits as a hub request would do.
   92  * Toggle handling and other details are left for the controller driver
   93  * to avoid mixing too much the controller and the comon device.
   94  * While an endpoint is closed, its toggles are saved in the Ep struct.
   95  */
   96 struct Hciimpl
   97 {
   98         void    *aux;                           /* for controller info */
   99         void    (*init)(Hci*);                  /* init. controller */
  100         void    (*dump)(Hci*);                  /* debug */
  101         void    (*interrupt)(Ureg*, void*);     /* service interrupt */
  102         void    (*epopen)(Ep*);                 /* prepare ep. for I/O */
  103         void    (*epclose)(Ep*);                /* terminate I/O on ep. */
  104         long    (*epread)(Ep*,void*,long);      /* transmit data for ep */
  105         long    (*epwrite)(Ep*,void*,long);     /* receive data for ep */
  106         char*   (*seprintep)(char*,char*,Ep*);  /* debug */
  107         int     (*portenable)(Hci*, int, int);  /* enable/disable port */
  108         int     (*portreset)(Hci*, int, int);   /* set/clear port reset */
  109         int     (*portstatus)(Hci*, int);       /* get port status */
  110         void    (*debug)(Hci*, int);            /* set/clear debug flag */
  111 };
  112 
  113 struct Hci
  114 {
  115         ISAConf;                                /* hardware info */
  116         int     tbdf;                           /* type+busno+devno+funcno */
  117         int     ctlrno;                         /* controller number */
  118         int     nports;                         /* number of ports in hub */
  119         int     highspeed;
  120         Hciimpl;                                        /* HCI driver  */
  121 
  122 };
  123 
  124 /*
  125  * USB endpoint.
  126  * All endpoints are kept in a global array. The first
  127  * block of fields is constant after endpoint creation.
  128  * The rest is configuration information given to all controllers.
  129  * The first endpoint for a device (known as ep0) represents the
  130  * device and is used to configure it and create other endpoints.
  131  * Its QLock also protects per-device data in dev.
  132  * See Hciimpl for clues regarding how this is used by controllers.
  133  */
  134 struct Ep
  135 {
  136         Ref;                    /* one per fid (and per dev ep for ep0s) */
  137 
  138         /* const once inited. */
  139         int     idx;            /* index in global eps array */
  140         int     nb;             /* endpoint number in device */
  141         Hci*    hp;             /* HCI it belongs to */
  142         Udev*   dev;            /* device for the endpoint */
  143         Ep*     ep0;            /* control endpoint for its device */
  144 
  145         QLock;                  /* protect fields below */
  146         char*   name;           /* for ep file names at #u/ */
  147         int     inuse;          /* endpoint is open */
  148         int     mode;           /* OREAD, OWRITE, or ORDWR */
  149         int     clrhalt;        /* true if halt was cleared on ep. */
  150         int     debug;          /* per endpoint debug flag */
  151         char*   info;           /* for humans to read */
  152         long    maxpkt;         /* maximum packet size */
  153         int     ttype;          /* tranfer type */
  154         ulong   load;           /* in µs, for a fransfer of maxpkt bytes */
  155         void*   aux;            /* for controller specific info */
  156         int     rhrepl;         /* fake root hub replies */
  157         int     toggle[2];      /* saved toggles (while ep is not in use) */
  158         long    pollival;               /* poll interval ([µ]frames; intr/iso) */
  159         long    hz;             /* poll frequency (iso) */
  160         long    samplesz;       /* sample size (iso) */
  161         int     ntds;           /* nb. of Tds per µframe */
  162 };
  163 
  164 /*
  165  * Per-device configuration and cached list of endpoints.
  166  * eps[0]->QLock protects it.
  167  */
  168 struct Udev
  169 {
  170         int     nb;             /* USB device number */
  171         int     state;          /* state for the device */
  172         int     ishub;          /* hubs can allocate devices */
  173         int     isroot;         /* is a root hub */
  174         int     speed;          /* Full/Low/High/No -speed */
  175         int     hub;            /* dev number for the parent hub */
  176         int     port;           /* port number in the parent hub */
  177         Ep*     eps[Ndeveps];   /* end points for this device (cached) */
  178 };
  179 
  180 void    addhcitype(char *type, int (*reset)(Hci*));
  181 #define dprint          if(debug)print
  182 #define ddprint         if(debug>1)print
  183 #define deprint         if(debug || ep->debug)print
  184 #define ddeprint        if(debug>1 || ep->debug>1)print
  185 #define GET2(p)         ((((p)[1]&0xFF)<<8)|((p)[0]&0xFF))
  186 #define PUT2(p,v)       {((p)[0] = (v)); ((p)[1] = (v)>>8);}
  187 
  188 extern char *usbmodename[];
  189 extern char Estalled[];
  190 
  191 extern char *seprintdata(char*,char*,uchar*,int);

Cache object: 3aafffd51dab6ebe01b590666c8192ab


[ 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.