Changeset ec4538d in mainline for uspace/drv/uhci-hcd/utils/device_keeper.c
- Timestamp:
- 2011-03-07T19:08:13Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1d115c8, a8e98498
- Parents:
- f16a76b (diff), 18e9eeb (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/drv/uhci-hcd/utils/device_keeper.c
rf16a76b rec4538d 39 39 40 40 /*----------------------------------------------------------------------------*/ 41 /** Initializes device keeper structure. 42 * 43 * @param[in] instance Memory place to initialize. 44 */ 41 45 void device_keeper_init(device_keeper_t *instance) 42 46 { … … 53 57 } 54 58 /*----------------------------------------------------------------------------*/ 55 void device_keeper_reserve_default( 56 device_keeper_t *instance, usb_speed_t speed) 59 /** Attempts to obtain address 0, blocks. 60 * 61 * @param[in] instance Device keeper structure to use. 62 * @param[in] speed Speed of the device requesting default address. 63 */ 64 void device_keeper_reserve_default(device_keeper_t *instance, usb_speed_t speed) 57 65 { 58 66 assert(instance); … … 67 75 } 68 76 /*----------------------------------------------------------------------------*/ 77 /** Attempts to obtain address 0, blocks. 78 * 79 * @param[in] instance Device keeper structure to use. 80 * @param[in] speed Speed of the device requesting default address. 81 */ 69 82 void device_keeper_release_default(device_keeper_t *instance) 70 83 { … … 76 89 } 77 90 /*----------------------------------------------------------------------------*/ 91 /** Checks setup data for signs of toggle reset. 92 * 93 * @param[in] instance Device keeper structure to use. 94 * @param[in] target Device to receive setup packet. 95 * @param[in] data Setup packet data. 96 */ 78 97 void device_keeper_reset_if_need( 79 98 device_keeper_t *instance, usb_target_t target, const unsigned char *data) … … 84 103 || target.address >= USB_ADDRESS_COUNT || target.address < 0 85 104 || !instance->devices[target.address].occupied) { 86 goto the_end; 105 fibril_mutex_unlock(&instance->guard); 106 return; 87 107 } 88 108 … … 90 110 { 91 111 case 0x01: /*clear feature*/ 92 /* recipient is en point, value is zero (ENDPOINT_STALL) */112 /* recipient is endpoint, value is zero (ENDPOINT_STALL) */ 93 113 if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) { 94 /* enpoint number is < 16, thus first byte is enough */ 95 instance->devices[target.address].toggle_status &= ~(1 << data[4]); 114 /* endpoint number is < 16, thus first byte is enough */ 115 instance->devices[target.address].toggle_status &= 116 ~(1 << data[4]); 96 117 } 97 118 break; … … 102 123 break; 103 124 } 104 the_end: 105 fibril_mutex_unlock(&instance->guard); 106 } 107 /*----------------------------------------------------------------------------*/ 125 fibril_mutex_unlock(&instance->guard); 126 } 127 /*----------------------------------------------------------------------------*/ 128 /** Gets current value of endpoint toggle. 129 * 130 * @param[in] instance Device keeper structure to use. 131 * @param[in] target Device and endpoint used. 132 * @return Error code 133 */ 108 134 int device_keeper_get_toggle(device_keeper_t *instance, usb_target_t target) 109 135 { … … 116 142 ret = EINVAL; 117 143 } else { 118 ret = (instance->devices[target.address].toggle_status >> target.endpoint) & 1; 144 ret = 145 (instance->devices[target.address].toggle_status 146 >> target.endpoint) & 1; 119 147 } 120 148 fibril_mutex_unlock(&instance->guard); … … 122 150 } 123 151 /*----------------------------------------------------------------------------*/ 152 /** Sets current value of endpoint toggle. 153 * 154 * @param[in] instance Device keeper structure to use. 155 * @param[in] target Device and endpoint used. 156 * @param[in] toggle Current toggle value. 157 * @return Error code. 158 */ 124 159 int device_keeper_set_toggle( 125 160 device_keeper_t *instance, usb_target_t target, bool toggle) … … 144 179 } 145 180 /*----------------------------------------------------------------------------*/ 181 /** Gets a free USB address 182 * 183 * @param[in] instance Device keeper structure to use. 184 * @param[in] speed Speed of the device requiring address. 185 * @return Free address, or error code. 186 */ 146 187 usb_address_t device_keeper_request( 147 188 device_keeper_t *instance, usb_speed_t speed) … … 171 212 } 172 213 /*----------------------------------------------------------------------------*/ 214 /** Binds USB address to devman handle. 215 * 216 * @param[in] instance Device keeper structure to use. 217 * @param[in] address Device address 218 * @param[in] handle Devman handle of the device. 219 */ 173 220 void device_keeper_bind( 174 221 device_keeper_t *instance, usb_address_t address, devman_handle_t handle) … … 183 230 } 184 231 /*----------------------------------------------------------------------------*/ 232 /** Releases used USB address. 233 * 234 * @param[in] instance Device keeper structure to use. 235 * @param[in] address Device address 236 */ 185 237 void device_keeper_release(device_keeper_t *instance, usb_address_t address) 186 238 { … … 195 247 } 196 248 /*----------------------------------------------------------------------------*/ 249 /** Finds USB address associated with the device 250 * 251 * @param[in] instance Device keeper structure to use. 252 * @param[in] handle Devman handle of the device seeking its address. 253 * @return USB Address, or error code. 254 */ 197 255 usb_address_t device_keeper_find( 198 256 device_keeper_t *instance, devman_handle_t handle) … … 212 270 } 213 271 /*----------------------------------------------------------------------------*/ 272 /** Gets speed associated with the address 273 * 274 * @param[in] instance Device keeper structure to use. 275 * @param[in] address Address of the device. 276 * @return USB speed. 277 */ 214 278 usb_speed_t device_keeper_speed( 215 279 device_keeper_t *instance, usb_address_t address)
Note:
See TracChangeset
for help on using the changeset viewer.