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

Last change on this file since 642 was 642, checked in by alain, 3 years ago

Introduce two new syscalls : sys_get_thread_info() / sys_fbf()

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