Changeset 433 for trunk/kernel/kern/rpc.c
- Timestamp:
- Feb 14, 2018, 3:40:19 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/rpc.c
r428 r433 42 42 #include <rpc.h> 43 43 44 45 ///////////////////////////////////////////////////////////////////////////////////////// 46 // Debug macros for marshalling functions 47 ///////////////////////////////////////////////////////////////////////////////////////// 48 49 #if CONFIG_DEBUG_RPC_MARSHALING 50 51 #define RPC_DEBUG_ENTER \ 52 uint32_t cycle = (uint32_t)hal_get_cycles(); \ 53 if( cycle > CONFIG_DEBUG_RPC_MARSHALING ) \ 54 printk("\n[DBG] %s : enter thread %x on core[%x,%d] / cycle %d\n", \ 55 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, CURRENT_THREAD->core->lid , cycle ); 56 57 #define RPC_DEBUG_EXIT \ 58 cycle = (uint32_t)hal_get_cycles(); \ 59 if( cycle > CONFIG_DEBUG_RPC_MARSHALING ) \ 60 printk("\n[DBG] %s : exit thread %x on core[%x,%d] / cycle %d\n", \ 61 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, CURRENT_THREAD->core->lid , cycle ); 62 63 #else 64 65 #define RPC_DEBUG_ENTER 66 67 #define RPC_DEBUG_EXIT 68 69 #endif 70 44 71 ///////////////////////////////////////////////////////////////////////////////////////// 45 72 // array of function pointers (must be consistent with enum in rpc.h) … … 50 77 &rpc_pmem_get_pages_server, // 0 51 78 &rpc_pmem_release_pages_server, // 1 52 &rpc_ process_make_exec_server, // 279 &rpc_undefined, // 2 unused slot 53 80 &rpc_process_make_fork_server, // 3 54 &rpc_ process_make_exit_server, // 481 &rpc_undefined, // 4 unused slot 55 82 &rpc_process_make_kill_server, // 5 56 83 &rpc_thread_user_create_server, // 6 … … 68 95 &rpc_vfs_mapper_load_all_server, // 17 69 96 &rpc_fatfs_get_cluster_server, // 18 70 &rpc_undefined, // 19 97 &rpc_undefined, // 19 unused slot 71 98 72 99 &rpc_vmm_get_vseg_server, // 20 … … 497 524 498 525 ///////////////////////////////////////////////////////////////////////////////////////// 499 // [2] Marshaling functions attached to RPC_PROCESS_MAKE_EXEC (blocking) 500 ///////////////////////////////////////////////////////////////////////////////////////// 501 502 ///////////////////////////////////////////////////// 503 void rpc_process_make_exec_client( cxy_t cxy, 504 exec_info_t * info, // in 505 error_t * error ) // out 506 { 507 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 508 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 509 CURRENT_THREAD->core->lid , hal_time_stamp() ); 510 511 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 512 513 // initialise RPC descriptor header 514 rpc_desc_t rpc; 515 rpc.index = RPC_PROCESS_MAKE_EXEC; 516 rpc.response = 1; 517 rpc.blocking = true; 518 519 // set input arguments in RPC descriptor 520 rpc.args[0] = (uint64_t)(intptr_t)info; 521 522 // register RPC request in remote RPC fifo (blocking function) 523 rpc_send( cxy , &rpc ); 524 525 // get output arguments from RPC descriptor 526 *error = (error_t)rpc.args[1]; 527 528 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 529 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 530 CURRENT_THREAD->core->lid , hal_time_stamp() ); 531 } 532 533 ////////////////////////////////////////////// 534 void rpc_process_make_exec_server( xptr_t xp ) 535 { 536 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 537 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 538 CURRENT_THREAD->core->lid , hal_time_stamp() ); 539 540 exec_info_t * ptr; // local pointer on remote exec_info structure 541 exec_info_t info; // local copy of exec_info structure 542 error_t error; // local error error status 543 544 // get client cluster identifier and pointer on RPC descriptor 545 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 546 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 547 548 // get pointer on exec_info structure in client cluster from RPC descriptor 549 ptr = (exec_info_t*)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 550 551 // copy exec_info structure from client buffer to server buffer 552 hal_remote_memcpy( XPTR( client_cxy , ptr ), 553 XPTR( local_cxy , &info ), 554 sizeof(exec_info_t) ); 555 556 // call local kernel function 557 error = process_make_exec( &info ); 558 559 // set output argument into client RPC descriptor 560 hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error ); 561 562 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 563 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 564 CURRENT_THREAD->core->lid , hal_time_stamp() ); 565 } 526 // [2] undefined slot 527 ///////////////////////////////////////////////////////////////////////////////////////// 566 528 567 529 ///////////////////////////////////////////////////////////////////////////////////////// … … 644 606 645 607 ///////////////////////////////////////////////////////////////////////////////////////// 646 // [4] Marshaling functions attached to RPC_PROCESS_MAKE_EXIT (blocking) 608 // [4] undefined slot 609 ///////////////////////////////////////////////////////////////////////////////////////// 610 611 ///////////////////////////////////////////////////////////////////////////////////////// 612 // [5] Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking) 647 613 ///////////////////////////////////////////////////////////////////////////////////////// 648 614 649 615 /////////////////////////////////////////////////// 650 void rpc_process_make_exit_client( cxy_t cxy, 651 pid_t pid, 616 void rpc_process_make_kill_client( cxy_t cxy, 617 process_t * process, 618 bool_t is_exit, 652 619 uint32_t status ) 653 620 { … … 656 623 CURRENT_THREAD->core->lid , hal_time_stamp() ); 657 624 658 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 659 660 // initialise RPC descriptor header 661 rpc_desc_t rpc; 662 rpc.index = RPC_PROCESS_MAKE_EXIT; 625 // initialise RPC descriptor header 626 rpc_desc_t rpc; 627 rpc.index = RPC_PROCESS_MAKE_KILL; 663 628 rpc.response = 1; 664 629 rpc.blocking = true; 665 630 666 631 // set input arguments in RPC descriptor 667 rpc.args[0] = (uint64_t)pid; 668 rpc.args[1] = (uint64_t)status; 632 rpc.args[0] = (uint64_t)(intptr_t)process; 633 rpc.args[1] = (uint64_t)is_exit; 634 rpc.args[2] = (uint64_t)status; 669 635 670 636 // register RPC request in remote RPC fifo (blocking function) … … 677 643 678 644 ////////////////////////////////////////////// 679 void rpc_process_make_ exit_server( xptr_t xp )645 void rpc_process_make_kill_server( xptr_t xp ) 680 646 { 681 647 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", … … 683 649 CURRENT_THREAD->core->lid , hal_time_stamp() ); 684 650 685 pid_t pid; 686 uint32_t status; 651 process_t * process; 652 bool_t is_exit; 653 uint32_t status; 687 654 688 655 // get client cluster identifier and pointer on RPC descriptor … … 691 658 692 659 // get arguments from RPC descriptor 693 pid = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 694 status = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 660 process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 661 is_exit = (bool_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 662 status = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 695 663 696 664 // call local kernel function 697 process_make_ exit( pid, status );665 process_make_kill( process , is_exit , status ); 698 666 699 667 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", … … 703 671 704 672 ///////////////////////////////////////////////////////////////////////////////////////// 705 // [5] Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking) 706 ///////////////////////////////////////////////////////////////////////////////////////// 707 708 /////////////////////////////////////////////////// 709 void rpc_process_make_kill_client( cxy_t cxy, 710 pid_t pid, 711 uint32_t sig_id ) 712 { 713 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 714 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 715 CURRENT_THREAD->core->lid , hal_time_stamp() ); 716 717 assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n"); 718 719 // initialise RPC descriptor header 720 rpc_desc_t rpc; 721 rpc.index = RPC_PROCESS_MAKE_KILL; 722 rpc.response = 1; 723 rpc.blocking = true; 724 725 // set input arguments in RPC descriptor 726 rpc.args[0] = (uint64_t)pid; 727 rpc.args[1] = (uint64_t)sig_id; 728 729 // register RPC request in remote RPC fifo (blocking function) 730 rpc_send( cxy , &rpc ); 731 732 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 733 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 734 CURRENT_THREAD->core->lid , hal_time_stamp() ); 735 } 736 737 ////////////////////////////////////////////// 738 void rpc_process_make_kill_server( xptr_t xp ) 739 { 740 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 741 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 742 CURRENT_THREAD->core->lid , hal_time_stamp() ); 743 744 pid_t pid; 745 uint32_t sig_id; 746 747 // get client cluster identifier and pointer on RPC descriptor 748 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 749 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 750 751 // get arguments from RPC descriptor 752 pid = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 753 sig_id = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 754 755 // call local kernel function 756 process_make_exit( pid , sig_id ); 757 758 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 759 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 760 CURRENT_THREAD->core->lid , hal_time_stamp() ); 761 } 762 763 ///////////////////////////////////////////////////////////////////////////////////////// 764 // [6] Marshaling functions attached to RPC_THREAD_USER_CREATE (blocking) 673 // [6] Marshaling functions attached to RPC_THREAD_USER_CREATE (blocking) 765 674 ///////////////////////////////////////////////////////////////////////////////////////// 766 675 … … 1036 945 1037 946 // call relevant kernel function 1038 if (action == DELETE_ALL_THREADS ) process_delete_threads ( process , client_xp);1039 else if (action == BLOCK_ALL_THREADS ) process_block_threads ( process , client_xp);1040 else if (action == UNBLOCK_ALL_THREADS ) process_unblock_threads( process 947 if (action == DELETE_ALL_THREADS ) process_delete_threads ( process ); 948 else if (action == BLOCK_ALL_THREADS ) process_block_threads ( process ); 949 else if (action == UNBLOCK_ALL_THREADS ) process_unblock_threads( process ); 1041 950 1042 951 // decrement the responses counter in RPC descriptor,
Note: See TracChangeset
for help on using the changeset viewer.