Changeset c4ba29c7 in mainline


Ignore:
Timestamp:
2010-11-21T22:51:16Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f62b0f
Parents:
4d31d58
Message:

Virtual host controller works again

Added correct implementation of transfer_ops, thus making VHC ready
to be used with the hcdhubd mini-framework.

Location:
uspace/drv/vhc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/connhost.c

    r4d31d58 rc4ba29c7  
    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

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

    r4d31d58 rc4ba29c7  
    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

    r4d31d58 rc4ba29c7  
    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);
    90109
    91110        return usb_hcd_main(&vhc_driver);
Note: See TracChangeset for help on using the changeset viewer.