Changeset 984a9ba in mainline for uspace/srv/devman/drv_conn.c
- Timestamp:
- 2018-07-05T09:34:09Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/drv_conn.c
r76f566d r984a9ba 64 64 65 65 /** Register running driver. */ 66 static driver_t *devman_driver_register( cap_call_handle_t chandle,ipc_call_t *call)66 static driver_t *devman_driver_register(ipc_call_t *call) 67 67 { 68 68 driver_t *driver = NULL; … … 74 74 errno_t rc = async_data_write_accept((void **) &drv_name, true, 0, 0, 0, 0); 75 75 if (rc != EOK) { 76 async_answer_0(c handle, rc);76 async_answer_0(call, rc); 77 77 return NULL; 78 78 } … … 87 87 free(drv_name); 88 88 drv_name = NULL; 89 async_answer_0(c handle, ENOENT);89 async_answer_0(call, ENOENT); 90 90 return NULL; 91 91 } … … 101 101 driver->name); 102 102 fibril_mutex_unlock(&driver->driver_mutex); 103 async_answer_0(c handle, EEXIST);103 async_answer_0(call, EEXIST); 104 104 return NULL; 105 105 } … … 126 126 if (!driver->sess) { 127 127 fibril_mutex_unlock(&driver->driver_mutex); 128 async_answer_0(c handle, ENOTSUP);128 async_answer_0(call, ENOTSUP); 129 129 return NULL; 130 130 } … … 146 146 "for driver `%s'.", driver->name); 147 147 fibril_mutex_unlock(&driver->driver_mutex); 148 async_answer_0(c handle, ENOMEM);148 async_answer_0(call, ENOMEM); 149 149 return NULL; 150 150 } … … 153 153 fibril_mutex_unlock(&driver->driver_mutex); 154 154 155 async_answer_0(c handle, EOK);155 async_answer_0(call, EOK); 156 156 return driver; 157 157 } … … 166 166 { 167 167 match_id_t *match_id = create_match_id(); 168 cap_call_handle_t chandle;169 168 ipc_call_t call; 170 169 errno_t rc = 0; 171 170 172 chandle =async_get_call(&call);171 async_get_call(&call); 173 172 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 174 173 log_msg(LOG_DEFAULT, LVL_ERROR, 175 174 "Invalid protocol when trying to receive match id."); 176 async_answer_0( chandle, EINVAL);175 async_answer_0(&call, EINVAL); 177 176 delete_match_id(match_id); 178 177 return EINVAL; … … 181 180 if (match_id == NULL) { 182 181 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to allocate match id."); 183 async_answer_0( chandle, ENOMEM);182 async_answer_0(&call, ENOMEM); 184 183 return ENOMEM; 185 184 } 186 185 187 async_answer_0( chandle, EOK);186 async_answer_0(&call, EOK); 188 187 189 188 match_id->score = IPC_GET_ARG1(call); … … 230 229 * Child devices are registered by their parent's device driver. 231 230 */ 232 static void devman_add_function( cap_call_handle_t chandle,ipc_call_t *call)231 static void devman_add_function(ipc_call_t *call) 233 232 { 234 233 fun_type_t ftype = (fun_type_t) IPC_GET_ARG1(*call); … … 239 238 dev_node_t *pdev = find_dev_node(&device_tree, dev_handle); 240 239 if (pdev == NULL) { 241 async_answer_0(c handle, ENOENT);240 async_answer_0(call, ENOENT); 242 241 return; 243 242 } … … 250 249 251 250 dev_del_ref(pdev); 252 async_answer_0(c handle, EINVAL);251 async_answer_0(call, EINVAL); 253 252 return; 254 253 } 255 254 256 255 char *fun_name = NULL; 257 errno_t rc = async_data_write_accept((void **) &fun_name, true, 0, 0, 0, 0);256 errno_t rc = async_data_write_accept((void **) &fun_name, true, 0, 0, 0, 0); 258 257 if (rc != EOK) { 259 258 dev_del_ref(pdev); 260 async_answer_0(c handle, rc);259 async_answer_0(call, rc); 261 260 return; 262 261 } … … 268 267 fibril_rwlock_write_unlock(&tree->rwlock); 269 268 dev_del_ref(pdev); 270 async_answer_0(c handle, ENOENT);269 async_answer_0(call, ENOENT); 271 270 return; 272 271 } … … 278 277 fibril_rwlock_write_unlock(&tree->rwlock); 279 278 dev_del_ref(pdev); 280 async_answer_0(c handle, EEXIST);279 async_answer_0(call, EEXIST); 281 280 printf(NAME ": Warning, driver tried to register `%s' twice.\n", 282 281 fun_name); … … 303 302 fun_del_ref(fun); 304 303 delete_fun_node(fun); 305 async_answer_0(c handle, ENOMEM);304 async_answer_0(call, ENOMEM); 306 305 return; 307 306 } … … 317 316 fun_busy_unlock(fun); 318 317 fun_del_ref(fun); 319 async_answer_0(c handle, rc);318 async_answer_0(call, rc); 320 319 return; 321 320 } … … 325 324 326 325 /* Return device handle to parent's driver. */ 327 async_answer_1(c handle, EOK, fun->handle);328 } 329 330 static void devman_add_function_to_cat( cap_call_handle_t chandle,ipc_call_t *call)326 async_answer_1(call, EOK, fun->handle); 327 } 328 329 static void devman_add_function_to_cat(ipc_call_t *call) 331 330 { 332 331 devman_handle_t handle = IPC_GET_ARG1(*call); … … 339 338 0, 0, 0, 0); 340 339 if (rc != EOK) { 341 async_answer_0(c handle, rc);340 async_answer_0(call, rc); 342 341 return; 343 342 } … … 345 344 fun_node_t *fun = find_fun_node(&device_tree, handle); 346 345 if (fun == NULL) { 347 async_answer_0(c handle, ENOENT);346 async_answer_0(call, ENOENT); 348 347 return; 349 348 } … … 354 353 if (fun->state == FUN_REMOVED) { 355 354 fibril_rwlock_read_unlock(&device_tree.rwlock); 356 async_answer_0(c handle, ENOENT);355 async_answer_0(call, ENOENT); 357 356 return; 358 357 } … … 371 370 fun_del_ref(fun); 372 371 373 async_answer_0(c handle, rc);372 async_answer_0(call, rc); 374 373 } 375 374 … … 377 376 * 378 377 */ 379 static void devman_drv_fun_online(cap_call_handle_t icall_handle, ipc_call_t *icall, 380 driver_t *drv) 378 static void devman_drv_fun_online(ipc_call_t *icall, driver_t *drv) 381 379 { 382 380 fun_node_t *fun; … … 387 385 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 388 386 if (fun == NULL) { 389 async_answer_0(icall _handle, ENOENT);387 async_answer_0(icall, ENOENT); 390 388 return; 391 389 } … … 398 396 fun_busy_unlock(fun); 399 397 fun_del_ref(fun); 400 async_answer_0(icall _handle, ENOENT);398 async_answer_0(icall, ENOENT); 401 399 return; 402 400 } … … 407 405 fun_busy_unlock(fun); 408 406 fun_del_ref(fun); 409 async_answer_0(icall _handle, rc);407 async_answer_0(icall, rc); 410 408 return; 411 409 } … … 414 412 fun_del_ref(fun); 415 413 416 async_answer_0(icall _handle, EOK);414 async_answer_0(icall, EOK); 417 415 } 418 416 … … 421 419 * 422 420 */ 423 static void devman_drv_fun_offline(cap_call_handle_t icall_handle, ipc_call_t *icall, 424 driver_t *drv) 421 static void devman_drv_fun_offline(ipc_call_t *icall, driver_t *drv) 425 422 { 426 423 fun_node_t *fun; … … 429 426 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 430 427 if (fun == NULL) { 431 async_answer_0(icall _handle, ENOENT);428 async_answer_0(icall, ENOENT); 432 429 return; 433 430 } … … 439 436 fun_busy_unlock(fun); 440 437 fun_del_ref(fun); 441 async_answer_0(icall _handle, ENOENT);438 async_answer_0(icall, ENOENT); 442 439 return; 443 440 } … … 448 445 fun_busy_unlock(fun); 449 446 fun_del_ref(fun); 450 async_answer_0(icall _handle, rc);447 async_answer_0(icall, rc); 451 448 return; 452 449 } … … 454 451 fun_busy_unlock(fun); 455 452 fun_del_ref(fun); 456 async_answer_0(icall _handle, EOK);453 async_answer_0(icall, EOK); 457 454 } 458 455 459 456 /** Remove function. */ 460 static void devman_remove_function( cap_call_handle_t chandle,ipc_call_t *call)457 static void devman_remove_function(ipc_call_t *call) 461 458 { 462 459 devman_handle_t fun_handle = IPC_GET_ARG1(*call); … … 466 463 fun_node_t *fun = find_fun_node(&device_tree, fun_handle); 467 464 if (fun == NULL) { 468 async_answer_0(c handle, ENOENT);465 async_answer_0(call, ENOENT); 469 466 return; 470 467 } … … 481 478 fun_busy_unlock(fun); 482 479 fun_del_ref(fun); 483 async_answer_0(c handle, ENOENT);480 async_answer_0(call, ENOENT); 484 481 return; 485 482 } … … 523 520 fun_busy_unlock(fun); 524 521 fun_del_ref(fun); 525 async_answer_0(c handle, gone_rc);522 async_answer_0(call, gone_rc); 526 523 return; 527 524 } … … 551 548 fun_busy_unlock(fun); 552 549 fun_del_ref(fun); 553 async_answer_0(c handle, EIO);550 async_answer_0(call, EIO); 554 551 return; 555 552 } … … 567 564 568 565 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_remove_function() succeeded."); 569 async_answer_0(c handle, EOK);566 async_answer_0(call, EOK); 570 567 } 571 568 … … 586 583 587 584 /** Function for handling connections from a driver to the device manager. */ 588 void devman_connection_driver( cap_call_handle_t icall_handle,ipc_call_t *icall, void *arg)585 void devman_connection_driver(ipc_call_t *icall, void *arg) 589 586 { 590 587 client_t *client; … … 592 589 593 590 /* Accept the connection. */ 594 async_answer_0(icall _handle, EOK);591 async_answer_0(icall, EOK); 595 592 596 593 client = async_get_client_data(); … … 602 599 while (true) { 603 600 ipc_call_t call; 604 cap_call_handle_t chandle =async_get_call(&call);601 async_get_call(&call); 605 602 606 603 if (!IPC_GET_IMETHOD(call)) … … 613 610 if (driver == NULL) { 614 611 /* First call must be to DEVMAN_DRIVER_REGISTER */ 615 async_answer_0( chandle, ENOTSUP);612 async_answer_0(&call, ENOTSUP); 616 613 continue; 617 614 } … … 623 620 if (client->driver != NULL) { 624 621 fibril_mutex_unlock(&client->mutex); 625 async_answer_0( chandle, EINVAL);622 async_answer_0(&call, EINVAL); 626 623 continue; 627 624 } 628 client->driver = devman_driver_register( chandle,&call);625 client->driver = devman_driver_register(&call); 629 626 fibril_mutex_unlock(&client->mutex); 630 627 break; 631 628 case DEVMAN_ADD_FUNCTION: 632 devman_add_function( chandle,&call);629 devman_add_function(&call); 633 630 break; 634 631 case DEVMAN_ADD_DEVICE_TO_CATEGORY: 635 devman_add_function_to_cat( chandle,&call);632 devman_add_function_to_cat(&call); 636 633 break; 637 634 case DEVMAN_DRV_FUN_ONLINE: 638 devman_drv_fun_online( chandle,&call, driver);635 devman_drv_fun_online(&call, driver); 639 636 break; 640 637 case DEVMAN_DRV_FUN_OFFLINE: 641 devman_drv_fun_offline( chandle,&call, driver);638 devman_drv_fun_offline(&call, driver); 642 639 break; 643 640 case DEVMAN_REMOVE_FUNCTION: 644 devman_remove_function( chandle,&call);641 devman_remove_function(&call); 645 642 break; 646 643 default: 647 async_answer_0( chandle, EINVAL);644 async_answer_0(&call, EINVAL); 648 645 break; 649 646 }
Note:
See TracChangeset
for help on using the changeset viewer.