Changeset edb5f837 in mainline


Ignore:
Timestamp:
2011-03-06T17:38:37Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3e37964
Parents:
40a5d40
Message:

Add toggle tracking

Location:
uspace/drv/uhci-hcd/utils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/utils/device_keeper.c

    r40a5d40 redb5f837  
    4949                instance->devices[i].occupied = false;
    5050                instance->devices[i].handle = 0;
     51                instance->devices[i].toggle_status = 0;
    5152        }
    5253}
     
    7576}
    7677/*----------------------------------------------------------------------------*/
     78int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target)
     79{
     80        assert(instance);
     81        int ret;
     82        fibril_mutex_lock(&instance->guard);
     83        if (target.endpoint > 15 || target.endpoint < 0
     84            || target.address >= USB_ADDRESS_COUNT || target.address < 0
     85            || !instance->devices[target.address].occupied) {
     86                ret = EINVAL;
     87        } else {
     88                ret = (instance->devices[target.address].toggle_status >> target.endpoint) & 1;
     89        }
     90        fibril_mutex_unlock(&instance->guard);
     91        return ret;
     92}
     93/*----------------------------------------------------------------------------*/
     94int device_keeper_set_toggle(
     95    device_keeper_t *instance, usb_target_t target, bool toggle)
     96{
     97        assert(instance);
     98        int ret;
     99        fibril_mutex_lock(&instance->guard);
     100        if (target.endpoint > 15 || target.endpoint < 0
     101            || target.address >= USB_ADDRESS_COUNT || target.address < 0
     102            || !instance->devices[target.address].occupied) {
     103                ret = EINVAL;
     104        } else {
     105                if (toggle) {
     106                        instance->devices[target.address].toggle_status |= (1 << target.endpoint);
     107                } else {
     108                        instance->devices[target.address].toggle_status &= ~(1 << target.endpoint);
     109                }
     110                ret = EOK;
     111        }
     112        fibril_mutex_unlock(&instance->guard);
     113        return ret;
     114}
     115/*----------------------------------------------------------------------------*/
    77116usb_address_t device_keeper_request(
    78117    device_keeper_t *instance, usb_speed_t speed)
     
    96135        instance->devices[new_address].occupied = true;
    97136        instance->devices[new_address].speed = speed;
     137        instance->devices[new_address].toggle_status = 0;
    98138        instance->last_address = new_address;
    99139        fibril_mutex_unlock(&instance->guard);
  • uspace/drv/uhci-hcd/utils/device_keeper.h

    r40a5d40 redb5f837  
    4444        usb_speed_t speed;
    4545        bool occupied;
     46        uint16_t toggle_status;
    4647        devman_handle_t handle;
    4748};
     
    5556
    5657void device_keeper_init(device_keeper_t *instance);
     58
    5759void device_keeper_reserve_default(
    5860    device_keeper_t *instance, usb_speed_t speed);
     61
    5962void device_keeper_release_default(device_keeper_t *instance);
     63
     64int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target);
     65
     66int device_keeper_set_toggle(device_keeper_t *instance, usb_target_t target, bool toggle);
    6067
    6168usb_address_t device_keeper_request(
    6269    device_keeper_t *instance, usb_speed_t speed);
     70
    6371void device_keeper_bind(
    6472    device_keeper_t *instance, usb_address_t address, devman_handle_t handle);
     73
    6574void device_keeper_release(device_keeper_t *instance, usb_address_t address);
     75
    6676usb_address_t device_keeper_find(
    6777    device_keeper_t *instance, devman_handle_t handle);
Note: See TracChangeset for help on using the changeset viewer.