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

Last change on this file since 508 was 506, checked in by viala@…, 6 years ago

[syscalls] add interface in implementation.

Add const where possible, fix protoypes to follow interface.

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