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