Index: trunk/kernel/syscalls/syscalls.h
===================================================================
--- trunk/kernel/syscalls/syscalls.h	(revision 690)
+++ trunk/kernel/syscalls/syscalls.h	(revision 1)
@@ -1,6 +1,7 @@
 /*
- * syscalls.h - Kernel side services for syscall handling.
+ * syscall.h - kernel services definition
  * 
- * Author     Alain Greiner (2016,2017,2018,2019,2020)
+ * Author  Ghassan Almaless (2007,2008,2009,2010,2011,2012)
+ *         Alain Greiner    (2016)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -22,791 +23,123 @@
  */
 
-#ifndef _SYSCALLS_H_
-#define _SYSCALLS_H_
+#ifndef _SYSCALL_H_
+#define _SYSCALL_H_
 
-#include <hal_kernel_types.h>
-#include <shared_syscalls.h>
+/******************************************************************************************
+ * This enum defines the system calls index.
+ * It must be kept consistant with the syscall vector defined in sys_vector.c file.
+ *****************************************************************************************/
+enum
+{
+	SYS_EXIT,          /* 0  */
+	SYS_MMAP,          /* 1  */
+	SYS_CREATE,        /* 2  */
+	SYS_JOIN,          /* 3  */
+	SYS_DETACH,        /* 4  */
+	SYS_YIELD,         /* 5  */
+	SYS_SEMAPHORE,     /* 6  */
+	SYS_COND_VAR,      /* 7  */
+	SYS_BARRIER,       /* 8  */
+	SYS_RWLOCK,        /* 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_DMA_MEMCPY,    /* 29 */
+	SYS_UTLS,          /* 30 */  
+	SYS_SIGRETURN,     /* 31 */
+	SYS_SIGNAL,        /* 32 */
+	SYS_SET_SIGRETURN, /* 33 */
+	SYS_KILL,          /* 34 */
+	SYS_GETPID,        /* 35 */
+	SYS_FORK,          /* 36 */
+	SYS_EXEC,          /* 37 */
+	SYS_GETATTR,       /* 38 */     
+	SYS_PS,            /* 39 */
+	SYS_MADVISE,       /* 40 */   
+	SYS_PAGEINFO,      /* 41 */
+	SYS_STAT,          /* 42 */
+	SYS_MIGRATE,       /* 43 */
+	SYS_SBRK,          /* 44 */
+	SYS_RMDIR,         /* 45 */
+	SYS_FTIME,         /* 46 */
+	SYS_CHMOD,         /* 47 */
+	SYS_FSYNC,         /* 48 */
+	SYS_GET_TOD,       /* 49 */
+	SYS_TIMES,         /* 50 */
+	SYSCALLS_NR,
+};
 
-/**   Forward declarations  *****/
+/********************************************************************************************/
+/********************   Process related system calls  ***************************************/ 
+/********************************************************************************************/
 
