Ignore:
Timestamp:
2012-02-18T16:47:38Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (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 mainline changes.

File:
1 edited

Legend:

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

    rbd5f3b7 r00aece0  
    3838 */
    3939#ifndef LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H
    40 #define LIBUSBHOST_HOST_YSB_ENDPOINT_MANAGER_H
     40#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;
    54         fibril_condvar_t change;
     61        /** Size of the bandwidth pool */
    5562        size_t free_bw;
     63        /** Use this function to count bw required by EP */
     64        size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t);
    5665} usb_endpoint_manager_t;
    5766
     
    6069
    6170int usb_endpoint_manager_init(usb_endpoint_manager_t *instance,
    62     size_t available_bandwidth);
     71    size_t available_bandwidth,
     72    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t));
    6373
    64 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]);
    6576
    66 int usb_endpoint_manager_register_ep(usb_endpoint_manager_t *instance,
    67     endpoint_t *ep, size_t data_size);
    68 
    69 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,
    7082    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction);
    7183
    72 endpoint_t * usb_endpoint_manager_get_ep(usb_endpoint_manager_t *instance,
    73     usb_address_t address, usb_endpoint_t ep, usb_direction_t direction,
    74     size_t *bw);
    75 
    76 void usb_endpoint_manager_reset_if_need(
    77     usb_endpoint_manager_t *instance, usb_target_t target, const uint8_t *data);
    78 
    79 static inline int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
     84int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
    8085    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    8186    usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size,
    82     size_t data_size)
    83 {
    84         endpoint_t *ep = endpoint_get(
    85             address, endpoint, direction, type, speed, max_packet_size);
    86         if (!ep)
    87                 return ENOMEM;
     87    size_t data_size, int (*callback)(endpoint_t *, void *), void *arg);
    8888
    89         const int ret =
    90             usb_endpoint_manager_register_ep(instance, ep, data_size);
    91         if (ret != EOK) {
    92                 endpoint_destroy(ep);
    93         }
    94         return ret;
    95 }
     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);
     92
     93void usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance,
     94    usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg);
    9695#endif
    9796/**
    9897 * @}
    9998 */
    100 
Note: See TracChangeset for help on using the changeset viewer.