Index: trunk/kernel/syscalls/syscalls.h
===================================================================
--- trunk/kernel/syscalls/syscalls.h	(revision 279)
+++ trunk/kernel/syscalls/syscalls.h	(revision 407)
@@ -1,4 +1,4 @@
 /*
- * syscalls.h - kernel services definition
+ * syscalls.h - Kernel side services for syscall handling.
  * 
  * Author     Alain Greiner (2016,2017)
@@ -26,7 +26,7 @@
 
 #include <hal_types.h>
-#include <time.h>
-
-/*****   Forward declarations  *****/
+#include <shared_syscalls.h>
+
+/**   Forward declarations  *****/
 
 struct thread_s;                  // defined in thread.h
@@ -36,86 +36,28 @@
 struct mmap_attr_s;               // defined in vmm.h
 
-/******************************************************************************************
- * This enum defines the mnemonics for the syscall indexes.
- * It must be kept consistent with the array defined in do_syscalls.c
- *****************************************************************************************/
-enum
-{
-	SYS_THREAD_EXIT    = 0,
-	SYS_MMAP           = 1,
-	SYS_THREAD_CREATE  = 2,
-	SYS_THREAD_JOIN    = 3,
-	SYS_THREAD_DETACH  = 4,
-	SYS_THREAD_YIELD   = 5,
-	SYS_SEM            = 6,
-	SYS_CONDVAR        = 7,
-	SYS_BARRIER        = 8,
-	SYS_MUTEX          = 9,
-
-	SYS_SLEEP          = 10,
-	SYS_WAKEUP         = 11,
-	SYS_OPEN           = 12,
-	SYS_CREAT          = 13,
-	SYS_READ           = 14,
-	SYS_WRITE          = 15,
-	SYS_LSEEK          = 16,
-	SYS_CLOSE          = 17,
-	SYS_UNLINK         = 18,   
-	SYS_PIPE           = 19,
-
-	SYS_CHDIR          = 20,
-	SYS_MKDIR          = 21,
-	SYS_MKFIFO         = 22,    
-	SYS_OPENDIR        = 23,
-	SYS_READDIR        = 24,
-	SYS_CLOSEDIR       = 25,
-	SYS_GETCWD         = 26,
-	SYS_CLOCK          = 27,
-	SYS_ALARM          = 28,   
-	SYS_RMDIR          = 29,
-
-	SYS_UTLS           = 30,  
-	SYS_CHMOD          = 31,
-	SYS_SIGNAL         = 32,
-	SYS_TIMEOFDAY      = 33,
-	SYS_KILL           = 34,
-	SYS_GETPID         = 35,
-	SYS_FORK           = 36,
-	SYS_EXEC           = 37,
-	SYS_STAT           = 38,     
-	SYS_TRACE          = 39,
-        
-	SYSCALLS_NR        = 40,
-};
-
-
-/********************************************************************************************/
-/********************    system calls    ****************************************************/ 
-/********************************************************************************************/
-
-/********************************************************************************************* 
- * [0] This function terminates the execution of the calling user thread value, 
+/****************************************************************************************** 
+ * [0] This function terminates the execution of the calling user thread, 
  * and makes the exit_value pointer available to any successful pthread_join() with the 
  * terminating thread.
- *********************************************************************************************
- * @ exit_vallue  : [out] pointer to to the parrent thread if attached.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ ******************************************************************************************
+ * @ exit_vallue  : pointer to be returned to parent thread if thead is attached.
+ * @ return 0 if success / return -1 if failure.
+ *****************************************************************************************/
 int sys_thread_exit( void * exit_value );
 
