diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/arcotg_udc.h | 4 | ||||
-rw-r--r-- | firmware/export/config-e200.h | 2 | ||||
-rw-r--r-- | firmware/export/linkedlist.h | 710 | ||||
-rw-r--r-- | firmware/export/usb_ch9.h | 762 | ||||
-rw-r--r-- | firmware/export/usbstack.h | 55 |
5 files changed, 1530 insertions, 3 deletions
diff --git a/firmware/export/arcotg_udc.h b/firmware/export/arcotg_udc.h index e3bf93a52e..e016321b37 100644 --- a/firmware/export/arcotg_udc.h +++ b/firmware/export/arcotg_udc.h | |||
@@ -37,8 +37,6 @@ | |||
37 | 37 | ||
38 | #include "cpu.h" | 38 | #include "cpu.h" |
39 | 39 | ||
40 | #define ETIMEDOUT 1 | ||
41 | |||
42 | #define USB_MAX_ENDPOINTS 8 | 40 | #define USB_MAX_ENDPOINTS 8 |
43 | #define USB_MAX_PIPES (USB_MAX_ENDPOINTS*2) | 41 | #define USB_MAX_PIPES (USB_MAX_ENDPOINTS*2) |
44 | #define USB_MAX_CTRL_PAYLOAD 64 | 42 | #define USB_MAX_CTRL_PAYLOAD 64 |
@@ -99,7 +97,7 @@ | |||
99 | #define USB_FRINDEX_MASKS (0x3fff) | 97 | #define USB_FRINDEX_MASKS (0x3fff) |
100 | 98 | ||
101 | /* USB CMD Register Bit Masks */ | 99 | /* USB CMD Register Bit Masks */ |
102 | #define USB_CMD_RUN_STOP (0x00000001) | 100 | #define USB_CMD_RUN (0x00000001) |
103 | #define USB_CMD_CTRL_RESET (0x00000002) | 101 | #define USB_CMD_CTRL_RESET (0x00000002) |
104 | #define USB_CMD_PERIODIC_SCHEDULE_EN (0x00000010) | 102 | #define USB_CMD_PERIODIC_SCHEDULE_EN (0x00000010) |
105 | #define USB_CMD_ASYNC_SCHEDULE_EN (0x00000020) | 103 | #define USB_CMD_ASYNC_SCHEDULE_EN (0x00000020) |
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 5a23b276eb..453faf5b33 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h | |||
@@ -148,6 +148,8 @@ | |||
148 | #define FIRMWARE_OFFSET_FILE_DATA 0x8 | 148 | #define FIRMWARE_OFFSET_FILE_DATA 0x8 |
149 | 149 | ||
150 | /* #define USB_IPODSTYLE */ | 150 | /* #define USB_IPODSTYLE */ |
151 | #define HAVE_USBSTACK | ||
152 | #define USBSTACK_CAPS CONTROLLER_DEVICE | ||
151 | 153 | ||
152 | /* USB On-the-go */ | 154 | /* USB On-the-go */ |
153 | #define CONFIG_USBOTG USBOTG_ARC | 155 | #define CONFIG_USBOTG USBOTG_ARC |
diff --git a/firmware/export/linkedlist.h b/firmware/export/linkedlist.h new file mode 100644 index 0000000000..299c2f2c85 --- /dev/null +++ b/firmware/export/linkedlist.h | |||
@@ -0,0 +1,710 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: adc.h 13174 2007-04-15 23:35:56Z amiconn $ | ||
9 | * | ||
10 | * Copyright (C) by Linux Kernel Developers | ||
11 | * | ||
12 | * Original source can be found in linux kernel: <kernel>/include/list.h | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _LINKED_LIST_H_ | ||
23 | #define _LINKED_LIST_H_ | ||
24 | |||
25 | #include <stddef.h> /* used for offsetof */ | ||
26 | |||
27 | static inline void prefetch(const void *x) { (void)x; } | ||
28 | |||
29 | /* | ||
30 | * Simple doubly linked list implementation. | ||
31 | * | ||
32 | * Some of the internal functions ("__xxx") are useful when | ||
33 | * manipulating whole lists rather than single entries, as | ||
34 | * sometimes we already know the next/prev entries and we can | ||
35 | * generate better code by using them directly rather than | ||
36 | * using the generic single-entry routines. | ||
37 | */ | ||
38 | |||
39 | /* TODO move this macro? */ | ||
40 | /* more about this macro: http://www.kroah.com/log/linux/container_of.html */ | ||
41 | #define container_of(ptr, type, member) ({ \ | ||
42 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
43 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
44 | |||
45 | /* | ||
46 | * These are non-NULL pointers that will result in page faults | ||
47 | * under normal circumstances, used to verify that nobody uses | ||
48 | * non-initialized list entries. | ||
49 | */ | ||
50 | #define LIST_POISON1 ((void *) 0x00100100) | ||
51 | #define LIST_POISON2 ((void *) 0x00200200) | ||
52 | |||
53 | struct list_head { | ||
54 | struct list_head *next, *prev; | ||
55 | }; | ||
56 | |||
57 | #define LIST_HEAD_INIT(name) { &(name), &(name) } | ||
58 | |||
59 | #define LIST_HEAD(name) \ | ||
60 | struct list_head name = LIST_HEAD_INIT(name) | ||
61 | |||
62 | static inline void INIT_LIST_HEAD(struct list_head *list) | ||
63 | { | ||
64 | list->next = list; | ||
65 | list->prev = list; | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * Insert a new entry between two known consecutive entries. | ||
70 | * | ||
71 | * This is only for internal list manipulation where we know | ||
72 | * the prev/next entries already! | ||
73 | */ | ||
74 | static inline void __list_add(struct list_head *new, | ||
75 | struct list_head *prev, | ||
76 | struct list_head *next) | ||
77 | { | ||
78 | next->prev = new; | ||
79 | new->next = next; | ||
80 | new->prev = prev; | ||
81 | prev->next = new; | ||
82 | } | ||
83 | |||
84 | |||
85 | /** | ||
86 | * list_add - add a new entry | ||
87 | * @new: new entry to be added | ||
88 | * @head: list head to add it after | ||
89 | * | ||
90 | * Insert a new entry after the specified head. | ||
91 | * This is good for implementing stacks. | ||
92 | */ | ||
93 | static inline void list_add(struct list_head *new, struct list_head *head) | ||
94 | { | ||
95 | __list_add(new, head, head->next); | ||
96 | } | ||
97 | |||
98 | |||
99 | /** | ||
100 | * list_add_tail - add a new entry | ||
101 | * @new: new entry to be added | ||
102 | * @head: list head to add it before | ||
103 | * | ||
104 | * Insert a new entry before the specified head. | ||
105 | * This is useful for implementing queues. | ||
106 | */ | ||
107 | static inline void list_add_tail(struct list_head *new, struct list_head *head) | ||
108 | { | ||
109 | __list_add(new, head->prev, head); | ||
110 | } | ||
111 | |||
112 | /* | ||
113 | * Delete a list entry by making the prev/next entries | ||
114 | * point to each other. | ||
115 | * | ||
116 | * This is only for internal list manipulation where we know | ||
117 | * the prev/next entries already! | ||
118 | */ | ||
119 | static inline void __list_del(struct list_head * prev, struct list_head * next) | ||
120 | { | ||
121 | next->prev = prev; | ||
122 | prev->next = next; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * list_del - deletes entry from list. | ||
127 | * @entry: the element to delete from the list. | ||
128 | * Note: list_empty() on entry does not return true after this, the entry is | ||
129 | * in an undefined state. | ||
130 | */ | ||
131 | static inline void list_del(struct list_head *entry) | ||
132 | { | ||
133 | __list_del(entry->prev, entry->next); | ||
134 | entry->next = LIST_POISON1; | ||
135 | entry->prev = LIST_POISON2; | ||
136 | } | ||
137 | |||
138 | /** | ||
139 | * list_replace - replace old entry by new one | ||
140 | * @old : the element to be replaced | ||
141 | * @new : the new element to insert | ||
142 | * | ||
143 | * If @old was empty, it will be overwritten. | ||
144 | */ | ||
145 | static inline void list_replace(struct list_head *old, | ||
146 | struct list_head *new) | ||
147 | { | ||
148 | new->next = old->next; | ||
149 | new->next->prev = new; | ||
150 | new->prev = old->prev; | ||
151 | new->prev->next = new; | ||
152 | } | ||
153 | |||
154 | static inline void list_replace_init(struct list_head *old, | ||
155 | struct list_head *new) | ||
156 | { | ||
157 | list_replace(old, new); | ||
158 | INIT_LIST_HEAD(old); | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * list_del_init - deletes entry from list and reinitialize it. | ||
163 | * @entry: the element to delete from the list. | ||
164 | */ | ||
165 | static inline void list_del_init(struct list_head *entry) | ||
166 | { | ||
167 | __list_del(entry->prev, entry->next); | ||
168 | INIT_LIST_HEAD(entry); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * list_move - delete from one list and add as another's head | ||
173 | * @list: the entry to move | ||
174 | * @head: the head that will precede our entry | ||
175 | */ | ||
176 | static inline void list_move(struct list_head *list, struct list_head *head) | ||
177 | { | ||
178 | __list_del(list->prev, list->next); | ||
179 | list_add(list, head); | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * list_move_tail - delete from one list and add as another's tail | ||
184 | * @list: the entry to move | ||
185 | * @head: the head that will follow our entry | ||
186 | */ | ||
187 | static inline void list_move_tail(struct list_head *list, | ||
188 | struct list_head *head) | ||
189 | { | ||
190 | __list_del(list->prev, list->next); | ||
191 | list_add_tail(list, head); | ||
192 | } | ||
193 | |||
194 | /** | ||
195 | * list_is_last - tests whether @list is the last entry in list @head | ||
196 | * @list: the entry to test | ||
197 | * @head: the head of the list | ||
198 | */ | ||
199 | static inline int list_is_last(const struct list_head *list, | ||
200 | const struct list_head *head) | ||
201 | { | ||
202 | return list->next == head; | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * list_empty - tests whether a list is empty | ||
207 | * @head: the list to test. | ||
208 | */ | ||
209 | static inline int list_empty(const struct list_head *head) | ||
210 | { | ||
211 | return head->next == head; | ||
212 | } | ||
213 | |||
214 | static inline void __list_splice(struct list_head *list, | ||
215 | struct list_head *head) | ||
216 | { | ||
217 | struct list_head *first = list->next; | ||
218 | struct list_head *last = list->prev; | ||
219 | struct list_head *at = head->next; | ||
220 | |||
221 | first->prev = head; | ||
222 | head->next = first; | ||
223 | |||
224 | last->next = at; | ||
225 | at->prev = last; | ||
226 | } | ||
227 | |||
228 | /** | ||
229 | * list_splice - join two lists | ||
230 | * @list: the new list to add. | ||
231 | * @head: the place to add it in the first list. | ||
232 | */ | ||
233 | static inline void list_splice(struct list_head *list, struct list_head *head) | ||
234 | { | ||
235 | if (!list_empty(list)) { | ||
236 | __list_splice(list, head); | ||
237 | } | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * list_splice_init - join two lists and reinitialise the emptied list. | ||
242 | * @list: the new list to add. | ||
243 | * @head: the place to add it in the first list. | ||
244 | * | ||
245 | * The list at @list is reinitialised | ||
246 | */ | ||
247 | static inline void list_splice_init(struct list_head *list, | ||
248 | struct list_head *head) | ||
249 | { | ||
250 | if (!list_empty(list)) { | ||
251 | __list_splice(list, head); | ||
252 | INIT_LIST_HEAD(list); | ||
253 | } | ||
254 | } | ||
255 | |||
256 | /** | ||
257 | * list_entry - get the struct for this entry | ||
258 | * @ptr: the &struct list_head pointer. | ||
259 | * @type: the type of the struct this is embedded in. | ||
260 | * @member: the name of the list_struct within the struct. | ||
261 | */ | ||
262 | #define list_entry(ptr, type, member) \ | ||
263 | container_of(ptr, type, member) | ||
264 | |||
265 | /** | ||
266 | * list_for_each - iterate over a list | ||
267 | * @pos: the &struct list_head to use as a loop cursor. | ||
268 | * @head: the head for your list. | ||
269 | */ | ||
270 | #define list_for_each(pos, head) \ | ||
271 | for (pos = (head)->next; prefetch(pos->next), pos != (head); \ | ||
272 | pos = pos->next) | ||
273 | |||
274 | /** | ||
275 | * __list_for_each - iterate over a list | ||
276 | * @pos: the &struct list_head to use as a loop cursor. | ||
277 | * @head: the head for your list. | ||
278 | * | ||
279 | * This variant differs from list_for_each() in that it's the | ||
280 | * simplest possible list iteration code, no prefetching is done. | ||
281 | * Use this for code that knows the list to be very short (empty | ||
282 | * or 1 entry) most of the time. | ||
283 | */ | ||
284 | #define __list_for_each(pos, head) \ | ||
285 | for (pos = (head)->next; pos != (head); pos = pos->next) | ||
286 | |||
287 | /** | ||
288 | * list_for_each_prev - iterate over a list backwards | ||
289 | * @pos: the &struct list_head to use as a loop cursor. | ||
290 | * @head: the head for your list. | ||
291 | */ | ||
292 | #define list_for_each_prev(pos, head) \ | ||
293 | for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ | ||
294 | pos = pos->prev) | ||
295 | |||
296 | /** | ||
297 | * list_for_each_entry - iterate over list of given type | ||
298 | * @pos: the type * to use as a loop cursor. | ||
299 | * @head: the head for your list. | ||
300 | * @member: the name of the list_struct within the struct. | ||
301 | */ | ||
302 | #define list_for_each_entry(pos, head, member) \ | ||
303 | for (pos = list_entry((head)->next, typeof(*pos), member); \ | ||
304 | prefetch(pos->member.next), &pos->member != (head); \ | ||
305 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
306 | |||
307 | /** | ||
308 | * list_for_each_entry_reverse - iterate backwards over list of given type. | ||
309 | * @pos: the type * to use as a loop cursor. | ||
310 | * @head: the head for your list. | ||
311 | * @member: the name of the list_struct within the struct. | ||
312 | */ | ||
313 | #define list_for_each_entry_reverse(pos, head, member) \ | ||
314 | for (pos = list_entry((head)->prev, typeof(*pos), member); \ | ||
315 | prefetch(pos->member.prev), &pos->member != (head); \ | ||
316 | pos = list_entry(pos->member.prev, typeof(*pos), member)) | ||
317 | |||
318 | /** | ||
319 | * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() | ||
320 | * @pos: the type * to use as a start point | ||
321 | * @head: the head of the list | ||
322 | * @member: the name of the list_struct within the struct. | ||
323 | * | ||
324 | * Prepares a pos entry for use as a start point in list_for_each_entry_continue(). | ||
325 | */ | ||
326 | #define list_prepare_entry(pos, head, member) \ | ||
327 | ((pos) ? : list_entry(head, typeof(*pos), member)) | ||
328 | |||
329 | /** | ||
330 | * list_for_each_entry_continue - continue iteration over list of given type | ||
331 | * @pos: the type * to use as a loop cursor. | ||
332 | * @head: the head for your list. | ||
333 | * @member: the name of the list_struct within the struct. | ||
334 | * | ||
335 | * Continue to iterate over list of given type, continuing after | ||
336 | * the current position. | ||
337 | */ | ||
338 | #define list_for_each_entry_continue(pos, head, member) \ | ||
339 | for (pos = list_entry(pos->member.next, typeof(*pos), member); \ | ||
340 | prefetch(pos->member.next), &pos->member != (head); \ | ||
341 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
342 | |||
343 | /** | ||
344 | * list_for_each_entry_from - iterate over list of given type from the current point | ||
345 | * @pos: the type * to use as a loop cursor. | ||
346 | * @head: the head for your list. | ||
347 | * @member: the name of the list_struct within the struct. | ||
348 | * | ||
349 | * Iterate over list of given type, continuing from current position. | ||
350 | */ | ||
351 | #define list_for_each_entry_from(pos, head, member) \ | ||
352 | for (; prefetch(pos->member.next), &pos->member != (head); \ | ||
353 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
354 | |||
355 | #endif /*_LINKED_LIST_H_*/ | ||
356 | /*************************************************************************** | ||
357 | * __________ __ ___. | ||
358 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
359 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
360 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
361 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
362 | * \/ \/ \/ \/ \/ | ||
363 | * $Id: adc.h 13174 2007-04-15 23:35:56Z amiconn $ | ||
364 | * | ||
365 | * Copyright (C) by Linux Kernel Developers | ||
366 | * | ||
367 | * Original source can be found in linux kernel: <kernel>/include/list.h | ||
368 | * | ||
369 | * All files in this archive are subject to the GNU General Public License. | ||
370 | * See the file COPYING in the source tree root for full license agreement. | ||
371 | * | ||
372 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
373 | * KIND, either express or implied. | ||
374 | * | ||
375 | ****************************************************************************/ | ||
376 | |||
377 | #ifndef _LINKED_LIST_H_ | ||
378 | #define _LINKED_LIST_H_ | ||
379 | |||
380 | #include <stddef.h> /* used for offsetof */ | ||
381 | |||
382 | static inline void prefetch(const void *x) { (void)x; } | ||
383 | |||
384 | /* | ||
385 | * Simple doubly linked list implementation. | ||
386 | * | ||
387 | * Some of the internal functions ("__xxx") are useful when | ||
388 | * manipulating whole lists rather than single entries, as | ||
389 | * sometimes we already know the next/prev entries and we can | ||
390 | * generate better code by using them directly rather than | ||
391 | * using the generic single-entry routines. | ||
392 | */ | ||
393 | |||
394 | /* TODO move this macro? */ | ||
395 | /* more about this macro: http://www.kroah.com/log/linux/container_of.html */ | ||
396 | #define container_of(ptr, type, member) ({ \ | ||
397 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
398 | (type *)( (char *)__mptr - offsetof(type,member) );}) | ||
399 | |||
400 | /* | ||
401 | * These are non-NULL pointers that will result in page faults | ||
402 | * under normal circumstances, used to verify that nobody uses | ||
403 | * non-initialized list entries. | ||
404 | */ | ||
405 | #define LIST_POISON1 ((void *) 0x00100100) | ||
406 | #define LIST_POISON2 ((void *) 0x00200200) | ||
407 | |||
408 | struct list_head { | ||
409 | struct list_head *next, *prev; | ||
410 | }; | ||
411 | |||
412 | #define LIST_HEAD_INIT(name) { &(name), &(name) } | ||
413 | |||
414 | #define LIST_HEAD(name) \ | ||
415 | struct list_head name = LIST_HEAD_INIT(name) | ||
416 | |||
417 | static inline void INIT_LIST_HEAD(struct list_head *list) | ||
418 | { | ||
419 | list->next = list; | ||
420 | list->prev = list; | ||
421 | } | ||
422 | |||
423 | /* | ||
424 | * Insert a new entry between two known consecutive entries. | ||
425 | * | ||
426 | * This is only for internal list manipulation where we know | ||
427 | * the prev/next entries already! | ||
428 | */ | ||
429 | static inline void __list_add(struct list_head *new, | ||
430 | struct list_head *prev, | ||
431 | struct list_head *next) | ||
432 | { | ||
433 | next->prev = new; | ||
434 | new->next = next; | ||
435 | new->prev = prev; | ||
436 | prev->next = new; | ||
437 | } | ||
438 | |||
439 | |||
440 | /** | ||
441 | * list_add - add a new entry | ||
442 | * @new: new entry to be added | ||
443 | * @head: list head to add it after | ||
444 | * | ||
445 | * Insert a new entry after the specified head. | ||
446 | * This is good for implementing stacks. | ||
447 | */ | ||
448 | static inline void list_add(struct list_head *new, struct list_head *head) | ||
449 | { | ||
450 | __list_add(new, head, head->next); | ||
451 | } | ||
452 | |||
453 | |||
454 | /** | ||
455 | * list_add_tail - add a new entry | ||
456 | * @new: new entry to be added | ||
457 | * @head: list head to add it before | ||
458 | * | ||
459 | * Insert a new entry before the specified head. | ||
460 | * This is useful for implementing queues. | ||
461 | */ | ||
462 | static inline void list_add_tail(struct list_head *new, struct list_head *head) | ||
463 | { | ||
464 | __list_add(new, head->prev, head); | ||
465 | } | ||
466 | |||
467 | /* | ||
468 | * Delete a list entry by making the prev/next entries | ||
469 | * point to each other. | ||
470 | * | ||
471 | * This is only for internal list manipulation where we know | ||
472 | * the prev/next entries already! | ||
473 | */ | ||
474 | static inline void __list_del(struct list_head * prev, struct list_head * next) | ||
475 | { | ||
476 | next->prev = prev; | ||
477 | prev->next = next; | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * list_del - deletes entry from list. | ||
482 | * @entry: the element to delete from the list. | ||
483 | * Note: list_empty() on entry does not return true after this, the entry is | ||
484 | * in an undefined state. | ||
485 | */ | ||
486 | static inline void list_del(struct list_head *entry) | ||
487 | { | ||
488 | __list_del(entry->prev, entry->next); | ||
489 | entry->next = LIST_POISON1; | ||
490 | entry->prev = LIST_POISON2; | ||
491 | } | ||
492 | |||
493 | /** | ||
494 | * list_replace - replace old entry by new one | ||
495 | * @old : the element to be replaced | ||
496 | * @new : the new element to insert | ||
497 | * | ||
498 | * If @old was empty, it will be overwritten. | ||
499 | */ | ||
500 | static inline void list_replace(struct list_head *old, | ||
501 | struct list_head *new) | ||
502 | { | ||
503 | new->next = old->next; | ||
504 | new->next->prev = new; | ||
505 | new->prev = old->prev; | ||
506 | new->prev->next = new; | ||
507 | } | ||
508 | |||
509 | static inline void list_replace_init(struct list_head *old, | ||
510 | struct list_head *new) | ||
511 | { | ||
512 | list_replace(old, new); | ||
513 | INIT_LIST_HEAD(old); | ||
514 | } | ||
515 | |||
516 | /** | ||
517 | * list_del_init - deletes entry from list and reinitialize it. | ||
518 | * @entry: the element to delete from the list. | ||
519 | */ | ||
520 | static inline void list_del_init(struct list_head *entry) | ||
521 | { | ||
522 | __list_del(entry->prev, entry->next); | ||
523 | INIT_LIST_HEAD(entry); | ||
524 | } | ||
525 | |||
526 | /** | ||
527 | * list_move - delete from one list and add as another's head | ||
528 | * @list: the entry to move | ||
529 | * @head: the head that will precede our entry | ||
530 | */ | ||
531 | static inline void list_move(struct list_head *list, struct list_head *head) | ||
532 | { | ||
533 | __list_del(list->prev, list->next); | ||
534 | list_add(list, head); | ||
535 | } | ||
536 | |||
537 | /** | ||
538 | * list_move_tail - delete from one list and add as another's tail | ||
539 | * @list: the entry to move | ||
540 | * @head: the head that will follow our entry | ||
541 | */ | ||
542 | static inline void list_move_tail(struct list_head *list, | ||
543 | struct list_head *head) | ||
544 | { | ||
545 | __list_del(list->prev, list->next); | ||
546 | list_add_tail(list, head); | ||
547 | } | ||
548 | |||
549 | /** | ||
550 | * list_is_last - tests whether @list is the last entry in list @head | ||
551 | * @list: the entry to test | ||
552 | * @head: the head of the list | ||
553 | */ | ||
554 | static inline int list_is_last(const struct list_head *list, | ||
555 | const struct list_head *head) | ||
556 | { | ||
557 | return list->next == head; | ||
558 | } | ||
559 | |||
560 | /** | ||
561 | * list_empty - tests whether a list is empty | ||
562 | * @head: the list to test. | ||
563 | */ | ||
564 | static inline int list_empty(const struct list_head *head) | ||
565 | { | ||
566 | return head->next == head; | ||
567 | } | ||
568 | |||
569 | static inline void __list_splice(struct list_head *list, | ||
570 | struct list_head *head) | ||
571 | { | ||
572 | struct list_head *first = list->next; | ||
573 | struct list_head *last = list->prev; | ||
574 | struct list_head *at = head->next; | ||
575 | |||
576 | first->prev = head; | ||
577 | head->next = first; | ||
578 | |||
579 | last->next = at; | ||
580 | at->prev = last; | ||
581 | } | ||
582 | |||
583 | /** | ||
584 | * list_splice - join two lists | ||
585 | * @list: the new list to add. | ||
586 | * @head: the place to add it in the first list. | ||
587 | */ | ||
588 | static inline void list_splice(struct list_head *list, struct list_head *head) | ||
589 | { | ||
590 | if (!list_empty(list)) { | ||
591 | __list_splice(list, head); | ||
592 | } | ||
593 | } | ||
594 | |||
595 | /** | ||
596 | * list_splice_init - join two lists and reinitialise the emptied list. | ||
597 | * @list: the new list to add. | ||
598 | * @head: the place to add it in the first list. | ||
599 | * | ||
600 | * The list at @list is reinitialised | ||
601 | */ | ||
602 | static inline void list_splice_init(struct list_head *list, | ||
603 | struct list_head *head) | ||
604 | { | ||
605 | if (!list_empty(list)) { | ||
606 | __list_splice(list, head); | ||
607 | INIT_LIST_HEAD(list); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | /** | ||
612 | * list_entry - get the struct for this entry | ||
613 | * @ptr: the &struct list_head pointer. | ||
614 | * @type: the type of the struct this is embedded in. | ||
615 | * @member: the name of the list_struct within the struct. | ||
616 | */ | ||
617 | #define list_entry(ptr, type, member) \ | ||
618 | container_of(ptr, type, member) | ||
619 | |||
620 | /** | ||
621 | * list_for_each - iterate over a list | ||
622 | * @pos: the &struct list_head to use as a loop cursor. | ||
623 | * @head: the head for your list. | ||
624 | */ | ||
625 | #define list_for_each(pos, head) \ | ||
626 | for (pos = (head)->next; prefetch(pos->next), pos != (head); \ | ||
627 | pos = pos->next) | ||
628 | |||
629 | /** | ||
630 | * __list_for_each - iterate over a list | ||
631 | * @pos: the &struct list_head to use as a loop cursor. | ||
632 | * @head: the head for your list. | ||
633 | * | ||
634 | * This variant differs from list_for_each() in that it's the | ||
635 | * simplest possible list iteration code, no prefetching is done. | ||
636 | * Use this for code that knows the list to be very short (empty | ||
637 | * or 1 entry) most of the time. | ||
638 | */ | ||
639 | #define __list_for_each(pos, head) \ | ||
640 | for (pos = (head)->next; pos != (head); pos = pos->next) | ||
641 | |||
642 | /** | ||
643 | * list_for_each_prev - iterate over a list backwards | ||
644 | * @pos: the &struct list_head to use as a loop cursor. | ||
645 | * @head: the head for your list. | ||
646 | */ | ||
647 | #define list_for_each_prev(pos, head) \ | ||
648 | for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \ | ||
649 | pos = pos->prev) | ||
650 | |||
651 | /** | ||
652 | * list_for_each_entry - iterate over list of given type | ||
653 | * @pos: the type * to use as a loop cursor. | ||
654 | * @head: the head for your list. | ||
655 | * @member: the name of the list_struct within the struct. | ||
656 | */ | ||
657 | #define list_for_each_entry(pos, head, member) \ | ||
658 | for (pos = list_entry((head)->next, typeof(*pos), member); \ | ||
659 | prefetch(pos->member.next), &pos->member != (head); \ | ||
660 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
661 | |||
662 | /** | ||
663 | * list_for_each_entry_reverse - iterate backwards over list of given type. | ||
664 | * @pos: the type * to use as a loop cursor. | ||
665 | * @head: the head for your list. | ||
666 | * @member: the name of the list_struct within the struct. | ||
667 | */ | ||
668 | #define list_for_each_entry_reverse(pos, head, member) \ | ||
669 | for (pos = list_entry((head)->prev, typeof(*pos), member); \ | ||
670 | prefetch(pos->member.prev), &pos->member != (head); \ | ||
671 | pos = list_entry(pos->member.prev, typeof(*pos), member)) | ||
672 | |||
673 | /** | ||
674 | * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue() | ||
675 | * @pos: the type * to use as a start point | ||
676 | * @head: the head of the list | ||
677 | * @member: the name of the list_struct within the struct. | ||
678 | * | ||
679 | * Prepares a pos entry for use as a start point in list_for_each_entry_continue(). | ||
680 | */ | ||
681 | #define list_prepare_entry(pos, head, member) \ | ||
682 | ((pos) ? : list_entry(head, typeof(*pos), member)) | ||
683 | |||
684 | /** | ||
685 | * list_for_each_entry_continue - continue iteration over list of given type | ||
686 | * @pos: the type * to use as a loop cursor. | ||
687 | * @head: the head for your list. | ||
688 | * @member: the name of the list_struct within the struct. | ||
689 | * | ||
690 | * Continue to iterate over list of given type, continuing after | ||
691 | * the current position. | ||
692 | */ | ||
693 | #define list_for_each_entry_continue(pos, head, member) \ | ||
694 | for (pos = list_entry(pos->member.next, typeof(*pos), member); \ | ||
695 | prefetch(pos->member.next), &pos->member != (head); \ | ||
696 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
697 | |||
698 | /** | ||
699 | * list_for_each_entry_from - iterate over list of given type from the current point | ||
700 | * @pos: the type * to use as a loop cursor. | ||
701 | * @head: the head for your list. | ||
702 | * @member: the name of the list_struct within the struct. | ||
703 | * | ||
704 | * Iterate over list of given type, continuing from current position. | ||
705 | */ | ||
706 | #define list_for_each_entry_from(pos, head, member) \ | ||
707 | for (; prefetch(pos->member.next), &pos->member != (head); \ | ||
708 | pos = list_entry(pos->member.next, typeof(*pos), member)) | ||
709 | |||
710 | #endif /*_LINKED_LIST_H_*/ | ||
diff --git a/firmware/export/usb_ch9.h b/firmware/export/usb_ch9.h new file mode 100644 index 0000000000..5784ff3242 --- /dev/null +++ b/firmware/export/usb_ch9.h | |||
@@ -0,0 +1,762 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) by Linux Kernel Developers | ||
11 | * | ||
12 | * Based on code from the Linux Kernel | ||
13 | * available at http://www.kernel.org | ||
14 | * Original file: <kernel>/include/linux/usb/ch9.h | ||
15 | * | ||
16 | * All files in this archive are subject to the GNU General Public License. | ||
17 | * See the file COPYING in the source tree root for full license agreement. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #ifndef _CH9_H_ | ||
25 | #define _CH9_H_ | ||
26 | |||
27 | #include <inttypes.h> | ||
28 | |||
29 | /* | ||
30 | * USB directions | ||
31 | * | ||
32 | * This bit flag is used in endpoint descriptors' bEndpointAddress field. | ||
33 | * It's also one of three fields in control requests bRequestType. | ||
34 | */ | ||
35 | #define USB_DIR_OUT 0 /* to device */ | ||
36 | #define USB_DIR_IN 0x80 /* to host */ | ||
37 | |||
38 | /* | ||
39 | * USB types, the second of three bRequestType fields | ||
40 | */ | ||
41 | #define USB_TYPE_MASK (0x03 << 5) | ||
42 | #define USB_TYPE_STANDARD (0x00 << 5) | ||
43 | #define USB_TYPE_CLASS (0x01 << 5) | ||
44 | #define USB_TYPE_VENDOR (0x02 << 5) | ||
45 | #define USB_TYPE_RESERVED (0x03 << 5) | ||
46 | |||
47 | /* | ||
48 | * USB recipients, the third of three bRequestType fields | ||
49 | */ | ||
50 | #define USB_RECIP_MASK 0x1f | ||
51 | #define USB_RECIP_DEVICE 0x00 | ||
52 | #define USB_RECIP_INTERFACE 0x01 | ||
53 | #define USB_RECIP_ENDPOINT 0x02 | ||
54 | #define USB_RECIP_OTHER 0x03 | ||
55 | |||
56 | /*-------------------------------------------------------------------------*/ | ||
57 | |||
58 | /** | ||
59 | * struct usb_ctrlrequest - SETUP data for a USB device control request | ||
60 | * @bRequestType: matches the USB bmRequestType field | ||
61 | * @bRequest: matches the USB bRequest field | ||
62 | * @wValue: matches the USB wValue field (le16 byte order) | ||
63 | * @wIndex: matches the USB wIndex field (le16 byte order) | ||
64 | * @wLength: matches the USB wLength field (le16 byte order) | ||
65 | */ | ||
66 | struct usb_ctrlrequest { | ||
67 | uint8_t bRequestType; | ||
68 | uint8_t bRequest; | ||
69 | uint16_t wValue; | ||
70 | uint16_t wIndex; | ||
71 | uint16_t wLength; | ||
72 | } __attribute__ ((packed)); | ||
73 | |||
74 | /* | ||
75 | * Standard requests, for the bRequest field of a SETUP packet. | ||
76 | * | ||
77 | * These are qualified by the bRequestType field, so that for example | ||
78 | * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved | ||
79 | * by a GET_STATUS request. | ||
80 | */ | ||
81 | #define USB_REQ_GET_STATUS 0x00 | ||
82 | #define USB_REQ_CLEAR_FEATURE 0x01 | ||
83 | #define USB_REQ_SET_FEATURE 0x03 | ||
84 | #define USB_REQ_SET_ADDRESS 0x05 | ||
85 | #define USB_REQ_GET_DESCRIPTOR 0x06 | ||
86 | #define USB_REQ_SET_DESCRIPTOR 0x07 | ||
87 | #define USB_REQ_GET_CONFIGURATION 0x08 | ||
88 | #define USB_REQ_SET_CONFIGURATION 0x09 | ||
89 | #define USB_REQ_GET_INTERFACE 0x0A | ||
90 | #define USB_REQ_SET_INTERFACE 0x0B | ||
91 | #define USB_REQ_SYNCH_FRAME 0x0C | ||
92 | |||
93 | /*-------------------------------------------------------------------------*/ | ||
94 | |||
95 | /* | ||
96 | * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or | ||
97 | * (rarely) accepted by SET_DESCRIPTOR. | ||
98 | * | ||
99 | * Note that all multi-byte values here are encoded in little endian | ||
100 | * byte order "on the wire". But when exposed through Linux-USB APIs, | ||
101 | * they've been converted to cpu byte order. | ||
102 | */ | ||
103 | |||
104 | /* | ||
105 | * Descriptor types ... USB 2.0 spec table 9.5 | ||
106 | */ | ||
107 | #define USB_DT_DEVICE 0x01 | ||
108 | #define USB_DT_CONFIG 0x02 | ||
109 | #define USB_DT_STRING 0x03 | ||
110 | #define USB_DT_INTERFACE 0x04 | ||
111 | #define USB_DT_ENDPOINT 0x05 | ||
112 | #define USB_DT_DEVICE_QUALIFIER 0x06 | ||
113 | #define USB_DT_OTHER_SPEED_CONFIG 0x07 | ||
114 | #define USB_DT_INTERFACE_POWER 0x08 | ||
115 | /* these are from a minor usb 2.0 revision (ECN) */ | ||
116 | #define USB_DT_OTG 0x09 | ||
117 | #define USB_DT_DEBUG 0x0a | ||
118 | #define USB_DT_INTERFACE_ASSOCIATION 0x0b | ||
119 | /* these are from the Wireless USB spec */ | ||
120 | #define USB_DT_SECURITY 0x0c | ||
121 | #define USB_DT_KEY 0x0d | ||
122 | #define USB_DT_ENCRYPTION_TYPE 0x0e | ||
123 | #define USB_DT_BOS 0x0f | ||
124 | #define USB_DT_DEVICE_CAPABILITY 0x10 | ||
125 | #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 | ||
126 | #define USB_DT_WIRE_ADAPTER 0x21 | ||
127 | #define USB_DT_RPIPE 0x22 | ||
128 | |||
129 | /* Conventional codes for class-specific descriptors. The convention is | ||
130 | * defined in the USB "Common Class" Spec (3.11). Individual class specs | ||
131 | * are authoritative for their usage, not the "common class" writeup. | ||
132 | */ | ||
133 | #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) | ||
134 | #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) | ||
135 | #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) | ||
136 | #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) | ||
137 | #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) | ||
138 | |||
139 | /*-------------------------------------------------------------------------*/ | ||
140 | |||
141 | /* USB_DT_DEVICE: Device descriptor */ | ||
142 | struct usb_device_descriptor { | ||
143 | uint8_t bLength; | ||
144 | uint8_t bDescriptorType; | ||
145 | uint16_t bcdUSB; | ||
146 | uint8_t bDeviceClass; | ||
147 | uint8_t bDeviceSubClass; | ||
148 | uint8_t bDeviceProtocol; | ||
149 | uint8_t bMaxPacketSize0; | ||
150 | uint16_t idVendor; | ||
151 | uint16_t idProduct; | ||
152 | uint16_t bcdDevice; | ||
153 | uint8_t iManufacturer; | ||
154 | uint8_t iProduct; | ||
155 | uint8_t iSerialNumber; | ||
156 | uint8_t bNumConfigurations; | ||
157 | } __attribute__ ((packed)); | ||
158 | |||
159 | #define USB_DT_DEVICE_SIZE 18 | ||
160 | |||
161 | /* | ||
162 | * Device and/or Interface Class codes | ||
163 | * as found in bDeviceClass or bInterfaceClass | ||
164 | * and defined by www.usb.org documents | ||
165 | */ | ||
166 | #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ | ||
167 | #define USB_CLASS_AUDIO 1 | ||
168 | #define USB_CLASS_COMM 2 | ||
169 | #define USB_CLASS_HID 3 | ||
170 | #define USB_CLASS_PHYSICAL 5 | ||
171 | #define USB_CLASS_STILL_IMAGE 6 | ||
172 | #define USB_CLASS_PRINTER 7 | ||
173 | #define USB_CLASS_MASS_STORAGE 8 | ||
174 | #define USB_CLASS_HUB 9 | ||
175 | #define USB_CLASS_CDC_DATA 0x0a | ||
176 | #define USB_CLASS_CSCID 0x0b /* chip+ smart card */ | ||
177 | #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ | ||
178 | #define USB_CLASS_VIDEO 0x0e | ||
179 | #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 | ||
180 | #define USB_CLASS_MISC 0xef | ||
181 | #define USB_CLASS_APP_SPEC 0xfe | ||
182 | #define USB_CLASS_VENDOR_SPEC 0xff | ||
183 | |||
184 | /*-------------------------------------------------------------------------*/ | ||
185 | |||
186 | /* USB_DT_CONFIG: Configuration descriptor information. | ||
187 | * | ||
188 | * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the | ||
189 | * descriptor type is different. Highspeed-capable devices can look | ||
190 | * different depending on what speed they're currently running. Only | ||
191 | * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG | ||
192 | * descriptors. | ||
193 | */ | ||
194 | struct usb_config_descriptor { | ||
195 | uint8_t bLength; | ||
196 | uint8_t bDescriptorType; | ||
197 | uint16_t wTotalLength; | ||
198 | uint8_t bNumInterfaces; | ||
199 | uint8_t bConfigurationValue; | ||
200 | uint8_t iConfiguration; | ||
201 | uint8_t bmAttributes; | ||
202 | uint8_t bMaxPower; | ||
203 | } __attribute__ ((packed)); | ||
204 | |||
205 | #define USB_DT_CONFIG_SIZE 9 | ||
206 | |||
207 | /* from config descriptor bmAttributes */ | ||
208 | #define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ | ||
209 | #define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ | ||
210 | #define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ | ||
211 | #define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ | ||
212 | |||
213 | /*-------------------------------------------------------------------------*/ | ||
214 | |||
215 | /* USB_DT_STRING: String descriptor */ | ||
216 | struct usb_string_descriptor { | ||
217 | uint8_t bLength; | ||
218 | uint8_t bDescriptorType; | ||
219 | |||
220 | uint16_t wData[1]; /* UTF-16LE encoded */ | ||
221 | } __attribute__ ((packed)); | ||
222 | |||
223 | /* note that "string" zero is special, it holds language codes that | ||
224 | * the device supports, not Unicode characters. | ||
225 | */ | ||
226 | |||
227 | /*-------------------------------------------------------------------------*/ | ||
228 | |||
229 | /* USB_DT_INTERFACE: Interface descriptor */ | ||
230 | struct usb_interface_descriptor { | ||
231 | uint8_t bLength; | ||
232 | uint8_t bDescriptorType; | ||
233 | |||
234 | uint8_t bInterfaceNumber; | ||
235 | uint8_t bAlternateSetting; | ||
236 | uint8_t bNumEndpoints; | ||
237 | uint8_t bInterfaceClass; | ||
238 | uint8_t bInterfaceSubClass; | ||
239 | uint8_t bInterfaceProtocol; | ||
240 | uint8_t iInterface; | ||
241 | } __attribute__ ((packed)); | ||
242 | |||
243 | #define USB_DT_INTERFACE_SIZE 9 | ||
244 | |||
245 | /*-------------------------------------------------------------------------*/ | ||
246 | |||
247 | /* USB_DT_ENDPOINT: Endpoint descriptor */ | ||
248 | struct usb_endpoint_descriptor { | ||
249 | uint8_t bLength; | ||
250 | uint8_t bDescriptorType; | ||
251 | |||
252 | uint8_t bEndpointAddress; | ||
253 | uint8_t bmAttributes; | ||
254 | uint16_t wMaxPacketSize; | ||
255 | uint8_t bInterval; | ||
256 | |||
257 | /* NOTE: these two are _only_ in audio endpoints. */ | ||
258 | /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ | ||
259 | //uint8_t bRefresh; | ||
260 | //uint8_t bSynchAddress; | ||
261 | } __attribute__ ((packed)); | ||
262 | |||
263 | #define USB_DT_ENDPOINT_SIZE 7 | ||
264 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | ||
265 | |||
266 | /*-------------------------------------------------------------------------*/ | ||
267 | |||
268 | /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ | ||
269 | struct usb_qualifier_descriptor { | ||
270 | uint8_t bLength; | ||
271 | uint8_t bDescriptorType; | ||
272 | |||
273 | uint16_t bcdUSB; | ||
274 | uint8_t bDeviceClass; | ||
275 | uint8_t bDeviceSubClass; | ||
276 | uint8_t bDeviceProtocol; | ||
277 | uint8_t bMaxPacketSize0; | ||
278 | uint8_t bNumConfigurations; | ||
279 | uint8_t bRESERVED; | ||
280 | } __attribute__ ((packed)); | ||
281 | |||
282 | /*-------------------------------------------------------------------------*/ | ||
283 | |||
284 | /* USB_DT_OTG (from OTG 1.0a supplement) */ | ||
285 | struct usb_otg_descriptor { | ||
286 | uint8_t bLength; | ||
287 | uint8_t bDescriptorType; | ||
288 | |||
289 | uint8_t bmAttributes; /* support for HNP, SRP, etc */ | ||
290 | } __attribute__ ((packed)); | ||
291 | |||
292 | /* from usb_otg_descriptor.bmAttributes */ | ||
293 | #define USB_OTG_SRP (1 << 0) | ||
294 | #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ | ||
295 | |||
296 | /*-------------------------------------------------------------------------*/ | ||
297 | |||
298 | /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ | ||
299 | struct usb_debug_descriptor { | ||
300 | uint8_t bLength; | ||
301 | uint8_t bDescriptorType; | ||
302 | |||
303 | /* bulk endpoints with 8 byte maxpacket */ | ||
304 | uint8_t bDebugInEndpoint; | ||
305 | uint8_t bDebugOutEndpoint; | ||
306 | }; | ||
307 | |||
308 | /*-------------------------------------------------------------------------*/ | ||
309 | |||
310 | /* | ||
311 | * Endpoints | ||
312 | */ | ||
313 | #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ | ||
314 | #define USB_ENDPOINT_XFER_CONTROL 0 | ||
315 | #define USB_ENDPOINT_XFER_ISOC 1 | ||
316 | #define USB_ENDPOINT_XFER_BULK 2 | ||
317 | #define USB_ENDPOINT_XFER_INT 3 | ||
318 | |||
319 | enum usb_device_speed { | ||
320 | USB_SPEED_UNKNOWN = 0, /* enumerating */ | ||
321 | USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | ||
322 | USB_SPEED_HIGH, /* usb 2.0 */ | ||
323 | USB_SPEED_VARIABLE, /* wireless (usb 2.5) */ | ||
324 | }; | ||
325 | |||
326 | enum usb_device_state { | ||
327 | /* NOTATTACHED isn't in the USB spec, and this state acts | ||
328 | * the same as ATTACHED ... but it's clearer this way. | ||
329 | */ | ||
330 | USB_STATE_NOTATTACHED = 0, | ||
331 | |||
332 | /* chapter 9 and authentication (wireless) device states */ | ||
333 | USB_STATE_ATTACHED, | ||
334 | USB_STATE_POWERED, /* wired */ | ||
335 | USB_STATE_UNAUTHENTICATED, /* auth */ | ||
336 | USB_STATE_RECONNECTING, /* auth */ | ||
337 | USB_STATE_DEFAULT, /* limited function */ | ||
338 | USB_STATE_ADDRESS, | ||
339 | USB_STATE_CONFIGURED, /* most functions */ | ||
340 | |||
341 | USB_STATE_SUSPENDED | ||
342 | |||
343 | /* NOTE: there are actually four different SUSPENDED | ||
344 | * states, returning to POWERED, DEFAULT, ADDRESS, or | ||
345 | * CONFIGURED respectively when SOF tokens flow again. | ||
346 | */ | ||
347 | }; | ||
348 | |||
349 | /* All standard descriptors have these 2 fields at the beginning */ | ||
350 | struct usb_descriptor_header { | ||
351 | uint8_t bLength; | ||
352 | uint8_t bDescriptorType; | ||
353 | } __attribute__ ((packed)); | ||
354 | |||
355 | /** | ||
356 | * struct usb_string - wraps a C string and its USB id | ||
357 | * @id:the (nonzero) ID for this string | ||
358 | * @s:the string, in UTF-8 encoding | ||
359 | * | ||
360 | * If you're using usb_gadget_get_string(), use this to wrap a string | ||
361 | * together with its ID. | ||
362 | */ | ||
363 | struct usb_string { | ||
364 | uint8_t id; | ||
365 | const char* s; | ||
366 | }; | ||
367 | |||
368 | /** | ||
369 | * struct usb_gadget_strings - a set of USB strings in a given language | ||
370 | * @language:identifies the strings' language (0x0409 for en-us) | ||
371 | * @strings:array of strings with their ids | ||
372 | * | ||
373 | * If you're using usb_gadget_get_string(), use this to wrap all the | ||
374 | * strings for a given language. | ||
375 | */ | ||
376 | struct usb_gadget_strings { | ||
377 | uint16_t language; /* 0x0409 for en-us */ | ||
378 | struct usb_string* strings; | ||
379 | }; | ||
380 | |||
381 | #endif /*_CH9_H_*/ | ||
382 | /*************************************************************************** | ||
383 | * __________ __ ___. | ||
384 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
385 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
386 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
387 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
388 | * \/ \/ \/ \/ \/ | ||
389 | * $Id: $ | ||
390 | * | ||
391 | * Copyright (C) by Linux Kernel Developers | ||
392 | * | ||
393 | * Based on code from the Linux Kernel | ||
394 | * available at http://www.kernel.org | ||
395 | * Original file: <kernel>/include/linux/usb/ch9.h | ||
396 | * | ||
397 | * All files in this archive are subject to the GNU General Public License. | ||
398 | * See the file COPYING in the source tree root for full license agreement. | ||
399 | * | ||
400 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
401 | * KIND, either express or implied. | ||
402 | * | ||
403 | ****************************************************************************/ | ||
404 | |||
405 | #ifndef _CH9_H_ | ||
406 | #define _CH9_H_ | ||
407 | |||
408 | #include <inttypes.h> | ||
409 | |||
410 | /* | ||
411 | * USB directions | ||
412 | * | ||
413 | * This bit flag is used in endpoint descriptors' bEndpointAddress field. | ||
414 | * It's also one of three fields in control requests bRequestType. | ||
415 | */ | ||
416 | #define USB_DIR_OUT 0 /* to device */ | ||
417 | #define USB_DIR_IN 0x80 /* to host */ | ||
418 | |||
419 | /* | ||
420 | * USB types, the second of three bRequestType fields | ||
421 | */ | ||
422 | #define USB_TYPE_MASK (0x03 << 5) | ||
423 | #define USB_TYPE_STANDARD (0x00 << 5) | ||
424 | #define USB_TYPE_CLASS (0x01 << 5) | ||
425 | #define USB_TYPE_VENDOR (0x02 << 5) | ||
426 | #define USB_TYPE_RESERVED (0x03 << 5) | ||
427 | |||
428 | /* | ||
429 | * USB recipients, the third of three bRequestType fields | ||
430 | */ | ||
431 | #define USB_RECIP_MASK 0x1f | ||
432 | #define USB_RECIP_DEVICE 0x00 | ||
433 | #define USB_RECIP_INTERFACE 0x01 | ||
434 | #define USB_RECIP_ENDPOINT 0x02 | ||
435 | #define USB_RECIP_OTHER 0x03 | ||
436 | |||
437 | /*-------------------------------------------------------------------------*/ | ||
438 | |||
439 | /** | ||
440 | * struct usb_ctrlrequest - SETUP data for a USB device control request | ||
441 | * @bRequestType: matches the USB bmRequestType field | ||
442 | * @bRequest: matches the USB bRequest field | ||
443 | * @wValue: matches the USB wValue field (le16 byte order) | ||
444 | * @wIndex: matches the USB wIndex field (le16 byte order) | ||
445 | * @wLength: matches the USB wLength field (le16 byte order) | ||
446 | */ | ||
447 | struct usb_ctrlrequest { | ||
448 | uint8_t bRequestType; | ||
449 | uint8_t bRequest; | ||
450 | uint16_t wValue; | ||
451 | uint16_t wIndex; | ||
452 | uint16_t wLength; | ||
453 | } __attribute__ ((packed)); | ||
454 | |||
455 | /* | ||
456 | * Standard requests, for the bRequest field of a SETUP packet. | ||
457 | * | ||
458 | * These are qualified by the bRequestType field, so that for example | ||
459 | * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved | ||
460 | * by a GET_STATUS request. | ||
461 | */ | ||
462 | #define USB_REQ_GET_STATUS 0x00 | ||
463 | #define USB_REQ_CLEAR_FEATURE 0x01 | ||
464 | #define USB_REQ_SET_FEATURE 0x03 | ||
465 | #define USB_REQ_SET_ADDRESS 0x05 | ||
466 | #define USB_REQ_GET_DESCRIPTOR 0x06 | ||
467 | #define USB_REQ_SET_DESCRIPTOR 0x07 | ||
468 | #define USB_REQ_GET_CONFIGURATION 0x08 | ||
469 | #define USB_REQ_SET_CONFIGURATION 0x09 | ||
470 | #define USB_REQ_GET_INTERFACE 0x0A | ||
471 | #define USB_REQ_SET_INTERFACE 0x0B | ||
472 | #define USB_REQ_SYNCH_FRAME 0x0C | ||
473 | |||
474 | /*-------------------------------------------------------------------------*/ | ||
475 | |||
476 | /* | ||
477 | * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or | ||
478 | * (rarely) accepted by SET_DESCRIPTOR. | ||
479 | * | ||
480 | * Note that all multi-byte values here are encoded in little endian | ||
481 | * byte order "on the wire". But when exposed through Linux-USB APIs, | ||
482 | * they've been converted to cpu byte order. | ||
483 | */ | ||
484 | |||
485 | /* | ||
486 | * Descriptor types ... USB 2.0 spec table 9.5 | ||
487 | */ | ||
488 | #define USB_DT_DEVICE 0x01 | ||
489 | #define USB_DT_CONFIG 0x02 | ||
490 | #define USB_DT_STRING 0x03 | ||
491 | #define USB_DT_INTERFACE 0x04 | ||
492 | #define USB_DT_ENDPOINT 0x05 | ||
493 | #define USB_DT_DEVICE_QUALIFIER 0x06 | ||
494 | #define USB_DT_OTHER_SPEED_CONFIG 0x07 | ||
495 | #define USB_DT_INTERFACE_POWER 0x08 | ||
496 | /* these are from a minor usb 2.0 revision (ECN) */ | ||
497 | #define USB_DT_OTG 0x09 | ||
498 | #define USB_DT_DEBUG 0x0a | ||
499 | #define USB_DT_INTERFACE_ASSOCIATION 0x0b | ||
500 | /* these are from the Wireless USB spec */ | ||
501 | #define USB_DT_SECURITY 0x0c | ||
502 | #define USB_DT_KEY 0x0d | ||
503 | #define USB_DT_ENCRYPTION_TYPE 0x0e | ||
504 | #define USB_DT_BOS 0x0f | ||
505 | #define USB_DT_DEVICE_CAPABILITY 0x10 | ||
506 | #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 | ||
507 | #define USB_DT_WIRE_ADAPTER 0x21 | ||
508 | #define USB_DT_RPIPE 0x22 | ||
509 | |||
510 | /* Conventional codes for class-specific descriptors. The convention is | ||
511 | * defined in the USB "Common Class" Spec (3.11). Individual class specs | ||
512 | * are authoritative for their usage, not the "common class" writeup. | ||
513 | */ | ||
514 | #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) | ||
515 | #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) | ||
516 | #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) | ||
517 | #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) | ||
518 | #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) | ||
519 | |||
520 | /*-------------------------------------------------------------------------*/ | ||
521 | |||
522 | /* USB_DT_DEVICE: Device descriptor */ | ||
523 | struct usb_device_descriptor { | ||
524 | uint8_t bLength; | ||
525 | uint8_t bDescriptorType; | ||
526 | uint16_t bcdUSB; | ||
527 | uint8_t bDeviceClass; | ||
528 | uint8_t bDeviceSubClass; | ||
529 | uint8_t bDeviceProtocol; | ||
530 | uint8_t bMaxPacketSize0; | ||
531 | uint16_t idVendor; | ||
532 | uint16_t idProduct; | ||
533 | uint16_t bcdDevice; | ||
534 | uint8_t iManufacturer; | ||
535 | uint8_t iProduct; | ||
536 | uint8_t iSerialNumber; | ||
537 | uint8_t bNumConfigurations; | ||
538 | } __attribute__ ((packed)); | ||
539 | |||
540 | #define USB_DT_DEVICE_SIZE 18 | ||
541 | |||
542 | /* | ||
543 | * Device and/or Interface Class codes | ||
544 | * as found in bDeviceClass or bInterfaceClass | ||
545 | * and defined by www.usb.org documents | ||
546 | */ | ||
547 | #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ | ||
548 | #define USB_CLASS_AUDIO 1 | ||
549 | #define USB_CLASS_COMM 2 | ||
550 | #define USB_CLASS_HID 3 | ||
551 | #define USB_CLASS_PHYSICAL 5 | ||
552 | #define USB_CLASS_STILL_IMAGE 6 | ||
553 | #define USB_CLASS_PRINTER 7 | ||
554 | #define USB_CLASS_MASS_STORAGE 8 | ||
555 | #define USB_CLASS_HUB 9 | ||
556 | #define USB_CLASS_CDC_DATA 0x0a | ||
557 | #define USB_CLASS_CSCID 0x0b /* chip+ smart card */ | ||
558 | #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ | ||
559 | #define USB_CLASS_VIDEO 0x0e | ||
560 | #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 | ||
561 | #define USB_CLASS_MISC 0xef | ||
562 | #define USB_CLASS_APP_SPEC 0xfe | ||
563 | #define USB_CLASS_VENDOR_SPEC 0xff | ||
564 | |||
565 | /*-------------------------------------------------------------------------*/ | ||
566 | |||
567 | /* USB_DT_CONFIG: Configuration descriptor information. | ||
568 | * | ||
569 | * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the | ||
570 | * descriptor type is different. Highspeed-capable devices can look | ||
571 | * different depending on what speed they're currently running. Only | ||
572 | * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG | ||
573 | * descriptors. | ||
574 | */ | ||
575 | struct usb_config_descriptor { | ||
576 | uint8_t bLength; | ||
577 | uint8_t bDescriptorType; | ||
578 | uint16_t wTotalLength; | ||
579 | uint8_t bNumInterfaces; | ||
580 | uint8_t bConfigurationValue; | ||
581 | uint8_t iConfiguration; | ||
582 | uint8_t bmAttributes; | ||
583 | uint8_t bMaxPower; | ||
584 | } __attribute__ ((packed)); | ||
585 | |||
586 | #define USB_DT_CONFIG_SIZE 9 | ||
587 | |||
588 | /* from config descriptor bmAttributes */ | ||
589 | #define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ | ||
590 | #define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ | ||
591 | #define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ | ||
592 | #define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ | ||
593 | |||
594 | /*-------------------------------------------------------------------------*/ | ||
595 | |||
596 | /* USB_DT_STRING: String descriptor */ | ||
597 | struct usb_string_descriptor { | ||
598 | uint8_t bLength; | ||
599 | uint8_t bDescriptorType; | ||
600 | |||
601 | uint16_t wData[1]; /* UTF-16LE encoded */ | ||
602 | } __attribute__ ((packed)); | ||
603 | |||
604 | /* note that "string" zero is special, it holds language codes that | ||
605 | * the device supports, not Unicode characters. | ||
606 | */ | ||
607 | |||
608 | /*-------------------------------------------------------------------------*/ | ||
609 | |||
610 | /* USB_DT_INTERFACE: Interface descriptor */ | ||
611 | struct usb_interface_descriptor { | ||
612 | uint8_t bLength; | ||
613 | uint8_t bDescriptorType; | ||
614 | |||
615 | uint8_t bInterfaceNumber; | ||
616 | uint8_t bAlternateSetting; | ||
617 | uint8_t bNumEndpoints; | ||
618 | uint8_t bInterfaceClass; | ||
619 | uint8_t bInterfaceSubClass; | ||
620 | uint8_t bInterfaceProtocol; | ||
621 | uint8_t iInterface; | ||
622 | } __attribute__ ((packed)); | ||
623 | |||
624 | #define USB_DT_INTERFACE_SIZE 9 | ||
625 | |||
626 | /*-------------------------------------------------------------------------*/ | ||
627 | |||
628 | /* USB_DT_ENDPOINT: Endpoint descriptor */ | ||
629 | struct usb_endpoint_descriptor { | ||
630 | uint8_t bLength; | ||
631 | uint8_t bDescriptorType; | ||
632 | |||
633 | uint8_t bEndpointAddress; | ||
634 | uint8_t bmAttributes; | ||
635 | uint16_t wMaxPacketSize; | ||
636 | uint8_t bInterval; | ||
637 | |||
638 | /* NOTE: these two are _only_ in audio endpoints. */ | ||
639 | /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ | ||
640 | //uint8_t bRefresh; | ||
641 | //uint8_t bSynchAddress; | ||
642 | } __attribute__ ((packed)); | ||
643 | |||
644 | #define USB_DT_ENDPOINT_SIZE 7 | ||
645 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | ||
646 | |||
647 | /*-------------------------------------------------------------------------*/ | ||
648 | |||
649 | /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ | ||
650 | struct usb_qualifier_descriptor { | ||
651 | uint8_t bLength; | ||
652 | uint8_t bDescriptorType; | ||
653 | |||
654 | uint16_t bcdUSB; | ||
655 | uint8_t bDeviceClass; | ||
656 | uint8_t bDeviceSubClass; | ||
657 | uint8_t bDeviceProtocol; | ||
658 | uint8_t bMaxPacketSize0; | ||
659 | uint8_t bNumConfigurations; | ||
660 | uint8_t bRESERVED; | ||
661 | } __attribute__ ((packed)); | ||
662 | |||
663 | /*-------------------------------------------------------------------------*/ | ||
664 | |||
665 | /* USB_DT_OTG (from OTG 1.0a supplement) */ | ||
666 | struct usb_otg_descriptor { | ||
667 | uint8_t bLength; | ||
668 | uint8_t bDescriptorType; | ||
669 | |||
670 | uint8_t bmAttributes; /* support for HNP, SRP, etc */ | ||
671 | } __attribute__ ((packed)); | ||
672 | |||
673 | /* from usb_otg_descriptor.bmAttributes */ | ||
674 | #define USB_OTG_SRP (1 << 0) | ||
675 | #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ | ||
676 | |||
677 | /*-------------------------------------------------------------------------*/ | ||
678 | |||
679 | /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ | ||
680 | struct usb_debug_descriptor { | ||
681 | uint8_t bLength; | ||
682 | uint8_t bDescriptorType; | ||
683 | |||
684 | /* bulk endpoints with 8 byte maxpacket */ | ||
685 | uint8_t bDebugInEndpoint; | ||
686 | uint8_t bDebugOutEndpoint; | ||
687 | }; | ||
688 | |||
689 | /*-------------------------------------------------------------------------*/ | ||
690 | |||
691 | /* | ||
692 | * Endpoints | ||
693 | */ | ||
694 | #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ | ||
695 | #define USB_ENDPOINT_XFER_CONTROL 0 | ||
696 | #define USB_ENDPOINT_XFER_ISOC 1 | ||
697 | #define USB_ENDPOINT_XFER_BULK 2 | ||
698 | #define USB_ENDPOINT_XFER_INT 3 | ||
699 | |||
700 | enum usb_device_speed { | ||
701 | USB_SPEED_UNKNOWN = 0, /* enumerating */ | ||
702 | USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | ||
703 | USB_SPEED_HIGH, /* usb 2.0 */ | ||
704 | USB_SPEED_VARIABLE, /* wireless (usb 2.5) */ | ||
705 | }; | ||
706 | |||
707 | enum usb_device_state { | ||
708 | /* NOTATTACHED isn't in the USB spec, and this state acts | ||
709 | * the same as ATTACHED ... but it's clearer this way. | ||
710 | */ | ||
711 | USB_STATE_NOTATTACHED = 0, | ||
712 | |||
713 | /* chapter 9 and authentication (wireless) device states */ | ||
714 | USB_STATE_ATTACHED, | ||
715 | USB_STATE_POWERED, /* wired */ | ||
716 | USB_STATE_UNAUTHENTICATED, /* auth */ | ||
717 | USB_STATE_RECONNECTING, /* auth */ | ||
718 | USB_STATE_DEFAULT, /* limited function */ | ||
719 | USB_STATE_ADDRESS, | ||
720 | USB_STATE_CONFIGURED, /* most functions */ | ||
721 | |||
722 | USB_STATE_SUSPENDED | ||
723 | |||
724 | /* NOTE: there are actually four different SUSPENDED | ||
725 | * states, returning to POWERED, DEFAULT, ADDRESS, or | ||
726 | * CONFIGURED respectively when SOF tokens flow again. | ||
727 | */ | ||
728 | }; | ||
729 | |||
730 | /* All standard descriptors have these 2 fields at the beginning */ | ||
731 | struct usb_descriptor_header { | ||
732 | uint8_t bLength; | ||
733 | uint8_t bDescriptorType; | ||
734 | } __attribute__ ((packed)); | ||
735 | |||
736 | /** | ||
737 | * struct usb_string - wraps a C string and its USB id | ||
738 | * @id:the (nonzero) ID for this string | ||
739 | * @s:the string, in UTF-8 encoding | ||
740 | * | ||
741 | * If you're using usb_gadget_get_string(), use this to wrap a string | ||
742 | * together with its ID. | ||
743 | */ | ||
744 | struct usb_string { | ||
745 | uint8_t id; | ||
746 | const char* s; | ||
747 | }; | ||
748 | |||
749 | /** | ||
750 | * struct usb_gadget_strings - a set of USB strings in a given language | ||
751 | * @language:identifies the strings' language (0x0409 for en-us) | ||
752 | * @strings:array of strings with their ids | ||
753 | * | ||
754 | * If you're using usb_gadget_get_string(), use this to wrap all the | ||
755 | * strings for a given language. | ||
756 | */ | ||
757 | struct usb_gadget_strings { | ||
758 | uint16_t language; /* 0x0409 for en-us */ | ||
759 | struct usb_string* strings; | ||
760 | }; | ||
761 | |||
762 | #endif /*_CH9_H_*/ | ||
diff --git a/firmware/export/usbstack.h b/firmware/export/usbstack.h new file mode 100644 index 0000000000..9142b1bdba --- /dev/null +++ b/firmware/export/usbstack.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Christian Gmeiner | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef _USBSTACK_H_ | ||
21 | #define _USBSTACK_H_ | ||
22 | |||
23 | #include <errno.h> | ||
24 | |||
25 | #define USB_STACK_MAX_SETTINGS_NAME 32*10 /* should be enough for > 10 driver names */ | ||
26 | |||
27 | /* | ||
28 | * error codes | ||
29 | */ | ||
30 | #define ENOFREESLOT 1 | ||
31 | #define EWRONGCONTROLLERTYPE 2 | ||
32 | #define ENODRIVERFOUND 3 | ||
33 | #define EHWCRITICAL 4 | ||
34 | |||
35 | enum usb_controller_type { | ||
36 | DEVICE = 0, | ||
37 | HOST, | ||
38 | }; | ||
39 | |||
40 | /* | ||
41 | * stack routines | ||
42 | */ | ||
43 | void usb_stack_init(void); | ||
44 | void usb_stack_start(void); | ||
45 | void usb_stack_stop(void); | ||
46 | |||
47 | void usb_controller_select(int type); | ||
48 | int usb_stack_get_mode(void); | ||
49 | int usb_device_driver_bind(const char* name); | ||
50 | void ubs_device_driver_unbind(void); | ||
51 | |||
52 | /* used by apps settings code */ | ||
53 | unsigned char device_driver_names[USB_STACK_MAX_SETTINGS_NAME]; | ||
54 | |||
55 | #endif /*_USBSTACK_H_*/ | ||