Index: trunk/kernel/kern/rpc.h
===================================================================
--- trunk/kernel/kern/rpc.h	(revision 16)
+++ trunk/kernel/kern/rpc.h	(revision 23)
@@ -2,6 +2,5 @@
  * rpc.h - RPC (Remote Procedure Call) operations definition.
  *
- * Authors Mohamed Karaoui (2015)
- *         Alain Greiner (2016)
+ * Author  Alain Greiner (2016,2017)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -43,4 +42,5 @@
 struct vfs_inode_s;
 struct vfs_dentry_s;
+struct vfs_file_s;
 struct thread_s;
 struct mapper_s;
@@ -63,4 +63,5 @@
     RPC_THREAD_USER_CREATE     = 4,
     RPC_THREAD_KERNEL_CREATE   = 5,
+    RPC_SIGNAL_RISE            = 6,
 
     RPC_VFS_INODE_CREATE       = 10,
@@ -68,14 +69,15 @@
     RPC_VFS_DENTRY_CREATE      = 12,
     RPC_VFS_DENTRY_DESTROY     = 13,
+    RPC_VFS_FILE_CREATE        = 14,
+    RPC_VFS_FILE_DESTROY       = 15,
+    RPC_FATFS_GET_CLUSTER      = 16,
 
     RPC_VMM_GET_REF_VSEG       = 20,
     RPC_VMM_GET_PTE            = 21,
-    RPC_SEMAPHORE_ALLOC        = 22,
-    RPC_SEMAPHORE_FREE         = 23,
+    RPC_KCM_ALLOC              = 22,
+    RPC_KCM_FREE               = 23,
     RPC_MAPPER_MOVE            = 24,
 
-    RPC_FATFS_GET_CLUSTER      = 30,
-
-    RPC_MAX_INDEX              = 31,
+    RPC_MAX_INDEX              = 30,
 }
 rpc_index_t;
@@ -96,5 +98,5 @@
 	rpc_index_t       index;       // index of requested RPC service
 	volatile uint32_t response;    // response valid when 0
-    uint64_t          args[8];     // input/output arguments buffer
+    uint64_t          args[10];    // input/output arguments buffer
 } 
 rpc_desc_t;
@@ -192,4 +194,7 @@
 void __attribute__((noinline)) rpc_undefined();
 
+
+
+
 /**********************************************************************************/
 /******* Marshalling functions attached to the various RPCs ***********************/