-/********************************************************************************************* 
- * [1] This function map physical memory (or a file) in the calling thread virtual space.
- * The <attr> argument is a pointer on a structure containing arguments, defined in vmm.h.
- * TODO not implemented yet...
- *********************************************************************************************
- * @ attr       : pointer on attributes structure.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int sys_mmap( struct mmap_attr_s * attr );
-
-/********************************************************************************************* 
+/****************************************************************************************** 
+ * [1] This function calls the scheduler for the core running the calling thread.
+ ******************************************************************************************
+ * @ x_size   : [out] number of clusters in a row.
+ * @ y_size   : [out] number of clusters in a column.
+ * @ ncores   : [out] number of cores per cluster.
+ * @ return always 0.
+ *****************************************************************************************/
+int sys_thread_yield();
+
+/****************************************************************************************** 
  * [2] This function creates a new user thread. The <user_attr> argument is a pointer
  * on astructure containing the thread attributes, defined in thread.h file.
- *********************************************************************************************
+ ******************************************************************************************
  * @ new_thread  : [out] local pointer on created thread descriptor.
  * @ user_attr   : [in]  pointer on thread attributes structure.
@@ -123,5 +65,5 @@
  * @ start_args  : [in]  pointer on start function arguments.
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_thread_create( struct thread_s        * new_thread,
                        struct pthread_attr_s  * user_attr,
@@ -129,240 +71,175 @@
                        void                   * start_args );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [3] This blocking function suspend execution of the calling thread until completion 
  * of another target thread identified by the <trdid> argument.
  * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the 
  * target thread is stored in the location referenced by exit_value.
- *********************************************************************************************
+ ******************************************************************************************
  * @ trdid     : [in]  target thread identifier.
  * @ thread    : [out] buffer for exit_value returned by target thread. 
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_thread_join( trdid_t    trdid,
                      void    ** exit_value );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [4] This function detach a joinable thread.
- *********************************************************************************************
- * @ trdid   : thread identifier.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ ******************************************************************************************
+ * @ trdid   : thread identifier.i
+ * @ return 0 if success / return -1 if failure.
+ *****************************************************************************************/
 int sys_thread_detach( trdid_t  trdid );
 
