Changeset 00aece0 in mainline for uspace/lib/usb/include/usb/hc.h
- Timestamp:
- 2012-02-18T16:47:38Z (13 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
-
TabularUnified uspace/lib/usb/include/usb/hc.h ¶
rbd5f3b7 r00aece0 1 1 /* 2 2 * Copyright (c) 2011 Vojtech Horky 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 26 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28 */ 28 29 29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * General communication with host controller driver.33 * General communication with host controller. 34 34 */ 35 35 #ifndef LIBUSB_HC_H_ 36 36 #define LIBUSB_HC_H_ 37 37 38 #include <sys/types.h> 39 #include <ipc/devman.h> 40 #include <ipc/loc.h> 38 #include <async.h> 39 #include <devman.h> 41 40 #include <ddf/driver.h> 42 41 #include <bool.h> 43 #include < async.h>42 #include <fibril_synch.h> 44 43 #include <usb/usb.h> 45 44 46 /** Connection to the host controller driver. */ 45 /** Connection to the host controller driver. 46 * 47 * This is a high level IPC communication wrapper. After the structure has been 48 * initialized using devman handle of an USB host controller, it 49 * will manage all communication to that host controller, including session 50 * creation/destruction and proper IPC protocol. 51 */ 47 52 typedef struct { 48 53 /** Devman handle of the host controller. */ … … 50 55 /** Session to the host controller. */ 51 56 async_sess_t *hc_sess; 57 /** Session guard. */ 58 fibril_mutex_t guard; 59 /** Use counter. */ 60 unsigned ref_count; 52 61 } usb_hc_connection_t; 53 62 63 /** Initialize connection to USB host controller. 64 * 65 * @param connection Connection to be initialized. 66 * @param hc_handle Devman handle of the host controller. 67 * @return Error code. 68 */ 69 static inline void usb_hc_connection_initialize(usb_hc_connection_t *connection, 70 devman_handle_t hc_handle) 71 { 72 assert(connection); 73 connection->hc_handle = hc_handle; 74 connection->hc_sess = NULL; 75 connection->ref_count = 0; 76 fibril_mutex_initialize(&connection->guard); 77 } 78 54 79 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *, 55 ddf_dev_t *); 56 int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t); 80 const ddf_dev_t *); 81 82 void usb_hc_connection_deinitialize(usb_hc_connection_t *); 57 83 58 84 int usb_hc_connection_open(usb_hc_connection_t *); 59 bool usb_hc_connection_is_opened(const usb_hc_connection_t *);60 85 int usb_hc_connection_close(usb_hc_connection_t *); 86 87 usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_address_t, bool, 88 usb_speed_t); 89 int usb_hc_bind_address(usb_hc_connection_t *, usb_address_t, devman_handle_t); 61 90 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t, 62 91 devman_handle_t *); 92 int usb_hc_release_address(usb_hc_connection_t *, usb_address_t); 63 93 64 int usb_hc_get_address_by_handle(devman_handle_t); 94 int usb_hc_register_endpoint(usb_hc_connection_t *, usb_address_t, 95 usb_endpoint_t, usb_transfer_type_t, usb_direction_t, size_t, unsigned int); 96 int usb_hc_unregister_endpoint(usb_hc_connection_t *, usb_address_t, 97 usb_endpoint_t, usb_direction_t); 65 98 66 int usb_hc_find(devman_handle_t, devman_handle_t *); 99 int usb_hc_read(usb_hc_connection_t *, usb_address_t, usb_endpoint_t, 100 uint64_t, void *, size_t, size_t *); 101 int usb_hc_write(usb_hc_connection_t *, usb_address_t, usb_endpoint_t, 102 uint64_t, const void *, size_t); 67 103 68 int usb_resolve_device_handle(const char *, devman_handle_t *, usb_address_t *, 69 devman_handle_t *); 70 71 int usb_ddf_get_hc_handle_by_sid(service_id_t, devman_handle_t *); 72 104 /** Get host controller handle by its class index. 105 * 106 * @param sid Service ID of the HC function. 107 * @param hc_handle Where to store the HC handle 108 * (can be NULL for existence test only). 109 * @return Error code. 110 */ 111 static inline int usb_ddf_get_hc_handle_by_sid( 112 service_id_t sid, devman_handle_t *handle) 113 { 114 devman_handle_t h; 115 return devman_fun_sid_to_handle(sid, handle ? handle : &h); 116 } 73 117 74 118 #endif
Note:
See TracChangeset
for help on using the changeset viewer.