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

Last change on this file since 639 was 637, checked in by alain, 5 years ago

Introduce the non-standard pthread_parallel_create() system call
and re-write the <fft> and <sort> applications to improve the
intrinsic paralelism in applications.

File size: 43.2 KB
RevLine 
[1]1/*
[407]2 * syscalls.h - Kernel side services for syscall handling.
[1]3 *
[626]4 * Author     Alain Greiner (2016,2017,2018,2019)
[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 ******************************************************************************************
[619]148 * @ vaddr     : barrier address in user space == identifier.
[23]149 * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT.
[619]150 * @ count     : number of expected threads (only used by BARRIER_INIT).
151 * @ attr      : barrier attributes address in user space (only used by BARRIER_INIT).
[23]152 * @ return 0 if success / return -1 if failure.
[407]153 *****************************************************************************************/
[619]154int sys_barrier( intptr_t   vaddr,
[23]155                 uint32_t   operation,
[619]156                 uint32_t   count,
157                 intptr_t   attr );
[16]158
[407]159/******************************************************************************************
[23]160 * [9] This function implement all operations on a POSIX mutex.
161 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
162 * The code implementting the operations is defined in the remote_barrier.c file.
[407]163 ******************************************************************************************
[23]164 * @ vaddr     : mutex virtual address in user space == identifier.
165 * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK
166 * @ attr      : mutex attributes (non supported yet => must be 0).
167 * @ return 0 if success / return -1 if failure.
[407]168 *****************************************************************************************/
[23]169int sys_mutex( void     * vaddr,
170               uint32_t   operation,
171               uint32_t   count );
[16]172
[407]173/******************************************************************************************
[610]174 * [10] This function causes the file named <old> to be renamed as <new>.
175 * If new exists, it is first removed.  Both old and new must be of the same type (both
176 * must be either directories or non-directories) and must reside on the same file system.
177 * It guarantees that an instance of <new> will always exist, even if the system should
178 * crash in the middle of the operation.
[407]179 ******************************************************************************************
[610]180 * @ old      : old file name.
181 * @ new      : new file name.
182 * @ return 0 if success / return -1 if failure.
[407]183 *****************************************************************************************/
[610]184int sys_rename( char *old,
185                char *new );
[16]186
[407]187/******************************************************************************************
[408]188 * [11] This function remove an existing mapping defined by the <addr> and <size>
[407]189 * arguments in user space.
190 ******************************************************************************************
191 * @ addr  : base address in user space.
192 * # size  : number of bytes.
[23]193 * @ return 0 if success / return -1 if failure.
[407]194 *****************************************************************************************/
195int sys_munmap( void     * addr,
196                uint32_t   size );
[16]197
[407]198/******************************************************************************************
199 * [12] This function open or create an open file descriptor.
200 ******************************************************************************************
[23]201 * @ pathname   : pathname (can be relative or absolute).
[445]202 * @ flags      : bit vector attributes (see in shared_fcntl.h file)
[23]203 * @ mode       : access rights.
204 * @ return file descriptor index in fd_array if success / return -1 if failure.
[407]205 *****************************************************************************************/
[566]206int sys_open( char       * pathname,
[506]207              uint32_t     flags,
208              uint32_t     mode );
[16]209
[407]210/******************************************************************************************
211 * [13] This function map physical memory (or a file) in the calling thread virtual space.
[637]212 * The <attr> argument is a pointer on a structure for arguments (see shared_mman.h).
[594]213 * The user defined virtual address (MAP_FIXED flag) is not supported.
214 * TODO : the access rights checking is not implemented yet [AG]
215 * TODO : the Copy on Write for MAP_PRIVATE is not implemented yet [AG]
[407]216 ******************************************************************************************
217 * @ attr       : pointer on attributes structure.
218 * @ return 0 if success / return -1 if failure.
219 *****************************************************************************************/
220int sys_mmap( mmap_attr_t * attr );
[23]221
[407]222/******************************************************************************************
[23]223 * [14] This function read bytes from an open file identified by its file descriptor.
[407]224 * The file can be a regular file or character oriented device.
[408]225 * IRQs are enabled during this system call.
[407]226 ******************************************************************************************
[23]227 * @ file_id  : open file index in fd_array.
228 * @ buf      : buffer virtual address in user space.
229 * @ count    : number of bytes.
230 * @ return number of bytes actually read if success / returns -1 if failure.
[407]231 *****************************************************************************************/
[23]232int sys_read( uint32_t   file_id,
233              void     * buf,
234              uint32_t   count );
[16]235
[407]236/******************************************************************************************
[23]237 * [15] This function writes bytes to an open file identified by its file descriptor.
[623]238 * The file can be a regular file or character oriented device. For a regular file,
239 * the target inode "size" field is updated if (offset + count) is larger than the
240 * current "size" value. The size value registered in the mappers of the parent(s)
241 * directory are not modified and will be asynchronously updated when the file is closed.
[408]242 * IRQs are enabled during this system call.
[407]243 ******************************************************************************************
[23]244 * @ file_id  : open file index in fd_array.
245 * @ buf      : buffer virtual address in user space.
246 * @ count    : number of bytes.
247 * @ return number of bytes actually written if success / returns -1 if failure.
[407]248 *****************************************************************************************/
[23]249int sys_write( uint32_t   file_id,
250               void     * buf,
251               uint32_t   count );
[16]252
[407]253/******************************************************************************************
254 * [16] This function repositions the offset of the file descriptor identified by <file_id>,
255 * according to the operation type defined by the <whence> argument.
256 ******************************************************************************************
[23]257 * @ file_id  : open file index in fd_array.
[407]258 * @ offset   : used to compute new offset value.
[23]259 * @ whence   : operation type (see below).
260 * @ return 0 if success / returns -1 if failure.
[407]261 *****************************************************************************************/
[23]262int sys_lseek( xptr_t    file_id,
263               uint32_t  offset,
264               uint32_t  whence );
[16]265
[407]266/******************************************************************************************
[23]267 * [17] This function release the memory allocated for the file descriptor identified by
268 * the <file_id> argument, and remove the fd array_entry in all copies of the process
269 * descriptor.
[407]270 ******************************************************************************************
[23]271  file_id   : file descriptor index in fd_array.
272 * @ return 0 if success / returns -1 if failure.
[407]273 *****************************************************************************************/
[23]274int sys_close( uint32_t file_id );
[16]275
[407]276/******************************************************************************************
277 * [18] This function removes a directory entry identified by the <pathname> from the
[23]278 * directory, and decrement the link count of the file referenced by the link.
279 * If the link count reduces to zero, and no process has the file open, then all resources
280 * associated with the file are reclaimed.  If one or more process have the file open when
281 * the last link is removed, the link is removed, but the removal of the file is delayed
282 * until all references to it have been closed.
[407]283 ******************************************************************************************
[23]284 * @ pathname   : pathname (can be relative or absolute).
285 * @ return 0 if success / returns -1 if failure.
[407]286 *****************************************************************************************/
[566]287int sys_unlink( char * pathname );
[16]288
[407]289/******************************************************************************************
[23]290 * [19] This function creates in the calling thread cluster an unnamed pipe, and two
291 * (read and write) file descriptors.
[594]292 * TODO not implemented yet [AG]
[407]293 ******************************************************************************************
[23]294 * @ file_id[0] : [out] read only file descriptor index.
295 * @ file_id[1] : [out] write only file descriptor index.
296 * @ return 0 if success / return -1 if failure.
[407]297 *****************************************************************************************/
[23]298int sys_pipe( uint32_t file_id[2] );
[16]299
[407]300/******************************************************************************************
[23]301 * [20] This function change the current working directory in reference process descriptor.
[407]302 ******************************************************************************************
[23]303 * @ pathname   : pathname (can be relative or absolute).
304 * @ return 0 if success / returns -1 if failure.
[407]305 *****************************************************************************************/
[566]306int sys_chdir( char * pathname );
[16]307
[407]308/******************************************************************************************
[610]309 * [21] This function implements the "mkdir" system call, creating a new directory in
310 * the file system, as defined by the <pathname> argument, with the access permission
311 * defined by the <rights> argument. All nodes but the last in the pathname must exist.
312 * It can be called by any thread running in any cluster.
[407]313 ******************************************************************************************
[610]314 * @ pathname  : pathname defining the new directory location in file system.
315 * @ rights    : access rights (non used yet).
316 * @ return 0 if success / return -1 if failure.
[407]317 *****************************************************************************************/
[610]318int sys_mkdir( char     * pathname,
319               uint32_t   rights );
[16]320
[407]321/******************************************************************************************
[23]322 * [22] This function creates a named FIFO file in the calling thread cluster.
323 * The associated read and write file descriptors mut be be  explicitely created
[407]324 * using the sys_open() function.
325 ******************************************************************************************
[23]326 * @ pathname   : pathname (can be relative or absolute).
327 * @ mode       : access rights (as defined in chmod).
328 * @ return 0 if success / returns -1 if failure.
[407]329 *****************************************************************************************/
[23]330int sys_mkfifo( char     * pathname,
331                uint32_t   mode );
[16]332
[407]333/******************************************************************************************
[623]334 * [23] This function creates an user level directory descriptor (including the associated
335 * array of user level dirents), and intialise it from the kernel directory mapper, that
336 * contains all entries in this directory). The directory is identified by the <pathname>
337 * argument. If the corresponding inode is missing in the Inode Tree, the inode is created,
338 * but the directory must exist in the file system.
339 * It returns a DIR pointer <dirp> on the dirent array in user space.
[407]340 ******************************************************************************************
[611]341 * @ pathname   : [in]  pathname (can be relative or absolute).
[407]342 * @ dirp       : [out] buffer for pointer on user directory (DIR).
[23]343 * @ return 0 if success / returns -1 if failure.
[407]344 *****************************************************************************************/
345int sys_opendir( char * pathname,
346                 DIR ** dirp );
[16]347
[407]348/******************************************************************************************
349 * [24] This function returns an user pointer on the dirent structure describing the
350 * next directory entry in the directory identified by the <dirp> argument.
351 ******************************************************************************************
[611]352 * @ dirp     : [in]  user pointer on dirent array identifying the open directory.
353 * @ buffer   : [out] pointer on user buffer for a pointer on dirent in user space.
[407]354 * @ return O if success / returns -1 if failure.
355 *****************************************************************************************/
356int sys_readdir( DIR            * dirp,
[611]357                 struct dirent ** buffer );
[407]358
359/******************************************************************************************
360 * [25] This function closes the directory identified by the <dirp> argument, and releases
361 * all structures associated with the <dirp> pointer.
362 ******************************************************************************************
[611]363 * @ dirp     : [in] user pointer on dirent array identifying the open directory.
[23]364 * @ return 0 if success / returns -1 if failure.
[407]365 *****************************************************************************************/
366int sys_closedir( DIR * dirp );
[16]367
[407]368/******************************************************************************************
[23]369 * [26] This function returns the pathname of the current working directory.
[407]370 ******************************************************************************************
[23]371 * buf     : buffer addres in user space.
372 * nbytes  : user buffer size in bytes.
373 * @ return 0 if success / returns -1 if failure.
[407]374 *****************************************************************************************/
[23]375int sys_getcwd( char     * buf,
376                uint32_t   nbytes );
[16]377
[407]378/******************************************************************************************
[437]379 * [27] This function tests whether a given file descriptor dentified by the <file_id>
380 * argument is an open file descriptor referring to a terminal.
381 ******************************************************************************************
382 * @ file_id   : file descriptor index
383 * @ return 1 if it is a TXT device / return 0 if it is not a TXT device.
[407]384 *****************************************************************************************/
[437]385int sys_isatty( uint32_t file_id );
[16]386
[407]387/******************************************************************************************
[23]388 * [28] This function forces the calling thread to sleep, for a fixed number of cycles.
[407]389 ******************************************************************************************
[23]390 * cycles   : number of cycles.
[407]391 *****************************************************************************************/
[23]392int sys_alarm( uint32_t cycles );
[16]393
[407]394/******************************************************************************************
395 * [29] This function removes a directory file whose name is given by <pathname>.
396 * The directory must not have any entries other than `.' and `..'.
397 ******************************************************************************************
[23]398 * @ pathname   : pathname (can be relative or absolute).
399 * @ return 0 if success / returns -1 if failure.
[407]400 *****************************************************************************************/
[566]401int sys_rmdir( char * pathname );
[16]402
[407]403/******************************************************************************************
[23]404 * [30] This function implement the operations related to User Thread Local Storage.
405 * It is actually implemented as an uint32_t variable in the thread descriptor.
[407]406 ******************************************************************************************
[23]407 * @ operation  : UTLS operation type as defined below.
408 * @ value      : argument value for the UTLS_SET operation.
409 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
[407]410 *****************************************************************************************/
[23]411int sys_utls( uint32_t operation,
412              uint32_t value );
[16]413
[407]414/******************************************************************************************
[23]415 * [31] This function change the acces rights for the file/dir identified by the
416 * pathname argument.
[407]417 ******************************************************************************************
[23]418 * @ pathname   : pathname (can be relative or absolute).
419 * @ rights     : acces rights.
420 * @ return 0 if success / returns -1 if failure.
[407]421 *****************************************************************************************/
[566]422int sys_chmod( char       * pathname,
[506]423               uint32_t     rights );
[16]424
[407]425/******************************************************************************************
[23]426 * [32] This function associate a specific signal handler to a given signal type.
[584]427 * The handlers for the SIGKILL and SIGSTOP signals cannot be redefined.
[407]428 ******************************************************************************************
[23]429 * @ sig_id    : index defining signal type (from 1 to 31).
430 * @ handler   : pointer on fonction implementing the specific handler.
431 * @ return 0 if success / returns -1 if failure.
[407]432 *****************************************************************************************/
[23]433int sys_signal( uint32_t   sig_id,
434                void     * handler );
[16]435
[407]436/******************************************************************************************
[23]437 * [33] This function returns in the structure <tv>, defined in the time.h file,
438 * the current time (in seconds & micro-seconds).
439 * It is computed from the calling core descriptor.
440 * The timezone is not supported.
[407]441 ******************************************************************************************
[23]442 * @ tv      : pointer on the timeval structure.
443 * @ tz      : pointer on the timezone structure : must be NULL.       
444 * @ return 0 if success / returns -1 if failure.
[407]445 *****************************************************************************************/
[50]446int sys_timeofday( struct timeval  * tv,
447                   struct timezone * tz );
[16]448
[407]449/******************************************************************************************
[433]450 * [34] This function implements the "kill" system call on the kernel side.
[23]451 * It register the signal defined by the <sig_id> argument in all thread descriptors
452 * of a target process identified by the <pid> argument. This is done in all clusters
453 * containing threads for the target process.
454 * It can be executed by any thread running in any cluster, as this function uses
[407]455 * remote access to traverse the list of process copies stored in the owner cluster,
[23]456 * and the RPC_SIGNAL_RISE to signal the remote threads.
[421]457 * This function does nothing for (sig_id == 0). This can be used to check process pid.
458 * TODO : This first implementation supports only SIGKILL / SIGSTOP / SIGCONT values.
[407]459 ******************************************************************************************
[16]460 * @ pid      : target process identifier.
[433]461 * @ sig_id   : index defining the signal type.
[23]462 * @ return 0 if success / returns -1 if failure.
[407]463 *****************************************************************************************/
[16]464int sys_kill( pid_t    pid,
[23]465              uint32_t sig_id );
[16]466
[407]467/******************************************************************************************
[433]468 * [35] This function implements the "getpid" system call on the kernel side.
[407]469 ******************************************************************************************
470 * @ returns the process PID for the calling thread.
471 *****************************************************************************************/
[479]472int sys_getpid( void );
[1]473
[407]474/******************************************************************************************
[433]475 * [36] This function implement the "fork" system call on the kernel side.
476 * The calling process descriptor (parent process), and the associated thread descriptor
477 * are replicated in a - likely - remote cluster, that becomes the child process owner.
478 * The child process get a new PID, and is linked to the parent PID. The child process
479 * inherit from its parent the memory image, and all open files (including the TXT).
480 * The child process becomes the TXT terminal owner.
[1]481 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be
482 * stored in the calling thread descriptor by the specific fork_place() system call.
[433]483 * If not, the kernel function makes a query to the DQDT to select the target cluster.
[407]484 ******************************************************************************************
485 * @ if success, returns child process PID to parent, and return O to child.
486 * @ if failure, returns -1 to parent / no child process is created.
487 *****************************************************************************************/
[479]488int sys_fork( void );
[1]489
[407]490/******************************************************************************************
[433]491 * [37] This function implement the "exec" system call on the kernel side.
492 * It creates, in the same cluster as the calling thread, a new process descriptor,
493 * and a new associated main thread descriptor, executing a new memory image defined
494 * by the <filename> argument. This new process inherit from the old process the PID
495 * and the PPID, as well as all open files (including the TXT).
496 * The old process descriptor, and all its threads are blocked, and marked for deletion.
497 * Therefore the exec syscall does not return to the calling thread in case of success.
498 * This function build an exec_info_t structure containing the new process arguments,
499 * as defined by the <arv> argument, and the new process environment variables,
500 * as defined by the <envp>  argument.
501 * TODO : the <argv> and <envp> arguments are not supported yet (both must be NULL).
[407]502 ******************************************************************************************
503 * @ filename : string pointer on .elf filename (pointer in user space)
504 * @ argv     : array of strings on process arguments (pointers in user space)
505 * @ envp     : array of strings on environment variables (pointers in user space)
[433]506 * @ does not return if success / returns -1 if failure.
[407]507 *****************************************************************************************/
[566]508int sys_exec( char  * filename,
509              char ** argv,
510              char ** envp );
[1]511
[407]512/******************************************************************************************
513 * [38] This function  returns in the <stat> structure, defined in the "shared_syscalls.h"
514 * file, various informations on the file/directory identified by the <pathname> argument.
[594]515 * TODO only the <st_ino>, <st_mode>,<st_uid>,<st_gid>,<st_size> are set.
[407]516 ******************************************************************************************
517 * @ pathname  : user pointer on file pathname.
518 * @ stat      : user pointer on the stat structure.
[23]519 * @ returns O if success / returns -1 if failure.
[407]520 *****************************************************************************************/
[566]521int sys_stat( char        * pathname,
[407]522              struct stat * stat );
[1]523
[407]524/******************************************************************************************
[433]525 * [39] This blocking function waits a change of a child process state, that can be:
526 * - a termination of child following a process_make_exit().
527 * - a termination of child following a process_make_kill().
[421]528 * - a blocking of child following a SIGSTOP signal.
[433]529 * In case of a multi-thread process, this function must be called by the main thread
530 * runningin the reference cluster.
531 * When a change has been observed, it returns the PID of the child process, and stores
532 * in the <status> argument relevant information on the child state change.
[421]533 * The following macros can be used to extract information from status:
534 * - WIFEXITED(status)   : is true if the child process terminated with an exit().
[435]535 * - WIFSIGNALED(status) : is true if the child process killed by a signal.
[421]536 * - WIFSTOPPED(status)  : is true if the child process is stopped by a signal.
537 * - WEXITSTATUS(status) : returns the low-order 8 bits of the exit() argument.
538 * If a parent process terminates without waiting for all child processes to terminate,
539 * the remaining child processes are attached to the init process.
[433]540 * WARNING: negative values for the <pid> argument are not supported.
[421]541 ******************************************************************************************
[433]542 * @ searched_pid : searched child process identifier.
543 * @ status       : [out] child termination status.
544 * @ return child PID if success / return -1 if searched PID not found.
[407]545 *****************************************************************************************/
[421]546int sys_wait( uint32_t * status );
[1]547
[407]548/******************************************************************************************
[584]549 * [40] This function implement the non-standard get_config() syscall.
550 * It returns in <x_size>, <y_size>, <ncores> the hardware platform parameters.
[407]551 ******************************************************************************************
552 * @ x_size   : [out] number of clusters in a row.
553 * @ y_size   : [out] number of clusters in a column.
554 * @ ncores   : [out] number of cores per cluster.
555 * @ return 0 if success / return -1 if illegal arguments
556 *****************************************************************************************/
557int sys_get_config( uint32_t * x_size,
558                    uint32_t * y_size,
559                    uint32_t * ncores );
[1]560
[407]561/******************************************************************************************
[637]562 * [41] This function implements the non-standard get_core_id() syscall.
[584]563 * It returns in <cxy> and <lid> the calling core cluster and local index.
[407]564 ******************************************************************************************
565 * @ cxy      : [out] cluster identifier (fixed format)
566 * @ lid      : [out] core local index in cluster.
567 * @ return 0 if success / return -1 if illegal arguments
568 *****************************************************************************************/
[637]569int sys_get_core_id( uint32_t * cxy,
570                     uint32_t * lid );
[1]571
[407]572/******************************************************************************************
[584]573 * [42] This function implements the non-standard get_cycle() syscall.
574 * It returns in a 64 bits user buffer the calling core cycles count.
[407]575 * It uses both the hardware register and the core descriptor cycles count to take
576 * into account a possible harware register overflow  in 32 bits architectures.
577 ******************************************************************************************
578 * cycle    : [out] address of buffer in user space.
579 * @ return 0 if success / return -1 if illegal arguments
580 *****************************************************************************************/
581int sys_get_cycle( uint64_t * cycle );
582
583/******************************************************************************************
[421]584 * [43] This debug function displays on the kernel terminal TXT0 an user defined string,
585 * or the current state of a kernel structure, identified by the <type> argument.
[626]586 * The <arg0>, <arg1>, and <arg2> arguments depends on the structure type.
[407]587 ******************************************************************************************
[435]588 * type      : [in] type of display
[421]589 * arg0      : [in] type dependant argument.
590 * arg1      : [in] type dependant argument.
[611]591 * arg2      : [in] type dependant argument.
[407]592 * @ return 0 if success / return -1 if illegal arguments
593 *****************************************************************************************/
[421]594int sys_display( reg_t  type,
595                 reg_t  arg0,
[611]596                 reg_t  arg1,
597                 reg_t  arg2 );
[407]598
599/******************************************************************************************
[584]600 * [44] This function implements the non-standard place_fork() syscall.
601 * It can be used to specify the target cluster <cxy> for a new process created
602 * by a subsequent fork() syscall.
603 * WARNING: it must be called before each fork() syscall, as the placement specification
604 *          is reset by the fork syscall.
[457]605 ******************************************************************************************
606 * @ cxy    : cluster identifier.
607 * @ return 0 if success / return -1 if failure.
608 *****************************************************************************************/
[584]609int sys_place_fork( uint32_t cxy );
[457]610
611/******************************************************************************************
[407]612 * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition,
613 * and deschedule.
614 ******************************************************************************************
615 * @ return 0 if success / returns -1 if failure.
616 *****************************************************************************************/
[479]617int sys_thread_sleep( void );
[407]618
619/******************************************************************************************
620 * [46] This function unblock the thread identified by its <trdid> from the
621 * THREAD_BLOCKED_GLOBAL condition.
622 ******************************************************************************************
623 * @ trdid  : target thread identifier.
624 * @ return 0 if success / return -1 if failure.
625 *****************************************************************************************/
[506]626int sys_thread_wakeup( trdid_t trdid );
[407]627
[421]628/******************************************************************************************
[443]629 * [47] This debug function is used to activate / desactivate the context switches trace
630 * for a core identified by the <cxy> and <lid> arguments.
[421]631 * It can be called by any other thread in the same process.
632 ******************************************************************************************
[443]633 * @ active     : activate trace if true / desactivate trace if false.
634 * @ cxy        : cluster identifier.
635 * @ lid        : core local index.
[421]636 * @ returns O if success / returns -1 if failure.
637 *****************************************************************************************/
[443]638int sys_trace( bool_t   active,
639               cxy_t    cxy, 
640               lid_t    lid );
[407]641
[421]642/******************************************************************************************
643 * [48] This function gives the process identified by the <pid> argument
644 * the exclusive ownership of its TXT_TX terminal (put it in foreground).
645 ******************************************************************************************
646 * @ pid    : process identifier.
647 * @ return 0 if success / return -1 if failure.
648 *****************************************************************************************/
649int sys_fg( pid_t   pid );
650
[445]651/******************************************************************************************
[457]652 * [49] This function returns a non-zero value in the <is_fg> buffer when the process
653 * identified by the <pid> argument is the current TXT owner.
[445]654 ******************************************************************************************
[457]655 * @ pid      : process identifier.
656 * @ is_fg    : pointer on buffer.
[445]657 * @ return 0 if success / return -1 if failure.
658 *****************************************************************************************/
[457]659int sys_is_fg( pid_t      pid,
660               uint32_t * is_fg );
[421]661
[610]662/******************************************************************************************
[626]663 * [50] This function implements the "exit" system call terminating a POSIX process.
[610]664 * It can be called by any thread running in any cluster.
665 * It uses both remote accesses to access the owner process descriptor, and the
[626]666 * RPC_PROCESS_SIGACTION to delete remote process copies and thread descriptors.
[610]667 * In the present implementation, this function implements actually the _exit():
668 * - it does not flush open output streams.
669 * - it does not close open streams.
670 ******************************************************************************************
[626]671 * @ status   : terminaison status returned to parent process.
672 * @ return 0 if success / return -1 if failure.
[610]673 *****************************************************************************************/
674int sys_exit( uint32_t status );
675
[626]676/******************************************************************************************
677 * [51] This function implements the "sync" system call.
678 * It forces all modified pages in all kernel mappers to be copied to the IOC device.
679 * It can be called by any thread running in any cluster.
680 * TODO not implemented yet.
681 ******************************************************************************************
682 * @ return 0 if success / return -1 if failure.
683 *****************************************************************************************/
684int sys_sync( void );
685
686/******************************************************************************************
687 * [52] This function implements the "fsync" system call.
688 * It forces all modified pages of the file mapper identified by the <fd> argument
689 * to be copied to the IOC device.
690 * It can be called by any thread running in any cluster.
691 * TODO not implemented yet.
692 ******************************************************************************************
693 * @ file_id   : file descriptor index in fd_array.
694 * @ return 0 if success / return -1 if failure.
695 *****************************************************************************************/
696int sys_fsync( uint32_t file_id );
697
[637]698/******************************************************************************************
699 * [53] This function implements the non-standard "get_best_core" syscall.
700 * It selects, in a macro-cluster specified by the <base_cxy> and <level> arguments,
701 * the core that has the lowest load.
702 * When an active core has been found in the target macro-cluster, it writes into the
703 * <cxy> and <lid> buffers the cluster identifier and the core local index, and return 0.
704 * It returns -1 in case of illegal arguments (level / cxy / lid).
705 * It returns +1 if there is no active core in specified macro-cluster.
706 ******************************************************************************************
707 * @ base_cxy : [in]  any cluster identifier in macro-cluster.
708 * @ level    : [in]  macro-cluster level in [1,2,3,4,5].
709 * @ cxy      : [out] selected core cluster identifier.
710 * @ lid      : [out] selected core local index in cluster.
711 * @ return 0 if success / -1 if illegal arguments / +1 if no core in macro-clusters.
712 *****************************************************************************************/
713int sys_get_best_core( uint32_t   base_cxy,
714                       uint32_t   level,
715                       uint32_t * cxy,
716                       uint32_t * lid );
717
718/******************************************************************************************
719 * [54] This function implements the non-standard "get_nb_cores" syscall.
720 * It writes in the <ncores> buffer the number of cores in the target cluster <cxy>.
721 ******************************************************************************************
722 * @ cxy      : [in]  target cluster identifier.
723 * @ ncores   : [out] number of cores / 0 if cluster cxy undefined in architecture.
724 * @ return 0 if success / return -1 if illegal "ncores" arguments.
725 *****************************************************************************************/
726int sys_get_nb_cores( uint32_t   cxy,
727                      uint32_t * ncores );
728
[16]729#endif  // _SYSCALLS_H_
Note: See TracBrowser for help on using the repository browser.