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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d3880aa was eb1a2f4, checked in by Vojtech Horky <vojtechhorky@…>, 15 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
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 */
[eb1a2f4]34#include <ddf/driver.h>
[67a1b78]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
[86b39f7e]44/*----------------------------------------------------------------------------*/
[eb1a2f4]45static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
[86b39f7e]46{
[eb1a2f4]47 assert(fun);
48 uhci_t *hc = fun_to_uhci(fun);
[86b39f7e]49 assert(hc);
50 usb_address_keeping_reserve_default(&hc->address_manager);
51 return EOK;
52}
53/*----------------------------------------------------------------------------*/
[eb1a2f4]54static int release_default_address(ddf_fun_t *fun)
[86b39f7e]55{
[eb1a2f4]56 assert(fun);
57 uhci_t *hc = fun_to_uhci(fun);
[86b39f7e]58 assert(hc);
59 usb_address_keeping_release_default(&hc->address_manager);
60 return EOK;
61}
62/*----------------------------------------------------------------------------*/
[eb1a2f4]63static int request_address(ddf_fun_t *fun, usb_speed_t speed,
[6427cf67]64 usb_address_t *address)
[86b39f7e]65{
[eb1a2f4]66 assert(fun);
67 uhci_t *hc = fun_to_uhci(fun);
[86b39f7e]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(
[eb1a2f4]76 ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
[86b39f7e]77{
[eb1a2f4]78 assert(fun);
79 uhci_t *hc = fun_to_uhci(fun);
[86b39f7e]80 assert(hc);
81 usb_address_keeping_devman_bind(&hc->address_manager, address, handle);
82 return EOK;
83}
84/*----------------------------------------------------------------------------*/
[eb1a2f4]85static int release_address(ddf_fun_t *fun, usb_address_t address)
[86b39f7e]86{
[eb1a2f4]87 assert(fun);
88 uhci_t *hc = fun_to_uhci(fun);
[86b39f7e]89 assert(hc);
90 usb_address_keeping_release_default(&hc->address_manager);
91 return EOK;
[4317827]92}
[3515533]93/*----------------------------------------------------------------------------*/
[eb1a2f4]94static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
[ec59693]95 size_t max_packet_size,
[4317827]96 void *data, size_t size,
97 usbhc_iface_transfer_out_callback_t callback, void *arg)
98{
[fe10e72]99 dev_speed_t speed = FULL_SPEED;
100
[eb1a2f4]101 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
[7dd3318]102 max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
[83c439c]103 if (!batch)
[7e62b62]104 return ENOMEM;
[83c439c]105 batch_interrupt_out(batch);
[7e62b62]106 return EOK;
[4317827]107}
[3515533]108/*----------------------------------------------------------------------------*/
[eb1a2f4]109static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
[ec59693]110 size_t max_packet_size,
[4317827]111 void *data, size_t size,
112 usbhc_iface_transfer_in_callback_t callback, void *arg)
113{
[fe10e72]114 dev_speed_t speed = FULL_SPEED;
115
[eb1a2f4]116 batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
[7dd3318]117 max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
[83c439c]118 if (!batch)
[7e62b62]119 return ENOMEM;
[83c439c]120 batch_interrupt_in(batch);
[7e62b62]121 return EOK;
[4317827]122}
[3515533]123/*----------------------------------------------------------------------------*/
[eb1a2f4]124static int control_write(ddf_fun_t *fun, usb_target_t target,
[ec59693]125 size_t max_packet_size,
[a72620d]126 void *setup_data, size_t setup_size, void *data, size_t size,
127 usbhc_iface_transfer_out_callback_t callback, void *arg)
128{
[f241b05b]129 dev_speed_t speed = FULL_SPEED;
130
[eb1a2f4]131 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
[7dd3318]132 max_packet_size, speed, data, size, setup_data, setup_size,
133 NULL, callback, arg);
[83c439c]134 if (!batch)
[f241b05b]135 return ENOMEM;
[83c439c]136 batch_control_write(batch);
[f241b05b]137 return EOK;
[a72620d]138}
139/*----------------------------------------------------------------------------*/
[eb1a2f4]140static int control_read(ddf_fun_t *fun, usb_target_t target,
[ec59693]141 size_t max_packet_size,
[a72620d]142 void *setup_data, size_t setup_size, void *data, size_t size,
143 usbhc_iface_transfer_in_callback_t callback, void *arg)
144{
[f241b05b]145 dev_speed_t speed = FULL_SPEED;
146
[eb1a2f4]147 batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
[7dd3318]148 max_packet_size, speed, data, size, setup_data, setup_size, callback,
149 NULL, arg);
[83c439c]150 if (!batch)
[f241b05b]151 return ENOMEM;
[83c439c]152 batch_control_read(batch);
[f241b05b]153 return EOK;
[a72620d]154}
[7dd3318]155
156
[9e80904]157/*----------------------------------------------------------------------------*/
[4317827]158usbhc_iface_t uhci_iface = {
[86b39f7e]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,
[3515533]164
[4317827]165 .interrupt_out = interrupt_out,
166 .interrupt_in = interrupt_in,
[3515533]167
[a72620d]168 .control_read = control_read,
169 .control_write = control_write,
[4317827]170};
[c56dbe0]171/**
172 * @}
173 */
Note: See TracBrowser for help on using the repository browser.