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

Last change on this file since 640 was 640, checked in by alain, 5 years ago

Remove all RPCs in page-fault handling.

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