Changeset 238 for trunk/kernel/kern
- Timestamp:
- Jul 19, 2017, 3:31:39 PM (7 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/rpc.c
r188 r238 66 66 &rpc_vfs_file_create_server, // 14 67 67 &rpc_vfs_file_destroy_server, // 15 68 &rpc_ fatfs_get_cluster_server,// 1669 &rpc_ undefined,// 1770 &rpc_ undefined,// 1868 &rpc_vfs_inode_load_server, // 16 69 &rpc_vfs_mapper_load_all_server, // 17 70 &rpc_fatfs_get_cluster_server, // 18 71 71 &rpc_undefined, // 19 72 72 … … 100 100 uint32_t * ppn ) // out 101 101 { 102 // any RPC must be remote 103 if( cxy == local_cxy ) 104 { 105 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 106 hal_core_sleep(); 107 } 102 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 108 103 109 104 // initialise RPC descriptor header … … 157 152 pid_t * pid ) // out 158 153 { 159 // RPC must be remote 160 if( cxy == local_cxy ) 161 { 162 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 163 hal_core_sleep(); 164 } 154 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 165 155 166 156 // initialise RPC descriptor header … … 213 203 error_t * error ) // out 214 204 { 215 // RPC must be remote 216 if( cxy == local_cxy ) 217 { 218 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 219 hal_core_sleep(); 220 } 205 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 221 206 222 207 // initialise RPC descriptor header … … 270 255 { 271 256 // only reference cluster can send this RPC 272 if( GET_CXY( process->ref_xp ) != local_cxy ) 273 { 274 printk("PANIC in %s : caller is not the reference process\n", __FUNCTION__ ); 275 hal_core_sleep(); 276 } 257 assert( (GET_CXY( process->ref_xp ) == local_cxy) , __FUNCTION__ , 258 "caller must be reference process cluster\n"); 277 259 278 260 // get local process index in reference cluster … … 344 326 error_t * error ) // out 345 327 { 346 // RPC must be remote 347 if( cxy == local_cxy ) 348 { 349 printk("\n[PANIC] in %s : target is not remote\n", __FUNCTION__ ); 350 hal_core_sleep(); 351 } 328 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 352 329 353 330 // initialise RPC descriptor header … … 427 404 error_t * error ) // out 428 405 { 429 // RPC must be remote 430 if( cxy == local_cxy ) 431 { 432 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 433 hal_core_sleep(); 434 } 406 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 435 407 436 408 // initialise RPC descriptor header … … 490 462 uint32_t sig_id ) // in 491 463 { 492 // RPC must be remote 493 if( cxy == local_cxy ) 494 { 495 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 496 hal_core_sleep(); 497 } 464 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 498 465 499 466 // initialise RPC descriptor header … … 545 512 error_t * error ) // out 546 513 { 547 // RPC must be remote 548 if( cxy == local_cxy ) 549 { 550 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 551 hal_core_sleep(); 552 } 514 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 553 515 554 516 // initialise RPC descriptor header … … 627 589 struct vfs_inode_s * inode ) 628 590 { 629 // RPC must be remote 630 if( cxy == local_cxy ) 631 { 632 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 633 hal_core_sleep(); 634 } 591 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 635 592 636 593 // initialise RPC descriptor header … … 674 631 error_t * error ) // out 675 632 { 676 // RPC must be remote 677 if( cxy == local_cxy ) 678 { 679 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 680 hal_core_sleep(); 681 } 633 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 682 634 683 635 // initialise RPC descriptor header … … 689 641 rpc.args[0] = (uint64_t)type; 690 642 rpc.args[1] = (uint64_t)(intptr_t)name; 691 rpc.args[2] = (uint64_t)strlen( name ); 692 rpc.args[3] = (uint64_t)(intptr_t)parent; 643 rpc.args[2] = (uint64_t)(intptr_t)parent; 693 644 694 645 // register RPC request in remote RPC fifo (blocking function) … … 696 647 697 648 // get output values from RPC descriptor 698 *dentry_xp = (xptr_t)rpc.args[ 4];699 *error = (error_t)rpc.args[ 5];649 *dentry_xp = (xptr_t)rpc.args[3]; 650 *error = (error_t)rpc.args[4]; 700 651 } 701 652 … … 707 658 vfs_inode_t * parent; 708 659 xptr_t dentry_xp; 660 error_t error; 661 709 662 char name_copy[CONFIG_VFS_MAX_NAME_LENGTH]; 710 uint32_t length;711 error_t error;712 663 713 664 // get client cluster identifier and pointer on RPC descriptor … … 715 666 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 716 667 717 // get argument "name" & "length" from client RPC descriptor and makes a local copy 718 name = (char *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 719 length = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 720 hal_remote_memcpy( XPTR( local_cxy , name_copy ), 721 XPTR( client_cxy , name ), 722 length + 1 ); // +1 for the NUL char 723 724 // get arguments "type" and "parent" from client RPC descriptor 668 // get arguments "name", "type", and "parent" from client RPC descriptor 725 669 type = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 726 parent = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) ); 670 name = (char *)(intptr_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 671 parent = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 727 672 673 // makes a local copy of name 674 hal_remote_strcpy( XPTR( local_cxy , name_copy ), 675 XPTR( client_cxy , name ) ); 676 728 677 // call local kernel function 729 678 error = vfs_dentry_create( type, … … 733 682 734 683 // set output arguments 735 hal_remote_swd( XPTR( client_cxy , &desc->args[ 4] ) , (uint64_t)dentry_xp );736 hal_remote_swd( XPTR( client_cxy , &desc->args[ 5] ) , (uint64_t)error );684 hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)dentry_xp ); 685 hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error ); 737 686 } 738 687 … … 745 694 vfs_dentry_t * dentry ) 746 695 { 747 // RPC must be remote 748 if( cxy == local_cxy ) 749 { 750 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 751 hal_core_sleep(); 752 } 696 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 753 697 754 698 // initialise RPC descriptor header … … 792 736 error_t * error ) // out 793 737 { 794 // RPC must be remote 795 if( cxy == local_cxy ) 796 { 797 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 798 hal_core_sleep(); 799 } 738 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 800 739 801 740 // initialise RPC descriptor header … … 850 789 vfs_file_t * file ) 851 790 { 852 // RPC must be remote 853 if( cxy == local_cxy ) 854 { 855 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 856 hal_core_sleep(); 857 } 791 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 858 792 859 793 // initialise RPC descriptor header … … 886 820 887 821 ///////////////////////////////////////////////////////////////////////////////////////// 888 // [16] Marshaling functions attached to RPC_FATFS_GET_CLUSTER 822 // [16] Marshaling functions attached to RPC_VFS_INODE_LOAD 823 ///////////////////////////////////////////////////////////////////////////////////////// 824 825 ////////////////////////////////////////////////// 826 void rpc_vfs_inode_load_client( cxy_t cxy, 827 vfs_inode_t * parent_inode, // in 828 char * name, // in 829 xptr_t child_inode_xp, // in 830 error_t * error ) // out 831 { 832 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 833 834 // initialise RPC descriptor header 835 rpc_desc_t rpc; 836 rpc.index = RPC_VFS_INODE_LOAD; 837 rpc.response = 1; 838 839 // set input arguments in RPC descriptor 840 rpc.args[0] = (uint64_t)(intptr_t)parent_inode; 841 rpc.args[1] = (uint64_t)(intptr_t)name; 842 rpc.args[2] = (uint64_t)child_inode_xp; 843 844 // register RPC request in remote RPC fifo (blocking function) 845 rpc_send_sync( cxy , &rpc ); 846 847 // get output values from RPC descriptor 848 *error = (error_t)rpc.args[3]; 849 } 850 851 /////////////////////////////////////////// 852 void rpc_vfs_inode_load_server( xptr_t xp ) 853 { 854 error_t error; 855 vfs_inode_t * parent; 856 xptr_t child_xp; 857 char * name; 858 859 char name_copy[CONFIG_VFS_MAX_NAME_LENGTH]; 860 861 // get client cluster identifier and pointer on RPC descriptor 862 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 863 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 864 865 // get arguments "parent", "name", and "child_xp" 866 parent = (vfs_inode_t*)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[0])); 867 name = (char*)(intptr_t) hal_remote_lwd(XPTR(client_cxy , &desc->args[1])); 868 child_xp = (xptr_t) hal_remote_lwd(XPTR(client_cxy , &desc->args[2])); 869 870 // get name local copy 871 hal_remote_strcpy( XPTR( local_cxy , name_copy ) , 872 XPTR( client_cxy , name ) ); 873 874 // call the kernel function 875 error = vfs_inode_load( parent , name_copy , child_xp ); 876 877 // set output argument 878 hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 879 } 880 881 ///////////////////////////////////////////////////////////////////////////////////////// 882 // [17] Marshaling functions attached to RPC_VFS_MAPPER_LOAD_ALL 883 ///////////////////////////////////////////////////////////////////////////////////////// 884 885 /////////////////////////////////////////////////////// 886 void rpc_vfs_mapper_load_all_client( cxy_t cxy, 887 vfs_inode_t * inode, // in 888 error_t * error ) // out 889 { 890 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 891 892 // initialise RPC descriptor header 893 rpc_desc_t rpc; 894 rpc.index = RPC_VFS_INODE_LOAD; 895 rpc.response = 1; 896 897 // set input arguments in RPC descriptor 898 rpc.args[0] = (uint64_t)(intptr_t)inode; 899 900 // register RPC request in remote RPC fifo (blocking function) 901 rpc_send_sync( cxy , &rpc ); 902 903 // get output values from RPC descriptor 904 *error = (error_t)rpc.args[1]; 905 } 906 907 //////////////////////////////////////////////// 908 void rpc_vfs_mapper_load_all_server( xptr_t xp ) 909 { 910 error_t error; 911 vfs_inode_t * inode; 912 913 // get client cluster identifier and pointer on RPC descriptor 914 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 915 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 916 917 // get arguments "parent", "name", and "child_xp" 918 inode = (vfs_inode_t*)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[0])); 919 920 // call the kernel function 921 error = vfs_mapper_load_all( inode ); 922 923 // set output argument 924 hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 925 } 926 927 ///////////////////////////////////////////////////////////////////////////////////////// 928 // [18] Marshaling functions attached to RPC_FATFS_GET_CLUSTER 889 929 ///////////////////////////////////////////////////////////////////////////////////////// 890 930 … … 897 937 error_t * error ) // out 898 938 { 899 // RPC must be remote 900 if( cxy == local_cxy ) 901 { 902 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 903 hal_core_sleep(); 904 } 939 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 905 940 906 941 // initialise RPC descriptor header … … 958 993 xptr_t * vseg_xp ) // out 959 994 { 960 // RPC must be remote 961 if( cxy == local_cxy ) 962 { 963 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 964 hal_core_sleep(); 965 } 995 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 966 996 967 997 // initialise RPC descriptor header … … 1019 1049 error_t * error ) // out 1020 1050 { 1021 // RPC must be remote 1022 if( cxy == local_cxy ) 1023 { 1024 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 1025 hal_core_sleep(); 1026 } 1051 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 1027 1052 1028 1053 // initialise RPC descriptor header … … 1079 1104 xptr_t * buf_xp ) // out 1080 1105 { 1081 // RPC must be remote 1082 if( cxy == local_cxy ) 1083 { 1084 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 1085 hal_core_sleep(); 1086 } 1106 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 1087 1107 1088 1108 // initialise RPC descriptor header … … 1131 1151 uint32_t kmem_type ) // in 1132 1152 { 1133 // RPC must be remote 1134 if( cxy == local_cxy ) 1135 { 1136 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 1137 hal_core_sleep(); 1138 } 1153 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 1139 1154 1140 1155 // initialise RPC descriptor header … … 1182 1197 error_t * error ) // out 1183 1198 { 1184 // RPC must be remote 1185 if( cxy == local_cxy ) 1186 { 1187 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 1188 hal_core_sleep(); 1189 } 1199 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 1190 1200 1191 1201 // initialise RPC descriptor header -
trunk/kernel/kern/rpc.h
r188 r238 71 71 RPC_VFS_FILE_CREATE = 14, 72 72 RPC_VFS_FILE_DESTROY = 15, 73 RPC_FATFS_GET_CLUSTER = 16, 73 RPC_VFS_INODE_LOAD = 16, 74 RPC_VFS_MAPPER_LOAD_ALL = 17, 75 RPC_FATFS_GET_CLUSTER = 18, 74 76 75 77 RPC_VMM_GET_REF_VSEG = 20, … … 421 423 void rpc_vfs_file_destroy_server( xptr_t xp ); 422 424 423 /*********************************************************************************** 424 * [16] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" 425 /*********************************************************************************** 426 * [16] The RPC_VFS_LOAD_INODE calls the vfs_inode_load() kernel function in a 427 * remote cluster containing a parent inode directory to scan the associated 428 * mapper, find a directory entry, identified by its name, and update the remote 429 * child inode. 430 *********************************************************************************** 431 * @ cxy : server cluster identifier 432 * @ parent_inode : [in] local pointer on parent inode. 433 * @ name : [in] local pointer on child name (in client cluster). 434 * @ child_inode_xp : [in] extended pointer on child inode (in another cluster). 435 * @ error : [out] error status (0 if success). 436 **********************************************************************************/ 437 void rpc_vfs_inode_load_client( cxy_t cxy, 438 struct vfs_inode_s * parent_inode, 439 char * name, 440 xptr_t child_inode_xp, 441 error_t * error ); 442 443 void rpc_vfs_inode_load_server( xptr_t xp ); 444 445 /*********************************************************************************** 446 * [17] The RPC_VFS_MAPPER_LOAD_ALL calls the vfs_mapper_load_all() kernel function 447 * in a remote cluster containing an inode, to load all pages of the associated 448 * mapper from the file system on device. 449 *********************************************************************************** 450 * @ cxy : server cluster identifier 451 * @ inode : [in] local pointer on inode in server cluster. 452 * @ error : [out] error status (0 if success). 453 **********************************************************************************/ 454 void rpc_vfs_mapper_load_all_client( cxy_t cxy, 455 struct vfs_inode_s * inode, 456 error_t * error ); 457 458 void rpc_vfs_mapper_load_all_server( xptr_t xp ); 459 460 /*********************************************************************************** 461 * [18] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" 425 462 * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get 426 463 * from the mapper the local pointer on a given page.
Note: See TracChangeset
for help on using the changeset viewer.