Ignore:
Timestamp:
Nov 7, 2017, 3:08:12 PM (4 years ago)
Author:
alain
Message:

First implementation of fork/exec.

File:
1 edited

Legend:

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

    r406 r407  
    7676    &rpc_mapper_move_buffer_server,     // 24
    7777    &rpc_mapper_get_page_server,        // 25
    78     &rpc_undefined,                     // 26
    79     &rpc_undefined,                     // 27
     78    &rpc_vmm_create_vseg_server,        // 26
     79    &rpc_sched_display_server,          // 27
    8080    &rpc_undefined,                     // 28
    8181    &rpc_undefined,                     // 29
     
    9797                                page_t  ** page )      // out
    9898{
    99     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     99    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    100100    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    101101    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    115115
    116116    // get output arguments from RPC descriptor
    117     *page    = (page_t *)(intptr_t)rpc.args[1];
    118 
    119     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     117    *page = (page_t *)(intptr_t)rpc.args[1];
     118
     119    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    120120    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    121121    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    125125void rpc_pmem_get_pages_server( xptr_t xp )
    126126{
    127     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     127    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    128128    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    129129    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    142142    hal_remote_swd( XPTR( cxy , &desc->args[1] ) , (uint64_t)(intptr_t)page );
    143143
    144     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     144    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    145145    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    146146    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    157157                                   pid_t     * pid )     // out
    158158{
    159     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     159    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    160160    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    161161    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    178178    *error  = (error_t)rpc.args[2];     
    179179
    180     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     180    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    181181    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    182182    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    190190    pid_t       pid;       // output : process identifier
    191191
    192     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     192    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    193193    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    194194    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    209209    hal_remote_sw( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)pid );
    210210
    211     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     211    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    212212    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    213213    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    224224                              error_t     * error )   // out
    225225{
    226     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     226    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    227227    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    228228    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    244244    *error  = (error_t)rpc.args[1];     
    245245
    246     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     246    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    247247    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    248248    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    256256    error_t       error;     // local error error status
    257257
    258     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     258    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    259259    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    260260    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    278278    hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
    279279
    280     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     280    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    281281    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    282282    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    291291void rpc_process_kill_client( process_t * process )
    292292{
    293     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     293    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    294294    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    295295    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    325325    }
    326326
    327     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     327    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    328328    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    329329    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    336336    process_t * process; 
    337337
    338     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     338    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    339339    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    340340    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    360360    }
    361361
    362     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     362    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    363363    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    364364    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    379379                                    error_t        * error )      // out
    380380{
    381     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     381    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    382382    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    383383    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    387387    // initialise RPC descriptor header
    388388    rpc_desc_t  rpc;
    389     rpc.index    = RPC_THREAD_USER_CREATE;
    390     rpc.response = 1;
     389    rpc.index     = RPC_THREAD_USER_CREATE;
     390    rpc.response  = 1;
    391391
    392392    // set input arguments in RPC descriptor
     
    403403    *error     = (error_t)rpc.args[5];
    404404
    405     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     405    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    406406    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    407407    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    421421    error_t          error;
    422422
    423     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     423    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    424424    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    425425    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    442442                       sizeof(pthread_attr_t) );
    443443   
    444     assert( (attr_copy.cxy == local_cxy) , __FUNCTION__ , "bad target cluster\n" );
    445 
    446444    // call kernel function
    447445    error = thread_user_create( pid,
     
    453451    // set output arguments
    454452    thread_xp = XPTR( local_cxy , thread_ptr );
    455     hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
    456     hal_remote_swd( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)thread_xp );
    457 
    458     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     453    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)thread_xp );
     454    hal_remote_swd( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error );
     455
     456    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    459457    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    460458    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    473471                                      error_t * error )      // out
    474472{
    475     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     473    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    476474    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    477475    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    496494    *error     = (error_t)rpc.args[4];
    497495
    498     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     496    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    499497    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    500498    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    509507    error_t          error;   
    510508
    511     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     509    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    512510    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    513511    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    533531    hal_remote_swd( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)thread_xp );
    534532
    535     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     533    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    536534    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    537535    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    547545                             uint32_t    sig_id )    // in
    548546{
    549     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     547    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    550548    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    551549    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    565563    rpc_send_sync( cxy , &rpc );
    566564
    567     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     565    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    568566    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    569567    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    576574    uint32_t     sig_id;   // signal index
    577575
    578     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     576    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    579577    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    580578    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    591589    signal_rise( process , sig_id );
    592590
    593     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     591    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    594592    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    595593    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    613611                                  error_t      * error )     // out
    614612{
    615     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     613    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    616614    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    617615    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    641639    *error    = (error_t)rpc.args[9];
    642640
    643     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     641    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    644642    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    645643    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    660658    error_t          error;
    661659
    662     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     660    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    663661    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    664662    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    693691    hal_remote_swd( XPTR( client_cxy , &desc->args[9] ) , (uint64_t)error );
    694692
    695     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     693    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    696694    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    697695    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    706704                                   struct vfs_inode_s * inode )
    707705{
    708     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     706    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    709707    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    710708    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    723721    rpc_send_sync( cxy , &rpc );
    724722
    725     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     723    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    726724    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    727725    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    733731    vfs_inode_t * inode;
    734732
    735     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     733    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    736734    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    737735    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    747745    vfs_inode_destroy( inode );
    748746
    749     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     747    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    750748    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    751749    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    764762                                   error_t              * error )       // out
    765763{
    766     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     764    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    767765    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    768766    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    787785    *error     = (error_t)rpc.args[4];
    788786
    789     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     787    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    790788    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    791789    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    803801    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
    804802
    805     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     803    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    806804    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    807805    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    829827    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
    830828
    831     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     829    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    832830    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    833831    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    843841                                    vfs_dentry_t * dentry )
    844842{
    845     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     843    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    846844    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    847845    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    860858    rpc_send_sync( cxy , &rpc );
    861859
    862     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     860    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    863861    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    864862    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    870868    vfs_dentry_t * dentry;
    871869
    872     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     870    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    873871    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    874872    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    884882    vfs_dentry_destroy( dentry );
    885883
    886     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     884    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    887885    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    888886    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    901899                                 error_t              * error )      // out
    902900{
    903     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     901    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    904902    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    905903    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    923921    *error   = (error_t)rpc.args[3];
    924922
    925     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     923    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    926924    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    927925    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    936934    error_t       error;
    937935
    938     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     936    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    939937    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    940938    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    957955    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
    958956
    959     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     957    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    960958    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    961959    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    970968                                  vfs_file_t * file )
    971969{
    972     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     970    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    973971    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    974972    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    987985    rpc_send_sync( cxy , &rpc );
    988986
    989     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     987    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    990988    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    991989    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    997995    vfs_file_t * file;
    998996
    999     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     997    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    1000998    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    1001999    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    10111009    vfs_file_destroy( file );
    10121010
    1013     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1011    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    10141012    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    10151013    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    10271025                                error_t     * error )          // out
    10281026{
    1029     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1027    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    10301028    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    10311029    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    10491047    *error   = (error_t)rpc.args[3];
    10501048
    1051     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1049    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    10521050    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    10531051    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    10641062    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
    10651063
    1066     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1064    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    10671065    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    10681066    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    10871085    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
    10881086
    1089     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1087    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    10901088    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    10911089    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11011099                                     error_t     * error )     // out
    11021100{
    1103     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1101    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    11041102    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    11051103    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11211119    *error   = (error_t)rpc.args[1];
    11221120
    1123     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1121    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    11241122    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    11251123    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11321130    vfs_inode_t * inode;
    11331131
    1134     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1132    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    11351133    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    11361134    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11491147    hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
    11501148
    1151     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1149    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    11521150    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    11531151    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11621160                                   mapper_t * mapper,    // in
    11631161                                   uint32_t   first,     // in
    1164                                    uint32_t   page,      // in
     1162                                   uint32_t   index,     // in
    11651163                                   uint32_t * cluster,   // out
    11661164                                   error_t  * error )    // out
    11671165{
    1168     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1166    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    11691167    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    11701168    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11801178    rpc.args[0] = (uint64_t)(intptr_t)mapper;
    11811179    rpc.args[1] = (uint64_t)first;
    1182     rpc.args[2] = (uint64_t)page;
     1180    rpc.args[2] = (uint64_t)index;
    11831181
    11841182    // register RPC request in remote RPC fifo
     
    11891187    *error   = (error_t)rpc.args[4];
    11901188
    1191     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1189    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    11921190    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    11931191    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    11991197    mapper_t    * mapper;
    12001198    uint32_t      first;
    1201     uint32_t      page;
     1199    uint32_t      index;
    12021200    uint32_t      cluster;
    12031201    error_t       error;
    12041202
    1205     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1203    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    12061204    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    12071205    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    12141212    mapper = (mapper_t *)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) );
    12151213    first  = (uint32_t)            hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) );
    1216     page   = (uint32_t)            hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) );
     1214    index  = (uint32_t)            hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) );
    12171215
    12181216    // call the kernel function
    1219     error = fatfs_get_cluster( mapper , first , page , &cluster );
     1217    error = fatfs_get_cluster( mapper , first , index , &cluster );
    12201218
    12211219    // set output argument
     
    12231221    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
    12241222
    1225     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1223    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    12261224    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    12271225    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    12391237                              error_t   * error )      // out
    12401238{
    1241     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1239    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    12421240    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    12431241    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    12611259    *error   = (error_t)rpc.args[3];
    12621260
    1263     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1261    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    12641262    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    12651263    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    12751273    error_t       error;
    12761274
    1277     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1275    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    12781276    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    12791277    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    12951293    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
    12961294
    1297     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1295    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    12981296    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    12991297    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    13091307                             process_t * process,  // in
    13101308                             vpn_t       vpn,      // in
     1309                             bool_t      cow,      // in
    13111310                             uint32_t  * attr,     // out
    13121311                             ppn_t     * ppn,      // out
    13131312                             error_t   * error )   // out
    13141313{
    1315     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1314    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    13161315    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    13171316    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    13271326    rpc.args[0] = (uint64_t)(intptr_t)process;
    13281327    rpc.args[1] = (uint64_t)vpn;
     1328    rpc.args[2] = (uint64_t)cow;
    13291329
    13301330    // register RPC request in remote RPC fifo (blocking function)
     
    13321332
    13331333    // get output argument from rpc descriptor
    1334     *attr  = (uint32_t)rpc.args[2];
    1335     *ppn   = (ppn_t)rpc.args[3];
    1336     *error = (error_t)rpc.args[4];
    1337 
    1338     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1334    *attr  = (uint32_t)rpc.args[3];
     1335    *ppn   = (ppn_t)rpc.args[4];
     1336    *error = (error_t)rpc.args[5];
     1337
     1338    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    13391339    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    13401340    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    13461346    process_t   * process;
    13471347    vpn_t         vpn;
     1348    bool_t        cow;
    13481349    uint32_t      attr;
    13491350    ppn_t         ppn;
    13501351    error_t       error;
    13511352
    1352     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1353    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    13531354    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    13541355    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    13611362    process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
    13621363    vpn     = (vpn_t)                hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
     1364    cow     = (bool_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
    13631365   
    13641366    // call local kernel function
    1365     error = vmm_get_pte( process , vpn , &attr , &ppn );
     1367    error = vmm_get_pte( process , vpn , cow , &attr , &ppn );
    13661368
    13671369    // set output argument "attr" & "ppn" to client RPC descriptor
    1368     hal_remote_swd( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)attr );
    1369     hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)ppn );
    1370     hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
    1371 
    1372     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1370    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)attr );
     1371    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)ppn );
     1372    hal_remote_swd( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error );
     1373
     1374    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    13731375    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    13741376    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    13841386                           xptr_t *   buf_xp )     // out
    13851387{
    1386     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1388    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    13871389    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    13881390    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14041406    *buf_xp = (xptr_t)rpc.args[1];
    14051407
    1406     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1408    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    14071409    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14081410    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14121414void rpc_kcm_alloc_server( xptr_t xp )
    14131415{
    1414     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1416    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    14151417    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14161418    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14331435    hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)buf_xp );
    14341436
    1435     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1437    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    14361438    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14371439    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14471449                          uint32_t   kmem_type )   // in
    14481450{
    1449     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1451    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    14501452    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14511453    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14651467    rpc_send_sync( cxy , &rpc );
    14661468
    1467     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1469    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    14681470    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14691471    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14731475void rpc_kcm_free_server( xptr_t xp )
    14741476{
    1475     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1477    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    14761478    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14771479    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    14911493    kmem_free( &req );
    14921494
    1493     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1495    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    14941496    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    14951497    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    15101512                                    error_t  * error )        // out
    15111513{
    1512     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1514    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    15131515    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    15141516    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    15351537    *error     = (error_t)rpc.args[6];
    15361538
    1537     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1539    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    15381540    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    15391541    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    15521554    error_t    error;
    15531555
    1554     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1556    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    15551557    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    15561558    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    15921594    hal_remote_swd( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error );
    15931595
    1594     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1596    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    15951597    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    15961598    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    16071609                                 page_t         ** page )      // out
    16081610{
    1609     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1611    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    16101612    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    16111613    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    16281630    *page = (page_t *)(intptr_t)rpc.args[2];
    16291631
    1630     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1632    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    16311633    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    16321634    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    16361638void rpc_mapper_get_page_server( xptr_t xp )
    16371639{
    1638     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1640    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    16391641    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    16401642    CURRENT_THREAD->core->lid , hal_time_stamp() );
     
    16541656    hal_remote_swd( XPTR( cxy , &desc->args[1] ) , (uint64_t)(intptr_t)page );
    16551657
    1656     rpc_dmsg("\n[DMSG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
    1657     __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
    1658     CURRENT_THREAD->core->lid , hal_time_stamp() );
    1659 }
    1660 
     1658    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1659    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1660    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1661}
     1662
     1663/////////////////////////////////////////////////////////////////////////////////////////
     1664// [26]          Marshaling functions attached to RPC_VMM_CREATE_VSEG
     1665/////////////////////////////////////////////////////////////////////////////////////////
     1666
     1667////////////////////////////////////////////////////////
     1668void rpc_vmm_create_vseg_client( cxy_t              cxy,
     1669                                 struct process_s * process,
     1670                                 vseg_type_t        type,
     1671                                 intptr_t           base,
     1672                                 uint32_t           size,
     1673                                 uint32_t           file_offset,
     1674                                 uint32_t           file_size,
     1675                                 xptr_t             mapper_xp,
     1676                                 cxy_t              vseg_cxy,
     1677                                 struct vseg_s   ** vseg )
     1678{
     1679    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1680    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1681    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1682
     1683    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
     1684
     1685    // initialise RPC descriptor header
     1686    rpc_desc_t  rpc;
     1687    rpc.index    = RPC_VMM_CREATE_VSEG;
     1688    rpc.response = 1;
     1689
     1690    // set input arguments in RPC descriptor
     1691    rpc.args[0] = (uint64_t)(intptr_t)process;
     1692    rpc.args[1] = (uint64_t)type;
     1693    rpc.args[2] = (uint64_t)base;
     1694    rpc.args[3] = (uint64_t)size;
     1695    rpc.args[4] = (uint64_t)file_offset;
     1696    rpc.args[5] = (uint64_t)file_size;
     1697    rpc.args[6] = (uint64_t)mapper_xp;
     1698    rpc.args[7] = (uint64_t)vseg_cxy;
     1699
     1700    // register RPC request in remote RPC fifo (blocking function)
     1701    rpc_send_sync( cxy , &rpc );
     1702
     1703    // get output values from RPC descriptor
     1704    *vseg = (vseg_t *)(intptr_t)rpc.args[8];
     1705
     1706    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1707    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1708    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1709}
     1710
     1711////////////////////////////////////////////
     1712void rpc_vmm_create_vseg_server( xptr_t xp )
     1713{
     1714    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1715    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1716    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1717
     1718    // get client cluster identifier and pointer on RPC descriptor
     1719    cxy_t        cxy  = (cxy_t)GET_CXY( xp );
     1720    rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
     1721
     1722    // get input arguments from client RPC descriptor
     1723    process_t * process     = (process_t *)(intptr_t)hal_remote_lwd( XPTR(cxy , &desc->args[0]));
     1724    vseg_type_t type        = (vseg_type_t)(uint32_t)hal_remote_lwd( XPTR(cxy , &desc->args[1]));
     1725    intptr_t    base        = (intptr_t)             hal_remote_lwd( XPTR(cxy , &desc->args[2]));
     1726    uint32_t    size        = (uint32_t)             hal_remote_lwd( XPTR(cxy , &desc->args[3]));
     1727    uint32_t    file_offset = (uint32_t)             hal_remote_lwd( XPTR(cxy , &desc->args[4]));
     1728    uint32_t    file_size   = (uint32_t)             hal_remote_lwd( XPTR(cxy , &desc->args[5]));
     1729    xptr_t      mapper_xp   = (xptr_t)               hal_remote_lwd( XPTR(cxy , &desc->args[6]));
     1730    cxy_t       vseg_cxy    = (cxy_t)(uint32_t)      hal_remote_lwd( XPTR(cxy , &desc->args[7]));
     1731   
     1732    // call local kernel function
     1733    vseg_t * vseg = vmm_create_vseg( process,
     1734                                     type,
     1735                                     base,
     1736                                     size,
     1737                                     file_offset,
     1738                                     file_size,
     1739                                     mapper_xp,
     1740                                     vseg_cxy );
     1741
     1742    // set output arguments into client RPC descriptor
     1743    hal_remote_swd( XPTR( cxy , &desc->args[8] ) , (uint64_t)(intptr_t)vseg );
     1744
     1745    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1746    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1747    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1748}
     1749
     1750/////////////////////////////////////////////////////////////////////////////////////////
     1751// [27]          Marshaling functions attached to RPC_SCHED_DISPLAY
     1752/////////////////////////////////////////////////////////////////////////////////////////
     1753
     1754////////////////////////////////////////////////////////
     1755void rpc_sched_display_client( cxy_t              cxy,
     1756                               lid_t              lid)
     1757{
     1758    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1759    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1760    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1761
     1762    assert( (cxy != local_cxy) , __FUNCTION__ , "target cluster is not remote\n");
     1763
     1764    // initialise RPC descriptor header
     1765    rpc_desc_t  rpc;
     1766    rpc.index    = RPC_SCHED_DISPLAY;
     1767    rpc.response = 1;
     1768
     1769    // set input arguments in RPC descriptor
     1770    rpc.args[0] = (uint64_t)lid;
     1771
     1772    // register RPC request in remote RPC fifo (blocking function)
     1773    rpc_send_sync( cxy , &rpc );
     1774
     1775    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1776    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1777    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1778}
     1779
     1780//////////////////////////////////////////
     1781void rpc_sched_display_server( xptr_t xp )
     1782{
     1783    rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
     1784    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1785    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1786
     1787    // get client cluster identifier and pointer on RPC descriptor
     1788    cxy_t        cxy  = (cxy_t)GET_CXY( xp );
     1789    rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
     1790
     1791    // get input arguments from client RPC descriptor
     1792    lid_t lid = (lid_t)hal_remote_lw( XPTR(cxy , &desc->args[0]));
     1793   
     1794    // call local kernel function
     1795    sched_display( lid );
     1796
     1797    rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n",
     1798    __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy,
     1799    CURRENT_THREAD->core->lid , hal_time_stamp() );
     1800}
    16611801
    16621802/***************************************************************************************/
     
    16681808                    rpc_desc_t * rpc )
    16691809{
    1670     uint32_t   cores;
    16711810    error_t    error;
    1672     bool_t     first;
    1673     reg_t      sr_save;
    1674 
    1675     rpc_dmsg("\n[DMSG] %s : enter / client_cxy = %x / server_cxy = %x / cycle %d\n",
    1676     __FUNCTION__ , local_cxy , server_cxy , hal_time_stamp() );
    1677 
    1678     // allocate and initialise an extended pointer on the RPC descriptor
     1811
     1812    thread_t * this = CURRENT_THREAD;
     1813    core_t   * core = this->core;
     1814
     1815    // register client thread pointer and core lid in RPC descriptor
     1816    rpc->thread    = this;
     1817    rpc->lid       = core->lid;
     1818
     1819    // build an extended pointer on the RPC descriptor
    16791820        xptr_t   desc_xp = XPTR( local_cxy , rpc );
    16801821
    16811822    // get local pointer on rpc_fifo in remote cluster, with the
    1682     // assumption that rpc_fifo pddresses are identical in all clusters
    1683     rpc_fifo_t * rf = &LOCAL_CLUSTER->rpc_fifo;
     1823    // assumption that local pointers are identical in all clusters
     1824    remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
    16841825
    16851826        // try to post an item in remote fifo
     
    16871828    do
    16881829    {
    1689         error = remote_fifo_put_item( XPTR( server_cxy , &rf->fifo ),
    1690                                       (uint64_t )desc_xp,
    1691                                       &first );
     1830        error = remote_fifo_put_item( XPTR( server_cxy , rpc_fifo ),
     1831                                      (uint64_t )desc_xp );
    16921832            if ( error )
    16931833        {
     
    16951835            __FUNCTION__ , local_cxy , server_cxy );
    16961836
    1697             if( thread_can_yield() ) sched_yield( NULL );
     1837            if( thread_can_yield() ) sched_yield();
    16981838        }
    16991839    }
    17001840    while( error );
    17011841 
    1702     rpc_dmsg("\n[DMSG] %s : RPC %l registered / server_cxy = %x / cycle %d\n",
    1703     __FUNCTION__ , desc_xp , server_cxy , hal_time_stamp() );
     1842    hal_fence();
    17041843       
    1705     // send IPI to remote CP0, if this is the first RPC in remote FIFO,
    1706     // and there is no CPU is in kernel mode in server cluster.
    1707         if( first )
    1708         {
    1709         // get number of cores in kernel mode in server cluster
    1710         cores = hal_remote_lw( XPTR( server_cxy , &LOCAL_CLUSTER->cores_in_kernel ) );
    1711 
    1712                 if( cores == 0 ) // no core in kernel mode in server
    1713                 {
    1714                     dev_pic_send_ipi( server_cxy , 0 );
    1715 
    1716                     rpc_dmsg("\n[DMSG] %s : IPI sent / client_cxy = %x / server_cxy = %x\n",
    1717             __FUNCTION__, local_cxy , server_cxy );
    1718         }
    1719         }
    1720 
    1721         // enable IRQs to allow incoming RPC and avoid deadlock
    1722         hal_enable_irq( &sr_save );
    1723 
    1724     // the server thread poll the response slot until RPC completed
    1725     // TODO this could be replaced by a descheduling policy... [AG]
    1726     while( rpc->response ) asm volatile( "nop" );
    1727 
    1728     // restore IRQs
    1729         hal_restore_irq( sr_save );
    1730 
    1731     rpc_dmsg("\n[DMSG] %s : completed / client_cxy = %x / server_cxy = %x / cycle %d\n",
    1732     __FUNCTION__ , local_cxy , server_cxy , hal_time_stamp() );
    1733 
     1844    // send IPI to the remote core corresponding to the client core
     1845        dev_pic_send_ipi( server_cxy , core->lid );
     1846
     1847    // wait RPC completion:
     1848    // - busy waiting policy during kernel_init, or if threads cannot yield
     1849    // - block and deschedule in all other cases
     1850
     1851    if( (this->type == THREAD_IDLE) || (thread_can_yield() == false) ) // busy waiting
     1852    {
     1853
     1854grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %s busy waiting after registering RPC\n"
     1855"        rpc = %d / server = %x / cycle %d\n",
     1856__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , thread_type_str(this->type) ,
     1857rpc->index , server_cxy , hal_time_stamp() );
     1858
     1859        while( rpc->response ) hal_fixed_delay( 100 );
     1860   
     1861grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %s exit after RPC completion\n",
     1862__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , thread_type_str(this->type) );
     1863
     1864    }
     1865    else                                                              // block & deschedule
     1866    {
     1867
     1868grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %s deschedule after registering RPC\n"
     1869"        rpc = %d / server = %x / cycle %d\n",
     1870__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , thread_type_str(this->type) ,
     1871rpc->index , server_cxy , hal_time_stamp() );
     1872
     1873        thread_block( this , THREAD_BLOCKED_RPC );
     1874        sched_yield();
     1875
     1876grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %s resumes after RPC completion\n",
     1877__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , thread_type_str(this->type) );
     1878
     1879    }
     1880
     1881    // check response available
     1882    assert( (rpc->response == 0) , __FUNCTION__, "illegal RPC response\n" );
     1883
     1884    // acknowledge the IPI sent by the server
     1885    dev_pic_ack_ipi();
     1886   
    17341887}  // end rpc_send_sync()
    17351888
     
    17401893/***************************************************************************************/
    17411894
    1742 ///////////////////////////////////////////
    1743 void rpc_fifo_init( rpc_fifo_t * rpc_fifo )
    1744 {
    1745         rpc_fifo->count       = 0;
    1746         rpc_fifo->owner       = 0;
    1747         local_fifo_init( &rpc_fifo->fifo );
    1748 }
    1749 
    1750 /////////////////////////////////////////////
    1751 void rpc_execute_all( rpc_fifo_t * rpc_fifo )
    1752 {
    1753         xptr_t         xp;             // extended pointer on RPC descriptor
    1754         uint32_t       count;          // handled RPC request counter
    1755         thread_t     * this;           // pointer on this RPC thread
    1756     core_t       * core;           // pointer on core running this thread
    1757     rpc_desc_t   * desc;           // pointer on RPC descriptor
    1758     uint32_t       index;          // RPC index
    1759     cxy_t          client_cxy;     // client cluster identifier
    1760         error_t        error;
    1761      
    1762         this  = CURRENT_THREAD;
    1763     core  = this->core;   
    1764         count = 0;
    1765 
    1766     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    1767     __FUNCTION__, this->trdid, local_cxy, core->lid , hal_time_stamp() );
     1895////////////////
     1896void rpc_check()
     1897{
     1898    error_t         error;
     1899    thread_t      * thread; 
     1900    uint32_t        sr_save;
     1901
     1902    bool_t          found    = false;
     1903        thread_t      * this     = CURRENT_THREAD;
     1904    core_t        * core     = this->core;
     1905    scheduler_t   * sched    = &core->scheduler;
     1906        remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
     1907
     1908grpc_dmsg("\n[DBG] %s : core[%x,%d] / interrupted thread %s / cycle %d\n",
     1909__FUNCTION__, local_cxy, core->lid, thread_type_str(this->type), hal_time_stamp() );
     1910
     1911    // interrupted thread not preemptable during RPC chek
     1912        hal_disable_irq( &sr_save );
     1913
     1914    // check RPC FIFO not empty and no RPC thread handling it 
     1915        if( (rpc_fifo->owner == 0) && (local_fifo_is_empty(rpc_fifo) == false) )
     1916    {
     1917        // search one non blocked RPC thread   
     1918        list_entry_t * iter;
     1919        LIST_FOREACH( &sched->k_root , iter )
     1920        {
     1921            thread = LIST_ELEMENT( iter , thread_t , sched_list );
     1922            if( (thread->type == THREAD_RPC) && (thread->blocked == 0 ) )
     1923            {
     1924                found = true;
     1925                break;
     1926            }
     1927        }
     1928
     1929        // create new RPC thread if not found   
     1930        if( found == false )                   
     1931        {
     1932            error = thread_kernel_create( &thread,
     1933                                          THREAD_RPC,
     1934                                                      &rpc_thread_func,
     1935                                          NULL,
     1936                                                      this->core->lid );
     1937                if( error )
     1938            {
     1939                printk("\n[WARNING] in %s : no memory for new RPC thread in cluster %x\n",
     1940                __FUNCTION__ , local_cxy );
     1941            }
     1942            else
     1943            {
     1944                // unblock created RPC thread
     1945                thread->blocked = 0;
     1946
     1947                // update core descriptor counter 
     1948                    hal_atomic_add( &LOCAL_CLUSTER->rpc_threads , 1 );
     1949
     1950grpc_dmsg("\n[DBG] %s : core [%x,%d] creates a new RPC thread %x / cycle %d\n",
     1951__FUNCTION__ , local_cxy , core->lid , thread->trdid , hal_time_stamp() );
     1952
     1953            }
     1954        }
     1955    }
     1956
     1957grpc_dmsg("\n[DBG] %s : core[%x,%d] / interrupted thread %s deschedules / cycle %d\n",
     1958__FUNCTION__, local_cxy, core->lid, thread_type_str(this->type), hal_time_stamp() );
     1959
     1960    // interrupted thread deschedule always           
     1961        sched_yield();
     1962
     1963grpc_dmsg("\n[DBG] %s : core[%x,%d] / interrupted thread %s resume / cycle %d\n",
     1964__FUNCTION__, local_cxy, core->lid, thread_type_str(this->type), hal_time_stamp() );
     1965
     1966    // interrupted thread restore IRQs after resume
     1967        hal_restore_irq( sr_save );
     1968
     1969} // end rpc_check()
     1970
     1971
     1972//////////////////////
     1973void rpc_thread_func()
     1974{
     1975    uint32_t     count;       // handled RPC requests counter
     1976    error_t      empty;       // local RPC fifo state
     1977    xptr_t       desc_xp;     // extended pointer on RPC request
     1978    cxy_t        desc_cxy;    // RPC request cluster (client)
     1979    rpc_desc_t * desc_ptr;    // RPC request local pointer
     1980    uint32_t     index;       // RPC request index
     1981    uint32_t     responses;   // number of responses received by client
     1982    thread_t   * thread_ptr;  // local pointer on client thread
     1983    lid_t        core_lid;    // local index of client core
    17681984 
    1769     // handle up to CONFIG_RPC_PENDING_MAX requests before exit
    1770         do
    1771     {
    1772             error = local_fifo_get_item( &rpc_fifo->fifo, (uint64_t *)&xp );
    1773 
    1774                 if ( error == 0 )  // One RPC request successfully extracted from RPC_FIFO
     1985    // makes RPC thread not preemptable
     1986        hal_disable_irq( NULL );
     1987 
     1988        thread_t      * this     = CURRENT_THREAD;
     1989        remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
     1990
     1991    // two embedded loops:
     1992    // - external loop : "infinite" RPC thread
     1993    // - internal loop : handle up to CONFIG_RPC_PENDING_MAX RPC requests
     1994 
     1995        while(1)  // external loop
     1996        {
     1997        // try to take RPC_FIFO ownership
     1998        if( hal_atomic_test_set( &rpc_fifo->owner , this->trdid ) )
    17751999        {
    1776             // get client cluster identifier and pointer on RPC descriptor
    1777             client_cxy = (cxy_t)GET_CXY( xp );
    1778             desc       = (rpc_desc_t *)GET_PTR( xp );
    1779 
    1780             // get rpc index from RPC descriptor
    1781                 index = hal_remote_lw( XPTR( client_cxy , &desc->index ) );
    1782 
    1783             rpc_dmsg("\n[DMSG] %s : thread %x on core [%x,%d] / rpc = %d\n",
    1784                      __FUNCTION__ , this->trdid , core->lid , local_cxy , index );
    1785 
    1786             // call the relevant server function
    1787             rpc_server[index]( xp );
    1788 
    1789             // increment handled RPC counter
    1790                 count++;
    1791 
    1792             // notify RPC completion as required
    1793             hal_remote_atomic_add( XPTR( client_cxy , &desc->response ) , -1 );
    1794                 }
     2000            // initializes RPC requests counter
     2001            count = 0;
     2002
     2003            // acknowledge local IPI
     2004            dev_pic_ack_ipi();
     2005
     2006                    // exit internal loop in three cases:
     2007            // - RPC fifo is empty
     2008            // - ownership has been lost (because descheduling)
     2009            // - max number of RPCs is reached
     2010                while( 1 )  // internal loop
     2011            {
     2012                    empty = local_fifo_get_item( rpc_fifo , (uint64_t *)&desc_xp );
     2013
     2014                    if ( empty == 0 ) // one RPC request found
     2015                {
     2016                    // get client cluster and pointer on RPC descriptor
     2017                    desc_cxy = (cxy_t)GET_CXY( desc_xp );
     2018                    desc_ptr = (rpc_desc_t *)GET_PTR( desc_xp );
     2019
     2020                    // get rpc index from RPC descriptor
     2021                        index = hal_remote_lw( XPTR( desc_cxy , &desc_ptr->index ) );
     2022
     2023grpc_dmsg("\n[DBG] %s : core[%x,%d] / RPC thread %x / starts rpc %d / cycle %d\n",
     2024__FUNCTION__ , local_cxy , this->core->lid , this->trdid , index , hal_time_stamp() );
     2025
     2026                    // call the relevant server function
     2027                    rpc_server[index]( desc_xp );
     2028
     2029grpc_dmsg("\n[DBG] %s : core[%x,%d] / RPC thread %x / completes rpc %d / cycle %d\n",
     2030__FUNCTION__ , local_cxy , this->core->lid , this->trdid , index , hal_time_stamp() );
     2031
     2032                    // increment handled RPC counter
     2033                        count++;
     2034
     2035                    // decrement response counter in RPC descriptor
     2036                    responses = hal_remote_atomic_add(XPTR( desc_cxy, &desc_ptr->response ), -1);
     2037
     2038                    // unblock client thread  and send IPI to client core if last response
     2039                    if( responses == 1 )
     2040                    {
     2041                        // get pointer on client thread and unblock it
     2042                        thread_ptr = (thread_t *)hal_remote_lpt(XPTR(desc_cxy,&desc_ptr->thread));
     2043                        thread_unblock( XPTR(desc_cxy,thread_ptr) , THREAD_BLOCKED_RPC );
     2044
     2045                        hal_fence();
     2046
     2047                        // get client core lid and send IPI
     2048                        core_lid = hal_remote_lw(XPTR(desc_cxy, &desc_ptr->lid));
     2049                            dev_pic_send_ipi( desc_cxy , core_lid );
     2050                    }
     2051                        }
    17952052       
    1796                 // exit loop in three cases:
    1797         // - fifo is empty
    1798         // - look has been released (because descheduling)
    1799         // - max number of RPCs has been reached
    1800                 if( error ||
    1801             (rpc_fifo->owner != this->trdid) ||
    1802             (count > CONFIG_RPC_PENDING_MAX) ) break;
    1803         }
    1804     while( 1 );
    1805 
    1806     // update RPC_FIFO global counter
    1807         rpc_fifo->count += count;
    1808 
    1809 }  // end rpc_execute_all()
     2053                // chek exit condition
     2054                        if( local_fifo_is_empty( rpc_fifo )  ||
     2055                    (rpc_fifo->owner != this->trdid) ||
     2056                    (count >= CONFIG_RPC_PENDING_MAX) ) break;
     2057                } // end internal loop
     2058
     2059            // release rpc_fifo ownership if not lost
     2060            if( rpc_fifo->owner == this->trdid ) rpc_fifo->owner = 0;
     2061        }
     2062
     2063        // sucide if too many RPC threads in cluster
     2064        if( LOCAL_CLUSTER->rpc_threads >= CONFIG_RPC_THREADS_MAX )
     2065            {
     2066
     2067grpc_dmsg("\n[DBG] %s : core[%x,%d] (RPC thread %x) suicide at cycle %d\n",
     2068__FUNCTION__, local_cxy, this->core->lid, this->trdid, hal_time_stamp() );
     2069
     2070            // update RPC threads counter
     2071                hal_atomic_add( &LOCAL_CLUSTER->rpc_threads , -1 );
     2072
     2073            // suicide
     2074                thread_exit();
     2075            }
     2076
     2077grpc_dmsg("\n[DBG] %s : core[%x,%d] (RPC thread %x) deschedules / cycle %d\n",
     2078__FUNCTION__, local_cxy, this->core->lid, this->trdid, hal_time_stamp() );
     2079
     2080        // deschedule without blocking
     2081        sched_yield();
     2082
     2083grpc_dmsg("\n[DBG] %s : core[%x,%d] (RPC thread %x) resumes / cycle %d\n",
     2084__FUNCTION__, local_cxy, this->core->lid, this->trdid, hal_time_stamp() );
     2085
     2086        } // end external loop
     2087
     2088} // end rpc_thread_func()
     2089
     2090
     2091
     2092
     2093
     2094
     2095
     2096
     2097
     2098/* deprecated [AG] 29/09/2017
    18102099
    18112100////////////////////////////////////////////////////
    1812 error_t rpc_activate_thread( rpc_fifo_t * rpc_fifo )
     2101error_t rpc_activate_thread( remote_fifo_t * rpc_fifo )
    18132102{
    18142103        core_t      * core;
     
    18272116
    18282117    assert( (this->trdid == rpc_fifo->owner) , __FUNCTION__ ,
    1829           "calling thread is not RPC_FIFO owner\n" );
     2118    "calling thread is not RPC_FIFO owner\n" );
    18302119
    18312120    // makes the calling thread not preemptable
     
    18332122        hal_disable_irq( &sr_save );
    18342123
    1835     // search a free RPC thread (must be in THREAD_BLOCKED_IDLE state)   
     2124grpc_dmsg("\n[DBG] %s : core[%x,%d] enter at cycle %d\n",
     2125__FUNCTION__ , local_cxy , core->lid , hal_time_stamp() );
     2126
     2127    // search one non blocked RPC thread   
    18362128    list_entry_t * iter;
    18372129    LIST_FOREACH( &sched->k_root , iter )
    18382130    {
    18392131        thread = LIST_ELEMENT( iter , thread_t , sched_list );
    1840         if( (thread->type == THREAD_RPC) && (thread->blocked == THREAD_BLOCKED_IDLE ) )
     2132        if( (thread->type == THREAD_RPC) && (thread->blocked == 0 ) )
    18412133        {
    18422134            found = true;
     
    18452137    }
    18462138
    1847     if( found )                    // activate this idle RPC thread     
     2139    if( found == false )                    // create new RPC thread     
    18482140    {
    1849         // unblock it
    1850         thread->blocked = 0;
    1851 
    1852         rpc_dmsg("\n[DMSG] %s : activate RPC thread %x on core [%x,%d] / cycle %d\n",
    1853                           __FUNCTION__ , thread , core->gid , local_cxy , hal_time_stamp() );
    1854     }
    1855     else                           // create a new RPC thread
    1856     {
    1857         // create new thread
    18582141        error = thread_kernel_create( &thread,
    18592142                                      THREAD_RPC,
     
    18692152        }
    18702153
    1871         // unblock new thread
     2154        // unblock thread
    18722155        thread->blocked = 0;
    18732156
     
    18752158            hal_atomic_add( &LOCAL_CLUSTER->rpc_threads , 1 );
    18762159
    1877         rpc_dmsg("\n[DMSG] %s : create RPC thread %x on core [%x,%d] / cycle %d\n",
    1878                           __FUNCTION__ , thread->trdid, local_cxy, core->lid, hal_time_stamp() );
     2160grpc_dmsg("\n[DBG] %s : core [%x,%d] creates RPC thread %x at cycle %d\n",
     2161__FUNCTION__ , local_cxy , core->lid , thread->trdid , hal_time_stamp() );
     2162
    18792163    }
    1880 
    1881     // update owner in rpc_fifo
     2164    else                           // create a new RPC thread
     2165    {
     2166
     2167grpc_dmsg("\n[DBG] %s : core[%x,%d] activates RPC thread %x at cycle %d\n",
     2168__FUNCTION__ , local_cxy , core->lid , thread->trdid , hal_time_stamp() );
     2169
     2170    }
     2171
     2172    // update rpc_fifo owner
    18822173    rpc_fifo->owner = thread->trdid;
    18832174
    1884     // current thread switch to RPC thread 
    1885         sched_yield( thread );
     2175    // current thread deschedule           
     2176        sched_yield();
    18862177
    18872178    // restore IRQs for the calling thread
     
    18932184}  // end rpc_activate_thread()
    18942185
    1895 //////////////////
    1896 bool_t rpc_check()
     2186////////////////
     2187void rpc_check()
    18972188{
    18982189        thread_t   * this     = CURRENT_THREAD;
    1899         rpc_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
     2190        remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
    19002191    error_t      error;
    19012192
    1902     rpc_dmsg("\n[DMSG] %s : enter / thread %x / cluster %x / cycle %d\n",
    1903              __FUNCTION__ , this->trdid , local_cxy , hal_time_stamp() );
     2193grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %x / enter at cycle %d\n",
     2194__FUNCTION__ , local_cxy , this->core->lid , this->trdid , hal_time_stamp() );
    19042195
    19052196    // calling thread does nothing if light lock already taken or FIFO empty 
    19062197        if( (rpc_fifo->owner != 0) || (local_fifo_is_empty( &rpc_fifo->fifo )) )
    19072198    {
    1908         rpc_dmsg("\n[DMSG] %s : exit do nothing / thread %x / cluster %x / cycle %d\n",
    1909                  __FUNCTION__ , this->trdid , local_cxy , hal_time_stamp() );
    1910 
    1911         return false;
     2199
     2200grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %x / exit do nothing at cycle %d\n",
     2201__FUNCTION__ , local_cxy , this->core->lid , this->trdid , hal_time_stamp() );
     2202
     2203        return;
    19122204    }
    19132205
     
    19222214
    19232215            printk("\n[ERROR] in %s : no memory to create a RPC thread for core %d"
    1924                    " in cluster %x => do nothing\n",
    1925                    __FUNCTION__ , CURRENT_CORE->lid , local_cxy );
     2216            " in cluster %x => do nothing\n",
     2217            __FUNCTION__ , CURRENT_CORE->lid , local_cxy );
    19262218        }
    19272219
    1928         rpc_dmsg("\n[DMSG] %s : exit after RPC thread activation / "
    1929                  "thread %x / cluster %x / cycle %d\n",
    1930                  __FUNCTION__ , this->trdid , local_cxy , hal_time_stamp() );
    1931 
    1932         return true;
     2220        return;
    19332221    }
    19342222    else  // light lock taken by another thread
    19352223    {
    1936         rpc_dmsg("\n[DMSG] %s : exit do nothing / thread %x / cluster %x / cycle %d\n",
    1937                  __FUNCTION__ , this->trdid , local_cxy , hal_time_stamp() );
    1938 
    1939         return false;
     2224
     2225grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %x / exit do nothing at cycle %d\n",
     2226__FUNCTION__ , local_cxy , this->core->lid , this->trdid , hal_time_stamp() );
     2227
     2228        return;
    19402229    }
    19412230} // end rpc_check()
     
    19492238 
    19502239        thread_t   * this     = CURRENT_THREAD;
    1951         rpc_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
    1952 
    1953     rpc_dmsg("\n[DMSG] %s : enter / thread %x on core[%x,%d] / cycle %d\n",
    1954              __FUNCTION__, this->trdid, local_cxy, this->core->lid, hal_time_stamp() );
    1955 
    1956     // this infinite loop is not preemptable
    1957     // the RPC thread deschedule only when the RPC_FIFO is empty
     2240        remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo;
     2241
    19582242        while(1)
    19592243        {
    19602244        // check fifo ownership (ownership should be given by rpc_activate()
    1961         if( this->trdid != rpc_fifo->owner )
    1962         {
    1963             panic("thread %x on core[%x,%d] not owner of RPC_FIFO",
    1964                   this->trdid, local_cxy, this->core->lid );
    1965         }
     2245        assert( (this->trdid == rpc_fifo->owner) , __FUNCTION__ ,
     2246        "thread %x on core[%x,%d] not owner of RPC_FIFO / owner = %x\n",
     2247        this->trdid, local_cxy, this->core->lid , rpc_fifo->owner );
    19662248 
    19672249        // executes pending RPC(s)
    19682250        rpc_execute_all( rpc_fifo );
    19692251
    1970         // release rpc_fifo ownership (can be lost during RPC execution)
     2252        // release rpc_fifo ownership if required
     2253        // (this ownership can be lost during RPC execution)
    19712254        if( rpc_fifo->owner == this->trdid ) rpc_fifo->owner = 0;
    19722255
    1973 
    1974         //  block and deschedule or sucide
    1975                 if( LOCAL_CLUSTER->rpc_threads >= CONFIG_RPC_THREADS_MAX )
     2256        //  deschedule or sucide
     2257                if( LOCAL_CLUSTER->rpc_threads >= CONFIG_RPC_THREADS_MAX )  // suicide
    19762258                {
    1977             rpc_dmsg("\n[DMSG] %s : RPC thread %x on core[%x,%d] suicide / cycle %d\n",
    1978                     __FUNCTION__, this->trdid, local_cxy, this->core->lid, hal_time_stamp() );
     2259
     2260grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %x / suicide at cycle %d\n",
     2261__FUNCTION__, local_cxy, this->core->lid, this->trdid, hal_time_stamp() );
    19792262
    19802263            // update core descriptor counter
     
    19842267                        thread_exit();
    19852268                }
    1986         else
     2269        else                                                       // deschedule
    19872270        {
    1988             rpc_dmsg("\n[DMSG] %s : RPC thread %x on core[%x,%d] blocks / cycle %d\n",
    1989                         __FUNCTION__, this->trdid, local_cxy, this->core->lid, hal_time_stamp() );
    1990 
    1991                     thread_block( this , THREAD_BLOCKED_IDLE );
    1992             sched_yield( NULL );
    1993 
    1994                     rpc_dmsg("\n[DMSG] %s : RPC thread %x wake up on core[%x,%d] / cycle %d\n",
    1995                 __FUNCTION__, this->trdid, local_cxy, this->core->lid, hal_time_stamp() );
     2271
     2272grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %x / deschedule at cycle %d\n",
     2273__FUNCTION__, local_cxy, this->core->lid, this->trdid, hal_time_stamp() );
     2274
     2275            sched_yield();
     2276
     2277grpc_dmsg("\n[DBG] %s : core[%x,%d] / thread %x / wake up at cycle %d\n",
     2278__FUNCTION__, local_cxy, this->core->lid, this->trdid, hal_time_stamp() );
     2279
    19962280        }
    19972281        } // end while
    19982282} // end rpc_thread_func()
    19992283
     2284*/
     2285
     2286
Note: See TracChangeset for help on using the changeset viewer.