Changes in uspace/lib/c/generic/devman.c [4c9b28a:d87561c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/devman.c
r4c9b28a rd87561c 1 1 /* 2 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 201 3Jiri Svoboda3 * Copyright (c) 2011 Jiri Svoboda 4 4 * Copyright (c) 2010 Lenka Trochtova 5 5 * All rights reserved. … … 230 230 } 231 231 232 list_foreach(match_ids->ids, link, match_id_t, match_id) { 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 233 237 ipc_call_t answer2; 234 238 aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID, … … 401 405 } 402 406 403 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, 404 s ysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size)407 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf, 408 size_t buf_size) 405 409 { 406 410 async_exch_t *exch; … … 412 416 413 417 ipc_call_t answer; 414 aid_t req = async_send_ 2(exch, method, arg1, arg2, &answer);418 aid_t req = async_send_1(exch, method, arg1, &answer); 415 419 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 416 420 async_wait_for(dreq, &dretval); … … 430 434 } 431 435 432 if (r1 != NULL)433 *r1 = IPC_GET_ARG1(answer);434 436 act_size = IPC_GET_ARG2(dreply); 435 437 assert(act_size <= buf_size - 1); … … 441 443 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 442 444 { 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; 445 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 446 buf_size); 460 447 } 461 448 462 449 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 463 450 { 464 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL,465 buf , buf_size);451 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf, 452 buf_size); 466 453 } 467 454 468 455 int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size) 469 456 { 470 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0,471 NULL, buf,buf_size);457 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf, 458 buf_size); 472 459 } 473 460 … … 596 583 } 597 584 598 int devman_ dev_get_parent(devman_handle_t devh, devman_handle_t *funh)585 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 599 586 { 600 587 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); … … 602 589 return ENOMEM; 603 590 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 611 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)612 {613 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);614 if (exch == NULL)615 return ENOMEM;616 617 591 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE, 618 592 sid, handle); … … 622 596 } 623 597 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 723 598 /** @} 724 599 */
Note:
See TracChangeset
for help on using the changeset viewer.