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 "uhci.h"
|
---|
32 |
|
---|
33 | static int enqueue_transfer_out(device_t *dev,
|
---|
34 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
35 | void *buffer, size_t size,
|
---|
36 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
37 | {
|
---|
38 | printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
|
---|
39 | target.address, target.endpoint,
|
---|
40 | usb_str_transfer_type(transfer_type),
|
---|
41 | size);
|
---|
42 |
|
---|
43 | return ENOTSUP;
|
---|
44 | }
|
---|
45 |
|
---|
46 | static int enqueue_transfer_setup(device_t *dev,
|
---|
47 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
48 | void *buffer, size_t size,
|
---|
49 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
50 | {
|
---|
51 | printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
|
---|
52 | target.address, target.endpoint,
|
---|
53 | usb_str_transfer_type(transfer_type),
|
---|
54 | size);
|
---|
55 |
|
---|
56 | return ENOTSUP;
|
---|
57 | }
|
---|
58 |
|
---|
59 | static int enqueue_transfer_in(device_t *dev,
|
---|
60 | usb_target_t target, usb_transfer_type_t transfer_type,
|
---|
61 | void *buffer, size_t size,
|
---|
62 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
63 | {
|
---|
64 | printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
|
---|
65 | target.address, target.endpoint,
|
---|
66 | usb_str_transfer_type(transfer_type),
|
---|
67 | size);
|
---|
68 |
|
---|
69 | return ENOTSUP;
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | static int get_address(device_t *dev, devman_handle_t handle,
|
---|
74 | usb_address_t *address)
|
---|
75 | {
|
---|
76 | return ENOTSUP;
|
---|
77 | }
|
---|
78 |
|
---|
79 | static int interrupt_out(device_t *dev, usb_target_t target,
|
---|
80 | void *data, size_t size,
|
---|
81 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
82 | {
|
---|
83 | return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT,
|
---|
84 | data, size,
|
---|
85 | 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 enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
|
---|
93 | data, size,
|
---|
94 | callback, arg);
|
---|
95 | }
|
---|
96 |
|
---|
97 | static int control_write_setup(device_t *dev, usb_target_t target,
|
---|
98 | void *data, size_t size,
|
---|
99 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
100 | {
|
---|
101 | return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
|
---|
102 | data, size,
|
---|
103 | callback, arg);
|
---|
104 | }
|
---|
105 |
|
---|
106 | static int control_write_data(device_t *dev, usb_target_t target,
|
---|
107 | void *data, size_t size,
|
---|
108 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
109 | {
|
---|
110 | return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
|
---|
111 | data, size,
|
---|
112 | callback, arg);
|
---|
113 | }
|
---|
114 |
|
---|
115 | static int control_write_status(device_t *dev, usb_target_t target,
|
---|
116 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
117 | {
|
---|
118 | return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
|
---|
119 | NULL, 0,
|
---|
120 | callback, arg);
|
---|
121 | }
|
---|
122 |
|
---|
123 | static int control_read_setup(device_t *dev, usb_target_t target,
|
---|
124 | void *data, size_t size,
|
---|
125 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
126 | {
|
---|
127 | return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
|
---|
128 | data, size,
|
---|
129 | callback, arg);
|
---|
130 | }
|
---|
131 |
|
---|
132 | static int control_read_data(device_t *dev, usb_target_t target,
|
---|
133 | void *data, size_t size,
|
---|
134 | usbhc_iface_transfer_in_callback_t callback, void *arg)
|
---|
135 | {
|
---|
136 | return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
|
---|
137 | data, size,
|
---|
138 | callback, arg);
|
---|
139 | }
|
---|
140 |
|
---|
141 | static int control_read_status(device_t *dev, usb_target_t target,
|
---|
142 | usbhc_iface_transfer_out_callback_t callback, void *arg)
|
---|
143 | {
|
---|
144 | return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
|
---|
145 | NULL, 0,
|
---|
146 | callback, arg);
|
---|
147 | }
|
---|
148 |
|
---|
149 |
|
---|
150 | usbhc_iface_t uhci_iface = {
|
---|
151 | .tell_address = get_address,
|
---|
152 | .interrupt_out = interrupt_out,
|
---|
153 | .interrupt_in = interrupt_in,
|
---|
154 | .control_write_setup = control_write_setup,
|
---|
155 | .control_write_data = control_write_data,
|
---|
156 | .control_write_status = control_write_status,
|
---|
157 | .control_read_setup = control_read_setup,
|
---|
158 | .control_read_data = control_read_data,
|
---|
159 | .control_read_status = control_read_status
|
---|
160 | };
|
---|