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

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

Merge mainline changes (DDF refactoring)

This merge includes DDF refactoring that brought multifunctional devices
(i.e. ddf_dev_t and ddf_fun_t). Please, see ticket #295 at HelenOS
upstream Trac.

The conflicts themselves were easy to solve (merely several renamings).

Changes to USB subsystem:

  • drivers uses ddf_dev_t and ddf_fun_t
  • different signatures of many library functions
  • several hacks around communication with parent device (now the communication is clearer and somehow what we have now is hack about other hacks)
    • will repair and clean later
  • maybe added some extra debugging messages (the diff has about 240K, and I admit I have no energy to double check that)

WARNING:

  • the diff is VERY long, recommended is viewing partial diffs of the merge (i.e. merges in mainline branch that lead to the parent one)
  • merging with your branches might involve huge renamings, sorry, no other way is possible

BUGS:

  • hub driver will not work (no function created)

GOOD NEWS:

  • QEMU keyboard seems to work with QEMU 0.13 and 0.14
  • we are up-to-date with mainline again
  • Property mode set to 100644
File size: 5.7 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 <ddf/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
44/*----------------------------------------------------------------------------*/
45static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
46{
47 assert(fun);
48 uhci_t *hc = fun_to_uhci(fun);
49 assert(hc);
50 usb_address_keeping_reserve_default(&hc->address_manager);
51 return EOK;
52}
53/*----------------------------------------------------------------------------*/
54static int release_default_address(ddf_fun_t *fun)
55{
56 assert(fun);
57 uhci_t *hc = fun_to_uhci(fun);
58 assert(hc);
59 usb_address_keeping_release_default(&hc->address_manager);
60 return EOK;
61}
62/*----------------------------------------------------------------------------*/
63static int request_address(ddf_fun_t *fun, usb_speed_t speed,
64 usb_address_t *address)
65{
66 assert(fun);
67 uhci_t *hc = fun_to_uhci(fun);
68 assert(hc);
69 *address = usb_address_keeping_request(&hc->address_manager);
70 if (*address <= 0)
71 return *address;
72 return EOK;
73}
74/*----------------------------------------------------------------------------*/
75static int bind_address(
76 ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
77{
78 assert(fun);
79 uhci_t *hc = fun_to_uhci(fun);
80 assert(hc);
81 usb_address_keeping_devman_bind(&hc->address_manager, address, handle);
82 return EOK;
83}
84/*----------------------------------------------------------------------------*/
85static int release_address(ddf_fun_t *fun, usb_address_t address)
86{
87 assert(fun);
88 uhci_t *hc = fun_to_uhci(fun);
89 assert(hc);
90 usb_address_keeping_release_default(&hc->address_manager);
91 return EOK;
92}
93/*----------------------------------------------------------------------------*/
94static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
95 size_t max_packet_size,
96 void *data, size_t size,
97 usbhc_iface_transfer_out_callback_t callback, void *arg)
98{
99 dev_speed_t speed = FULL_SPEED;
100
101 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
102 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
103 if (!batch)
104 return ENOMEM;
105 batch_interrupt_out(batch);
106 return EOK;
107}
108/*----------------------------------------------------------------------------*/
109static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
110 size_t max_packet_size,
111 void *data, size_t size,
112 usbhc_iface_transfer_in_callback_t callback, void *arg)
113{
114 dev_speed_t speed = FULL_SPEED;
115
116 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
117 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
118 if (!batch)
119 return ENOMEM;
120 batch_interrupt_in(batch);
121 return EOK;
122}
123/*----------------------------------------------------------------------------*/
124static int control_write(ddf_fun_t *fun, usb_target_t target,
125 size_t max_packet_size,
126 void *setup_data, size_t setup_size, void *data, size_t size,
127 usbhc_iface_transfer_out_callback_t callback, void *arg)
128{
129 dev_speed_t speed = FULL_SPEED;
130
131 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
132 max_packet_size, speed, data, size, setup_data, setup_size,
133 NULL, callback, arg);
134 if (!batch)
135 return ENOMEM;
136 batch_control_write(batch);
137 return EOK;
138}
139/*----------------------------------------------------------------------------*/
140static int control_read(ddf_fun_t *fun, usb_target_t target,
141 size_t max_packet_size,
142 void *setup_data, size_t setup_size, void *data, size_t size,
143 usbhc_iface_transfer_in_callback_t callback, void *arg)
144{
145 dev_speed_t speed = FULL_SPEED;
146
147 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
148 max_packet_size, speed, data, size, setup_data, setup_size, callback,
149 NULL, arg);
150 if (!batch)
151 return ENOMEM;
152 batch_control_read(batch);
153 return EOK;
154}
155
156
157/*----------------------------------------------------------------------------*/
158usbhc_iface_t uhci_iface = {
159 .reserve_default_address = reserve_default_address,
160 .release_default_address = release_default_address,
161 .request_address = request_address,
162 .bind_address = bind_address,
163 .release_address = release_address,
164
165 .interrupt_out = interrupt_out,
166 .interrupt_in = interrupt_in,
167
168 .control_read = control_read,
169 .control_write = control_write,
170};
171/**
172 * @}
173 */
Note: See TracBrowser for help on using the repository browser.