Ignore:
Timestamp:
2016-07-22T08:24:47Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f76d2c2
Parents:
5b18137 (diff), 8351f9a4 (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 lp:~jan.vesely/helenos/usb

File:
1 moved

Legend:

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

    r5b18137 rb4b534ac  
    4040#define LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H
    4141
     42#include <usb/host/endpoint.h>
     43#include <usb/usb.h>
     44
    4245#include <adt/list.h>
    4346#include <fibril_synch.h>
    44 #include <usb/usb.h>
     47#include <stdbool.h>
    4548
    46 #include <usb/host/endpoint.h>
    4749
    4850/** Bytes per second in FULL SPEED */
     
    5052/** 90% of total bandwidth is available for periodic transfers */
    5153#define BANDWIDTH_AVAILABLE_USB11 ((BANDWIDTH_TOTAL_USB11 / 10) * 9)
    52 /** 16 addresses per list */
    53 #define ENDPOINT_LIST_COUNT 8
     54
     55//TODO: Implement
     56#define BANDWIDTH_AVAILABLE_USB20  1
     57
     58typedef size_t (*bw_count_func_t)(usb_speed_t, usb_transfer_type_t, size_t, size_t);
     59typedef void (*ep_remove_callback_t)(endpoint_t *, void *);
     60typedef int (*ep_add_callback_t)(endpoint_t *, void *);
    5461
    5562/** Endpoint management structure */
    56 typedef struct usb_endpoint_manager {
    57         /** Store endpoint_t instances */
    58         list_t endpoint_lists[ENDPOINT_LIST_COUNT];
     63typedef struct usb_bus {
     64        struct {
     65                usb_speed_t speed;      /**< Device speed */
     66                bool occupied;          /**< The address is in use. */
     67                list_t endpoint_list;   /**< Store endpoint_t instances */
     68        } devices[USB_ADDRESS_COUNT];
    5969        /** Prevents races accessing lists */
    6070        fibril_mutex_t guard;
     
    6272        size_t free_bw;
    6373        /** 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);
    65 } usb_endpoint_manager_t;
     74        bw_count_func_t bw_count;
     75        /** Maximum speed allowed. */
     76        usb_speed_t max_speed;
     77        /** The last reserved address */
     78        usb_address_t last_address;
     79} usb_bus_t;
     80
    6681
    6782size_t bandwidth_count_usb11(usb_speed_t speed, usb_transfer_type_t type,
    6883    size_t size, size_t max_packet_size);
     84size_t bandwidth_count_usb20(usb_speed_t speed, usb_transfer_type_t type,
     85    size_t size, size_t max_packet_size);
    6986
    70 int usb_endpoint_manager_init(usb_endpoint_manager_t *instance,
    71     size_t available_bandwidth,
    72     size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t));
     87int usb_bus_init(usb_bus_t *instance,
     88    size_t available_bandwidth, bw_count_func_t bw_count, usb_speed_t max_speed);
    7389
    74 void usb_endpoint_manager_reset_eps_if_need(usb_endpoint_manager_t *instance,
    75     usb_target_t target, const uint8_t data[8]);
     90int usb_bus_register_ep(usb_bus_t *instance, endpoint_t *ep, size_t data_size);
    7691
    77 int usb_endpoint_manager_register_ep(
    78     usb_endpoint_manager_t *instance, endpoint_t *ep, size_t data_size);
    79 int usb_endpoint_manager_unregister_ep(
    80     usb_endpoint_manager_t *instance, endpoint_t *ep);
    81 endpoint_t * usb_endpoint_manager_find_ep(usb_endpoint_manager_t *instance,
     92int usb_bus_unregister_ep(usb_bus_t *instance, endpoint_t *ep);
     93
     94endpoint_t * usb_bus_find_ep(usb_bus_t *instance,
    8295    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction);
    8396
    84 int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
     97int usb_bus_add_ep(usb_bus_t *instance,
    8598    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    86     usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size,
    87     size_t data_size, int (*callback)(endpoint_t *, void *), void *arg);
     99    usb_transfer_type_t type, size_t max_packet_size, unsigned packets,
     100    size_t data_size, ep_add_callback_t callback, void *arg,
     101    usb_address_t tt_address, unsigned tt_port);
    88102
    89 int usb_endpoint_manager_remove_ep(usb_endpoint_manager_t *instance,
     103int usb_bus_remove_ep(usb_bus_t *instance,
    90104    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    91     void (*callback)(endpoint_t *, void *), void *arg);
     105    ep_remove_callback_t callback, void *arg);
    92106
    93 void usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance,
    94     usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg);
     107int usb_bus_reset_toggle(usb_bus_t *instance, usb_target_t target, bool all);
     108
     109int usb_bus_remove_address(usb_bus_t *instance,
     110    usb_address_t address, ep_remove_callback_t callback, void *arg);
     111
     112int usb_bus_request_address(usb_bus_t *instance,
     113    usb_address_t *address, bool strict, usb_speed_t speed);
     114
     115int usb_bus_get_speed(usb_bus_t *instance,
     116    usb_address_t address, usb_speed_t *speed);
    95117#endif
    96118/**
Note: See TracChangeset for help on using the changeset viewer.