Index: trunk/kernel/kern/rpc.c
===================================================================
--- trunk/kernel/kern/rpc.c	(revision 601)
+++ trunk/kernel/kern/rpc.c	(revision 610)
@@ -75,5 +75,5 @@
     &rpc_kcm_alloc_server,                 // 22
     &rpc_kcm_free_server,                  // 23
-    &rpc_mapper_move_user_server,          // 24
+    &rpc_undefined,                        // 24   unused slot
     &rpc_mapper_handle_miss_server,        // 25
     &rpc_undefined,                        // 26   unused slot
@@ -111,5 +111,5 @@
     "KCM_ALLOC",                 // 22
     "KCM_FREE",                  // 23
-    "MAPPER_MOVE_USER",          // 24
+    "undefined",                 // 24
     "MAPPER_HANDLE_MISS",        // 25
     "undefined",                 // 26
@@ -302,5 +302,5 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[DBG] %s : RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",
+printk("\n[%s] RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",
 __FUNCTION__, server_ptr->trdid, server_core_lid, cycle );
 #endif
@@ -318,6 +318,7 @@
                 desc_ptr = GET_PTR( desc_xp );
 
-	            index    = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) );
-                blocking = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) );
+	            index      = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) );
+                blocking   = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) );
+                client_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->thread ) );
 
 #if DEBUG_RPC_SERVER_GENERIC
@@ -325,7 +326,10 @@
 uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) );
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[DBG] %s : RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",
+printk("\n[%s] RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",
 __FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle );
 #endif
+                // register client thread in RPC thread descriptor
+                server_ptr->rpc_client_xp = XPTR( desc_cxy , client_ptr );
+ 
                 // call the relevant server function
                 rpc_server[index]( desc_xp );
@@ -334,5 +338,5 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[DBG] %s : RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",
+printk("\n[%s] RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",
 __FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, cycle );
 #endif
@@ -355,5 +359,5 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[DBG] %s : RPC thread %x unblocked client thread %x / cycle %d\n",
+printk("\n[%s] RPC thread %x unblocked client thread %x / cycle %d\n",
 __FUNCTION__, server_ptr->trdid, client_ptr->trdid, cycle );
 #endif
@@ -372,5 +376,5 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[DBG] %s : RPC thread %x suicides / cycle %d\n",
+printk("\n[%s] RPC thread %x suicides / cycle %d\n",
 __FUNCTION__, server_ptr->trdid, cycle );
 #endif
@@ -391,5 +395,5 @@
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 
-printk("\n[DBG] %s : RPC thread %x block IDLE & deschedules / cycle %d\n",
+printk("\n[%s] RPC thread %x block IDLE & deschedules / cycle %d\n",
 __FUNCTION__, server_ptr->trdid, cycle );
 #endif
@@ -870,7 +874,8 @@
 uint32_t  action = rpc->args[0];
 pid_t     pid    = rpc->args[1];
+thread_t * this = CURRENT_THREAD;
 if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : enter to request %s of process %x in cluster %x / cycle %d\n",
-__FUNCTION__ , process_action_str( action ) , pid , cxy , cycle );
+printk("\n[%s] thread[%x,%x] enter to request %s of process %x in cluster %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle );
 #endif
 
@@ -885,6 +890,6 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : exit after requesting to %s process %x in cluster %x / cycle %d\n",
-__FUNCTION__ , process_action_str( action ) , pid , cxy , cycle );
+printk("\n[%s] thread[%x,%x] requested %s of process %x in cluster %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle );
 #endif
 
@@ -915,7 +920,9 @@
 #if DEBUG_RPC_PROCESS_SIGACTION
 uint32_t cycle = (uint32_t)hal_get_cycles();
+thread_t * this = CURRENT_THREAD;
 if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n",
-__FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle );
+printk("\n[%s] thread[%x,%x] enter to %s process %x in cluster %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid,
+process_action_str( action ), pid, local_cxy, cycle );
 #endif
 
@@ -954,6 +961,7 @@
 cycle = (uint32_t)hal_get_cycles();
 if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n",
-__FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle );
+printk("\n[%s] thread[%x,%x] exit after %s process %x in cluster %x / cycle %d\n",
+__FUNCTION__, this->process->pid, this->trdid,
+process_action_str( action ), pid, local_cxy, cycle );
 #endif
 
@@ -966,5 +974,4 @@
 /////////////////////////////////////////////////////
 void rpc_vfs_inode_create_client( cxy_t          cxy,     
-                                  xptr_t         dentry_xp,  // in
                                   uint32_t       fs_type,    // in
                                   uint32_t       inode_type, // in
@@ -993,11 +1000,10 @@
 
     // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)dentry_xp;
-    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;
+    rpc.args[0] = (uint64_t)fs_type;
+    rpc.args[1] = (uint64_t)inode_type;
+    rpc.args[2] = (uint64_t)attr;
+    rpc.args[3] = (uint64_t)rights;
+    rpc.args[4] = (uint64_t)uid;
+    rpc.args[5] = (uint64_t)gid;
 
     // register RPC request in remote RPC fifo
@@ -1005,6 +1011,6 @@
 
     // get output values from RPC descriptor
-    *inode_xp = (xptr_t)rpc.args[7];
-    *error    = (error_t)rpc.args[8];
+    *inode_xp = (xptr_t)rpc.args[6];
+    *error    = (error_t)rpc.args[7];
 
 #if DEBUG_RPC_VFS_INODE_CREATE
@@ -1027,5 +1033,4 @@
 #endif
 
-    xptr_t           dentry_xp;
     uint32_t         fs_type;
     uint32_t         inode_type;
@@ -1042,15 +1047,13 @@
 
     // get input arguments from client rpc descriptor
-    dentry_xp  = (xptr_t)    hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    fs_type    = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
-    inode_type = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
-    attr       = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
-    rights     = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
-    uid        = (uid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) );
-    gid        = (gid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[6] ) );
+    fs_type    = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
+    inode_type = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
+    attr       = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
+    rights     = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
+    uid        = (uid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
+    gid        = (gid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) );
 
     // call local kernel function
