Changeset 7034be15 in mainline


Ignore:
Timestamp:
2010-11-19T23:00:31Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e27595b
Parents:
91db50ac
Message:

Various changes to HC driver framework API

Also, the root driver only registers VHC as its only child to clean-up
debug output from devman.

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/root/root.c

    r91db50ac r7034be15  
    7272static int add_platform_child(device_t *parent)
    7373{
     74        return EOK;
    7475        printf(NAME ": adding new child for platform device.\n");
    7576       
  • uspace/drv/vhc/hcd.c

    r91db50ac r7034be15  
    6666
    6767        dev->transfer_ops = &vhc_transfer_ops;
    68         /* Fail because of bug in libusb that caused devman to hang. */
    69         return ENOTSUP;
     68
     69        /*
     70         * Announce that we have some root hub present.
     71         */
     72        usb_hcd_add_root_hub(dev);
     73
     74        return EOK;
    7075}
    7176
     
    7782int main(int argc, char * argv[])
    7883{       
    79         /*
    80          * For debugging purpose to enable viewing the output
    81          * within devman tty.
    82          */
    83         sleep(5);
    84 
    8584        printf("%s: virtual USB host controller driver.\n", NAME);
    8685
  • uspace/lib/usb/hcdhubd.c

    r91db50ac r7034be15  
    3434 */
    3535#include "hcdhubd.h"
     36#include <usb_iface.h>
    3637#include <driver.h>
    3738#include <bool.h>
     
    4445static usb_hc_driver_t *hc_driver = NULL;
    4546
     47static usb_iface_t usb_interface = {
     48        .interrupt_out = NULL,
     49        .interrupt_in = NULL
     50};
     51
     52static device_ops_t usb_device_ops = {
     53        .interfaces[USB_DEV_IFACE] = &usb_interface
     54};
     55
    4656/** Callback when new device is detected and must be handled by this driver.
    4757 *
     
    6373                usb_hc_device_t *hc_dev = malloc(sizeof(usb_hc_device_t));
    6474                list_initialize(&hc_dev->link);
     75                hc_dev->transfer_ops = NULL;
    6576
    6677                hc_dev->generic = dev;
     
    7182                }
    7283
    73                 add_device_to_class(dev, "usbhc");
     84                /*
     85                 * Finish initialization of dev and hc_dev structures.
     86                 */
     87                hc_dev->generic->driver_data = hc_dev;
     88                dev->ops = &usb_device_ops;
     89
     90                /*
     91                 * FIXME: The following line causes devman to hang.
     92                 * Will investigate later why.
     93                 */
     94                // add_device_to_class(dev, "usbhc");
    7495
    7596                list_append(&hc_dev->link, &hc_list);
     
    128149                         * FIXME: check returned value for possible errors
    129150                         */
    130                         usb_hcd_local_transfer_interrupt_in(hc, target,
     151                        usb_hc_async_interrupt_in(hc, target,
    131152                            change_bitmap, byte_length, &actual_size,
    132153                            &handle);
    133154
    134                         usb_hcd_local_wait_for(handle);
     155                        usb_hc_async_wait_for(handle);
    135156
    136157                        /*
     
    187208int usb_hcd_add_root_hub(usb_hc_device_t *dev)
    188209{
     210        int rc;
     211
     212        /*
     213         * For testing/debugging purposes only.
     214         * Try to send some data to default USB address.
     215         */
     216        usb_target_t target = {0, 0};
     217        usb_handle_t handle = 0;
     218        char *data = (char *) "Hello, World!";
     219
     220
     221        (void)usb_hc_async_interrupt_out(dev, target, data, str_length(data), &handle);
     222        (void)usb_hc_async_wait_for(handle);
     223
    189224        /*
    190225         * Announce presence of child device.
     
    192227        device_t *hub = NULL;
    193228        match_id_t *match_id = NULL;
    194         int rc;
    195229
    196230        hub = create_device();
     
    215249
    216250        match_id->id = id;
    217         match_id->score = 10;
     251        match_id->score = 30;
    218252
    219253        add_match_id(&hub->match_ids, match_id);
     
    224258        }
    225259
     260        printf("%s: registered root hub\n", dev->generic->name);
    226261        return EOK;
    227262
     
    236271}
    237272
     273/** Issue interrupt OUT transfer to HC driven by current task.
     274 *
     275 * @param hc Host controller to handle the transfer.
     276 * @param target Target device address.
     277 * @param buffer Data buffer.
     278 * @param size Buffer size.
     279 * @param handle Transfer handle.
     280 * @return Error code.
     281 */
     282int usb_hc_async_interrupt_out(usb_hc_device_t *hc, usb_target_t target,
     283    void *buffer, size_t size,
     284    usb_handle_t *handle)
     285{
     286        if ((hc->transfer_ops == NULL)
     287            || (hc->transfer_ops->transfer_out == NULL)) {
     288                return ENOTSUP;
     289        }
     290
     291        /*
     292         * For debugging purposes only.
     293         * We need to find appropriate device in list of managed device
     294         * and pass it to the transfer callback function.
     295         */
     296        usb_hcd_attached_device_info_t dev = {
     297                .address = target.address,
     298                .endpoint_count = 0,
     299                .endpoints = NULL,
     300        };
     301        usb_hc_endpoint_info_t endpoint = {
     302                .endpoint = target.endpoint,
     303                .transfer_type = USB_TRANSFER_INTERRUPT,
     304                .direction = USB_DIRECTION_OUT,
     305                .data_toggle = 0
     306        };
     307
     308        hc->transfer_ops->transfer_out(hc, &dev, &endpoint, buffer, size, NULL, NULL);
     309
     310        *handle = NULL;
     311
     312        return EOK;
     313}
     314
    238315
    239316/** Issue interrupt IN transfer to HC driven by current task.
    240317 *
    241318 * @warning The @p buffer and @p actual_size parameters shall not be
    242  * touched until this transfer is waited for by usb_hcd_local_wait_for().
     319 * touched until this transfer is waited for by usb_hc_async_wait_for().
    243320 *
    244321 * @param hc Host controller to handle the transfer.
     
    250327 * @return Error code.
    251328 */
    252 int usb_hcd_local_transfer_interrupt_in(usb_hc_device_t *hc,
    253     usb_target_t target, void *buffer, size_t size, size_t *actual_size,
     329int usb_hc_async_interrupt_in(usb_hc_device_t *hc, usb_target_t target,
     330    void *buffer, size_t size, size_t *actual_size,
    254331    usb_handle_t *handle)
    255332{
     
    266343 * @return Error code.
    267344 */
    268 int usb_hcd_local_wait_for(usb_handle_t handle)
     345int usb_hc_async_wait_for(usb_handle_t handle)
    269346{
    270347        return ENOTSUP;
  • uspace/lib/usb/hcdhubd.h

    r91db50ac r7034be15  
    8080/** Callback for OUT transfers. */
    8181typedef void (*usb_hcd_transfer_callback_out_t)
    82     (usb_hc_device_t *, usb_hcd_attached_device_info_t *,
    83     usb_hc_endpoint_info_t *,
    84     usb_transaction_outcome_t, void *);
     82    (usb_hc_device_t *, usb_transaction_outcome_t, void *);
    8583
    8684/** Callback for IN transfers. */
    8785typedef void (*usb_hcd_transfer_callback_in_t)
    88     (usb_hc_device_t *, usb_hcd_attached_device_info_t *,
    89     usb_hc_endpoint_info_t *,
    90     size_t, usb_transaction_outcome_t, void *);
     86    (usb_hc_device_t *, size_t, usb_transaction_outcome_t, void *);
    9187
    9288
     
    158154 */
    159155
    160 int usb_hcd_local_set_endpoint_properties(usb_hc_device_t *, usb_target_t,
    161     usb_transfer_type_t, usb_direction_t);
    162156
    163 /* First variant - repeat transfer type. */
    164 int usb_hcd_local_transfer_interrupt_in(usb_hc_device_t *, usb_target_t,
     157int usb_hc_async_interrupt_out(usb_hc_device_t *, usb_target_t,
     158    void *, size_t, usb_handle_t *);
     159int usb_hc_async_interrupt_in(usb_hc_device_t *, usb_target_t,
    165160    void *, size_t, size_t *, usb_handle_t *);
    166161
    167 /* Second variant - determine transfer type from endpoint properties. */
    168 int usb_hcd_local_transfer_in(usb_hc_device_t *, usb_target_t,
    169     void *, size_t, size_t *, usb_handle_t *);
    170 
    171 
    172 int usb_hcd_local_wait_for(usb_handle_t);
     162int usb_hc_async_wait_for(usb_handle_t);
    173163
    174164
Note: See TracChangeset for help on using the changeset viewer.