Changeset 82122f3 in mainline for uspace/drv/vhc/hc.c


Ignore:
Timestamp:
2010-12-17T14:51:41Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1f383dde
Parents:
692f13e4 (diff), 11658b64 (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:

Merged development into lelian/hidd

File:
1 edited

Legend:

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

    r692f13e4 r82122f3  
    5050#include "hub.h"
    5151
    52 #define USLEEP_BASE (500 * 1000)
    53 
    54 #define USLEEP_VAR 5000
     52#define USLEEP_BASE (0 * 5 * 1000)
     53
     54#define USLEEP_VAR 50
    5555
    5656#define SHORTENING_VAR 15
     
    6868static link_t transaction_list;
    6969
    70 #define TRANSACTION_FORMAT "T[%d:%d %s (%d)]"
     70#define TRANSACTION_FORMAT "T[%d.%d %s/%s (%d)]"
    7171#define TRANSACTION_PRINTF(t) \
    7272        (t).target.address, (t).target.endpoint, \
     73        usb_str_transfer_type((t).transfer_type), \
    7374        usbvirt_str_transaction_type((t).type), \
    7475        (int)(t).len
     
    7778        list_get_instance(lnk, transaction_t, link)
    7879
     80#define HUB_STATUS_MAX_LEN (HUB_PORT_COUNT + 64)
     81
    7982static inline unsigned int pseudo_random(unsigned int *seed)
    8083{
     
    8992    usb_transaction_outcome_t outcome)
    9093{
    91         dprintf(3, "processing transaction " TRANSACTION_FORMAT ", outcome: %s",
     94        dprintf(3, "transaction " TRANSACTION_FORMAT " done, outcome: %s",
    9295            TRANSACTION_PRINTF(*transaction),
    9396            usb_str_transaction_outcome(outcome));
     
    99102/** Host controller manager main function.
    100103 */
    101 void hc_manager(void)
     104static int hc_manager_fibril(void *arg)
    102105{
    103106        list_initialize(&transaction_list);
     
    114117                }
    115118               
    116                 char ports[HUB_PORT_COUNT + 2];
    117                 hub_get_port_statuses(ports, HUB_PORT_COUNT + 1);
    118                 dprintf(3, "virtual hub: addr=%d ports=%s",
    119                     virthub_dev.address, ports);
     119                char ports[HUB_STATUS_MAX_LEN + 1];
     120                virthub_get_status(&virtual_hub_device, ports, HUB_STATUS_MAX_LEN);
    120121               
    121122                link_t *first_transaction_link = transaction_list.next;
     
    124125                list_remove(first_transaction_link);
    125126               
     127
     128                dprintf(0, "about to process " TRANSACTION_FORMAT " [%s]",
     129                    TRANSACTION_PRINTF(*transaction), ports);
     130
    126131                dprintf(3, "processing transaction " TRANSACTION_FORMAT "",
    127132                    TRANSACTION_PRINTF(*transaction));
     
    134139                free(transaction);
    135140        }
     141
     142        assert(false && "unreachable");
     143        return EOK;
     144}
     145
     146void hc_manager(void)
     147{
     148        fid_t fid = fibril_create(hc_manager_fibril, NULL);
     149        if (fid == 0) {
     150                printf(NAME ": failed to start HC manager fibril\n");
     151                return;
     152        }
     153        fibril_add_ready(fid);
    136154}
    137155
     
    139157 */
    140158static transaction_t *transaction_create(usbvirt_transaction_type_t type,
    141     usb_target_t target,
     159    usb_target_t target, usb_transfer_type_t transfer_type,
    142160    void * buffer, size_t len,
    143161    hc_transaction_done_callback_t callback, void * arg)
     
    147165        list_initialize(&transaction->link);
    148166        transaction->type = type;
     167        transaction->transfer_type = transfer_type;
    149168        transaction->target = target;
    150169        transaction->buffer = buffer;
     
    153172        transaction->callback_arg = arg;
    154173       
    155         dprintf(1, "creating transaction " TRANSACTION_FORMAT,
     174        dprintf(3, "creating transaction " TRANSACTION_FORMAT,
    156175            TRANSACTION_PRINTF(*transaction));
    157176       
     
    162181 */
    163182void hc_add_transaction_to_device(bool setup, usb_target_t target,
     183    usb_transfer_type_t transfer_type,
    164184    void * buffer, size_t len,
    165185    hc_transaction_done_callback_t callback, void * arg)
    166186{
    167187        transaction_t *transaction = transaction_create(
    168             setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT, target,
     188            setup ? USBVIRT_TRANSACTION_SETUP : USBVIRT_TRANSACTION_OUT,
     189            target, transfer_type,
    169190            buffer, len, callback, arg);
    170191        list_append(&transaction->link, &transaction_list);
     
    174195 */
    175196void hc_add_transaction_from_device(usb_target_t target,
     197    usb_transfer_type_t transfer_type,
    176198    void * buffer, size_t len,
    177199    hc_transaction_done_callback_t callback, void * arg)
    178200{
    179201        transaction_t *transaction = transaction_create(USBVIRT_TRANSACTION_IN,
    180             target, buffer, len, callback, arg);
     202            target, transfer_type,
     203            buffer, len, callback, arg);
    181204        list_append(&transaction->link, &transaction_list);
    182205}
Note: See TracChangeset for help on using the changeset viewer.