Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (7 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

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

    r16 r23  
    22 * syscalls.h - kernel services definition
    33 *
    4  * Author  Ghassan Almaless (2007,2008,2009,2010,2011,2012)
    5  *         Alain Greiner    (2016)
     4 * Author     Alain Greiner (2016,2017)
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    2625#define _SYSCALLS_H_
    2726
     27#include <hal_types.h>
     28#include <time.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
    2838/******************************************************************************************
    2939 * This enum defines the mnemonics for the syscall indexes.
     
    3242enum
    3343{
    34         SYS_EXIT,          /* 0  */
    35         SYS_MMAP,          /* 1  */
    36         SYS_CREATE,        /* 2  */
    37         SYS_JOIN,          /* 3  */
    38         SYS_DETACH,        /* 4  */
    39         SYS_YIELD,         /* 5  */
    40         SYS_SEMAPHORE,     /* 6  */
    41         SYS_COND_VAR,      /* 7  */
    42         SYS_BARRIER,       /* 8  */
    43         SYS_RWLOCK,        /* 9  */
    44         SYS_SLEEP,         /* 10 */
    45         SYS_WAKEUP,        /* 11 */
    46         SYS_OPEN,          /* 12 */
    47         SYS_CREAT,         /* 13 */
    48         SYS_READ,          /* 14 */
    49         SYS_WRITE,         /* 15 */
    50         SYS_LSEEK,         /* 16 */
    51         SYS_CLOSE,         /* 17 */
    52         SYS_UNLINK,        /* 18 */   
    53         SYS_PIPE,          /* 19 */
    54         SYS_CHDIR,         /* 20 */
    55         SYS_MKDIR,         /* 21 */
    56         SYS_MKFIFO,        /* 22 */   
    57         SYS_OPENDIR,       /* 23 */
    58         SYS_READDIR,       /* 24 */
    59         SYS_CLOSEDIR,      /* 25 */
    60         SYS_GETCWD,        /* 26 */
    61         SYS_CLOCK,         /* 27 */
    62         SYS_ALARM,         /* 28 */   
    63         SYS_DMA_MEMCPY,    /* 29 */
    64         SYS_UTLS,          /* 30 */ 
    65         SYS_SIGRETURN,     /* 31 */
    66         SYS_SIGNAL,        /* 32 */
    67         SYS_SET_SIGRETURN, /* 33 */
    68         SYS_KILL,          /* 34 */
    69         SYS_GETPID,        /* 35 */
    70         SYS_FORK,          /* 36 */
    71         SYS_EXEC,          /* 37 */
    72         SYS_GETATTR,       /* 38 */     
    73         SYS_PS,            /* 39 */
    74         SYS_MADVISE,       /* 40 */   
    75         SYS_PAGEINFO,      /* 41 */
    76         SYS_STAT,          /* 42 */
    77         SYS_MIGRATE,       /* 43 */
    78         SYS_SBRK,          /* 44 */
    79         SYS_RMDIR,         /* 45 */
    80         SYS_FTIME,         /* 46 */
    81         SYS_CHMOD,         /* 47 */
    82         SYS_FSYNC,         /* 48 */
    83         SYS_GET_TOD,       /* 49 */
    84         SYS_TIMES,         /* 50 */
    85         SYSCALLS_NR,
     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,
    8689};
    8790
     91
    8892/********************************************************************************************/
    89 /********************   Process related system calls  ***************************************/
     93/********************    system calls    ****************************************************/
    9094/********************************************************************************************/
    9195
    92 
    93 /*********************************************************************************************
    94  * [0] This function TODO
    95  ********************************************************************************************/
    96 int sys_thread_exit( void * );
    97 
    98 /*********************************************************************************************
    99  * [1] This function TODO
    100  ********************************************************************************************/
    101 int sys_mmap();
    102 
    103 /*********************************************************************************************
    104  * [2] This function TODO
    105  ********************************************************************************************/
    106 int sys_thread_create();
    107 
    108 /*********************************************************************************************
    109  * [3] This function TODO
    110  ********************************************************************************************/
    111 int sys_thread_join();
    112 
    113 /*********************************************************************************************
    114  * [4] This function TODO
    115  ********************************************************************************************/
    116 int sys_thread_detach();
    117 
    118 /*********************************************************************************************
    119  * [5] This function TODO
     96/*********************************************************************************************
     97 * [0] This function terminates the execution of the calling user thread value,
     98 * and makes the exit_value pointer available to any successful pthread_join() with the
     99 * 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 ********************************************************************************************/
     104int sys_thread_exit( void * exit_value );
     105
     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 ********************************************************************************************/
     114int sys_mmap( struct mmap_attr_s * attr );
     115
     116/*********************************************************************************************
     117 * [2] This function creates a new user thread. The <user_attr> argument is a pointer
     118 * on astructure containing the thread attributes, defined in thread.h file.
     119 *********************************************************************************************
     120 * @ new_thread  : [out] local pointer on created thread descriptor.
     121 * @ user_attr   : [in]  pointer on thread attributes structure.
     122 * @ start_func  : [in]  pointer on start function.
     123 * @ start_args  : [in]  pointer on start function arguments.
     124 * @ return 0 if success / return -1 if failure.
     125 ********************************************************************************************/
     126int sys_thread_create( struct thread_s        * new_thread,
     127                       struct pthread_attr_s  * user_attr,
     128                       void                   * start_func,
     129                       void                   * start_args );
     130
     131/*********************************************************************************************
     132 * [3] This blocking function suspend execution of the calling thread until completion
     133 * of another target thread identified by the <trdid> argument.
     134 * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the
     135 * target thread is stored in the location referenced by exit_value.
     136 *********************************************************************************************
     137 * @ trdid     : [in]  target thread identifier.
     138 * @ thread    : [out] buffer for exit_value returned by target thread.
     139 * @ return 0 if success / return -1 if failure.
     140 ********************************************************************************************/
     141int sys_thread_join( trdid_t    trdid,
     142                     void    ** exit_value );
     143
     144/*********************************************************************************************
     145 * [4] This function detach a joinable thread.
     146 *********************************************************************************************
     147 * @ trdid   : thread identifier.
     148 * @ return 0 if success / return -1 if failure.
     149 ********************************************************************************************/
     150int sys_thread_detach( trdid_t  trdid );
     151
     152/*********************************************************************************************
     153 * [5] This function calls the scheduler for the core running the calling thread.
     154 *********************************************************************************************
     155 * @ return always 0.
    120156 ********************************************************************************************/
    121157int sys_thread_yield();
    122158
    123159/*********************************************************************************************
    124  * [6] This function TODO
    125  ********************************************************************************************/
    126 int sys_sem();
    127 
    128 /*********************************************************************************************
    129  * [7] This function TODO
    130  ********************************************************************************************/
    131 int sys_cond_var();
    132 
    133 /*********************************************************************************************
    134  * [8] This function TODO
    135  ********************************************************************************************/
    136 int sys_barrier();
    137 
    138 /*********************************************************************************************
    139  * [9] This function TODO
    140  ********************************************************************************************/
    141 int sys_rwlock();
    142 
    143 /*********************************************************************************************
    144  * [10] This function TODO
     160 * [6] This function implement all operations on a POSIX unnamed semaphore,
     161 * that can be shared by threads running in different clusters.
     162 * The kernel structure representing a remote semaphore is in the remote_sem.h file,
     163 * and the code implementing the operations is in the remore_sem.c file.
     164 *********************************************************************************************
     165 * @ vaddr     : semaphore virtual address in user space == identifier.
     166 * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT.
     167 * @ value     : pointer on in/out argument in user space.
     168 * @ return 0 if success / return -1 if failure.
     169 ********************************************************************************************/
     170int sys_sem( void       * vaddr,
     171             uint32_t     operation,
     172             uint32_t   * value );
     173
     174typedef enum
     175{
     176        SEM_INIT,
     177        SEM_DESTROY,
     178        SEM_GETVALUE,
     179        SEM_WAIT,
     180        SEM_POST,
     181}
     182sem_operation_t;
     183
     184/*********************************************************************************************
     185 * [7] This function implement all operations on a POSIX condition variable.
     186 * The kernel structure representing a cond_var is defined in the remote_cv.h file,
     187 * The code implementing the operations is defined in the remote_cv.c file.
     188 *********************************************************************************************
     189 * @ vaddr     : condvar virtual address in user space == identifier.
     190 * @ operation : operation type (see below).
     191 * @ attr      : mutex virtual address in user space == identifier.
     192 * @ return 0 if success / return -1 if failure.
     193 ********************************************************************************************/
     194int sys_condvar( void     * condvar,
     195                 uint32_t   operation,
     196                 void     * mutex );
     197
     198typedef enum
     199{
     200        CONDVAR_INIT,
     201        CONDVAR_DESTROY,
     202    CONDVAR_WAIT,
     203    CONDVAR_SIGNAL,
     204    CONDVAR_BROADCAST,
     205}
     206condvar_operation_t;
     207
     208/*********************************************************************************************
     209 * [8] This function implement all operations on a POSIX barrier.
     210 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
     211 * The code implementting the operations is defined in the remote_barrier.c file.
     212 *********************************************************************************************
     213 * @ vaddr     : barrier virtual address in user space == identifier.
     214 * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT.
     215 * @ count     : number of expected threads (only used by BARRIER_INIT operation).
     216 * @ return 0 if success / return -1 if failure.
     217 ********************************************************************************************/
     218int sys_barrier( void     * vaddr,
     219                 uint32_t   operation,
     220                 uint32_t   count );
     221
     222typedef enum
     223{
     224        BARRIER_INIT,
     225        BARRIER_DESTROY,
     226        BARRIER_WAIT,
     227}
     228barrier_operation_t;
     229
     230/*********************************************************************************************
     231 * [9] This function implement all operations on a POSIX mutex.
     232 * The kernel structure representing a barrier is defined in the remote_barrier.h file.
     233 * The code implementting the operations is defined in the remote_barrier.c file.
     234 *********************************************************************************************
     235 * @ vaddr     : mutex virtual address in user space == identifier.
     236 * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK
     237 * @ attr      : mutex attributes (non supported yet => must be 0).
     238 * @ return 0 if success / return -1 if failure.
     239 ********************************************************************************************/
     240int sys_mutex( void     * vaddr,
     241               uint32_t   operation,
     242               uint32_t   count );
     243
     244typedef enum
     245{
     246        MUTEX_INIT,
     247        MUTEX_DESTROY,
     248        MUTEX_LOCK,
     249        MUTEX_UNLOCK,
     250}
     251mutex_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.
    145258 ********************************************************************************************/
    146259int sys_thread_sleep();
    147260
    148261/*********************************************************************************************
    149  * [11] This function TODO
     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.
    150267 ********************************************************************************************/
    151268int sys_thread_wakeup();
    152269
    153270/*********************************************************************************************
    154  * [12] This function TODO
    155  ********************************************************************************************/
    156 int sys_open();
    157 
    158 /*********************************************************************************************
    159  * [13] This function TODO
    160  ********************************************************************************************/
    161 int sys_creat();
    162 
    163 /*********************************************************************************************
    164  * [14] This function TODO
    165  ********************************************************************************************/
    166 int sys_read();
    167 
    168 /*********************************************************************************************
    169  * [15] This function TODO
    170  ********************************************************************************************/
    171 int sys_write();
    172 
    173 /*********************************************************************************************
    174  * [16] This function TODO
    175  ********************************************************************************************/
    176 int sys_lseek();
    177 
    178 /*********************************************************************************************
    179  * [17] This function TODO
    180  ********************************************************************************************/
    181 int sys_close();
    182 
    183 /*********************************************************************************************
    184  * [18] This function TODO
    185  ********************************************************************************************/
    186 int sys_unlink();
    187 
    188 /*********************************************************************************************
    189  * [19] This function TODO
    190  ********************************************************************************************/
    191 int sys_pipe();
    192 
    193 /*********************************************************************************************
    194  * [20] This function TODO
    195  ********************************************************************************************/
    196 int sys_chdir();
    197 
    198 /*********************************************************************************************
    199  * [21] This function TODO
    200  ********************************************************************************************/
    201 int sys_mkdir();
    202 
    203 /*********************************************************************************************
    204  * [22] This function TODO
    205  ********************************************************************************************/
    206 int sys_mkfifo();
    207 
    208 /*********************************************************************************************
    209  * [23] This function TODO
    210  ********************************************************************************************/
    211 int sys_opendir();
    212 
    213 /*********************************************************************************************
    214  * [24] This function TODO
    215  ********************************************************************************************/
    216 int sys_readdir();
    217 
    218 /*********************************************************************************************
    219  * [25] This function TODO
    220  ********************************************************************************************/
    221 int sys_closedir();
    222 
    223 /*********************************************************************************************
    224  * [26] This function TODO
    225  ********************************************************************************************/
    226 int sys_getcwd();
    227 
    228 /*********************************************************************************************
    229  * [27] This function TODO
    230  ********************************************************************************************/
    231 int sys_clock();
    232 
    233 /*********************************************************************************************
    234  * [28] This function TODO
    235  ********************************************************************************************/
    236 int sys_alarm();
    237 
    238 /*********************************************************************************************
    239  * [29] This function TODO
    240  ********************************************************************************************/
    241 int sys_dma_memcpy();
    242 
    243 /*********************************************************************************************
    244  * [30] This function TODO
    245  ********************************************************************************************/
    246 int sys_utls();
    247 
    248 /*********************************************************************************************
    249  * [31] This function TODO
    250  ********************************************************************************************/
    251 int sys_notAvailable();
    252 
    253 /*********************************************************************************************
    254  * [32] This function TODO
    255  ********************************************************************************************/
    256 int sys_signal();
    257 
    258 /*********************************************************************************************
    259  * [33] This function TODO
    260  ********************************************************************************************/
    261 int sys_sigreturn_setup();
     271 * [12] This function open or create a file.
     272 *********************************************************************************************
     273 * @ pathname   : pathname (can be relative or absolute).
     274 * @ flags      : bit vector attributes (see below).
     275 * @ mode       : access rights.
     276 * @ return file descriptor index in fd_array if success / return -1 if failure.
     277 ********************************************************************************************/
     278int sys_open( char    * pathname,
     279              uint32_t  flags,
     280              uint32_t  mode );
     281
     282typedef 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}
     296open_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 ********************************************************************************************/
     305int sys_creat( char     * pathname,
     306               uint32_t   mode );
     307
     308/*********************************************************************************************
     309 * [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 *********************************************************************************************
     312 * @ file_id  : open file index in fd_array.
     313 * @ buf      : buffer virtual address in user space.
     314 * @ count    : number of bytes.
     315 * @ return number of bytes actually read if success / returns -1 if failure.
     316 ********************************************************************************************/
     317int sys_read( uint32_t   file_id,
     318              void     * buf,
     319              uint32_t   count );
     320
     321/*********************************************************************************************
     322 * [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 *********************************************************************************************
     325 * @ file_id  : open file index in fd_array.
     326 * @ buf      : buffer virtual address in user space.
     327 * @ count    : number of bytes.
     328 * @ return number of bytes actually written if success / returns -1 if failure.
     329 ********************************************************************************************/
     330int sys_write( uint32_t   file_id,
     331               void     * buf,
     332               uint32_t   count );
     333
     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 *********************************************************************************************
     338 * @ file_id  : open file index in fd_array.
     339 * @ offset   : buffer virtual address in user space.
     340 * @ whence   : operation type (see below).
     341 * @ return 0 if success / returns -1 if failure.
     342 ********************************************************************************************/
     343int sys_lseek( xptr_t    file_id,
     344               uint32_t  offset,
     345               uint32_t  whence );
     346
     347typedef 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}
     353lseek_operation_t;
     354
     355/*********************************************************************************************
     356 * [17] This function release the memory allocated for the file descriptor identified by
     357 * the <file_id> argument, and remove the fd array_entry in all copies of the process
     358 * descriptor.
     359 *********************************************************************************************
     360  file_id   : file descriptor index in fd_array.
     361 * @ return 0 if success / returns -1 if failure.
     362 ********************************************************************************************/
     363int sys_close( uint32_t file_id );
     364
     365/*********************************************************************************************
     366 * [18] This function removes a directory entry identified by the <pathname> from its
     367 * directory, and decrement the link count of the file referenced by the link.
     368 * If the link count reduces to zero, and no process has the file open, then all resources
     369 * associated with the file are reclaimed.  If one or more process have the file open when
     370 * the last link is removed, the link is removed, but the removal of the file is delayed
     371 * 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 ********************************************************************************************/
     376int sys_unlink( char * pathname );
     377
     378/*********************************************************************************************
     379 * [19] This function creates in the calling thread cluster an unnamed pipe, and two
     380 * (read and write) file descriptors.
     381 *********************************************************************************************
     382 * @ file_id[0] : [out] read only file descriptor index.
     383 * @ file_id[1] : [out] write only file descriptor index.
     384 * @ return 0 if success / return -1 if failure.
     385 ********************************************************************************************/
     386int sys_pipe( uint32_t file_id[2] );
     387
     388/*********************************************************************************************
     389 * [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 ********************************************************************************************/
     394int sys_chdir( char * pathname );
     395
     396/*********************************************************************************************
     397 * [21] This function creates a new directory in file system.
     398 *********************************************************************************************
     399 * @ pathname   : pathname (can be relative or absolute).
     400 * @ mode       : access rights (as defined in chmod).
     401 * @ return 0 if success / returns -1 if failure.
     402 ********************************************************************************************/
     403int sys_mkdir( char      pathname,
     404               uint32_t  mode );
     405
     406/*********************************************************************************************
     407 * [22] This function creates a named FIFO file in the calling thread cluster.
     408 * The associated read and write file descriptors mut be be  explicitely created
     409 * using the sy_open() function.
     410 *********************************************************************************************
     411 * @ pathname   : pathname (can be relative or absolute).
     412 * @ mode       : access rights (as defined in chmod).
     413 * @ return 0 if success / returns -1 if failure.
     414 ********************************************************************************************/
     415int sys_mkfifo( char     * pathname,
     416                uint32_t   mode );
     417
     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 ********************************************************************************************/
     424int 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 ********************************************************************************************/
     434int 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 ********************************************************************************************/
     443int sys_closedir( uint32_t file_id );
     444
     445/*********************************************************************************************
     446 * [26] This function returns the pathname of the current working directory.
     447 *********************************************************************************************
     448 * buf     : buffer addres in user space.
     449 * nbytes  : user buffer size in bytes.
     450 * @ return 0 if success / returns -1 if failure.
     451 ********************************************************************************************/
     452int sys_getcwd( char     * buf,
     453                uint32_t   nbytes );
     454
     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 ********************************************************************************************/
     462int sys_clock( uint64_t * cycles );
     463
     464/*********************************************************************************************
     465 * [28] This function forces the calling thread to sleep, for a fixed number of cycles.
     466 *********************************************************************************************
     467 * cycles   : number of cycles.
     468 ********************************************************************************************/
     469int sys_alarm( uint32_t cycles );
     470
     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 ********************************************************************************************/
     477int sys_rmdir( char * pathname );
     478
     479/*********************************************************************************************
     480 * [30] This function implement the operations related to User Thread Local Storage.
     481 * It is actually implemented as an uint32_t variable in the thread descriptor.
     482 *********************************************************************************************
     483 * @ operation  : UTLS operation type as defined below.
     484 * @ value      : argument value for the UTLS_SET operation.
     485 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
     486 ********************************************************************************************/
     487int sys_utls( uint32_t operation,
     488              uint32_t value );
     489
     490typedef enum
     491{
     492    UTLS_SET       = 1,
     493    UTLS_GET       = 2,
     494    UTLS_GET_ERRNO = 3,
     495}
     496utls_operation_t;
     497
     498/*********************************************************************************************
     499 * [31] This function change the acces rights for the file/dir identified by the
     500 * pathname argument.
     501 *********************************************************************************************
     502 * @ pathname   : pathname (can be relative or absolute).
     503 * @ rights     : acces rights.
     504 * @ return 0 if success / returns -1 if failure.
     505 ********************************************************************************************/
     506int sys_chmod( char     * pathname,
     507               uint32_t   rights );
     508
     509/*********************************************************************************************
     510 * [32] This function associate a specific signal handler to a given signal type.
     511 * Tee handlers for the SIGKILL and SIGSTOP signals cannot be redefined.
     512 *********************************************************************************************
     513 * @ sig_id    : index defining signal type (from 1 to 31).
     514 * @ handler   : pointer on fonction implementing the specific handler.
     515 * @ return 0 if success / returns -1 if failure.
     516 ********************************************************************************************/
     517int sys_signal( uint32_t   sig_id,
     518                void     * handler );
     519
     520/*********************************************************************************************
     521 * [33] This function returns in the structure <tv>, defined in the time.h file,
     522 * the current time (in seconds & micro-seconds).
     523 * It is computed from the calling core descriptor.
     524 * The timezone is not supported.
     525 *********************************************************************************************
     526 * @ tv      : pointer on the timeval structure.
     527 * @ tz      : pointer on the timezone structure : must be NULL.       
     528 * @ return 0 if success / returns -1 if failure.
     529 ********************************************************************************************/
     530int sys_gettimeofday( struct timeval  * tv,
     531                      struct timezone * tz );
    262532
    263533/*********************************************************************************************
    264534 * [34] This function implements the "kill" system call.
    265  * It register the signal identified by the <sig> argument in all thread descriptors
    266  * of process identified by the <pid> argument.
     535 * It register the signal defined by the <sig_id> argument in all thread descriptors
     536 * of a target process identified by the <pid> argument. This is done in all clusters
     537 * containing threads for the target process.
     538 * 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,
     540 * and the RPC_SIGNAL_RISE to signal the remote threads.
    267541 *********************************************************************************************
    268542 * @ pid      : target process identifier.
    269  * @ sig      : signal index.
     543 * @ sig_id   : index defining the signal type (from 1 to 31).
     544 * @ return 0 if success / returns -1 if failure.
    270545 ********************************************************************************************/
    271546int sys_kill( pid_t    pid,
    272               uint32_t sig );
    273 
    274 /*********************************************************************************************
    275  * [35] This function TODO
     547              uint32_t sig_id );
     548
     549/*********************************************************************************************
     550 * [35] This function implements the "getpid" system call.
     551 *********************************************************************************************
     552 * @ returns the PID for the calling thread.
    276553 ********************************************************************************************/
    277554int sys_getpid();
     
    281558 * The calling process descriptor (parent process), and the associated thread descriptor are
    282559 * replicated in the same cluster as the calling thread, but the new process (child process)
    283  * is registered in another target cluster, that will become the process owner.
     560 * is registered in another target cluster, that is the new process owner.
    284561 * The child process and the associated main thread will be migrated to the target cluster
    285562 * later, when the child process makes an "exec" or any other system call.
     
    295572 * [37] This function implement the "exec" system call.
    296573 * It is executed in the client cluster, but the new process descriptor and main thread
    297  * must be created in a server cluster, that is generally another cluster, using a RPC.
    298  * - If the server_cluster is the client cluster, call directly make_exec() in local
    299  *   mode, to change the process image and launch a new thread in local cluster.
    300  *   finally, the old thread is deleted.
    301  * - If the target_cluster is remote, call rpc_process_exec_client() to execute the
    302  *   make_exec() in remote mode on the remote cluster, to create a new process
    303  *   descriptor and a new thread on remote cluster. Finally, both the local
    304  *   process descriptor and the local thread descriptor are deleted.
     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()
     576 *   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.
    305579 * In both case this function build an exec_info_t structure containing all informations
    306  * required to build the new process descriptor and the associated thread, including
    307  * the mode (local/remote).
     580 * required to build the new process descriptor and the associated thread.
     581 * Finally, the calling process and thread are deleted.
    308582 *********************************************************************************************
    309583 * @ filename : string pointer on .elf filename (virtual pointer in user space)
    310584 * @ argv     : array of strings on process arguments (virtual pointers in user space)
    311585 * @ envp     : array of strings on Renvironment variables (virtual pointers in user space)
    312  * @ returns O if success / returns non-zero if error.
     586 * @ returns O if success / returns -1 if failure.
    313587 ********************************************************************************************/
    314588int sys_exec( char  * filename,
     
    317591
    318592/*********************************************************************************************
    319  * [38] This function TODO
    320  ********************************************************************************************/
    321 int sys_thread_getattr();
    322 
    323 /*********************************************************************************************
    324  * [39] This function implements the ps system call.
    325  ********************************************************************************************/
    326 int sys_ps( uint32_t cmd,
    327             pid_t    pid,
    328             uint32_t tid );
    329 
    330 /*********************************************************************************************
    331  * [40] This function TODO
    332  ********************************************************************************************/
    333 int sys_madvise();
    334 
    335 /*********************************************************************************************
    336  * [41] This function TODO
    337  ********************************************************************************************/
    338 int sys_mcntl();
    339 
    340 /*********************************************************************************************
    341  * [42] This function TODO
    342  ********************************************************************************************/
    343 int sys_stat();
    344 
    345 /*********************************************************************************************
    346  * [43] This function TODO
    347  ********************************************************************************************/
    348 int sys_thread_migrate();
    349 
    350 /*********************************************************************************************
    351  * [44] This function TODO
    352  ********************************************************************************************/
    353 int sys_sbrk();
    354 
    355 /*********************************************************************************************
    356  * [45] This function TODO
    357  ********************************************************************************************/
    358 int sys_rmdir();
    359 
    360 /*********************************************************************************************
    361  * [46] This function TODO
    362  ********************************************************************************************/
    363 int sys_ftime();
    364 
    365 /*********************************************************************************************
    366  * [47] This function TODO
    367  ********************************************************************************************/
    368 int sys_chmod();
    369 
    370 /*********************************************************************************************
    371  * [48] This function TODO
    372  ********************************************************************************************/
    373 int sys_fsync();
    374 
    375 /*********************************************************************************************
    376  * [49] This function TODO
    377  ********************************************************************************************/
    378 int sys_gettimeofday();
    379 
    380 /*********************************************************************************************
    381  * [50] This function TODO
    382  ********************************************************************************************/
    383 int sys_times();
     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.
     598 * @ returns O if success / returns -1 if failure.
     599 ********************************************************************************************/
     600int 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
     605 * identified by the <trdid> and <pid> arguments.
     606 * It can be called by any other thread.
     607 *********************************************************************************************
     608 * @ operation  : operation type as defined below.
     609 * @ pid        : process identifier.
     610 * @ trdid      : thread identifier.
     611 * @ returns O if success / returns -1 if failure.
     612 ********************************************************************************************/
     613int sys_trace( uint32_t operation,
     614               pid_t    pid,
     615               uint32_t trdid );
     616
     617typedef enum
     618{
     619    TRACE_ON       = 0,
     620    TRACE_OFF      = 1,
     621}
     622trace_operation_t;
    384623
    385624
Note: See TracChangeset for help on using the changeset viewer.