-/********************************************************************************************* 
- * [5] This function calls the scheduler for the core running the calling thread.
- *********************************************************************************************
- * @ return always 0. 
- ********************************************************************************************/
-int sys_thread_yield();
-
-/********************************************************************************************* 
+/****************************************************************************************** 
+ * [5] This slot is not used.
+ *****************************************************************************************/
+
+/****************************************************************************************** 
  * [6] This function implement all operations on a POSIX unnamed semaphore,
  * that can be shared by threads running in different clusters.
  * The kernel structure representing a remote semaphore is in the remote_sem.h file,
  * and the code implementing the operations is in the remore_sem.c file.
- *********************************************************************************************
+ ******************************************************************************************
  * @ vaddr     : semaphore virtual address in user space == identifier.
  * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT.
  * @ value     : pointer on in/out argument in user space.
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_sem( void       * vaddr,
              uint32_t     operation,
              uint32_t   * value );
 
-typedef enum
-{
-	SEM_INIT,
-	SEM_DESTROY,
-	SEM_GETVALUE,
-	SEM_WAIT,
-	SEM_POST,
-} 
-sem_operation_t;
-
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [7] This function implement all operations on a POSIX condition variable.
  * The kernel structure representing a cond_var is defined in the remote_cv.h file,
  * The code implementing the operations is defined in the remote_cv.c file.
- *********************************************************************************************
+ ******************************************************************************************
  * @ vaddr     : condvar virtual address in user space == identifier.
  * @ operation : operation type (see below).
  * @ attr      : mutex virtual address in user space == identifier.
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_condvar( void     * condvar,
                  uint32_t   operation,
                  void     * mutex );
 
-typedef enum
-{
-	CONDVAR_INIT,
-	CONDVAR_DESTROY,
-    CONDVAR_WAIT,
-    CONDVAR_SIGNAL,
-    CONDVAR_BROADCAST,
-} 
-condvar_operation_t;
-
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [8] This function implement all operations on a POSIX barrier.
  * The kernel structure representing a barrier is defined in the remote_barrier.h file.
  * The code implementting the operations is defined in the remote_barrier.c file.
- *********************************************************************************************
+ ******************************************************************************************
  * @ vaddr     : barrier virtual address in user space == identifier.
  * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT.
  * @ count     : number of expected threads (only used by BARRIER_INIT operation).
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_barrier( void     * vaddr,
                  uint32_t   operation,
                  uint32_t   count );
 
-typedef enum
-{
-	BARRIER_INIT,
-	BARRIER_DESTROY,
-	BARRIER_WAIT,
-} 
-barrier_operation_t;
-
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [9] This function implement all operations on a POSIX mutex.
  * The kernel structure representing a barrier is defined in the remote_barrier.h file.
  * The code implementting the operations is defined in the remote_barrier.c file.
- *********************************************************************************************
+ ******************************************************************************************
  * @ vaddr     : mutex virtual address in user space == identifier.
  * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK
  * @ attr      : mutex attributes (non supported yet => must be 0).
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_mutex( void     * vaddr,
                uint32_t   operation,
                uint32_t   count );
 
-typedef enum
-{
-	MUTEX_INIT,
-	MUTEX_DESTROY,
-	MUTEX_LOCK,
-	MUTEX_UNLOCK,
-} 
-mutex_operation_t;
-
-/********************************************************************************************* 
- * [10] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition,
- * and deschedule.
- *********************************************************************************************
- * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
-int sys_thread_sleep();
-
-/********************************************************************************************* 
- * [11] This function unblock the thread identified by its <trdid> from the 
- * THREAD_BLOCKED_GLOBAL condition.
- *********************************************************************************************
- * @ trdid  : target thread identifier.
- * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
-int sys_thread_wakeup();
-
-/********************************************************************************************* 
- * [12] This function open or create a file.
- *********************************************************************************************
+/****************************************************************************************** 
+ * [10] This slot not allocated yet
+ ******************************************************************************************
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
+
+/****************************************************************************************** 
+ * [11] This function rmove an existing mapping defined by the <addr> and <size>
+ * arguments in user space.
+ ******************************************************************************************
+ * @ addr  : base address in user space.
+ * # size  : number of bytes.
+ * @ return 0 if success / return -1 if failure.
+ *****************************************************************************************/
+int sys_munmap( void     * addr,
+                uint32_t   size );
+
+/****************************************************************************************** 
+ * [12] This function open or create an open file descriptor.
+ ******************************************************************************************
  * @ pathname   : pathname (can be relative or absolute).
  * @ flags      : bit vector attributes (see below).
  * @ mode       : access rights.
  * @ return file descriptor index in fd_array if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_open( char    * pathname,
               uint32_t  flags,
               uint32_t  mode );
 
-typedef enum
-{
-    O_RDONLY   = 0x0010000,    /*! open file in read-only mode                              */
-    O_WRONLY   = 0x0020000,    /*! open file in write-only mode                             */
-    O_RDWR     = 0x0030000,    /*! open file in read/write mode                             */
-    O_NONBLOCK = 0x0040000,    /*! do not block if data non available                       */
-    O_APPEND   = 0x0080000,    /*! append on each write                                     */
-    O_CREAT    = 0x0100000,    /*! create file if it does not exist                         */
-    O_TRUNC    = 0x0200000,    /*! file length is forced to 0                               */
-    O_EXCL     = 0x0400000,    /*! error if VFS_O_CREAT and file exist                      */
-    O_SYNC	   = 0x0800000,    /*! synchronize File System on each write                    */
-    O_CLOEXEC  = 0x1000000,    /*! set the close-on-exec flag in file descriptor            */
-    O_DIR      = 0x2000000,    /*! new file descriptor is for a directory                   */
-}
-open_attributes_t;
-
-/********************************************************************************************* 
- * [13] This function creates a new file as specified by the arguments.
- * This function is obsolete, you should use open() with 0_CREATE.
- *********************************************************************************************
- * @ pathname   : pathname (can be relative or absolute).
- * @ mode       : access rights.
- ********************************************************************************************/
-int sys_creat( char     * pathname,
-               uint32_t   mode );
-
-/********************************************************************************************* 
+/****************************************************************************************** 
+ * [13] This function map physical memory (or a file) in the calling thread virtual space.
+ * The <attr> argument is a pointer on a structure for arguments (see shared_syscalls.h).
+ ******************************************************************************************
+ * @ attr       : pointer on attributes structure.
+ * @ return 0 if success / return -1 if failure.
+ *****************************************************************************************/
+int sys_mmap( mmap_attr_t * attr );
+
+/****************************************************************************************** 
  * [14] This function read bytes from an open file identified by its file descriptor.
- * This file can be a regular file or character oriented device.
- *********************************************************************************************
+ * The file can be a regular file or character oriented device.
+ ******************************************************************************************
  * @ file_id  : open file index in fd_array.
  * @ buf      : buffer virtual address in user space.
  * @ count    : number of bytes.
  * @ return number of bytes actually read if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_read( uint32_t   file_id,
               void     * buf,
               uint32_t   count );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [15] This function writes bytes to an open file identified by its file descriptor.
- * This file can be a regular file or character oriented device.
- *********************************************************************************************
+ * The file can be a regular file or character oriented device.
+ ******************************************************************************************
  * @ file_id  : open file index in fd_array.
  * @ buf      : buffer virtual address in user space.
  * @ count    : number of bytes.
  * @ return number of bytes actually written if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_write( uint32_t   file_id,
                void     * buf,
                uint32_t   count );
 
-/********************************************************************************************* 
- * [16] This function epositions the offset of the file descriptor identified by <file_id>,
- * according to the operation type defined by the <whence> and <offset> arguments.
- *********************************************************************************************
+/****************************************************************************************** 
+ * [16] This function repositions the offset of the file descriptor identified by <file_id>,
+ * according to the operation type defined by the <whence> argument.
+ ******************************************************************************************
  * @ file_id  : open file index in fd_array.
- * @ offset   : buffer virtual address in user space.
+ * @ offset   : used to compute new offset value.
  * @ whence   : operation type (see below).
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_lseek( xptr_t    file_id,
                uint32_t  offset,
                uint32_t  whence );
 
-typedef enum
-{
-    SEEK_SET  = 0,     /*! new_offset <= offset                                             */
-    SEEK_CUR  = 1,     /*! new_offset <= current_offset + offset                            */
-    SEEK_END  = 2,     /*! new_iffset <= current_size + offset                              */
-}
-lseek_operation_t;
-
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [17] This function release the memory allocated for the file descriptor identified by 
  * the <file_id> argument, and remove the fd array_entry in all copies of the process 
  * descriptor.
