Changeset 9a7e5b4 in mainline for uspace/lib/usb/src


Ignore:
Timestamp:
2011-04-07T08:19:03Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41c1f7b
Parents:
dcaf819 (diff), 506d330 (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:

More OHCI structures and refactoring. Add per endpoint toggle reset

Location:
uspace/lib/usb/src/host
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/host/device_keeper.c

    rdcaf819 r9a7e5b4  
    128128                /* recipient is endpoint, value is zero (ENDPOINT_STALL) */
    129129                if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) {
     130                        while (current !=
     131                           &instance->devices[target.address].endpoints)
     132                        {
    130133                        /* endpoint number is < 16, thus first byte is enough */
    131                         assert(!"NOT IMPLEMENTED!");
     134                                endpoint_toggle_reset_filtered(
     135                                    current, data[4]);
     136                                current = current->next;
     137                        }
    132138                }
    133139        break;
  • uspace/lib/usb/src/host/endpoint.c

    rdcaf819 r9a7e5b4  
    3737#include <usb/host/endpoint.h>
    3838
    39 int endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type,
    40     usb_speed_t speed, size_t max_packet_size)
     39int endpoint_init(endpoint_t *instance, usb_address_t address,
     40    usb_endpoint_t endpoint, usb_direction_t direction,
     41    usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size)
    4142{
    4243        assert(instance);
    43         link_initialize(&instance->same_device_eps);
    44         instance->transfer_type = transfer_type;
     44        instance->address = address;
     45        instance->endpoint = endpoint;
     46        instance->direction = direction;
     47        instance->transfer_type = type;
    4548        instance->speed = speed;
    4649        instance->max_packet_size = max_packet_size;
    4750        instance->toggle = 0;
     51        link_initialize(&instance->same_device_eps);
    4852        return EOK;
    4953}
     
    7680        instance->toggle = 0;
    7781}
     82/*----------------------------------------------------------------------------*/
     83void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn)
     84{
     85        endpoint_t *instance =
     86            list_get_instance(ep, endpoint_t, same_device_eps);
     87        assert(instance);
     88        if (instance->endpoint == epn)
     89                instance->toggle = 0;
     90}
    7891/**
    7992 * @}
  • uspace/lib/usb/src/host/usb_endpoint_manager.c

    rdcaf819 r9a7e5b4  
    3535#define BUCKET_COUNT 7
    3636
    37 typedef struct {
    38         usb_address_t address;
    39         usb_endpoint_t endpoint;
    40         usb_direction_t direction;
    41 } __attribute__((aligned (sizeof(unsigned long)))) id_t;
    42 #define MAX_KEYS (sizeof(id_t) / sizeof(unsigned long))
     37#define MAX_KEYS (3)
    4338typedef struct {
    44         union {
    45                 id_t id;
    46                 unsigned long key[MAX_KEYS];
    47         };
    4839        link_t link;
    4940        size_t bw;
     
    6657        assert(item);
    6758        node_t *node = hash_table_get_instance(item, node_t, link);
    68         hash_count_t i = 0;
    69         for (; i < keys; ++i) {
    70                 if (key[i] != node->key[i])
    71                         return false;
    72         }
    73         return true;
     59        assert(node);
     60        assert(node->ep);
     61        bool match = true;
     62        switch (keys) {
     63        case 3:
     64                match = match && (key[2] == node->ep->direction);
     65        case 2:
     66                match = match && (key[1] == (unsigned long)node->ep->endpoint);
     67        case 1:
     68                match = match && (key[0] == (unsigned long)node->ep->address);
     69                break;
     70        default:
     71                match = false;
     72        }
     73        return match;
    7474}
    7575/*----------------------------------------------------------------------------*/
     
    142142/*----------------------------------------------------------------------------*/
    143143int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance,
    144     usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    145144    endpoint_t *ep, size_t data_size)
    146145{
     
    150149        assert(instance);
    151150
    152         id_t id = {
    153                 .address = address,
    154                 .endpoint = endpoint,
    155                 .direction = direction,
    156         };
     151        unsigned long key[MAX_KEYS] =
     152            {ep->address, ep->endpoint, ep->direction};
    157153        fibril_mutex_lock(&instance->guard);
    158154
    159155        link_t *item =
    160             hash_table_find(&instance->ep_table, (unsigned long*)&id);
     156            hash_table_find(&instance->ep_table, key);
    161157        if (item != NULL) {
    162158                fibril_mutex_unlock(&instance->guard);
     
    175171        }
    176172
    177         node->id = id;
    178173        node->bw = bw;
    179174        node->ep = ep;
    180175        link_initialize(&node->link);
    181176
    182         hash_table_insert(&instance->ep_table,
    183             (unsigned long*)&id, &node->link);
     177        hash_table_insert(&instance->ep_table, key, &node->link);
    184178        instance->free_bw -= bw;
    185179        fibril_mutex_unlock(&instance->guard);
     
    192186{
    193187        assert(instance);
    194         id_t id = {
    195                 .address = address,
    196                 .endpoint = endpoint,
    197                 .direction = direction,
    198         };
     188        unsigned long key[MAX_KEYS] = {address, endpoint, direction};
     189
    199190        fibril_mutex_lock(&instance->guard);
    200         link_t *item =
    201             hash_table_find(&instance->ep_table, (unsigned long*)&id);
     191        link_t *item = hash_table_find(&instance->ep_table, key);
    202192        if (item == NULL) {
    203193                fibril_mutex_unlock(&instance->guard);
     
    207197        node_t *node = hash_table_get_instance(item, node_t, link);
    208198        instance->free_bw += node->bw;
    209         hash_table_remove(&instance->ep_table, (unsigned long*)&id, MAX_KEYS);
     199        hash_table_remove(&instance->ep_table, key, MAX_KEYS);
    210200
    211201        fibril_mutex_unlock(&instance->guard);
     
    219209{
    220210        assert(instance);
    221         id_t id = {
    222                 .address = address,
    223                 .endpoint = endpoint,
    224                 .direction = direction,
    225         };
     211        unsigned long key[MAX_KEYS] = {address, endpoint, direction};
     212
    226213        fibril_mutex_lock(&instance->guard);
    227         link_t *item =
    228             hash_table_find(&instance->ep_table, (unsigned long*)&id);
     214        link_t *item = hash_table_find(&instance->ep_table, key);
    229215        if (item == NULL) {
    230216                fibril_mutex_unlock(&instance->guard);
Note: See TracChangeset for help on using the changeset viewer.