Changeset a46e56b in mainline for uspace/lib/drv/generic/remote_usbhc.c
- Timestamp:
- 2018-03-22T06:49:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77f0a1d
- Parents:
- 3e242d2
- git-author:
- Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r3e242d2 ra46e56b 232 232 static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, cap_call_handle_t, ipc_call_t *); 233 233 static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, cap_call_handle_t, ipc_call_t *); 234 static void remote_usbhc_transfer(ddf_fun_t *fun, void *iface, cap_call_handle_t c allid, ipc_call_t *call);234 static void remote_usbhc_transfer(ddf_fun_t *fun, void *iface, cap_call_handle_t chandle, ipc_call_t *call); 235 235 236 236 /** Remote USB interface operations. */ … … 257 257 258 258 void remote_usbhc_default_address_reservation(ddf_fun_t *fun, void *iface, 259 cap_call_handle_t c allid, ipc_call_t *call)259 cap_call_handle_t chandle, ipc_call_t *call) 260 260 { 261 261 const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface; 262 262 263 263 if (usbhc_iface->default_address_reservation == NULL) { 264 async_answer_0(c allid, ENOTSUP);264 async_answer_0(chandle, ENOTSUP); 265 265 return; 266 266 } … … 268 268 const bool reserve = IPC_GET_ARG2(*call); 269 269 const errno_t ret = usbhc_iface->default_address_reservation(fun, reserve); 270 async_answer_0(c allid, ret);270 async_answer_0(chandle, ret); 271 271 } 272 272 273 273 274 274 static void remote_usbhc_device_enumerate(ddf_fun_t *fun, void *iface, 275 cap_call_handle_t c allid, ipc_call_t *call)275 cap_call_handle_t chandle, ipc_call_t *call) 276 276 { 277 277 const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface; 278 278 279 279 if (usbhc_iface->device_enumerate == NULL) { 280 async_answer_0(c allid, ENOTSUP);280 async_answer_0(chandle, ENOTSUP); 281 281 return; 282 282 } … … 285 285 usb_speed_t speed = DEV_IPC_GET_ARG2(*call); 286 286 const errno_t ret = usbhc_iface->device_enumerate(fun, port, speed); 287 async_answer_0(c allid, ret);287 async_answer_0(chandle, ret); 288 288 } 289 289 290 290 static void remote_usbhc_device_remove(ddf_fun_t *fun, void *iface, 291 cap_call_handle_t c allid, ipc_call_t *call)291 cap_call_handle_t chandle, ipc_call_t *call) 292 292 { 293 293 const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface; 294 294 295 295 if (usbhc_iface->device_remove == NULL) { 296 async_answer_0(c allid, ENOTSUP);296 async_answer_0(chandle, ENOTSUP); 297 297 return; 298 298 } … … 300 300 const unsigned port = DEV_IPC_GET_ARG1(*call); 301 301 const errno_t ret = usbhc_iface->device_remove(fun, port); 302 async_answer_0(c allid, ret);302 async_answer_0(chandle, ret); 303 303 } 304 304 305 305 static void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 306 cap_call_handle_t c allid, ipc_call_t *call)306 cap_call_handle_t chandle, ipc_call_t *call) 307 307 { 308 308 assert(fun); … … 313 313 314 314 if (!usbhc_iface->register_endpoint) { 315 async_answer_0(c allid, ENOTSUP);315 async_answer_0(chandle, ENOTSUP); 316 316 return; 317 317 } 318 318 319 319 usb_endpoint_descriptors_t ep_desc; 320 cap_call_handle_t data_c allid;320 cap_call_handle_t data_chandle; 321 321 size_t len; 322 322 323 if (!async_data_write_receive(&data_c allid, &len)323 if (!async_data_write_receive(&data_chandle, &len) 324 324 || len != sizeof(ep_desc)) { 325 async_answer_0(c allid, EINVAL);326 return; 327 } 328 async_data_write_finalize(data_c allid, &ep_desc, sizeof(ep_desc));325 async_answer_0(chandle, EINVAL); 326 return; 327 } 328 async_data_write_finalize(data_chandle, &ep_desc, sizeof(ep_desc)); 329 329 330 330 usb_pipe_desc_t pipe_desc; 331 331 332 332 const errno_t rc = usbhc_iface->register_endpoint(fun, &pipe_desc, &ep_desc); 333 async_answer_0(c allid, rc);334 335 if (!async_data_read_receive(&data_c allid, &len)333 async_answer_0(chandle, rc); 334 335 if (!async_data_read_receive(&data_chandle, &len) 336 336 || len != sizeof(pipe_desc)) { 337 337 return; 338 338 } 339 async_data_read_finalize(data_c allid, &pipe_desc, sizeof(pipe_desc));339 async_data_read_finalize(data_chandle, &pipe_desc, sizeof(pipe_desc)); 340 340 } 341 341 342 342 static void remote_usbhc_unregister_endpoint(ddf_fun_t *fun, void *iface, 343 cap_call_handle_t c allid, ipc_call_t *call)343 cap_call_handle_t chandle, ipc_call_t *call) 344 344 { 345 345 assert(fun); … … 350 350 351 351 if (!usbhc_iface->unregister_endpoint) { 352 async_answer_0(c allid, ENOTSUP);352 async_answer_0(chandle, ENOTSUP); 353 353 return; 354 354 } 355 355 356 356 usb_pipe_desc_t pipe_desc; 357 cap_call_handle_t data_c allid;357 cap_call_handle_t data_chandle; 358 358 size_t len; 359 359 360 if (!async_data_write_receive(&data_c allid, &len)360 if (!async_data_write_receive(&data_chandle, &len) 361 361 || len != sizeof(pipe_desc)) { 362 async_answer_0(c allid, EINVAL);363 return; 364 } 365 async_data_write_finalize(data_c allid, &pipe_desc, sizeof(pipe_desc));362 async_answer_0(chandle, EINVAL); 363 return; 364 } 365 async_data_write_finalize(data_chandle, &pipe_desc, sizeof(pipe_desc)); 366 366 367 367 const errno_t rc = usbhc_iface->unregister_endpoint(fun, &pipe_desc); 368 async_answer_0(c allid, rc);368 async_answer_0(chandle, rc); 369 369 } 370 370 … … 410 410 411 411 errno_t err; 412 cap_call_handle_t data_c allid;412 cap_call_handle_t data_chandle; 413 413 size_t size; 414 414 unsigned flags; 415 415 416 if (!async_share_out_receive(&data_c allid, &size, &flags))416 if (!async_share_out_receive(&data_chandle, &size, &flags)) 417 417 return EPARTY; 418 418 419 419 if (size < required_size || (flags & required_flags) != required_flags) { 420 async_answer_0(data_c allid, EINVAL);420 async_answer_0(data_chandle, EINVAL); 421 421 return EINVAL; 422 422 } 423 423 424 if ((err = async_share_out_finalize(data_c allid, &trans->request.buffer.virt)))424 if ((err = async_share_out_finalize(data_chandle, &trans->request.buffer.virt))) 425 425 return err; 426 426 … … 445 445 } 446 446 447 void remote_usbhc_transfer(ddf_fun_t *fun, void *iface, cap_call_handle_t c allid, ipc_call_t *call)447 void remote_usbhc_transfer(ddf_fun_t *fun, void *iface, cap_call_handle_t chandle, ipc_call_t *call) 448 448 { 449 449 assert(fun); … … 454 454 455 455 if (!usbhc_iface->transfer) { 456 async_answer_0(c allid, ENOTSUP);457 return; 458 } 459 460 async_transaction_t *trans = async_transaction_create(c allid);456 async_answer_0(chandle, ENOTSUP); 457 return; 458 } 459 460 async_transaction_t *trans = async_transaction_create(chandle); 461 461 if (trans == NULL) { 462 async_answer_0(c allid, ENOMEM);462 async_answer_0(chandle, ENOMEM); 463 463 return; 464 464 } … … 466 466 errno_t err = EPARTY; 467 467 468 cap_call_handle_t data_c allid;468 cap_call_handle_t data_chandle; 469 469 size_t len; 470 if (!async_data_write_receive(&data_c allid, &len)470 if (!async_data_write_receive(&data_chandle, &len) 471 471 || len != sizeof(trans->request)) { 472 async_answer_0(data_c allid, EINVAL);472 async_answer_0(data_chandle, EINVAL); 473 473 goto err; 474 474 } 475 475 476 if ((err = async_data_write_finalize(data_c allid,476 if ((err = async_data_write_finalize(data_chandle, 477 477 &trans->request, sizeof(trans->request)))) 478 478 goto err; … … 494 494 495 495 err: 496 async_answer_0(c allid, err);496 async_answer_0(chandle, err); 497 497 async_transaction_destroy(trans); 498 498 }
Note:
See TracChangeset
for help on using the changeset viewer.