Changeset 17873ac7 in mainline for uspace/lib/usbhost/include/usb


Ignore:
Timestamp:
2017-10-31T19:06:57Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
479e32d
Parents:
a312d8f
Message:

usbhost endpoint: endpoint→active replaced by tracking active batch

The mechanism is optional, synchronization over endpoint is now not forced. It will be used by xhci to utilize streams.

Location:
uspace/lib/usbhost/include/usb/host
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/bus.h

    ra312d8f r17873ac7  
    4444
    4545#include <usb/usb.h>
     46#include <usb/request.h>
    4647
    4748#include <assert.h>
     
    9798        int (*release_address)(bus_t *, usb_address_t);
    9899
    99         int (*reset_toggle)(bus_t *, usb_target_t, bool);
     100        int (*reset_toggle)(bus_t *, usb_target_t, toggle_reset_mode_t);
    100101
    101102        size_t (*count_bw) (endpoint_t *, size_t);
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    ra312d8f r17873ac7  
    5252/** Host controller side endpoint structure. */
    5353typedef struct endpoint {
     54        /** Part of linked list. */
     55        link_t link;
    5456        /** Managing bus */
    5557        bus_t *bus;
    5658        /** Reference count. */
    5759        atomic_t refcnt;
    58         /** Part of linked list. */
    59         link_t link;
    6060        /** USB device */
    6161        device_t *device;
     
    7676        /** Value of the toggle bit. */
    7777        unsigned toggle:1;
    78         /** True if there is a batch using this scheduled for this endpoint. */
    79         bool active;
     78        /** The currently active transfer batch. Write using methods, read under guard. */
     79        usb_transfer_batch_t *active_batch;
    8080        /** Protects resources and active status changes. */
    8181        fibril_mutex_t guard;
     
    9191extern void endpoint_del_ref(endpoint_t *);
    9292
    93 extern void endpoint_use(endpoint_t *);
    94 extern void endpoint_release(endpoint_t *);
     93/* Pay atention to synchronization of batch access wrt to aborting & finishing from another fibril. */
     94
     95/* Set currently active batch. The common case is to activate in the same
     96 * critical section as scheduling to HW.
     97 */
     98extern void endpoint_activate_locked(endpoint_t *, usb_transfer_batch_t *);
     99
     100/* Deactivate the endpoint, allowing others to activate it again. Batch shall
     101 * already have an error set. */
     102extern void endpoint_deactivate_locked(endpoint_t *);
     103
     104/* Abort the currenty active batch. */
     105void endpoint_abort(endpoint_t *);
    95106
    96107extern int endpoint_toggle_get(endpoint_t *);
    97 extern void endpoint_toggle_set(endpoint_t *, unsigned);
     108extern void endpoint_toggle_set(endpoint_t *, bool);
    98109
    99110/** list_get_instance wrapper.
  • uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h

    ra312d8f r17873ac7  
    4040#include <usb/request.h>
    4141
     42#include <atomic.h>
    4243#include <stddef.h>
     44#include <errno.h>
    4345#include <stdint.h>
    4446#include <usbhc_iface.h>
     
    8688        /** Size of memory pointed to by buffer member */
    8789        size_t buffer_size;
    88 
    8990        /** Actually used portion of the buffer */
    9091        size_t transfered_size;
     92
    9193        /** Indicates success/failure of the communication */
    9294        int error;
     
    106108        (batch).buffer_size, (batch).ep->max_packet_size
    107109
     110/** Wrapper for bus operation. */
     111usb_transfer_batch_t *usb_transfer_batch_create(endpoint_t *);
     112
     113/** Batch initializer. */
    108114void usb_transfer_batch_init(usb_transfer_batch_t *, endpoint_t *);
     115
     116/** Call after status is known, but before releasing endpoint */
     117int usb_transfer_batch_reset_toggle(usb_transfer_batch_t *);
     118
     119/** Batch finalization. */
     120void usb_transfer_batch_abort(usb_transfer_batch_t *);
    109121void usb_transfer_batch_finish(usb_transfer_batch_t *);
    110122
    111 usb_transfer_batch_t *usb_transfer_batch_create(endpoint_t *);
     123/** To be called from outside only when the transfer is not going to be finished
     124 * (i.o.w. until successfuly scheduling)
     125 */
    112126void usb_transfer_batch_destroy(usb_transfer_batch_t *);
    113127
Note: See TracChangeset for help on using the changeset viewer.