1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 struct usbf_endpoint {
29 struct usbf_interface *iface;
30 usb_endpoint_descriptor_t *edesc;
31 int halted;
32 int refcnt;
33 SIMPLEQ_ENTRY(usbf_endpoint) next;
34 };
35
36 struct usbf_interface {
37 struct usbf_config *config;
38 usb_interface_descriptor_t *idesc;
39 LIST_HEAD(, usbf_pipe) pipes;
40 SIMPLEQ_HEAD(, usbf_endpoint) endpoint_head;
41 SIMPLEQ_ENTRY(usbf_interface) next;
42 };
43
44 struct usbf_config {
45 struct usbf_device *uc_device;
46 usb_config_descriptor_t *uc_cdesc;
47 size_t uc_cdesc_size;
48 int uc_closed;
49 SIMPLEQ_HEAD(, usbf_interface) iface_head;
50 SIMPLEQ_ENTRY(usbf_config) next;
51 };
52
53 struct usbf_device {
54 struct device bdev;
55 struct usbf_bus *bus;
56 struct usbf_function *function;
57 struct usbf_pipe *default_pipe;
58 struct usbf_xfer *default_xfer;
59 struct usbf_xfer *data_xfer;
60 int address;
61 usbf_config_handle config;
62 usb_status_t status;
63 usb_device_request_t def_req;
64 struct usbf_endpoint def_ep;
65 usb_endpoint_descriptor_t def_ep_desc;
66 usb_device_descriptor_t ddesc;
67 usb_string_descriptor_t *sdesc;
68 size_t sdesc_size;
69 uByte string_id;
70 SIMPLEQ_HEAD(, usbf_config) configs;
71 };
72
73
74
75 struct usbf_pipe_methods {
76 usbf_status (*transfer)(usbf_xfer_handle);
77 usbf_status (*start)(usbf_xfer_handle);
78 void (*abort)(usbf_xfer_handle);
79 void (*done)(usbf_xfer_handle);
80 void (*close)(usbf_pipe_handle);
81 };
82
83 struct usbf_bus_methods {
84 usbf_status (*open_pipe)(struct usbf_pipe *);
85 void (*soft_intr)(void *);
86 usbf_status (*allocm)(struct usbf_bus *, usb_dma_t *, u_int32_t);
87 void (*freem)(struct usbf_bus *, usb_dma_t *);
88 struct usbf_xfer *(*allocx)(struct usbf_bus *);
89 void (*freex)(struct usbf_bus *, struct usbf_xfer *);
90 };
91
92 struct usbf_softc;
93
94 struct usbf_bus {
95
96 struct device bdev;
97 struct usbf_bus_methods *methods;
98 size_t pipe_size;
99 u_int8_t ep0_maxp;
100 int usbrev;
101
102 struct usbf_softc *usbfctl;
103 int intr_context;
104 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
105 void *soft;
106 #endif
107 bus_dma_tag_t dmatag;
108 };
109
110 struct usbf_port {
111 usb_port_status_t status;
112 u_int8_t portno;
113 struct usbf_device *device;
114 };
115
116 struct usbf_pipe {
117 struct usbf_device *device;
118 struct usbf_interface *iface;
119 struct usbf_endpoint *endpoint;
120 int refcnt;
121 int running;
122 int aborting;
123 SIMPLEQ_HEAD(, usbf_xfer) queue;
124 LIST_ENTRY(usbf_pipe) next;
125
126 char repeat;
127 int interval;
128
129
130 struct usbf_pipe_methods *methods;
131 };
132
133 struct usbf_xfer {
134 struct usbf_pipe *pipe;
135 usbf_private_handle priv;
136 void *buffer;
137 u_int32_t length;
138 u_int32_t actlen;
139 u_int16_t flags;
140 u_int32_t timeout;
141 usbf_status status;
142 usbf_callback callback;
143 SIMPLEQ_ENTRY(usbf_xfer) next;
144
145
146 struct usbf_device *device;
147 int rqflags;
148 usb_dma_t dmabuf;
149
150 struct timeout timeout_handle;
151 };
152
153
154
155 void usbf_host_reset(usbf_bus_handle);
156 void usbf_do_request(usbf_xfer_handle, usbf_private_handle,
157 usbf_status);
158
159
160 usbf_status usbf_new_device(struct device *, usbf_bus_handle, int, int, int,
161 struct usbf_port *);
162 usbf_status usbf_set_endpoint_feature(usbf_config_handle, u_int8_t,
163 u_int16_t);
164 usbf_status usbf_clear_endpoint_feature(usbf_config_handle, u_int8_t,
165 u_int16_t);
166 usbf_status usbf_insert_transfer(usbf_xfer_handle xfer);
167 void usbf_transfer_complete(usbf_xfer_handle xfer);
168 usbf_status usbf_allocmem(usbf_bus_handle, size_t, size_t, usb_dma_t *);
169 void usbf_freemem(usbf_bus_handle, usb_dma_t *);
170 usbf_status usbf_softintr_establish(struct usbf_bus *);
171 void usbf_schedsoftintr(struct usbf_bus *);