Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 8cd1aa5e in mainline


Ignore:
Timestamp:
2010-11-21T23:22:50Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
03171de, 0b749a3
Parents:
31860b7 (diff), f0da4eb2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge ddf_proposal changes

Location:
uspace
Files:
1 added
10 edited

Legend:

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

    r31860b7 r8cd1aa5e  
    7272static int add_platform_child(device_t *parent)
    7373{
    74         return EOK;
    7574        printf(NAME ": adding new child for platform device.\n");
    7675       
  • uspace/drv/uhci/main.c

    r31860b7 r8cd1aa5e  
    7777        /*
    7878         * We need to announce the presence of our root hub.
     79         * Commented out until the problem which causes the whole task to
     80         * block is solved.
    7981         */
    80         usb_hcd_add_root_hub(device);
     82        //usb_hcd_add_root_hub(device);
    8183
    8284        return EOK;
  • uspace/drv/uhci/uhci.ma

    r31860b7 r8cd1aa5e  
    1 0 pci/ven=8086&dev=7020
     110 pci/ven=8086&dev=7020
    2210 usb&hc=uhci
    3310 usb&hc=uhci&hub
  • uspace/drv/vhc/connhost.c

    r31860b7 r8cd1aa5e  
    4141#include "hc.h"
    4242
     43typedef struct {
     44        usb_direction_t direction;
     45        usb_hcd_transfer_callback_out_t out_callback;
     46        usb_hcd_transfer_callback_in_t in_callback;
     47        usb_hc_device_t *hc;
     48        void *arg;
     49} transfer_info_t;
     50
     51static void universal_callback(void *buffer, size_t size,
     52    usb_transaction_outcome_t outcome, void *arg)
     53{
     54        transfer_info_t *transfer = (transfer_info_t *) arg;
     55
     56        switch (transfer->direction) {
     57                case USB_DIRECTION_IN:
     58                        transfer->in_callback(transfer->hc,
     59                            size, outcome,
     60                            transfer->arg);
     61                        break;
     62                case USB_DIRECTION_OUT:
     63                        transfer->out_callback(transfer->hc,
     64                            outcome,
     65                            transfer->arg);
     66                        break;
     67                default:
     68                        assert(false && "unreachable");
     69                        break;
     70        }
     71
     72        free(transfer);
     73}
     74
     75static transfer_info_t *create_transfer_info(usb_hc_device_t *hc,
     76    usb_direction_t direction, void *arg)
     77{
     78        transfer_info_t *transfer = malloc(sizeof(transfer_info_t));
     79
     80        transfer->direction = direction;
     81        transfer->in_callback = NULL;
     82        transfer->out_callback = NULL;
     83        transfer->arg = arg;
     84        transfer->hc = hc;
     85
     86        return transfer;
     87}
     88
    4389static int enqueue_transfer_out(usb_hc_device_t *hc,
    4490    usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
     
    5096            usb_str_transfer_type(endpoint->transfer_type),
    5197            size);
    52         return ENOTSUP;
     98
     99        transfer_info_t *transfer
     100            = create_transfer_info(hc, USB_DIRECTION_OUT, arg);
     101        transfer->out_callback = callback;
     102
     103        usb_target_t target = {
     104                .address = dev->address,
     105                .endpoint = endpoint->endpoint
     106        };
     107
     108        hc_add_transaction_to_device(false, target, buffer, size,
     109            universal_callback, transfer);
     110
     111        return EOK;
    53112}
    54113
     
    62121            usb_str_transfer_type(endpoint->transfer_type),
    63122            size);
    64         return ENOTSUP;
     123
     124        transfer_info_t *transfer
     125            = create_transfer_info(hc, USB_DIRECTION_OUT, arg);
     126        transfer->out_callback = callback;
     127
     128        usb_target_t target = {
     129                .address = dev->address,
     130                .endpoint = endpoint->endpoint
     131        };
     132
     133        hc_add_transaction_to_device(true, target, buffer, size,
     134            universal_callback, transfer);
     135
     136        return EOK;
    65137}
    66138
     
    74146            usb_str_transfer_type(endpoint->transfer_type),
    75147            size);
    76         return ENOTSUP;
     148
     149        transfer_info_t *transfer
     150            = create_transfer_info(hc, USB_DIRECTION_IN, arg);
     151        transfer->in_callback = callback;
     152
     153        usb_target_t target = {
     154                .address = dev->address,
     155                .endpoint = endpoint->endpoint
     156        };
     157
     158        hc_add_transaction_from_device(target, buffer, size,
     159            universal_callback, transfer);
     160
     161        return EOK;
    77162}
    78163
  • uspace/drv/vhc/hc.c

    r31860b7 r8cd1aa5e  
    131131               
    132132                process_transaction_with_outcome(transaction, outcome);
    133                
     133
    134134                free(transaction);
    135135        }
  • uspace/drv/vhc/hc.h

    r31860b7 r8cd1aa5e  
    7979    hc_transaction_done_callback_t callback, void * arg);
    8080
    81 int hc_fillin_transaction_from_device(usb_target_t target,
    82     void * buffer, size_t len);
    8381
    8482#endif
  • uspace/drv/vhc/hcd.c

    r31860b7 r8cd1aa5e  
    6969
    7070        /*
    71          * Announce that we have some root hub present.
     71         * Initialize our hub and announce its presence.
    7272         */
     73        hub_init();
    7374        usb_hcd_add_root_hub(dev);
    7475
     
    8384};
    8485
     86/** Fibril wrapper for HC transaction manager.
     87 *
     88 * @param arg Not used.
     89 * @return Nothing, return argument is unreachable.
     90 */
     91static int hc_manager_fibril(void *arg)
     92{
     93        hc_manager();
     94        return EOK;
     95}
     96
    8597int main(int argc, char * argv[])
    8698{       
    8799        printf("%s: virtual USB host controller driver.\n", NAME);
    88100
    89         debug_level = 5;
     101        debug_level = 10;
     102
     103        fid_t fid = fibril_create(hc_manager_fibril, NULL);
     104        if (fid == 0) {
     105                printf("%s: failed to start HC manager fibril\n", NAME);
     106                return ENOMEM;
     107        }
     108        fibril_add_ready(fid);
     109
     110        /*
     111         * Temporary workaround. Wait a little bit to be the last driver
     112         * in devman output.
     113         */
     114        sleep(4);
    90115
    91116        return usb_hcd_main(&vhc_driver);
  • uspace/lib/usb/Makefile

    r31860b7 r8cd1aa5e  
    3434SOURCES = \
    3535        src/hcdhubd.c \
     36        src/localdrv.c \
    3637        src/usb.c \
    3738        src/usbdrv.c
  • uspace/lib/usb/include/usb/hcdhubd.h

    r31860b7 r8cd1aa5e  
    159159    void *, size_t, size_t *, usb_handle_t *);
    160160
     161int usb_hc_async_control_write_setup(usb_hc_device_t *, usb_target_t,
     162    void *, size_t, usb_handle_t *);
     163int usb_hc_async_control_write_data(usb_hc_device_t *, usb_target_t,
     164    void *, size_t, usb_handle_t *);
     165int usb_hc_async_control_write_status(usb_hc_device_t *, usb_target_t,
     166    usb_handle_t *);
     167
     168int usb_hc_async_control_read_setup(usb_hc_device_t *, usb_target_t,
     169    void *, size_t, usb_handle_t *);
     170int usb_hc_async_control_read_data(usb_hc_device_t *, usb_target_t,
     171    void *, size_t, size_t *, usb_handle_t *);
     172int usb_hc_async_control_read_status(usb_hc_device_t *, usb_target_t,
     173    usb_handle_t *);
     174
    161175int usb_hc_async_wait_for(usb_handle_t);
    162176
  • uspace/lib/usb/src/hcdhubd.c

    r31860b7 r8cd1aa5e  
    3434 */
    3535#include <usb/hcdhubd.h>
     36#include <usb/devreq.h>
    3637#include <usbhc_iface.h>
    3738#include <driver.h>
     
    5556        .interfaces[USBHC_DEV_IFACE] = &usb_interface
    5657};
     58
     59static void set_hub_address(usb_hc_device_t *hc, usb_address_t address);
    5760
    5861/** Callback when new device is detected and must be handled by this driver.
     
    98101                return EOK;
    99102        } else {
    100                 printf("%s: hub added, hurrah!\n", hc_driver->name);
     103                usb_hc_device_t *hc = list_get_instance(hc_list.next, usb_hc_device_t, link);
     104                set_hub_address(hc, 5);
     105
    101106                /*
    102107                 * We are some (probably deeply nested) hub.
     
    104109                 * connected devices.
    105110                 */
     111
    106112                return ENOTSUP;
    107113        }
     114}
     115
     116/** Sample usage of usb_hc_async functions.
     117 * This function sets hub address using standard SET_ADDRESS request.
     118 *
     119 * @warning This function shall be removed once you are familiar with
     120 * the usb_hc_ API.
     121 *
     122 * @param hc Host controller the hub belongs to.
     123 * @param address New hub address.
     124 */
     125static void set_hub_address(usb_hc_device_t *hc, usb_address_t address)
     126{
     127        printf("%s: setting hub address to %d\n", hc->generic->name, address);
     128        usb_target_t target = {0, 0};
     129        usb_handle_t handle;
     130        int rc;
     131
     132        usb_device_request_setup_packet_t setup_packet = {
     133                .request_type = 0,
     134                .request = USB_DEVREQ_SET_ADDRESS,
     135                .index = 0,
     136                .length = 0,
     137        };
     138        setup_packet.value = address;
     139
     140        rc = usb_hc_async_control_write_setup(hc, target,
     141            &setup_packet, sizeof(setup_packet), &handle);
     142        if (rc != EOK) {
     143                return;
     144        }
     145
     146        rc = usb_hc_async_wait_for(handle);
     147        if (rc != EOK) {
     148                return;
     149        }
     150
     151        rc = usb_hc_async_control_write_status(hc, target, &handle);
     152        if (rc != EOK) {
     153                return;
     154        }
     155
     156        rc = usb_hc_async_wait_for(handle);
     157        if (rc != EOK) {
     158                return;
     159        }
     160
     161        printf("%s: hub address changed\n", hc->generic->name);
    108162}
    109163
     
    212266
    213267        /*
    214          * For testing/debugging purposes only.
    215          * Try to send some data to default USB address.
    216          */
    217         usb_target_t target = {0, 0};
    218         usb_handle_t handle = 0;
    219         char *data = (char *) "Hello, World!";
    220 
    221 
    222         (void)usb_hc_async_interrupt_out(dev, target, data, str_length(data), &handle);
    223         (void)usb_hc_async_wait_for(handle);
    224 
    225         /*
    226268         * Announce presence of child device.
    227269         */
     
    272314}
    273315
    274 /** Issue interrupt OUT transfer to HC driven by current task.
    275  *
    276  * @param hc Host controller to handle the transfer.
    277  * @param target Target device address.
    278  * @param buffer Data buffer.
    279  * @param size Buffer size.
    280  * @param handle Transfer handle.
    281  * @return Error code.
    282  */
    283 int usb_hc_async_interrupt_out(usb_hc_device_t *hc, usb_target_t target,
    284     void *buffer, size_t size,
    285     usb_handle_t *handle)
    286 {
    287         if ((hc->transfer_ops == NULL)
    288             || (hc->transfer_ops->transfer_out == NULL)) {
    289                 return ENOTSUP;
    290         }
    291 
    292         /*
    293          * For debugging purposes only.
    294          * We need to find appropriate device in list of managed device
    295          * and pass it to the transfer callback function.
    296          */
    297         usb_hcd_attached_device_info_t dev = {
    298                 .address = target.address,
    299                 .endpoint_count = 0,
    300                 .endpoints = NULL,
    301         };
    302         usb_hc_endpoint_info_t endpoint = {
    303                 .endpoint = target.endpoint,
    304                 .transfer_type = USB_TRANSFER_INTERRUPT,
    305                 .direction = USB_DIRECTION_OUT,
    306                 .data_toggle = 0
    307         };
    308 
    309         hc->transfer_ops->transfer_out(hc, &dev, &endpoint, buffer, size, NULL, NULL);
    310 
    311         *handle = (usb_handle_t)NULL;
    312 
    313         return EOK;
    314 }
    315 
    316 
    317 /** Issue interrupt IN transfer to HC driven by current task.
    318  *
    319  * @warning The @p buffer and @p actual_size parameters shall not be
    320  * touched until this transfer is waited for by usb_hc_async_wait_for().
    321  *
    322  * @param hc Host controller to handle the transfer.
    323  * @param target Target device address.
    324  * @param buffer Data buffer.
    325  * @param size Buffer size.
    326  * @param actual_size Size of actually transferred data.
    327  * @param handle Transfer handle.
    328  * @return Error code.
    329  */
    330 int usb_hc_async_interrupt_in(usb_hc_device_t *hc, usb_target_t target,
    331     void *buffer, size_t size, size_t *actual_size,
    332     usb_handle_t *handle)
    333 {
    334         /*
    335          * TODO: verify that given endpoint is of interrupt type and
    336          * call hc->transfer_ops->transfer_in()
    337          */
    338         return ENOTSUP;
    339 }
    340 
    341 /** Wait for transfer to complete.
    342  *
    343  * @param handle Transfer handle.
    344  * @return Error code.
    345  */
    346 int usb_hc_async_wait_for(usb_handle_t handle)
    347 {
    348         return ENOTSUP;
    349 }
    350 
    351316/**
    352317 * @}
Note: See TracChangeset for help on using the changeset viewer.