Changeset 23 for trunk/kernel/kern/rpc.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/rpc.c
r16 r23 2 2 * rpc.c - RPC related operations implementation. 3 3 * 4 * Authors Mohamed Lamine Karaoui (2015) 5 * Alain Greiner (2016) 4 * Author Alain Greiner (2016,2017) 6 5 * 7 6 * Copyright (c) UPMC Sorbonne Universites … … 40 39 #include <vfs.h> 41 40 #include <fatfs.h> 41 #include <signal.h> 42 42 #include <dev_icu.h> 43 43 #include <rpc.h> … … 55 55 &rpc_thread_user_create_server, // 4 56 56 &rpc_thread_kernel_create_server, // 5 57 &rpc_ undefined,// 657 &rpc_signal_rise_server, // 6 58 58 &rpc_undefined, // 7 59 59 &rpc_undefined, // 8 … … 64 64 &rpc_vfs_dentry_create_server, // 12 65 65 &rpc_vfs_dentry_destroy_server, // 13 66 &rpc_ undefined,// 1467 &rpc_ undefined,// 1568 &rpc_ undefined,// 1666 &rpc_vfs_file_create_server, // 14 67 &rpc_vfs_file_destroy_server, // 15 68 &rpc_fatfs_get_cluster_server, // 16 69 69 &rpc_undefined, // 17 70 70 &rpc_undefined, // 18 … … 73 73 &rpc_vmm_get_ref_vseg_server, // 20 74 74 &rpc_vmm_get_pte_server, // 21 75 &rpc_ semaphore_alloc_server,// 2276 &rpc_ semaphore_free_server,// 2375 &rpc_kcm_alloc_server, // 22 76 &rpc_kcm_free_server, // 23 77 77 &rpc_mapper_move_server, // 24 78 78 &rpc_undefined, // 25 … … 81 81 &rpc_undefined, // 28 82 82 &rpc_undefined, // 29 83 84 &rpc_fatfs_get_cluster_server // 3085 83 }; 86 84 … … 93 91 94 92 ///////////////////////////////////////////////////////////////////////////////////////// 95 // 93 // [0] Marshaling functions attached to RPC_PMEM_GET_PAGES 96 94 ///////////////////////////////////////////////////////////////////////////////////////// 97 95 … … 150 148 151 149 ///////////////////////////////////////////////////////////////////////////////////////// 152 // 150 // [1] Marshaling functions attached to RPC_PROCESS_PID_ALLOC 153 151 ///////////////////////////////////////////////////////////////////////////////////////// 154 152 … … 207 205 208 206 ///////////////////////////////////////////////////////////////////////////////////////// 209 // 207 // [2] Marshaling functions attached to RPC_PROCESS_EXEC 210 208 ///////////////////////////////////////////////////////////////////////////////////////// 211 209 … … 265 263 266 264 ///////////////////////////////////////////////////////////////////////////////////////// 267 // 265 // [3] Marshaling functions attached to RPC_PROCESS_KILL 268 266 ///////////////////////////////////////////////////////////////////////////////////////// 269 267 … … 272 270 { 273 271 // only reference cluster can send this RPC 274 if( !process->is_ref)272 if( GET_CXY( process->ref_xp ) != local_cxy ) 275 273 { 276 274 printk("PANIC in %s : caller is not the reference process\n", __FUNCTION__ ); … … 334 332 335 333 ///////////////////////////////////////////////////////////////////////////////////////// 336 // 334 // [4] Marshaling functions attached to RPC_THREAD_USER_CREATE 337 335 ///////////////////////////////////////////////////////////////////////////////////////// 338 336 339 337 ///////////////////////////////////////////////////////// 340 338 void rpc_thread_user_create_client( cxy_t cxy, 339 pid_t pid, // in 340 void * start_func, // in 341 void * start_arg, // in 341 342 pthread_attr_t * attr, // in 342 343 xptr_t * thread_xp, // out … … 356 357 357 358 // set input arguments in RPC descriptor 358 rpc.args[0] = (uint64_t)(intptr_t)attr; 359 rpc.args[0] = (uint64_t)pid; 360 rpc.args[1] = (uint64_t)(intptr_t)start_func; 361 rpc.args[2] = (uint64_t)(intptr_t)start_arg; 362 rpc.args[3] = (uint64_t)(intptr_t)attr; 359 363 360 364 // register RPC request in remote RPC fifo … … 362 366 363 367 // get output arguments from RPC descriptor 364 *thread_xp = (xptr_t)rpc.args[ 1];365 *error = (error_t)rpc.args[ 2];368 *thread_xp = (xptr_t)rpc.args[4]; 369 *error = (error_t)rpc.args[5]; 366 370 } 367 371 … … 373 377 thread_t * thread_ptr; // local pointer on thread descriptor 374 378 xptr_t thread_xp; // extended pointer on thread descriptor 379 375 380 pid_t pid; // process identifier 376 process_t * process; // local pointer on process descriptor 377 vseg_t * vseg; // local pointer on stack vseg 378 379 error_t error = 0; 381 void * start_func; 382 void * start_arg; 383 error_t error; 380 384 381 385 // get client cluster identifier and pointer on RPC descriptor … … 384 388 385 389 // get pointer on attributes structure in client cluster from RPC descriptor 386 attr_ptr = (pthread_attr_t *)(intptr_t)hal_remote_lwd( XPTR(client_cxy , &desc->args[0]) ); 390 391 // get input arguments from RPC descriptor 392 pid = (pid_t) hal_remote_lwd(XPTR(client_cxy , &desc->args[0])); 393 start_func = (void *)(intptr_t) hal_remote_lwd(XPTR(client_cxy , &desc->args[1])); 394 start_arg = (void *)(intptr_t) hal_remote_lwd(XPTR(client_cxy , &desc->args[2])); 395 attr_ptr = (pthread_attr_t *)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[3])); 387 396 388 397 // makes a local copy of attributes structure … … 391 400 sizeof(pthread_attr_t) ); 392 401 393 if( attr_copy.cxy != local_cxy ) 394 { 395 printk("\n[PANIC] in %s : target cluster = %X / local_cluster = %x\n", 396 __FUNCTION__ , attr_copy.cxy , local_cxy ); 397 hal_core_sleep(); 398 } 399 400 // get local process descriptor 401 pid = attr_copy.pid; 402 process = cluster_get_local_process_from_pid( pid ); 403 404 if( process == NULL ) 405 { 406 printk("\n[ERROR] in %s : no process descriptor in cluster %x for pid = %x\n", 407 __FUNCTION__ , local_cxy , pid ); 408 error = ENOMEM; 409 410 } 411 412 // allocate a stack from local VMM 413 vseg = vmm_create_vseg( process, 414 0, 415 0, 416 VSEG_TYPE_STACK ); 417 if( vseg == NULL ) 418 { 419 printk("\n[ERROR] in %s : cannot create stack vseg in cluster %x for pid %x\n", 420 __FUNCTION__ , local_cxy , pid ); 421 error = ENOMEM; 422 } 423 424 // create thread in local cluster 425 if( thread_user_create( &thread_ptr, 426 &attr_copy, 427 vseg->min, 428 vseg->max - vseg->min ) ) error = ENOMEM; 429 402 assert( (attr_copy.cxy == local_cxy) , __FUNCTION__ , "bad target cluster\n" ); 403 404 // call kernel function 405 error = thread_user_create( pid, 406 start_func, 407 start_arg, 408 &attr_copy, 409 &thread_ptr ); 430 410 431 411 // set output arguments … … 436 416 437 417 ///////////////////////////////////////////////////////////////////////////////////////// 438 // 418 // [5] Marshaling functions attached to RPC_THREAD_KERNEL_CREATE 439 419 ///////////////////////////////////////////////////////////////////////////////////////// 440 420 … … 502 482 503 483 ///////////////////////////////////////////////////////////////////////////////////////// 504 // Marshaling functions attached to RPC_VFS_INODE_CREATE 484 // [6] Marshaling functions attached to RPC_SIGNAL_RISE 485 ///////////////////////////////////////////////////////////////////////////////////////// 486 487 ///////////////////////////////////////////// 488 void rpc_signal_rise_client( cxy_t cxy, 489 process_t * process, // in 490 uint32_t sig_id ) // in 491 { 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 } 498 499 // initialise RPC descriptor header 500 rpc_desc_t rpc; 501 rpc.index = RPC_SIGNAL_RISE; 502 rpc.response = 1; 503 504 // set input arguments in RPC descriptor 505 rpc.args[0] = (uint64_t)(intptr_t)process; 506 rpc.args[1] = (uint64_t)sig_id; 507 508 // register RPC request in remote RPC fifo 509 rpc_send_sync( cxy , &rpc ); 510 } 511 512 //////////////////////////////////////// 513 void rpc_signal_rise_server( xptr_t xp ) 514 { 515 process_t * process; // local pointer on process descriptor 516 uint32_t sig_id; // signal index 517 518 // get client cluster identifier and pointer on RPC descriptor 519 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 520 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 521 522 // get attributes from RPC descriptor 523 process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 524 sig_id = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 525 526 // call local kernel function 527 signal_rise( process , sig_id ); 528 } 529 530 ///////////////////////////////////////////////////////////////////////////////////////// 531 // [10] Marshaling functions attached to RPC_VFS_INODE_CREATE 505 532 ///////////////////////////////////////////////////////////////////////////////////////// 506 533 … … 508 535 void rpc_vfs_inode_create_client( cxy_t cxy, 509 536 xptr_t dentry_xp, // in 510 uint32_t type, // in 537 uint32_t fs_type, // in 538 uint32_t inode_type, // in 511 539 uint32_t attr, // in 512 uint32_t mode,// in540 uint32_t rights, // in 513 541 uint32_t uid, // in 514 542 uint32_t gid, // in … … 530 558 // set input arguments in RPC descriptor 531 559 rpc.args[0] = (uint64_t)dentry_xp; 532 rpc.args[1] = (uint64_t)type; 533 rpc.args[2] = (uint64_t)attr; 534 rpc.args[3] = (uint64_t)mode; 535 rpc.args[4] = (uint64_t)uid; 536 rpc.args[5] = (uint64_t)gid; 560 rpc.args[1] = (uint64_t)fs_type; 561 rpc.args[2] = (uint64_t)inode_type; 562 rpc.args[3] = (uint64_t)attr; 563 rpc.args[4] = (uint64_t)rights; 564 rpc.args[5] = (uint64_t)uid; 565 rpc.args[6] = (uint64_t)gid; 537 566 538 567 // register RPC request in remote RPC fifo (blocking function) … … 540 569 541 570 // get output values from RPC descriptor 542 *inode_xp = (xptr_t)rpc.args[ 6];543 *error = (error_t)rpc.args[ 7];571 *inode_xp = (xptr_t)rpc.args[7]; 572 *error = (error_t)rpc.args[8]; 544 573 } 545 574 … … 548 577 { 549 578 xptr_t dentry_xp; 550 uint32_t type; 579 uint32_t fs_type; 580 uint32_t inode_type; 551 581 uint32_t attr; 552 uint32_t mode;582 uint32_t rights; 553 583 uint32_t uid; 554 584 uint32_t gid; … … 561 591 562 592 // get input arguments from client rpc descriptor 563 dentry_xp = (xptr_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 564 type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 565 attr = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 566 mode = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) ); 567 uid = (uid_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) ); 568 gid = (gid_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[5] ) ); 593 dentry_xp = (xptr_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 594 fs_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 595 inode_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 596 attr = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) ); 597 rights = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) ); 598 uid = (uid_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[5] ) ); 599 gid = (gid_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[6] ) ); 569 600 570 601 // call local kernel function 571 602 error = vfs_inode_create( dentry_xp, 572 type, 603 fs_type, 604 inode_type, 573 605 attr, 574 mode,606 rights, 575 607 uid, 576 608 gid, … … 578 610 579 611 // set output arguments 580 hal_remote_swd( XPTR( client_cxy , &desc->args[ 6] ) , (uint64_t)inode_xp );581 hal_remote_swd( XPTR( client_cxy , &desc->args[ 7] ) , (uint64_t)error );582 } 583 584 ///////////////////////////////////////////////////////////////////////////////////////// 585 // 612 hal_remote_swd( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)inode_xp ); 613 hal_remote_swd( XPTR( client_cxy , &desc->args[8] ) , (uint64_t)error ); 614 } 615 616 ///////////////////////////////////////////////////////////////////////////////////////// 617 // [11] Marshaling functions attached to RPC_VFS_INODE_DESTROY 586 618 ///////////////////////////////////////////////////////////////////////////////////////// 587 619 … … 626 658 627 659 ///////////////////////////////////////////////////////////////////////////////////////// 628 // 660 // [12] Marshaling functions attached to RPC_VFS_DENTRY_CREATE 629 661 ///////////////////////////////////////////////////////////////////////////////////////// 630 662 … … 701 733 702 734 ///////////////////////////////////////////////////////////////////////////////////////// 703 // 735 // [13] Marshaling functions attached to RPC_VFS_DENTRY_DESTROY 704 736 ///////////////////////////////////////////////////////////////////////////////////////// 705 737 … … 745 777 746 778 ///////////////////////////////////////////////////////////////////////////////////////// 747 // Marshaling functions attached to RPC_VMM_GET_REF_VSEG 779 // [14] Marshaling functions attached to RPC_VFS_FILE_CREATE 780 ///////////////////////////////////////////////////////////////////////////////////////// 781 782 ////////////////////////////////////////////////////////////// 783 void rpc_vfs_file_create_client( cxy_t cxy, 784 struct vfs_inode_s * inode, // in 785 uint32_t file_attr, // in 786 xptr_t * file_xp, // out 787 error_t * error ) // out 788 { 789 // RPC must be remote 790 if( cxy == local_cxy ) 791 { 792 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 793 hal_core_sleep(); 794 } 795 796 // initialise RPC descriptor header 797 rpc_desc_t rpc; 798 rpc.index = RPC_VFS_FILE_CREATE; 799 rpc.response = 1; 800 801 // set input arguments in RPC descriptor 802 rpc.args[0] = (uint64_t)(intptr_t)inode; 803 rpc.args[1] = (uint64_t)file_attr; 804 805 // register RPC request in remote RPC fifo (blocking function) 806 rpc_send_sync( cxy , &rpc ); 807 808 // get output values from RPC descriptor 809 *file_xp = (xptr_t)rpc.args[2]; 810 *error = (error_t)rpc.args[3]; 811 } 812 813 //////////////////////////////////////////// 814 void rpc_vfs_file_create_server( xptr_t xp ) 815 { 816 uint32_t file_attr; 817 vfs_inode_t * inode; 818 xptr_t file_xp; 819 error_t error; 820 821 // get client cluster identifier and pointer on RPC descriptor 822 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 823 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 824 825 // get arguments "file_attr" and "inode" from client RPC descriptor 826 inode = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 827 file_attr = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 828 829 // call local kernel function 830 error = vfs_file_create( inode, 831 file_attr, 832 &file_xp ); 833 834 // set output arguments 835 hal_remote_swd( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)file_xp ); 836 hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error ); 837 } 838 839 ///////////////////////////////////////////////////////////////////////////////////////// 840 // [15] Marshaling functions attached to RPC_VFS_FILE_DESTROY 841 ///////////////////////////////////////////////////////////////////////////////////////// 842 843 /////////////////////////////////////////////////// 844 void rpc_vfs_file_destroy_client( cxy_t cxy, 845 vfs_file_t * file ) 846 { 847 // RPC must be remote 848 if( cxy == local_cxy ) 849 { 850 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 851 hal_core_sleep(); 852 } 853 854 // initialise RPC descriptor header 855 rpc_desc_t rpc; 856 rpc.index = RPC_VFS_FILE_DESTROY; 857 rpc.response = 1; 858 859 // set input arguments in RPC descriptor 860 rpc.args[0] = (uint64_t)(intptr_t)file; 861 862 // register RPC request in remote RPC fifo (blocking function) 863 rpc_send_sync( cxy , &rpc ); 864 } 865 866 ///////////////////////////////////////////// 867 void rpc_vfs_file_destroy_server( xptr_t xp ) 868 { 869 vfs_file_t * file; 870 871 // get client cluster identifier and pointer on RPC descriptor 872 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 873 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 874 875 // get arguments "dentry" from client RPC descriptor 876 file = (vfs_file_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 877 878 // call local kernel function 879 vfs_file_destroy( file ); 880 } 881 882 ///////////////////////////////////////////////////////////////////////////////////////// 883 // [16] Marshaling functions attached to RPC_FATFS_GET_CLUSTER 884 ///////////////////////////////////////////////////////////////////////////////////////// 885 886 ////////////////////////////////////////////////// 887 void rpc_fatfs_get_cluster_client( cxy_t cxy, 888 mapper_t * mapper, // in 889 uint32_t first, // in 890 uint32_t page, // in 891 uint32_t * cluster, // out 892 error_t * error ) // out 893 { 894 // RPC must be remote 895 if( cxy == local_cxy ) 896 { 897 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 898 hal_core_sleep(); 899 } 900 901 // initialise RPC descriptor header 902 rpc_desc_t rpc; 903 rpc.index = RPC_FATFS_GET_CLUSTER; 904 rpc.response = 1; 905 906 // set input arguments in RPC descriptor 907 rpc.args[0] = (uint64_t)(intptr_t)mapper; 908 rpc.args[1] = (uint64_t)first; 909 rpc.args[2] = (uint64_t)page; 910 911 // register RPC request in remote RPC fifo 912 rpc_send_sync( cxy , &rpc ); 913 914 // get output argument from rpc descriptor 915 *cluster = (uint32_t)rpc.args[3]; 916 *error = (error_t)rpc.args[4]; 917 } 918 919 ////////////////////////////////////////////// 920 void rpc_fatfs_get_cluster_server( xptr_t xp ) 921 { 922 mapper_t * mapper; 923 uint32_t first; 924 uint32_t page; 925 uint32_t cluster; 926 error_t error; 927 928 // get client cluster identifier and pointer on RPC descriptor 929 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 930 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 931 932 // get input arguments 933 mapper = (mapper_t *)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) ); 934 first = (uint32_t) hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) ); 935 page = (uint32_t) hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) ); 936 937 // call the kernel function 938 error = fatfs_get_cluster( mapper , first , page , &cluster ); 939 940 // set output argument 941 hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)cluster ); 942 hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error ); 943 } 944 945 ///////////////////////////////////////////////////////////////////////////////////////// 946 // [20] Marshaling functions attached to RPC_VMM_GET_REF_VSEG 748 947 ///////////////////////////////////////////////////////////////////////////////////////// 749 948 … … 804 1003 805 1004 ///////////////////////////////////////////////////////////////////////////////////////// 806 // 1005 // [21] Marshaling functions attached to RPC_VMM_GET_PTE 807 1006 ///////////////////////////////////////////////////////////////////////////////////////// 808 1007 … … 867 1066 868 1067 ///////////////////////////////////////////////////////////////////////////////////////// 869 // Marshaling functions attached to RPC_SEMAPHORE_ALLOC 870 ///////////////////////////////////////////////////////////////////////////////////////// 871 872 ////////////////////////////////////////////// 873 void rpc_semaphore_alloc_client( cxy_t cxy, 874 xptr_t * sem_xp ) // out 1068 // [22] Marshaling functions attached to RPC_KCM_ALLOC 1069 ///////////////////////////////////////////////////////////////////////////////////////// 1070 1071 ////////////////////////////////////////// 1072 void rpc_kcm_alloc_client( cxy_t cxy, 1073 uint32_t kmem_type, // in 1074 xptr_t * buf_xp ) // out 875 1075 { 876 1076 // RPC must be remote … … 886 1086 rpc.response = 1; 887 1087 1088 // set input arguments in RPC descriptor 1089 rpc.args[0] = (uint64_t)kmem_type; 1090 888 1091 // register RPC request in remote RPC fifo 889 1092 rpc_send_sync( cxy , &rpc ); 890 1093 891 1094 // get output arguments from RPC descriptor 892 * sem_xp = (xptr_t)rpc.args[0];893 } 894 895 ////////////////////////////////////// //////896 void rpc_ semaphore_alloc_server( xptr_t xp )1095 *buf_xp = (xptr_t)rpc.args[1]; 1096 } 1097 1098 ////////////////////////////////////// 1099 void rpc_kcm_alloc_server( xptr_t xp ) 897 1100 { 898 1101 // get client cluster identifier and pointer on RPC descriptor … … 900 1103 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 901 1104 902 // allocates memory for semaphore 1105 // get input argument "kmem_type" from client RPC descriptor 1106 uint32_t kmem_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 1107 1108 // allocates memory for kcm 903 1109 kmem_req_t req; 904 req.type = KMEM_SEM;1110 req.type = kmem_type; 905 1111 req.flags = AF_ZERO; 906 remote_sem_t * sem_ptr = kmem_alloc( &req );1112 void * buf_ptr = kmem_alloc( &req ); 907 1113 908 1114 // set output argument 909 xptr_t sem_xp = XPTR( local_cxy , sem_ptr );910 hal_remote_swd( XPTR( client_cxy , &desc->args[ 0] ) , (uint64_t)sem_xp );1115 xptr_t buf_xp = XPTR( local_cxy , buf_ptr ); 1116 hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)buf_xp ); 911 1117 } 912 1118 913 1119 ///////////////////////////////////////////////////////////////////////////////////////// 914 // Marshaling functions attached to RPC_SEMAPHORE_FREE 915 ///////////////////////////////////////////////////////////////////////////////////////// 916 917 /////////////////////////////////////////////////// 918 void rpc_semaphore_free_client( cxy_t cxy, 919 remote_sem_t * sem ) // in 1120 // [23] Marshaling functions attached to RPC_KCM_FREE 1121 ///////////////////////////////////////////////////////////////////////////////////////// 1122 1123 ///////////////////////////////////////// 1124 void rpc_kcm_free_client( cxy_t cxy, 1125 void * buf, // in 1126 uint32_t kmem_type ) // in 920 1127 { 921 1128 // RPC must be remote … … 932 1139 933 1140 // set input arguments in RPC descriptor 934 rpc.args[0] = (uint64_t)(intptr_t)sem; 1141 rpc.args[0] = (uint64_t)(intptr_t)buf; 1142 rpc.args[1] = (uint64_t)kmem_type; 935 1143 936 1144 // register RPC request in remote RPC fifo … … 938 1146 } 939 1147 940 ///////////////////////////////////// //////941 void rpc_ semaphore_free_server( xptr_t xp )1148 ///////////////////////////////////// 1149 void rpc_kcm_free_server( xptr_t xp ) 942 1150 { 943 1151 // get client cluster identifier and pointer on RPC descriptor … … 945 1153 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 946 1154 947 // get input argument "sem_ptr" from client RPC descriptor 948 void * sem = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 1155 // get input arguments "buf" and "kmem_type" from client RPC descriptor 1156 void * buf = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 1157 uint32_t kmem_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 949 1158 950 1159 // releases memory 951 1160 kmem_req_t req; 952 req.type = KMEM_SEM;953 req.ptr = sem;954 kmem_free( &req);1161 req.type = kmem_type; 1162 req.ptr = buf; 1163 kmem_free( &req ); 955 1164 } 956 1165 957 1166 ///////////////////////////////////////////////////////////////////////////////////////// 958 // Marshaling functions attached to RPC_MAPPER_MOVE 959 ///////////////////////////////////////////////////////////////////////////////////////// 960 961 ////////////////////////////////////////////// 962 void rpc_mapper_move_client( cxy_t cxy, 963 mapper_t * mapper, // in 964 bool_t read, // in 965 uint32_t nb_frags, // in 966 fragment_t * frags, // in 967 error_t * error ) // out 968 { 969 // RPC must be remote 970 if( cxy == local_cxy ) 971 { 972 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 1167 // [24] Marshaling functions attached to RPC_MAPPER_MOVE 1168 ///////////////////////////////////////////////////////////////////////////////////////// 1169 1170 /////////////////////////////////////////// 1171 void rpc_mapper_move_client( cxy_t cxy, 1172 mapper_t * mapper, // in 1173 uint32_t to_buffer, // in 1174 uint32_t file_offset, // in 1175 void * buffer, // in 1176 uint32_t size, // in 1177 error_t * error ) // out 1178 { 1179 // RPC must be remote 1180 if( cxy == local_cxy ) 1181 { 1182 printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ ); 973 1183 hal_core_sleep(); 974 1184 } … … 981 1191 // set input arguments in RPC descriptor 982 1192 rpc.args[0] = (uint64_t)(intptr_t)mapper; 983 rpc.args[1] = (uint64_t)read; 984 rpc.args[2] = (uint64_t)nb_frags; 985 rpc.args[3] = (uint64_t)(intptr_t)frags; 986 987 // register RPC request in remote RPC fifo 988 rpc_send_sync( cxy , &rpc ); 989 990 // get output argument from rpc descriptor 991 *error = (error_t)rpc.args[4]; 1193 rpc.args[1] = (uint64_t)to_buffer; 1194 rpc.args[2] = (uint64_t)file_offset; 1195 rpc.args[3] = (uint64_t)(intptr_t)buffer; 1196 rpc.args[4] = (uint64_t)size; 1197 1198 // register RPC request in remote RPC fifo (blocking function) 1199 rpc_send_sync( cxy , &rpc ); 1200 1201 // get output values from RPC descriptor 1202 *error = (error_t)rpc.args[5]; 992 1203 } 993 1204 … … 995 1206 void rpc_mapper_move_server( xptr_t xp ) 996 1207 { 997 mapper_t * mapper; 998 bool_t read; 999 uint32_t nb; 1000 void * frags; 1001 error_t error; 1002 1003 // get client cluster identifier and pointer on RPC descriptor 1004 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 1005 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 1006 1007 // get input arguments 1008 mapper = (mapper_t*)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) ); 1009 read = (bool_t) hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) ); 1010 nb = (uint32_t) hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) ); 1011 frags = (void*)(intptr_t) hal_remote_lpt( XPTR( client_cxy , &desc->args[3] ) ); 1012 1013 // call the mapper_move_fragments() function 1014 error = mapper_move_fragments( mapper , read , nb , XPTR( client_cxy , frags ) ); 1015 1016 // set output argument 1017 hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error ); 1018 } 1019 1020 ///////////////////////////////////////////////////////////////////////////////////////// 1021 // Marshaling functions attached to RPC_FATFS_GET_CLUSTER 1022 ///////////////////////////////////////////////////////////////////////////////////////// 1023 1024 ////////////////////////////////////////////////// 1025 void rpc_fatfs_get_cluster_client( cxy_t cxy, 1026 mapper_t * mapper, // in 1027 uint32_t first, // in 1028 uint32_t page, // in 1029 uint32_t * cluster, // out 1030 error_t * error ) // out 1031 { 1032 // RPC must be remote 1033 if( cxy == local_cxy ) 1034 { 1035 printk("PANIC in %s : target is not remote\n", __FUNCTION__ ); 1036 hal_core_sleep(); 1037 } 1038 1039 // initialise RPC descriptor header 1040 rpc_desc_t rpc; 1041 rpc.index = RPC_FATFS_GET_CLUSTER; 1042 rpc.response = 1; 1043 1044 // set input arguments in RPC descriptor 1045 rpc.args[0] = (uint64_t)(intptr_t)mapper; 1046 rpc.args[1] = (uint64_t)first; 1047 rpc.args[2] = (uint64_t)page; 1048 1049 // register RPC request in remote RPC fifo 1050 rpc_send_sync( cxy , &rpc ); 1051 1052 // get output argument from rpc descriptor 1053 *cluster = (uint32_t)rpc.args[3]; 1054 *error = (error_t)rpc.args[4]; 1055 } 1056 1057 ////////////////////////////////////////////// 1058 void rpc_fatfs_get_cluster_server( xptr_t xp ) 1059 { 1060 mapper_t * mapper; 1061 uint32_t first; 1062 uint32_t page; 1063 uint32_t cluster; 1064 error_t error; 1065 1066 // get client cluster identifier and pointer on RPC descriptor 1067 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 1068 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 1069 1070 // get input arguments 1071 mapper = (mapper_t*)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) ); 1072 first = (uint32_t) hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) ); 1073 page = (uint32_t) hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) ); 1074 1075 // call the kernel function 1076 error = fatfs_get_cluster( mapper , first , page , &cluster ); 1077 1078 // set output argument 1079 hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)cluster ); 1080 hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error ); 1208 mapper_t * mapper; 1209 uint32_t to_buffer; 1210 uint32_t file_offset; 1211 void * buffer; 1212 uint32_t size; 1213 error_t error; 1214 1215 // get client cluster identifier and pointer on RPC descriptor 1216 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 1217 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 1218 1219 // get arguments from client RPC descriptor 1220 mapper = (mapper_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 1221 to_buffer = hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 1222 file_offset = hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 1223 buffer = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) ); 1224 size = hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) ); 1225 1226 // call local kernel function 1227 error = mapper_move( mapper, 1228 to_buffer, 1229 file_offset, 1230 buffer, 1231 size ); 1232 1233 // set output argument to client RPC descriptor 1234 hal_remote_swd( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error ); 1081 1235 } 1082 1236
Note: See TracChangeset
for help on using the changeset viewer.