source: mainline/uspace/drv/uhci-hcd/iface.c@ b9d910f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b9d910f was b36e5de2, checked in by Vojtech Horky <vojtechhorky@…>, 15 years ago

Removal of remote parts of old API

The control transfer callbacks for each part of the transfer
(i.e. for setup, data and status) were completely removed.

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*
2 * Copyright (c) 2011 Vojtech Horky, Jan Vesely
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/** @addtogroup usb
29 * @{
30 */
31/** @file
32 * @brief UHCI driver
33 */
34#include <driver.h>
35#include <remote_usbhc.h>
36
37#include <usb/debug.h>
38
39#include <errno.h>
40
41#include "iface.h"
42#include "uhci.h"
43
44static int get_address(device_t *dev, devman_handle_t handle,
45 usb_address_t *address)
46{
47 assert(dev);
48 uhci_t *hc = dev_to_uhci(dev);
49 assert(hc);
50 *address = usb_address_keeping_find(&hc->address_manager, handle);
51 if (*address <= 0)
52 return *address;
53 return EOK;
54}
55/*----------------------------------------------------------------------------*/
56static int reserve_default_address(device_t *dev, usb_speed_t speed)
57{
58 assert(dev);
59 uhci_t *hc = dev_to_uhci(dev);
60 assert(hc);
61 usb_address_keeping_reserve_default(&hc->address_manager);
62 return EOK;
63}
64/*----------------------------------------------------------------------------*/
65static int release_default_address(device_t *dev)
66{
67 assert(dev);
68 uhci_t *hc = dev_to_uhci(dev);
69 assert(hc);
70 usb_address_keeping_release_default(&hc->address_manager);
71 return EOK;
72}
73/*----------------------------------------------------------------------------*/
74static int request_address(device_t *dev, usb_speed_t speed,
75 usb_address_t *address)
76{
77 assert(dev);
78 uhci_t *hc = dev_to_uhci(dev);
79 assert(hc);
80 *address = usb_address_keeping_request(&hc->address_manager);
81 if (*address <= 0)
82 return *address;
83 return EOK;
84}
85/*----------------------------------------------------------------------------*/
86static int bind_address(
87 device_t *dev, usb_address_t address, devman_handle_t handle)
88{
89 assert(dev);
90 uhci_t *hc = dev_to_uhci(dev);
91 assert(hc);
92 usb_address_keeping_devman_bind(&hc->address_manager, address, handle);
93 return EOK;
94}
95/*----------------------------------------------------------------------------*/
96static int release_address(device_t *dev, usb_address_t address)
97{
98 assert(dev);
99 uhci_t *hc = dev_to_uhci(dev);
100 assert(hc);
101 usb_address_keeping_release_default(&hc->address_manager);
102 return EOK;
103}
104/*----------------------------------------------------------------------------*/
105static int interrupt_out(device_t *dev, usb_target_t target,
106 size_t max_packet_size,
107 void *data, size_t size,
108 usbhc_iface_transfer_out_callback_t callback, void *arg)
109{
110 dev_speed_t speed = FULL_SPEED;
111
112 batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
113 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
114 if (!batch)
115 return ENOMEM;
116 batch_interrupt_out(batch);
117 return EOK;
118}
119/*----------------------------------------------------------------------------*/
120static int interrupt_in(device_t *dev, usb_target_t target,
121 size_t max_packet_size,
122 void *data, size_t size,
123 usbhc_iface_transfer_in_callback_t callback, void *arg)
124{
125 dev_speed_t speed = FULL_SPEED;
126
127 batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
128 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
129 if (!batch)
130 return ENOMEM;
131 batch_interrupt_in(batch);
132 return EOK;
133}
134/*----------------------------------------------------------------------------*/
135static int control_write(device_t *dev, usb_target_t target,
136 size_t max_packet_size,
137 void *setup_data, size_t setup_size, void *data, size_t size,
138 usbhc_iface_transfer_out_callback_t callback, void *arg)
139{
140 dev_speed_t speed = FULL_SPEED;
141
142 batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
143 max_packet_size, speed, data, size, setup_data, setup_size,
144 NULL, callback, arg);
145 if (!batch)
146 return ENOMEM;
147 batch_control_write(batch);
148 return EOK;
149}
150/*----------------------------------------------------------------------------*/
151static int control_read(device_t *dev, usb_target_t target,
152 size_t max_packet_size,
153 void *setup_data, size_t setup_size, void *data, size_t size,
154 usbhc_iface_transfer_in_callback_t callback, void *arg)
155{
156 dev_speed_t speed = FULL_SPEED;
157
158 batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
159 max_packet_size, speed, data, size, setup_data, setup_size, callback,
160 NULL, arg);
161 if (!batch)
162 return ENOMEM;
163 batch_control_read(batch);
164 return EOK;
165}
166
167
168/*----------------------------------------------------------------------------*/
169usbhc_iface_t uhci_iface = {
170 .tell_address = get_address,
171
172 .reserve_default_address = reserve_default_address,
173 .release_default_address = release_default_address,
174 .request_address = request_address,
175 .bind_address = bind_address,
176 .release_address = release_address,
177
178 .interrupt_out = interrupt_out,
179 .interrupt_in = interrupt_in,
180
181 .control_read = control_read,
182 .control_write = control_write,
183};
184/**
185 * @}
186 */
Note: See TracBrowser for help on using the repository browser.