Changes in uspace/srv/devmap/devmap.c [4ae90f9:01b87dc5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
r4ae90f9 r01b87dc5 123 123 static devmap_handle_t last_handle = 0; 124 124 static devmap_device_t *null_devices[NULL_DEVICES]; 125 126 /*127 * Dummy list for null devices. This is necessary so that null devices can128 * be used just as any other devices, e.g. in devmap_device_unregister_core().129 */130 static LIST_INITIALIZE(dummy_null_driver_devices);131 125 132 126 static devmap_handle_t devmap_create_handle(void) … … 380 374 381 375 if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) { 382 async_answer_0(iid, EREFUSED);376 ipc_answer_0(iid, EREFUSED); 383 377 return NULL; 384 378 } … … 387 381 (devmap_driver_t *) malloc(sizeof(devmap_driver_t)); 388 382 if (driver == NULL) { 389 async_answer_0(iid, ENOMEM);383 ipc_answer_0(iid, ENOMEM); 390 384 return NULL; 391 385 } … … 398 392 if (rc != EOK) { 399 393 free(driver); 400 async_answer_0(iid, rc);394 ipc_answer_0(iid, rc); 401 395 return NULL; 402 396 } … … 411 405 free(driver->name); 412 406 free(driver); 413 async_answer_0(callid, ENOTSUP);414 async_answer_0(iid, ENOTSUP);407 ipc_answer_0(callid, ENOTSUP); 408 ipc_answer_0(iid, ENOTSUP); 415 409 return NULL; 416 410 } 417 411 418 412 driver->phone = IPC_GET_ARG5(call); 419 async_answer_0(callid, EOK);413 ipc_answer_0(callid, EOK); 420 414 421 415 /* … … 429 423 */ 430 424 list_initialize(&driver->devices); 431 432 link_initialize(&driver->drivers); 425 list_initialize(&(driver->drivers)); 433 426 434 427 fibril_mutex_lock(&drivers_list_mutex); … … 445 438 fibril_mutex_unlock(&drivers_list_mutex); 446 439 447 async_answer_0(iid, EOK);440 ipc_answer_0(iid, EOK); 448 441 449 442 return driver; … … 463 456 464 457 if (driver->phone != 0) 465 async_hangup(driver->phone);458 ipc_hangup(driver->phone); 466 459 467 460 /* Remove it from list of drivers */ … … 498 491 { 499 492 if (driver == NULL) { 500 async_answer_0(iid, EREFUSED);493 ipc_answer_0(iid, EREFUSED); 501 494 return; 502 495 } … … 506 499 (devmap_device_t *) malloc(sizeof(devmap_device_t)); 507 500 if (device == NULL) { 508 async_answer_0(iid, ENOMEM);501 ipc_answer_0(iid, ENOMEM); 509 502 return; 510 503 } … … 519 512 if (rc != EOK) { 520 513 free(device); 521 async_answer_0(iid, rc);514 ipc_answer_0(iid, rc); 522 515 return; 523 516 } … … 527 520 free(fqdn); 528 521 free(device); 529 async_answer_0(iid, EINVAL);522 ipc_answer_0(iid, EINVAL); 530 523 return; 531 524 } … … 541 534 free(device->name); 542 535 free(device); 543 async_answer_0(iid, ENOMEM);544 return; 545 } 546 547 li nk_initialize(&device->devices);548 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)); 549 542 550 543 /* Check that device is not already registered */ 551 544 if (devmap_device_find_name(namespace->name, device->name) != NULL) { 552 545 printf("%s: Device '%s/%s' already registered\n", NAME, 553 namespace->name, device->name);546 device->namespace->name, device->name); 554 547 devmap_namespace_destroy(namespace); 555 548 fibril_mutex_unlock(&devices_list_mutex); 556 549 free(device->name); 557 550 free(device); 558 async_answer_0(iid, EEXISTS);551 ipc_answer_0(iid, EEXISTS); 559 552 return; 560 553 } … … 578 571 fibril_mutex_unlock(&devices_list_mutex); 579 572 580 async_answer_1(iid, EOK, device->handle);573 ipc_answer_1(iid, EOK, device->handle); 581 574 } 582 575 … … 609 602 if ((dev == NULL) || (dev->driver == NULL) || (dev->driver->phone == 0)) { 610 603 fibril_mutex_unlock(&devices_list_mutex); 611 async_answer_0(callid, ENOENT);604 ipc_answer_0(callid, ENOENT); 612 605 return; 613 606 } 614 607 615 608 if (dev->forward_interface == 0) { 616 async_forward_fast(callid, dev->driver->phone,609 ipc_forward_fast(callid, dev->driver->phone, 617 610 dev->handle, 0, 0, 618 611 IPC_FF_NONE); 619 612 } else { 620 async_forward_fast(callid, dev->driver->phone,613 ipc_forward_fast(callid, dev->driver->phone, 621 614 dev->forward_interface, dev->handle, 0, 622 615 IPC_FF_NONE); … … 640 633 DEVMAP_NAME_MAXLEN, 0, NULL); 641 634 if (rc != EOK) { 642 async_answer_0(iid, rc);635 ipc_answer_0(iid, rc); 643 636 return; 644 637 } … … 648 641 if (!devmap_fqdn_split(fqdn, &ns_name, &name)) { 649 642 free(fqdn); 650 async_answer_0(iid, EINVAL);643 ipc_answer_0(iid, EINVAL); 651 644 return; 652 645 } … … 675 668 } 676 669 677 async_answer_0(iid, ENOENT);670 ipc_answer_0(iid, ENOENT); 678 671 free(ns_name); 679 672 free(name); … … 682 675 } 683 676 684 async_answer_1(iid, EOK, dev->handle);677 ipc_answer_1(iid, EOK, dev->handle); 685 678 686 679 fibril_mutex_unlock(&devices_list_mutex); … … 703 696 DEVMAP_NAME_MAXLEN, 0, NULL); 704 697 if (rc != EOK) { 705 async_answer_0(iid, rc);698 ipc_answer_0(iid, rc); 706 699 return; 707 700 } … … 728 721 } 729 722 730 async_answer_0(iid, ENOENT);723 ipc_answer_0(iid, ENOENT); 731 724 free(name); 732 725 fibril_mutex_unlock(&devices_list_mutex); … … 734 727 } 735 728 736 async_answer_1(iid, EOK, namespace->handle);729 ipc_answer_1(iid, EOK, namespace->handle); 737 730 738 731 fibril_mutex_unlock(&devices_list_mutex); … … 750 743 devmap_device_find_handle(IPC_GET_ARG1(*icall)); 751 744 if (dev == NULL) 752 async_answer_1(iid, EOK, DEV_HANDLE_NONE);745 ipc_answer_1(iid, EOK, DEV_HANDLE_NONE); 753 746 else 754 async_answer_1(iid, EOK, DEV_HANDLE_DEVICE);747 ipc_answer_1(iid, EOK, DEV_HANDLE_DEVICE); 755 748 } else 756 async_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);749 ipc_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE); 757 750 758 751 fibril_mutex_unlock(&devices_list_mutex); … … 762 755 { 763 756 fibril_mutex_lock(&devices_list_mutex); 764 async_answer_1(iid, EOK, list_count(&namespaces_list));757 ipc_answer_1(iid, EOK, list_count(&namespaces_list)); 765 758 fibril_mutex_unlock(&devices_list_mutex); 766 759 } … … 773 766 devmap_namespace_find_handle(IPC_GET_ARG1(*icall)); 774 767 if (namespace == NULL) 775 async_answer_0(iid, EEXISTS);768 ipc_answer_0(iid, EEXISTS); 776 769 else 777 async_answer_1(iid, EOK, namespace->refcnt);770 ipc_answer_1(iid, EOK, namespace->refcnt); 778 771 779 772 fibril_mutex_unlock(&devices_list_mutex); … … 785 778 size_t size; 786 779 if (!async_data_read_receive(&callid, &size)) { 787 async_answer_0(callid, EREFUSED);788 async_answer_0(iid, EREFUSED);780 ipc_answer_0(callid, EREFUSED); 781 ipc_answer_0(iid, EREFUSED); 789 782 return; 790 783 } 791 784 792 785 if ((size % sizeof(dev_desc_t)) != 0) { 793 async_answer_0(callid, EINVAL);794 async_answer_0(iid, EINVAL);786 ipc_answer_0(callid, EINVAL); 787 ipc_answer_0(iid, EINVAL); 795 788 return; 796 789 } … … 801 794 if (count != list_count(&namespaces_list)) { 802 795 fibril_mutex_unlock(&devices_list_mutex); 803 async_answer_0(callid, EOVERFLOW);804 async_answer_0(iid, EOVERFLOW);796 ipc_answer_0(callid, EOVERFLOW); 797 ipc_answer_0(iid, EOVERFLOW); 805 798 return; 806 799 } … … 809 802 if (desc == NULL) { 810 803 fibril_mutex_unlock(&devices_list_mutex); 811 async_answer_0(callid, ENOMEM);812 async_answer_0(iid, ENOMEM);804 ipc_answer_0(callid, ENOMEM); 805 ipc_answer_0(iid, ENOMEM); 813 806 return; 814 807 } … … 831 824 fibril_mutex_unlock(&devices_list_mutex); 832 825 833 async_answer_0(iid, retval);826 ipc_answer_0(iid, retval); 834 827 } 835 828 … … 842 835 size_t size; 843 836 if (!async_data_read_receive(&callid, &size)) { 844 async_answer_0(callid, EREFUSED);845 async_answer_0(iid, EREFUSED);837 ipc_answer_0(callid, EREFUSED); 838 ipc_answer_0(iid, EREFUSED); 846 839 return; 847 840 } 848 841 849 842 if ((size % sizeof(dev_desc_t)) != 0) { 850 async_answer_0(callid, EINVAL);851 async_answer_0(iid, EINVAL);843 ipc_answer_0(callid, EINVAL); 844 ipc_answer_0(iid, EINVAL); 852 845 return; 853 846 } … … 859 852 if (namespace == NULL) { 860 853 fibril_mutex_unlock(&devices_list_mutex); 861 async_answer_0(callid, ENOENT);862 async_answer_0(iid, ENOENT);854 ipc_answer_0(callid, ENOENT); 855 ipc_answer_0(iid, ENOENT); 863 856 return; 864 857 } … … 867 860 if (count != namespace->refcnt) { 868 861 fibril_mutex_unlock(&devices_list_mutex); 869 async_answer_0(callid, EOVERFLOW);870 async_answer_0(iid, EOVERFLOW);862 ipc_answer_0(callid, EOVERFLOW); 863 ipc_answer_0(iid, EOVERFLOW); 871 864 return; 872 865 } … … 875 868 if (desc == NULL) { 876 869 fibril_mutex_unlock(&devices_list_mutex); 877 async_answer_0(callid, ENOMEM);878 async_answer_0(iid, EREFUSED);870 ipc_answer_0(callid, ENOMEM); 871 ipc_answer_0(iid, EREFUSED); 879 872 return; 880 873 } … … 898 891 fibril_mutex_unlock(&devices_list_mutex); 899 892 900 async_answer_0(iid, retval);893 ipc_answer_0(iid, retval); 901 894 } 902 895 … … 917 910 if (!fnd) { 918 911 fibril_mutex_unlock(&null_devices_mutex); 919 async_answer_0(iid, ENOMEM);912 ipc_answer_0(iid, ENOMEM); 920 913 return; 921 914 } … … 927 920 if (dev_name == NULL) { 928 921 fibril_mutex_unlock(&null_devices_mutex); 929 async_answer_0(iid, ENOMEM);922 ipc_answer_0(iid, ENOMEM); 930 923 return; 931 924 } … … 935 928 if (device == NULL) { 936 929 fibril_mutex_unlock(&null_devices_mutex); 937 async_answer_0(iid, ENOMEM);930 ipc_answer_0(iid, ENOMEM); 938 931 return; 939 932 } … … 945 938 fibril_mutex_lock(&devices_list_mutex); 946 939 fibril_mutex_unlock(&null_devices_mutex); 947 async_answer_0(iid, ENOMEM);948 return; 949 } 950 951 li nk_initialize(&device->devices);952 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)); 953 946 954 947 /* Get unique device handle */ … … 959 952 device->name = dev_name; 960 953 961 /* 962 * Insert device into list of all devices and into null devices array. 963 * Insert device into a dummy list of null driver's devices so that it 964 * can be safely removed later. 965 */ 954 /* Insert device into list of all devices 955 and into null devices array */ 966 956 list_append(&device->devices, &devices_list); 967 list_append(&device->driver_devices, &dummy_null_driver_devices);968 957 null_devices[i] = device; 969 958 … … 971 960 fibril_mutex_unlock(&null_devices_mutex); 972 961 973 async_answer_1(iid, EOK, (sysarg_t) i);962 ipc_answer_1(iid, EOK, (sysarg_t) i); 974 963 } 975 964 … … 978 967 sysarg_t i = IPC_GET_ARG1(*icall); 979 968 if (i >= NULL_DEVICES) { 980 async_answer_0(iid, ELIMIT);969 ipc_answer_0(iid, ELIMIT); 981 970 return; 982 971 } … … 986 975 if (null_devices[i] == NULL) { 987 976 fibril_mutex_unlock(&null_devices_mutex); 988 async_answer_0(iid, ENOENT);977 ipc_answer_0(iid, ENOENT); 989 978 return; 990 979 } … … 997 986 998 987 fibril_mutex_unlock(&null_devices_mutex); 999 async_answer_0(iid, EOK);988 ipc_answer_0(iid, EOK); 1000 989 } 1001 990 … … 1023 1012 { 1024 1013 /* Accept connection */ 1025 async_answer_0(iid, EOK);1014 ipc_answer_0(iid, EOK); 1026 1015 1027 1016 devmap_driver_t *driver = devmap_driver_register(); … … 1040 1029 case DEVMAP_DRIVER_UNREGISTER: 1041 1030 if (NULL == driver) 1042 async_answer_0(callid, ENOENT);1031 ipc_answer_0(callid, ENOENT); 1043 1032 else 1044 async_answer_0(callid, EOK);1033 ipc_answer_0(callid, EOK); 1045 1034 break; 1046 1035 case DEVMAP_DEVICE_REGISTER: … … 1059 1048 break; 1060 1049 default: 1061 async_answer_0(callid, ENOENT);1050 ipc_answer_0(callid, ENOENT); 1062 1051 } 1063 1052 } … … 1078 1067 { 1079 1068 /* Accept connection */ 1080 async_answer_0(iid, EOK);1069 ipc_answer_0(iid, EOK); 1081 1070 1082 1071 bool cont = true; … … 1117 1106 break; 1118 1107 default: 1119 async_answer_0(callid, ENOENT);1108 ipc_answer_0(callid, ENOENT); 1120 1109 } 1121 1110 } … … 1141 1130 default: 1142 1131 /* No such interface */ 1143 async_answer_0(iid, ENOENT);1132 ipc_answer_0(iid, ENOENT); 1144 1133 } 1145 1134 } … … 1161 1150 1162 1151 /* Register device mapper at naming service */ 1163 if (service_register(SERVICE_DEVMAP) != EOK) 1152 sysarg_t phonead; 1153 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0) 1164 1154 return -1; 1165 1155
Note:
See TracChangeset
for help on using the changeset viewer.