@@ -197,5 +202,5 @@
 
 /***********************************************************************************
- * The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster,
+ * [0] The RPC_PMEM_GET_PAGES allocates one or several pages in a remote cluster,
  * and returns the PPN of the first allocated page.
  ***********************************************************************************
@@ -213,5 +218,5 @@
 
 /***********************************************************************************
- * The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers
+ * [1] The RPC_PROCESS_PID_ALLOC allocates one new PID in a remote cluster, registers
  * the new process in the remote cluster, and returns the PID, and an error code.
  ***********************************************************************************
@@ -229,5 +234,5 @@
 
 /***********************************************************************************
- * The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster
+ * [2] The RPC_PROCESS_EXEC creates a process descriptor copy, in a remote cluster
  * and initializes if from information found in the reference process descriptor.
  * This remote cluster becomes the new reference cluster.
@@ -244,5 +249,5 @@
 
 /***********************************************************************************
- * The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster
+ * [3] The RPC_PROCESS_KILL is actually a multicast RPC sent by the reference cluster
  * to other clusters containing a process descriptor copy, to destroy these copies.
  ***********************************************************************************
@@ -254,8 +259,8 @@
 
 /***********************************************************************************
- * The RPC_THREAD_USER_CREATE creates an user thread in the server cluster,
- * as specified by the pthread_attr_t argument. It returns the local pointer
- * on the thread descriptor in server cluster, and an error code.
- * It is called by the pthread_create system call.
+ * [4] The RPC_THREAD_USER_CREATE creates an user thread in the server cluster,
+ * as specified by the arguments. It returns an extended pointer on the new
+ * thread descriptor in server cluster, and an error code.
+ * It is called by the sys_thread_create() system call.
  ***********************************************************************************
  * @ cxy       : server cluster identifier.
@@ -265,4 +270,7 @@
  **********************************************************************************/
 void rpc_thread_user_create_client( cxy_t                   cxy,
+                                    pid_t                   pid,
+                                    void                  * start_func,
+                                    void                  * start_arg,
                                     struct pthread_attr_s * attr,
                                     xptr_t                * thread_xp,
@@ -272,8 +280,8 @@
 
 /***********************************************************************************
- * The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster,
+ * [5] The RPC_THREAD_KERNEL_CREATE creates a kernel thread in the server cluster,
  * as specified by the type, func and args arguments. It returns the local pointer
  * on the thread descriptor in server cluster and an error code.
- * It is used by the dev_init() function to cretae the device server thread.
+ * It is used by the dev_init() function to create the device server thread.
  ***********************************************************************************
  * @ cxy       : server cluster identifier.
@@ -293,24 +301,41 @@
 void rpc_thread_kernel_create_server( xptr_t xp );
 
+/***********************************************************************************
+ * [6] The RPC_SIGNAL_RISE ask a target cluster to register a given signal in
+ * all threads descriptors of a given process. 
+ * It is used by the sys_kill() function.
+ ***********************************************************************************
+ * @ cxy       : server cluster identifier.
+ * @ process   : [in]  local pointer on target process descriptor in server.
+ * @ sig_id    : [in]  signal index.
+ **********************************************************************************/
+void rpc_signal_rise_client( cxy_t              cxy,
+                             struct process_s * process,
+                             uint32_t           sig_id );
+                             
+void rpc_signal_rise_server( xptr_t xp );
+
 /*********************************************************************************** 
- * The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a
+ * [10] The RPC_VFS_INODE_CREATE creates an inode and the associated mapper in a
  * remote cluster. The parent dentry must have been previously created.
  * It returns an extended pointer on the created inode.
  ***********************************************************************************
- * @ cxy       :  server cluster identifier
- * @ dentry_xp : [in]  extended pointer on parent dentry.
- * @ type      : [in]  file system type.
- * @ attr      : [in]  TODO ???
- * @ mode      : [in]  access mode.
- * @ uid       : [in]  user ID
- * @ gid       : [in]  group ID
- * @ inode_xp  : [out] buffer for extended pointer on created inode.
- * @ error     : [out] error status (0 if success).
+ * @ cxy        :  server cluster identifier.
+ * @ dentry_xp  : [in]  extended pointer on parent dentry.
+ * @ fs_type    : [in]  file system type.
+ * @ inode_type : [in]  file system type.
+ * @ attr       : [in]  inode attributes.
+ * @ rights     : [in]  access rights
+ * @ uid        : [in]  user ID
+ * @ gid        : [in]  group ID
+ * @ inode_xp   : [out] buffer for extended pointer on created inode.
+ * @ error      : [out] error status (0 if success).
  **********************************************************************************/
 void rpc_vfs_inode_create_client( cxy_t      cxy,
                                   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,
@@ -321,5 +346,5 @@
 
 /*********************************************************************************** 
- * The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor
+ * [11] The RPC_VFS_INODE_DESTROY releases memory allocated for an inode descriptor
  * and for the associated mapper in a remote cluster. 
  ***********************************************************************************
@@ -333,5 +358,5 @@
 
 /*********************************************************************************** 
- * The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster. 
+ * [12] The RPC_VFS_DENTRY_CREATE creates a dentry in a remote cluster. 
  * It returns an extended pointer on the created dentry.
  ***********************************************************************************
@@ -353,5 +378,5 @@
 
 /*********************************************************************************** 
- * The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor
+ * [13] The RPC_VFS_DENTRY_DESTROY releases memory allocated for an dentry descriptor
  * in a remote cluster. 
  ***********************************************************************************
@@ -364,9 +389,57 @@
 void rpc_vfs_dentry_destroy_server( xptr_t xp );
 
-
-
-
-/***********************************************************************************
- * The RPC_VMM_GET_REF_VSEG returns an extended pointer 
+/*********************************************************************************** 
+ * [14] The RPC_VFS_FILE_CREATE creates a file descriptor in a remote cluster. 
+ * It returns an extended pointer on the created file structure.
+ ***********************************************************************************
+ * @ cxy        :  server cluster identifier
+ * @ inode      : [in]  local pointer on parent inode.
+ * @ file_attr  : [in]  new file attributes.
+ * @ file_xp    : [out] buffer for extended pointer on created file.
+ * @ error      : [out] error status (0 if success).
+ **********************************************************************************/
+void rpc_vfs_file_create_client( cxy_t                  cxy,
+                                 struct vfs_inode_s   * inode,
+                                 uint32_t               file_attr,
+                                 xptr_t               * file_xp,
+                                 error_t              * error );
+
+void rpc_vfs_file_create_server( xptr_t xp );
+
+/*********************************************************************************** 
+ * [15] The RPC_VFS_FILE_DESTROY releases memory allocated for a file descriptor
+ * in a remote cluster. 
+ ***********************************************************************************
+ * @ cxy       :  server cluster identifier
+ * @ file       : [in]  local pointer on file.
+ **********************************************************************************/
+void rpc_vfs_file_destroy_client( cxy_t               cxy,
+                                  struct vfs_file_s * file );
+
+void rpc_vfs_file_destroy_server( xptr_t xp );
+
+/***********************************************************************************
+ * [16] The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" 
+ * cluster to scan the FAT mapper, stored in a remote "server" cluster, and get 
+ * from the mapper the local pointer on a given page.
+ ***********************************************************************************
+ * @ cxy      : server cluster identifier.
+ * @ mapper   : [in]  local pointer on FAT mapper.
+ * @ first    : [in]  FATFS cluster index allocated to first page of file.
+ * @ page     : [in]  page index in file.
+ * @ cluster  : [out] local pointer on buffer for found FATFS cluster index.
+ * @ error    : [out] local pointer on buffer for error code (in client cluster). 
+ **********************************************************************************/
+void rpc_fatfs_get_cluster_client( cxy_t             cxy,
+                                   struct mapper_s * mapper,
+                                   uint32_t          first,
+                                   uint32_t          page,
+                                   uint32_t        * cluster,
+                                   error_t         * error );    
+
+void rpc_fatfs_get_cluster_server( xptr_t xp );
+
+/***********************************************************************************
+ * [20] The RPC_VMM_GET_REF_VSEG returns an extended pointer 
  * on the vseg containing a given virtual address in a given process.
  * The server cluster is supposed to be the reference cluster.
@@ -386,5 +459,5 @@
 
 /***********************************************************************************
- * The RPC_VMM_GET_PTE returns in the "ppn" and "attr" arguments the PTE value
+ * [21] The RPC_VMM_GET_PTE returns in the "ppn" and "attr" arguments the PTE value
  * for a given VPN in a given process.
  * The server cluster is supposed to be the reference cluster, and the vseg
@@ -410,76 +483,57 @@
 
 /***********************************************************************************
- * The RPC_SEMAPHORE_ALLOC allocates memory for a semaphore in a remote cluster,
- * and returns an extended pointer on the created semaphore.
-  It returns NULL if physical memory cannot be allocated. 
- ***********************************************************************************
- * @ cxy     : server cluster identifier.
- * @ sem_xp  : [out] buffer for extended pointer on semaphore. 
- **********************************************************************************/
-void rpc_semaphore_alloc_client( cxy_t    cxy,
-                                 xptr_t * sem_xp );  
-
-void rpc_semaphore_alloc_server( xptr_t xp );
-
-/***********************************************************************************
- * The RPC_SEMAPHORE_FREE releases memory allocated for a semaphore 
+ * [22] The RPC_KCM_ALLOC allocates memory from a given KCM in a remote cluster,
+ * and returns an extended pointer on the allocated object.
+  It returns XPTR_NULL if physical memory cannot be allocated. 
+ ***********************************************************************************
+ * @ cxy       : server cluster identifier.
+ * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
+ * @ buf_xp    : [out] buffer for extended pointer on allocated buffer.
+ **********************************************************************************/
+void rpc_kcm_alloc_client( cxy_t      cxy,
+                           uint32_t   kmem_type,
+                           xptr_t   * buf_xp );  
+
+void rpc_kcm_alloc_server( xptr_t xp );
+
+/***********************************************************************************
+ * [23] The RPC_KCM_FREE releases memory allocated for a KCM object of a given type,
  * in a remote cluster.
  ***********************************************************************************
- * @ cxy     : server cluster identifier.
- * @ sem     : [in] local pointer on semaphore. 
- **********************************************************************************/
-void rpc_semaphore_free_client( cxy_t                 cxy,
-                                struct remote_sem_s * sem );
-
-void rpc_semaphore_free_server( xptr_t xp );
-
-/***********************************************************************************
- * The RPC_MAPPER_MOVE can be send by any thread running in a "client" cluster 
- * to the "server" cluster containing the mapper of a given file. The service is 
- * to move data between the mapper and an user buffer. This user buffer is described
- * as a set of fragments. Each fragment is contained in one single physical page.
- * It is defined by four parameters : size / file_offset / ppn / page_offset,
- * defined in the mapper.h file. The client thread is in charge of building 
- * the fragments array covering the user buffer. 
- * As each fragments can be stored in a different cluster, and this fragment can 
- * be stored in two successive pages in the radix tree, each fragment is moved 
- * using one or two different hal_remote_memcpy().
- ***********************************************************************************
- * @ cxy      : server cluster identifier.
- * @ inode    : [in]  local pointer on inode (in server cluster).
- * @ read     : [in]  mapper to buffer if true / buffer to mapper if false.
- * @ nb_frags : [in]  number of fragments in fragments array.
- * @ frags    : [in]  local pointer on fragments array (in client cluster).
- * @ error    : [out] local pointer on buffer for error code (in client cluster). 
- **********************************************************************************/
-void rpc_mapper_move_client( cxy_t                cxy,
-                             struct mapper_s    * mapper,
-                             bool_t               read,
-                             uint32_t             nb_frags,
-                             struct fragment_s  * frags,
-                             error_t            * error );
+ * @ cxy       : server cluster identifier.
+ * @ buf       : [in] local pointer on allocated buffer. 
+ * @ kmem_type : [in]  KCM object type (as defined in kmem.h).
+ **********************************************************************************/
+void rpc_kcm_free_client( cxy_t     cxy,
+                          void    * buf,
+                          uint32_t  kmem_type );
+
+void rpc_kcm_free_server( xptr_t xp );
+
+/***********************************************************************************
+ * [24] The RPC_MAPPER_MOVE is called by the vfs_move() function.
+ * It allows a client thread to requires a remote mapper to move data to/from
+ * an user buffer, as specified by the arguments.
+ ***********************************************************************************
+ * @ cxy         : server cluster identifier.
+ * @ mapper      : [in]  local pointer on mapper
+ * @ to_buffer   : [in]  move data from buffer to mapper if non zero.
+ * @ file_offset : [in]  first byte to move in mapper 
+ * @ buffer      : [in]  pointer on buffer in user space
+ * @ size        : [in]  number of bytes to move
+ * @ error       : [out] error status (0 if success).
+ **********************************************************************************/
+void rpc_mapper_move_client( cxy_t             cxy,
+                             struct mapper_s * mapper,
+                             uint32_t          to_buffer,
+                             uint32_t          file_offset,
+                             void            * buffer,
+                             uint32_t          size,
+                             error_t         * error );
 
 void rpc_mapper_move_server( xptr_t xp );
 
-/***********************************************************************************
- * The RPC_FATFS_GET_CLUSTER can be send by any thread running in a "client" cluster
- * to scan the FAT mapper, stored in a remote "server" cluster, and get the FATFS 
- * cluster index of a given page of a given file.
- ***********************************************************************************
- * @ cxy      : server cluster identifier.
- * @ mapper   : [in]  local pointer on FAT mapper.
- * @ first    : [in]  FATFS cluster index allocated to first page of file.
- * @ page     : [in]  page index in file.
- * @ cluster  : [out] local pointer on buffer for found FATFS cluster index.
- * @ error    : [out] local pointer on buffer for error code (in client cluster). 
- **********************************************************************************/
-void rpc_fatfs_get_cluster_client( cxy_t             cxy,
-                                   struct mapper_s * mapper,
-                                   uint32_t          first,
-                                   uint32_t          page,
-                                   uint32_t        * cluster,
-                                   error_t         * error );    
-
-void rpc_fatfs_get_cluster_server( xptr_t xp );
+
+
 
 #endif