-struct thread_s;                  // defined in thread.h
-struct pthread_attr_s;            // defined in thread.h
-struct vfs_stat_s;                // defined in vfs.h
-struct vfs_dirent_s;              // defined in vfs.h
-struct mmap_attr_s;               // defined in vmm.h
+/********************************************************************************************* 
+ * This function TODO
+ ********************************************************************************************/
+int sys_getpid();
+
+/********************************************************************************************* 
+ * This function implement the "fork" system call.
+ * The calling process descriptor (parent process), and the associated thread descriptor are
+ * replicated in the same cluster as the calling thread, but the new process (child process)
+ * is registered in another target cluster, that will become the 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. 
+ * 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
+ ********************************************************************************************/
+int sys_fork();
+
+/********************************************************************************************* 
+ * 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, using a RPC.
+ * - If the server_cluster is the client cluster, call directly make_exec() in local
+ *   mode, to change the process image and launch a new thread in local cluster.
+ *   finally, the old thread is deleted.
+ * - If the target_cluster is remote, call rpc_process_exec_client() to execute the
+ *   make_exec() in remote mode on the remote cluster, to create a new process
+ *   descriptor and a new thread on remote cluster. Finally, both the local
+ *   process descriptor and the local thread descriptor are deleted.
+ * 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, including
+ * the mode (local/remote).
+ * @ 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)
+ * @ returns O if success / returns non-zero if error.
+ ********************************************************************************************/
+int sys_exec( char  * filename,
+              char ** argv,
+              char ** envp );
 
 
-/****************************************************************************************** 
- * This function forces the calling thread to sleep, for a fixed number of seconds.
- ******************************************************************************************
- * @ seconds   : number of seconds.
- *****************************************************************************************/
-int sys_alarm( uint32_t seconds );
-
-/****************************************************************************************** 
- * 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 address in user space == identifier.
- * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT.
- * @ count     : number of expected threads (only used by BARRIER_INIT).
- * @ attr      : barrier attributes address in user space (only used by BARRIER_INIT).
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_barrier( intptr_t   vaddr,
-                 uint32_t   operation,
-                 uint32_t   count,
-                 intptr_t   attr );
-
-/****************************************************************************************** 
- * 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.
- *****************************************************************************************/
-int sys_chdir( char * pathname );
-
-/****************************************************************************************** 
- * This function change the acces rights for the file/directory inode identified by the
- * <pathname> argument, as specified by the <mode> argument.
- ******************************************************************************************
- * @ pathname : pathname (can be relative or absolute).
- * @ mode     : acces rights.
- * @ return 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_chmod( char       * pathname,
-               uint32_t     mode );
-
-/****************************************************************************************** 
- * 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.
- * @ returns 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_close( uint32_t file_id );
-
-/****************************************************************************************** 
- * This function closes the directory identified by the <dirp> argument, and releases
- * all structures associated with the <dirp> pointer.
- ******************************************************************************************
- * @ dirp     : [in] user pointer on dirent array identifying the open directory.
- * @ return 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_closedir( DIR * dirp );
-
-/****************************************************************************************** 
- * This function implement all operations on a POSIX condition variable.
- * The kernel structure representing a condvar is defined in the remote_condvar.h file,
- * The code implementing the operations is defined in the remote_condvar.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 );
-
-/****************************************************************************************** 
- * This debug function displays on the kernel terminal TXT0 an user defined string,
- * or the current state of a kernel structure, identified by the <type> argument.
- * The <arg0>, <arg1>, and <arg2> arguments depends on the structure type.
- ******************************************************************************************
- * type      : [in] type of display 
- * arg0      : [in] type dependant argument.
- * arg1      : [in] type dependant argument.
- * arg2      : [in] type dependant argument.
- * @ return 0 if success / return -1 if illegal arguments
- *****************************************************************************************/
-int sys_display( reg_t  type,
-                 reg_t  arg0,
-                 reg_t  arg1,
-                 reg_t  arg2 );
-
-/****************************************************************************************** 
- * This function implement the "exec" system call on the kernel side.
- * It creates, in the same cluster as the calling thread, a new process descriptor,
- * and a new associated main thread descriptor, executing a new memory image defined 
- * by the <filename> argument. This new process inherit from the old process the PID
- * and the PPID, as well as all open files registered in fd_array, including the TXT. 
- * The old process descriptor, and all its threads are blocked, and marked for deletion.
- * Therefore the exec syscall does not return to the calling thread in case of success.
- * This function must be called by the main thread (thread 0 in owner cluster), of the
- * calling process, to destroy all process copies, and all other threads in all clusters. 
- ****************************************************************************************** 
- * Implementation note:
- * It fill the calling process "exec_info" structure containing all informations required
- * to initialize the new process descriptor and the associated main thread. This includes:
- * - pathname to the new process .elf> file in VFS. 
- * - array of string pointers defining the process arguments, and the associated strings.
- * - array of string pointers defining environment variables, and the associated strings.
- * To do this, it calls the process_exec_get_strings function, that copies all relevant
- * information from user space to kernel space, using functions defined in <hal_uspace.h>.
- * Then it calls the process_make_exec() function that returns only in case of failure.
- *
- * TODO : the <envs> argument is not supported yet and must be NULL.
- ****************************************************************************************** 
- * @ filename      : string pointer on .elf filename (pointer in user space)
- * @ user_args     : array of strings on process arguments (pointers in user space)
- * @ user_envs     : array of strings on environment variables (pointers in user space)
- * @ does not return if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_exec( char  * filename,
-              char ** user_args,
-              char ** user_envs );
-
-/****************************************************************************************** 
- * This function implements the "exit" system call terminating a POSIX process.
- * It can be called by any thread running in any cluster.
- * It uses both remote accesses to access the owner process descriptor, and the
- * RPC_PROCESS_SIGACTION to delete remote process copies and thread descriptors.
- * In the present implementation, this function implements actually the _exit():
- * - it does not flush open output streams.
- * - it does not close open streams.
- ******************************************************************************************
- * @ status   : terminaison status returned to parent process.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_exit( uint32_t status );
-
-/****************************************************************************************** 
- * This generic function implements the non-standard FBF related syscalls.
- * The operation types mnemonics are defined in the <shared_fbf> file.
- * The supported operations are defined in the <almosmkh.h> & <almosmkh.c> files.
- * This function ckecks the syscall arguments, and call the relevant kernel function.
- ******************************************************************************************
- * @ arg0       : operation type (mnemonics defined in shared_fbf.h)
- * @ arg1       : depends on operation type
- * @ arg2       : depends on operation type
- * @ arg3       : depends on operation type
- * @ return 0 if success / return -1 if illegal argument.
- *****************************************************************************************/
-int sys_fbf( reg_t   arg0,
-             reg_t   arg1,
-             reg_t   arg2,
-             reg_t   arg3 );
-
-/****************************************************************************************** 
- * This function gives the process identified by the <pid> argument
- * the exclusive ownership of its TXT_TX terminal (put it in foreground).
- ******************************************************************************************
- * @ pid    : process identifier.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_fg( pid_t   pid );
-
-/****************************************************************************************** 
- * This function implements the "fsync" system call.
- * It forces all modified pages of the file mapper identified by the <fd> argument
- * to be copied to the IOC device.
- * It can be called by any thread running in any cluster.
- * TODO not implemented yet.
- ******************************************************************************************
- * @ file_id   : file descriptor index in fd_array.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_fsync( uint32_t file_id );
-
-/****************************************************************************************** 
- * This function implement the "fork" system call on the kernel side.
- * The calling process descriptor (parent process), and the associated thread descriptor
- * are replicated in a - likely - remote cluster, that becomes the child process owner. 
- * The child process get a new PID, and is linked to the parent PID. The child process 
- * inherit from its parent the memory image, and all open files (including the TXT).
- * The child process becomes the TXT terminal owner.
- * 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 kernel function makes a query to the DQDT to select the target cluster. 
- ****************************************************************************************** 
- * @ 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( void );
-
-/****************************************************************************************** 
- * This generic function implements all the non standard syscalls of type "get_xxx()",
- * defined in the <almosmkh.h> and <almosmkh.c> files.
- * The operation types mnemonics are defined in the <shared_almos.h> file.
- * This function ckecks the syscall arguments, and call the relevant kernel function.
- ******************************************************************************************
- * @ arg0       : operation type (mnemonics defined in shared_get.h)
- * @ arg1       : depends on operation type
- * @ arg2       : depends on operation type
- * @ arg3       : depends on operation type
- * @ return 0 if success / return -1 if illegal argument.
- *****************************************************************************************/
-int sys_get( reg_t   arg0,
-             reg_t   arg1,
-             reg_t   arg2,
-             reg_t   arg3 );
-
-/****************************************************************************************** 
- * This function implements the non-standard "get_best_core" syscall.
- * It selects, in a macro-cluster specified by the <base_cxy> and <level> arguments,
- * the core that has the lowest load.
- * When an active core has been found in the target macro-cluster, it writes into the 
- * <cxy> and <lid> buffers the cluster identifier and the core local index, and return 0.
- * It returns -1 in case of illegal arguments (level / cxy / lid).
- * It returns +1 if there is no active core in specified macro-cluster.
- ******************************************************************************************
- * @ base_cxy : [in]  any cluster identifier in macro-cluster.
- * @ level    : [in]  macro-cluster level in [1,2,3,4,5].
- * @ cxy      : [out] selected core cluster identifier.
- * @ lid      : [out] selected core local index in cluster.
- * @ return 0 if success / -1 if illegal arguments / +1 if no core in macro-clusters.
- *****************************************************************************************/
-int sys_get_best_core( uint32_t   base_cxy,
-                       uint32_t   level,
-                       uint32_t * cxy,
-                       uint32_t * lid );
-
-/****************************************************************************************** 
- * This function implement the non-standard get_config() syscall.
- * It returns the global hardware platform parameters in the <config> shared structure,
- * that is defined in the shared_almos.h file.
- ******************************************************************************************
- * @ config   : [out] pointer on the hard_config_t structure in user space.
- * @ return 0 if success / return -1 if illegal argument
- *****************************************************************************************/
-int sys_get_config( struct hard_config_s * config );
-
-/****************************************************************************************** 
- * This function implements the non-standard get_core_id() syscall.
- * It returns in <cxy> and <lid> 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_id( uint32_t * cxy,
-                     uint32_t * lid );
-
-/****************************************************************************************** 
- * This function implements the non-standard get_cycle() syscall.
- * It 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 );
-
-/****************************************************************************************** 
- * 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 );
-
-/****************************************************************************************** 
- * This function implements the non-standard "get_nb_cores" syscall.
- * It writes in the <ncores> buffer the number of cores in the target cluster <cxy>.
- ******************************************************************************************
- * @ cxy      : [in]  target cluster identifier.
- * @ ncores   : [out] number of cores / 0 if cluster cxy undefined in architecture.
- * @ return 0 if success / return -1 if illegal "ncores" arguments.
- *****************************************************************************************/
-int sys_get_nb_cores( uint32_t   cxy,
-                      uint32_t * ncores );
-
-/****************************************************************************************** 
- * This function implements the "getpid" system call on the kernel side.
- ****************************************************************************************** 
- * @ returns the process PID for the calling thread.
- *****************************************************************************************/
-int sys_getpid( void );
-
-/****************************************************************************************** 
- * This function implements the non-standard "get_thread_info" syscall.
- * It copies in the user structure defined by the <info> argument the values registered
- * in the calling thread "thread_info_t" kernel structure.
- ******************************************************************************************
- * @ info      : [out] pointer on thread_info_t structure in user space.
- * @ return 0 if success / return -1 if illegal argument.
- *****************************************************************************************/
-int sys_get_thread_info( thread_info_t * info );
-
-/****************************************************************************************** 
- * This function tests whether a given file descriptor dentified by the <file_id>
- * argument is an open file descriptor referring to a terminal.
- ******************************************************************************************
- * @ file_id   : file descriptor index
- * @ return 1 if it is a TXT device / return 0 if it is not a TXT device.
- *****************************************************************************************/
-int sys_isatty( uint32_t file_id );
-
-/****************************************************************************************** 
- * This function returns a non-zero value in the <is_fg> buffer when the process
- * identified by the <pid> argument is the current TXT owner.
- ******************************************************************************************
- * @ pid      : process identifier.
- * @ is_fg    : pointer on buffer.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_is_fg( pid_t      pid,
-               uint32_t * is_fg );
-
-/****************************************************************************************** 
- * This function implements the "kill" system call on the kernel side.
- * It register the signal defined by the <sig_id> argument in all thread descriptors 
- * of a target process identified by the <pid> argument. This is done in all clusters
- * 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 stored in the owner cluster,
- * and the RPC_SIGNAL_RISE to signal the remote threads. 
- * This function does nothing for (sig_id == 0). This can be used to check process pid.
- * TODO : This first implementation supports only SIGKILL / SIGSTOP / SIGCONT values.
- ****************************************************************************************** 
- * @ pid      : target process identifier.
- * @ sig_id   : index defining the signal type. 
- * @ return 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_kill( pid_t    pid,
-              uint32_t sig_id );
-
-/****************************************************************************************** 
- * This function repositions the offset of the file descriptor identified by the
- * <file_id> argument, according to the operation type defined by the <whence> argument.
- ******************************************************************************************
- * @ file_id  : open file index in fd_array.
- * @ offset   : used to compute new offset value.
- * @ whence   : operation type (see below).
- * @ returns new offset value if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_lseek( xptr_t    file_id,
-               uint32_t  offset,
-               uint32_t  whence );
-
-/****************************************************************************************** 
- * This function implements the "mkdir" system call, creating a new directory in
- * the file system, as defined by the <pathname> argument, with the access permission
- * defined by the <rights> argument. All nodes but the last in the pathname must exist.
- * It can be called by any thread running in any cluster.
- ******************************************************************************************
- * @ pathname  : pathname defining the new directory location in file system.
- * @ rights    : access rights (non used yet).
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_mkdir( char     * pathname,
-               uint32_t   rights );
-
-/****************************************************************************************** 
- * This function creates a new inode/dentry couple of type FIFO, and registers it in 
- * the Inode-Tree, as specified by the <pathname> and <mode> arguments. 
- * The associated file descriptors are created later, 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 );
-
-/****************************************************************************************** 
- * 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_mman.h).
- * The user defined virtual address (MAP_FIXED flag) is not supported.
- * TODO : the access rights checking is not implemented yet [AG]
- * TODO : the Copy on Write for MAP_PRIVATE is not implemented yet [AG]
- ******************************************************************************************
- * @ attr       : pointer on attributes structure.
- * @ returns 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_mmap( mmap_attr_t * attr );
-
-/****************************************************************************************** 
- * This function remove an existing mapping defined by the <addr> and <size>
- * arguments in user space. This can modify the number of vsegs:
- * (a) if the region is not entirely mapped in one existing vseg, it's an error.
- * (b) if the region has same base and size as an existing vseg, the vseg is removed.
- * (c) if the removed region cut the exiting vseg in two parts, it is resized.
- * (d) if the removed region cut the vseg in three parts, it is modified, and a new
- *     vseg is created with same type.
- * All existing VSL copies are updated.
-******************************************************************************************
- * @ 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 );
-
-/****************************************************************************************** 
- * 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 );
-
-/****************************************************************************************** 
- * This function creates a new file descriptor for an existing inode.
- * It creates a new inode if required by the flags.
- ******************************************************************************************
- * @ pathname   : pathname in the inode tree (can be relative or absolute).
- * @ flags      : bit vector attributes (see in shared_fcntl.h file)
- * @ 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 );
-
-/****************************************************************************************** 
- * This function creates an user level directory descriptor (including the associated
- * array of user level dirents), and intialise it from the kernel directory mapper, that
- * contains all entries in this directory). The directory is identified by the <pathname>
- * argument. If the corresponding inode is missing in the Inode Tree, the inode is created,
- * but the directory must exist in the file system. 
- * It returns a DIR pointer <dirp> on the dirent array in user space.
- * The calling process fd_array is NOT modified.
- ******************************************************************************************
- * @ pathname   : [in]  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 );
-
-/****************************************************************************************** 
- * This function creates in the calling thread cluster an unnamed pipe, implemented
- * as a remote_buffer_t, creates two (read and write) file descriptors, and links these
- * two file descriptors to the pipe.
- * TODO  : the dynamic memory allocation in case of buffer full is not implemented.
- * FIXME : wich syscall release the kernel memory allocated by this syscall ?
- ******************************************************************************************
- * @ fd   : pointeur on a 2 slots array of fdid : fd[0] read / fd[1] write.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_pipe( fdid_t * fd );
-
-/****************************************************************************************** 
- * This function implements the non-standard place_fork() syscall.
- * It can be used to specify the target cluster <cxy> for a new process created
- * by a subsequent fork() syscall.
- * WARNING: it must be called before each fork() syscall, as the placement specification
- *          is reset by the fork syscall. 
- ******************************************************************************************
- * @ cxy    : cluster identifier.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_place_fork( uint32_t cxy );
-
-/****************************************************************************************** 
- * This function read bytes from an open file identified by its file descriptor.
- * The file can be a regular file or character oriented device.
- * IRQs are enabled during this system call.
- ******************************************************************************************
- * @ file_id  : open file index in fd_array.
- * @ buf      : buffer virtual address in user space.
- * @ count    : number of bytes.
- * @ returns number of bytes actually read if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_read( uint32_t   file_id,
-              void     * buf,
-              uint32_t   count );
-
-/****************************************************************************************** 
- * This function returns an user pointer on the dirent structure describing the
- * next directory entry in the directory identified by the <dirp> argument.
- ******************************************************************************************
- * @ dirp     : [in]  user pointer on dirent array identifying the open directory.
- * @ buffer   : [out] pointer on user buffer for a pointer on dirent in user space.
- * @ return O if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_readdir( DIR            * dirp,
-                 struct dirent ** buffer );
-
-/****************************************************************************************** 
- * This function causes the file named <old> to be renamed as <new>.
- * If new exists, it is first removed.  Both old and new must be of the same type (both
- * must be either directories or non-directories) and must reside on the same file system.
- * It guarantees that an instance of <new> will always exist, even if the system should 
- * crash in the middle of the operation.
- ******************************************************************************************
- * @ old      : old file name.
- * @ new      : new file name.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_rename( char *old,
-                char *new );
-
-/****************************************************************************************** 
- * 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 );
-
-/****************************************************************************************** 
- * 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.
- * @ init_value    : initial semaphore value.
- * @ current_value : pointer on buffer for current semaphore value.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_sem( void       * vaddr,
-             uint32_t     operation,
-             uint32_t     init_value,
-             uint32_t   * current_value );
-
-/****************************************************************************************** 
- * This function associate a specific signal handler to a given signal type.
- * The 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 );
-
-/****************************************************************************************** 
- * This generic function implements all socket related syscalls.
- * The operation types mnemonics are defined in the <shared_socket> file.
- * The supported operations are defined in the <socket.h> & <socket.c> files.
- * This function ckecks the syscall arguments, and call the relevant kernel function.
- ******************************************************************************************
- * @ arg0       : operation type (mnemonics defined in shared_socket.h)
- * @ arg1       : depends on operation type
- * @ arg2       : depends on operation type
- * @ arg3       : depends on operation type
- * @ return 0 if success / return -1 if illegal argument.
- *****************************************************************************************/
-int sys_socket( reg_t   arg0,
-                reg_t   arg1,
-                reg_t   arg2,
-                reg_t   arg3 );
-
-/****************************************************************************************** 
- * 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.
- * TODO only the <st_ino>, <st_mode>,<st_uid>,<st_gid>,<st_size> are set.
- ****************************************************************************************** 
- * @ pathname  : user pointer on file pathname.
- * @ stat      : user pointer on the stat structure.
- * @ returns O if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_stat( char        * pathname,
-              struct stat * stat );
-
-/****************************************************************************************** 
- * This function implements the "sync" system call.
- * It forces all modified pages in all kernel mappers to be copied to the IOC device.
- * It can be called by any thread running in any cluster.
- * TODO not implemented yet.
- ******************************************************************************************
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_sync( void );
-
-/****************************************************************************************** 
- * 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 );
-
-/****************************************************************************************** 
- * This function requests a target thread identified by its <trdid> argument
- * to be cancelled. It calls the thread_kill() function to block the target thread
- * on the THREAD_BLOCKED_GLOBAL condition, and to set the THREAD_FLAG_REQ_DELETE.
- * The thread will be detached from its process, and the memory allocated to the thread
- * descriptor will be released by the scheduler at the next scheduling point.
- ******************************************************************************************
- * @ trdid   : thread identifier.
- * @ return 0 if success / return -1 if illegal argument.
- *****************************************************************************************/
-int sys_thread_cancel( trdid_t  trdid );
-
-/****************************************************************************************** 
- * 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.
- ******************************************************************************************
- * @ trdid_ptr   : [out] pointer on buffer for created thread trdid.
- * @ user_attr   : [in]  pointer on thread attributes structure.
- * @ start_func  : [in]  pointer on start function.
- * @ start_args  : [in]  pointer on start function arguments.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_thread_create( trdid_t               * trdid_ptr,
-                       struct pthread_attr_s * user_attr,
-                       void                  * start_func,
-                       void                  * start_args );
-
-/****************************************************************************************** 
- * This function detach a joinable thread.
- ******************************************************************************************
- * @ trdid   : thread identifier.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_thread_detach( trdid_t  trdid );
-
-/****************************************************************************************** 
- * This function terminates the execution of the calling user thread, and makes 
- * the <exit_status> pointer available to any successful pthread_join() with the 
- * terminating thread.
- * - If the calling thread is the main thread, it calls the sys_exit() function to delete
- *   completely the user process.  
- * - if the calling thread is not the main thread, it registers the <exit_status> pointer
- *   in the thread descriptor, and calls the thread_delete() function, that will set the
- *   THREAD_SIG_EXIT signal, set the THREAD_BLOCKED_GLOBAL bit in thread descriptor, and 
- *   deschedules. All memory allocated to the thread is released later by the scheduler.
- *   If the thread is in "detached" mode, the thread_delete() function implements
- *   the synchonisation with the joining thread.
- ******************************************************************************************
- * @ exit_status  : [out] pointer to be returned to joining thread if thread is attached.
- * @ return 0 if success / return -1 if all locks not released or illegal argument.
- *****************************************************************************************/
-int sys_thread_exit( void * exit_status );
-
-/****************************************************************************************** 
- * This blocking function suspend execution of the calling thread until completion 
- * of another target thread identified by the <trdid> argument.
- * The target thread must be joinable (running in ATTACHED mode), and must be different
- * from the calling thread.
- * 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 );
-
-/****************************************************************************************** 
- * This function blocks the calling thread on the THREAD_BLOCKED_SLEEP condition,
- * and deschedules. When the <seconds> argument is non-zero, this argument defines
- * the sleeping time. When it is zero, the sleeping time is unbounded, and the thread
- * must be unblocked by the sys_thread_wakeup() function
- ******************************************************************************************
- * @ seconds : number of seconds of sleep / No alarm is activated when 0. 
- * @ return 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_thread_sleep( uint32_t seconds );
-
-/****************************************************************************************** 
- * This function unblock the thread identified by its <trdid> from the 
- * THREAD_BLOCKED_SLEEP condition, and cancel the registered alarm if required.
- ******************************************************************************************
- * @ trdid  : target thread identifier.
- * @ return 0 if success / return -1 if failure.
- *****************************************************************************************/
-int sys_thread_wakeup( trdid_t trdid );
-
-/****************************************************************************************** 
- * This function calls the scheduler for the core running the calling thread.
- ******************************************************************************************
- * @ return always 0.
- *****************************************************************************************/
-int sys_thread_yield( void );
-
-/****************************************************************************************** 
- * This debug function is used to activate / desactivate the context switches trace
- * for a core identified by the <cxy> and <lid> arguments.
- * It can be called by any other thread in the same process.
- ****************************************************************************************** 
- * @ active     : activate trace if true / desactivate trace if false.
- * @ cxy        : cluster identifier.
- * @ lid        : core local index.
- * @ returns O if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_trace( bool_t   active,
-               cxy_t    cxy, 
-               lid_t    lid );
-
-/****************************************************************************************** 
- * 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 );
-
-/****************************************************************************************** 
- * 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
- * associated with the file are reclaimed.  If one or more process have the file open when
- * 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).
- * @ returns 0 if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_unlink( char * pathname );
-
-/****************************************************************************************** 
- * This blocking function waits a change of a child process state, that can be:
- * - a termination of child following a process_make_exit().
- * - a termination of child following a process_make_kill().
- * - a blocking of child following a SIGSTOP signal.
- * In case of a multi-thread process, this function must be called by the main thread
- * runningin the reference cluster.
- * When a change has been observed, it returns the PID of the child process, and stores
- * in the <status> argument relevant information on the child state change.
- * The following macros can be used to extract information from status:
- * - WIFEXITED(status)   : is true if the child process terminated with an exit().
- * - WIFSIGNALED(status) : is true if the child process killed by a signal.
- * - WIFSTOPPED(status)  : is true if the child process is stopped by a signal.
- * - WEXITSTATUS(status) : returns the low-order 8 bits of the exit() argument.
- * If a parent process terminates without waiting for all child processes to terminate,
- * the remaining child processes are attached to the init process.
- * WARNING: negative values for the <pid> argument are not supported.
- ******************************************************************************************
- * @ searched_pid : searched child process identifier.
- * @ status       : [out] child termination status.
- * @ return child PID if success / return -1 if searched PID not found.
- *****************************************************************************************/
-int sys_wait( uint32_t * status );
-
-/****************************************************************************************** 
- * This function writes bytes to an open file identified by its file descriptor.
- * The file can be a regular file or character oriented device. For a regular file,
- * the target inode "size" field is updated if (offset + count) is larger than the
- * current "size" value. The size value registered in the mappers of the parent(s)
- * directory are not modified and will be asynchronously updated when the file is closed.
- * IRQs are enabled during this system call.
- ******************************************************************************************
- * @ file_id  : open file index in fd_array.
- * @ buf      : buffer virtual address in user space.
- * @ count    : number of bytes.
- * @ returns number of bytes actually written if success / returns -1 if failure.
- *****************************************************************************************/
-int sys_write( uint32_t   file_id,
-               void     * buf,
-               uint32_t   count );
+/********************************************************************************************* 
+ * This function TODO
+ ********************************************************************************************/
+int sys_ps( uint32_t cmd, 
+            pid_t    pid, 
+            uint32_t tid );
 
 
-#endif  // _SYSCALLS_H_
+
+#endif