-    error = vfs_inode_create( dentry_xp,
-                              fs_type,
+    error = vfs_inode_create( fs_type,
                               inode_type,
                               attr,
@@ -1061,6 +1064,6 @@
 
     // set output arguments
-    hal_remote_s64( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)inode_xp );
-    hal_remote_s64( XPTR( client_cxy , &desc->args[8] ) , (uint64_t)error );
+    hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)inode_xp );
+    hal_remote_s64( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)error );
 
 #if DEBUG_RPC_VFS_INODE_CREATE
@@ -1149,5 +1152,4 @@
                                    uint32_t               type,         // in
                                    char                 * name,         // in
-                                   struct vfs_inode_s   * parent,       // in
                                    xptr_t               * dentry_xp,    // out
                                    error_t              * error )       // out
@@ -1172,5 +1174,4 @@
     rpc.args[0] = (uint64_t)type;
     rpc.args[1] = (uint64_t)(intptr_t)name;
-    rpc.args[2] = (uint64_t)(intptr_t)parent;
 
     // register RPC request in remote RPC fifo
@@ -1178,6 +1179,6 @@
 
     // get output values from RPC descriptor
-    *dentry_xp = (xptr_t)rpc.args[3];
-    *error     = (error_t)rpc.args[4];
+    *dentry_xp = (xptr_t)rpc.args[2];
+    *error     = (error_t)rpc.args[3];
 
 #if DEBUG_RPC_VFS_DENTRY_CREATE
@@ -1202,5 +1203,4 @@
     uint32_t      type;
     char        * name;
-    vfs_inode_t * parent;
     xptr_t        dentry_xp;
     error_t       error;
@@ -1212,7 +1212,6 @@
 
     // get arguments "name", "type", and "parent" from client RPC descriptor
-    type   = (uint32_t)               hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    name   = (char *)(intptr_t)       hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
-    parent = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
+    type   = (uint32_t)         hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
+    name   = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
 
     // makes a local copy of  name
@@ -1223,9 +1222,8 @@
     error = vfs_dentry_create( type,
                                name_copy,
-                               parent,
                                &dentry_xp );
     // set output arguments
-    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)dentry_xp );
-    hal_remote_s64( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
+    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)dentry_xp );
+    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
 
 #if DEBUG_RPC_VFS_DENTRY_CREATE
@@ -2112,97 +2110,6 @@
 
 /////////////////////////////////////////////////////////////////////////////////////////
-// [24]          Marshaling functions attached to RPC_MAPPER_MOVE_USER  
-/////////////////////////////////////////////////////////////////////////////////////////
-
-/////////////////////////////////////////////////
-void rpc_mapper_move_user_client( cxy_t      cxy,
-                                  mapper_t * mapper,        // in
-                                  bool_t     to_buffer,     // in
-                                  uint32_t   file_offset,   // in
-                                  void     * buffer,        // in
-                                  uint32_t   size,          // in
-                                  error_t  * error )        // out
-{
-#if DEBUG_RPC_MAPPER_MOVE_USER
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
-printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-
-    assert( (cxy != local_cxy) , "target cluster is not remote\n");
-
-    // initialise RPC descriptor header 
-    rpc_desc_t  rpc;
-    rpc.index    = RPC_MAPPER_MOVE_USER;
-    rpc.blocking = true;
-    rpc.responses = 1;
-
-    // set input arguments in RPC descriptor 
-    rpc.args[0] = (uint64_t)(intptr_t)mapper;
-    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
-    rpc_send( cxy , &rpc );
-
-    // get output values from RPC descriptor
-    *error     = (error_t)rpc.args[5];
-
-#if DEBUG_RPC_MAPPER_MOVE_USER
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
-printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-}
-
-/////////////////////////////////////////////
-void rpc_mapper_move_user_server( xptr_t xp )
-{
-#if DEBUG_RPC_MAPPER_MOVE_USER
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
-printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-
-    mapper_t * mapper;
-    bool_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  = GET_CXY( xp );
-    rpc_desc_t * desc        = GET_PTR( xp );
-
-    // get arguments from client RPC descriptor
-    mapper      = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
-    to_buffer   =                       hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
-    file_offset =                       hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
-    buffer      = (void *)(intptr_t)    hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
-    size        =                       hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
-
-    // call local kernel function
-    error = mapper_move_user( mapper,
-                              to_buffer,
-                              file_offset,
-                              buffer,
-                              size );
-
-    // set output argument to client RPC descriptor
-    hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error );
-
-#if DEBUG_RPC_MAPPER_MOVE_USER
-cycle = (uint32_t)hal_get_cycles();
-if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
-printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
-__FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
-#endif
-}
+// [24]          undefined slot 
+/////////////////////////////////////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -2280,6 +2187,6 @@
 
     // set output argument to client RPC descriptor
-    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)error );
-    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)page_xp );
+    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)page_xp );
+    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
 
 #if DEBUG_RPC_MAPPER_HANDLE_MISS
