Ignore:
Timestamp:
Nov 7, 2017, 3:08:12 PM (5 years ago)
Author:
alain
Message:

First implementation of fork/exec.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/syscalls.h

    r279 r407  
    11/*
    2  * syscalls.h - kernel services definition
     2 * syscalls.h - Kernel side services for syscall handling.
    33 *
    44 * Author     Alain Greiner (2016,2017)
     
    2626
    2727#include <hal_types.h>
    28 #include <time.h>
    29 
    30 /*****   Forward declarations  *****/
     28#include <shared_syscalls.h>
     29
     30/**   Forward declarations  *****/
    3131
    3232struct thread_s;                  // defined in thread.h
     
    3636struct mmap_attr_s;               // defined in vmm.h
    3737
    38 /******************************************************************************************
    39  * This enum defines the mnemonics for the syscall indexes.
    40  * It must be kept consistent with the array defined in do_syscalls.c
    41  *****************************************************************************************/
    42 enum
    43 {
    44         SYS_THREAD_EXIT    = 0,
    45         SYS_MMAP           = 1,
    46         SYS_THREAD_CREATE  = 2,
    47         SYS_THREAD_JOIN    = 3,
    48         SYS_THREAD_DETACH  = 4,
    49         SYS_THREAD_YIELD   = 5,
    50         SYS_SEM            = 6,
    51         SYS_CONDVAR        = 7,
    52         SYS_BARRIER        = 8,
    53         SYS_MUTEX          = 9,
    54 
    55         SYS_SLEEP          = 10,
    56         SYS_WAKEUP         = 11,
    57         SYS_OPEN           = 12,
    58         SYS_CREAT          = 13,
    59         SYS_READ           = 14,
    60         SYS_WRITE          = 15,
    61         SYS_LSEEK          = 16,
    62         SYS_CLOSE          = 17,
    63         SYS_UNLINK         = 18,   
    64         SYS_PIPE           = 19,
    65 
    66         SYS_CHDIR          = 20,
    67         SYS_MKDIR          = 21,
    68         SYS_MKFIFO         = 22,   
    69         SYS_OPENDIR        = 23,
    70         SYS_READDIR        = 24,
    71         SYS_CLOSEDIR       = 25,
    72         SYS_GETCWD         = 26,
    73         SYS_CLOCK          = 27,
    74         SYS_ALARM          = 28,   
    75         SYS_RMDIR          = 29,
    76 
    77         SYS_UTLS           = 30, 
    78         SYS_CHMOD          = 31,
    79         SYS_SIGNAL         = 32,
    80         SYS_TIMEOFDAY      = 33,
    81         SYS_KILL           = 34,
    82         SYS_GETPID         = 35,
    83         SYS_FORK           = 36,
    84         SYS_EXEC           = 37,
    85         SYS_STAT           = 38,     
    86         SYS_TRACE          = 39,
    87        
    88         SYSCALLS_NR        = 40,
    89 };
    90 
    91 
    92 /********************************************************************************************/
    93 /********************    system calls    ****************************************************/
    94 /********************************************************************************************/
    95 
    96 /*********************************************************************************************
    97  * [0] This function terminates the execution of the calling user thread value,
     38/******************************************************************************************
     39 * [0] This function terminates the execution of the calling user thread,
    9840 * and makes the exit_value pointer available to any successful pthread_join() with the
    9941 * terminating thread.
    100  *********************************************************************************************
    101  * @ exit_vallue  : [out] pointer to to the parrent thread if attached.
    102  * @ return 0 if success / return -1 if failure.
    103  ********************************************************************************************/
     42 ******************************************************************************************
     43 * @ exit_vallue  : pointer to be returned to parent thread if thead is attached.
     44 * @ return 0 if success / return -1 if failure.
     45 *****************************************************************************************/
    10446int sys_thread_exit( void * exit_value );
    10547
    106 /*********************************************************************************************
    107  * [1] This function map physical memory (or a file) in the calling thread virtual space.
    108  * The <attr> argument is a pointer on a structure containing arguments, defined in vmm.h.
    109  * TODO not implemented yet...
    110  *********************************************************************************************
    111  * @ attr       : pointer on attributes structure.
    112  * @ return 0 if success / return -1 if failure.
    113  ********************************************************************************************/
    114 int sys_mmap( struct mmap_attr_s * attr );
    115 
    116 /*********************************************************************************************
     48/******************************************************************************************
     49 * [1] This function calls the scheduler for the core running the calling thread.
     50 ******************************************************************************************
     51 * @ x_size   : [out] number of clusters in a row.
     52 * @ y_size   : [out] number of clusters in a column.
     53 * @ ncores   : [out] number of cores per cluster.
     54 * @ return always 0.
     55 *****************************************************************************************/
     56int sys_thread_yield();
     57
     58/******************************************************************************************
    11759 * [2] This function creates a new user thread. The <user_attr> argument is a pointer
    11860 * on astructure containing the thread attributes, defined in thread.h file.
    119  *********************************************************************************************
     61 ******************************************************************************************
    12062 * @ new_thread  : [out] local pointer on created thread descriptor.
    12163 * @ user_attr   : [in]  pointer on thread attributes structure.
     
    12365 * @ start_args  : [in]  pointer on start function arguments.
    12466 * @ return 0 if success / return -1 if failure.
    125  ********************************************************************************************/
     67 *****************************************************************************************/
    12668int sys_thread_create( struct thread_s        * new_thread,
    12769                       struct pthread_attr_s  * user_attr,
     
    12971                       void                   * start_args );
    13072
    131 /*********************************************************************************************
     73/******************************************************************************************
    13274 * [3] This blocking function suspend execution of the calling thread until completion
    13375 * of another target thread identified by the <trdid> argument.
    13476 * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the
    13577 * target thread is stored in the location referenced by exit_value.
    136  *********************************************************************************************
     78 ******************************************************************************************
    13779 * @ trdid     : [in]  target thread identifier.
    13880 * @ thread    : [out] buffer for exit_value returned by target thread.
    13981 * @ return 0 if success / return -1 if failure.
    140  ********************************************************************************************/
     82 *****************************************************************************************/
    14183int sys_thread_join( trdid_t    trdid,
    14284                     void    ** exit_value );
    14385
    144 /*********************************************************************************************
     86/******************************************************************************************
    14587 * [4] This function detach a joinable thread.
    146  *********************************************************************************************
    147  * @ trdid   : thread identifier.
    148  * @ return 0 if success / return -1 if failure.
    149  ********************************************************************************************/
     88 ******************************************************************************************
     89 * @ trdid   : thread identifier.i
     90 * @ return 0 if success / return -1 if failure.
     91 *****************************************************************************************/
    15092int sys_thread_detach( trdid_t  trdid );
    15193
    152 /*********************************************************************************************
    153  * [5] This function calls the scheduler for the core running the calling thread.
    154  *********************************************************************************************
    155  * @ return always 0.
    156  ********************************************************************************************/
    157 int sys_thread_yield();
    158 
    159 /*********************************************************************************************
     94/******************************************************************************************
     95 * [5] This slot is not used.
     96 *****************************************************************************************/
     97
     98/******************************************************************************************
    16099 * [6] This function implement all operations on a POSIX unnamed semaphore,
    161100 * that can be shared by threads running in different clusters.
    162101 * The kernel structure representing a remote semaphore is in the remote_sem.h file,
    163102 * and the code implementing the operations is in the remore_sem.c file.
    164  *********************************************************************************************
     103 ******************************************************************************************
    165104 * @ vaddr     : semaphore virtual address in user space == identifier.
    166105 * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT.
    167106 * @ value     : pointer on in/out argument in user space.
    168107 * @ return 0 if success / return -1 if failure.
    169  ********************************************************************************************/
     108 *****************************************************************************************/
    170109int sys_sem( void       * vaddr,
    171110             uint32_t     operation,
    172111             uint32_t   * value );
    173112
    174 typedef enum
    175 {
    176         SEM_INIT,
    177         SEM_DESTROY,
    178         SEM_GETVALUE,
    179         SEM_WAIT,
    180         SEM_POST,
    181 }
    182 sem_operation_t;
    183 
    184 /*********************************************************************************************
     113/******************************************************************************************
    185114 * [7] This function implement all operations on a POSIX condition variable.
    186115 * The kernel structure representing a cond_var is defined in the remote_cv.h file,
    187116 * The code implementing the operations is defined in the remote_cv.c file.
    188  *********************************************************************************************
     117 ******************************************************************************************
    189118 * @ vaddr     : condvar virtual address in user space == identifier.
    190119 * @ operation : operation type (see below).
    191120 * @ attr      : mutex virtual address in user space == identifier.
    192121 * @ return 0 if success / return -1 if failure.
    193  ********************************************************************************************/
     122 *****************************************************************************************/
    194123int sys_condvar( void     * condvar,
    195124                 uint32_t   operation,
    196125                 void     * mutex );
    197126
    198 typedef enum
    199 {
    200         CONDVAR_INIT,
    201         CONDVAR_DESTROY,
    202     CONDVAR_WAIT,
    203     CONDVAR_SIGNAL,
    204     CONDVAR_BROADCAST,
    205 }
    206 condvar_operation_t;
    207 
    208 /*********************************************************************************************
     127/******************************************************************************************
    209128 * [8] This function implement all operations on a POSIX barrier.
    210129 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
    211130 * The code implementting the operations is defined in the remote_barrier.c file.
    212  *********************************************************************************************
     131 ******************************************************************************************
    213132 * @ vaddr     : barrier virtual address in user space == identifier.
    214133 * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT.
    215134 * @ count     : number of expected threads (only used by BARRIER_INIT operation).
    216135 * @ return 0 if success / return -1 if failure.
    217  ********************************************************************************************/
     136 *****************************************************************************************/
    218137int sys_barrier( void     * vaddr,
    219138                 uint32_t   operation,
    220139                 uint32_t   count );
    221140
    222 typedef enum
    223 {
    224         BARRIER_INIT,
    225         BARRIER_DESTROY,
    226         BARRIER_WAIT,
    227 }
    228 barrier_operation_t;
    229 
    230 /*********************************************************************************************
     141/******************************************************************************************
    231142 * [9] This function implement all operations on a POSIX mutex.
    232143 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
    233144 * The code implementting the operations is defined in the remote_barrier.c file.
    234  *********************************************************************************************
     145 ******************************************************************************************
    235146 * @ vaddr     : mutex virtual address in user space == identifier.
    236147 * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK
    237148 * @ attr      : mutex attributes (non supported yet => must be 0).
    238149 * @ return 0 if success / return -1 if failure.
    239  ********************************************************************************************/
     150 *****************************************************************************************/
    240151int sys_mutex( void     * vaddr,
    241152               uint32_t   operation,
    242153               uint32_t   count );
    243154
    244 typedef enum
    245 {
    246         MUTEX_INIT,
    247         MUTEX_DESTROY,
    248         MUTEX_LOCK,
    249         MUTEX_UNLOCK,
    250 }
    251 mutex_operation_t;
    252 
    253 /*********************************************************************************************
    254  * [10] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition,
    255  * and deschedule.
    256  *********************************************************************************************
    257  * @ return 0 if success / returns -1 if failure.
    258  ********************************************************************************************/
    259 int sys_thread_sleep();
    260 
    261 /*********************************************************************************************
    262  * [11] This function unblock the thread identified by its <trdid> from the
    263  * THREAD_BLOCKED_GLOBAL condition.
    264  *********************************************************************************************
    265  * @ trdid  : target thread identifier.
    266  * @ return 0 if success / return -1 if failure.
    267  ********************************************************************************************/
    268 int sys_thread_wakeup();
    269 
    270 /*********************************************************************************************
    271  * [12] This function open or create a file.
    272  *********************************************************************************************
     155/******************************************************************************************
     156 * [10] This slot not allocated yet
     157 ******************************************************************************************
     158 * @ return 0 if success / returns -1 if failure.
     159 *****************************************************************************************/
     160
     161/******************************************************************************************
     162 * [11] This function rmove an existing mapping defined by the <addr> and <size>
     163 * arguments in user space.
     164 ******************************************************************************************
     165 * @ addr  : base address in user space.
     166 * # size  : number of bytes.
     167 * @ return 0 if success / return -1 if failure.
     168 *****************************************************************************************/
     169int sys_munmap( void     * addr,
     170                uint32_t   size );
     171
     172/******************************************************************************************
     173 * [12] This function open or create an open file descriptor.
     174 ******************************************************************************************
    273175 * @ pathname   : pathname (can be relative or absolute).
    274176 * @ flags      : bit vector attributes (see below).
    275177 * @ mode       : access rights.
    276178 * @ return file descriptor index in fd_array if success / return -1 if failure.
    277  ********************************************************************************************/
     179 *****************************************************************************************/
    278180int sys_open( char    * pathname,
    279181              uint32_t  flags,
    280182              uint32_t  mode );
    281183
    282 typedef enum
    283 {
    284     O_RDONLY   = 0x0010000,    /*! open file in read-only mode                              */
    285     O_WRONLY   = 0x0020000,    /*! open file in write-only mode                             */
    286     O_RDWR     = 0x0030000,    /*! open file in read/write mode                             */
    287     O_NONBLOCK = 0x0040000,    /*! do not block if data non available                       */
    288     O_APPEND   = 0x0080000,    /*! append on each write                                     */
    289     O_CREAT    = 0x0100000,    /*! create file if it does not exist                         */
    290     O_TRUNC    = 0x0200000,    /*! file length is forced to 0                               */
    291     O_EXCL     = 0x0400000,    /*! error if VFS_O_CREAT and file exist                      */
    292     O_SYNC         = 0x0800000,    /*! synchronize File System on each write                    */
    293     O_CLOEXEC  = 0x1000000,    /*! set the close-on-exec flag in file descriptor            */
    294     O_DIR      = 0x2000000,    /*! new file descriptor is for a directory                   */
    295 }
    296 open_attributes_t;
    297 
    298 /*********************************************************************************************
    299  * [13] This function creates a new file as specified by the arguments.
    300  * This function is obsolete, you should use open() with 0_CREATE.
    301  *********************************************************************************************
    302  * @ pathname   : pathname (can be relative or absolute).
    303  * @ mode       : access rights.
    304  ********************************************************************************************/
    305 int sys_creat( char     * pathname,
    306                uint32_t   mode );
    307 
    308 /*********************************************************************************************
     184/******************************************************************************************
     185 * [13] This function map physical memory (or a file) in the calling thread virtual space.
     186 * The <attr> argument is a pointer on a structure for arguments (see shared_syscalls.h).
     187 ******************************************************************************************
     188 * @ attr       : pointer on attributes structure.
     189 * @ return 0 if success / return -1 if failure.
     190 *****************************************************************************************/
     191int sys_mmap( mmap_attr_t * attr );
     192
     193/******************************************************************************************
    309194 * [14] This function read bytes from an open file identified by its file descriptor.
    310  * This file can be a regular file or character oriented device.
    311  *********************************************************************************************
     195 * The file can be a regular file or character oriented device.
     196 ******************************************************************************************
    312197 * @ file_id  : open file index in fd_array.
    313198 * @ buf      : buffer virtual address in user space.
    314199 * @ count    : number of bytes.
    315200 * @ return number of bytes actually read if success / returns -1 if failure.
    316  ********************************************************************************************/
     201 *****************************************************************************************/
    317202int sys_read( uint32_t   file_id,
    318203              void     * buf,
    319204              uint32_t   count );
    320205
    321 /*********************************************************************************************
     206/******************************************************************************************
    322207 * [15] This function writes bytes to an open file identified by its file descriptor.
    323  * This file can be a regular file or character oriented device.
    324  *********************************************************************************************
     208 * The file can be a regular file or character oriented device.
     209 ******************************************************************************************
    325210 * @ file_id  : open file index in fd_array.
    326211 * @ buf      : buffer virtual address in user space.
    327212 * @ count    : number of bytes.
    328213 * @ return number of bytes actually written if success / returns -1 if failure.
    329  ********************************************************************************************/
     214 *****************************************************************************************/
    330215int sys_write( uint32_t   file_id,
    331216               void     * buf,
    332217               uint32_t   count );
    333218
    334 /*********************************************************************************************
    335  * [16] This function epositions the offset of the file descriptor identified by <file_id>,
    336  * according to the operation type defined by the <whence> and <offset> arguments.
    337  *********************************************************************************************
     219/******************************************************************************************
     220 * [16] This function repositions the offset of the file descriptor identified by <file_id>,
     221 * according to the operation type defined by the <whence> argument.
     222 ******************************************************************************************
    338223 * @ file_id  : open file index in fd_array.
    339  * @ offset   : buffer virtual address in user space.
     224 * @ offset   : used to compute new offset value.
    340225 * @ whence   : operation type (see below).
    341226 * @ return 0 if success / returns -1 if failure.
    342  ********************************************************************************************/
     227 *****************************************************************************************/
    343228int sys_lseek( xptr_t    file_id,
    344229               uint32_t  offset,
    345230               uint32_t  whence );
    346231
    347 typedef enum
    348 {
    349     SEEK_SET  = 0,     /*! new_offset <= offset                                             */
    350     SEEK_CUR  = 1,     /*! new_offset <= current_offset + offset                            */
    351     SEEK_END  = 2,     /*! new_iffset <= current_size + offset                              */
    352 }
    353 lseek_operation_t;
    354 
    355 /*********************************************************************************************
     232/******************************************************************************************
    356233 * [17] This function release the memory allocated for the file descriptor identified by
    357234 * the <file_id> argument, and remove the fd array_entry in all copies of the process
    358235 * descriptor.
    359  *********************************************************************************************
     236 ******************************************************************************************
    360237  file_id   : file descriptor index in fd_array.
    361238 * @ return 0 if success / returns -1 if failure.
    362  ********************************************************************************************/
     239 *****************************************************************************************/
    363240int sys_close( uint32_t file_id );
    364241
    365 /*********************************************************************************************
    366  * [18] This function removes a directory entry identified by the <pathname> from its
     242/******************************************************************************************
     243 * [18] This function removes a directory entry identified by the <pathname> from the
    367244 * directory, and decrement the link count of the file referenced by the link.
    368245 * If the link count reduces to zero, and no process has the file open, then all resources
     
    370247 * the last link is removed, the link is removed, but the removal of the file is delayed
    371248 * until all references to it have been closed.
    372  *********************************************************************************************
    373  * @ pathname   : pathname (can be relative or absolute).
    374  * @ return 0 if success / returns -1 if failure.
    375  ********************************************************************************************/
     249 ******************************************************************************************
     250 * @ pathname   : pathname (can be relative or absolute).
     251 * @ return 0 if success / returns -1 if failure.
     252 *****************************************************************************************/
    376253int sys_unlink( char * pathname );
    377254
    378 /*********************************************************************************************
     255/******************************************************************************************
    379256 * [19] This function creates in the calling thread cluster an unnamed pipe, and two
    380257 * (read and write) file descriptors.
    381  *********************************************************************************************
     258 * TODO not implemented yet...
     259 ******************************************************************************************
    382260 * @ file_id[0] : [out] read only file descriptor index.
    383261 * @ file_id[1] : [out] write only file descriptor index.
    384262 * @ return 0 if success / return -1 if failure.
    385  ********************************************************************************************/
     263 *****************************************************************************************/
    386264int sys_pipe( uint32_t file_id[2] );
    387265
    388 /*********************************************************************************************
     266/******************************************************************************************
    389267 * [20] This function change the current working directory in reference process descriptor.
    390  *********************************************************************************************
    391  * @ pathname   : pathname (can be relative or absolute).
    392  * @ return 0 if success / returns -1 if failure.
    393  ********************************************************************************************/
     268 ******************************************************************************************
     269 * @ pathname   : pathname (can be relative or absolute).
     270 * @ return 0 if success / returns -1 if failure.
     271 *****************************************************************************************/
    394272int sys_chdir( char * pathname );
    395273
    396 /*********************************************************************************************
     274/******************************************************************************************
    397275 * [21] This function creates a new directory in file system.
    398  *********************************************************************************************
     276 ******************************************************************************************
    399277 * @ pathname   : pathname (can be relative or absolute).
    400278 * @ mode       : access rights (as defined in chmod).
    401279 * @ return 0 if success / returns -1 if failure.
    402  ********************************************************************************************/
     280 *****************************************************************************************/
    403281int sys_mkdir( char    * pathname,
    404282               uint32_t  mode );
    405283
    406 /*********************************************************************************************
     284/******************************************************************************************
    407285 * [22] This function creates a named FIFO file in the calling thread cluster.
    408286 * The associated read and write file descriptors mut be be  explicitely created
    409  * using the sy_open() function.
    410  *********************************************************************************************
     287 * using the sys_open() function.
     288 ******************************************************************************************
    411289 * @ pathname   : pathname (can be relative or absolute).
    412290 * @ mode       : access rights (as defined in chmod).
    413291 * @ return 0 if success / returns -1 if failure.
    414  ********************************************************************************************/
     292 *****************************************************************************************/
    415293int sys_mkfifo( char     * pathname,
    416294                uint32_t   mode );
    417295
    418 /*********************************************************************************************
    419  * [23] This function open a directory, that must exist in the file system.
    420  *********************************************************************************************
    421  * @ pathname   : pathname (can be relative or absolute).
    422  * @ return file descriptor index in fd_array if success / return -1 if failure.
    423  ********************************************************************************************/
    424 int sys_opendir( char * pathname );
    425 
    426 /*********************************************************************************************
    427  * [24] This function returns in the structure pointed by the <dirent> argument various
    428  * information about an entry of the directory identified by the <file_id> argument.
    429  *********************************************************************************************
    430  * @ file_id   : file descriptor index of the searched directory.
    431  * @ dirent    : pointer on a dirent structure in user space.
    432  * @ return 0 if success / returns -1 if failure.
    433  ********************************************************************************************/
    434 int sys_readdir( uint32_t              file_id,
    435                  struct vfs_dirent_s * dirent );
    436 
    437 /*********************************************************************************************
    438  * [25] This function close the file descriptor previouly open by the opendir() function.
    439  *********************************************************************************************
    440  * @ file_id   : file descriptor index of the searched directory.
    441  * @ return 0 if success / returns -1 if failure.
    442  ********************************************************************************************/
    443 int sys_closedir( uint32_t file_id );
    444 
    445 /*********************************************************************************************
     296/******************************************************************************************
     297 * [23] This function open a directory, that must exist in the file system, returning
     298 * a DIR pointer on the directory in user space.
     299 ******************************************************************************************
     300 * @ pathname   : pathname (can be relative or absolute).
     301 * @ dirp       : [out] buffer for pointer on user directory (DIR).
     302 * @ return 0 if success / returns -1 if failure.
     303 *****************************************************************************************/
     304int sys_opendir( char * pathname,
     305                 DIR ** dirp );
     306
     307/******************************************************************************************
     308 * [24] This function returns an user pointer on the dirent structure describing the
     309 * next directory entry in the directory identified by the <dirp> argument.
     310 ******************************************************************************************
     311 * @ dirp     : user pointer identifying the searched directory.
     312 * @ dentp    : [out] buffer for pointer on user direntory entry (dirent).
     313 * @ return O if success / returns -1 if failure.
     314 *****************************************************************************************/
     315int sys_readdir( DIR            * dirp,
     316                 struct dirent ** dentp );
     317
     318/******************************************************************************************
     319 * [25] This function closes the directory identified by the <dirp> argument, and releases
     320 * all structures associated with the <dirp> pointer.
     321 ******************************************************************************************
     322 * @ dirp     : user pointer identifying the directory.
     323 * @ return 0 if success / returns -1 if failure.
     324 *****************************************************************************************/
     325int sys_closedir( DIR * dirp );
     326
     327/******************************************************************************************
    446328 * [26] This function returns the pathname of the current working directory.
    447  *********************************************************************************************
     329 ******************************************************************************************
    448330 * buf     : buffer addres in user space.
    449331 * nbytes  : user buffer size in bytes.
    450332 * @ return 0 if success / returns -1 if failure.
    451  ********************************************************************************************/
     333 *****************************************************************************************/
    452334int sys_getcwd( char     * buf,
    453335                uint32_t   nbytes );
    454336
    455 /*********************************************************************************************
    456  * [27] This function returns in a 64 bits user buffer the calling core cycles count.
    457  * It uses both the hardware register and the core descriptor cycles count tos take
    458  * into account a possible harware register overflow  in 32 bits architectures.
    459  *********************************************************************************************
    460  * cyles    : [out] address of buffer in user space.
    461  ********************************************************************************************/
    462 int sys_clock( uint64_t * cycles );
    463 
    464 /*********************************************************************************************
     337/******************************************************************************************
     338 * [27] This slot is not used.
     339 *****************************************************************************************/
     340
     341/******************************************************************************************
    465342 * [28] This function forces the calling thread to sleep, for a fixed number of cycles.
    466  *********************************************************************************************
     343 ******************************************************************************************
    467344 * cycles   : number of cycles.
    468  ********************************************************************************************/
     345 *****************************************************************************************/
    469346int sys_alarm( uint32_t cycles );
    470347
    471 /*********************************************************************************************
    472  * [29] This undefined function does nothing.
    473  *********************************************************************************************
    474  * @ pathname   : pathname (can be relative or absolute).
    475  * @ return 0 if success / returns -1 if failure.
    476  ********************************************************************************************/
     348/******************************************************************************************
     349 * [29] This function removes a directory file whose name is given by <pathname>.
     350 * The directory must not have any entries other than `.' and `..'.
     351 ******************************************************************************************
     352 * @ pathname   : pathname (can be relative or absolute).
     353 * @ return 0 if success / returns -1 if failure.
     354 *****************************************************************************************/
    477355int sys_rmdir( char * pathname );
    478356
    479 /*********************************************************************************************
     357/******************************************************************************************
    480358 * [30] This function implement the operations related to User Thread Local Storage.
    481359 * It is actually implemented as an uint32_t variable in the thread descriptor.
    482  *********************************************************************************************
     360 ******************************************************************************************
    483361 * @ operation  : UTLS operation type as defined below.
    484362 * @ value      : argument value for the UTLS_SET operation.
    485363 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
    486  ********************************************************************************************/
     364 *****************************************************************************************/
    487365int sys_utls( uint32_t operation,
    488366              uint32_t value );
    489367
    490 typedef enum
    491 {
    492     UTLS_SET       = 1,
    493     UTLS_GET       = 2,
    494     UTLS_GET_ERRNO = 3,
    495 }
    496 utls_operation_t;
    497 
    498 /*********************************************************************************************
     368/******************************************************************************************
    499369 * [31] This function change the acces rights for the file/dir identified by the
    500370 * pathname argument.
    501  *********************************************************************************************
     371 ******************************************************************************************
    502372 * @ pathname   : pathname (can be relative or absolute).
    503373 * @ rights     : acces rights.
    504374 * @ return 0 if success / returns -1 if failure.
    505  ********************************************************************************************/
     375 *****************************************************************************************/
    506376int sys_chmod( char     * pathname,
    507377               uint32_t   rights );
    508378
    509 /*********************************************************************************************
     379/******************************************************************************************
    510380 * [32] This function associate a specific signal handler to a given signal type.
    511381 * Tee handlers for the SIGKILL and SIGSTOP signals cannot be redefined.
    512  *********************************************************************************************
     382 ******************************************************************************************
    513383 * @ sig_id    : index defining signal type (from 1 to 31).
    514384 * @ handler   : pointer on fonction implementing the specific handler.
    515385 * @ return 0 if success / returns -1 if failure.
    516  ********************************************************************************************/
     386 *****************************************************************************************/
    517387int sys_signal( uint32_t   sig_id,
    518388                void     * handler );
    519389
    520 /*********************************************************************************************
     390/******************************************************************************************
    521391 * [33] This function returns in the structure <tv>, defined in the time.h file,
    522392 * the current time (in seconds & micro-seconds).
    523393 * It is computed from the calling core descriptor.
    524394 * The timezone is not supported.
    525  *********************************************************************************************
     395 ******************************************************************************************
    526396 * @ tv      : pointer on the timeval structure.
    527397 * @ tz      : pointer on the timezone structure : must be NULL.       
    528398 * @ return 0 if success / returns -1 if failure.
    529  ********************************************************************************************/
     399 *****************************************************************************************/
    530400int sys_timeofday( struct timeval  * tv,
    531401                   struct timezone * tz );
    532402
    533 /*********************************************************************************************
     403/******************************************************************************************
    534404 * [34] This function implements the "kill" system call.
    535405 * It register the signal defined by the <sig_id> argument in all thread descriptors
     
    537407 * containing threads for the target process.
    538408 * It can be executed by any thread running in any cluster, as this function uses
    539  * remote access to traverse the list of process copies in the owner cluster,
     409 * remote access to traverse the list of process copies stored in the owner cluster,
    540410 * and the RPC_SIGNAL_RISE to signal the remote threads.
    541  *********************************************************************************************
     411 ******************************************************************************************
    542412 * @ pid      : target process identifier.
    543413 * @ sig_id   : index defining the signal type (from 1 to 31).
    544414 * @ return 0 if success / returns -1 if failure.
    545  ********************************************************************************************/
     415 *****************************************************************************************/
    546416int sys_kill( pid_t    pid,
    547417              uint32_t sig_id );
    548418
    549 /*********************************************************************************************
     419/******************************************************************************************
    550420 * [35] This function implements the "getpid" system call.
    551  *********************************************************************************************
    552  * @ returns the PID for the calling thread.
    553  ********************************************************************************************/
     421 ******************************************************************************************
     422 * @ returns the process PID for the calling thread.
     423 *****************************************************************************************/
    554424int sys_getpid();
    555425
    556 /*********************************************************************************************
     426/******************************************************************************************
    557427 * [36] This function implement the "fork" system call.
    558428 * The calling process descriptor (parent process), and the associated thread descriptor are
     
    560430 * is registered in another target cluster, that is the new process owner.
    561431 * The child process and the associated main thread will be migrated to the target cluster
    562  * later, when the child process makes an "exec" or any other system call. 
     432 * later, when the child process makes an "exec" or any other system call... TODO [AG]
    563433 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be
    564434 * stored in the calling thread descriptor by the specific fork_place() system call.
    565435 * If not, the sys_fork() function makes a query to the DQDT to select the target cluster.
    566  *********************************************************************************************
    567  * @ returns child process PID if success / returns -1 if failure
    568  ********************************************************************************************/
     436 ******************************************************************************************
     437 * @ if success, returns child process PID to parent, and return O to child.
     438 * @ if failure, returns -1 to parent / no child process is created.
     439 *****************************************************************************************/
    569440int sys_fork();
    570441
    571 /*********************************************************************************************
    572  * [37] This function implement the "exec" system call.
    573  * It is executed in the client cluster, but the new process descriptor and main thread
    574  * must be created in a server cluster, that is generally another cluster.
    575  * - if the server_cluster is the client cluster, call directly the process_make_exec()
     442/******************************************************************************************
     443 * [37] This function implement the "exec" system call, that creates a new process
     444 * descriptor.
     445 * It is executed in the client cluster, but the new process descriptor and the main
     446 * thread are created in a server cluster, that is generally another cluster.
     447 * - if the server_cluster is the client cluster, it calls directly the process_make_exec()
    576448 *   function to create a new process, and launch a new thread in local cluster.
    577  * - if the target_cluster is remote, call rpc_process_exec_client() to execute the
    578  *   process_make_exec() on the remote cluster.
     449 * - if the target_cluster is remote, it calls the rpc_process_exec_client() to execute
     450 *   process_signedmake_exec() on the remote cluster.
    579451 * In both case this function build an exec_info_t structure containing all informations
    580452 * required to build the new process descriptor and the associated thread.
    581453 * Finally, the calling process and thread are deleted.
    582  *********************************************************************************************
    583  * @ filename : string pointer on .elf filename (virtual pointer in user space)
    584  * @ argv     : array of strings on process arguments (virtual pointers in user space)
    585  * @ envp     : array of strings on Renvironment variables (virtual pointers in user space)
     454 ******************************************************************************************
     455 * @ filename : string pointer on .elf filename (pointer in user space)
     456 * @ argv     : array of strings on process arguments (pointers in user space)
     457 * @ envp     : array of strings on environment variables (pointers in user space)
    586458 * @ returns O if success / returns -1 if failure.
    587  ********************************************************************************************/
     459 *****************************************************************************************/
    588460int sys_exec( char  * filename,
    589461              char ** argv,
    590462              char ** envp );
    591463
    592 /*********************************************************************************************
    593  * [38] This function  returns in the <stat> structure, defined in the vfs.h file,
    594  * various informations on the file/directory identified by the <file_id> argument.
    595  *********************************************************************************************
    596  * @ file_id   : file descriptor index in fd_array.
    597  * @ stat      : pointer on the stat structure.
     464/******************************************************************************************
     465 * [38] This function  returns in the <stat> structure, defined in the "shared_syscalls.h"
     466 * file, various informations on the file/directory identified by the <pathname> argument.
     467 ******************************************************************************************
     468 * @ pathname  : user pointer on file pathname.
     469 * @ stat      : user pointer on the stat structure.
    598470 * @ returns O if success / returns -1 if failure.
    599  ********************************************************************************************/
    600 int sys_stat( uint32_t            file_id,
    601               struct vfs_stat_s * stat );
    602 
    603 /*********************************************************************************************
    604  * [39] This function is used to activate / desactivate Rthe trace for a thread
     471 *****************************************************************************************/
     472int sys_stat( const char  * pathname,
     473              struct stat * stat );
     474
     475/******************************************************************************************
     476 * [39] This non-standard function is used to activate / desactivate the trace for a thread
    605477 * identified by the <trdid> and <pid> arguments.
    606  * It can be called by any other thread.
    607  *********************************************************************************************
     478 * It can be called by any other thread in the same process.
     479 ******************************************************************************************
    608480 * @ operation  : operation type as defined below.
    609481 * @ pid        : process identifier.
    610482 * @ trdid      : thread identifier.
    611483 * @ returns O if success / returns -1 if failure.
    612  ********************************************************************************************/
     484 *****************************************************************************************/
    613485int sys_trace( uint32_t operation,
    614486               pid_t    pid,
    615487               uint32_t trdid );
    616488
    617 typedef enum
    618 {
    619     TRACE_ON       = 0,
    620     TRACE_OFF      = 1,
    621 }
    622 trace_operation_t;
     489/******************************************************************************************
     490 * [40] This function returns the hardware platform parameters.
     491 ******************************************************************************************
     492 * @ x_size   : [out] number of clusters in a row.
     493 * @ y_size   : [out] number of clusters in a column.
     494 * @ ncores   : [out] number of cores per cluster.
     495 * @ return 0 if success / return -1 if illegal arguments
     496 *****************************************************************************************/
     497int sys_get_config( uint32_t * x_size,
     498                    uint32_t * y_size,
     499                    uint32_t * ncores );
     500
     501/******************************************************************************************
     502 * [41] This function returns the calling core cluster and local index.
     503 ******************************************************************************************
     504 * @ cxy      : [out] cluster identifier (fixed format)
     505 * @ lid      : [out] core local index in cluster.
     506 * @ return 0 if success / return -1 if illegal arguments
     507 *****************************************************************************************/
     508int sys_get_core( uint32_t * cxy,
     509                  uint32_t * lid );
     510
     511/******************************************************************************************
     512 * [42] This function returns in a 64 bits user buffer the calling core cycles count.
     513 * It uses both the hardware register and the core descriptor cycles count to take
     514 * into account a possible harware register overflow  in 32 bits architectures.
     515 ******************************************************************************************
     516 * cycle    : [out] address of buffer in user space.
     517 * @ return 0 if success / return -1 if illegal arguments
     518 *****************************************************************************************/
     519int sys_get_cycle( uint64_t * cycle );
     520
     521/******************************************************************************************
     522 * [43] This debug function displays on the kernel terminal the current state of a
     523 * scheduler identified by the <cxy> and <lid> arguments.
     524 ******************************************************************************************
     525 * cxy      : [in] target cluster identifier.
     526 * lid      : [in] target core local index.
     527 * @ return 0 if success / return -1 if illegal arguments
     528 *****************************************************************************************/
     529int sys_get_sched( uint32_t  cxy,
     530                   uint32_t  lid );
     531
     532/******************************************************************************************
     533 * [44] This debug function requires the kernel to display on the kernel terminal a message
     534 * containing the thread / process / core identifiers, and the cause of panic,
     535 * as defined by the <string> argument.
     536 ******************************************************************************************
     537 * string   : [in] message to be displayed.
     538 * @ return always 0.
     539 *****************************************************************************************/
     540int sys_panic( char * string );
     541
     542/******************************************************************************************
     543 * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition,
     544 * and deschedule.
     545 ******************************************************************************************
     546 * @ return 0 if success / returns -1 if failure.
     547 *****************************************************************************************/
     548int sys_thread_sleep();
     549
     550/******************************************************************************************
     551 * [46] This function unblock the thread identified by its <trdid> from the
     552 * THREAD_BLOCKED_GLOBAL condition.
     553 ******************************************************************************************
     554 * @ trdid  : target thread identifier.
     555 * @ return 0 if success / return -1 if failure.
     556 *****************************************************************************************/
     557int sys_thread_wakeup();
    623558
    624559
Note: See TracChangeset for help on using the changeset viewer.