Index: trunk/kernel/kern/rpc.c
===================================================================
--- trunk/kernel/kern/rpc.c	(revision 16)
+++ trunk/kernel/kern/rpc.c	(revision 23)
@@ -2,6 +2,5 @@
  * rpc.c - RPC related operations implementation.
  * 
- * Authors Mohamed Lamine Karaoui (2015)
- *         Alain Greiner (2016)
+ * Author    Alain Greiner (2016,2017)
  *
  * Copyright (c)  UPMC Sorbonne Universites
@@ -40,4 +39,5 @@
 #include <vfs.h>
 #include <fatfs.h>
+#include <signal.h>
 #include <dev_icu.h>
 #include <rpc.h>
@@ -55,5 +55,5 @@
     &rpc_thread_user_create_server,     // 4
     &rpc_thread_kernel_create_server,   // 5
-    &rpc_undefined,                     // 6                       
+    &rpc_signal_rise_server,            // 6                       
     &rpc_undefined,                     // 7
     &rpc_undefined,                     // 8
@@ -64,7 +64,7 @@
     &rpc_vfs_dentry_create_server,      // 12  
     &rpc_vfs_dentry_destroy_server,     // 13  
-    &rpc_undefined,                     // 14
-    &rpc_undefined,                     // 15
-    &rpc_undefined,                     // 16
+    &rpc_vfs_file_create_server,        // 14
+    &rpc_vfs_file_destroy_server,       // 15
+    &rpc_fatfs_get_cluster_server,      // 16
     &rpc_undefined,                     // 17
     &rpc_undefined,                     // 18
@@ -73,6 +73,6 @@
     &rpc_vmm_get_ref_vseg_server,       // 20
     &rpc_vmm_get_pte_server,            // 21
-    &rpc_semaphore_alloc_server,        // 22
-    &rpc_semaphore_free_server,         // 23
+    &rpc_kcm_alloc_server,              // 22
+    &rpc_kcm_free_server,               // 23
     &rpc_mapper_move_server,            // 24
     &rpc_undefined,                     // 25
@@ -81,6 +81,4 @@
     &rpc_undefined,                     // 28
     &rpc_undefined,                     // 29
-
-    &rpc_fatfs_get_cluster_server       // 30
 };
 
@@ -93,5 +91,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_PMEM_GET_PAGES 
+// [0]           Marshaling functions attached to RPC_PMEM_GET_PAGES 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -150,5 +148,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_PROCESS_PID_ALLOC
+// [1]           Marshaling functions attached to RPC_PROCESS_PID_ALLOC
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -207,5 +205,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_PROCESS_EXEC 
+// [2]           Marshaling functions attached to RPC_PROCESS_EXEC 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -265,5 +263,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_PROCESS_KILL 
+// [3]           Marshaling functions attached to RPC_PROCESS_KILL 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -272,5 +270,5 @@
 {
     // only reference cluster can send this RPC
-    if( !process->is_ref )
+    if( GET_CXY( process->ref_xp ) != local_cxy )
     {
         printk("PANIC in %s : caller is not the reference process\n", __FUNCTION__ );
@@ -334,9 +332,12 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_THREAD_USER_CREATE               
+// [4]           Marshaling functions attached to RPC_THREAD_USER_CREATE               
 /////////////////////////////////////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////
 void rpc_thread_user_create_client( cxy_t            cxy,  
+                                    pid_t            pid,         // in
+                                    void           * start_func,  // in
+                                    void           * start_arg,   // in
                                     pthread_attr_t * attr,        // in
                                     xptr_t         * thread_xp,   // out 
@@ -356,5 +357,8 @@
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)attr;
+    rpc.args[0] = (uint64_t)pid;
+    rpc.args[1] = (uint64_t)(intptr_t)start_func;
+    rpc.args[2] = (uint64_t)(intptr_t)start_arg;
+    rpc.args[3] = (uint64_t)(intptr_t)attr;
 
     // register RPC request in remote RPC fifo 
@@ -362,6 +366,6 @@
 
     // get output arguments from RPC descriptor
-    *thread_xp = (xptr_t)rpc.args[1];
-    *error     = (error_t)rpc.args[2];
+    *thread_xp = (xptr_t)rpc.args[4];
+    *error     = (error_t)rpc.args[5];
 }
 
@@ -373,9 +377,9 @@
     thread_t       * thread_ptr; // local pointer on thread descriptor
     xptr_t           thread_xp;  // extended pointer on thread descriptor
+
     pid_t            pid;        // process identifier
-    process_t      * process;    // local pointer on process descriptor
-    vseg_t         * vseg;       // local pointer on stack vseg
-
-    error_t          error = 0;
+    void           * start_func;
+    void           * start_arg;
+    error_t          error;
 
     // get client cluster identifier and pointer on RPC descriptor
@@ -384,5 +388,10 @@
 
     // get pointer on attributes structure in client cluster from RPC descriptor
-    attr_ptr = (pthread_attr_t *)(intptr_t)hal_remote_lwd( XPTR(client_cxy , &desc->args[0]) );
+
+    // get input arguments from RPC descriptor
+    pid        = (pid_t)                     hal_remote_lwd(XPTR(client_cxy , &desc->args[0]));
+    start_func = (void *)(intptr_t)          hal_remote_lwd(XPTR(client_cxy , &desc->args[1]));
+    start_arg  = (void *)(intptr_t)          hal_remote_lwd(XPTR(client_cxy , &desc->args[2]));
+    attr_ptr   = (pthread_attr_t *)(intptr_t)hal_remote_lwd(XPTR(client_cxy , &desc->args[3]));
 
     // makes a local copy of attributes structure
@@ -391,41 +400,12 @@
                        sizeof(pthread_attr_t) );
     
