Ignore:
Timestamp:
2011-10-30T15:35:36Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
20a3465, 3ce78580
Parents:
1737bfb (diff), e978ada (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:

Merge from USB branch.

Cleanup libusbhost interfaces.
Fix few possible memory corruption/crashes and memory leaks.
Add device_remove hooks for usbflbk, usbhid.

File:
1 edited

Legend:

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

    r1737bfb r45bf63c  
    4040#define LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H
    4141
    42 #include <stdlib.h>
    43 #include <adt/hash_table.h>
     42#include <adt/list.h>
    4443#include <fibril_synch.h>
    4544#include <usb/usb.h>
     45
    4646#include <usb/host/endpoint.h>
    4747
    48 #define BANDWIDTH_TOTAL_USB11 12000000
     48/** Bytes per second in FULL SPEED */
     49#define BANDWIDTH_TOTAL_USB11 (12000000 / 8)
     50/** 90% of total bandwidth is available for periodic transfers */
    4951#define BANDWIDTH_AVAILABLE_USB11 ((BANDWIDTH_TOTAL_USB11 / 10) * 9)
     52/** 16 addresses per list */
     53#define ENDPOINT_LIST_COUNT 8
    5054
     55/** Endpoint management structure */
    5156typedef struct usb_endpoint_manager {
    52         hash_table_t ep_table;
     57        /** Store endpoint_t instances */
     58        list_t endpoint_lists[ENDPOINT_LIST_COUNT];
     59        /** Prevents races accessing lists */
    5360        fibril_mutex_t guard;
     61        /** Size of the bandwidth pool */
    5462        size_t free_bw;
     63        /** Use this function to count bw required by EP */
    5564        size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t);
    5665} usb_endpoint_manager_t;
     
    6372    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t));
    6473
    65 void usb_endpoint_manager_destroy(usb_endpoint_manager_t *instance);
     74void usb_endpoint_manager_reset_eps_if_need(usb_endpoint_manager_t *instance,
     75    usb_target_t target, const uint8_t data[8]);
    6676
    67 int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance,
    68     endpoint_t *ep, size_t data_size);
    69 
    70 int usb_endpoint_manager_unregister_ep(usb_endpoint_manager_t *instance,
     77int usb_endpoint_manager_register_ep(
     78    usb_endpoint_manager_t *instance, endpoint_t *ep, size_t data_size);
     79int usb_endpoint_manager_unregister_ep(
     80    usb_endpoint_manager_t *instance, endpoint_t *ep);
     81endpoint_t * usb_endpoint_manager_find_ep(usb_endpoint_manager_t *instance,
    7182    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction);
    7283
    73 endpoint_t * usb_endpoint_manager_get_ep(usb_endpoint_manager_t *instance,
    74     usb_address_t address, usb_endpoint_t ep, usb_direction_t direction,
    75     size_t *bw);
    76 
    77 void usb_endpoint_manager_reset_if_need(
    78     usb_endpoint_manager_t *instance, usb_target_t target, const uint8_t *data);
    79 
    80 /** Wrapper combining allocation and insertion */
    81 static inline int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
     84int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
    8285    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    8386    usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size,
    84     size_t data_size)
    85 {
    86         endpoint_t *ep = endpoint_get(
    87             address, endpoint, direction, type, speed, max_packet_size);
    88         if (!ep)
    89                 return ENOMEM;
     87    size_t data_size, int (*callback)(endpoint_t *, void *), void *arg);
    9088
    91         const int ret =
    92             usb_endpoint_manager_register_ep(instance, ep, data_size);
    93         if (ret != EOK) {
    94                 endpoint_destroy(ep);
    95         }
    96         return ret;
    97 }
     89int usb_endpoint_manager_remove_ep(usb_endpoint_manager_t *instance,
     90    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
     91    void (*callback)(endpoint_t *, void *), void *arg);
    9892#endif
    9993/**
    10094 * @}
    10195 */
    102 
Note: See TracChangeset for help on using the changeset viewer.