- *********************************************************************************************
+ ******************************************************************************************
   file_id   : file descriptor index in fd_array.
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_close( uint32_t file_id );
 
-/********************************************************************************************* 
- * [18] This function removes a directory entry identified by the <pathname> from its
+/****************************************************************************************** 
+ * [18] This function removes a directory entry identified by the <pathname> from the
  * directory, and decrement the link count of the file referenced by the link.
  * If the link count reduces to zero, and no process has the file open, then all resources
@@ -370,166 +247,159 @@
  * the last link is removed, the link is removed, but the removal of the file is delayed 
  * until all references to it have been closed.
- *********************************************************************************************
- * @ pathname   : pathname (can be relative or absolute).
- * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ ******************************************************************************************
+ * @ pathname   : pathname (can be relative or absolute).
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
 int sys_unlink( char * pathname );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [19] This function creates in the calling thread cluster an unnamed pipe, and two
  * (read and write) file descriptors.
- *********************************************************************************************
+ * TODO not implemented yet...
+ ******************************************************************************************
  * @ file_id[0] : [out] read only file descriptor index.
  * @ file_id[1] : [out] write only file descriptor index.
  * @ return 0 if success / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_pipe( uint32_t file_id[2] );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [20] This function change the current working directory in reference process descriptor.
- *********************************************************************************************
- * @ pathname   : pathname (can be relative or absolute).
- * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ ******************************************************************************************
+ * @ pathname   : pathname (can be relative or absolute).
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
 int sys_chdir( char * pathname );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [21] This function creates a new directory in file system.
- *********************************************************************************************
+ ******************************************************************************************
  * @ pathname   : pathname (can be relative or absolute).
  * @ mode       : access rights (as defined in chmod).
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_mkdir( char    * pathname,
                uint32_t  mode );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [22] This function creates a named FIFO file in the calling thread cluster.
  * The associated read and write file descriptors mut be be  explicitely created
- * using the sy_open() function.
- *********************************************************************************************
+ * using the sys_open() function.
+ ******************************************************************************************
  * @ pathname   : pathname (can be relative or absolute).
  * @ mode       : access rights (as defined in chmod).
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_mkfifo( char     * pathname,
                 uint32_t   mode );
 
-/********************************************************************************************* 
- * [23] This function open a directory, that must exist in the file system.
- *********************************************************************************************
- * @ pathname   : pathname (can be relative or absolute).
- * @ return file descriptor index in fd_array if success / return -1 if failure.
- ********************************************************************************************/
-int sys_opendir( char * pathname );
-
-/********************************************************************************************* 
- * [24] This function returns in the structure pointed by the <dirent> argument various
- * information about an entry of the directory identified by the <file_id> argument.
- *********************************************************************************************
- * @ file_id   : file descriptor index of the searched directory.
- * @ dirent    : pointer on a dirent structure in user space.
- * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
-int sys_readdir( uint32_t              file_id,
-                 struct vfs_dirent_s * dirent );
-
-/********************************************************************************************* 
- * [25] This function close the file descriptor previouly open by the opendir() function.
- *********************************************************************************************
- * @ file_id   : file descriptor index of the searched directory.
- * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
-int sys_closedir( uint32_t file_id );
-
-/********************************************************************************************* 
+/****************************************************************************************** 
+ * [23] This function open a directory, that must exist in the file system, returning 
+ * a DIR pointer on the directory in user space.
+ ******************************************************************************************
+ * @ pathname   : pathname (can be relative or absolute).
+ * @ dirp       : [out] buffer for pointer on user directory (DIR).
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
+int sys_opendir( char * pathname,
+                 DIR ** dirp );
+
+/****************************************************************************************** 
+ * [24] This function returns an user pointer on the dirent structure describing the
+ * next directory entry in the directory identified by the <dirp> argument.
+ ******************************************************************************************
+ * @ dirp     : user pointer identifying the searched directory.
+ * @ dentp    : [out] buffer for pointer on user direntory entry (dirent).
+ * @ return O if success / returns -1 if failure.
+ *****************************************************************************************/
+int sys_readdir( DIR            * dirp,
+                 struct dirent ** dentp );
+
+/****************************************************************************************** 
+ * [25] This function closes the directory identified by the <dirp> argument, and releases
+ * all structures associated with the <dirp> pointer.
+ ******************************************************************************************
+ * @ dirp     : user pointer identifying the directory.
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
+int sys_closedir( DIR * dirp );
+
+/****************************************************************************************** 
  * [26] This function returns the pathname of the current working directory.
- *********************************************************************************************
+ ******************************************************************************************
  * buf     : buffer addres in user space.
  * nbytes  : user buffer size in bytes.
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_getcwd( char     * buf,
                 uint32_t   nbytes );
 
-/********************************************************************************************* 
- * [27] This function returns in a 64 bits user buffer the calling core cycles count.
- * It uses both the hardware register and the core descriptor cycles count tos take
- * into account a possible harware register overflow  in 32 bits architectures.
- *********************************************************************************************
- * cyles    : [out] address of buffer in user space.
- ********************************************************************************************/
-int sys_clock( uint64_t * cycles );
-
-/********************************************************************************************* 
+/****************************************************************************************** 
+ * [27] This slot is not used.
+ *****************************************************************************************/
+
+/****************************************************************************************** 
  * [28] This function forces the calling thread to sleep, for a fixed number of cycles.
- *********************************************************************************************
+ ******************************************************************************************
  * cycles   : number of cycles.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_alarm( uint32_t cycles );
 
-/********************************************************************************************* 
- * [29] This undefined function does nothing.
- *********************************************************************************************
- * @ pathname   : pathname (can be relative or absolute).
- * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+/****************************************************************************************** 
+ * [29] This function removes a directory file whose name is given by <pathname>.
+ * The directory must not have any entries other than `.' and `..'.
+ ******************************************************************************************
+ * @ pathname   : pathname (can be relative or absolute).
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
 int sys_rmdir( char * pathname ); 
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [30] This function implement the operations related to User Thread Local Storage.
  * It is actually implemented as an uint32_t variable in the thread descriptor.
- *********************************************************************************************
+ ******************************************************************************************
  * @ operation  : UTLS operation type as defined below.
  * @ value      : argument value for the UTLS_SET operation.
  * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_utls( uint32_t operation,
               uint32_t value );
 
-typedef enum
-{
-    UTLS_SET       = 1,
-    UTLS_GET       = 2,
-    UTLS_GET_ERRNO = 3,
-}
-utls_operation_t;
-
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [31] This function change the acces rights for the file/dir identified by the
  * pathname argument.
- *********************************************************************************************
+ ******************************************************************************************
  * @ pathname   : pathname (can be relative or absolute).
  * @ rights     : acces rights.
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_chmod( char     * pathname,
                uint32_t   rights );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [32] This function associate a specific signal handler to a given signal type.
  * Tee handlers for the SIGKILL and SIGSTOP signals cannot be redefined.
- ********************************************************************************************* 
+ ****************************************************************************************** 
  * @ sig_id    : index defining signal type (from 1 to 31).
  * @ handler   : pointer on fonction implementing the specific handler.
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_signal( uint32_t   sig_id,
                 void     * handler );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [33] This function returns in the structure <tv>, defined in the time.h file,
  * the current time (in seconds & micro-seconds).
  * It is computed from the calling core descriptor.
  * The timezone is not supported.
- *********************************************************************************************
+ ******************************************************************************************
  * @ tv      : pointer on the timeval structure.
  * @ tz      : pointer on the timezone structure : must be NULL.       
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_timeofday( struct timeval  * tv,
                    struct timezone * tz );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [34] This function implements the "kill" system call.
  * It register the signal defined by the <sig_id> argument in all thread descriptors 
@@ -537,22 +407,22 @@
  * containing threads for the target process.
  * It can be executed by any thread running in any cluster, as this function uses
- * remote access to traverse the list of process copies in the owner cluster,
+ * remote access to traverse the list of process copies stored in the owner cluster,
  * and the RPC_SIGNAL_RISE to signal the remote threads. 
- ********************************************************************************************* 
+ ****************************************************************************************** 
  * @ pid      : target process identifier.
  * @ sig_id   : index defining the signal type (from 1 to 31). 
  * @ return 0 if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_kill( pid_t    pid,
               uint32_t sig_id );
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [35] This function implements the "getpid" system call.
- ********************************************************************************************* 
- * @ returns the PID for the calling thread.
- ********************************************************************************************/
+ ****************************************************************************************** 
+ * @ returns the process PID for the calling thread.
+ *****************************************************************************************/
 int sys_getpid();
 