-    if( attr_copy.cxy != local_cxy )
-    {
-        printk("\n[PANIC] in %s : target cluster = %X / local_cluster = %x\n",
-               __FUNCTION__ , attr_copy.cxy , local_cxy );
-        hal_core_sleep();
-    }
-
-    // get local process descriptor
-    pid     = attr_copy.pid; 
-    process = cluster_get_local_process_from_pid( pid );
-
-    if( process == NULL )
-    {
-        printk("\n[ERROR] in %s : no process descriptor in cluster %x for pid = %x\n",
-               __FUNCTION__ , local_cxy , pid );
-        error = ENOMEM;
-       
-    }
-
-    // allocate a stack from local VMM 
-    vseg = vmm_create_vseg( process, 
-                            0,
-                            0,
-                            VSEG_TYPE_STACK );
-    if( vseg == NULL )
-    {
-        printk("\n[ERROR] in %s : cannot create stack vseg in cluster %x for pid %x\n",
-               __FUNCTION__ , local_cxy , pid );
-        error = ENOMEM;
-    } 
-
-    // create thread in local cluster
-    if( thread_user_create( &thread_ptr,
-                            &attr_copy,
-                            vseg->min,
-                            vseg->max - vseg->min ) ) error = ENOMEM;
-
+    assert( (attr_copy.cxy == local_cxy) , __FUNCTION__ , "bad target cluster\n" );
+
+    // call kernel function
+    error = thread_user_create( pid,
+                                start_func,
+                                start_arg,
+                                &attr_copy,
+                                &thread_ptr );
 
     // set output arguments
