source: trunk/kernel/kern/rpc.c @ 656

Last change on this file since 656 was 641, checked in by alain, 5 years ago
  • Fix several bugs.
  • Introduce the "stat" command in KSH.

This almos-mkh version sucessfully executed the FFT application
(65536 complex points) on the TSAR architecture from 1 to 64 cores.

File size: 100.0 KB
RevLine 
[1]1/*
[437]2 * rpc.c - RPC operations implementation.
[1]3 *
[623]4 * Author    Alain Greiner (2016,2017,2018,2019)
[1]5 *
6 * Copyright (c)  UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[14]24#include <kernel_config.h>
[457]25#include <hal_kernel_types.h>
[625]26#include <hal_vmm.h>
[1]27#include <hal_atomic.h>
28#include <hal_remote.h>
29#include <hal_irqmask.h>
30#include <hal_special.h>
31#include <printk.h>
[612]32#include <user_dir.h>
[1]33#include <remote_sem.h>
34#include <core.h>
35#include <mapper.h>
[5]36#include <chdev.h>
[1]37#include <bits.h>
38#include <thread.h>
39#include <cluster.h>
40#include <process.h>
41#include <vfs.h>
42#include <fatfs.h>
43#include <rpc.h>
44
[433]45
[1]46/////////////////////////////////////////////////////////////////////////////////////////
[564]47// Array of function pointers and array of printable strings.
48// These arrays must be kept consistent with enum in rpc.h file.
[1]49/////////////////////////////////////////////////////////////////////////////////////////
50
51rpc_server_t * rpc_server[RPC_MAX_INDEX] =
52{
[632]53    &rpc_undefined,                        // 0
54    &rpc_undefined,                        // 1
55    &rpc_undefined,                        // 2
[601]56    &rpc_process_make_fork_server,         // 3
[614]57    &rpc_user_dir_create_server,           // 4
58    &rpc_user_dir_destroy_server,          // 5
[601]59    &rpc_thread_user_create_server,        // 6
60    &rpc_thread_kernel_create_server,      // 7
[623]61    &rpc_vfs_fs_update_dentry_server,      // 8
[601]62    &rpc_process_sigaction_server,         // 9
[1]63
[601]64    &rpc_vfs_inode_create_server,          // 10 
65    &rpc_vfs_inode_destroy_server,         // 11 
66    &rpc_vfs_dentry_create_server,         // 12 
67    &rpc_vfs_dentry_destroy_server,        // 13 
68    &rpc_vfs_file_create_server,           // 14
69    &rpc_vfs_file_destroy_server,          // 15
[623]70    &rpc_vfs_fs_new_dentry_server,         // 16
[601]71    &rpc_vfs_fs_add_dentry_server,         // 17
72    &rpc_vfs_fs_remove_dentry_server,      // 18
73    &rpc_vfs_inode_load_all_pages_server,  // 19
[1]74
[640]75    &rpc_undefined,                        // 20
76    &rpc_undefined,                        // 21
[635]77    &rpc_undefined,                        // 22
78    &rpc_undefined,                        // 23
[623]79    &rpc_mapper_sync_server,               // 24
[640]80    &rpc_vmm_resize_vseg_server,           // 25
81    &rpc_vmm_remove_vseg_server,           // 26
[601]82    &rpc_vmm_create_vseg_server,           // 27
83    &rpc_vmm_set_cow_server,               // 28
[635]84    &rpc_undefined,                        // 29
[1]85};
86
[564]87char * rpc_str[RPC_MAX_INDEX] =
88{
[632]89    "undefined_0",               // 0
90    "undefined_1",               // 1
91    "undefined_2",               // 2
[601]92    "PROCESS_MAKE_FORK",         // 3
[614]93    "USER_DIR_CREATE",           // 4
94    "USER_DIR_DESTROY",          // 5
[601]95    "THREAD_USER_CREATE",        // 6
96    "THREAD_KERNEL_CREATE",      // 7
[623]97    "VFS_FS_UPDATE_DENTRY",      // 8
[601]98    "PROCESS_SIGACTION",         // 9
[564]99
[601]100    "VFS_INODE_CREATE",          // 10
101    "VFS_INODE_DESTROY",         // 11
102    "VFS_DENTRY_CREATE",         // 12
103    "VFS_DENTRY_DESTROY",        // 13
104    "VFS_FILE_CREATE",           // 14
105    "VFS_FILE_DESTROY",          // 15
[629]106    "VFS_FS_NEW_DENTRY",         // 16
[601]107    "VFS_FS_ADD_DENTRY",         // 17
108    "VFS_FS_REMOVE_DENTRY",      // 18
109    "VFS_INODE_LOAD_ALL_PAGES",  // 19
[564]110
[640]111    "VMM_GLOBAL_RESIZE_VSEG",    // 20
112    "VMM_GLOBAL_UPDATE_PTE",     // 21
[635]113    "undefined_22",              // 22
114    "undefined_23",              // 23
[623]115    "MAPPER_SYNC",               // 24
[635]116    "undefined_25",              // 25
[640]117    "VMM_REMOVE_VSEG",           // 26
[601]118    "VMM_CREATE_VSEG",           // 27
119    "VMM_SET_COW",               // 28
[635]120    "undefined_29",              // 29
[564]121};
122
123//////////////////////////////////////////////////////////////////////////////////
[503]124void __attribute__((noinline)) rpc_undefined( xptr_t xp __attribute__ ((unused)) )
[1]125{
[492]126        assert( false , "called in cluster %x", local_cxy );
[1]127}
128
[409]129/***************************************************************************************/
[583]130/************ Generic function supporting RPCs : client side ***************************/
[409]131/***************************************************************************************/
132
133///////////////////////////////////////
134void rpc_send( cxy_t        server_cxy, 
[416]135               rpc_desc_t * rpc )
[409]136{
[438]137    lid_t              server_core_lid;
138    lid_t              client_core_lid;
139    volatile error_t   full;
140    thread_t         * this;
[409]141
[457]142    full            = 0;
143    this            = CURRENT_THREAD;
144    client_core_lid = this->core->lid;
145
[619]146    // check calling thread can yield when is not the IDLE thread
[581]147    // RPCs executed by the IDLE thread during kernel_init do not deschedule
148    if( this->type != THREAD_IDLE ) thread_assert_can_yield( this , __FUNCTION__ );
[564]149
[440]150    // select a server_core : use client core index if possible / core 0 otherwise
[564]151    if( client_core_lid < hal_remote_l32( XPTR( server_cxy , &LOCAL_CLUSTER->cores_nr ) ) )
[438]152    {
153        server_core_lid = client_core_lid;
154    }
155    else
156    {   
157        server_core_lid = 0;
158    }
159
[583]160    // register client_thread and client_core in RPC descriptor
[436]161    rpc->thread = this;
[438]162    rpc->lid    = client_core_lid;
[409]163
[438]164    // build extended pointer on the RPC descriptor
[409]165        xptr_t   desc_xp = XPTR( local_cxy , rpc );
166
[436]167    // get local pointer on rpc_fifo in remote cluster,
[564]168    remote_fifo_t * rpc_fifo    = &LOCAL_CLUSTER->rpc_fifo[server_core_lid];
169    xptr_t          rpc_fifo_xp = XPTR( server_cxy , rpc_fifo );
[409]170
[564]171        // post RPC in remote fifo / deschedule without blocking if fifo full
[409]172    do
173    { 
[564]174        full = remote_fifo_put_item( rpc_fifo_xp , (uint64_t )desc_xp );
175
[436]176            if ( full ) 
[409]177        {
178            printk("\n[WARNING] %s : cluster %x cannot post RPC to cluster %x\n",
179            __FUNCTION__ , local_cxy , server_cxy );
180
[436]181            // deschedule without blocking
182            sched_yield("RPC fifo full");
[409]183        }
184    }
[436]185    while( full );
[409]186 
[457]187#if DEBUG_RPC_CLIENT_GENERIC
[583]188uint32_t cycle = (uint32_t)hal_get_cycles();
[564]189uint32_t items = remote_fifo_items( rpc_fifo_xp );
[457]190if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 
[601]191printk("\n[%s] thread[%x,%x] / rpc %s / server[%x,%d] / items %d / cycle %d\n",
192__FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], 
[583]193server_cxy, server_core_lid, items, cycle );
[457]194#endif
[409]195       
[457]196   // send IPI to the selected server core
197   dev_pic_send_ipi( server_cxy , server_core_lid );
[409]198
[564]199    // wait RPC completion before returning if blocking RPC :
[619]200    // - deschedule without blocking if thread idle (in kernel init)
[564]201    // - block and deschedule policy for any other thread
[416]202    if ( rpc->blocking )
[409]203    {
[564]204        if( this->type == THREAD_IDLE )  // deschedule without blocking policy
[409]205        {
[564]206 
[438]207#if DEBUG_RPC_CLIENT_GENERIC
[436]208cycle = (uint32_t)hal_get_cycles();
[438]209if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 
[601]210printk("\n[%s] thread[%x,%x] enter waiting loop for rpc %s / cycle %d\n",
211__FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle );
[436]212#endif
[619]213             while( 1 )
214             {
215                 // check responses counter
216                 if( hal_remote_l32( XPTR( local_cxy , rpc->rsp ) ) == 0 ) break;
217                   
218                 // deschedule
219                 sched_yield("busy_waiting RPC completion");
220             }
[409]221
[438]222#if DEBUG_RPC_CLIENT_GENERIC
[436]223cycle = (uint32_t)hal_get_cycles();
[438]224if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 
[601]225printk("\n[%s] thread[%x,%x] received response for rpc %s / cycle %d\n",
226__FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle );
[436]227#endif
[564]228 
229        }
230        else                            // block and deschedule policy
[409]231        {
232
[438]233#if DEBUG_RPC_CLIENT_GENERIC
[436]234cycle = (uint32_t)hal_get_cycles();
[438]235if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 
[601]236printk("\n[%s] thread[%x,%x] blocks & deschedules for rpc %s / cycle %d\n",
237__FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle );
[436]238#endif
[409]239
[564]240        // block client thread
241        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_RPC );
242
243        // deschedule
244        sched_yield("blocked on RPC");
245
[438]246#if DEBUG_RPC_CLIENT_GENERIC
[436]247cycle = (uint32_t)hal_get_cycles();
[438]248if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 
[619]249printk("\n[%s] thread[%x,%x] resumes after rpc %s / cycle %d\n",
[601]250__FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle );
[436]251#endif
[409]252        }
253
[564]254// response must be available for a blocking RPC
[619]255assert( (*rpc->rsp == 0) , "illegal response for RPC %s\n", rpc_str[rpc->index] );
[564]256
[409]257    }
[564]258    else       // non blocking RPC
[436]259    {
260
[438]261#if DEBUG_RPC_CLIENT_GENERIC
[436]262cycle = (uint32_t)hal_get_cycles();
[438]263if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 
[601]264printk("\n[%s] thread[%x,%x] returns for non blocking rpc %s / cycle %d\n",
265__FUNCTION__, this->process->pid, this->trdid, rpc_str[rpc->index], cycle );
[436]266#endif
267
268    }
[409]269}  // end rpc_send()
270
271
272/***************************************************************************************/
273/************ Generic functions supporting RPCs : server side **************************/
274/***************************************************************************************/
275
[564]276////////////////////////////
[619]277void rpc_server_func( void )
[409]278{
[440]279    error_t         empty;              // local RPC fifo state
280    xptr_t          desc_xp;            // extended pointer on RPC request
281    cxy_t           desc_cxy;           // RPC request cluster (client)
282    rpc_desc_t    * desc_ptr;           // RPC request local pointer
283    uint32_t        index;              // RPC request index
284    thread_t      * client_ptr;         // local pointer on client thread
[619]285    xptr_t          client_xp;          // extended pointer on client thread
286    lid_t           client_lid;         // local index of client core
[440]287        thread_t      * server_ptr;         // local pointer on server thread
288    xptr_t          server_xp;          // extended pointer on server thread
[619]289    lid_t           server_lid;         // local index of server core
[440]290        remote_fifo_t * rpc_fifo;           // local pointer on RPC fifo
[619]291    uint32_t      * rsp_ptr;            // local pointer on responses counter
292    xptr_t          rsp_xp;             // extended pointer on responses counter
293    uint32_t        responses;          // number of expected responses
294
[409]295    // makes RPC thread not preemptable
296        hal_disable_irq( NULL );
297 
[440]298        server_ptr      = CURRENT_THREAD;
299    server_xp       = XPTR( local_cxy , server_ptr );
[619]300    server_lid      = server_ptr->core->lid;
301        rpc_fifo        = &LOCAL_CLUSTER->rpc_fifo[server_lid];
[409]302
[564]303    // "infinite" RPC thread loop
304        while(1)
[409]305        {
306        // try to take RPC_FIFO ownership
[564]307        if( hal_atomic_test_set( &rpc_fifo->owner , server_ptr->trdid ) ) 
[409]308        {
[436]309
[438]310#if DEBUG_RPC_SERVER_GENERIC
[436]311uint32_t cycle = (uint32_t)hal_get_cycles();
[438]312if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
[611]313printk("\n[%s] RPC thread[%x,%x] on core[%d] takes RPC_FIFO ownership / cycle %d\n",
[619]314__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, server_lid, cycle );
[436]315#endif
[564]316                // try to consume one RPC request 
317                empty = remote_fifo_get_item( rpc_fifo , (uint64_t *)&desc_xp );
318
319            // release RPC_FIFO ownership
320            rpc_fifo->owner = 0;
321
322            // handle RPC request if success
323                if ( empty == 0 )   
[409]324            {
[564]325                // get client cluster and pointer on RPC descriptor
326                desc_cxy = GET_CXY( desc_xp );
327                desc_ptr = GET_PTR( desc_xp );
[409]328
[619]329                // get relevant infos from RPC descriptor
[610]330                    index      = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) );
331                client_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->thread ) );
[619]332                rsp_ptr    = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->rsp ) );
333                client_lid = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->lid ) );
[409]334
[619]335                rsp_xp     = XPTR( desc_cxy , rsp_ptr );
336                client_xp  = XPTR( desc_cxy , client_ptr );
337
[438]338#if DEBUG_RPC_SERVER_GENERIC
[436]339cycle = (uint32_t)hal_get_cycles();
[564]340uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) );
[438]341if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
[611]342printk("\n[%s] RPC thread[%x,%x] got rpc %s / client_cxy %x / items %d / cycle %d\n",
343__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle );
[436]344#endif
[610]345                // register client thread in RPC thread descriptor
[619]346                server_ptr->rpc_client_xp = client_xp;
[610]347 
[564]348                // call the relevant server function
349                rpc_server[index]( desc_xp );
[409]350
[641]351                // update responses counter
352                responses = hal_remote_atomic_add( rsp_xp , -1 );
353
[438]354#if DEBUG_RPC_SERVER_GENERIC
[436]355cycle = (uint32_t)hal_get_cycles();
[438]356if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
[641]357printk("\n[%s] RPC thread[%x,%x] completes rpc %s / responses %d / cycle %d\n",
358__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], responses, cycle );
[436]359#endif
[619]360                // decrement expected responses counter
361                // unblock client thread if last response
362                if( responses == 1 ) 
[564]363                {
364                    // unblock client thread
[619]365                    thread_unblock( client_xp , THREAD_BLOCKED_RPC );
[409]366
[564]367                    hal_fence();
[409]368
[438]369#if DEBUG_RPC_SERVER_GENERIC
370cycle = (uint32_t)hal_get_cycles();
[619]371trdid_t     client_trdid = hal_remote_l32( XPTR( desc_cxy , &client_ptr->trdid ) );
372process_t * process      = hal_remote_lpt( XPTR( desc_cxy , &client_ptr->process ) );
373pid_t       client_pid   = hal_remote_l32( XPTR( desc_cxy , &process->pid ) );
[438]374if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
[611]375printk("\n[%s] RPC thread[%x,%x] unblocked client thread[%x,%x] / cycle %d\n",
376__FUNCTION__, server_ptr->process->pid, server_ptr->trdid,
[619]377client_pid, client_trdid, cycle );
[438]378#endif
[564]379                    // send IPI to client core
[619]380                    dev_pic_send_ipi( desc_cxy , client_lid );
[611]381                }
[564]382            }  // end RPC handling if fifo non empty
383        }  // end if RPC_fIFO ownership successfully taken and released
[409]384
[564]385        // sucide if too many RPC threads
[619]386        if( LOCAL_CLUSTER->rpc_threads[server_lid] >= CONFIG_RPC_THREADS_MAX )
[409]387            {
388
[438]389#if DEBUG_RPC_SERVER_GENERIC
[436]390uint32_t cycle = (uint32_t)hal_get_cycles();
[438]391if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
[611]392printk("\n[%s] RPC thread[%x,%x] suicides / cycle %d\n",
393__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, cycle );
[436]394#endif
[409]395            // update RPC threads counter
[619]396                hal_atomic_add( &LOCAL_CLUSTER->rpc_threads[server_lid] , -1 );
[409]397
[440]398            // RPC thread blocks on GLOBAL
399                thread_block( server_xp , THREAD_BLOCKED_GLOBAL );
400
401            // RPC thread set the REQ_DELETE flag to suicide
402            hal_remote_atomic_or( server_xp , THREAD_FLAG_REQ_DELETE );
[409]403            }
[564]404        // block and deschedule otherwise
[440]405        else
406        {
[409]407
[438]408#if DEBUG_RPC_SERVER_GENERIC
[436]409uint32_t cycle = (uint32_t)hal_get_cycles();
[438]410if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
[619]411printk("\n[%s] RPC thread[%x,%x] blocks & deschedules / cycle %d\n",
[611]412__FUNCTION__, server_ptr->process->pid, server_ptr->trdid, cycle );
[436]413#endif
[564]414            // RPC thread blocks on IDLE
415            thread_block( server_xp , THREAD_BLOCKED_IDLE );
[409]416
[440]417            // RPC thread deschedules
[564]418            sched_yield("RPC_FIFO empty");
[440]419        }
[438]420        } // end infinite loop
[409]421
[619]422} // end rpc_server_func()
[409]423
[619]424
[1]425/////////////////////////////////////////////////////////////////////////////////////////
[632]426// [0]       RPC_PMEM_GET_PAGES deprecated [AG] May 2019
[1]427/////////////////////////////////////////////////////////////////////////////////////////
428
[632]429/*
[1]430///////////////////////////////////////////////
431void rpc_pmem_get_pages_client( cxy_t      cxy,
432                                uint32_t   order,      // in
[313]433                                page_t  ** page )      // out
[1]434{
[438]435#if DEBUG_RPC_PMEM_GET_PAGES
[564]436thread_t * this = CURRENT_THREAD;
[438]437uint32_t cycle = (uint32_t)hal_get_cycles();
438if( cycle > DEBUG_RPC_PMEM_GET_PAGES )
[601]439printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
440__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]441#endif
[296]442
[619]443    uint32_t responses = 1;
[1]444
445    // initialise RPC descriptor header
446    rpc_desc_t  rpc;
[438]447    rpc.index     = RPC_PMEM_GET_PAGES;
448    rpc.blocking  = true;
[619]449    rpc.rsp       = &responses;
[1]450
451    // set input arguments in RPC descriptor
452    rpc.args[0] = (uint64_t)order;
453
[436]454    // register RPC request in remote RPC fifo
[416]455    rpc_send( cxy , &rpc );
[1]456
[313]457    // get output arguments from RPC descriptor
[407]458    *page = (page_t *)(intptr_t)rpc.args[1];
[279]459
[438]460#if DEBUG_RPC_PMEM_GET_PAGES
461cycle = (uint32_t)hal_get_cycles();
462if( cycle > DEBUG_RPC_PMEM_GET_PAGES )
[601]463printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
464__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]465#endif
[1]466}
467
468///////////////////////////////////////////
469void rpc_pmem_get_pages_server( xptr_t xp )
470{
[438]471#if DEBUG_RPC_PMEM_GET_PAGES
[564]472thread_t * this = CURRENT_THREAD;
[438]473uint32_t cycle = (uint32_t)hal_get_cycles();
474if( cycle > DEBUG_RPC_PMEM_GET_PAGES )
[601]475printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
476__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]477#endif
[296]478
[1]479    // get client cluster identifier and pointer on RPC descriptor
[436]480    cxy_t        cxy  = GET_CXY( xp );
481    rpc_desc_t * desc = GET_PTR( xp );
[1]482
483    // get input arguments from client RPC descriptor
[564]484    uint32_t order = (uint32_t)hal_remote_l64( XPTR( cxy , &desc->args[0] ) );
[1]485   
486    // call local pmem allocator
487    page_t * page = ppm_alloc_pages( order );
488
489    // set output arguments into client RPC descriptor
[564]490    hal_remote_s64( XPTR( cxy , &desc->args[1] ) , (uint64_t)(intptr_t)page );
[296]491
[438]492#if DEBUG_RPC_PMEM_GET_PAGES
493cycle = (uint32_t)hal_get_cycles();
494if( cycle > DEBUG_RPC_PMEM_GET_PAGES )
[601]495printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
496__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]497#endif
[1]498}
[632]499*/
[1]500
501/////////////////////////////////////////////////////////////////////////////////////////
[632]502// [1]       RPC_PMEM_RELEASE_PAGES deprecated [AG] may 2019
[1]503/////////////////////////////////////////////////////////////////////////////////////////
504
[632]505/*
[409]506//////////////////////////////////////////////////
507void rpc_pmem_release_pages_client( cxy_t     cxy,
508                                    page_t  * page )      // out
509{
[438]510#if DEBUG_RPC_PMEM_RELEASE_PAGES
[564]511thread_t * this = CURRENT_THREAD;
[438]512uint32_t cycle = (uint32_t)hal_get_cycles();
513if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES )
[601]514printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
515__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[438]516#endif
[409]517
[619]518    uint32_t responses = 1;
[409]519
520    // initialise RPC descriptor header
521    rpc_desc_t  rpc;
522    rpc.index    = RPC_PMEM_RELEASE_PAGES;
[416]523    rpc.blocking = true;
[619]524    rpc.rsp      = &responses;
[409]525
526    // set input arguments in RPC descriptor
527    rpc.args[0] = (uint64_t)(intptr_t)page;
528
[436]529    // register RPC request in remote RPC fifo
[416]530    rpc_send( cxy , &rpc );
[409]531
[438]532#if DEBUG_RPC_PMEM_RELEASE_PAGES
533cycle = (uint32_t)hal_get_cycles();
534if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES )
[601]535printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
536__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]537#endif
[409]538}
539
540///////////////////////////////////////////////
541void rpc_pmem_release_pages_server( xptr_t xp )
542{
[438]543#if DEBUG_RPC_PMEM_RELEASE_PAGES
[564]544thread_t * this = CURRENT_THREAD;
[438]545uint32_t cycle = (uint32_t)hal_get_cycles();
546if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES )
[601]547printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
548__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[438]549#endif
[409]550
551    // get client cluster identifier and pointer on RPC descriptor
[436]552    cxy_t        cxy  = GET_CXY( xp );
553    rpc_desc_t * desc = GET_PTR( xp );
[409]554
555    // get input arguments from client RPC descriptor
[564]556    page_t * page = (page_t *)(intptr_t)hal_remote_l64( XPTR( cxy , &desc->args[0] ) );
[409]557   
558    // release memory to local pmem
559    kmem_req_t req;
[635]560    req.type = KMEM_PPM;
[409]561    req.ptr  = page;
562    kmem_free( &req );
563
[438]564#if DEBUG_RPC_PMEM_RELEASE_PAGES
565cycle = (uint32_t)hal_get_cycles();
566if( cycle > DEBUG_RPC_PMEM_RELEASE_PAGES )
[601]567printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
568__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]569#endif
[409]570}
[632]571*/
[409]572
573/////////////////////////////////////////////////////////////////////////////////////////
[632]574// [2]          RPC_PPM_DISPLAY deprecated [AG] May 2019   
[409]575/////////////////////////////////////////////////////////////////////////////////////////
576
[632]577/*
[625]578/////////////////////////////////////////
579void rpc_ppm_display_client( cxy_t  cxy )
580{
581#if DEBUG_RPC_PPM_DISPLAY
582thread_t * this = CURRENT_THREAD;
583uint32_t cycle = (uint32_t)hal_get_cycles();
584if( cycle > DEBUG_RPC_PPM_DISPLAY )
585printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
586__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
587#endif
588
589    uint32_t responses = 1;
590
591    // initialise RPC descriptor header
592    rpc_desc_t  rpc;
593    rpc.index    = RPC_PPM_DISPLAY;
594    rpc.blocking = true;
595    rpc.rsp      = &responses;
596
597    // register RPC request in remote RPC fifo
598    rpc_send( cxy , &rpc );
599
600#if DEBUG_RPC_PPM_DISPLAY
601cycle = (uint32_t)hal_get_cycles();
602if( cycle > DEBUG_RPC_PPM_DISPLAY )
603printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
604__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
605#endif
606}
607
608////////////////////////////////////////////////////////////////////
609void rpc_ppm_display_server( xptr_t __attribute__((__unused__)) xp )
610{
611#if DEBUG_RPC_PPM_DISPLAY
612thread_t * this = CURRENT_THREAD;
613uint32_t cycle = (uint32_t)hal_get_cycles();
614if( cycle > DEBUG_RPC_PPM_DISPLAY )
615printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
616__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
617#endif
618
619    // call local kernel function
620    ppm_display();
621
622#if DEBUG_RPC_PPM_DISPLAY
623cycle = (uint32_t)hal_get_cycles();
624if( cycle > DEBUG_RPC_PPM_DISPLAY )
625printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
626__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
627#endif
628}
[632]629*/
[625]630
[1]631/////////////////////////////////////////////////////////////////////////////////////////
[619]632// [3]           Marshaling functions attached to RPC_PROCESS_MAKE_FORK
[1]633/////////////////////////////////////////////////////////////////////////////////////////
634
[408]635///////////////////////////////////////////////////
636void rpc_process_make_fork_client( cxy_t       cxy,
637                                   xptr_t      ref_process_xp,      // in
638                                   xptr_t      parent_thread_xp,    // in
639                                   pid_t     * child_pid,           // out
640                                   thread_t ** child_thread_ptr,    // out     
641                                   error_t   * error )              // out
[1]642{
[438]643#if DEBUG_RPC_PROCESS_MAKE_FORK
[564]644thread_t * this = CURRENT_THREAD;
[438]645uint32_t cycle = (uint32_t)hal_get_cycles();
646if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK )
[601]647printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
648__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[438]649#endif
650
[619]651    uint32_t responses = 1;
[1]652
653    // initialise RPC descriptor header
654    rpc_desc_t  rpc;
[408]655    rpc.index    = RPC_PROCESS_MAKE_FORK;
[416]656    rpc.blocking = true;
[619]657    rpc.rsp      = &responses;
[1]658
659    // set input arguments in RPC descriptor 
[440]660    rpc.args[0] = (uint64_t)ref_process_xp;
661    rpc.args[1] = (uint64_t)parent_thread_xp;
[1]662
[436]663    // register RPC request in remote RPC fifo
[416]664    rpc_send( cxy , &rpc );
[1]665
666    // get output arguments from RPC descriptor
[408]667    *child_pid         = (pid_t)rpc.args[2];
668    *child_thread_ptr  = (thread_t *)(intptr_t)rpc.args[3];
669    *error             = (error_t)rpc.args[4];     
[279]670
[438]671#if DEBUG_RPC_PROCESS_MAKE_FORK
672cycle = (uint32_t)hal_get_cycles();
673if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK )
[601]674printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
675__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]676#endif
[1]677}
678
[408]679//////////////////////////////////////////////
680void rpc_process_make_fork_server( xptr_t xp )
[1]681{
[438]682#if DEBUG_RPC_PROCESS_MAKE_FORK
[564]683thread_t * this = CURRENT_THREAD;
[438]684uint32_t cycle = (uint32_t)hal_get_cycles();
685if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK )
[601]686printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
687__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]688#endif
[409]689
[408]690    xptr_t     ref_process_xp;     // extended pointer on reference parent process
691    xptr_t     parent_thread_xp;   // extended pointer on parent thread
692    pid_t      child_pid;          // child process identifier
693    thread_t * child_thread_ptr;   // local copy of exec_info structure
694    error_t    error;              // local error status
[1]695
696    // get client cluster identifier and pointer on RPC descriptor
[436]697    cxy_t        client_cxy  = GET_CXY( xp );
698    rpc_desc_t * desc        = GET_PTR( xp );
[1]699
[408]700    // get input arguments from cient RPC descriptor
[564]701    ref_process_xp   = (xptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
702    parent_thread_xp = (xptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
[1]703
704    // call local kernel function
[408]705    error = process_make_fork( ref_process_xp,
706                               parent_thread_xp,
707                               &child_pid,
708                               &child_thread_ptr ); 
[1]709
710    // set output argument into client RPC descriptor
[564]711    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)child_pid );
712    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)(intptr_t)child_thread_ptr );
713    hal_remote_s64( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
[296]714
[438]715#if DEBUG_RPC_PROCESS_MAKE_FORK
716cycle = (uint32_t)hal_get_cycles();
717if( cycle > DEBUG_RPC_PROCESS_MAKE_FORK )
[601]718printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
719__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]720#endif
[1]721}
722
723/////////////////////////////////////////////////////////////////////////////////////////
[619]724// [4]      Marshaling functions attached to RPC_USER_DIR_CREATE 
[1]725/////////////////////////////////////////////////////////////////////////////////////////
726
[612]727////////////////////////////////////////////////////
728void rpc_user_dir_create_client( cxy_t          cxy,
729                                 vfs_inode_t *  inode,
[614]730                                 xptr_t         ref_xp,
[612]731                                 user_dir_t  ** dir )
732{
733#if DEBUG_RPC_USER_DIR_CREATE
734thread_t * this = CURRENT_THREAD;
735uint32_t cycle = (uint32_t)hal_get_cycles();
736if( cycle > DEBUG_RPC_USER_DIR_CREATE)
737printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
738__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
739#endif
740
[619]741    uint32_t responses = 1;
[612]742
743    // initialise RPC descriptor header
744    rpc_desc_t  rpc;
745    rpc.index    = RPC_USER_DIR_CREATE;
746    rpc.blocking = true;
[619]747    rpc.rsp      = &responses;
[612]748
749    // set input arguments in RPC descriptor
750    rpc.args[0] = (uint64_t)(intptr_t)inode;
[614]751    rpc.args[1] = (uint64_t)ref_xp;
[612]752
753    // register RPC request in remote RPC fifo
754    rpc_send( cxy , &rpc );
755
756    // get output argument from RPC descriptor
[614]757    *dir = (user_dir_t *)(intptr_t)rpc.args[2];
[612]758
759#if DEBUG_RPC_USER_DIR_CREATE
760cycle = (uint32_t)hal_get_cycles();
761if( cycle > DEBUG_RPC_USER_DIR_CREATE)
762printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
763__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
764#endif
765}
766
767////////////////////////////////////////////
768void rpc_user_dir_create_server( xptr_t xp )
769{
770#if DEBUG_RPC_USER_DIR_CREATE
771thread_t * this = CURRENT_THREAD;
772uint32_t cycle = (uint32_t)hal_get_cycles();
773if( cycle > DEBUG_RPC_USER_DIR_CREATE)
774printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
775__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
776#endif
777
778    vfs_inode_t * inode;          // pointer on inode in server cluster
[614]779    xptr_t        ref_xp;         // extended pointer on reference user process
[612]780    user_dir_t  * dir;            // pointer on user_dir structure in server cluster
781
782    // get client cluster identifier and pointer on RPC descriptor
783    cxy_t        client_cxy  = GET_CXY( xp );
784    rpc_desc_t * desc        = GET_PTR( xp );
785
786    // get input argument from RPC descriptor
[614]787    inode  = (vfs_inode_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
788    ref_xp = (xptr_t)                 hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
[612]789
790    // call kernel function
[614]791    dir = user_dir_create( inode , ref_xp );
[612]792
793    // set output argument into RPC descriptor
[614]794    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (intptr_t)dir );
[612]795
796#if DEBUG_RPC_USER_DIR_CREATE
797cycle = (uint32_t)hal_get_cycles();
798if( cycle > DEBUG_RPC_USER_DIR_CREATE)
799printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
800__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
801#endif
802}
803
[409]804/////////////////////////////////////////////////////////////////////////////////////////
[619]805// [5]      Marshaling functions attached to RPC_USER_DIR_DESTROY
[409]806/////////////////////////////////////////////////////////////////////////////////////////
807
[612]808////////////////////////////////////////////////////
809void rpc_user_dir_destroy_client( cxy_t         cxy,
[614]810                                  user_dir_t  * dir,
811                                  xptr_t        ref_xp )
[612]812{
813#if DEBUG_RPC_USER_DIR_DESTROY
814thread_t * this = CURRENT_THREAD;
815uint32_t cycle = (uint32_t)hal_get_cycles();
816if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
817printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
818__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
819#endif
820
[619]821    uint32_t responses = 1;
[612]822
823    // initialise RPC descriptor header
824    rpc_desc_t  rpc;
825    rpc.index    = RPC_USER_DIR_DESTROY;
826    rpc.blocking = true;
[619]827    rpc.rsp      = &responses;
[612]828
829    // set input arguments in RPC descriptor
830    rpc.args[0] = (uint64_t)(intptr_t)dir;
[614]831    rpc.args[1] = (uint64_t)ref_xp;
[612]832
833    // register RPC request in remote RPC fifo
834    rpc_send( cxy , &rpc );
835
836#if DEBUG_RPC_USER_DIR_DESTROY
837cycle = (uint32_t)hal_get_cycles();
838if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
839printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
840__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
841#endif
842}
843
844/////////////////////////////////////////////
845void rpc_user_dir_destroy_server( xptr_t xp )
846{
847#if DEBUG_RPC_USER_DIR_DESTROY
848thread_t * this = CURRENT_THREAD;
849uint32_t cycle = (uint32_t)hal_get_cycles();
850if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
851printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
852__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
853#endif
854
855    user_dir_t * dir;            // pointer on user_dir structure in server cluster
[614]856    xptr_t       ref_xp;         // extended pointer on reference process
[612]857
858    // get client cluster identifier and pointer on RPC descriptor
859    cxy_t        client_cxy  = GET_CXY( xp );
860    rpc_desc_t * desc        = GET_PTR( xp );
861
862    // get input argument from RPC descriptor
[614]863    dir    = (user_dir_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
864    ref_xp = (xptr_t)                hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
[612]865
866    // call kernel function
[614]867    user_dir_destroy( dir , ref_xp );
[612]868
869#if DEBUG_RPC_USER_DIR_DESTROY
870cycle = (uint32_t)hal_get_cycles();
871if( cycle > DEBUG_RPC_USER_DIR_DESTROY)
872printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
873__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
874#endif
875}
876
[1]877/////////////////////////////////////////////////////////////////////////////////////////
[619]878// [6]      Marshaling functions attached to RPC_THREAD_USER_CREATE   
[1]879/////////////////////////////////////////////////////////////////////////////////////////
880
881/////////////////////////////////////////////////////////
882void rpc_thread_user_create_client( cxy_t            cxy, 
[23]883                                    pid_t            pid,         // in
884                                    void           * start_func,  // in
885                                    void           * start_arg,   // in
[1]886                                    pthread_attr_t * attr,        // in
887                                    xptr_t         * thread_xp,   // out
888                                    error_t        * error )      // out
889{
[564]890#if DEBUG_RPC_THREAD_USER_CREATE
891thread_t * this = CURRENT_THREAD;
892uint32_t cycle = (uint32_t)hal_get_cycles();
893if( cycle > DEBUG_RPC_THREAD_USER_CREATE)
[601]894printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
895__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]896#endif
[619]897   
898    uint32_t responses = 1;
[564]899
[1]900    // initialise RPC descriptor header
901    rpc_desc_t  rpc;
[436]902    rpc.index    = RPC_THREAD_USER_CREATE;
[416]903    rpc.blocking = true;
[619]904    rpc.rsp      = &responses;
[1]905
906    // set input arguments in RPC descriptor
[23]907    rpc.args[0] = (uint64_t)pid;
908    rpc.args[1] = (uint64_t)(intptr_t)start_func;
909    rpc.args[2] = (uint64_t)(intptr_t)start_arg;
910    rpc.args[3] = (uint64_t)(intptr_t)attr;
[1]911
[436]912    // register RPC request in remote RPC fifo
[416]913    rpc_send( cxy , &rpc );
[1]914
915    // get output arguments from RPC descriptor
[23]916    *thread_xp = (xptr_t)rpc.args[4];
917    *error     = (error_t)rpc.args[5];
[279]918
[564]919#if DEBUG_RPC_THREAD_USER_CREATE
920cycle = (uint32_t)hal_get_cycles();
921if( cycle > DEBUG_RPC_THREAD_USER_CREATE)
[601]922printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
923__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]924#endif
[1]925}
926
927///////////////////////////////////////////////
928void rpc_thread_user_create_server( xptr_t xp )
929{
[564]930#if DEBUG_RPC_THREAD_USER_CREATE
931thread_t * this = CURRENT_THREAD;
932uint32_t cycle = (uint32_t)hal_get_cycles();
933if( cycle > DEBUG_RPC_THREAD_USER_CREATE)
[601]934printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
935__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]936#endif
[409]937
[1]938    pthread_attr_t * attr_ptr;   // pointer on attributes structure in client cluster
939    pthread_attr_t   attr_copy;  // attributes structure  copy in server cluster
940    thread_t       * thread_ptr; // local pointer on thread descriptor
941    xptr_t           thread_xp;  // extended pointer on thread descriptor
[23]942
[1]943    pid_t            pid;        // process identifier
[23]944    void           * start_func;
945    void           * start_arg;
946    error_t          error;
[1]947
948    // get client cluster identifier and pointer on RPC descriptor
[436]949    cxy_t        client_cxy  = GET_CXY( xp );
[438]950    rpc_desc_t * desc        = GET_PTR( xp );
[1]951
[23]952    // get input arguments from RPC descriptor
[564]953    pid        = (pid_t)                     hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
954    start_func = (void *)(intptr_t)          hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
955    start_arg  = (void *)(intptr_t)          hal_remote_l64(XPTR(client_cxy , &desc->args[2]));
956    attr_ptr   = (pthread_attr_t *)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[3]));
[23]957
[1]958    // makes a local copy of attributes structure
959    hal_remote_memcpy( XPTR( local_cxy , &attr_copy ),
960                       XPTR( client_cxy , attr_ptr ), 
961                       sizeof(pthread_attr_t) );
962   
[23]963    // call kernel function
964    error = thread_user_create( pid,
965                                start_func,
966                                start_arg,
967                                &attr_copy,
968                                &thread_ptr );
[1]969    // set output arguments
970    thread_xp = XPTR( local_cxy , thread_ptr );
[564]971    hal_remote_s64( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)thread_xp );
972    hal_remote_s64( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error );
[296]973
[564]974#if DEBUG_RPC_THREAD_USER_CREATE
975cycle = (uint32_t)hal_get_cycles();
976if( cycle > DEBUG_RPC_THREAD_USER_CREATE)
[601]977printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
978__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]979#endif
[1]980}
981
982/////////////////////////////////////////////////////////////////////////////////////////
[623]983// [7]      Marshaling functions attached to RPC_THREAD_KERNEL_CREATE
[1]984/////////////////////////////////////////////////////////////////////////////////////////
985
986////////////////////////////////////////////////////
987void rpc_thread_kernel_create_client( cxy_t     cxy,
988                                      uint32_t  type,        // in
989                                      void    * func,        // in
990                                      void    * args,        // in
991                                      xptr_t  * thread_xp,   // out
992                                      error_t * error )      // out
993{
[564]994#if DEBUG_RPC_THREAD_KERNEL_CREATE
995thread_t * this = CURRENT_THREAD;
996uint32_t cycle = (uint32_t)hal_get_cycles();
997if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE)
[601]998printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
999__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]1000#endif
1001
[619]1002    uint32_t responses = 1;
[1]1003
1004    // initialise RPC descriptor header
1005    rpc_desc_t  rpc;
1006    rpc.index    = RPC_THREAD_KERNEL_CREATE;
[416]1007    rpc.blocking = true;
[619]1008    rpc.rsp      = &responses;
[1]1009
1010    // set input arguments in RPC descriptor
1011    rpc.args[0] = (uint64_t)type;
1012    rpc.args[1] = (uint64_t)(intptr_t)func;
1013    rpc.args[2] = (uint64_t)(intptr_t)args;
1014   
[436]1015    // register RPC request in remote RPC fifo
[416]1016    rpc_send( cxy , &rpc );
[1]1017
1018    // get output arguments from RPC descriptor
1019    *thread_xp = (xptr_t)rpc.args[3];
1020    *error     = (error_t)rpc.args[4];
[279]1021
[564]1022#if DEBUG_RPC_THREAD_KERNEL_CREATE
1023cycle = (uint32_t)hal_get_cycles();
1024if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE)
[601]1025printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1026__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]1027#endif
[1]1028}
1029
1030/////////////////////////////////////////////////
1031void rpc_thread_kernel_create_server( xptr_t xp )
1032{
[564]1033#if DEBUG_RPC_THREAD_KERNEL_CREATE
1034thread_t * this = CURRENT_THREAD;
1035uint32_t cycle = (uint32_t)hal_get_cycles();
1036if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE)
[601]1037printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1038__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]1039#endif
1040
[1]1041    thread_t       * thread_ptr;  // local pointer on thread descriptor
1042    xptr_t           thread_xp;   // extended pointer on thread descriptor
1043    lid_t            core_lid;    // core local index
1044    error_t          error;   
1045
1046    // get client cluster identifier and pointer on RPC descriptor
[436]1047    cxy_t        client_cxy  = GET_CXY( xp );
[438]1048    rpc_desc_t * desc        = GET_PTR( xp );
[1]1049
1050    // get attributes from RPC descriptor
[564]1051    uint32_t  type = (uint32_t)       hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
1052    void    * func = (void*)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
1053    void    * args = (void*)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
[1]1054
1055    // select one core
[637]1056    core_lid = cluster_select_local_core( local_cxy );
[1]1057
1058    // call local kernel function
1059    error = thread_kernel_create( &thread_ptr , type , func , args , core_lid );
1060
1061    // set output arguments
1062    thread_xp = XPTR( local_cxy , thread_ptr );
[564]1063    hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
1064    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)thread_xp );
[296]1065
[564]1066#if DEBUG_RPC_THREAD_KERNEL_CREATE
1067cycle = (uint32_t)hal_get_cycles();
1068if( cycle > DEBUG_RPC_THREAD_KERNEL_CREATE)
[601]1069printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1070__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[564]1071#endif
[1]1072}
1073
1074/////////////////////////////////////////////////////////////////////////////////////////
[640]1075// [8]   Marshaling functions attached to RPC_VFS_FS_UPDATE_DENTRY
[1]1076/////////////////////////////////////////////////////////////////////////////////////////
1077
[623]1078/////////////////////////////////////////////////////////
1079void rpc_vfs_fs_update_dentry_client( cxy_t          cxy,
1080                                      vfs_inode_t  * inode,
1081                                      vfs_dentry_t * dentry,
1082                                      uint32_t       size,
1083                                      error_t      * error )
1084{
1085#if DEBUG_RPC_VFS_FS_UPDATE_DENTRY
1086thread_t * this = CURRENT_THREAD;
1087uint32_t cycle = (uint32_t)hal_get_cycles();
1088if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY )
1089printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1090__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1091#endif
[296]1092
[623]1093    uint32_t responses = 1;
1094
1095    // initialise RPC descriptor header
1096    rpc_desc_t  rpc;
1097    rpc.index    = RPC_VFS_FS_UPDATE_DENTRY;
1098    rpc.blocking = true;
1099    rpc.rsp      = &responses;
1100
1101    // set input arguments in RPC descriptor
1102    rpc.args[0] = (uint64_t)(intptr_t)inode;
1103    rpc.args[1] = (uint64_t)(intptr_t)dentry;
1104    rpc.args[2] = (uint64_t)size;
1105
1106    // register RPC request in remote RPC fifo
1107    rpc_send( cxy , &rpc );
1108
1109    // get output values from RPC descriptor
1110    *error   = (error_t)rpc.args[3];
1111
1112#if DEBUG_RPC_VFS_FS_UPDATE_DENTRY
1113cycle = (uint32_t)hal_get_cycles();
1114if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY )
1115printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1116__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1117#endif
1118}
1119
1120/////////////////////////////////////////////////
1121void rpc_vfs_fs_update_dentry_server( xptr_t xp )
1122{
1123#if DEBUG_RPC_VFS_FS_UPDATE_DENTRY
1124thread_t * this = CURRENT_THREAD;
1125uint32_t cycle = (uint32_t)hal_get_cycles();
1126if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY )
1127printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1128__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1129#endif
1130
1131    error_t        error;
1132    vfs_inode_t  * inode;
1133    vfs_dentry_t * dentry;
1134    uint32_t       size;
1135
1136    // get client cluster identifier and pointer on RPC descriptor
1137    cxy_t        client_cxy  = GET_CXY( xp );
1138    rpc_desc_t * desc        = GET_PTR( xp );
1139
1140    // get input arguments
1141    inode  = (vfs_inode_t*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
1142    dentry = (vfs_dentry_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
1143    size   = (uint32_t)               hal_remote_l64(XPTR(client_cxy , &desc->args[2]));
1144
1145    // call the kernel function
1146    error = vfs_fs_update_dentry( inode , dentry , size );
1147
1148    // set output argument
1149    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
1150
1151#if DEBUG_RPC_VFS_FS_UPDATE_DENTRY
1152cycle = (uint32_t)hal_get_cycles();
1153if( cycle > DEBUG_RPC_VFS_FS_UPDATE_DENTRY )
1154printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1155__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1156#endif
1157}
1158
[23]1159/////////////////////////////////////////////////////////////////////////////////////////
[619]1160// [9]   Marshaling functions attached to RPC_PROCESS_SIGACTION
[23]1161/////////////////////////////////////////////////////////////////////////////////////////
1162
[416]1163////////////////////////////////////////////////////
1164void rpc_process_sigaction_client( cxy_t        cxy,
[619]1165                                   pid_t        pid,
1166                                   uint32_t     action )
[409]1167{
[438]1168#if DEBUG_RPC_PROCESS_SIGACTION
[611]1169uint32_t  cycle = (uint32_t)hal_get_cycles();
[610]1170thread_t * this = CURRENT_THREAD;
[438]1171if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
[619]1172printk("\n[%s] thread[%x,%x] on core %d : enter to %s process %x / cycle %d\n",
1173__FUNCTION__, this->process->pid, this->trdid, this->core->lid,
1174process_action_str( action ), pid, cycle );
[436]1175#endif
[409]1176
[619]1177    uint32_t    responses = 1;
1178    rpc_desc_t  rpc;
[409]1179
[619]1180    // initialise RPC descriptor header
1181    rpc.index    = RPC_PROCESS_SIGACTION;
1182    rpc.blocking = true;
1183    rpc.rsp      = &responses;
[436]1184
[619]1185    // set input arguments in RPC descriptor
1186    rpc.args[0] = (uint64_t)pid;
1187    rpc.args[1] = (uint64_t)action;
1188
1189    // register RPC request in remote RPC fifo
1190    rpc_send( cxy , &rpc );
1191
[438]1192#if DEBUG_RPC_PROCESS_SIGACTION
[436]1193cycle = (uint32_t)hal_get_cycles();
[438]1194if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
[619]1195printk("\n[%s] thread[%x,%x] on core %d : exit after %s process %x / cycle %d\n",
1196__FUNCTION__, this->process->pid, this->trdid, this->core->lid,
1197process_action_str( action ), pid, cycle );
[436]1198#endif
1199}  // end rpc_process_sigaction_client()
1200
[409]1201//////////////////////////////////////////////
1202void rpc_process_sigaction_server( xptr_t xp )
1203{
[611]1204    // get client cluster identifier and pointer on RPC descriptor
1205    cxy_t        client_cxy = GET_CXY( xp );
1206    rpc_desc_t * desc       = GET_PTR( xp );
1207
1208    // get arguments from RPC descriptor
1209    pid_t    pid    = (pid_t)   hal_remote_l64( XPTR(client_cxy , &desc->args[0]) );
1210    uint32_t action = (uint32_t)hal_remote_l64( XPTR(client_cxy , &desc->args[1]) );
1211
[619]1212#if DEBUG_RPC_PROCESS_SIGACTION
1213uint32_t cycle = (uint32_t)hal_get_cycles();
1214thread_t * this = CURRENT_THREAD;
1215if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
1216printk("\n[%s] thread[%x,%x] on core %d : enter to %s process %x / cycle %d\n",
1217__FUNCTION__, this->process->pid, this->trdid, this->core->lid,
1218process_action_str( action ), pid, cycle );
1219#endif
1220
[440]1221    // get client thread pointers
[611]1222    thread_t * client_ptr = hal_remote_lpt( XPTR( client_cxy , &desc->thread ) );
1223    xptr_t     client_xp  = XPTR( client_cxy , client_ptr );
[440]1224
[435]1225    // get local process descriptor
[611]1226    process_t * process = cluster_get_local_process_from_pid( pid );
[435]1227
[619]1228    // call relevant kernel function if found / does nothing if not found
1229    if( process != NULL )
1230    {
1231        if ( action == DELETE_ALL_THREADS  ) process_delete_threads ( process , client_xp ); 
1232        if ( action == BLOCK_ALL_THREADS   ) process_block_threads  ( process ); 
1233        if ( action == UNBLOCK_ALL_THREADS ) process_unblock_threads( process );
1234    }
[409]1235
[438]1236#if DEBUG_RPC_PROCESS_SIGACTION
[436]1237cycle = (uint32_t)hal_get_cycles();
[438]1238if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
[619]1239printk("\n[%s] thread[%x,%x] on core %d : exit after %s process %x / cycle %d\n",
1240__FUNCTION__, this->process->pid, this->trdid, this->core->lid,
1241process_action_str( action ), pid, cycle );
[436]1242#endif
1243} // end rpc_process_sigaction_server()
1244
[409]1245/////////////////////////////////////////////////////////////////////////////////////////
[619]1246// [10]     Marshaling functions attached to RPC_VFS_INODE_CREATE
[409]1247/////////////////////////////////////////////////////////////////////////////////////////
1248
[1]1249/////////////////////////////////////////////////////
1250void rpc_vfs_inode_create_client( cxy_t          cxy,     
[23]1251                                  uint32_t       fs_type,    // in
[1]1252                                  uint32_t       attr,       // in
[23]1253                                  uint32_t       rights,     // in
[1]1254                                  uint32_t       uid,        // in
1255                                  uint32_t       gid,        // in
1256                                  xptr_t       * inode_xp,   // out
1257                                  error_t      * error )     // out
1258{
[459]1259#if DEBUG_RPC_VFS_INODE_CREATE
[564]1260thread_t * this = CURRENT_THREAD;
[459]1261uint32_t cycle = (uint32_t)hal_get_cycles();
1262if( cycle > DEBUG_RPC_VFS_INODE_CREATE )
[601]1263printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1264__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[459]1265#endif
1266
[619]1267    uint32_t responses = 1;
[1]1268
1269    // initialise RPC descriptor header
1270    rpc_desc_t  rpc;
1271    rpc.index    = RPC_VFS_INODE_CREATE;
[416]1272    rpc.blocking = true;
[619]1273    rpc.rsp      = &responses;
[1]1274
1275    // set input arguments in RPC descriptor
[610]1276    rpc.args[0] = (uint64_t)fs_type;
[623]1277    rpc.args[1] = (uint64_t)attr;
1278    rpc.args[2] = (uint64_t)rights;
1279    rpc.args[3] = (uint64_t)uid;
1280    rpc.args[4] = (uint64_t)gid;
[1]1281
[436]1282    // register RPC request in remote RPC fifo
[416]1283    rpc_send( cxy , &rpc );
[1]1284
1285    // get output values from RPC descriptor
[623]1286    *inode_xp = (xptr_t)rpc.args[5];
1287    *error    = (error_t)rpc.args[6];
[279]1288
[459]1289#if DEBUG_RPC_VFS_INODE_CREATE
[564]1290cycle = (uint32_t)hal_get_cycles();
[459]1291if( cycle > DEBUG_RPC_VFS_INODE_CREATE )
[601]1292printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1293__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1294#endif
[1]1295}
1296
1297/////////////////////////////////////////////
1298void rpc_vfs_inode_create_server( xptr_t xp )
1299{
[459]1300#if DEBUG_RPC_VFS_INODE_CREATE
[564]1301thread_t * this = CURRENT_THREAD;
[459]1302uint32_t cycle = (uint32_t)hal_get_cycles();
1303if( cycle > DEBUG_RPC_VFS_INODE_CREATE )
[601]1304printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1305__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1306#endif
1307
[23]1308    uint32_t         fs_type;
[1]1309    uint32_t         attr;
[23]1310    uint32_t         rights;
[1]1311    uint32_t         uid;
1312    uint32_t         gid;
1313    xptr_t           inode_xp;
1314    error_t          error;
1315
1316    // get client cluster identifier and pointer on RPC descriptor
[436]1317    cxy_t        client_cxy  = GET_CXY( xp );
1318    rpc_desc_t * desc        = GET_PTR( xp );
[1]1319
1320    // get input arguments from client rpc descriptor
[610]1321    fs_type    = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
[623]1322    attr       = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
1323    rights     = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
1324    uid        = (uid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
1325    gid        = (gid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
[1]1326
1327    // call local kernel function
[610]1328    error = vfs_inode_create( fs_type,
[1]1329                              attr,
[23]1330                              rights,
[1]1331                              uid,
1332                              gid,
1333                              &inode_xp );
1334
1335    // set output arguments
[623]1336    hal_remote_s64( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)inode_xp );
1337    hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error );
[296]1338
[459]1339#if DEBUG_RPC_VFS_INODE_CREATE
[564]1340cycle = (uint32_t)hal_get_cycles();
[459]1341if( cycle > DEBUG_RPC_VFS_INODE_CREATE )
[601]1342printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1343__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1344#endif
[1]1345}
1346
1347/////////////////////////////////////////////////////////////////////////////////////////
[619]1348// [11]          Marshaling functions attached to RPC_VFS_INODE_DESTROY
[1]1349/////////////////////////////////////////////////////////////////////////////////////////
1350
1351/////////////////////////////////////////////////////////////
1352void rpc_vfs_inode_destroy_client( cxy_t                cxy,
[601]1353                                   struct vfs_inode_s * inode )
[1]1354{
[459]1355#if DEBUG_RPC_VFS_INODE_DESTROY
[564]1356thread_t * this = CURRENT_THREAD;
[459]1357uint32_t cycle = (uint32_t)hal_get_cycles();
1358if( cycle > DEBUG_RPC_VFS_INODE_DESTROY )
[601]1359printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1360__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1361#endif
1362
[619]1363    uint32_t responses = 1;
[1]1364
1365    // initialise RPC descriptor header
1366    rpc_desc_t  rpc;
1367    rpc.index    = RPC_VFS_INODE_DESTROY;
[416]1368    rpc.blocking = true;
[619]1369    rpc.rsp      = &responses;
[1]1370
1371    // set input arguments in RPC descriptor
1372    rpc.args[0] = (uint64_t)(intptr_t)inode;
1373   
[436]1374    // register RPC request in remote RPC fifo
[416]1375    rpc_send( cxy , &rpc );
[279]1376
[459]1377#if DEBUG_RPC_VFS_INODE_DESTROY
[564]1378cycle = (uint32_t)hal_get_cycles();
[459]1379if( cycle > DEBUG_RPC_VFS_INODE_DESTROY )
[601]1380printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1381__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1382#endif
[1]1383}
1384
1385//////////////////////////////////////////////
1386void rpc_vfs_inode_destroy_server( xptr_t xp )
1387{
[459]1388#if DEBUG_RPC_VFS_INODE_DESTROY
[564]1389thread_t * this = CURRENT_THREAD;
[459]1390uint32_t cycle = (uint32_t)hal_get_cycles();
1391if( cycle > DEBUG_RPC_VFS_INODE_DESTROY )
[601]1392printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1393__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1394#endif
1395
[1]1396    vfs_inode_t * inode;
1397
1398    // get client cluster identifier and pointer on RPC descriptor
[436]1399    cxy_t        client_cxy  = GET_CXY( xp );
1400    rpc_desc_t * desc        = GET_PTR( xp );
[1]1401
[601]1402    // get argument "inode" from client RPC descriptor
[564]1403    inode = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
[1]1404                       
1405    // call local kernel function
[601]1406    vfs_inode_destroy( inode );
[296]1407
[459]1408#if DEBUG_RPC_VFS_INODE_DESTROY
[564]1409cycle = (uint32_t)hal_get_cycles();
[459]1410if( cycle > DEBUG_RPC_VFS_INODE_DESTROY )
[601]1411printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1412__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[459]1413#endif
[1]1414}
1415
1416/////////////////////////////////////////////////////////////////////////////////////////
[619]1417// [12]          Marshaling functions attached to RPC_VFS_DENTRY_CREATE
[1]1418/////////////////////////////////////////////////////////////////////////////////////////
1419
1420//////////////////////////////////////////////////////////////
1421void rpc_vfs_dentry_create_client( cxy_t                  cxy,
1422                                   uint32_t               type,         // in
1423                                   char                 * name,         // in
1424                                   xptr_t               * dentry_xp,    // out
1425                                   error_t              * error )       // out
1426{
[438]1427#if DEBUG_RPC_VFS_DENTRY_CREATE
[564]1428thread_t * this = CURRENT_THREAD;
[438]1429uint32_t cycle = (uint32_t)hal_get_cycles();
1430if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE )
[601]1431printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1432__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]1433#endif
[296]1434
[619]1435    uint32_t responses = 1;
[1]1436
1437    // initialise RPC descriptor header
1438    rpc_desc_t  rpc;
1439    rpc.index    = RPC_VFS_DENTRY_CREATE;
[416]1440    rpc.blocking = true;
[619]1441    rpc.rsp      = &responses;
[1]1442
1443    // set input arguments in RPC descriptor
1444    rpc.args[0] = (uint64_t)type;
1445    rpc.args[1] = (uint64_t)(intptr_t)name;
1446
[436]1447    // register RPC request in remote RPC fifo
[416]1448    rpc_send( cxy , &rpc );
[1]1449
1450    // get output values from RPC descriptor
[610]1451    *dentry_xp = (xptr_t)rpc.args[2];
1452    *error     = (error_t)rpc.args[3];
[279]1453
[438]1454#if DEBUG_RPC_VFS_DENTRY_CREATE
1455cycle = (uint32_t)hal_get_cycles();
1456if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE )
[601]1457printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1458__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]1459#endif
[1]1460}
1461
1462//////////////////////////////////////////////
1463void rpc_vfs_dentry_create_server( xptr_t xp )
1464{
[438]1465#if DEBUG_RPC_VFS_DENTRY_CREATE
[564]1466thread_t * this = CURRENT_THREAD;
[438]1467uint32_t cycle = (uint32_t)hal_get_cycles();
1468if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE )
[601]1469printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1470__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[438]1471#endif
1472
[1]1473    uint32_t      type;
1474    char        * name;
1475    xptr_t        dentry_xp;
1476    error_t       error;
[238]1477    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
1478
[1]1479    // get client cluster identifier and pointer on RPC descriptor
[436]1480    cxy_t        client_cxy  = GET_CXY( xp );
1481    rpc_desc_t * desc        = GET_PTR( xp );
[1]1482
[238]1483    // get arguments "name", "type", and "parent" from client RPC descriptor
[610]1484    type   = (uint32_t)         hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
1485    name   = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
[296]1486
[238]1487    // makes a local copy of  name
1488    hal_remote_strcpy( XPTR( local_cxy , name_copy ),
1489                       XPTR( client_cxy , name ) );
1490
[1]1491    // call local kernel function
1492    error = vfs_dentry_create( type,
1493                               name_copy,
1494                               &dentry_xp );
1495    // set output arguments
[610]1496    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)dentry_xp );
1497    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
[296]1498
[438]1499#if DEBUG_RPC_VFS_DENTRY_CREATE
1500cycle = (uint32_t)hal_get_cycles();
1501if( cycle > DEBUG_RPC_VFS_DENTRY_CREATE )
[601]1502printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1503__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]1504#endif
[1]1505}
1506
1507/////////////////////////////////////////////////////////////////////////////////////////
[619]1508// [13]          Marshaling functions attached to RPC_VFS_DENTRY_DESTROY
[1]1509/////////////////////////////////////////////////////////////////////////////////////////
1510
1511///////////////////////////////////////////////////////
1512void rpc_vfs_dentry_destroy_client( cxy_t          cxy,
[601]1513                                    vfs_dentry_t * dentry )
[1]1514{
[440]1515#if DEBUG_RPC_VFS_DENTRY_DESTROY
[564]1516thread_t * this = CURRENT_THREAD;
[440]1517uint32_t cycle = (uint32_t)hal_get_cycles();
1518if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY )
[601]1519printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1520__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]1521#endif
1522
[619]1523    uint32_t responses = 1;
[1]1524
1525    // initialise RPC descriptor header
1526    rpc_desc_t  rpc;
1527    rpc.index    = RPC_VFS_DENTRY_DESTROY;
[416]1528    rpc.blocking = true;
[619]1529    rpc.rsp      = &responses;
[1]1530
1531    // set input arguments in RPC descriptor
1532    rpc.args[0] = (uint64_t)(intptr_t)dentry;
1533   
[436]1534    // register RPC request in remote RPC fifo
[416]1535    rpc_send( cxy , &rpc );
[279]1536
[440]1537#if DEBUG_RPC_VFS_DENTRY_DESTROY
1538cycle = (uint32_t)hal_get_cycles();
1539if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY )
[601]1540printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1541__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[440]1542#endif
[1]1543}
1544
1545///////////////////////////////////////////////
1546void rpc_vfs_dentry_destroy_server( xptr_t xp )
1547{
[440]1548#if DEBUG_RPC_VFS_DENTRY_DESTROY
[564]1549thread_t * this = CURRENT_THREAD;
[440]1550uint32_t cycle = (uint32_t)hal_get_cycles();
1551if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY )
[601]1552printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1553__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]1554#endif
1555
[1]1556    vfs_dentry_t * dentry;
1557
1558    // get client cluster identifier and pointer on RPC descriptor
[436]1559    cxy_t        client_cxy  = GET_CXY( xp );
1560    rpc_desc_t * desc        = GET_PTR( xp );
[1]1561
1562    // get arguments "dentry" from client RPC descriptor
[564]1563    dentry = (vfs_dentry_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
[1]1564                       
1565    // call local kernel function
[601]1566    vfs_dentry_destroy( dentry );
[296]1567
[440]1568#if DEBUG_RPC_VFS_DENTRY_DESTROY
1569cycle = (uint32_t)hal_get_cycles();
1570if( cycle > DEBUG_RPC_VFS_DENTRY_DESTROY )
[601]1571printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1572__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[440]1573#endif
[1]1574}
1575
1576
1577/////////////////////////////////////////////////////////////////////////////////////////
[619]1578// [14]          Marshaling functions attached to RPC_VFS_FILE_CREATE 
[1]1579/////////////////////////////////////////////////////////////////////////////////////////
1580
[23]1581//////////////////////////////////////////////////////////////
1582void rpc_vfs_file_create_client( cxy_t                  cxy,
1583                                 struct vfs_inode_s   * inode,       // in
1584                                 uint32_t               file_attr,   // in
1585                                 xptr_t               * file_xp,     // out
1586                                 error_t              * error )      // out
1587{
[438]1588#if DEBUG_RPC_VFS_FILE_CREATE
[564]1589thread_t * this = CURRENT_THREAD;
[438]1590uint32_t cycle = (uint32_t)hal_get_cycles();
1591if( cycle > DEBUG_RPC_VFS_FILE_CREATE )
[601]1592printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1593__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[438]1594#endif
1595
[619]1596    uint32_t responses = 1;
[23]1597
1598    // initialise RPC descriptor header
1599    rpc_desc_t  rpc;
1600    rpc.index    = RPC_VFS_FILE_CREATE;
[416]1601    rpc.blocking = true;
[619]1602    rpc.rsp      = &responses;
[23]1603
1604    // set input arguments in RPC descriptor
1605    rpc.args[0] = (uint64_t)(intptr_t)inode;
1606    rpc.args[1] = (uint64_t)file_attr;
1607
[436]1608    // register RPC request in remote RPC fifo
[416]1609    rpc_send( cxy , &rpc );
[23]1610
1611    // get output values from RPC descriptor
1612    *file_xp = (xptr_t)rpc.args[2];
1613    *error   = (error_t)rpc.args[3];
[279]1614
[438]1615#if DEBUG_RPC_VFS_FILE_CREATE
1616cycle = (uint32_t)hal_get_cycles();
1617if( cycle > DEBUG_RPC_VFS_FILE_CREATE )
[601]1618printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1619__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]1620#endif
[23]1621}
1622
1623////////////////////////////////////////////
1624void rpc_vfs_file_create_server( xptr_t xp )
1625{
[438]1626#if DEBUG_RPC_VFS_FILE_CREATE
[564]1627thread_t * this = CURRENT_THREAD;
[438]1628uint32_t cycle = (uint32_t)hal_get_cycles();
1629if( cycle > DEBUG_RPC_VFS_FILE_CREATE )
[601]1630printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1631__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[438]1632#endif
1633
[23]1634    uint32_t      file_attr;
1635    vfs_inode_t * inode;
1636    xptr_t        file_xp;
1637    error_t       error;
1638
1639    // get client cluster identifier and pointer on RPC descriptor
[436]1640    cxy_t        client_cxy  = GET_CXY( xp );
1641    rpc_desc_t * desc        = GET_PTR( xp );
[23]1642
1643    // get arguments "file_attr" and "inode" from client RPC descriptor
[564]1644    inode     = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
1645    file_attr = (uint32_t)               hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
[23]1646                       
1647    // call local kernel function
1648    error = vfs_file_create( inode,
1649                             file_attr,
1650                             &file_xp );
1651 
1652    // set output arguments
[564]1653    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)file_xp );
1654    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
[296]1655
[438]1656#if DEBUG_RPC_VFS_FILE_CREATE
1657cycle = (uint32_t)hal_get_cycles();
1658if( cycle > DEBUG_RPC_VFS_FILE_CREATE )
[601]1659printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1660__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[438]1661#endif
[23]1662}
1663
1664/////////////////////////////////////////////////////////////////////////////////////////
[619]1665// [15]          Marshaling functions attached to RPC_VFS_FILE_DESTROY 
[23]1666/////////////////////////////////////////////////////////////////////////////////////////
1667
1668///////////////////////////////////////////////////
1669void rpc_vfs_file_destroy_client( cxy_t        cxy,
1670                                  vfs_file_t * file )
1671{
[440]1672#if DEBUG_RPC_VFS_FILE_DESTROY
[564]1673thread_t * this = CURRENT_THREAD;
[440]1674uint32_t cycle = (uint32_t)hal_get_cycles();
1675if( cycle > DEBUG_RPC_VFS_FILE_DESTROY )
[601]1676printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1677__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]1678#endif
1679
[619]1680    uint32_t responses = 1;
[23]1681
1682    // initialise RPC descriptor header
1683    rpc_desc_t  rpc;
1684    rpc.index    = RPC_VFS_FILE_DESTROY;
[416]1685    rpc.blocking = true;
[619]1686    rpc.rsp      = &responses;
[23]1687
1688    // set input arguments in RPC descriptor
1689    rpc.args[0] = (uint64_t)(intptr_t)file;
1690   
[436]1691    // register RPC request in remote RPC fifo
[416]1692    rpc_send( cxy , &rpc );
[279]1693
[440]1694#if DEBUG_RPC_VFS_FILE_DESTROY
1695cycle = (uint32_t)hal_get_cycles();
1696if( cycle > DEBUG_RPC_VFS_FILE_DESTROY )
[601]1697printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1698__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[440]1699#endif
[23]1700}
1701
1702/////////////////////////////////////////////
1703void rpc_vfs_file_destroy_server( xptr_t xp )
1704{
[440]1705#if DEBUG_RPC_VFS_FILE_DESTROY
[564]1706thread_t * this = CURRENT_THREAD;
[440]1707uint32_t cycle = (uint32_t)hal_get_cycles();
1708if( cycle > DEBUG_RPC_VFS_FILE_DESTROY )
[601]1709printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1710__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]1711#endif
1712
[23]1713    vfs_file_t * file;
1714
1715    // get client cluster identifier and pointer on RPC descriptor
[436]1716    cxy_t        client_cxy  = GET_CXY( xp );
1717    rpc_desc_t * desc        = GET_PTR( xp );
[23]1718
1719    // get arguments "dentry" from client RPC descriptor
[564]1720    file = (vfs_file_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
[23]1721                       
1722    // call local kernel function
1723    vfs_file_destroy( file );
[296]1724
[440]1725#if DEBUG_RPC_VFS_FILE_DESTROY
1726cycle = (uint32_t)hal_get_cycles();
1727if( cycle > DEBUG_RPC_VFS_FILE_DESTROY )
[601]1728printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1729__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
[440]1730#endif
[23]1731}
1732
1733/////////////////////////////////////////////////////////////////////////////////////////
[619]1734// [16]      Marshaling functions attached to RPC_VFS_FS_GET_DENTRY
[23]1735/////////////////////////////////////////////////////////////////////////////////////////
1736
[601]1737/////////////////////////////////////////////////////////
[623]1738void rpc_vfs_fs_new_dentry_client( cxy_t         cxy,
[601]1739                                   vfs_inode_t * parent_inode,    // in
1740                                   char        * name,            // in
1741                                   xptr_t        child_inode_xp,  // in
1742                                   error_t     * error )          // out
[238]1743{
[628]1744#if DEBUG_RPC_VFS_FS_NEW_DENTRY
[601]1745thread_t * this = CURRENT_THREAD;
1746uint32_t cycle = (uint32_t)hal_get_cycles();
[628]1747if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY )
[601]1748printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1749__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1750#endif
1751
[619]1752    uint32_t responses = 1;
[238]1753
1754    // initialise RPC descriptor header
1755    rpc_desc_t  rpc;
[628]1756    rpc.index    = RPC_VFS_FS_NEW_DENTRY;
[416]1757    rpc.blocking = true;
[619]1758    rpc.rsp      = &responses;
[238]1759
1760    // set input arguments in RPC descriptor
1761    rpc.args[0] = (uint64_t)(intptr_t)parent_inode;
1762    rpc.args[1] = (uint64_t)(intptr_t)name;
1763    rpc.args[2] = (uint64_t)child_inode_xp;
1764
[436]1765    // register RPC request in remote RPC fifo
[416]1766    rpc_send( cxy , &rpc );
[238]1767
1768    // get output values from RPC descriptor
1769    *error   = (error_t)rpc.args[3];
[279]1770
[628]1771#if DEBUG_RPC_VFS_FS_NEW_DENTRY
[601]1772cycle = (uint32_t)hal_get_cycles();
[628]1773if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY )
[601]1774printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1775__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1776#endif
[238]1777}
1778
[601]1779//////////////////////////////////////////////
[623]1780void rpc_vfs_fs_new_dentry_server( xptr_t xp )
[238]1781{
[628]1782#if DEBUG_RPC_VFS_FS_NEW_DENTRY
[601]1783thread_t * this = CURRENT_THREAD;
1784uint32_t cycle = (uint32_t)hal_get_cycles();
[628]1785if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY )
[601]1786printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1787__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1788#endif
1789
[238]1790    error_t       error;
1791    vfs_inode_t * parent;
1792    xptr_t        child_xp;
1793    char        * name;
1794
1795    char          name_copy[CONFIG_VFS_MAX_NAME_LENGTH];
1796
1797    // get client cluster identifier and pointer on RPC descriptor
[436]1798    cxy_t        client_cxy  = GET_CXY( xp );
1799    rpc_desc_t * desc        = GET_PTR( xp );
[238]1800
1801    // get arguments "parent", "name", and "child_xp"
[564]1802    parent     = (vfs_inode_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
1803    name       = (char*)(intptr_t)       hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
1804    child_xp   = (xptr_t)                hal_remote_l64(XPTR(client_cxy , &desc->args[2]));
[238]1805
1806    // get name local copy
1807    hal_remote_strcpy( XPTR( local_cxy , name_copy ) ,
1808                       XPTR( client_cxy , name ) );
1809
1810    // call the kernel function
[623]1811    error = vfs_fs_new_dentry( parent , name_copy , child_xp );
[238]1812
1813    // set output argument
[564]1814    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
[296]1815
[628]1816#if DEBUG_RPC_VFS_FS_NEW_DENTRY
[601]1817cycle = (uint32_t)hal_get_cycles();
[628]1818if( cycle > DEBUG_RPC_VFS_FS_NEW_DENTRY )
[601]1819printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1820__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1821#endif
[238]1822}
1823
1824/////////////////////////////////////////////////////////////////////////////////////////
[619]1825// [17]      Marshaling function attached to RPC_VFS_FS_ADD_DENTRY 
[238]1826/////////////////////////////////////////////////////////////////////////////////////////
1827
[601]1828void rpc_vfs_fs_add_dentry_client( cxy_t          cxy,
1829                                   vfs_inode_t  * parent,     // in
1830                                   vfs_dentry_t * dentry,     // in
1831                                   error_t      * error )     // out
[238]1832{
[601]1833#if DEBUG_RPC_VFS_FS_ADD_DENTRY
1834thread_t * this = CURRENT_THREAD;
1835uint32_t cycle = (uint32_t)hal_get_cycles();
1836if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY )
1837printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1838__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1839#endif
1840
[619]1841    uint32_t responses = 1;
[238]1842
1843    // initialise RPC descriptor header
1844    rpc_desc_t  rpc;
[601]1845    rpc.index    = RPC_VFS_FS_ADD_DENTRY;
[416]1846    rpc.blocking = true;
[619]1847    rpc.rsp      = &responses;
[238]1848
1849    // set input arguments in RPC descriptor
[601]1850    rpc.args[0] = (uint64_t)(intptr_t)parent;
1851    rpc.args[1] = (uint64_t)(intptr_t)dentry;
[238]1852
[436]1853    // register RPC request in remote RPC fifo
[416]1854    rpc_send( cxy , &rpc );
[238]1855
1856    // get output values from RPC descriptor
[601]1857    *error   = (error_t)rpc.args[2];
[279]1858
[601]1859#if DEBUG_RPC_VFS_FS_ADD_DENTRY
1860cycle = (uint32_t)hal_get_cycles();
1861if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY )
1862printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1863__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1864#endif
[238]1865}
1866
[619]1867//////////////////////////////////////////////
[601]1868void rpc_vfs_fs_add_dentry_server( xptr_t xp )
[238]1869{
[601]1870#if DEBUG_RPC_VFS_FS_ADD_DENTRY
1871thread_t * this = CURRENT_THREAD;
1872uint32_t cycle = (uint32_t)hal_get_cycles();
1873if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY )
1874printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1875__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1876#endif
[238]1877
[601]1878    error_t        error;
1879    vfs_inode_t  * parent;
1880    vfs_dentry_t * dentry;
1881
[238]1882    // get client cluster identifier and pointer on RPC descriptor
[436]1883    cxy_t        client_cxy  = GET_CXY( xp );
1884    rpc_desc_t * desc        = GET_PTR( xp );
[238]1885
[601]1886    // get input arguments
1887    parent = (vfs_inode_t*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
1888    dentry = (vfs_dentry_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
[238]1889
1890    // call the kernel function
[601]1891    error = vfs_fs_add_dentry( parent , dentry );
[238]1892
1893    // set output argument
[601]1894    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)error );
[296]1895
[601]1896#if DEBUG_RPC_VFS_FS_ADD_DENTRY
1897cycle = (uint32_t)hal_get_cycles();
1898if( cycle > DEBUG_RPC_VFS_FS_ADD_DENTRY )
1899printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1900__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1901#endif
[238]1902}
1903
1904/////////////////////////////////////////////////////////////////////////////////////////
[619]1905// [18]      Marshaling function attached to RPC_VFS_FS_REMOVE_DENTRY
[238]1906/////////////////////////////////////////////////////////////////////////////////////////
1907
[601]1908void rpc_vfs_fs_remove_dentry_client( cxy_t          cxy,
1909                                      vfs_inode_t  * parent,     // in
1910                                      vfs_dentry_t * dentry,     // in
1911                                      error_t      * error )     // out
[23]1912{
[601]1913#if DEBUG_RPC_VFS_FS_REMOVE_DENTRY
1914thread_t * this = CURRENT_THREAD;
1915uint32_t cycle = (uint32_t)hal_get_cycles();
1916if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY )
1917printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1918__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1919#endif
1920
[619]1921    uint32_t responses = 1;
[23]1922
1923    // initialise RPC descriptor header
1924    rpc_desc_t  rpc;
[601]1925    rpc.index    = RPC_VFS_FS_REMOVE_DENTRY;
[416]1926    rpc.blocking = true;
[619]1927    rpc.rsp      = &responses;
[23]1928
1929    // set input arguments in RPC descriptor
[601]1930    rpc.args[0] = (uint64_t)(intptr_t)parent;
1931    rpc.args[1] = (uint64_t)(intptr_t)dentry;
[23]1932
[601]1933    // register RPC request in remote RPC fifo
[416]1934    rpc_send( cxy , &rpc );
[23]1935
[601]1936    // get output values from RPC descriptor
1937    *error   = (error_t)rpc.args[2];
[279]1938
[601]1939#if DEBUG_RPC_VFS_FS_REMOVE_DENTRY
1940cycle = (uint32_t)hal_get_cycles();
1941if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY )
1942printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1943__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1944#endif
[23]1945}
1946
[601]1947/////////////////////////////////////////////////
1948void rpc_vfs_fs_remove_dentry_server( xptr_t xp )
[23]1949{
[601]1950#if DEBUG_RPC_VFS_FS_REMOVE_DENTRY
1951thread_t * this = CURRENT_THREAD;
1952uint32_t cycle = (uint32_t)hal_get_cycles();
1953if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY )
1954printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1955__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1956#endif
[23]1957
[601]1958    error_t        error;
1959    vfs_inode_t  * parent;
1960    vfs_dentry_t * dentry;
1961
[23]1962    // get client cluster identifier and pointer on RPC descriptor
[436]1963    cxy_t        client_cxy  = GET_CXY( xp );
[438]1964    rpc_desc_t * desc        = GET_PTR( xp );
[23]1965
1966    // get input arguments
[601]1967    parent = (vfs_inode_t*)(intptr_t) hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
1968    dentry = (vfs_dentry_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[1]));
[23]1969
1970    // call the kernel function
[601]1971    error = vfs_fs_remove_dentry( parent , dentry );
[23]1972
1973    // set output argument
[601]1974    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)error );
[296]1975
[601]1976#if DEBUG_RPC_VFS_FS_REMOVE_DENTRY
1977cycle = (uint32_t)hal_get_cycles();
1978if( cycle > DEBUG_RPC_VFS_FS_REMOVE_DENTRY )
1979printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
1980__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1981#endif
[23]1982}
1983
1984/////////////////////////////////////////////////////////////////////////////////////////
[619]1985// [19]     Marshaling functions attached to RPC_VFS_INODE_LOAD_ALL_PAGES
[601]1986/////////////////////////////////////////////////////////////////////////////////////////
1987
1988////////////////////////////////////////////////////////////
1989void rpc_vfs_inode_load_all_pages_client( cxy_t         cxy,
1990                                          vfs_inode_t * inode,      // in
1991                                          error_t     * error )     // out
1992{
1993#if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES
1994thread_t * this = CURRENT_THREAD;
1995uint32_t cycle = (uint32_t)hal_get_cycles();
1996if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES )
1997printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
1998__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
1999#endif
2000
[619]2001    uint32_t responses = 1;
[601]2002
2003    // initialise RPC descriptor header
2004    rpc_desc_t  rpc;
2005    rpc.index    = RPC_VFS_INODE_LOAD_ALL_PAGES;
2006    rpc.blocking = true;
[619]2007    rpc.rsp      = &responses;
[601]2008
2009    // set input arguments in RPC descriptor
2010    rpc.args[0] = (uint64_t)(intptr_t)inode;
2011
2012    // register RPC request in remote RPC fifo
2013    rpc_send( cxy , &rpc );
2014
2015    // get output values from RPC descriptor
2016    *error   = (error_t)rpc.args[1];
2017
2018#if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES
2019cycle = (uint32_t)hal_get_cycles();
2020if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES )
2021printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2022__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2023#endif
2024}
2025
2026/////////////////////////////////////////////////////
2027void rpc_vfs_inode_load_all_pages_server( xptr_t xp )
2028{
2029#if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES
2030thread_t * this = CURRENT_THREAD;
2031uint32_t cycle = (uint32_t)hal_get_cycles();
2032if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES )
2033printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2034__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2035#endif
2036
2037    error_t       error;
2038    vfs_inode_t * inode;
2039
2040    // get client cluster identifier and pointer on RPC descriptor
2041    cxy_t        client_cxy  = GET_CXY( xp );
2042    rpc_desc_t * desc        = GET_PTR( xp );
2043
2044    // get input argument
2045    inode = (vfs_inode_t*)(intptr_t)hal_remote_l64(XPTR(client_cxy , &desc->args[0]));
2046
2047    // call the kernel function
2048    error = vfs_inode_load_all_pages( inode );
2049
2050    // set output argument
2051    hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
2052
2053#if DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES
2054cycle = (uint32_t)hal_get_cycles();
2055if( cycle > DEBUG_RPC_VFS_INODE_LOAD_ALL_PAGES )
2056printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2057__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2058#endif
2059}
2060
2061/////////////////////////////////////////////////////////////////////////////////////////
[640]2062// [20]          RPC_VMM_GET_VSEG deprecated [AG] sept 2019
[23]2063/////////////////////////////////////////////////////////////////////////////////////////
2064
[640]2065/*
[23]2066//////////////////////////////////////////////////
[389]2067void rpc_vmm_get_vseg_client( cxy_t       cxy,     
2068                              process_t * process,     // in 
2069                              intptr_t    vaddr,       // in 
2070                              xptr_t    * vseg_xp,     // out
2071                              error_t   * error )      // out
[1]2072{
[440]2073#if DEBUG_RPC_VMM_GET_VSEG
[564]2074thread_t * this = CURRENT_THREAD;
[440]2075uint32_t cycle = (uint32_t)hal_get_cycles();
2076if( cycle > DEBUG_RPC_VMM_GET_VSEG )
[601]2077printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2078__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]2079#endif
2080
[619]2081    uint32_t responses = 1;
[1]2082
2083    // initialise RPC descriptor header
2084    rpc_desc_t  rpc;
[389]2085    rpc.index    = RPC_VMM_GET_VSEG;
[416]2086    rpc.blocking = true;
[619]2087    rpc.rsp      = &responses;
[1]2088
2089    // set input arguments in RPC descriptor
2090    rpc.args[0] = (uint64_t)(intptr_t)process;
2091    rpc.args[1] = (uint64_t)vaddr;
2092
[436]2093    // register RPC request in remote RPC fifo
[416]2094    rpc_send( cxy , &rpc );
[1]2095
2096    // get output argument from rpc descriptor
2097    *vseg_xp = rpc.args[2];
[389]2098    *error   = (error_t)rpc.args[3];
[279]2099
[440]2100#if DEBUG_RPC_VMM_GET_VSEG
2101cycle = (uint32_t)hal_get_cycles();
2102if( cycle > DEBUG_RPC_VMM_GET_VSEG )
[601]2103printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2104__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]2105#endif
[1]2106}
2107
[389]2108/////////////////////////////////////////
2109void rpc_vmm_get_vseg_server( xptr_t xp )
[1]2110{
[440]2111#if DEBUG_RPC_VMM_GET_VSEG
[564]2112thread_t * this = CURRENT_THREAD;
[440]2113uint32_t cycle = (uint32_t)hal_get_cycles();
2114if( cycle > DEBUG_RPC_VMM_GET_VSEG )
[601]2115printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2116__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]2117#endif
2118
[1]2119    process_t   * process;
2120    intptr_t      vaddr;
2121    vseg_t      * vseg_ptr;
2122    xptr_t        vseg_xp;
[389]2123    error_t       error;
[1]2124
2125    // get client cluster identifier and pointer on RPC descriptor
[436]2126    cxy_t        client_cxy  = GET_CXY( xp );
2127    rpc_desc_t * desc        = GET_PTR( xp );
[1]2128
2129    // get input argument from client RPC descriptor
[564]2130    process = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
2131    vaddr   = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
[1]2132   
2133    // call local kernel function
[389]2134    error = vmm_get_vseg( process , vaddr , &vseg_ptr );
[1]2135
[389]2136    // set output arguments to client RPC descriptor
2137    vseg_xp = XPTR( local_cxy , vseg_ptr );
[564]2138    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)vseg_xp );
2139    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
[296]2140
[440]2141#if DEBUG_RPC_VMM_GET_VSEG
2142cycle = (uint32_t)hal_get_cycles();
2143if( cycle > DEBUG_RPC_VMM_GET_VSEG )
[601]2144printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2145__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[440]2146#endif
[1]2147}
[640]2148*/
[1]2149
2150/////////////////////////////////////////////////////////////////////////////////////////
[640]2151// [21]    undefined
[1]2152/////////////////////////////////////////////////////////////////////////////////////////
2153
2154/////////////////////////////////////////////////////////////////////////////////////////
[640]2155// [22]          RPC_KCM_ALLOC deprecated [AG] sept 2019
[1]2156/////////////////////////////////////////////////////////////////////////////////////////
2157
[635]2158/*
[23]2159//////////////////////////////////////////
2160void rpc_kcm_alloc_client( cxy_t      cxy,
2161                           uint32_t   kmem_type,   // in
[619]2162                           xptr_t   * buf_xp )     // out
[1]2163{
[564]2164#if DEBUG_RPC_KCM_ALLOC
2165thread_t * this = CURRENT_THREAD;
2166uint32_t cycle = (uint32_t)hal_get_cycles();
2167if( cycle > DEBUG_RPC_KCM_ALLOC )
[601]2168printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2169__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2170#endif
2171
[619]2172    uint32_t responses = 1;
[1]2173
2174    // initialise RPC descriptor header
2175    rpc_desc_t  rpc;
[441]2176    rpc.index    = RPC_KCM_ALLOC;
[416]2177    rpc.blocking = true;
[619]2178    rpc.rsp      = &responses;
[1]2179
[23]2180    // set input arguments in RPC descriptor
2181    rpc.args[0] = (uint64_t)kmem_type;
2182
[436]2183    // register RPC request in remote RPC fifo
[416]2184    rpc_send( cxy , &rpc );
[1]2185
2186    // get output arguments from RPC descriptor
[23]2187    *buf_xp = (xptr_t)rpc.args[1];
[279]2188
[564]2189#if DEBUG_RPC_KCM_ALLOC
2190cycle = (uint32_t)hal_get_cycles();
2191if( cycle > DEBUG_RPC_KCM_ALLOC )
[601]2192printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2193__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2194#endif
[1]2195}
2196
[23]2197//////////////////////////////////////
2198void rpc_kcm_alloc_server( xptr_t xp )
[1]2199{
[564]2200#if DEBUG_RPC_KCM_ALLOC
2201thread_t * this = CURRENT_THREAD;
2202uint32_t cycle = (uint32_t)hal_get_cycles();
2203if( cycle > DEBUG_RPC_KCM_ALLOC )
[601]2204printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2205__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2206#endif
2207
[1]2208    // get client cluster identifier and pointer on RPC descriptor
[436]2209    cxy_t        client_cxy  = GET_CXY( xp );
[438]2210    rpc_desc_t * desc        = GET_PTR( xp );
[1]2211
[23]2212    // get input argument "kmem_type" from client RPC descriptor
[564]2213    uint32_t kmem_type = (uint32_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
[23]2214
2215    // allocates memory for kcm
[1]2216    kmem_req_t  req;
[23]2217    req.type  = kmem_type;
[1]2218    req.flags = AF_ZERO;
[23]2219    void * buf_ptr = kmem_alloc( &req );
[1]2220
2221    // set output argument
[23]2222    xptr_t buf_xp = XPTR( local_cxy , buf_ptr );
[564]2223    hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)buf_xp );
[296]2224
[564]2225#if DEBUG_RPC_KCM_ALLOC
2226cycle = (uint32_t)hal_get_cycles();
2227if( cycle > DEBUG_RPC_KCM_ALLOC )
[601]2228printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2229__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2230#endif
[1]2231}   
[635]2232*/
[1]2233
2234/////////////////////////////////////////////////////////////////////////////////////////
[640]2235// [23]          RPC_KCM_FREE deprecated [AG] sept 2019
[1]2236/////////////////////////////////////////////////////////////////////////////////////////
2237
[635]2238/*
[23]2239/////////////////////////////////////////
2240void rpc_kcm_free_client( cxy_t      cxy,
2241                          void     * buf,          // in
2242                          uint32_t   kmem_type )   // in
[1]2243{
[564]2244#if DEBUG_RPC_KCM_FREE
2245thread_t * this = CURRENT_THREAD;
2246uint32_t cycle = (uint32_t)hal_get_cycles();
2247if( cycle > DEBUG_RPC_KCM_FREE )
[601]2248printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2249__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2250#endif
2251
[619]2252    uint32_t responses = 1;
[1]2253
2254    // initialise RPC descriptor header
2255    rpc_desc_t  rpc;
[441]2256    rpc.index    = RPC_KCM_FREE;
[416]2257    rpc.blocking = true;
[619]2258    rpc.rsp      = &responses;
[1]2259
2260    // set input arguments in RPC descriptor
[23]2261    rpc.args[0] = (uint64_t)(intptr_t)buf;
2262    rpc.args[1] = (uint64_t)kmem_type;
[1]2263
[436]2264    // register RPC request in remote RPC fifo
[416]2265    rpc_send( cxy , &rpc );
[279]2266
[564]2267#if DEBUG_RPC_KCM_FREE
2268cycle = (uint32_t)hal_get_cycles();
2269if( cycle > DEBUG_RPC_KCM_FREE )
[601]2270printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2271__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2272#endif
[1]2273}
2274
[23]2275/////////////////////////////////////
2276void rpc_kcm_free_server( xptr_t xp )
[1]2277{
[564]2278#if DEBUG_RPC_KCM_FREE
2279thread_t * this = CURRENT_THREAD;
2280uint32_t cycle = (uint32_t)hal_get_cycles();
2281if( cycle > DEBUG_RPC_KCM_FREE )
[601]2282printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2283__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2284#endif
2285
[1]2286    // get client cluster identifier and pointer on RPC descriptor
[436]2287    cxy_t        client_cxy  = GET_CXY( xp );
[438]2288    rpc_desc_t * desc        = GET_PTR( xp );
[1]2289
[23]2290    // get input arguments "buf" and "kmem_type" from client RPC descriptor
[564]2291    void     * buf = (void *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
2292    uint32_t   kmem_type = (uint32_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
[1]2293
2294    // releases memory
2295    kmem_req_t  req;
[23]2296    req.type = kmem_type;
2297    req.ptr  = buf;
2298    kmem_free( &req );
[296]2299
[564]2300#if DEBUG_RPC_KCM_FREE
2301cycle = (uint32_t)hal_get_cycles();
2302if( cycle > DEBUG_RPC_KCM_FREE )
[601]2303printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2304__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
[564]2305#endif
[1]2306}   
[635]2307*/
[1]2308
2309/////////////////////////////////////////////////////////////////////////////////////////
[635]2310// [24]          Marshaling functions attached to RPC_MAPPER_SYNC
[1]2311/////////////////////////////////////////////////////////////////////////////////////////
2312
[623]2313///////////////////////////////////////////////////
2314void rpc_mapper_sync_client( cxy_t             cxy,
2315                             struct mapper_s * mapper,
2316                             error_t         * error )
2317{
2318#if DEBUG_RPC_MAPPER_SYNC
2319thread_t * this = CURRENT_THREAD;
2320uint32_t cycle = (uint32_t)hal_get_cycles();
2321if( cycle > DEBUG_RPC_MAPPER_SYNC )
2322printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2323__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2324#endif
2325
2326    uint32_t responses = 1;
2327
2328    // initialise RPC descriptor header
2329    rpc_desc_t  rpc;
2330    rpc.index    = RPC_MAPPER_SYNC;
2331    rpc.blocking = true;
2332    rpc.rsp      = &responses;
2333
2334    // set input arguments in RPC descriptor
2335    rpc.args[0] = (uint64_t)(intptr_t)mapper;
2336
2337    // register RPC request in remote RPC fifo
2338    rpc_send( cxy , &rpc );
2339
2340    // get output values from RPC descriptor
2341    *error   = (error_t)rpc.args[1];
2342
2343#if DEBUG_RPC_MAPPER_SYNC
2344cycle = (uint32_t)hal_get_cycles();
2345if( cycle > DEBUG_RPC_MAPPER_SYNC )
2346printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2347__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2348#endif
2349}
2350
2351////////////////////////////////////////
2352void rpc_mapper_sync_server( xptr_t xp )
2353{
2354#if DEBUG_RPC_MAPPER_SYNC
2355thread_t * this = CURRENT_THREAD;
2356uint32_t cycle = (uint32_t)hal_get_cycles();
2357if( cycle > DEBUG_RPC_MAPPER_SYNC )
2358printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2359__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2360#endif
2361
2362    mapper_t * mapper;
2363    error_t    error;
2364
2365    // get client cluster identifier and pointer on RPC descriptor
2366    cxy_t        client_cxy  = GET_CXY( xp );
2367    rpc_desc_t * desc        = GET_PTR( xp );
2368
2369    // get arguments from client RPC descriptor
2370    mapper  = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
2371
2372    // call local kernel function
2373    error = mapper_sync( mapper );
2374
2375    // set output argument to client RPC descriptor
2376    hal_remote_s64( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
2377
2378#if DEBUG_RPC_MAPPER_SYNC
2379cycle = (uint32_t)hal_get_cycles();
2380if( cycle > DEBUG_RPC_MAPPER_SYNC )
2381printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2382__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2383#endif
2384}
2385
[313]2386/////////////////////////////////////////////////////////////////////////////////////////
[640]2387// [25]          Marshaling functions attached to RPC_VMM_RESIZE_VSEG
[313]2388/////////////////////////////////////////////////////////////////////////////////////////
2389
[601]2390//////////////////////////////////////////////////////////
[641]2391void rpc_vmm_resize_vseg_client( cxy_t          cxy,
2392                                 pid_t          pid,
2393                                 intptr_t       base,
2394                                 intptr_t       new_base,
2395                                 intptr_t       new_size )
[313]2396{
[640]2397#if DEBUG_RPC_VMM_RESIZE_VSEG
[611]2398thread_t * this = CURRENT_THREAD;
[601]2399uint32_t cycle = (uint32_t)hal_get_cycles();
[640]2400if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
[601]2401printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2402__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2403#endif
2404
[619]2405    uint32_t responses = 1;
[313]2406
2407    // initialise RPC descriptor header
2408    rpc_desc_t  rpc;
[640]2409    rpc.index    = RPC_VMM_RESIZE_VSEG;
[416]2410    rpc.blocking = true;
[619]2411    rpc.rsp      = &responses;
[313]2412
2413    // set input arguments in RPC descriptor
[641]2414    rpc.args[0] = (uint64_t)pid;
2415    rpc.args[1] = (uint64_t)base;
[640]2416    rpc.args[2] = (uint64_t)new_base;
2417    rpc.args[3] = (uint64_t)new_size;
[313]2418
[436]2419    // register RPC request in remote RPC fifo
[416]2420    rpc_send( cxy , &rpc );
[313]2421
[640]2422#if DEBUG_RPC_VMM_RESIZE_VSEG
[601]2423cycle = (uint32_t)hal_get_cycles();
[640]2424if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
[601]2425printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2426__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2427#endif
[313]2428}
2429
[640]2430////////////////////////////////////////////
2431void rpc_vmm_resize_vseg_server( xptr_t xp )
[313]2432{
[640]2433#if DEBUG_RPC_VMM_RESIZE_VSEG
[611]2434thread_t * this = CURRENT_THREAD;
[601]2435uint32_t cycle = (uint32_t)hal_get_cycles();
[640]2436if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
[601]2437printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2438__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2439#endif
2440
[641]2441    pid_t       pid;
[640]2442    process_t * process;
[641]2443    intptr_t    base;
[640]2444    vseg_t    * vseg;
2445    intptr_t    new_base;
2446    intptr_t    new_size;
[601]2447
[313]2448    // get client cluster identifier and pointer on RPC descriptor
[601]2449    cxy_t        client_cxy  = GET_CXY( xp );
2450    rpc_desc_t * desc        = GET_PTR( xp );
[313]2451
[601]2452    // get arguments from client RPC descriptor
[641]2453    pid      = (pid_t)   hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
2454    base     = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
2455    new_base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
2456    new_size = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
[313]2457
[641]2458    // get local pointer on target process
2459    process = cluster_get_local_process_from_pid( pid );
2460
2461    // get target vseg from vaddr
2462    vmm_get_vseg( process , base , &vseg );
2463
[640]2464    // call relevant kernel function
2465    vmm_resize_vseg( process,
2466                     vseg,
2467                     new_base,
2468                     new_size );
[313]2469
[640]2470#if DEBUG_RPC_VMM_RESIZE_VSEG
[601]2471cycle = (uint32_t)hal_get_cycles();
[640]2472if( cycle > DEBUG_RPC_VMM_RESIZE_VSEG )
[601]2473printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2474__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2475#endif
[313]2476}
2477
[640]2478
[407]2479/////////////////////////////////////////////////////////////////////////////////////////
[640]2480// [26]  Marshaling functions attached to RPC_VMM_REMOVE_VSEG
[407]2481/////////////////////////////////////////////////////////////////////////////////////////
[313]2482
[640]2483/////////////////////////////////////////////////
2484void rpc_vmm_remove_vseg_client( cxy_t       cxy,
[641]2485                                 pid_t       pid,
2486                                 intptr_t    base )
[611]2487{
[640]2488#if DEBUG_RPC_VMM_REMOVE_VSEG
[611]2489thread_t * this  = CURRENT_THREAD;
2490uint32_t   cycle = (uint32_t)hal_get_cycles();
[640]2491if( cycle > DEBUG_RPC_VMM_REMOVE_VSEG )
[611]2492printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2493__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
2494#endif
2495
[619]2496    uint32_t    responses = 1;
2497    rpc_desc_t  rpc;
[611]2498
[619]2499    // initialise RPC descriptor header
[640]2500    rpc.index    = RPC_VMM_REMOVE_VSEG;
[619]2501    rpc.blocking = true;
2502    rpc.rsp      = &responses;
2503
2504    // set input arguments in RPC descriptor
[641]2505    rpc.args[0] = (uint64_t)pid;
2506    rpc.args[1] = (uint64_t)base;
[619]2507
[611]2508    // register RPC request in remote RPC fifo
[619]2509    rpc_send( cxy , &rpc );
[611]2510
[640]2511#if DEBUG_RPC_VMM_REMOVE_VSEG
[611]2512cycle = (uint32_t)hal_get_cycles();
[640]2513if( cycle > DEBUG_RPC_VMM_REMOVE_VSEG )
[611]2514printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2515__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
2516#endif
2517}
2518
2519////////////////////////////////////////////
[640]2520void rpc_vmm_remove_vseg_server( xptr_t xp )
[611]2521{
[640]2522#if DEBUG_RPC_VMM_REMOVE_VSEG
[611]2523uint32_t cycle = (uint32_t)hal_get_cycles();
2524thread_t * this = CURRENT_THREAD;
[640]2525if( DEBUG_RPC_VMM_REMOVE_VSEG < cycle )
[611]2526printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2527__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
2528#endif
2529
[641]2530    pid_t       pid;
2531    intptr_t    vaddr;
[640]2532    process_t * process;
2533    vseg_t    * vseg;
2534
[611]2535    // get client cluster identifier and pointer on RPC descriptor
2536    cxy_t        client_cxy = GET_CXY( xp );
2537    rpc_desc_t * desc       = GET_PTR( xp );
2538
2539    // get arguments from RPC descriptor
[641]2540    pid   = (pid_t)   hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
2541    vaddr = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
[611]2542
[641]2543    // get local pointer on target process
2544    process = cluster_get_local_process_from_pid( pid );
2545
2546    // get target vseg from vaddr
2547    vmm_get_vseg( process , vaddr , &vseg );
2548
[611]2549    // call relevant kernel function
[640]2550    vmm_remove_vseg( process,
2551                     vseg );
[611]2552
[640]2553#if DEBUG_RPC_VMM_REMOVE_VSEG
[611]2554cycle = (uint32_t)hal_get_cycles();
[640]2555if( DEBUG_RPC_VMM_REMOVE_VSEG < cycle )
[611]2556printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2557__FUNCTION__, this->process->pid, this->trdid, this->core->lid, cycle );
2558#endif
2559} 
2560
[601]2561/////////////////////////////////////////////////////////////////////////////////////////
[619]2562// [27]          Marshaling functions attached to RPC_VMM_CREATE_VSEG
[601]2563/////////////////////////////////////////////////////////////////////////////////////////
2564
[407]2565////////////////////////////////////////////////////////
2566void rpc_vmm_create_vseg_client( cxy_t              cxy,
2567                                 struct process_s * process,
2568                                 vseg_type_t        type,
2569                                 intptr_t           base,
2570                                 uint32_t           size,
2571                                 uint32_t           file_offset,
2572                                 uint32_t           file_size,
2573                                 xptr_t             mapper_xp,
2574                                 cxy_t              vseg_cxy,
2575                                 struct vseg_s   ** vseg )
2576{
[611]2577#if DEBUG_RPC_VMM_CREATE_VSEG
2578thread_t * this = CURRENT_THREAD;
2579uint32_t cycle = (uint32_t)hal_get_cycles();
2580if( cycle > DEBUG_RPC_VMM_CREATE_VSEG )
2581printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2582__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2583#endif
[407]2584
[619]2585    uint32_t responses = 1;
[611]2586
[407]2587    // initialise RPC descriptor header
2588    rpc_desc_t  rpc;
2589    rpc.index    = RPC_VMM_CREATE_VSEG;
[416]2590    rpc.blocking = true;
[619]2591    rpc.rsp      = &responses;
[407]2592
2593    // set input arguments in RPC descriptor
2594    rpc.args[0] = (uint64_t)(intptr_t)process;
2595    rpc.args[1] = (uint64_t)type;
2596    rpc.args[2] = (uint64_t)base;
2597    rpc.args[3] = (uint64_t)size;
2598    rpc.args[4] = (uint64_t)file_offset;
2599    rpc.args[5] = (uint64_t)file_size;
2600    rpc.args[6] = (uint64_t)mapper_xp;
2601    rpc.args[7] = (uint64_t)vseg_cxy;
2602
[436]2603    // register RPC request in remote RPC fifo
[416]2604    rpc_send( cxy , &rpc );
[407]2605
2606    // get output values from RPC descriptor
2607    *vseg = (vseg_t *)(intptr_t)rpc.args[8];
2608
[611]2609#if DEBUG_RPC_VMM_CREATE_VSEG
2610cycle = (uint32_t)hal_get_cycles();
2611if( cycle > DEBUG_RPC_VMM_CREATE_VSEG )
2612printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2613__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2614#endif
[407]2615}
2616
2617////////////////////////////////////////////
2618void rpc_vmm_create_vseg_server( xptr_t xp )
2619{
[611]2620#if DEBUG_RPC_VMM_CREATE_VSEG
2621thread_t * this = CURRENT_THREAD;
2622uint32_t cycle = (uint32_t)hal_get_cycles();
2623if( cycle > DEBUG_RPC_VMM_CREATE_VSEG )
2624printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2625__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2626#endif
2627
[407]2628    // get client cluster identifier and pointer on RPC descriptor
[436]2629    cxy_t        cxy  = GET_CXY( xp );
2630    rpc_desc_t * desc = GET_PTR( xp );
[407]2631
2632    // get input arguments from client RPC descriptor
[564]2633    process_t * process     = (process_t *)(intptr_t)hal_remote_l64( XPTR(cxy , &desc->args[0]));
2634    vseg_type_t type        = (vseg_type_t)(uint32_t)hal_remote_l64( XPTR(cxy , &desc->args[1]));
2635    intptr_t    base        = (intptr_t)             hal_remote_l64( XPTR(cxy , &desc->args[2]));
2636    uint32_t    size        = (uint32_t)             hal_remote_l64( XPTR(cxy , &desc->args[3]));
2637    uint32_t    file_offset = (uint32_t)             hal_remote_l64( XPTR(cxy , &desc->args[4]));
2638    uint32_t    file_size   = (uint32_t)             hal_remote_l64( XPTR(cxy , &desc->args[5]));
2639    xptr_t      mapper_xp   = (xptr_t)               hal_remote_l64( XPTR(cxy , &desc->args[6]));
2640    cxy_t       vseg_cxy    = (cxy_t)(uint32_t)      hal_remote_l64( XPTR(cxy , &desc->args[7]));
[407]2641   
2642    // call local kernel function
2643    vseg_t * vseg = vmm_create_vseg( process,
2644                                     type,
2645                                     base,
2646                                     size,
2647                                     file_offset,
2648                                     file_size,
2649                                     mapper_xp,
2650                                     vseg_cxy ); 
2651
2652    // set output arguments into client RPC descriptor
[564]2653    hal_remote_s64( XPTR( cxy , &desc->args[8] ) , (uint64_t)(intptr_t)vseg );
[407]2654
[611]2655#if DEBUG_RPC_VMM_CREATE_VSEG
2656cycle = (uint32_t)hal_get_cycles();
2657if( cycle > DEBUG_RPC_VMM_CREATE_VSEG )
2658printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2659__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2660#endif
[407]2661}
2662
2663/////////////////////////////////////////////////////////////////////////////////////////
[619]2664// [28]          Marshaling functions attached to RPC_VMM_SET_COW
[408]2665/////////////////////////////////////////////////////////////////////////////////////////
2666
2667/////////////////////////////////////////////
2668void rpc_vmm_set_cow_client( cxy_t       cxy,
2669                             process_t * process )
2670{
[619]2671#if DEBUG_RPC_VMM_SET_COW
2672thread_t * this = CURRENT_THREAD;
2673uint32_t cycle = (uint32_t)hal_get_cycles();
2674if( cycle > DEBUG_RPC_VMM_SET_COW )
2675printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2676__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2677#endif
[408]2678
[619]2679    uint32_t responses = 1;
2680
[408]2681    // initialise RPC descriptor header
2682    rpc_desc_t  rpc;
2683    rpc.index    = RPC_VMM_SET_COW;
[416]2684    rpc.blocking = true;
[619]2685    rpc.rsp      = &responses;
[408]2686
2687    // set input arguments in RPC descriptor
2688    rpc.args[0] = (uint64_t)(intptr_t)process;
2689
[436]2690    // register RPC request in remote RPC fifo
[416]2691    rpc_send( cxy , &rpc );
[408]2692
[619]2693#if DEBUG_RPC_VMM_SET_COW
2694cycle = (uint32_t)hal_get_cycles();
2695if( cycle > DEBUG_RPC_VMM_SET_COW )
2696printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2697__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2698#endif
[408]2699}
2700
2701////////////////////////////////////////
2702void rpc_vmm_set_cow_server( xptr_t xp )
2703{
[619]2704#if DEBUG_RPC_VMM_SET_COW
2705thread_t * this = CURRENT_THREAD;
2706uint32_t cycle = (uint32_t)hal_get_cycles();
2707if( cycle > DEBUG_RPC_VMM_SET_COW )
2708printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2709__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2710#endif
2711
[408]2712    process_t * process;
2713
2714    // get client cluster identifier and pointer on RPC descriptor
[436]2715    cxy_t        cxy  = GET_CXY( xp );
2716    rpc_desc_t * desc = GET_PTR( xp );
[408]2717
2718    // get input arguments from client RPC descriptor
[564]2719    process = (process_t *)(intptr_t)hal_remote_l64( XPTR(cxy , &desc->args[0]));
[408]2720   
2721    // call local kernel function
2722    vmm_set_cow( process );
2723
[619]2724#if DEBUG_RPC_VMM_SET_COW
2725cycle = (uint32_t)hal_get_cycles();
2726if( cycle > DEBUG_RPC_VMM_SET_COW )
2727printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2728__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2729#endif
[408]2730}
2731
[428]2732/////////////////////////////////////////////////////////////////////////////////////////
[635]2733// [29]      RPC_VMM_DISPLAY deprecated [AG] June 2019
[428]2734/////////////////////////////////////////////////////////////////////////////////////////
[1]2735
[635]2736/*
[428]2737/////////////////////////////////////////////
[624]2738void rpc_hal_vmm_display_client( cxy_t       cxy,
[428]2739                             process_t * process,
2740                             bool_t      detailed )
2741{
[619]2742#if DEBUG_RPC_VMM_DISPLAY
2743thread_t * this = CURRENT_THREAD;
2744uint32_t cycle = (uint32_t)hal_get_cycles();
2745if( cycle > DEBUG_RPC_VMM_DISPLAY )
2746printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2747__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2748#endif
[428]2749
[619]2750    uint32_t responses = 1;
2751
[428]2752    // initialise RPC descriptor header
2753    rpc_desc_t  rpc;
2754    rpc.index    = RPC_VMM_DISPLAY;
2755    rpc.blocking = true;
[619]2756    rpc.rsp      = &responses;
[428]2757
2758    // set input arguments in RPC descriptor
2759    rpc.args[0] = (uint64_t)(intptr_t)process;
2760    rpc.args[1] = (uint64_t)detailed;
2761
[436]2762    // register RPC request in remote RPC fifo
[428]2763    rpc_send( cxy , &rpc );
2764
[619]2765#if DEBUG_RPC_VMM_DISPLAY
2766cycle = (uint32_t)hal_get_cycles();
2767if( cycle > DEBUG_RPC_VMM_DISPLAY )
2768printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2769__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2770#endif
[428]2771}
2772
2773////////////////////////////////////////
[624]2774void rpc_hal_vmm_display_server( xptr_t xp )
[428]2775{
[619]2776#if DEBUG_RPC_VMM_DISPLAY
2777thread_t * this = CURRENT_THREAD;
2778uint32_t cycle = (uint32_t)hal_get_cycles();
2779if( cycle > DEBUG_RPC_VMM_DISPLAY )
2780printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
2781__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2782#endif
2783
[428]2784    process_t * process;
2785    bool_t      detailed;
2786
2787    // get client cluster identifier and pointer on RPC descriptor
[436]2788    cxy_t        cxy  = GET_CXY( xp );
2789    rpc_desc_t * desc = GET_PTR( xp );
[428]2790
2791    // get input arguments from client RPC descriptor
[564]2792    process  = (process_t *)(intptr_t)hal_remote_l64( XPTR(cxy , &desc->args[0]));
2793    detailed = (bool_t)               hal_remote_l64( XPTR(cxy , &desc->args[1]));
[428]2794   
2795    // call local kernel function
[624]2796    hal_vmm_display( process , detailed );
[428]2797
[619]2798#if DEBUG_RPC_VMM_DISPLAY
2799cycle = (uint32_t)hal_get_cycles();
2800if( cycle > DEBUG_RPC_VMM_DISPLAY )
2801printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
2802__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
2803#endif
[428]2804}
2805
[635]2806*/
Note: See TracBrowser for help on using the repository browser.