-/********************************************************************************************* 
+/****************************************************************************************** 
  * [36] This function implement the "fork" system call.
  * The calling process descriptor (parent process), and the associated thread descriptor are
@@ -560,65 +430,130 @@
  * is registered in another target cluster, that is the new process owner. 
  * The child process and the associated main thread will be migrated to the target cluster
- * later, when the child process makes an "exec" or any other system call. 
+ * later, when the child process makes an "exec" or any other system call... TODO [AG]
  * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be
  * stored in the calling thread descriptor by the specific fork_place() system call.
  * If not, the sys_fork() function makes a query to the DQDT to select the target cluster. 
- ********************************************************************************************* 
- * @ returns child process PID if success / returns -1 if failure
- ********************************************************************************************/
+ ****************************************************************************************** 
+ * @ if success, returns child process PID to parent, and return O to child.
+ * @ if failure, returns -1 to parent / no child process is created.
+ *****************************************************************************************/
 int sys_fork();
 
-/********************************************************************************************* 
- * [37] This function implement the "exec" system call.
- * It is executed in the client cluster, but the new process descriptor and main thread
- * must be created in a server cluster, that is generally another cluster. 
- * - if the server_cluster is the client cluster, call directly the process_make_exec()
+/****************************************************************************************** 
+ * [37] This function implement the "exec" system call, that creates a new process 
+ * descriptor.
+ * It is executed in the client cluster, but the new process descriptor and the main
+ * thread are created in a server cluster, that is generally another cluster. 
+ * - if the server_cluster is the client cluster, it calls directly the process_make_exec()
  *   function to create a new process, and launch a new thread in local cluster.
- * - if the target_cluster is remote, call rpc_process_exec_client() to execute the
- *   process_make_exec() on the remote cluster.
+ * - if the target_cluster is remote, it calls the rpc_process_exec_client() to execute
+ *   process_signedmake_exec() on the remote cluster.
  * In both case this function build an exec_info_t structure containing all informations
  * required to build the new process descriptor and the associated thread.
  * Finally, the calling process and thread are deleted.
- ********************************************************************************************* 
- * @ filename : string pointer on .elf filename (virtual pointer in user space)
- * @ argv     : array of strings on process arguments (virtual pointers in user space)
- * @ envp     : array of strings on Renvironment variables (virtual pointers in user space)
+ ****************************************************************************************** 
+ * @ filename : string pointer on .elf filename (pointer in user space)
+ * @ argv     : array of strings on process arguments (pointers in user space)
+ * @ envp     : array of strings on environment variables (pointers in user space)
  * @ returns O if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_exec( char  * filename,
               char ** argv,
               char ** envp );
 
-/********************************************************************************************* 
- * [38] This function  returns in the <stat> structure, defined in the vfs.h file,
- * various informations on the file/directory identified by the <file_id> argument.
- ********************************************************************************************* 
- * @ file_id   : file descriptor index in fd_array.
- * @ stat      : pointer on the stat structure.
+/****************************************************************************************** 
+ * [38] This function  returns in the <stat> structure, defined in the "shared_syscalls.h" 
+ * file, various informations on the file/directory identified by the <pathname> argument.
+ ****************************************************************************************** 
+ * @ pathname  : user pointer on file pathname.
+ * @ stat      : user pointer on the stat structure.
  * @ returns O if success / returns -1 if failure.
- ********************************************************************************************/
-int sys_stat( uint32_t            file_id,
-              struct vfs_stat_s * stat );
-
-/********************************************************************************************* 
- * [39] This function is used to activate / desactivate Rthe trace for a thread 
+ *****************************************************************************************/
+int sys_stat( const char  * pathname,
+              struct stat * stat );
+
+/****************************************************************************************** 
+ * [39] This non-standard function is used to activate / desactivate the trace for a thread 
  * identified by the <trdid> and <pid> arguments.
- * It can be called by any other thread.
- ********************************************************************************************* 
+ * It can be called by any other thread in the same process.
+ ****************************************************************************************** 
  * @ operation  : operation type as defined below.
  * @ pid        : process identifier.
  * @ trdid      : thread identifier.
  * @ returns O if success / returns -1 if failure.
- ********************************************************************************************/
+ *****************************************************************************************/
 int sys_trace( uint32_t operation,
                pid_t    pid, 
                uint32_t trdid );
 