@@ -436,5 +416,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_THREAD_KERNEL_CREATE
+// [5]           Marshaling functions attached to RPC_THREAD_KERNEL_CREATE
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -502,5 +482,52 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_VFS_INODE_CREATE 
+// [6]           Marshaling functions attached to RPC_SIGNAL_RISE
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////
+void rpc_signal_rise_client( cxy_t       cxy,
+                             process_t * process,    // in
+                             uint32_t    sig_id )    // in
+{
+    // RPC must be remote
+    if( cxy == local_cxy ) 
+    {
+        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
+        hal_core_sleep();
+    }
+
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_SIGNAL_RISE;
+    rpc.response = 1;
+
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)(intptr_t)process;
+    rpc.args[1] = (uint64_t)sig_id;
+    
+    // register RPC request in remote RPC fifo 
+    rpc_send_sync( cxy , &rpc );
+}
+
+////////////////////////////////////////                             
+void rpc_signal_rise_server( xptr_t xp )
+{
+    process_t  * process;  // local pointer on process descriptor
+    uint32_t     sig_id;   // signal index
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
+
+    // get attributes from RPC descriptor
+    process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    sig_id  = (uint32_t)             hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+
+    // call local kernel function
+    signal_rise( process , sig_id );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [10]          Marshaling functions attached to RPC_VFS_INODE_CREATE 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -508,7 +535,8 @@
 void rpc_vfs_inode_create_client( cxy_t          cxy,     
                                   xptr_t         dentry_xp,  // in
-                                  uint32_t       type,       // in
+                                  uint32_t       fs_type,    // in
+                                  uint32_t       inode_type, // in
                                   uint32_t       attr,       // in
-                                  uint32_t       mode,       // in
+                                  uint32_t       rights,     // in
                                   uint32_t       uid,        // in
                                   uint32_t       gid,        // in
@@ -530,9 +558,10 @@
     // set input arguments in RPC descriptor 
     rpc.args[0] = (uint64_t)dentry_xp;
-    rpc.args[1] = (uint64_t)type;
-    rpc.args[2] = (uint64_t)attr;
-    rpc.args[3] = (uint64_t)mode;
-    rpc.args[4] = (uint64_t)uid;
-    rpc.args[5] = (uint64_t)gid;
+    rpc.args[1] = (uint64_t)fs_type;
+    rpc.args[2] = (uint64_t)inode_type;
+    rpc.args[3] = (uint64_t)attr;
+    rpc.args[4] = (uint64_t)rights;
+    rpc.args[5] = (uint64_t)uid;
+    rpc.args[6] = (uint64_t)gid;
 
     // register RPC request in remote RPC fifo (blocking function)
@@ -540,6 +569,6 @@
 
     // get output values from RPC descriptor
-    *inode_xp = (xptr_t)rpc.args[6];
-    *error    = (error_t)rpc.args[7];
+    *inode_xp = (xptr_t)rpc.args[7];
+    *error    = (error_t)rpc.args[8];
 }
 
@@ -548,7 +577,8 @@
 {
     xptr_t           dentry_xp;
-    uint32_t         type;
+    uint32_t         fs_type;
+    uint32_t         inode_type;
     uint32_t         attr;
-    uint32_t         mode;
+    uint32_t         rights;
     uint32_t         uid;
     uint32_t         gid;
@@ -561,16 +591,18 @@
 
     // get input arguments from client rpc descriptor
-    dentry_xp = (xptr_t)  hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
-    type      = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
-    attr      = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
-    mode      = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) );
-    uid       = (uid_t)   hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) );
-    gid       = (gid_t)   hal_remote_lwd( XPTR( client_cxy , &desc->args[5] ) );
+    dentry_xp  = (xptr_t)  hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    fs_type    = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+    inode_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
+    attr       = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) );
+    rights     = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) );
+    uid        = (uid_t)   hal_remote_lwd( XPTR( client_cxy , &desc->args[5] ) );
+    gid        = (gid_t)   hal_remote_lwd( XPTR( client_cxy , &desc->args[6] ) );
 
     // call local kernel function
     error = vfs_inode_create( dentry_xp,
-                              type,
+                              fs_type,
+                              inode_type,
                               attr,
-                              mode,
+                              rights,
                               uid,
                               gid,
@@ -578,10 +610,10 @@
 
     // set output arguments
-    hal_remote_swd( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)inode_xp );
-    hal_remote_swd( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)error );
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_VFS_INODE_DESTROY 
+    hal_remote_swd( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)inode_xp );
+    hal_remote_swd( XPTR( client_cxy , &desc->args[8] ) , (uint64_t)error );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [11]          Marshaling functions attached to RPC_VFS_INODE_DESTROY 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -626,5 +658,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_VFS_DENTRY_CREATE
+// [12]          Marshaling functions attached to RPC_VFS_DENTRY_CREATE
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -701,5 +733,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_VFS_DENTRY_DESTROY 
+// [13]          Marshaling functions attached to RPC_VFS_DENTRY_DESTROY 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -745,5 +777,172 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_VMM_GET_REF_VSEG
+// [14]          Marshaling functions attached to RPC_VFS_FILE_CREATE
+/////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+void rpc_vfs_file_create_client( cxy_t                  cxy,
+                                 struct vfs_inode_s   * inode,       // in
+                                 uint32_t               file_attr,   // in
+                                 xptr_t               * file_xp,     // out
+                                 error_t              * error )      // out
+{
+    // RPC must be remote
+    if( cxy == local_cxy ) 
+    {
+        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
+        hal_core_sleep();
+    }
+
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_VFS_FILE_CREATE;
+    rpc.response = 1;
+
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)(intptr_t)inode;
+    rpc.args[1] = (uint64_t)file_attr;
+
+    // register RPC request in remote RPC fifo (blocking function)
+    rpc_send_sync( cxy , &rpc );
+
+    // get output values from RPC descriptor
+    *file_xp = (xptr_t)rpc.args[2];
+    *error   = (error_t)rpc.args[3];
+}
+
+////////////////////////////////////////////
+void rpc_vfs_file_create_server( xptr_t xp )
+{
+    uint32_t      file_attr;
+    vfs_inode_t * inode;
+    xptr_t        file_xp;
+    error_t       error;
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
+
+    // get arguments "file_attr" and "inode" from client RPC descriptor
+    inode     = (vfs_inode_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    file_attr = (uint32_t)               hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+                       
+    // call local kernel function
+    error = vfs_file_create( inode,
+                             file_attr,
+                             &file_xp );
+ 
+    // set output arguments
+    hal_remote_swd( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)file_xp );
+    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [15]          Marshaling functions attached to RPC_VFS_FILE_DESTROY 
+/////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////
+void rpc_vfs_file_destroy_client( cxy_t        cxy,
+                                  vfs_file_t * file )
+{
+    // RPC must be remote
+    if( cxy == local_cxy ) 
+    {
+        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
+        hal_core_sleep();
+    }
+
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_VFS_FILE_DESTROY;
+    rpc.response = 1;
+
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)(intptr_t)file;
+    
+    // register RPC request in remote RPC fifo (blocking function)
+    rpc_send_sync( cxy , &rpc );
+}
+
+/////////////////////////////////////////////
+void rpc_vfs_file_destroy_server( xptr_t xp )
+{
+    vfs_file_t * file;
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
+
+    // get arguments "dentry" from client RPC descriptor
+    file = (vfs_file_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+                       
+    // call local kernel function
+    vfs_file_destroy( file );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [16]          Marshaling functions attached to RPC_FATFS_GET_CLUSTER 
+/////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////
+void rpc_fatfs_get_cluster_client( cxy_t      cxy,
+                                   mapper_t * mapper,    // in
+                                   uint32_t   first,     // in
+                                   uint32_t   page,      // in
+                                   uint32_t * cluster,   // out
+                                   error_t  * error )    // out
+{
+    // RPC must be remote
+    if( cxy == local_cxy ) 
+    {
+        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
+        hal_core_sleep();
+    }
+
+    // initialise RPC descriptor header 
+    rpc_desc_t  rpc;
+    rpc.index    = RPC_FATFS_GET_CLUSTER;
+    rpc.response = 1;
+
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)(intptr_t)mapper;
+    rpc.args[1] = (uint64_t)first;
+    rpc.args[2] = (uint64_t)page;
+
+    // register RPC request in remote RPC fifo 
+    rpc_send_sync( cxy , &rpc );
+
+    // get output argument from rpc descriptor
+    *cluster = (uint32_t)rpc.args[3];
+    *error   = (error_t)rpc.args[4];
+}
+
+//////////////////////////////////////////////
+void rpc_fatfs_get_cluster_server( xptr_t xp )
+{
+    mapper_t    * mapper;
+    uint32_t      first;
+    uint32_t      page;
+    uint32_t      cluster;
+    error_t       error;
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
+
+    // get input arguments
+    mapper = (mapper_t *)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) );
+    first  = (uint32_t)            hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) );
+    page   = (uint32_t)            hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) );
+
+    // call the kernel function
+    error = fatfs_get_cluster( mapper , first , page , &cluster );
+
+    // set output argument
+    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)cluster );
+    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// [20]          Marshaling functions attached to RPC_VMM_GET_REF_VSEG
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -804,5 +1003,5 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_VMM_GET_PTE 
+// [21]          Marshaling functions attached to RPC_VMM_GET_PTE 
 /////////////////////////////////////////////////////////////////////////////////////////
 
