source: mainline/uspace/drv/vhc/hcd.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: 3.5 KB
Line 
1/*
2 * Copyright (c) 2010 Vojtech Horky
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
29/** @addtogroup drvusbvhc
30 * @{
31 */
32/** @file
33 * @brief Virtual host controller driver.
34 */
35
36#include <devmap.h>
37#include <async.h>
38#include <unistd.h>
39#include <stdlib.h>
40#include <sysinfo.h>
41#include <stdio.h>
42#include <errno.h>
43#include <str_error.h>
44#include <ddf/driver.h>
45
46#include <usb/usb.h>
47#include <usb/ddfiface.h>
48#include <usb_iface.h>
49#include "vhcd.h"
50#include "hc.h"
51#include "devices.h"
52#include "hub.h"
53#include "conn.h"
54
55static ddf_dev_ops_t vhc_ops = {
56 .interfaces[USBHC_DEV_IFACE] = &vhc_iface,
57 .interfaces[USB_DEV_IFACE] = &vhc_usb_iface,
58 .close = on_client_close,
59 .default_handler = default_connection_handler
60};
61
62static int vhc_add_device(ddf_dev_t *dev)
63{
64 static int vhc_count = 0;
65 int rc;
66
67 /*
68 * Currently, we know how to simulate only single HC.
69 */
70 if (vhc_count > 0) {
71 return ELIMIT;
72 }
73
74 /*
75 * Create exposed function representing the host controller
76 * itself.
77 */
78 ddf_fun_t *hc = ddf_fun_create(dev, fun_exposed, "hc");
79 if (hc == NULL) {
80 usb_log_fatal("Failed to create device function.\n");
81 return ENOMEM;
82 }
83
84 hc->ops = &vhc_ops;
85
86 rc = ddf_fun_bind(hc);
87 if (rc != EOK) {
88 usb_log_fatal("Failed to bind HC function: %s.\n",
89 str_error(rc));
90 return rc;
91 }
92
93 ddf_fun_add_to_class(hc, "usbhc");
94
95 /*
96 * Initialize our hub and announce its presence.
97 */
98 virtual_hub_device_init(hc);
99
100 usb_log_info("Virtual USB host controller ready (dev %zu, hc %zu).\n",
101 (size_t) dev->handle, (size_t) hc->handle);
102
103 return EOK;
104}
105
106static driver_ops_t vhc_driver_ops = {
107 .add_device = vhc_add_device,
108};
109
110static driver_t vhc_driver = {
111 .name = NAME,
112 .driver_ops = &vhc_driver_ops
113};
114
115
116int main(int argc, char * argv[])
117{
118 /*
119 * Temporary workaround. Wait a little bit to be the last driver
120 * in devman output.
121 */
122 //sleep(5);
123
124 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
125
126 printf(NAME ": virtual USB host controller driver.\n");
127
128 /*
129 * Initialize address management.
130 */
131 address_init();
132
133 /*
134 * Run the transfer scheduler.
135 */
136 hc_manager();
137
138 /*
139 * We are also a driver within devman framework.
140 */
141 return ddf_driver_main(&vhc_driver);
142}
143
144
145/**
146 * @}
147 */
Note: See TracBrowser for help on using the repository browser.