Ignore:
Timestamp:
2011-03-07T19:08:13Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d115c8, a8e98498
Parents:
f16a76b (diff), 18e9eeb (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:

EHCI handsoff fix (it works now), refactoring, Doxygen

File:
1 edited

Legend:

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

    rf16a76b rec4538d  
    3939
    4040/*----------------------------------------------------------------------------*/
     41/** Initializes device keeper structure.
     42 *
     43 * @param[in] instance Memory place to initialize.
     44 */
    4145void device_keeper_init(device_keeper_t *instance)
    4246{
     
    5357}
    5458/*----------------------------------------------------------------------------*/
    55 void device_keeper_reserve_default(
    56     device_keeper_t *instance, usb_speed_t speed)
     59/** Attempts to obtain address 0, blocks.
     60 *
     61 * @param[in] instance Device keeper structure to use.
     62 * @param[in] speed Speed of the device requesting default address.
     63 */
     64void device_keeper_reserve_default(device_keeper_t *instance, usb_speed_t speed)
    5765{
    5866        assert(instance);
     
    6775}
    6876/*----------------------------------------------------------------------------*/
     77/** Attempts to obtain address 0, blocks.
     78 *
     79 * @param[in] instance Device keeper structure to use.
     80 * @param[in] speed Speed of the device requesting default address.
     81 */
    6982void device_keeper_release_default(device_keeper_t *instance)
    7083{
     
    7689}
    7790/*----------------------------------------------------------------------------*/
     91/** Checks setup data for signs of toggle reset.
     92 *
     93 * @param[in] instance Device keeper structure to use.
     94 * @param[in] target Device to receive setup packet.
     95 * @param[in] data Setup packet data.
     96 */
    7897void device_keeper_reset_if_need(
    7998    device_keeper_t *instance, usb_target_t target, const unsigned char *data)
     
    84103            || target.address >= USB_ADDRESS_COUNT || target.address < 0
    85104            || !instance->devices[target.address].occupied) {
    86                 goto the_end;
     105                fibril_mutex_unlock(&instance->guard);
     106                return;
    87107        }
    88108
     
    90110        {
    91111        case 0x01: /*clear feature*/
    92                 /* recipient is enpoint, value is zero (ENDPOINT_STALL) */
     112                /* recipient is endpoint, value is zero (ENDPOINT_STALL) */
    93113                if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) {
    94                         /* enpoint number is < 16, thus first byte is enough */
    95                         instance->devices[target.address].toggle_status &= ~(1 << data[4]);
     114                        /* endpoint number is < 16, thus first byte is enough */
     115                        instance->devices[target.address].toggle_status &=
     116                            ~(1 << data[4]);
    96117                }
    97118        break;
     
    102123        break;
    103124        }
    104 the_end:
    105         fibril_mutex_unlock(&instance->guard);
    106 }
    107 /*----------------------------------------------------------------------------*/
     125        fibril_mutex_unlock(&instance->guard);
     126}
     127/*----------------------------------------------------------------------------*/
     128/** Gets current value of endpoint toggle.
     129 *
     130 * @param[in] instance Device keeper structure to use.
     131 * @param[in] target Device and endpoint used.
     132 * @return Error code
     133 */
    108134int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target)
    109135{
     
    116142                ret = EINVAL;
    117143        } else {
    118                 ret = (instance->devices[target.address].toggle_status >> target.endpoint) & 1;
     144                ret =
     145                    (instance->devices[target.address].toggle_status
     146                        >> target.endpoint) & 1;
    119147        }
    120148        fibril_mutex_unlock(&instance->guard);
     
    122150}
    123151/*----------------------------------------------------------------------------*/
     152/** Sets current value of endpoint toggle.
     153 *
     154 * @param[in] instance Device keeper structure to use.
     155 * @param[in] target Device and endpoint used.
     156 * @param[in] toggle Current toggle value.
     157 * @return Error code.
     158 */
    124159int device_keeper_set_toggle(
    125160    device_keeper_t *instance, usb_target_t target, bool toggle)
     
    144179}
    145180/*----------------------------------------------------------------------------*/
     181/** Gets a free USB address
     182 *
     183 * @param[in] instance Device keeper structure to use.
     184 * @param[in] speed Speed of the device requiring address.
     185 * @return Free address, or error code.
     186 */
    146187usb_address_t device_keeper_request(
    147188    device_keeper_t *instance, usb_speed_t speed)
     
    171212}
    172213/*----------------------------------------------------------------------------*/
     214/** Binds USB address to devman handle.
     215 *
     216 * @param[in] instance Device keeper structure to use.
     217 * @param[in] address Device address
     218 * @param[in] handle Devman handle of the device.
     219 */
    173220void device_keeper_bind(
    174221    device_keeper_t *instance, usb_address_t address, devman_handle_t handle)
     
    183230}
    184231/*----------------------------------------------------------------------------*/
     232/** Releases used USB address.
     233 *
     234 * @param[in] instance Device keeper structure to use.
     235 * @param[in] address Device address
     236 */
    185237void device_keeper_release(device_keeper_t *instance, usb_address_t address)
    186238{
     
    195247}
    196248/*----------------------------------------------------------------------------*/
     249/** Finds USB address associated with the device
     250 *
     251 * @param[in] instance Device keeper structure to use.
     252 * @param[in] handle Devman handle of the device seeking its address.
     253 * @return USB Address, or error code.
     254 */
    197255usb_address_t device_keeper_find(
    198256    device_keeper_t *instance, devman_handle_t handle)
     
    212270}
    213271/*----------------------------------------------------------------------------*/
     272/** Gets speed associated with the address
     273 *
     274 * @param[in] instance Device keeper structure to use.
     275 * @param[in] address Address of the device.
     276 * @return USB speed.
     277 */
    214278usb_speed_t device_keeper_speed(
    215279    device_keeper_t *instance, usb_address_t address)
Note: See TracChangeset for help on using the changeset viewer.