Changes in uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h [933b0d7:46f2808] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h
r933b0d7 r46f2808 40 40 #define LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H 41 41 42 #include <stdlib.h> 43 #include <adt/hash_table.h> 42 #include <adt/list.h> 44 43 #include <fibril_synch.h> 45 44 #include <usb/usb.h> 45 46 46 #include <usb/host/endpoint.h> 47 47 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 */ 49 51 #define BANDWIDTH_AVAILABLE_USB11 ((BANDWIDTH_TOTAL_USB11 / 10) * 9) 52 /** 16 addresses per list */ 53 #define ENDPOINT_LIST_COUNT 8 50 54 55 /** Endpoint management structure */ 51 56 typedef 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 */ 53 60 fibril_mutex_t guard; 61 /** Size of the bandwidth pool */ 54 62 size_t free_bw; 63 /** Use this function to count bw required by EP */ 55 64 size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t); 56 65 } usb_endpoint_manager_t; … … 63 72 size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t)); 64 73 65 void usb_endpoint_manager_destroy(usb_endpoint_manager_t *instance); 74 void usb_endpoint_manager_reset_eps_if_need(usb_endpoint_manager_t *instance, 75 usb_target_t target, const uint8_t data[8]); 66 76 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, 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, 71 82 usb_address_t address, usb_endpoint_t ep, usb_direction_t direction); 72 83 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, 84 int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance, 82 85 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction, 83 86 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); 90 88 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 } 89 int 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 93 void usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance, 94 usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg); 98 95 #endif 99 96 /** 100 97 * @} 101 98 */ 102
Note:
See TracChangeset
for help on using the changeset viewer.