Changeset b4b534ac in mainline for uspace/lib/usbhost/include/usb/host/usb_bus.h
- Timestamp:
- 2016-07-22T08:24:47Z (9 years ago)
- 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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/usb_bus.h
r5b18137 rb4b534ac 40 40 #define LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H 41 41 42 #include <usb/host/endpoint.h> 43 #include <usb/usb.h> 44 42 45 #include <adt/list.h> 43 46 #include <fibril_synch.h> 44 #include < usb/usb.h>47 #include <stdbool.h> 45 48 46 #include <usb/host/endpoint.h>47 49 48 50 /** Bytes per second in FULL SPEED */ … … 50 52 /** 90% of total bandwidth is available for periodic transfers */ 51 53 #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 58 typedef size_t (*bw_count_func_t)(usb_speed_t, usb_transfer_type_t, size_t, size_t); 59 typedef void (*ep_remove_callback_t)(endpoint_t *, void *); 60 typedef int (*ep_add_callback_t)(endpoint_t *, void *); 54 61 55 62 /** Endpoint management structure */ 56 typedef struct usb_endpoint_manager { 57 /** Store endpoint_t instances */ 58 list_t endpoint_lists[ENDPOINT_LIST_COUNT]; 63 typedef 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]; 59 69 /** Prevents races accessing lists */ 60 70 fibril_mutex_t guard; … … 62 72 size_t free_bw; 63 73 /** 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 66 81 67 82 size_t bandwidth_count_usb11(usb_speed_t speed, usb_transfer_type_t type, 68 83 size_t size, size_t max_packet_size); 84 size_t bandwidth_count_usb20(usb_speed_t speed, usb_transfer_type_t type, 85 size_t size, size_t max_packet_size); 69 86 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)); 87 int usb_bus_init(usb_bus_t *instance, 88 size_t available_bandwidth, bw_count_func_t bw_count, usb_speed_t max_speed); 73 89 74 void usb_endpoint_manager_reset_eps_if_need(usb_endpoint_manager_t *instance, 75 usb_target_t target, const uint8_t data[8]); 90 int usb_bus_register_ep(usb_bus_t *instance, endpoint_t *ep, size_t data_size); 76 91 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, 92 int usb_bus_unregister_ep(usb_bus_t *instance, endpoint_t *ep); 93 94 endpoint_t * usb_bus_find_ep(usb_bus_t *instance, 82 95 usb_address_t address, usb_endpoint_t ep, usb_direction_t direction); 83 96 84 int usb_ endpoint_manager_add_ep(usb_endpoint_manager_t *instance,97 int usb_bus_add_ep(usb_bus_t *instance, 85 98 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); 88 102 89 int usb_ endpoint_manager_remove_ep(usb_endpoint_manager_t *instance,103 int usb_bus_remove_ep(usb_bus_t *instance, 90 104 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); 92 106 93 void usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance, 94 usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg); 107 int usb_bus_reset_toggle(usb_bus_t *instance, usb_target_t target, bool all); 108 109 int usb_bus_remove_address(usb_bus_t *instance, 110 usb_address_t address, ep_remove_callback_t callback, void *arg); 111 112 int usb_bus_request_address(usb_bus_t *instance, 113 usb_address_t *address, bool strict, usb_speed_t speed); 114 115 int usb_bus_get_speed(usb_bus_t *instance, 116 usb_address_t address, usb_speed_t *speed); 95 117 #endif 96 118 /**
Note:
See TracChangeset
for help on using the changeset viewer.