[c7137738] | 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 | #include <usb/hcdhubd.h>
|
---|
| 29 | #include <errno.h>
|
---|
| 30 |
|
---|
| 31 | static int enqueue_transfer_out(usb_hc_device_t *hc,
|
---|
| 32 | usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
|
---|
| 33 | void *buffer, size_t size,
|
---|
| 34 | usb_hcd_transfer_callback_out_t callback, void *arg)
|
---|
| 35 | {
|
---|
| 36 | printf("UHCI: transfer OUT [%d.%d (%s); %u]\n",
|
---|
| 37 | dev->address, endpoint->endpoint,
|
---|
| 38 | usb_str_transfer_type(endpoint->transfer_type),
|
---|
| 39 | size);
|
---|
| 40 | return ENOTSUP;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | static int enqueue_transfer_setup(usb_hc_device_t *hc,
|
---|
| 44 | usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
|
---|
| 45 | void *buffer, size_t size,
|
---|
| 46 | usb_hcd_transfer_callback_out_t callback, void *arg)
|
---|
| 47 | {
|
---|
| 48 | printf("UHCI: transfer SETUP [%d.%d (%s); %u]\n",
|
---|
| 49 | dev->address, endpoint->endpoint,
|
---|
| 50 | usb_str_transfer_type(endpoint->transfer_type),
|
---|
| 51 | size);
|
---|
| 52 | return ENOTSUP;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | static int enqueue_transfer_in(usb_hc_device_t *hc,
|
---|
| 56 | usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
|
---|
| 57 | void *buffer, size_t size,
|
---|
| 58 | usb_hcd_transfer_callback_in_t callback, void *arg)
|
---|
| 59 | {
|
---|
| 60 | printf("UHCI: transfer IN [%d.%d (%s); %u]\n",
|
---|
| 61 | dev->address, endpoint->endpoint,
|
---|
| 62 | usb_str_transfer_type(endpoint->transfer_type),
|
---|
| 63 | size);
|
---|
| 64 | return ENOTSUP;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | static usb_hcd_transfer_ops_t uhci_transfer_ops = {
|
---|
| 68 | .transfer_out = enqueue_transfer_out,
|
---|
| 69 | .transfer_in = enqueue_transfer_in,
|
---|
| 70 | .transfer_setup = enqueue_transfer_setup
|
---|
| 71 | };
|
---|
| 72 |
|
---|
| 73 | static int uhci_add_hc(usb_hc_device_t *device)
|
---|
| 74 | {
|
---|
| 75 | device->transfer_ops = &uhci_transfer_ops;
|
---|
| 76 |
|
---|
| 77 | /*
|
---|
| 78 | * We need to announce the presence of our root hub.
|
---|
| 79 | */
|
---|
| 80 | usb_hcd_add_root_hub(device);
|
---|
| 81 |
|
---|
| 82 | return EOK;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | usb_hc_driver_t uhci_driver = {
|
---|
| 86 | .name = "uhci",
|
---|
| 87 | .add_hc = uhci_add_hc
|
---|
| 88 | };
|
---|
| 89 |
|
---|
| 90 | int main(int argc, char *argv[])
|
---|
| 91 | {
|
---|
| 92 | /*
|
---|
| 93 | * Do some global initializations.
|
---|
| 94 | */
|
---|
| 95 |
|
---|
| 96 | return usb_hcd_main(&uhci_driver);
|
---|
| 97 | }
|
---|