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
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
[1669a73]37#include <usb/debug.h>
38
[4317827]39#include <errno.h>
40
[3515533]41#include "iface.h"
[4317827]42#include "uhci.h"
43
44static int get_address(device_t *dev, devman_handle_t handle,
45 usb_address_t *address)
46{
[86b39f7e]47 assert(dev);
[5944244]48 uhci_t *hc = dev_to_uhci(dev);
[86b39f7e]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/*----------------------------------------------------------------------------*/
[fa48ebe]56static int reserve_default_address(device_t *dev, usb_speed_t speed)
[86b39f7e]57{
58 assert(dev);
[5944244]59 uhci_t *hc = dev_to_uhci(dev);
[86b39f7e]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);
[5944244]68 uhci_t *hc = dev_to_uhci(dev);
[86b39f7e]69 assert(hc);
70 usb_address_keeping_release_default(&hc->address_manager);
71 return EOK;
72}
73/*----------------------------------------------------------------------------*/
[fa48ebe]74static int request_address(device_t *dev, usb_speed_t speed,
[6427cf67]75 usb_address_t *address)
[86b39f7e]76{
77 assert(dev);
[5944244]78 uhci_t *hc = dev_to_uhci(dev);
[86b39f7e]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);
[5944244]90 uhci_t *hc = dev_to_uhci(dev);
[86b39f7e]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);
[5944244]99 uhci_t *hc = dev_to_uhci(dev);
[86b39f7e]100 assert(hc);
101 usb_address_keeping_release_default(&hc->address_manager);
102 return EOK;
[4317827]103}
[3515533]104/*----------------------------------------------------------------------------*/
[4317827]105static int interrupt_out(device_t *dev, usb_target_t target,
[ec59693]106 size_t max_packet_size,
[4317827]107 void *data, size_t size,
108 usbhc_iface_transfer_out_callback_t callback, void *arg)
109{
[fe10e72]110 dev_speed_t speed = FULL_SPEED;
111
[83c439c]112 batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
[7dd3318]113 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
[83c439c]114 if (!batch)
[7e62b62]115 return ENOMEM;
[83c439c]116 batch_interrupt_out(batch);
[7e62b62]117 return EOK;
[4317827]118}
[3515533]119/*----------------------------------------------------------------------------*/
[4317827]120static int interrupt_in(device_t *dev, usb_target_t target,
[ec59693]121 size_t max_packet_size,
[4317827]122 void *data, size_t size,
123 usbhc_iface_transfer_in_callback_t callback, void *arg)
124{
[fe10e72]125 dev_speed_t speed = FULL_SPEED;
126
[83c439c]127 batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
[7dd3318]128 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
[83c439c]129 if (!batch)
[7e62b62]130 return ENOMEM;
[83c439c]131 batch_interrupt_in(batch);
[7e62b62]132 return EOK;
[4317827]133}
[3515533]134/*----------------------------------------------------------------------------*/
[a72620d]135static int control_write(device_t *dev, usb_target_t target,
[ec59693]136 size_t max_packet_size,
[a72620d]137 void *setup_data, size_t setup_size, void *data, size_t size,
138 usbhc_iface_transfer_out_callback_t callback, void *arg)
139{
[f241b05b]140 dev_speed_t speed = FULL_SPEED;
141
[83c439c]142 batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
[7dd3318]143 max_packet_size, speed, data, size, setup_data, setup_size,
144 NULL, callback, arg);
[83c439c]145 if (!batch)
[f241b05b]146 return ENOMEM;
[83c439c]147 batch_control_write(batch);
[f241b05b]148 return EOK;
[a72620d]149}
150/*----------------------------------------------------------------------------*/
151static int control_read(device_t *dev, usb_target_t target,
[ec59693]152 size_t max_packet_size,
[a72620d]153 void *setup_data, size_t setup_size, void *data, size_t size,
154 usbhc_iface_transfer_in_callback_t callback, void *arg)
155{
[f241b05b]156 dev_speed_t speed = FULL_SPEED;
157
[83c439c]158 batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
[7dd3318]159 max_packet_size, speed, data, size, setup_data, setup_size, callback,
160 NULL, arg);
[83c439c]161 if (!batch)
[f241b05b]162 return ENOMEM;
[83c439c]163 batch_control_read(batch);
[f241b05b]164 return EOK;
[a72620d]165}
[7dd3318]166
167
[9e80904]168/*----------------------------------------------------------------------------*/
[4317827]169usbhc_iface_t uhci_iface = {
170 .tell_address = get_address,
[3515533]171
[86b39f7e]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,
[3515533]177
[4317827]178 .interrupt_out = interrupt_out,
179 .interrupt_in = interrupt_in,
[3515533]180
[a72620d]181 .control_read = control_read,
182 .control_write = control_write,
[4317827]183};
[c56dbe0]184/**
185 * @}
186 */
Note: See TracBrowser for help on using the repository browser.