Changes in uspace/srv/devmap/devmap.c [ca2a18e:01b87dc5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
rca2a18e r01b87dc5 374 374 375 375 if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) { 376 async_answer_0(iid, EREFUSED);376 ipc_answer_0(iid, EREFUSED); 377 377 return NULL; 378 378 } … … 381 381 (devmap_driver_t *) malloc(sizeof(devmap_driver_t)); 382 382 if (driver == NULL) { 383 async_answer_0(iid, ENOMEM);383 ipc_answer_0(iid, ENOMEM); 384 384 return NULL; 385 385 } … … 392 392 if (rc != EOK) { 393 393 free(driver); 394 async_answer_0(iid, rc);394 ipc_answer_0(iid, rc); 395 395 return NULL; 396 396 } … … 405 405 free(driver->name); 406 406 free(driver); 407 async_answer_0(callid, ENOTSUP);408 async_answer_0(iid, ENOTSUP);407 ipc_answer_0(callid, ENOTSUP); 408 ipc_answer_0(iid, ENOTSUP); 409 409 return NULL; 410 410 } 411 411 412 412 driver->phone = IPC_GET_ARG5(call); 413 async_answer_0(callid, EOK);413 ipc_answer_0(callid, EOK); 414 414 415 415 /* … … 423 423 */ 424 424 list_initialize(&driver->devices); 425 426 link_initialize(&driver->drivers); 425 list_initialize(&(driver->drivers)); 427 426 428 427 fibril_mutex_lock(&drivers_list_mutex); … … 439 438 fibril_mutex_unlock(&drivers_list_mutex); 440 439 441 async_answer_0(iid, EOK);440 ipc_answer_0(iid, EOK); 442 441 443 442 return driver; … … 457 456 458 457 if (driver->phone != 0) 459 async_hangup(driver->phone);458 ipc_hangup(driver->phone); 460 459 461 460 /* Remove it from list of drivers */ … … 492 491 { 493 492 if (driver == NULL) { 494 async_answer_0(iid, EREFUSED);493 ipc_answer_0(iid, EREFUSED); 495 494 return; 496 495 } … … 500 499 (devmap_device_t *) malloc(sizeof(devmap_device_t)); 501 500 if (device == NULL) { 502 async_answer_0(iid, ENOMEM);501 ipc_answer_0(iid, ENOMEM); 503 502 return; 504 503 } … … 513 512 if (rc != EOK) { 514 513 free(device); 515 async_answer_0(iid, rc);514 ipc_answer_0(iid, rc); 516 515 return; 517 516 } … … 521 520 free(fqdn); 522 521 free(device); 523 async_answer_0(iid, EINVAL);522 ipc_answer_0(iid, EINVAL); 524 523 return; 525 524 } … … 535 534 free(device->name); 536 535 free(device); 537 async_answer_0(iid, ENOMEM);538 return; 539 } 540 541 li nk_initialize(&device->devices);542 li nk_initialize(&device->driver_devices);536 ipc_answer_0(iid, ENOMEM); 537 return; 538 } 539 540 list_initialize(&(device->devices)); 541 list_initialize(&(device->driver_devices)); 543 542 544 543 /* Check that device is not already registered */ … … 550 549 free(device->name); 551 550 free(device); 552 async_answer_0(iid, EEXISTS);551 ipc_answer_0(iid, EEXISTS); 553 552 return; 554 553 } … … 572 571 fibril_mutex_unlock(&devices_list_mutex); 573 572 574 async_answer_1(iid, EOK, device->handle);573 ipc_answer_1(iid, EOK, device->handle); 575 574 } 576 575 … … 603 602 if ((dev == NULL) || (dev->driver == NULL) || (dev->driver->phone == 0)) { 604 603 fibril_mutex_unlock(&devices_list_mutex); 605 async_answer_0(callid, ENOENT);604 ipc_answer_0(callid, ENOENT); 606 605 return; 607 606 } 608 607 609 608 if (dev->forward_interface == 0) { 610 async_forward_fast(callid, dev->driver->phone,609 ipc_forward_fast(callid, dev->driver->phone, 611 610 dev->handle, 0, 0, 612 611 IPC_FF_NONE); 613 612 } else { 614 async_forward_fast(callid, dev->driver->phone,613 ipc_forward_fast(callid, dev->driver->phone, 615 614 dev->forward_interface, dev->handle, 0, 616 615 IPC_FF_NONE); … … 634 633 DEVMAP_NAME_MAXLEN, 0, NULL); 635 634 if (rc != EOK) { 636 async_answer_0(iid, rc);635 ipc_answer_0(iid, rc); 637 636 return; 638 637 } … … 642 641 if (!devmap_fqdn_split(fqdn, &ns_name, &name)) { 643 642 free(fqdn); 644 async_answer_0(iid, EINVAL);643 ipc_answer_0(iid, EINVAL); 645 644 return; 646 645 } … … 669 668 } 670 669 671 async_answer_0(iid, ENOENT);670 ipc_answer_0(iid, ENOENT); 672 671 free(ns_name); 673 672 free(name); … … 676 675 } 677 676 678 async_answer_1(iid, EOK, dev->handle);677 ipc_answer_1(iid, EOK, dev->handle); 679 678 680 679 fibril_mutex_unlock(&devices_list_mutex); … … 697 696 DEVMAP_NAME_MAXLEN, 0, NULL); 698 697 if (rc != EOK) { 699 async_answer_0(iid, rc);698 ipc_answer_0(iid, rc); 700 699 return; 701 700 } … … 722 721 } 723 722 724 async_answer_0(iid, ENOENT);723 ipc_answer_0(iid, ENOENT); 725 724 free(name); 726 725 fibril_mutex_unlock(&devices_list_mutex); … … 728 727 } 729 728 730 async_answer_1(iid, EOK, namespace->handle);729 ipc_answer_1(iid, EOK, namespace->handle); 731 730 732 731 fibril_mutex_unlock(&devices_list_mutex); … … 744 743 devmap_device_find_handle(IPC_GET_ARG1(*icall)); 745 744 if (dev == NULL) 746 async_answer_1(iid, EOK, DEV_HANDLE_NONE);745 ipc_answer_1(iid, EOK, DEV_HANDLE_NONE); 747 746 else 748 async_answer_1(iid, EOK, DEV_HANDLE_DEVICE);747 ipc_answer_1(iid, EOK, DEV_HANDLE_DEVICE); 749 748 } else 750 async_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);749 ipc_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE); 751 750 752 751 fibril_mutex_unlock(&devices_list_mutex); … … 756 755 { 757 756 fibril_mutex_lock(&devices_list_mutex); 758 async_answer_1(iid, EOK, list_count(&namespaces_list));757 ipc_answer_1(iid, EOK, list_count(&namespaces_list)); 759 758 fibril_mutex_unlock(&devices_list_mutex); 760 759 } … … 767 766 devmap_namespace_find_handle(IPC_GET_ARG1(*icall)); 768 767 if (namespace == NULL) 769 async_answer_0(iid, EEXISTS);768 ipc_answer_0(iid, EEXISTS); 770 769 else 771 async_answer_1(iid, EOK, namespace->refcnt);770 ipc_answer_1(iid, EOK, namespace->refcnt); 772 771 773 772 fibril_mutex_unlock(&devices_list_mutex); … … 779 778 size_t size; 780 779 if (!async_data_read_receive(&callid, &size)) { 781 async_answer_0(callid, EREFUSED);782 async_answer_0(iid, EREFUSED);780 ipc_answer_0(callid, EREFUSED); 781 ipc_answer_0(iid, EREFUSED); 783 782 return; 784 783 } 785 784 786 785 if ((size % sizeof(dev_desc_t)) != 0) { 787 async_answer_0(callid, EINVAL);788 async_answer_0(iid, EINVAL);786 ipc_answer_0(callid, EINVAL); 787 ipc_answer_0(iid, EINVAL); 789 788 return; 790 789 } … … 795 794 if (count != list_count(&namespaces_list)) { 796 795 fibril_mutex_unlock(&devices_list_mutex); 797 async_answer_0(callid, EOVERFLOW);798 async_answer_0(iid, EOVERFLOW);796 ipc_answer_0(callid, EOVERFLOW); 797 ipc_answer_0(iid, EOVERFLOW); 799 798 return; 800 799 } … … 803 802 if (desc == NULL) { 804 803 fibril_mutex_unlock(&devices_list_mutex); 805 async_answer_0(callid, ENOMEM);806 async_answer_0(iid, ENOMEM);804 ipc_answer_0(callid, ENOMEM); 805 ipc_answer_0(iid, ENOMEM); 807 806 return; 808 807 } … … 825 824 fibril_mutex_unlock(&devices_list_mutex); 826 825 827 async_answer_0(iid, retval);826 ipc_answer_0(iid, retval); 828 827 } 829 828 … … 836 835 size_t size; 837 836 if (!async_data_read_receive(&callid, &size)) { 838 async_answer_0(callid, EREFUSED);839 async_answer_0(iid, EREFUSED);837 ipc_answer_0(callid, EREFUSED); 838 ipc_answer_0(iid, EREFUSED); 840 839 return; 841 840 } 842 841 843 842 if ((size % sizeof(dev_desc_t)) != 0) { 844 async_answer_0(callid, EINVAL);845 async_answer_0(iid, EINVAL);843 ipc_answer_0(callid, EINVAL); 844 ipc_answer_0(iid, EINVAL); 846 845 return; 847 846 } … … 853 852 if (namespace == NULL) { 854 853 fibril_mutex_unlock(&devices_list_mutex); 855 async_answer_0(callid, ENOENT);856 async_answer_0(iid, ENOENT);854 ipc_answer_0(callid, ENOENT); 855 ipc_answer_0(iid, ENOENT); 857 856 return; 858 857 } … … 861 860 if (count != namespace->refcnt) { 862 861 fibril_mutex_unlock(&devices_list_mutex); 863 async_answer_0(callid, EOVERFLOW);864 async_answer_0(iid, EOVERFLOW);862 ipc_answer_0(callid, EOVERFLOW); 863 ipc_answer_0(iid, EOVERFLOW); 865 864 return; 866 865 } … … 869 868 if (desc == NULL) { 870 869 fibril_mutex_unlock(&devices_list_mutex); 871 async_answer_0(callid, ENOMEM);872 async_answer_0(iid, EREFUSED);870 ipc_answer_0(callid, ENOMEM); 871 ipc_answer_0(iid, EREFUSED); 873 872 return; 874 873 } … … 892 891 fibril_mutex_unlock(&devices_list_mutex); 893 892 894 async_answer_0(iid, retval);893 ipc_answer_0(iid, retval); 895 894 } 896 895 … … 911 910 if (!fnd) { 912 911 fibril_mutex_unlock(&null_devices_mutex); 913 async_answer_0(iid, ENOMEM);912 ipc_answer_0(iid, ENOMEM); 914 913 return; 915 914 } … … 921 920 if (dev_name == NULL) { 922 921 fibril_mutex_unlock(&null_devices_mutex); 923 async_answer_0(iid, ENOMEM);922 ipc_answer_0(iid, ENOMEM); 924 923 return; 925 924 } … … 929 928 if (device == NULL) { 930 929 fibril_mutex_unlock(&null_devices_mutex); 931 async_answer_0(iid, ENOMEM);930 ipc_answer_0(iid, ENOMEM); 932 931 return; 933 932 } … … 939 938 fibril_mutex_lock(&devices_list_mutex); 940 939 fibril_mutex_unlock(&null_devices_mutex); 941 async_answer_0(iid, ENOMEM);942 return; 943 } 944 945 li nk_initialize(&device->devices);946 li nk_initialize(&device->driver_devices);940 ipc_answer_0(iid, ENOMEM); 941 return; 942 } 943 944 list_initialize(&(device->devices)); 945 list_initialize(&(device->driver_devices)); 947 946 948 947 /* Get unique device handle */ … … 961 960 fibril_mutex_unlock(&null_devices_mutex); 962 961 963 async_answer_1(iid, EOK, (sysarg_t) i);962 ipc_answer_1(iid, EOK, (sysarg_t) i); 964 963 } 965 964 … … 968 967 sysarg_t i = IPC_GET_ARG1(*icall); 969 968 if (i >= NULL_DEVICES) { 970 async_answer_0(iid, ELIMIT);969 ipc_answer_0(iid, ELIMIT); 971 970 return; 972 971 } … … 976 975 if (null_devices[i] == NULL) { 977 976 fibril_mutex_unlock(&null_devices_mutex); 978 async_answer_0(iid, ENOENT);977 ipc_answer_0(iid, ENOENT); 979 978 return; 980 979 } … … 987 986 988 987 fibril_mutex_unlock(&null_devices_mutex); 989 async_answer_0(iid, EOK);988 ipc_answer_0(iid, EOK); 990 989 } 991 990 … … 1013 1012 { 1014 1013 /* Accept connection */ 1015 async_answer_0(iid, EOK);1014 ipc_answer_0(iid, EOK); 1016 1015 1017 1016 devmap_driver_t *driver = devmap_driver_register(); … … 1030 1029 case DEVMAP_DRIVER_UNREGISTER: 1031 1030 if (NULL == driver) 1032 async_answer_0(callid, ENOENT);1031 ipc_answer_0(callid, ENOENT); 1033 1032 else 1034 async_answer_0(callid, EOK);1033 ipc_answer_0(callid, EOK); 1035 1034 break; 1036 1035 case DEVMAP_DEVICE_REGISTER: … … 1049 1048 break; 1050 1049 default: 1051 async_answer_0(callid, ENOENT);1050 ipc_answer_0(callid, ENOENT); 1052 1051 } 1053 1052 } … … 1068 1067 { 1069 1068 /* Accept connection */ 1070 async_answer_0(iid, EOK);1069 ipc_answer_0(iid, EOK); 1071 1070 1072 1071 bool cont = true; … … 1107 1106 break; 1108 1107 default: 1109 async_answer_0(callid, ENOENT);1108 ipc_answer_0(callid, ENOENT); 1110 1109 } 1111 1110 } … … 1131 1130 default: 1132 1131 /* No such interface */ 1133 async_answer_0(iid, ENOENT);1132 ipc_answer_0(iid, ENOENT); 1134 1133 } 1135 1134 } … … 1151 1150 1152 1151 /* Register device mapper at naming service */ 1153 if (service_register(SERVICE_DEVMAP) != EOK) 1152 sysarg_t phonead; 1153 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0) 1154 1154 return -1; 1155 1155
Note:
See TracChangeset
for help on using the changeset viewer.