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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c56dbe0 was c56dbe0, checked in by Jan Vesely <jano.vesely@…>, 15 years ago

Added license statement to all .c files

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