lfn
serial
ticket/834-toolchain-update
topic/msim-upgrade
topic/simplify-dev-export
Last change
on this file since 6cb58e6 was 6cb58e6, checked in by Vojtech Horky <vojtechhorky@…>, 14 years ago |
Virtual USB layer rewritten
Major changes include
- IPC sends whole transfers (not transactions)
- separate transfer queues for each device in host controller
- possibility to return NAK from virtual device (handled by HC)
- better implementation of callbacks for non-zero endpoints
Still missing
- communication for some transfer types (bulk)
- face-lift
- documentation
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include "private.h"
|
---|
2 | #include <usb/request.h>
|
---|
3 | #include <usb/debug.h>
|
---|
4 | #include <assert.h>
|
---|
5 | #include <errno.h>
|
---|
6 |
|
---|
7 | int process_control_transfer(usbvirt_device_t *dev,
|
---|
8 | usbvirt_control_request_handler_t *control_handlers,
|
---|
9 | usb_device_request_setup_packet_t *setup,
|
---|
10 | uint8_t *data, size_t *data_sent_size)
|
---|
11 | {
|
---|
12 | assert(dev);
|
---|
13 | assert(setup);
|
---|
14 |
|
---|
15 | if (control_handlers == NULL) {
|
---|
16 | return EFORWARD;
|
---|
17 | }
|
---|
18 |
|
---|
19 | usb_direction_t direction = setup->request_type & 128 ?
|
---|
20 | USB_DIRECTION_IN : USB_DIRECTION_OUT;
|
---|
21 | usb_request_recipient_t req_recipient = setup->request_type & 31;
|
---|
22 | usb_request_type_t req_type = (setup->request_type >> 5) & 3;
|
---|
23 |
|
---|
24 | usbvirt_control_request_handler_t *handler = control_handlers;
|
---|
25 | while (handler->callback != NULL) {
|
---|
26 | if (handler->req_direction != direction) {
|
---|
27 | goto next;
|
---|
28 | }
|
---|
29 | if (handler->req_recipient != req_recipient) {
|
---|
30 | goto next;
|
---|
31 | }
|
---|
32 | if (handler->req_type != req_type) {
|
---|
33 | goto next;
|
---|
34 | }
|
---|
35 | if (handler->request != setup->request) {
|
---|
36 | goto next;
|
---|
37 | }
|
---|
38 |
|
---|
39 | usb_log_debug("Control transfer: %s(%s)\n", handler->name,
|
---|
40 | usb_debug_str_buffer((uint8_t*) setup, sizeof(*setup), 0));
|
---|
41 | int rc = handler->callback(dev, setup, data, data_sent_size);
|
---|
42 | if (rc == EFORWARD) {
|
---|
43 | goto next;
|
---|
44 | }
|
---|
45 |
|
---|
46 | return rc;
|
---|
47 |
|
---|
48 | next:
|
---|
49 | handler++;
|
---|
50 | }
|
---|
51 |
|
---|
52 | return EFORWARD;
|
---|
53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.