Changeset a46e56b in mainline for uspace/srv/devman/drv_conn.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/srv/devman/drv_conn.c
r3e242d2 ra46e56b 64 64 65 65 /** Register running driver. */ 66 static driver_t *devman_driver_register(cap_call_handle_t c allid, ipc_call_t *call)66 static driver_t *devman_driver_register(cap_call_handle_t chandle, 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 allid, rc);76 async_answer_0(chandle, rc); 77 77 return NULL; 78 78 } … … 87 87 free(drv_name); 88 88 drv_name = NULL; 89 async_answer_0(c allid, ENOENT);89 async_answer_0(chandle, ENOENT); 90 90 return NULL; 91 91 } … … 101 101 driver->name); 102 102 fibril_mutex_unlock(&driver->driver_mutex); 103 async_answer_0(c allid, EEXIST);103 async_answer_0(chandle, 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 allid, ENOTSUP);128 async_answer_0(chandle, 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 allid, ENOMEM);148 async_answer_0(chandle, ENOMEM); 149 149 return NULL; 150 150 } … … 153 153 fibril_mutex_unlock(&driver->driver_mutex); 154 154 155 async_answer_0(c allid, EOK);155 async_answer_0(chandle, EOK); 156 156 return driver; 157 157 } … … 166 166 { 167 167 match_id_t *match_id = create_match_id(); 168 cap_call_handle_t c allid;168 cap_call_handle_t chandle; 169 169 ipc_call_t call; 170 170 errno_t rc = 0; 171 171 172 c allid= async_get_call(&call);172 chandle = async_get_call(&call); 173 173 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 174 174 log_msg(LOG_DEFAULT, LVL_ERROR, 175 175 "Invalid protocol when trying to receive match id."); 176 async_answer_0(c allid, EINVAL);176 async_answer_0(chandle, EINVAL); 177 177 delete_match_id(match_id); 178 178 return EINVAL; … … 181 181 if (match_id == NULL) { 182 182 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed to allocate match id."); 183 async_answer_0(c allid, ENOMEM);183 async_answer_0(chandle, ENOMEM); 184 184 return ENOMEM; 185 185 } 186 186 187 async_answer_0(c allid, EOK);187 async_answer_0(chandle, EOK); 188 188 189 189 match_id->score = IPC_GET_ARG1(call); … … 230 230 * Child devices are registered by their parent's device driver. 231 231 */ 232 static void devman_add_function(cap_call_handle_t c allid, ipc_call_t *call)232 static void devman_add_function(cap_call_handle_t chandle, ipc_call_t *call) 233 233 { 234 234 fun_type_t ftype = (fun_type_t) IPC_GET_ARG1(*call); … … 239 239 dev_node_t *pdev = find_dev_node(&device_tree, dev_handle); 240 240 if (pdev == NULL) { 241 async_answer_0(c allid, ENOENT);241 async_answer_0(chandle, ENOENT); 242 242 return; 243 243 } … … 250 250 251 251 dev_del_ref(pdev); 252 async_answer_0(c allid, EINVAL);252 async_answer_0(chandle, EINVAL); 253 253 return; 254 254 } … … 258 258 if (rc != EOK) { 259 259 dev_del_ref(pdev); 260 async_answer_0(c allid, rc);260 async_answer_0(chandle, rc); 261 261 return; 262 262 } … … 268 268 fibril_rwlock_write_unlock(&tree->rwlock); 269 269 dev_del_ref(pdev); 270 async_answer_0(c allid, ENOENT);270 async_answer_0(chandle, ENOENT); 271 271 return; 272 272 } … … 278 278 fibril_rwlock_write_unlock(&tree->rwlock); 279 279 dev_del_ref(pdev); 280 async_answer_0(c allid, EEXIST);280 async_answer_0(chandle, EEXIST); 281 281 printf(NAME ": Warning, driver tried to register `%s' twice.\n", 282 282 fun_name); … … 303 303 fun_del_ref(fun); 304 304 delete_fun_node(fun); 305 async_answer_0(c allid, ENOMEM);305 async_answer_0(chandle, ENOMEM); 306 306 return; 307 307 } … … 317 317 fun_busy_unlock(fun); 318 318 fun_del_ref(fun); 319 async_answer_0(c allid, rc);319 async_answer_0(chandle, rc); 320 320 return; 321 321 } … … 325 325 326 326 /* Return device handle to parent's driver. */ 327 async_answer_1(c allid, EOK, fun->handle);328 } 329 330 static void devman_add_function_to_cat(cap_call_handle_t c allid, ipc_call_t *call)327 async_answer_1(chandle, EOK, fun->handle); 328 } 329 330 static void devman_add_function_to_cat(cap_call_handle_t chandle, ipc_call_t *call) 331 331 { 332 332 devman_handle_t handle = IPC_GET_ARG1(*call); … … 339 339 0, 0, 0, 0); 340 340 if (rc != EOK) { 341 async_answer_0(c allid, rc);341 async_answer_0(chandle, rc); 342 342 return; 343 343 } … … 345 345 fun_node_t *fun = find_fun_node(&device_tree, handle); 346 346 if (fun == NULL) { 347 async_answer_0(c allid, ENOENT);347 async_answer_0(chandle, ENOENT); 348 348 return; 349 349 } … … 354 354 if (fun->state == FUN_REMOVED) { 355 355 fibril_rwlock_read_unlock(&device_tree.rwlock); 356 async_answer_0(c allid, ENOENT);356 async_answer_0(chandle, ENOENT); 357 357 return; 358 358 } … … 371 371 fun_del_ref(fun); 372 372 373 async_answer_0(c allid, rc);373 async_answer_0(chandle, rc); 374 374 } 375 375 … … 377 377 * 378 378 */ 379 static void devman_drv_fun_online(cap_call_handle_t i id, ipc_call_t *icall,379 static void devman_drv_fun_online(cap_call_handle_t icall_handle, ipc_call_t *icall, 380 380 driver_t *drv) 381 381 { … … 387 387 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 388 388 if (fun == NULL) { 389 async_answer_0(i id, ENOENT);389 async_answer_0(icall_handle, ENOENT); 390 390 return; 391 391 } … … 398 398 fun_busy_unlock(fun); 399 399 fun_del_ref(fun); 400 async_answer_0(i id, ENOENT);400 async_answer_0(icall_handle, ENOENT); 401 401 return; 402 402 } … … 407 407 fun_busy_unlock(fun); 408 408 fun_del_ref(fun); 409 async_answer_0(i id, rc);409 async_answer_0(icall_handle, rc); 410 410 return; 411 411 } … … 414 414 fun_del_ref(fun); 415 415 416 async_answer_0(i id, EOK);416 async_answer_0(icall_handle, EOK); 417 417 } 418 418 … … 421 421 * 422 422 */ 423 static void devman_drv_fun_offline(cap_call_handle_t i id, ipc_call_t *icall,423 static void devman_drv_fun_offline(cap_call_handle_t icall_handle, ipc_call_t *icall, 424 424 driver_t *drv) 425 425 { … … 429 429 fun = find_fun_node(&device_tree, IPC_GET_ARG1(*icall)); 430 430 if (fun == NULL) { 431 async_answer_0(i id, ENOENT);431 async_answer_0(icall_handle, ENOENT); 432 432 return; 433 433 } … … 439 439 fun_busy_unlock(fun); 440 440 fun_del_ref(fun); 441 async_answer_0(i id, ENOENT);441 async_answer_0(icall_handle, ENOENT); 442 442 return; 443 443 } … … 448 448 fun_busy_unlock(fun); 449 449 fun_del_ref(fun); 450 async_answer_0(i id, rc);450 async_answer_0(icall_handle, rc); 451 451 return; 452 452 } … … 454 454 fun_busy_unlock(fun); 455 455 fun_del_ref(fun); 456 async_answer_0(i id, EOK);456 async_answer_0(icall_handle, EOK); 457 457 } 458 458 459 459 /** Remove function. */ 460 static void devman_remove_function(cap_call_handle_t c allid, ipc_call_t *call)460 static void devman_remove_function(cap_call_handle_t chandle, ipc_call_t *call) 461 461 { 462 462 devman_handle_t fun_handle = IPC_GET_ARG1(*call); … … 466 466 fun_node_t *fun = find_fun_node(&device_tree, fun_handle); 467 467 if (fun == NULL) { 468 async_answer_0(c allid, ENOENT);468 async_answer_0(chandle, ENOENT); 469 469 return; 470 470 } … … 481 481 fun_busy_unlock(fun); 482 482 fun_del_ref(fun); 483 async_answer_0(c allid, ENOENT);483 async_answer_0(chandle, ENOENT); 484 484 return; 485 485 } … … 523 523 fun_busy_unlock(fun); 524 524 fun_del_ref(fun); 525 async_answer_0(c allid, gone_rc);525 async_answer_0(chandle, gone_rc); 526 526 return; 527 527 } … … 551 551 fun_busy_unlock(fun); 552 552 fun_del_ref(fun); 553 async_answer_0(c allid, EIO);553 async_answer_0(chandle, EIO); 554 554 return; 555 555 } … … 567 567 568 568 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_remove_function() succeeded."); 569 async_answer_0(c allid, EOK);569 async_answer_0(chandle, EOK); 570 570 } 571 571 … … 586 586 587 587 /** Function for handling connections from a driver to the device manager. */ 588 void devman_connection_driver(cap_call_handle_t i id, ipc_call_t *icall, void *arg)588 void devman_connection_driver(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg) 589 589 { 590 590 client_t *client; … … 592 592 593 593 /* Accept the connection. */ 594 async_answer_0(i id, EOK);594 async_answer_0(icall_handle, EOK); 595 595 596 596 client = async_get_client_data(); … … 602 602 while (true) { 603 603 ipc_call_t call; 604 cap_call_handle_t c allid= async_get_call(&call);604 cap_call_handle_t chandle = async_get_call(&call); 605 605 606 606 if (!IPC_GET_IMETHOD(call)) … … 613 613 if (driver == NULL) { 614 614 /* First call must be to DEVMAN_DRIVER_REGISTER */ 615 async_answer_0(c allid, ENOTSUP);615 async_answer_0(chandle, ENOTSUP); 616 616 continue; 617 617 } … … 623 623 if (client->driver != NULL) { 624 624 fibril_mutex_unlock(&client->mutex); 625 async_answer_0(c allid, EINVAL);625 async_answer_0(chandle, EINVAL); 626 626 continue; 627 627 } 628 client->driver = devman_driver_register(c allid, &call);628 client->driver = devman_driver_register(chandle, &call); 629 629 fibril_mutex_unlock(&client->mutex); 630 630 break; 631 631 case DEVMAN_ADD_FUNCTION: 632 devman_add_function(c allid, &call);632 devman_add_function(chandle, &call); 633 633 break; 634 634 case DEVMAN_ADD_DEVICE_TO_CATEGORY: 635 devman_add_function_to_cat(c allid, &call);635 devman_add_function_to_cat(chandle, &call); 636 636 break; 637 637 case DEVMAN_DRV_FUN_ONLINE: 638 devman_drv_fun_online(c allid, &call, driver);638 devman_drv_fun_online(chandle, &call, driver); 639 639 break; 640 640 case DEVMAN_DRV_FUN_OFFLINE: 641 devman_drv_fun_offline(c allid, &call, driver);641 devman_drv_fun_offline(chandle, &call, driver); 642 642 break; 643 643 case DEVMAN_REMOVE_FUNCTION: 644 devman_remove_function(c allid, &call);644 devman_remove_function(chandle, &call); 645 645 break; 646 646 default: 647 async_answer_0(c allid, EINVAL);647 async_answer_0(chandle, EINVAL); 648 648 break; 649 649 }
Note:
See TracChangeset
for help on using the changeset viewer.