@@ -867,10 +1066,11 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_SEMAPHORE_ALLOC 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////
-void rpc_semaphore_alloc_client( cxy_t    cxy,
-                                 xptr_t * sem_xp )     // out
+// [22]          Marshaling functions attached to RPC_KCM_ALLOC 
+/////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////
+void rpc_kcm_alloc_client( cxy_t      cxy,
+                           uint32_t   kmem_type,   // in
+                           xptr_t *   buf_xp )     // out
 {
     // RPC must be remote
@@ -886,13 +1086,16 @@
     rpc.response = 1;
 
+    // set input arguments in RPC descriptor 
+    rpc.args[0] = (uint64_t)kmem_type;
+
     // register RPC request in remote RPC fifo 
     rpc_send_sync( cxy , &rpc );
 
     // get output arguments from RPC descriptor
-    *sem_xp = (xptr_t)rpc.args[0];
-}
-
-////////////////////////////////////////////
-void rpc_semaphore_alloc_server( xptr_t xp )
+    *buf_xp = (xptr_t)rpc.args[1];
+}
+
+//////////////////////////////////////
+void rpc_kcm_alloc_server( xptr_t xp )
 {
     // get client cluster identifier and pointer on RPC descriptor
@@ -900,22 +1103,26 @@
     rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
 
-    // allocates memory for semaphore
+    // get input argument "kmem_type" from client RPC descriptor
+    uint32_t kmem_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+
+    // allocates memory for kcm
     kmem_req_t  req;
-    req.type  = KMEM_SEM;
+    req.type  = kmem_type;
     req.flags = AF_ZERO;
-    remote_sem_t * sem_ptr = kmem_alloc( &req );
+    void * buf_ptr = kmem_alloc( &req );
 
     // set output argument
-    xptr_t sem_xp = XPTR( local_cxy , sem_ptr );
-    hal_remote_swd( XPTR( client_cxy , &desc->args[0] ) , (uint64_t)sem_xp );
+    xptr_t buf_xp = XPTR( local_cxy , buf_ptr );
+    hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)buf_xp );
 }   
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_SEMAPHORE_FREE 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////
-void rpc_semaphore_free_client( cxy_t          cxy,
-                                remote_sem_t * sem )   // in
+// [23]          Marshaling functions attached to RPC_KCM_FREE 
+/////////////////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////
+void rpc_kcm_free_client( cxy_t      cxy,
+                          void     * buf,          // in
+                          uint32_t   kmem_type )   // in
 {
     // RPC must be remote
@@ -932,5 +1139,6 @@
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)sem;
+    rpc.args[0] = (uint64_t)(intptr_t)buf;
+    rpc.args[1] = (uint64_t)kmem_type;
 
     // register RPC request in remote RPC fifo 
