Ignore:
Timestamp:
2011-03-25T17:18:46Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9a2923d
Parents:
da3dafc (diff), 095b2017 (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:

Fixes issue #122.

New allocator on not cached memory.
Only one control transfer per device as allowed

File:
1 edited

Legend:

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

    rda3dafc rb8d453ec  
    4949        assert(instance);
    5050        fibril_mutex_initialize(&instance->guard);
    51         fibril_condvar_initialize(&instance->default_address_occupied);
     51        fibril_condvar_initialize(&instance->change);
    5252        instance->last_address = 0;
    5353        unsigned i = 0;
    5454        for (; i < USB_ADDRESS_COUNT; ++i) {
    5555                instance->devices[i].occupied = false;
     56                instance->devices[i].control_used = false;
    5657                instance->devices[i].handle = 0;
    5758                instance->devices[i].toggle_status[0] = 0;
     
    7172        fibril_mutex_lock(&instance->guard);
    7273        while (instance->devices[USB_ADDRESS_DEFAULT].occupied) {
    73                 fibril_condvar_wait(&instance->default_address_occupied,
    74                     &instance->guard);
     74                fibril_condvar_wait(&instance->change, &instance->guard);
    7575        }
    7676        instance->devices[USB_ADDRESS_DEFAULT].occupied = true;
     
    9090        instance->devices[USB_ADDRESS_DEFAULT].occupied = false;
    9191        fibril_mutex_unlock(&instance->guard);
    92         fibril_condvar_signal(&instance->default_address_occupied);
     92        fibril_condvar_signal(&instance->change);
    9393}
    9494/*----------------------------------------------------------------------------*/
     
    309309        return instance->devices[address].speed;
    310310}
    311 
     311/*----------------------------------------------------------------------------*/
     312void usb_device_keeper_use_control(usb_device_keeper_t *instance,
     313    usb_address_t address)
     314{
     315        assert(instance);
     316        fibril_mutex_lock(&instance->guard);
     317        while (instance->devices[address].control_used) {
     318                fibril_condvar_wait(&instance->change, &instance->guard);
     319        }
     320        instance->devices[address].control_used = true;
     321        fibril_mutex_unlock(&instance->guard);
     322}
     323/*----------------------------------------------------------------------------*/
     324void usb_device_keeper_release_control(usb_device_keeper_t *instance,
     325    usb_address_t address)
     326{
     327        assert(instance);
     328        fibril_mutex_lock(&instance->guard);
     329        instance->devices[address].control_used = false;
     330        fibril_mutex_unlock(&instance->guard);
     331        fibril_condvar_signal(&instance->change);
     332}
    312333/**
    313334 * @}
Note: See TracChangeset for help on using the changeset viewer.