Ignore:
Timestamp:
Feb 14, 2018, 3:40:19 PM (7 years ago)
Author:
alain
Message:

blip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/rpc.c

    r428 r433  
    4242#include <rpc.h>
    4343
     44
     45/////////////////////////////////////////////////////////////////////////////////////////
     46//        Debug macros for marshalling functions
     47/////////////////////////////////////////////////////////////////////////////////////////
     48
     49#if CONFIG_DEBUG_RPC_MARSHALING
     50
     51#define RPC_DEBUG_ENTER                                                                \
     52uint32_t cycle = (uint32_t)hal_get_cycles();                                           \
     53if( cycle > CONFIG_DEBUG_RPC_MARSHALING )                                              \
     54printk("\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                                                                 \
     58cycle = (uint32_t)hal_get_cycles();                                                    \
     59if( cycle > CONFIG_DEBUG_RPC_MARSHALING )                                              \
     60printk("\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
    4471/////////////////////////////////////////////////////////////////////////////////////////
    4572//      array of function pointers  (must be consistent with enum in rpc.h)
     
    5077    &rpc_pmem_get_pages_server,         // 0
    5178    &rpc_pmem_release_pages_server,     // 1
    52     &rpc_process_make_exec_server,      // 2
     79    &rpc_undefined,                     // 2    unused slot
    5380    &rpc_process_make_fork_server,      // 3
    54     &rpc_process_make_exit_server,      // 4
     81    &rpc_undefined,                     // 4    unused slot
    5582    &rpc_process_make_kill_server,      // 5
    5683    &rpc_thread_user_create_server,     // 6
     
    6895    &rpc_vfs_mapper_load_all_server,    // 17
    6996    &rpc_fatfs_get_cluster_server,      // 18
    70     &rpc_undefined,                     // 19
     97    &rpc_undefined,                     // 19   unused slot
    7198
    7299    &rpc_vmm_get_vseg_server,           // 20
     
    497524
    498525/////////////////////////////////////////////////////////////////////////////////////////
    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/////////////////////////////////////////////////////////////////////////////////////////
    566528
    567529/////////////////////////////////////////////////////////////////////////////////////////
     
    644606
    645607/////////////////////////////////////////////////////////////////////////////////////////
    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)
    647613/////////////////////////////////////////////////////////////////////////////////////////
    648614
    649615///////////////////////////////////////////////////
    650 void rpc_process_make_exit_client( cxy_t       cxy,
    651                                    pid_t       pid,
     616void rpc_process_make_kill_client( cxy_t       cxy,
     617                                   process_t * process,
     618                                   bool_t      is_exit,
    652619                                   uint32_t    status )
    653620{
     
    656623CURRENT_THREAD->core->lid , hal_time_stamp() );
    657624
    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;
    663628    rpc.response = 1;
    664629    rpc.blocking = true;
    665630
    666631    // 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;
    669635
    670636    // register RPC request in remote RPC fifo (blocking function)
     
    677643
    678644//////////////////////////////////////////////
    679 void rpc_process_make_exit_server( xptr_t xp )
     645void rpc_process_make_kill_server( xptr_t xp )
    680646{
    681647rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     
    683649CURRENT_THREAD->core->lid , hal_time_stamp() );
    684650
    685     pid_t     pid;
    686     uint32_t  status; 
     651    process_t * process;
     652    bool_t      is_exit;
     653    uint32_t    status;
    687654
    688655    // get client cluster identifier and pointer on RPC descriptor
     
    691658
    692659    // 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] ) );
    695663
    696664    // call local kernel function
    697     process_make_exit( pid , status );
     665    process_make_kill( process , is_exit , status );
    698666
    699667rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     
    703671
    704672/////////////////////////////////////////////////////////////////////////////////////////
    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) 
    765674/////////////////////////////////////////////////////////////////////////////////////////
    766675
     
    1036945
    1037946    // 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 );
    1041950
    1042951    // decrement the responses counter in RPC descriptor,
Note: See TracChangeset for help on using the changeset viewer.