1 | /*
|
---|
2 | * Copyright (c) 2010 Vojtech Horky
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 | #include <usb/hcdhubd.h>
|
---|
29 | #include <errno.h>
|
---|
30 |
|
---|
31 | #include "iface.h"
|
---|
32 | #include "uhci.h"
|
---|
33 | /*
|
---|
34 | static int enqueue_transfer_out(device_t *dev,
|
---|
35 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
36 | void *buffer, size_t size,
|
---|
37 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
38 | {
|
---|
39 | printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
|
---|
40 | target.address, target.endpoint,
|
---|
41 | usb_str_transfer_type(transfer_type),
|
---|
42 | size);
|
---|
43 |
|
---|
44 | return ENOTSUP;
|
---|
45 | }
|
---|
46 |
|
---|
47 | static int enqueue_transfer_setup(device_t *dev,
|
---|
48 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
49 | void *buffer, size_t size,
|
---|
50 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
51 | {
|
---|
52 | printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
|
---|
53 | target.address, target.endpoint,
|
---|
54 | usb_str_transfer_type(transfer_type),
|
---|
55 | size);
|
---|
56 |
|
---|
57 | return ENOTSUP;
|
---|
58 | }
|
---|
59 |
|
---|
60 | static int enqueue_transfer_in(device_t *dev,
|
---|
61 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
62 | void *buffer, size_t size,
|
---|
63 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
64 | {
|
---|
65 | printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
|
---|
66 | target.address, target.endpoint,
|
---|
67 | usb_str_transfer_type(transfer_type),
|
---|
68 | size);
|
---|
69 |
|
---|
70 | return ENOTSUP;
|
---|
71 | }
|
---|
72 | */
|
---|
73 |
|
---|
74 | static int get_address(device_t *dev, devman_handle_t handle,
|
---|
75 | usb_address_t *address)
|
---|
76 | {
|
---|
77 | return ENOTSUP;
|
---|
78 | }
|
---|
79 | /*----------------------------------------------------------------------------*/
|
---|
80 | static int interrupt_out(device_t *dev, usb_target_t target,
|
---|
81 | void *data, size_t size,
|
---|
82 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
83 | {
|
---|
84 | return uhci_out(dev, target, USB_TRANSFER_INTERRUPT,
|
---|
85 | data, size, callback, arg);
|
---|
86 | }
|
---|
87 | /*----------------------------------------------------------------------------*/
|
---|
88 | static int interrupt_in(device_t *dev, usb_target_t target,
|
---|
89 | void *data, size_t size,
|
---|
90 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
91 | {
|
---|
92 | return uhci_in(dev, target, USB_TRANSFER_INTERRUPT,
|
---|
93 | data, size, callback, arg);
|
---|
94 | }
|
---|
95 | /*----------------------------------------------------------------------------*/
|
---|
96 | static int control_write_setup(device_t *dev, usb_target_t target,
|
---|
97 | void *data, size_t size,
|
---|
98 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
99 | {
|
---|
100 | return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
|
---|
101 | data, size, callback, arg);
|
---|
102 | }
|
---|
103 | /*----------------------------------------------------------------------------*/
|
---|
104 | static int control_write_data(device_t *dev, usb_target_t target,
|
---|
105 | void *data, size_t size,
|
---|
106 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
107 | {
|
---|
108 | return uhci_out(dev, target, USB_TRANSFER_CONTROL,
|
---|
109 | data, size, callback, arg);
|
---|
110 | }
|
---|
111 | /*----------------------------------------------------------------------------*/
|
---|
112 | static int control_write_status(device_t *dev, usb_target_t target,
|
---|
113 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
114 | {
|
---|
115 | return uhci_in(dev, target, USB_TRANSFER_CONTROL,
|
---|
116 | NULL, 0, callback, arg);
|
---|
117 | }
|
---|
118 | /*----------------------------------------------------------------------------*/
|
---|
119 | static int control_read_setup(device_t *dev, usb_target_t target,
|
---|
120 | void *data, size_t size,
|
---|
121 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
122 | {
|
---|
123 | return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
|
---|
124 | data, size, callback, arg);
|
---|
125 | }
|
---|
126 | /*----------------------------------------------------------------------------*/
|
---|
127 | static int control_read_data(device_t *dev, usb_target_t target,
|
---|
128 | void *data, size_t size,
|
---|
129 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
130 | {
|
---|
131 | return uhci_in(dev, target, USB_TRANSFER_CONTROL,
|
---|
132 | data, size, callback, arg);
|
---|
133 | }
|
---|
134 | /*----------------------------------------------------------------------------*/
|
---|
135 | static int control_read_status(device_t *dev, usb_target_t target,
|
---|
136 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
137 | {
|
---|
138 | return uhci_out(dev, target, USB_TRANSFER_CONTROL,
|
---|
139 | NULL, 0, callback, arg);
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | usbhc_iface_t uhci_iface = {
|
---|
144 | .tell_address = get_address,
|
---|
145 |
|
---|
146 | .reserve_default_address = NULL,
|
---|
147 | .release_default_address = NULL,
|
---|
148 | .request_address = NULL,
|
---|
149 | .bind_address = NULL,
|
---|
150 | .release_address = NULL,
|
---|
151 |
|
---|
152 | .interrupt_out = interrupt_out,
|
---|
153 | .interrupt_in = interrupt_in,
|
---|
154 |
|
---|
155 | .control_write_setup = control_write_setup,
|
---|
156 | .control_write_data = control_write_data,
|
---|
157 | .control_write_status = control_write_status,
|
---|
158 |
|
---|
159 | .control_read_setup = control_read_setup,
|
---|
160 | .control_read_data = control_read_data,
|
---|
161 | .control_read_status = control_read_status
|
---|
162 | };
|
---|