Changeset 01eeaaf in mainline for uspace/drv/bus/usb/vhc/connhost.c
- Timestamp:
- 2012-12-22T15:07:29Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f6577d9
- Parents:
- 94c40ce2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/vhc/connhost.c
r94c40ce2 r01eeaaf 158 158 return rc; 159 159 } 160 #if 0 161 /** Schedule interrupt out transfer. 162 * 163 * The callback is supposed to be called once the transfer (on the wire) is 164 * complete regardless of the outcome. 165 * However, the callback could be called only when this function returns 166 * with success status (i.e. returns EOK). 167 * 168 * @param[in] fun Device function the action was invoked on. 169 * @param[in] target Target pipe (address and endpoint number) specification. 170 * @param[in] data Data to be sent (in USB endianess, allocated and deallocated 171 * by the caller). 172 * @param[in] size Size of the @p data buffer in bytes. 173 * @param[in] callback Callback to be issued once the transfer is complete. 174 * @param[in] arg Pass-through argument to the callback. 175 * @return Error code. 176 */ 177 static int interrupt_out(ddf_fun_t *fun, usb_target_t target, 178 void *data, size_t size, 179 usbhc_iface_transfer_out_callback_t callback, void *arg) 180 { 181 VHC_DATA(vhc, fun); 182 183 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 184 target.endpoint, USB_DIRECTION_OUT, USB_TRANSFER_INTERRUPT, 185 fun, arg); 186 if (transfer == NULL) { 187 return ENOMEM; 188 } 189 190 transfer->data_buffer = data; 191 transfer->data_buffer_size = size; 192 transfer->callback_out = callback; 193 194 int rc = vhc_virtdev_add_transfer(vhc, transfer); 195 if (rc != EOK) { 196 free(transfer); 197 return rc; 198 } 199 200 return EOK; 201 } 202 203 /** Schedule interrupt in transfer. 204 * 205 * The callback is supposed to be called once the transfer (on the wire) is 206 * complete regardless of the outcome. 207 * However, the callback could be called only when this function returns 208 * with success status (i.e. returns EOK). 209 * 210 * @param[in] fun Device function the action was invoked on. 211 * @param[in] target Target pipe (address and endpoint number) specification. 212 * @param[in] data Buffer where to store the data (in USB endianess, 213 * allocated and deallocated by the caller). 214 * @param[in] size Size of the @p data buffer in bytes. 215 * @param[in] callback Callback to be issued once the transfer is complete. 216 * @param[in] arg Pass-through argument to the callback. 217 * @return Error code. 218 */ 219 static int interrupt_in(ddf_fun_t *fun, usb_target_t target, 220 void *data, size_t size, 221 usbhc_iface_transfer_in_callback_t callback, void *arg) 222 { 223 VHC_DATA(vhc, fun); 224 225 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 226 target.endpoint, USB_DIRECTION_IN, USB_TRANSFER_INTERRUPT, 227 fun, arg); 228 if (transfer == NULL) { 229 return ENOMEM; 230 } 231 232 transfer->data_buffer = data; 233 transfer->data_buffer_size = size; 234 transfer->callback_in = callback; 235 236 int rc = vhc_virtdev_add_transfer(vhc, transfer); 237 if (rc != EOK) { 238 free(transfer); 239 return rc; 240 } 241 242 return EOK; 243 } 244 245 /** Schedule bulk out transfer. 246 * 247 * The callback is supposed to be called once the transfer (on the wire) is 248 * complete regardless of the outcome. 249 * However, the callback could be called only when this function returns 250 * with success status (i.e. returns EOK). 251 * 252 * @param[in] fun Device function the action was invoked on. 253 * @param[in] target Target pipe (address and endpoint number) specification. 254 * @param[in] data Data to be sent (in USB endianess, allocated and deallocated 255 * by the caller). 256 * @param[in] size Size of the @p data buffer in bytes. 257 * @param[in] callback Callback to be issued once the transfer is complete. 258 * @param[in] arg Pass-through argument to the callback. 259 * @return Error code. 260 */ 261 static int bulk_out(ddf_fun_t *fun, usb_target_t target, 262 void *data, size_t size, 263 usbhc_iface_transfer_out_callback_t callback, void *arg) 264 { 265 UNSUPPORTED("bulk_out"); 266 267 return ENOTSUP; 268 } 269 270 /** Schedule bulk in transfer. 271 * 272 * The callback is supposed to be called once the transfer (on the wire) is 273 * complete regardless of the outcome. 274 * However, the callback could be called only when this function returns 275 * with success status (i.e. returns EOK). 276 * 277 * @param[in] fun Device function the action was invoked on. 278 * @param[in] target Target pipe (address and endpoint number) specification. 279 * @param[in] data Buffer where to store the data (in USB endianess, 280 * allocated and deallocated by the caller). 281 * @param[in] size Size of the @p data buffer in bytes. 282 * @param[in] callback Callback to be issued once the transfer is complete. 283 * @param[in] arg Pass-through argument to the callback. 284 * @return Error code. 285 */ 286 static int bulk_in(ddf_fun_t *fun, usb_target_t target, 287 void *data, size_t size, 288 usbhc_iface_transfer_in_callback_t callback, void *arg) 289 { 290 UNSUPPORTED("bulk_in"); 291 292 return ENOTSUP; 293 } 294 295 /** Schedule control write transfer. 296 * 297 * The callback is supposed to be called once the transfer (on the wire) is 298 * complete regardless of the outcome. 299 * However, the callback could be called only when this function returns 300 * with success status (i.e. returns EOK). 301 * 302 * @param[in] fun Device function the action was invoked on. 303 * @param[in] target Target pipe (address and endpoint number) specification. 304 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated 305 * and deallocated by the caller). 306 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes. 307 * @param[in] data_buffer Data buffer (in USB endianess, allocated and 308 * deallocated by the caller). 309 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes. 310 * @param[in] callback Callback to be issued once the transfer is complete. 311 * @param[in] arg Pass-through argument to the callback. 312 * @return Error code. 313 */ 314 static int control_write(ddf_fun_t *fun, usb_target_t target, 315 void *setup_packet, size_t setup_packet_size, 316 void *data_buffer, size_t data_buffer_size, 317 usbhc_iface_transfer_out_callback_t callback, void *arg) 318 { 319 VHC_DATA(vhc, fun); 320 321 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 322 target.endpoint, USB_DIRECTION_OUT, USB_TRANSFER_CONTROL, 323 fun, arg); 324 if (transfer == NULL) { 325 return ENOMEM; 326 } 327 328 transfer->setup_buffer = setup_packet; 329 transfer->setup_buffer_size = setup_packet_size; 330 transfer->data_buffer = data_buffer; 331 transfer->data_buffer_size = data_buffer_size; 332 transfer->callback_out = callback; 333 334 int rc = vhc_virtdev_add_transfer(vhc, transfer); 335 if (rc != EOK) { 336 free(transfer); 337 return rc; 338 } 339 340 return EOK; 341 } 342 343 /** Schedule control read transfer. 344 * 345 * The callback is supposed to be called once the transfer (on the wire) is 346 * complete regardless of the outcome. 347 * However, the callback could be called only when this function returns 348 * with success status (i.e. returns EOK). 349 * 350 * @param[in] fun Device function the action was invoked on. 351 * @param[in] target Target pipe (address and endpoint number) specification. 352 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated 353 * and deallocated by the caller). 354 * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes. 355 * @param[in] data_buffer Buffer where to store the data (in USB endianess, 356 * allocated and deallocated by the caller). 357 * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes. 358 * @param[in] callback Callback to be issued once the transfer is complete. 359 * @param[in] arg Pass-through argument to the callback. 360 * @return Error code. 361 */ 362 static int control_read(ddf_fun_t *fun, usb_target_t target, 363 void *setup_packet, size_t setup_packet_size, 364 void *data_buffer, size_t data_buffer_size, 365 usbhc_iface_transfer_in_callback_t callback, void *arg) 366 { 367 VHC_DATA(vhc, fun); 368 369 vhc_transfer_t *transfer = vhc_transfer_create(target.address, 370 target.endpoint, USB_DIRECTION_IN, USB_TRANSFER_CONTROL, 371 fun, arg); 372 if (transfer == NULL) { 373 return ENOMEM; 374 } 375 376 transfer->setup_buffer = setup_packet; 377 transfer->setup_buffer_size = setup_packet_size; 378 transfer->data_buffer = data_buffer; 379 transfer->data_buffer_size = data_buffer_size; 380 transfer->callback_in = callback; 381 382 int rc = vhc_virtdev_add_transfer(vhc, transfer); 383 if (rc != EOK) { 384 free(transfer); 385 return rc; 386 } 387 388 return EOK; 389 } 390 #endif 160 391 161 static int usb_read(ddf_fun_t *fun, usb_target_t target, uint64_t setup_buffer, 392 162 uint8_t *data_buffer, size_t data_buffer_size,
Note:
See TracChangeset
for help on using the changeset viewer.