Changeset 00aece0 in mainline for uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h
- Timestamp:
- 2012-02-18T16:47:38Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h
rbd5f3b7 r00aece0 38 38 */ 39 39 #ifndef LIBUSBHOST_HOST_USB_ENDPOINT_MANAGER_H 40 #define LIBUSBHOST_HOST_ YSB_ENDPOINT_MANAGER_H40 #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; 54 fibril_condvar_t change;61 /** Size of the bandwidth pool */ 55 62 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); 56 65 } usb_endpoint_manager_t; 57 66 … … 60 69 61 70 int 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)); 63 73 64 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]); 65 76 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, 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, 70 82 usb_address_t address, usb_endpoint_t ep, usb_direction_t direction); 71 83 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, 84 int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance, 80 85 usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction, 81 86 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); 88 88 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 } 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); 96 95 #endif 97 96 /** 98 97 * @} 99 98 */ 100
Note:
See TracChangeset
for help on using the changeset viewer.
