]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/nusb/usbd/dat.h
nusbd: properly terminate worker proc if no hubs can be found
[plan9front.git] / sys / src / cmd / nusb / usbd / dat.h
1 typedef struct Hub Hub;
2 typedef struct DHub DHub;
3 typedef struct Port Port;
4
5 enum
6 {
7         Stack   = 32*1024,
8
9         Dhub    = 0x29,         /* hub descriptor type */
10         Dhublen = 9,            /* hub descriptor length */
11
12         /* hub class feature selectors */
13         Fhublocalpower  = 0,
14         Fhubovercurrent = 1,
15
16         Fportconnection = 0,
17         Fportenable     = 1,
18         Fportsuspend    = 2,
19         Fportovercurrent = 3,
20         Fportreset      = 4,
21         Fportpower      = 8,
22         Fportlowspeed   = 9,
23         Fcportconnection        = 16,
24         Fcportenable    = 17,
25         Fcportsuspend   = 18,
26         Fcportovercurrent= 19,
27         Fcportreset     = 20,
28         Fportindicator  = 22,
29
30         /* Port status and status change bits
31          * Constants at /sys/src/9/pc/usb.h starting with HP-
32          * must have the same values or root hubs won't work.
33          */
34         PSpresent       = 0x0001,
35         PSenable        = 0x0002,
36         PSsuspend       = 0x0004,
37         PSovercurrent   = 0x0008,
38         PSreset         = 0x0010,
39         PSpower         = 0x0100,
40         PSslow          = 0x0200,
41         PShigh          = 0x0400,
42
43         PSstatuschg     = 0x10000,      /* PSpresent changed */
44         PSchange        = 0x20000,      /* PSenable changed */
45
46
47         /* port/device state */
48         Pdisabled = 0,          /* must be 0 */
49         Pattached,
50         Pconfiged,
51
52         /* Delays, timeouts (ms) */
53 //      Spawndelay      = 1000,         /* how often may we re-spawn a driver */
54         Spawndelay      = 250,          /* how often may we re-spawn a driver */
55 //      Connectdelay    = 1000,         /* how much to wait after a connect */
56         Connectdelay    = 500,          /* how much to wait after a connect */
57         Resetdelay      = 20,           /* how much to wait after a reset */
58         Enabledelay     = 20,           /* how much to wait after an enable */
59         Powerdelay      = 100,          /* after powering up ports */
60         Pollms          = 250,          /* port poll interval */
61         Chgdelay        = 100,          /* waiting for port become stable */
62         Chgtmout        = 1000,         /* ...but at most this much */
63
64         /*
65          * device tab for embedded usb drivers.
66          */
67         DCL = 0x01000000,               /* csp identifies just class */
68         DSC = 0x02000000,               /* csp identifies just subclass */
69         DPT = 0x04000000,               /* csp identifies just proto */
70
71 };
72
73 struct Hub
74 {
75         uchar   pwrmode;
76         uchar   compound;
77         uchar   pwrms;          /* time to wait in ms */
78         uchar   maxcurrent;     /*    after powering port*/
79         int     leds;           /* has port indicators? */
80         int     maxpkt;
81         uchar   nport;
82         Port    *port;
83         int     failed;         /* I/O error while enumerating */
84         int     isroot;         /* set if root hub */
85         Dev     *dev;           /* for this hub */
86         Hub     *next;          /* in list of hubs */
87 };
88
89 struct Port
90 {
91         int     state;          /* state of the device */
92         int     sts;            /* old port status */
93         uchar   removable;
94         uchar   pwrctl;
95         Dev     *dev;           /* attached device (if non-nil) */
96         Hub     *hub;           /* non-nil if hub attached */
97         int     devnb;          /* device number */
98         uvlong  *devmaskp;      /* ptr to dev mask */
99 };
100
101 /* USB HUB descriptor */
102 struct DHub
103 {
104         uchar   bLength;
105         uchar   bDescriptorType;
106         uchar   bNbrPorts;
107         uchar   wHubCharacteristics[2];
108         uchar   bPwrOn2PwrGood;
109         uchar   bHubContrCurrent;
110         uchar   DeviceRemovable[1];     /* variable length */
111 };