Changes in uspace/lib/c/generic/devman.c [d87561c:be12474] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/devman.c
rd87561c rbe12474 1 1 /* 2 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 201 1Jiri Svoboda3 * Copyright (c) 2013 Jiri Svoboda 4 4 * Copyright (c) 2010 Lenka Trochtova 5 5 * All rights reserved. … … 77 77 * 78 78 */ 79 async_exch_t *devman_exchange_begin_blocking( devman_interface_t iface)79 async_exch_t *devman_exchange_begin_blocking(iface_t iface) 80 80 { 81 81 switch (iface) { 82 case DEVMAN_DRIVER:82 case INTERFACE_DDF_DRIVER: 83 83 fibril_mutex_lock(&devman_driver_block_mutex); 84 84 … … 89 89 if (devman_driver_block_sess == NULL) 90 90 devman_driver_block_sess = 91 service_connect_blocking( EXCHANGE_PARALLEL,92 SERVICE_DEVMAN, DEVMAN_DRIVER, 0);91 service_connect_blocking(SERVICE_DEVMAN, 92 INTERFACE_DDF_DRIVER, 0); 93 93 } 94 94 … … 99 99 100 100 return async_exchange_begin(devman_driver_block_sess); 101 case DEVMAN_CLIENT:101 case INTERFACE_DDF_CLIENT: 102 102 fibril_mutex_lock(&devman_client_block_mutex); 103 103 … … 108 108 if (devman_client_block_sess == NULL) 109 109 devman_client_block_sess = 110 service_connect_blocking( EXCHANGE_SERIALIZE,111 SERVICE_DEVMAN, DEVMAN_CLIENT, 0);110 service_connect_blocking(SERVICE_DEVMAN, 111 INTERFACE_DDF_CLIENT, 0); 112 112 } 113 113 … … 130 130 * 131 131 */ 132 async_exch_t *devman_exchange_begin( devman_interface_t iface)132 async_exch_t *devman_exchange_begin(iface_t iface) 133 133 { 134 134 switch (iface) { 135 case DEVMAN_DRIVER:135 case INTERFACE_DDF_DRIVER: 136 136 fibril_mutex_lock(&devman_driver_mutex); 137 137 138 138 if (devman_driver_sess == NULL) 139 139 devman_driver_sess = 140 service_connect( EXCHANGE_PARALLEL,SERVICE_DEVMAN,141 DEVMAN_DRIVER, 0);140 service_connect(SERVICE_DEVMAN, 141 INTERFACE_DDF_DRIVER, 0); 142 142 143 143 fibril_mutex_unlock(&devman_driver_mutex); … … 147 147 148 148 return async_exchange_begin(devman_driver_sess); 149 case DEVMAN_CLIENT:149 case INTERFACE_DDF_CLIENT: 150 150 fibril_mutex_lock(&devman_client_mutex); 151 151 152 152 if (devman_client_sess == NULL) 153 153 devman_client_sess = 154 service_connect( EXCHANGE_SERIALIZE,SERVICE_DEVMAN,155 DEVMAN_CLIENT, 0);154 service_connect(SERVICE_DEVMAN, 155 INTERFACE_DDF_CLIENT, 0); 156 156 157 157 fibril_mutex_unlock(&devman_client_mutex); … … 179 179 int devman_driver_register(const char *name) 180 180 { 181 async_exch_t *exch = devman_exchange_begin_blocking( DEVMAN_DRIVER);181 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER); 182 182 183 183 ipc_call_t answer; … … 192 192 } 193 193 194 exch = devman_exchange_begin( DEVMAN_DRIVER);195 async_connect_to_me(exch, 0, 0, 0 , NULL, NULL);194 exch = devman_exchange_begin(INTERFACE_DDF_DRIVER); 195 async_connect_to_me(exch, 0, 0, 0); 196 196 devman_exchange_end(exch); 197 197 … … 217 217 match_id_list_t *match_ids, devman_handle_t devh, devman_handle_t *funh) 218 218 { 219 intmatch_count = list_count(&match_ids->ids);220 async_exch_t *exch = devman_exchange_begin_blocking( DEVMAN_DRIVER);219 unsigned long match_count = list_count(&match_ids->ids); 220 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER); 221 221 222 222 ipc_call_t answer; … … 230 230 } 231 231 232 match_id_t *match_id = NULL; 233 234 list_foreach(match_ids->ids, link) { 235 match_id = list_get_instance(link, match_id_t, link); 236 232 list_foreach(match_ids->ids, link, match_id_t, match_id) { 237 233 ipc_call_t answer2; 238 234 aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID, … … 272 268 const char *cat_name) 273 269 { 274 async_exch_t *exch = devman_exchange_begin_blocking( DEVMAN_DRIVER);270 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER); 275 271 276 272 ipc_call_t answer; … … 291 287 } 292 288 293 async_sess_t *devman_device_connect(exch_mgmt_t mgmt, devman_handle_t handle, 294 unsigned int flags) 289 async_sess_t *devman_device_connect(devman_handle_t handle, unsigned int flags) 295 290 { 296 291 async_sess_t *sess; 297 292 298 293 if (flags & IPC_FLAG_BLOCKING) 299 sess = service_connect_blocking( mgmt,SERVICE_DEVMAN,300 DEVMAN_CONNECT_TO_DEVICE, handle);294 sess = service_connect_blocking(SERVICE_DEVMAN, 295 INTERFACE_DEVMAN_DEVICE, handle); 301 296 else 302 sess = service_connect( mgmt,SERVICE_DEVMAN,303 DEVMAN_CONNECT_TO_DEVICE, handle);297 sess = service_connect(SERVICE_DEVMAN, 298 INTERFACE_DEVMAN_DEVICE, handle); 304 299 305 300 return sess; … … 318 313 sysarg_t retval; 319 314 320 exch = devman_exchange_begin_blocking( DEVMAN_DRIVER);315 exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER); 321 316 retval = async_req_1_0(exch, DEVMAN_REMOVE_FUNCTION, (sysarg_t) funh); 322 317 devman_exchange_end(exch); … … 327 322 int devman_drv_fun_online(devman_handle_t funh) 328 323 { 329 async_exch_t *exch = devman_exchange_begin( DEVMAN_DRIVER);324 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER); 330 325 if (exch == NULL) 331 326 return ENOMEM; … … 339 334 int devman_drv_fun_offline(devman_handle_t funh) 340 335 { 341 async_exch_t *exch = devman_exchange_begin( DEVMAN_DRIVER);336 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER); 342 337 if (exch == NULL) 343 338 return ENOMEM; … … 349 344 } 350 345 351 async_sess_t *devman_parent_device_connect( exch_mgmt_t mgmt,352 devman_handle_t handle,unsigned int flags)346 async_sess_t *devman_parent_device_connect(devman_handle_t handle, 347 unsigned int flags) 353 348 { 354 349 async_sess_t *sess; 355 350 356 351 if (flags & IPC_FLAG_BLOCKING) 357 sess = service_connect_blocking( mgmt,SERVICE_DEVMAN,358 DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);352 sess = service_connect_blocking(SERVICE_DEVMAN, 353 INTERFACE_DEVMAN_PARENT, handle); 359 354 else 360 sess = service_connect (mgmt,SERVICE_DEVMAN,361 DEVMAN_CONNECT_TO_PARENTS_DEVICE, handle);355 sess = service_connect_blocking(SERVICE_DEVMAN, 356 INTERFACE_DEVMAN_PARENT, handle); 362 357 363 358 return sess; … … 370 365 371 366 if (flags & IPC_FLAG_BLOCKING) 372 exch = devman_exchange_begin_blocking( DEVMAN_CLIENT);367 exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT); 373 368 else { 374 exch = devman_exchange_begin( DEVMAN_CLIENT);369 exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 375 370 if (exch == NULL) 376 371 return ENOMEM; … … 405 400 } 406 401 407 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,408 s ize_t buf_size)402 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, 403 sysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size) 409 404 { 410 405 async_exch_t *exch; … … 413 408 sysarg_t dretval; 414 409 415 exch = devman_exchange_begin_blocking( DEVMAN_CLIENT);410 exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT); 416 411 417 412 ipc_call_t answer; 418 aid_t req = async_send_ 1(exch, method, arg1, &answer);413 aid_t req = async_send_2(exch, method, arg1, arg2, &answer); 419 414 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 420 415 async_wait_for(dreq, &dretval); … … 434 429 } 435 430 431 if (r1 != NULL) 432 *r1 = IPC_GET_ARG1(answer); 436 433 act_size = IPC_GET_ARG2(dreply); 437 434 assert(act_size <= buf_size - 1); … … 443 440 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 444 441 { 445 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 446 buf_size); 442 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, 0, NULL, 443 buf, buf_size); 444 } 445 446 int devman_fun_get_match_id(devman_handle_t handle, size_t index, char *buf, 447 size_t buf_size, unsigned int *rscore) 448 { 449 int rc; 450 sysarg_t score = 0; 451 452 rc = devman_get_str_internal(DEVMAN_FUN_GET_MATCH_ID, handle, index, 453 &score, buf, buf_size); 454 if (rc != EOK) 455 return rc; 456 457 *rscore = score; 458 return rc; 447 459 } 448 460 449 461 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 450 462 { 451 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,452 buf _size);463 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL, 464 buf, buf_size); 453 465 } 454 466 455 467 int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size) 456 468 { 457 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,458 buf_size);469 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0, 470 NULL, buf, buf_size); 459 471 } 460 472 461 473 int devman_fun_online(devman_handle_t funh) 462 474 { 463 async_exch_t *exch = devman_exchange_begin( DEVMAN_CLIENT);475 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 464 476 if (exch == NULL) 465 477 return ENOMEM; … … 473 485 int devman_fun_offline(devman_handle_t funh) 474 486 { 475 async_exch_t *exch = devman_exchange_begin( DEVMAN_CLIENT);487 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 476 488 if (exch == NULL) 477 489 return ENOMEM; … … 486 498 devman_handle_t *handle_buf, size_t buf_size, size_t *act_size) 487 499 { 488 async_exch_t *exch = devman_exchange_begin_blocking( DEVMAN_CLIENT);500 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT); 489 501 490 502 ipc_call_t answer; … … 565 577 int devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh) 566 578 { 567 async_exch_t *exch = devman_exchange_begin( DEVMAN_CLIENT);579 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 568 580 if (exch == NULL) 569 581 return ENOMEM; … … 583 595 } 584 596 597 int devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh) 598 { 599 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 600 if (exch == NULL) 601 return ENOMEM; 602 603 sysarg_t retval = async_req_1_1(exch, DEVMAN_DEV_GET_PARENT, 604 devh, funh); 605 606 devman_exchange_end(exch); 607 return (int) retval; 608 } 609 585 610 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 586 611 { 587 async_exch_t *exch = devman_exchange_begin( DEVMAN_CLIENT);612 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 588 613 if (exch == NULL) 589 614 return ENOMEM; … … 596 621 } 597 622 623 int devman_get_drivers(devman_handle_t **drvs, 624 size_t *count) 625 { 626 return devman_get_handles_internal(DEVMAN_GET_DRIVERS, 0, drvs, count); 627 } 628 629 int devman_driver_get_devices(devman_handle_t drvh, devman_handle_t **devs, 630 size_t *count) 631 { 632 return devman_get_handles_internal(DEVMAN_DRIVER_GET_DEVICES, 633 drvh, devs, count); 634 } 635 636 int devman_driver_get_handle(const char *drvname, devman_handle_t *handle) 637 { 638 async_exch_t *exch; 639 640 exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 641 if (exch == NULL) 642 return ENOMEM; 643 644 ipc_call_t answer; 645 aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer); 646 sysarg_t retval = async_data_write_start(exch, drvname, 647 str_size(drvname)); 648 649 devman_exchange_end(exch); 650 651 if (retval != EOK) { 652 async_forget(req); 653 return retval; 654 } 655 656 async_wait_for(req, &retval); 657 658 if (retval != EOK) { 659 if (handle != NULL) 660 *handle = (devman_handle_t) -1; 661 662 return retval; 663 } 664 665 if (handle != NULL) 666 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 667 668 return retval; 669 } 670 671 int devman_driver_get_match_id(devman_handle_t handle, size_t index, char *buf, 672 size_t buf_size, unsigned int *rscore) 673 { 674 int rc; 675 sysarg_t score = 0; 676 677 rc = devman_get_str_internal(DEVMAN_DRIVER_GET_MATCH_ID, handle, index, 678 &score, buf, buf_size); 679 if (rc != EOK) 680 return rc; 681 682 *rscore = score; 683 return rc; 684 } 685 686 int devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size) 687 { 688 return devman_get_str_internal(DEVMAN_DRIVER_GET_NAME, handle, 0, NULL, 689 buf, buf_size); 690 } 691 692 int devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate) 693 { 694 sysarg_t state; 695 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 696 if (exch == NULL) 697 return ENOMEM; 698 699 int rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh, 700 &state); 701 702 devman_exchange_end(exch); 703 if (rc != EOK) 704 return rc; 705 706 *rstate = state; 707 return rc; 708 } 709 710 int devman_driver_load(devman_handle_t drvh) 711 { 712 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT); 713 if (exch == NULL) 714 return ENOMEM; 715 716 int rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh); 717 718 devman_exchange_end(exch); 719 return rc; 720 } 721 598 722 /** @} 599 723 */
Note:
See TracChangeset
for help on using the changeset viewer.