source: trunk/kernel/syscalls/syscalls.h @ 577

Last change on this file since 577 was 566, checked in by alain, 6 years ago

Complete restructuration of kernel locks.

File size: 37.9 KB
RevLine 
[1]1/*
[407]2 * syscalls.h - Kernel side services for syscall handling.
[1]3 *
[457]4 * Author     Alain Greiner (2016,2017,2018)
[1]5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[16]24#ifndef _SYSCALLS_H_
25#define _SYSCALLS_H_
[1]26
[457]27#include <hal_kernel_types.h>
[407]28#include <shared_syscalls.h>
[23]29
[407]30/**   Forward declarations  *****/
[23]31
32struct thread_s;                  // defined in thread.h
33struct pthread_attr_s;            // defined in thread.h
34struct vfs_stat_s;                // defined in vfs.h
35struct vfs_dirent_s;              // defined in vfs.h
36struct mmap_attr_s;               // defined in vmm.h
37
[407]38/******************************************************************************************
39 * [0] This function terminates the execution of the calling user thread,
[23]40 * and makes the exit_value pointer available to any successful pthread_join() with the
41 * terminating thread.
[409]42 * It actually set the THREAD_SIG_EXIT signal, set the THREAD_BLOCKED_GLOBAL bit in the
43 * thread descriptor and deschedule.
44 * The thread will be detached from its process, and the memory allocated to the thread
45 * descriptor will be released later by the scheduler.
[407]46 ******************************************************************************************
[409]47 * @ exit_vallue  : pointer to be returned to joining thread if thread is attached.
48 * @ return 0 if success / return -1 if all locks not released or illegal argument.
[407]49 *****************************************************************************************/
[23]50int sys_thread_exit( void * exit_value );
[16]51
[407]52/******************************************************************************************
53 * [1] This function calls the scheduler for the core running the calling thread.
54 ******************************************************************************************
55 * @ x_size   : [out] number of clusters in a row.
56 * @ y_size   : [out] number of clusters in a column.
57 * @ ncores   : [out] number of cores per cluster.
58 * @ return always 0.
59 *****************************************************************************************/
[479]60int sys_thread_yield( void );
[16]61
[407]62/******************************************************************************************
[23]63 * [2] This function creates a new user thread. The <user_attr> argument is a pointer
64 * on astructure containing the thread attributes, defined in thread.h file.
[407]65 ******************************************************************************************
[566]66 * @ trdid_ptr   : [out] pointer on buffer for created thread trdid.
[23]67 * @ user_attr   : [in]  pointer on thread attributes structure.
68 * @ start_func  : [in]  pointer on start function.
69 * @ start_args  : [in]  pointer on start function arguments.
70 * @ return 0 if success / return -1 if failure.
[407]71 *****************************************************************************************/
[566]72int sys_thread_create( trdid_t               * trdid_ptr,
73                       struct pthread_attr_s * user_attr,
74                       void                  * start_func,
75                       void                  * start_args );
[16]76
[407]77/******************************************************************************************
[23]78 * [3] This blocking function suspend execution of the calling thread until completion
79 * of another target thread identified by the <trdid> argument.
[421]80 * The target thread must be joinable (running in ATTACHED mode), and must be different
81 * from the calling thread.
[23]82 * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the
83 * target thread is stored in the location referenced by exit_value.
[407]84 ******************************************************************************************
[23]85 * @ trdid     : [in]  target thread identifier.
86 * @ thread    : [out] buffer for exit_value returned by target thread.
87 * @ return 0 if success / return -1 if failure.
[407]88 *****************************************************************************************/
[23]89int sys_thread_join( trdid_t    trdid,
90                     void    ** exit_value );
[16]91
[407]92/******************************************************************************************
[23]93 * [4] This function detach a joinable thread.
[407]94 ******************************************************************************************
[409]95 * @ trdid   : thread identifier.
[23]96 * @ return 0 if success / return -1 if failure.
[407]97 *****************************************************************************************/
[23]98int sys_thread_detach( trdid_t  trdid );
[16]99
[407]100/******************************************************************************************
[409]101 * [5] This function requests a target thread identified by its <trdid> argument
[436]102 * to be cancelled. It calls the thread_kill() function to block the target thread
103 * on the THREAD_BLOCKED_GLOBAL condition, and to set the THREAD_FLAG_REQ_DELETE.
[409]104 * The thread will be detached from its process, and the memory allocated to the thread
[436]105 * descriptor will be released by the scheduler at the next scheduling point.
[409]106 ******************************************************************************************
107 * @ trdid   : thread identifier.
108 * @ return 0 if success / return -1 if illegal argument.
[407]109 *****************************************************************************************/
[409]110int sys_thread_cancel( trdid_t  trdid );
[16]111
[407]112/******************************************************************************************
[23]113 * [6] This function implement all operations on a POSIX unnamed semaphore,
114 * that can be shared by threads running in different clusters.
115 * The kernel structure representing a remote semaphore is in the remote_sem.h file,
116 * and the code implementing the operations is in the remore_sem.c file.
[407]117 ******************************************************************************************
[457]118 * @ vaddr         : semaphore virtual address in user space == identifier.
119 * @ operation     : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT.
120 * @ init_value    : initial semaphore value.
121 * @ current_value : pointer on buffer for current semaphore value.
[23]122 * @ return 0 if success / return -1 if failure.
[407]123 *****************************************************************************************/
[23]124int sys_sem( void       * vaddr,
125             uint32_t     operation,
[457]126             uint32_t     init_value,
127             uint32_t   * current_value );
[16]128
[407]129/******************************************************************************************
[23]130 * [7] This function implement all operations on a POSIX condition variable.
[566]131 * The kernel structure representing a condvar is defined in the remote_condvar.h file,
132 * The code implementing the operations is defined in the remote_condvar.c file.
[407]133 ******************************************************************************************
[23]134 * @ vaddr     : condvar virtual address in user space == identifier.
135 * @ operation : operation type (see below).
136 * @ attr      : mutex virtual address in user space == identifier.
137 * @ return 0 if success / return -1 if failure.
[407]138 *****************************************************************************************/
[23]139int sys_condvar( void     * condvar,
140                 uint32_t   operation,
141                 void     * mutex );
[16]142
[407]143/******************************************************************************************
[23]144 * [8] This function implement all operations on a POSIX barrier.
145 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
146 * The code implementting the operations is defined in the remote_barrier.c file.
[407]147 ******************************************************************************************
[23]148 * @ vaddr     : barrier virtual address in user space == identifier.
149 * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT.
150 * @ count     : number of expected threads (only used by BARRIER_INIT operation).
151 * @ return 0 if success / return -1 if failure.
[407]152 *****************************************************************************************/
[23]153int sys_barrier( void     * vaddr,
154                 uint32_t   operation,
155                 uint32_t   count );
[16]156
[407]157/******************************************************************************************
[23]158 * [9] This function implement all operations on a POSIX mutex.
159 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
160 * The code implementting the operations is defined in the remote_barrier.c file.
[407]161 ******************************************************************************************
[23]162 * @ vaddr     : mutex virtual address in user space == identifier.
163 * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK
164 * @ attr      : mutex attributes (non supported yet => must be 0).
165 * @ return 0 if success / return -1 if failure.
[407]166 *****************************************************************************************/
[23]167int sys_mutex( void     * vaddr,
168               uint32_t   operation,
169               uint32_t   count );
[16]170
[407]171/******************************************************************************************
[408]172 * [10] This function implement the exit system call terminating a POSIX process.
[440]173 * It can be called by any thread running in any cluster.
[443]174 * It uses both remote accesses to access the owner process descriptor, and the
175 * RPC_PROCESS_SIGACTION to delete remote process and thread descriptors.
[433]176 * In the present implementation, this function implements actually the _exit():
[440]177 * - it does not flush open output streams.
[433]178 * - it does not close open streams.
[407]179 ******************************************************************************************
[408]180 * @ status   : terminaison status (not used in present implementation).
[407]181 *****************************************************************************************/
[409]182int sys_exit( uint32_t status );
[16]183
[407]184/******************************************************************************************
[408]185 * [11] This function remove an existing mapping defined by the <addr> and <size>
[407]186 * arguments in user space.
187 ******************************************************************************************
188 * @ addr  : base address in user space.
189 * # size  : number of bytes.
[23]190 * @ return 0 if success / return -1 if failure.
[407]191 *****************************************************************************************/
192int sys_munmap( void     * addr,
193                uint32_t   size );
[16]194
[407]195/******************************************************************************************
196 * [12] This function open or create an open file descriptor.
197 ******************************************************************************************
[23]198 * @ pathname   : pathname (can be relative or absolute).
[445]199 * @ flags      : bit vector attributes (see in shared_fcntl.h file)
[23]200 * @ mode       : access rights.
201 * @ return file descriptor index in fd_array if success / return -1 if failure.
[407]202 *****************************************************************************************/
[566]203int sys_open( char       * pathname,
[506]204              uint32_t     flags,
205              uint32_t     mode );
[16]206
[407]207/******************************************************************************************
208 * [13] This function map physical memory (or a file) in the calling thread virtual space.
209 * The <attr> argument is a pointer on a structure for arguments (see shared_syscalls.h).
210 ******************************************************************************************
211 * @ attr       : pointer on attributes structure.
212 * @ return 0 if success / return -1 if failure.
213 *****************************************************************************************/
214int sys_mmap( mmap_attr_t * attr );
[23]215
[407]216/******************************************************************************************
[23]217 * [14] This function read bytes from an open file identified by its file descriptor.
[407]218 * The file can be a regular file or character oriented device.
[408]219 * IRQs are enabled during this system call.
[407]220 ******************************************************************************************
[23]221 * @ file_id  : open file index in fd_array.
222 * @ buf      : buffer virtual address in user space.
223 * @ count    : number of bytes.
224 * @ return number of bytes actually read if success / returns -1 if failure.
[407]225 *****************************************************************************************/
[23]226int sys_read( uint32_t   file_id,
227              void     * buf,
228              uint32_t   count );
[16]229
[407]230/******************************************************************************************
[23]231 * [15] This function writes bytes to an open file identified by its file descriptor.
[407]232 * The file can be a regular file or character oriented device.
[408]233 * IRQs are enabled during this system call.
[407]234 ******************************************************************************************
[23]235 * @ file_id  : open file index in fd_array.
236 * @ buf      : buffer virtual address in user space.
237 * @ count    : number of bytes.
238 * @ return number of bytes actually written if success / returns -1 if failure.
[407]239 *****************************************************************************************/
[23]240int sys_write( uint32_t   file_id,
241               void     * buf,
242               uint32_t   count );
[16]243
[407]244/******************************************************************************************
245 * [16] This function repositions the offset of the file descriptor identified by <file_id>,
246 * according to the operation type defined by the <whence> argument.
247 ******************************************************************************************
[23]248 * @ file_id  : open file index in fd_array.
[407]249 * @ offset   : used to compute new offset value.
[23]250 * @ whence   : operation type (see below).
251 * @ return 0 if success / returns -1 if failure.
[407]252 *****************************************************************************************/
[23]253int sys_lseek( xptr_t    file_id,
254               uint32_t  offset,
255               uint32_t  whence );
[16]256
[407]257/******************************************************************************************
[23]258 * [17] This function release the memory allocated for the file descriptor identified by
259 * the <file_id> argument, and remove the fd array_entry in all copies of the process
260 * descriptor.
[407]261 ******************************************************************************************
[23]262  file_id   : file descriptor index in fd_array.
263 * @ return 0 if success / returns -1 if failure.
[407]264 *****************************************************************************************/
[23]265int sys_close( uint32_t file_id );
[16]266
[407]267/******************************************************************************************
268 * [18] This function removes a directory entry identified by the <pathname> from the
[23]269 * directory, and decrement the link count of the file referenced by the link.
270 * If the link count reduces to zero, and no process has the file open, then all resources
271 * associated with the file are reclaimed.  If one or more process have the file open when
272 * the last link is removed, the link is removed, but the removal of the file is delayed
273 * until all references to it have been closed.
[407]274 ******************************************************************************************
[23]275 * @ pathname   : pathname (can be relative or absolute).
276 * @ return 0 if success / returns -1 if failure.
[407]277 *****************************************************************************************/
[566]278int sys_unlink( char * pathname );
[16]279
[407]280/******************************************************************************************
[23]281 * [19] This function creates in the calling thread cluster an unnamed pipe, and two
282 * (read and write) file descriptors.
[407]283 * TODO not implemented yet...
284 ******************************************************************************************
[23]285 * @ file_id[0] : [out] read only file descriptor index.
286 * @ file_id[1] : [out] write only file descriptor index.
287 * @ return 0 if success / return -1 if failure.
[407]288 *****************************************************************************************/
[23]289int sys_pipe( uint32_t file_id[2] );
[16]290
[407]291/******************************************************************************************
[23]292 * [20] This function change the current working directory in reference process descriptor.
[407]293 ******************************************************************************************
[23]294 * @ pathname   : pathname (can be relative or absolute).
295 * @ return 0 if success / returns -1 if failure.
[407]296 *****************************************************************************************/
[566]297int sys_chdir( char * pathname );
[16]298
[407]299/******************************************************************************************
[23]300 * [21] This function creates a new directory in file system.
[407]301 ******************************************************************************************
[23]302 * @ pathname   : pathname (can be relative or absolute).
303 * @ mode       : access rights (as defined in chmod).
304 * @ return 0 if success / returns -1 if failure.
[407]305 *****************************************************************************************/
[279]306int sys_mkdir( char    * pathname,
[23]307               uint32_t  mode );
[16]308
[407]309/******************************************************************************************
[23]310 * [22] This function creates a named FIFO file in the calling thread cluster.
311 * The associated read and write file descriptors mut be be  explicitely created
[407]312 * using the sys_open() function.
313 ******************************************************************************************
[23]314 * @ pathname   : pathname (can be relative or absolute).
315 * @ mode       : access rights (as defined in chmod).
316 * @ return 0 if success / returns -1 if failure.
[407]317 *****************************************************************************************/
[23]318int sys_mkfifo( char     * pathname,
319                uint32_t   mode );
[16]320
[407]321/******************************************************************************************
322 * [23] This function open a directory, that must exist in the file system, returning
323 * a DIR pointer on the directory in user space.
324 ******************************************************************************************
[23]325 * @ pathname   : pathname (can be relative or absolute).
[407]326 * @ dirp       : [out] buffer for pointer on user directory (DIR).
[23]327 * @ return 0 if success / returns -1 if failure.
[407]328 *****************************************************************************************/
329int sys_opendir( char * pathname,
330                 DIR ** dirp );
[16]331
[407]332/******************************************************************************************
333 * [24] This function returns an user pointer on the dirent structure describing the
334 * next directory entry in the directory identified by the <dirp> argument.
335 ******************************************************************************************
336 * @ dirp     : user pointer identifying the searched directory.
337 * @ dentp    : [out] buffer for pointer on user direntory entry (dirent).
338 * @ return O if success / returns -1 if failure.
339 *****************************************************************************************/
340int sys_readdir( DIR            * dirp,
341                 struct dirent ** dentp );
342
343/******************************************************************************************
344 * [25] This function closes the directory identified by the <dirp> argument, and releases
345 * all structures associated with the <dirp> pointer.
346 ******************************************************************************************
347 * @ dirp     : user pointer identifying the directory.
[23]348 * @ return 0 if success / returns -1 if failure.
[407]349 *****************************************************************************************/
350int sys_closedir( DIR * dirp );
[16]351
[407]352/******************************************************************************************
[23]353 * [26] This function returns the pathname of the current working directory.
[407]354 ******************************************************************************************
[23]355 * buf     : buffer addres in user space.
356 * nbytes  : user buffer size in bytes.
357 * @ return 0 if success / returns -1 if failure.
[407]358 *****************************************************************************************/
[23]359int sys_getcwd( char     * buf,
360                uint32_t   nbytes );
[16]361
[407]362/******************************************************************************************
[437]363 * [27] This function tests whether a given file descriptor dentified by the <file_id>
364 * argument is an open file descriptor referring to a terminal.
365 ******************************************************************************************
366 * @ file_id   : file descriptor index
367 * @ return 1 if it is a TXT device / return 0 if it is not a TXT device.
[407]368 *****************************************************************************************/
[437]369int sys_isatty( uint32_t file_id );
[16]370
[407]371/******************************************************************************************
[23]372 * [28] This function forces the calling thread to sleep, for a fixed number of cycles.
[407]373 ******************************************************************************************
[23]374 * cycles   : number of cycles.
[407]375 *****************************************************************************************/
[23]376int sys_alarm( uint32_t cycles );
[16]377
[407]378/******************************************************************************************
379 * [29] This function removes a directory file whose name is given by <pathname>.
380 * The directory must not have any entries other than `.' and `..'.
381 ******************************************************************************************
[23]382 * @ pathname   : pathname (can be relative or absolute).
383 * @ return 0 if success / returns -1 if failure.
[407]384 *****************************************************************************************/
[566]385int sys_rmdir( char * pathname );
[16]386
[407]387/******************************************************************************************
[23]388 * [30] This function implement the operations related to User Thread Local Storage.
389 * It is actually implemented as an uint32_t variable in the thread descriptor.
[407]390 ******************************************************************************************
[23]391 * @ operation  : UTLS operation type as defined below.
392 * @ value      : argument value for the UTLS_SET operation.
393 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
[407]394 *****************************************************************************************/
[23]395int sys_utls( uint32_t operation,
396              uint32_t value );
[16]397
[407]398/******************************************************************************************
[23]399 * [31] This function change the acces rights for the file/dir identified by the
400 * pathname argument.
[407]401 ******************************************************************************************
[23]402 * @ pathname   : pathname (can be relative or absolute).
403 * @ rights     : acces rights.
404 * @ return 0 if success / returns -1 if failure.
[407]405 *****************************************************************************************/
[566]406int sys_chmod( char       * pathname,
[506]407               uint32_t     rights );
[16]408
[407]409/******************************************************************************************
[23]410 * [32] This function associate a specific signal handler to a given signal type.
411 * Tee handlers for the SIGKILL and SIGSTOP signals cannot be redefined.
[407]412 ******************************************************************************************
[23]413 * @ sig_id    : index defining signal type (from 1 to 31).
414 * @ handler   : pointer on fonction implementing the specific handler.
415 * @ return 0 if success / returns -1 if failure.
[407]416 *****************************************************************************************/
[23]417int sys_signal( uint32_t   sig_id,
418                void     * handler );
[16]419
[407]420/******************************************************************************************
[23]421 * [33] This function returns in the structure <tv>, defined in the time.h file,
422 * the current time (in seconds & micro-seconds).
423 * It is computed from the calling core descriptor.
424 * The timezone is not supported.
[407]425 ******************************************************************************************
[23]426 * @ tv      : pointer on the timeval structure.
427 * @ tz      : pointer on the timezone structure : must be NULL.       
428 * @ return 0 if success / returns -1 if failure.
[407]429 *****************************************************************************************/
[50]430int sys_timeofday( struct timeval  * tv,
431                   struct timezone * tz );
[16]432
[407]433/******************************************************************************************
[433]434 * [34] This function implements the "kill" system call on the kernel side.
[23]435 * It register the signal defined by the <sig_id> argument in all thread descriptors
436 * of a target process identified by the <pid> argument. This is done in all clusters
437 * containing threads for the target process.
438 * It can be executed by any thread running in any cluster, as this function uses
[407]439 * remote access to traverse the list of process copies stored in the owner cluster,
[23]440 * and the RPC_SIGNAL_RISE to signal the remote threads.
[421]441 * This function does nothing for (sig_id == 0). This can be used to check process pid.
442 * TODO : This first implementation supports only SIGKILL / SIGSTOP / SIGCONT values.
[407]443 ******************************************************************************************
[16]444 * @ pid      : target process identifier.
[433]445 * @ sig_id   : index defining the signal type.
[23]446 * @ return 0 if success / returns -1 if failure.
[407]447 *****************************************************************************************/
[16]448int sys_kill( pid_t    pid,
[23]449              uint32_t sig_id );
[16]450
[407]451/******************************************************************************************
[433]452 * [35] This function implements the "getpid" system call on the kernel side.
[407]453 ******************************************************************************************
454 * @ returns the process PID for the calling thread.
455 *****************************************************************************************/
[479]456int sys_getpid( void );
[1]457
[407]458/******************************************************************************************
[433]459 * [36] This function implement the "fork" system call on the kernel side.
460 * The calling process descriptor (parent process), and the associated thread descriptor
461 * are replicated in a - likely - remote cluster, that becomes the child process owner.
462 * The child process get a new PID, and is linked to the parent PID. The child process
463 * inherit from its parent the memory image, and all open files (including the TXT).
464 * The child process becomes the TXT terminal owner.
[1]465 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be
466 * stored in the calling thread descriptor by the specific fork_place() system call.
[433]467 * If not, the kernel function makes a query to the DQDT to select the target cluster.
[407]468 ******************************************************************************************
469 * @ if success, returns child process PID to parent, and return O to child.
470 * @ if failure, returns -1 to parent / no child process is created.
471 *****************************************************************************************/
[479]472int sys_fork( void );
[1]473
[407]474/******************************************************************************************
[433]475 * [37] This function implement the "exec" system call on the kernel side.
476 * It creates, in the same cluster as the calling thread, a new process descriptor,
477 * and a new associated main thread descriptor, executing a new memory image defined
478 * by the <filename> argument. This new process inherit from the old process the PID
479 * and the PPID, as well as all open files (including the TXT).
480 * The old process descriptor, and all its threads are blocked, and marked for deletion.
481 * Therefore the exec syscall does not return to the calling thread in case of success.
482 * This function build an exec_info_t structure containing the new process arguments,
483 * as defined by the <arv> argument, and the new process environment variables,
484 * as defined by the <envp>  argument.
485 * TODO : the <argv> and <envp> arguments are not supported yet (both must be NULL).
[407]486 ******************************************************************************************
487 * @ filename : string pointer on .elf filename (pointer in user space)
488 * @ argv     : array of strings on process arguments (pointers in user space)
489 * @ envp     : array of strings on environment variables (pointers in user space)
[433]490 * @ does not return if success / returns -1 if failure.
[407]491 *****************************************************************************************/
[566]492int sys_exec( char  * filename,
493              char ** argv,
494              char ** envp );
[1]495
[407]496/******************************************************************************************
497 * [38] This function  returns in the <stat> structure, defined in the "shared_syscalls.h"
498 * file, various informations on the file/directory identified by the <pathname> argument.
499 ******************************************************************************************
500 * @ pathname  : user pointer on file pathname.
501 * @ stat      : user pointer on the stat structure.
[23]502 * @ returns O if success / returns -1 if failure.
[407]503 *****************************************************************************************/
[566]504int sys_stat( char        * pathname,
[407]505              struct stat * stat );
[1]506
[407]507/******************************************************************************************
[433]508 * [39] This blocking function waits a change of a child process state, that can be:
509 * - a termination of child following a process_make_exit().
510 * - a termination of child following a process_make_kill().
[421]511 * - a blocking of child following a SIGSTOP signal.
[433]512 * In case of a multi-thread process, this function must be called by the main thread
513 * runningin the reference cluster.
514 * When a change has been observed, it returns the PID of the child process, and stores
515 * in the <status> argument relevant information on the child state change.
[421]516 * The following macros can be used to extract information from status:
517 * - WIFEXITED(status)   : is true if the child process terminated with an exit().
[435]518 * - WIFSIGNALED(status) : is true if the child process killed by a signal.
[421]519 * - WIFSTOPPED(status)  : is true if the child process is stopped by a signal.
520 * - WEXITSTATUS(status) : returns the low-order 8 bits of the exit() argument.
521 * If a parent process terminates without waiting for all child processes to terminate,
522 * the remaining child processes are attached to the init process.
[433]523 * WARNING: negative values for the <pid> argument are not supported.
[421]524 ******************************************************************************************
[433]525 * @ searched_pid : searched child process identifier.
526 * @ status       : [out] child termination status.
527 * @ return child PID if success / return -1 if searched PID not found.
[407]528 *****************************************************************************************/
[421]529int sys_wait( uint32_t * status );
[1]530
[407]531/******************************************************************************************
532 * [40] This function returns the hardware platform parameters.
533 ******************************************************************************************
534 * @ x_size   : [out] number of clusters in a row.
535 * @ y_size   : [out] number of clusters in a column.
536 * @ ncores   : [out] number of cores per cluster.
537 * @ return 0 if success / return -1 if illegal arguments
538 *****************************************************************************************/
539int sys_get_config( uint32_t * x_size,
540                    uint32_t * y_size,
541                    uint32_t * ncores );
[1]542
[407]543/******************************************************************************************
544 * [41] This function returns the calling core cluster and local index.
545 ******************************************************************************************
546 * @ cxy      : [out] cluster identifier (fixed format)
547 * @ lid      : [out] core local index in cluster.
548 * @ return 0 if success / return -1 if illegal arguments
549 *****************************************************************************************/
550int sys_get_core( uint32_t * cxy,
551                  uint32_t * lid );
[1]552
[407]553/******************************************************************************************
554 * [42] This function returns in a 64 bits user buffer the calling core cycles count.
555 * It uses both the hardware register and the core descriptor cycles count to take
556 * into account a possible harware register overflow  in 32 bits architectures.
557 ******************************************************************************************
558 * cycle    : [out] address of buffer in user space.
559 * @ return 0 if success / return -1 if illegal arguments
560 *****************************************************************************************/
561int sys_get_cycle( uint64_t * cycle );
562
563/******************************************************************************************
[421]564 * [43] This debug function displays on the kernel terminal TXT0 an user defined string,
565 * or the current state of a kernel structure, identified by the <type> argument.
[435]566 * The <arg0> and <arg1> arguments depends on the structure type:
567 * - DISPLAY_STRING          : an user defined string
568 * - DISPLAY_VMM             : VSL and GPT for a process identified by <pid>.
569 * - DISPLAY_SCHED           : all threads allocated to a scheduler <cxy> & <lid>.
570 * - DISPLAY_CLUSTER_PROCESS : all processes registered in a cluster identified by <cxy>. 
571 * - DISPLAY_TXT_PROCESS     : all processes registered in a cluster identified by <cxy>. 
572 * - DISPLAY_VFS             : all files registered in the VFS cache.
573 * - DISPLAY_CHDEV           : all registered channel devices.
[445]574 * - DISPLAY_DQDT            : all DQDT nodes.
[407]575 ******************************************************************************************
[435]576 * type      : [in] type of display
[421]577 * arg0      : [in] type dependant argument.
578 * arg1      : [in] type dependant argument.
[407]579 * @ return 0 if success / return -1 if illegal arguments
580 *****************************************************************************************/
[421]581int sys_display( reg_t  type,
582                 reg_t  arg0,
583                 reg_t  arg1 );
[407]584
585/******************************************************************************************
[457]586 * [44] TBD
587 ******************************************************************************************
588 * @ cxy    : cluster identifier.
589 * @ lid    : core local index.
590 * @ return 0 if success / return -1 if failure.
591 *****************************************************************************************/
592int sys_place( uint32_t cxy,
593               uint32_t lid );
594
595/******************************************************************************************
[407]596 * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition,
597 * and deschedule.
598 ******************************************************************************************
599 * @ return 0 if success / returns -1 if failure.
600 *****************************************************************************************/
[479]601int sys_thread_sleep( void );
[407]602
603/******************************************************************************************
604 * [46] This function unblock the thread identified by its <trdid> from the
605 * THREAD_BLOCKED_GLOBAL condition.
606 ******************************************************************************************
607 * @ trdid  : target thread identifier.
608 * @ return 0 if success / return -1 if failure.
609 *****************************************************************************************/
[506]610int sys_thread_wakeup( trdid_t trdid );
[407]611
[421]612/******************************************************************************************
[443]613 * [47] This debug function is used to activate / desactivate the context switches trace
614 * for a core identified by the <cxy> and <lid> arguments.
[421]615 * It can be called by any other thread in the same process.
616 ******************************************************************************************
[443]617 * @ active     : activate trace if true / desactivate trace if false.
618 * @ cxy        : cluster identifier.
619 * @ lid        : core local index.
[421]620 * @ returns O if success / returns -1 if failure.
621 *****************************************************************************************/
[443]622int sys_trace( bool_t   active,
623               cxy_t    cxy, 
624               lid_t    lid );
[407]625
[421]626/******************************************************************************************
627 * [48] This function gives the process identified by the <pid> argument
628 * the exclusive ownership of its TXT_TX terminal (put it in foreground).
629 ******************************************************************************************
630 * @ pid    : process identifier.
631 * @ return 0 if success / return -1 if failure.
632 *****************************************************************************************/
633int sys_fg( pid_t   pid );
634
[445]635/******************************************************************************************
[457]636 * [49] This function returns a non-zero value in the <is_fg> buffer when the process
637 * identified by the <pid> argument is the current TXT owner.
[445]638 ******************************************************************************************
[457]639 * @ pid      : process identifier.
640 * @ is_fg    : pointer on buffer.
[445]641 * @ return 0 if success / return -1 if failure.
642 *****************************************************************************************/
[457]643int sys_is_fg( pid_t      pid,
644               uint32_t * is_fg );
[421]645
[16]646#endif  // _SYSCALLS_H_
Note: See TracBrowser for help on using the repository browser.