Changes in uspace/lib/c/generic/devman.c [3e6a98c5:4c9b28a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/devman.c
r3e6a98c5 r4c9b28a 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. … … 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, … … 405 401 } 406 402 407 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,408 s ize_t buf_size)403 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, 404 sysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size) 409 405 { 410 406 async_exch_t *exch; … … 413 409 sysarg_t dretval; 414 410 415 exch = devman_exchange_begin_blocking( LOC_PORT_CONSUMER);411 exch = devman_exchange_begin_blocking(DEVMAN_CLIENT); 416 412 417 413 ipc_call_t answer; 418 aid_t req = async_send_ 1(exch, method, arg1, &answer);414 aid_t req = async_send_2(exch, method, arg1, arg2, &answer); 419 415 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 420 416 async_wait_for(dreq, &dretval); … … 434 430 } 435 431 432 if (r1 != NULL) 433 *r1 = IPC_GET_ARG1(answer); 436 434 act_size = IPC_GET_ARG2(dreply); 437 435 assert(act_size <= buf_size - 1); … … 443 441 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 444 442 { 445 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 446 buf_size); 443 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, 0, NULL, 444 buf, buf_size); 445 } 446 447 int devman_fun_get_match_id(devman_handle_t handle, size_t index, char *buf, 448 size_t buf_size, unsigned int *rscore) 449 { 450 int rc; 451 sysarg_t score = 0; 452 453 rc = devman_get_str_internal(DEVMAN_FUN_GET_MATCH_ID, handle, index, 454 &score, buf, buf_size); 455 if (rc != EOK) 456 return rc; 457 458 *rscore = score; 459 return rc; 447 460 } 448 461 449 462 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 450 463 { 451 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,452 buf _size);464 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL, 465 buf, buf_size); 453 466 } 454 467 455 468 int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size) 456 469 { 457 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,458 buf_size);470 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0, 471 NULL, buf, buf_size); 459 472 } 460 473 … … 583 596 } 584 597 598 int devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh) 599 { 600 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 601 if (exch == NULL) 602 return ENOMEM; 603 604 sysarg_t retval = async_req_1_1(exch, DEVMAN_DEV_GET_PARENT, 605 devh, funh); 606 607 devman_exchange_end(exch); 608 return (int) retval; 609 } 610 585 611 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 586 612 { … … 596 622 } 597 623 624 int devman_get_drivers(devman_handle_t **drvs, 625 size_t *count) 626 { 627 return devman_get_handles_internal(DEVMAN_GET_DRIVERS, 0, drvs, count); 628 } 629 630 int devman_driver_get_devices(devman_handle_t drvh, devman_handle_t **devs, 631 size_t *count) 632 { 633 return devman_get_handles_internal(DEVMAN_DRIVER_GET_DEVICES, 634 drvh, devs, count); 635 } 636 637 int devman_driver_get_handle(const char *drvname, devman_handle_t *handle) 638 { 639 async_exch_t *exch; 640 641 exch = devman_exchange_begin(DEVMAN_CLIENT); 642 if (exch == NULL) 643 return ENOMEM; 644 645 ipc_call_t answer; 646 aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer); 647 sysarg_t retval = async_data_write_start(exch, drvname, 648 str_size(drvname)); 649 650 devman_exchange_end(exch); 651 652 if (retval != EOK) { 653 async_forget(req); 654 return retval; 655 } 656 657 async_wait_for(req, &retval); 658 659 if (retval != EOK) { 660 if (handle != NULL) 661 *handle = (devman_handle_t) -1; 662 663 return retval; 664 } 665 666 if (handle != NULL) 667 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 668 669 return retval; 670 } 671 672 int devman_driver_get_match_id(devman_handle_t handle, size_t index, char *buf, 673 size_t buf_size, unsigned int *rscore) 674 { 675 int rc; 676 sysarg_t score = 0; 677 678 rc = devman_get_str_internal(DEVMAN_DRIVER_GET_MATCH_ID, handle, index, 679 &score, buf, buf_size); 680 if (rc != EOK) 681 return rc; 682 683 *rscore = score; 684 return rc; 685 } 686 687 int devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size) 688 { 689 return devman_get_str_internal(DEVMAN_DRIVER_GET_NAME, handle, 0, NULL, 690 buf, buf_size); 691 } 692 693 int devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate) 694 { 695 sysarg_t state; 696 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 697 if (exch == NULL) 698 return ENOMEM; 699 700 int rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh, 701 &state); 702 703 devman_exchange_end(exch); 704 if (rc != EOK) 705 return rc; 706 707 *rstate = state; 708 return rc; 709 } 710 711 int devman_driver_load(devman_handle_t drvh) 712 { 713 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 714 if (exch == NULL) 715 return ENOMEM; 716 717 int rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh); 718 719 devman_exchange_end(exch); 720 return rc; 721 } 722 598 723 /** @} 599 724 */
Note:
See TracChangeset
for help on using the changeset viewer.