-typedef enum
-{
-    TRACE_ON       = 0,
-    TRACE_OFF      = 1,
-}
-trace_operation_t;
+/****************************************************************************************** 
+ * [40] This function returns the hardware platform parameters.
+ ******************************************************************************************
+ * @ x_size   : [out] number of clusters in a row.
+ * @ y_size   : [out] number of clusters in a column.
+ * @ ncores   : [out] number of cores per cluster.
+ * @ return 0 if success / return -1 if illegal arguments
+ *****************************************************************************************/
+int sys_get_config( uint32_t * x_size,
+                    uint32_t * y_size,
+                    uint32_t * ncores );
+
+/****************************************************************************************** 
+ * [41] This function returns the calling core cluster and local index.
+ ******************************************************************************************
+ * @ cxy      : [out] cluster identifier (fixed format)
+ * @ lid      : [out] core local index in cluster.
+ * @ return 0 if success / return -1 if illegal arguments
+ *****************************************************************************************/
+int sys_get_core( uint32_t * cxy,
+                  uint32_t * lid );
+
+/****************************************************************************************** 
+ * [42] This function returns in a 64 bits user buffer the calling core cycles count.
+ * It uses both the hardware register and the core descriptor cycles count to take
+ * into account a possible harware register overflow  in 32 bits architectures.
+ ******************************************************************************************
+ * cycle    : [out] address of buffer in user space.
+ * @ return 0 if success / return -1 if illegal arguments
+ *****************************************************************************************/
+int sys_get_cycle( uint64_t * cycle );
+
+/****************************************************************************************** 
+ * [43] This debug function displays on the kernel terminal the current state of a
+ * scheduler identified by the <cxy> and <lid> arguments.
+ ******************************************************************************************
+ * cxy      : [in] target cluster identifier.
+ * lid      : [in] target core local index.
+ * @ return 0 if success / return -1 if illegal arguments
+ *****************************************************************************************/
+int sys_get_sched( uint32_t  cxy,
+                   uint32_t  lid );
+
+/****************************************************************************************** 
+ * [44] This debug function requires the kernel to display on the kernel terminal a message
+ * containing the thread / process / core identifiers, and the cause of panic, 
+ * as defined by the <string> argument.
+ ******************************************************************************************
+ * string   : [in] message to be displayed.
+ * @ return always 0.
+ *****************************************************************************************/
+int sys_panic( char * string );
+
+/****************************************************************************************** 
+ * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition,
+ * and deschedule.
+ ******************************************************************************************
+ * @ return 0 if success / returns -1 if failure.
+ *****************************************************************************************/
+int sys_thread_sleep();
+
+/****************************************************************************************** 
+ * [46] This function unblock the thread identified by its <trdid> from the 
+ * THREAD_BLOCKED_GLOBAL condition.
+ ******************************************************************************************
+ * @ trdid  : target thread identifier.
+ * @ return 0 if success / return -1 if failure.
+ *****************************************************************************************/
+int sys_thread_wakeup();
 
 