@@ -938,6 +1146,6 @@
 }
 
-///////////////////////////////////////////
-void rpc_semaphore_free_server( xptr_t xp )
+/////////////////////////////////////
+void rpc_kcm_free_server( xptr_t xp )
 {
     // get client cluster identifier and pointer on RPC descriptor
@@ -945,30 +1153,32 @@
     rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
 
-    // get input argument "sem_ptr" from client RPC descriptor
-    void * sem = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    // get input arguments "buf" and "kmem_type" from client RPC descriptor
+    void     * buf = (void *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    uint32_t   kmem_type = (uint32_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
 
     // releases memory
     kmem_req_t  req;
-    req.type = KMEM_SEM;
-    req.ptr  = sem;
-    kmem_free(&req);
+    req.type = kmem_type;
+    req.ptr  = buf;
+    kmem_free( &req );
 }   
 
 /////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_MAPPER_MOVE
-/////////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////
-void rpc_mapper_move_client( cxy_t        cxy,
-                             mapper_t   * mapper,      // in
-                             bool_t       read,        // in
-                             uint32_t     nb_frags,    // in
-                             fragment_t * frags,       // in
-                             error_t    * error )      // out
-{
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
+// [24]          Marshaling functions attached to RPC_MAPPER_MOVE
+/////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////
+void rpc_mapper_move_client( cxy_t      cxy,
+                             mapper_t * mapper,        // in
+                             uint32_t   to_buffer,     // in
+                             uint32_t   file_offset,   // in
+                             void     * buffer,        // in
+                             uint32_t   size,          // in
+                             error_t  * error )        // out
+{
+    // RPC must be remote
+    if( cxy == local_cxy ) 
+    {
+        printk("PANIC in %s : target cluster is not remote\n", __FUNCTION__ );
         hal_core_sleep();
     }
@@ -981,13 +1191,14 @@
     // set input arguments in RPC descriptor 
     rpc.args[0] = (uint64_t)(intptr_t)mapper;
-    rpc.args[1] = (uint64_t)read;
-    rpc.args[2] = (uint64_t)nb_frags;
-    rpc.args[3] = (uint64_t)(intptr_t)frags;
-
-    // register RPC request in remote RPC fifo 
-    rpc_send_sync( cxy , &rpc );
-
-    // get output argument from rpc descriptor
-    *error = (error_t)rpc.args[4];
+    rpc.args[1] = (uint64_t)to_buffer;
+    rpc.args[2] = (uint64_t)file_offset;
+    rpc.args[3] = (uint64_t)(intptr_t)buffer;
+    rpc.args[4] = (uint64_t)size;
+
+    // register RPC request in remote RPC fifo (blocking function)
+    rpc_send_sync( cxy , &rpc );
+
+    // get output values from RPC descriptor
+    *error     = (error_t)rpc.args[5];
 }
 
@@ -995,88 +1206,31 @@
 void rpc_mapper_move_server( xptr_t xp )
 {
-    mapper_t    * mapper;
-    bool_t        read;
-    uint32_t      nb;
-    void        * frags;
-    error_t       error;
-
-    // get client cluster identifier and pointer on RPC descriptor
-    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
-    rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
-
-    // get input arguments
-    mapper = (mapper_t*)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) );
-    read   = (bool_t)             hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) );
-    nb     = (uint32_t)           hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) );
-    frags  = (void*)(intptr_t)    hal_remote_lpt( XPTR( client_cxy , &desc->args[3] ) );
-
-    // call the mapper_move_fragments() function
-    error = mapper_move_fragments( mapper , read , nb , XPTR( client_cxy , frags ) );
-
-    // set output argument
-    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-//               Marshaling functions attached to RPC_FATFS_GET_CLUSTER 
-/////////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////
-void rpc_fatfs_get_cluster_client( cxy_t      cxy,
-                                   mapper_t * mapper,    // in
-                                   uint32_t   first,     // in
-                                   uint32_t   page,      // in
-                                   uint32_t * cluster,   // out
-                                   error_t  * error )    // out
-{
-    // RPC must be remote
-    if( cxy == local_cxy ) 
-    {
-        printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
-        hal_core_sleep();
-    }
-
-    // initialise RPC descriptor header 
-    rpc_desc_t  rpc;
-    rpc.index    = RPC_FATFS_GET_CLUSTER;
-    rpc.response = 1;
-
-    // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)mapper;
-    rpc.args[1] = (uint64_t)first;
-    rpc.args[2] = (uint64_t)page;
-
-    // register RPC request in remote RPC fifo 
-    rpc_send_sync( cxy , &rpc );
-
-    // get output argument from rpc descriptor
-    *cluster = (uint32_t)rpc.args[3];
-    *error   = (error_t)rpc.args[4];
-}
-
-//////////////////////////////////////////////
-void rpc_fatfs_get_cluster_server( xptr_t xp )
-{
-    mapper_t    * mapper;
-    uint32_t      first;
-    uint32_t      page;
-    uint32_t      cluster;
-    error_t       error;
-
-    // get client cluster identifier and pointer on RPC descriptor
-    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
-    rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
-
-    // get input arguments
-    mapper = (mapper_t*)(intptr_t)hal_remote_lpt( XPTR( client_cxy , &desc->args[0] ) );
-    first  = (uint32_t)           hal_remote_lw ( XPTR( client_cxy , &desc->args[1] ) );
-    page   = (uint32_t)           hal_remote_lw ( XPTR( client_cxy , &desc->args[2] ) );
-
-    // call the kernel function
-    error = fatfs_get_cluster( mapper , first , page , &cluster );
-
-    // set output argument
-    hal_remote_swd( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)cluster );
-    hal_remote_swd( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
+    mapper_t * mapper;
+    uint32_t   to_buffer;
+    uint32_t   file_offset;
+    void     * buffer;
+    uint32_t   size;
+    error_t    error;
+
+    // get client cluster identifier and pointer on RPC descriptor
+    cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
+    rpc_desc_t * desc        = (rpc_desc_t *)GET_PTR( xp );
+
+    // get arguments from client RPC descriptor
+    mapper      = (mapper_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) );
+    to_buffer   =                       hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) );
+    file_offset =                       hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) );
+    buffer      = (void     *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[3] ) );
+    size        =                       hal_remote_lwd( XPTR( client_cxy , &desc->args[4] ) );
+
+    // call local kernel function
+    error = mapper_move( mapper,
+                         to_buffer,
+                         file_offset,
+                         buffer,
+                         size );
+
+    // set output argument to client RPC descriptor
+    hal_remote_swd( XPTR( client_cxy , &desc->args[5] ) , (uint64_t)error );
 }
 
