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

Last change on this file since 663 was 657, checked in by alain, 5 years ago

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

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