[1] | 1 | /* |
---|
[407] | 2 | * syscalls.h - Kernel side services for syscall handling. |
---|
[1] | 3 | * |
---|
[23] | 4 | * Author Alain Greiner (2016,2017) |
---|
[1] | 5 | * |
---|
| 6 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 7 | * |
---|
| 8 | * This file is part of ALMOS-MKH. |
---|
| 9 | * |
---|
| 10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 11 | * under the terms of the GNU General Public License as published by |
---|
| 12 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 13 | * |
---|
| 14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 17 | * General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 22 | */ |
---|
| 23 | |
---|
[16] | 24 | #ifndef _SYSCALLS_H_ |
---|
| 25 | #define _SYSCALLS_H_ |
---|
[1] | 26 | |
---|
[23] | 27 | #include <hal_types.h> |
---|
[407] | 28 | #include <shared_syscalls.h> |
---|
[23] | 29 | |
---|
[407] | 30 | /** Forward declarations *****/ |
---|
[23] | 31 | |
---|
| 32 | struct thread_s; // defined in thread.h |
---|
| 33 | struct pthread_attr_s; // defined in thread.h |
---|
| 34 | struct vfs_stat_s; // defined in vfs.h |
---|
| 35 | struct vfs_dirent_s; // defined in vfs.h |
---|
| 36 | struct mmap_attr_s; // defined in vmm.h |
---|
| 37 | |
---|
[407] | 38 | /****************************************************************************************** |
---|
| 39 | * [0] This function terminates the execution of the calling user thread, |
---|
[23] | 40 | * and makes the exit_value pointer available to any successful pthread_join() with the |
---|
| 41 | * terminating thread. |
---|
[407] | 42 | ****************************************************************************************** |
---|
[408] | 43 | * @ exit_vallue : pointer to be returned to parent thread if thread is attached. |
---|
[23] | 44 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 45 | *****************************************************************************************/ |
---|
[23] | 46 | int sys_thread_exit( void * exit_value ); |
---|
[16] | 47 | |
---|
[407] | 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 | *****************************************************************************************/ |
---|
| 56 | int sys_thread_yield(); |
---|
[16] | 57 | |
---|
[407] | 58 | /****************************************************************************************** |
---|
[23] | 59 | * [2] This function creates a new user thread. The <user_attr> argument is a pointer |
---|
| 60 | * on astructure containing the thread attributes, defined in thread.h file. |
---|
[407] | 61 | ****************************************************************************************** |
---|
[23] | 62 | * @ new_thread : [out] local pointer on created thread descriptor. |
---|
| 63 | * @ user_attr : [in] pointer on thread attributes structure. |
---|
| 64 | * @ start_func : [in] pointer on start function. |
---|
| 65 | * @ start_args : [in] pointer on start function arguments. |
---|
| 66 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 67 | *****************************************************************************************/ |
---|
[23] | 68 | int sys_thread_create( struct thread_s * new_thread, |
---|
| 69 | struct pthread_attr_s * user_attr, |
---|
| 70 | void * start_func, |
---|
| 71 | void * start_args ); |
---|
[16] | 72 | |
---|
[407] | 73 | /****************************************************************************************** |
---|
[23] | 74 | * [3] This blocking function suspend execution of the calling thread until completion |
---|
| 75 | * of another target thread identified by the <trdid> argument. |
---|
| 76 | * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the |
---|
| 77 | * target thread is stored in the location referenced by exit_value. |
---|
[407] | 78 | ****************************************************************************************** |
---|
[23] | 79 | * @ trdid : [in] target thread identifier. |
---|
| 80 | * @ thread : [out] buffer for exit_value returned by target thread. |
---|
| 81 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 82 | *****************************************************************************************/ |
---|
[23] | 83 | int sys_thread_join( trdid_t trdid, |
---|
| 84 | void ** exit_value ); |
---|
[16] | 85 | |
---|
[407] | 86 | /****************************************************************************************** |
---|
[23] | 87 | * [4] This function detach a joinable thread. |
---|
[407] | 88 | ****************************************************************************************** |
---|
| 89 | * @ trdid : thread identifier.i |
---|
[23] | 90 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 91 | *****************************************************************************************/ |
---|
[23] | 92 | int sys_thread_detach( trdid_t trdid ); |
---|
[16] | 93 | |
---|
[407] | 94 | /****************************************************************************************** |
---|
| 95 | * [5] This slot is not used. |
---|
| 96 | *****************************************************************************************/ |
---|
[16] | 97 | |
---|
[407] | 98 | /****************************************************************************************** |
---|
[23] | 99 | * [6] This function implement all operations on a POSIX unnamed semaphore, |
---|
| 100 | * that can be shared by threads running in different clusters. |
---|
| 101 | * The kernel structure representing a remote semaphore is in the remote_sem.h file, |
---|
| 102 | * and the code implementing the operations is in the remore_sem.c file. |
---|
[407] | 103 | ****************************************************************************************** |
---|
[23] | 104 | * @ vaddr : semaphore virtual address in user space == identifier. |
---|
| 105 | * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT. |
---|
| 106 | * @ value : pointer on in/out argument in user space. |
---|
| 107 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 108 | *****************************************************************************************/ |
---|
[23] | 109 | int sys_sem( void * vaddr, |
---|
| 110 | uint32_t operation, |
---|
| 111 | uint32_t * value ); |
---|
[16] | 112 | |
---|
[407] | 113 | /****************************************************************************************** |
---|
[23] | 114 | * [7] This function implement all operations on a POSIX condition variable. |
---|
| 115 | * The kernel structure representing a cond_var is defined in the remote_cv.h file, |
---|
| 116 | * The code implementing the operations is defined in the remote_cv.c file. |
---|
[407] | 117 | ****************************************************************************************** |
---|
[23] | 118 | * @ vaddr : condvar virtual address in user space == identifier. |
---|
| 119 | * @ operation : operation type (see below). |
---|
| 120 | * @ attr : mutex virtual address in user space == identifier. |
---|
| 121 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 122 | *****************************************************************************************/ |
---|
[23] | 123 | int sys_condvar( void * condvar, |
---|
| 124 | uint32_t operation, |
---|
| 125 | void * mutex ); |
---|
[16] | 126 | |
---|
[407] | 127 | /****************************************************************************************** |
---|
[23] | 128 | * [8] This function implement all operations on a POSIX barrier. |
---|
| 129 | * The kernel structure representing a barrier is defined in the remote_barrier.h file. |
---|
| 130 | * The code implementting the operations is defined in the remote_barrier.c file. |
---|
[407] | 131 | ****************************************************************************************** |
---|
[23] | 132 | * @ vaddr : barrier virtual address in user space == identifier. |
---|
| 133 | * @ operation : BARRIER_INIT / BARRIER_DESTROY / BARRIER_WAIT. |
---|
| 134 | * @ count : number of expected threads (only used by BARRIER_INIT operation). |
---|
| 135 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 136 | *****************************************************************************************/ |
---|
[23] | 137 | int sys_barrier( void * vaddr, |
---|
| 138 | uint32_t operation, |
---|
| 139 | uint32_t count ); |
---|
[16] | 140 | |
---|
[407] | 141 | /****************************************************************************************** |
---|
[23] | 142 | * [9] This function implement all operations on a POSIX mutex. |
---|
| 143 | * The kernel structure representing a barrier is defined in the remote_barrier.h file. |
---|
| 144 | * The code implementting the operations is defined in the remote_barrier.c file. |
---|
[407] | 145 | ****************************************************************************************** |
---|
[23] | 146 | * @ vaddr : mutex virtual address in user space == identifier. |
---|
| 147 | * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK |
---|
| 148 | * @ attr : mutex attributes (non supported yet => must be 0). |
---|
| 149 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 150 | *****************************************************************************************/ |
---|
[23] | 151 | int sys_mutex( void * vaddr, |
---|
| 152 | uint32_t operation, |
---|
| 153 | uint32_t count ); |
---|
[16] | 154 | |
---|
[407] | 155 | /****************************************************************************************** |
---|
[408] | 156 | * [10] This function implement the exit system call terminating a POSIX process. |
---|
[407] | 157 | ****************************************************************************************** |
---|
[408] | 158 | * @ status : terminaison status (not used in present implementation). |
---|
[407] | 159 | *****************************************************************************************/ |
---|
[408] | 160 | void sys_exit( uint32_t status ); |
---|
[16] | 161 | |
---|
[407] | 162 | /****************************************************************************************** |
---|
[408] | 163 | * [11] This function remove an existing mapping defined by the <addr> and <size> |
---|
[407] | 164 | * arguments in user space. |
---|
| 165 | ****************************************************************************************** |
---|
| 166 | * @ addr : base address in user space. |
---|
| 167 | * # size : number of bytes. |
---|
[23] | 168 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 169 | *****************************************************************************************/ |
---|
| 170 | int sys_munmap( void * addr, |
---|
| 171 | uint32_t size ); |
---|
[16] | 172 | |
---|
[407] | 173 | /****************************************************************************************** |
---|
| 174 | * [12] This function open or create an open file descriptor. |
---|
| 175 | ****************************************************************************************** |
---|
[23] | 176 | * @ pathname : pathname (can be relative or absolute). |
---|
| 177 | * @ flags : bit vector attributes (see below). |
---|
| 178 | * @ mode : access rights. |
---|
| 179 | * @ return file descriptor index in fd_array if success / return -1 if failure. |
---|
[407] | 180 | *****************************************************************************************/ |
---|
[23] | 181 | int sys_open( char * pathname, |
---|
| 182 | uint32_t flags, |
---|
| 183 | uint32_t mode ); |
---|
[16] | 184 | |
---|
[407] | 185 | /****************************************************************************************** |
---|
| 186 | * [13] This function map physical memory (or a file) in the calling thread virtual space. |
---|
| 187 | * The <attr> argument is a pointer on a structure for arguments (see shared_syscalls.h). |
---|
| 188 | ****************************************************************************************** |
---|
| 189 | * @ attr : pointer on attributes structure. |
---|
| 190 | * @ return 0 if success / return -1 if failure. |
---|
| 191 | *****************************************************************************************/ |
---|
| 192 | int sys_mmap( mmap_attr_t * attr ); |
---|
[23] | 193 | |
---|
[407] | 194 | /****************************************************************************************** |
---|
[23] | 195 | * [14] This function read bytes from an open file identified by its file descriptor. |
---|
[407] | 196 | * The file can be a regular file or character oriented device. |
---|
[408] | 197 | * IRQs are enabled during this system call. |
---|
[407] | 198 | ****************************************************************************************** |
---|
[23] | 199 | * @ file_id : open file index in fd_array. |
---|
| 200 | * @ buf : buffer virtual address in user space. |
---|
| 201 | * @ count : number of bytes. |
---|
| 202 | * @ return number of bytes actually read if success / returns -1 if failure. |
---|
[407] | 203 | *****************************************************************************************/ |
---|
[23] | 204 | int sys_read( uint32_t file_id, |
---|
| 205 | void * buf, |
---|
| 206 | uint32_t count ); |
---|
[16] | 207 | |
---|
[407] | 208 | /****************************************************************************************** |
---|
[23] | 209 | * [15] This function writes bytes to an open file identified by its file descriptor. |
---|
[407] | 210 | * The file can be a regular file or character oriented device. |
---|
[408] | 211 | * IRQs are enabled during this system call. |
---|
[407] | 212 | ****************************************************************************************** |
---|
[23] | 213 | * @ file_id : open file index in fd_array. |
---|
| 214 | * @ buf : buffer virtual address in user space. |
---|
| 215 | * @ count : number of bytes. |
---|
| 216 | * @ return number of bytes actually written if success / returns -1 if failure. |
---|
[407] | 217 | *****************************************************************************************/ |
---|
[23] | 218 | int sys_write( uint32_t file_id, |
---|
| 219 | void * buf, |
---|
| 220 | uint32_t count ); |
---|
[16] | 221 | |
---|
[407] | 222 | /****************************************************************************************** |
---|
| 223 | * [16] This function repositions the offset of the file descriptor identified by <file_id>, |
---|
| 224 | * according to the operation type defined by the <whence> argument. |
---|
| 225 | ****************************************************************************************** |
---|
[23] | 226 | * @ file_id : open file index in fd_array. |
---|
[407] | 227 | * @ offset : used to compute new offset value. |
---|
[23] | 228 | * @ whence : operation type (see below). |
---|
| 229 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 230 | *****************************************************************************************/ |
---|
[23] | 231 | int sys_lseek( xptr_t file_id, |
---|
| 232 | uint32_t offset, |
---|
| 233 | uint32_t whence ); |
---|
[16] | 234 | |
---|
[407] | 235 | /****************************************************************************************** |
---|
[23] | 236 | * [17] This function release the memory allocated for the file descriptor identified by |
---|
| 237 | * the <file_id> argument, and remove the fd array_entry in all copies of the process |
---|
| 238 | * descriptor. |
---|
[407] | 239 | ****************************************************************************************** |
---|
[23] | 240 | file_id : file descriptor index in fd_array. |
---|
| 241 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 242 | *****************************************************************************************/ |
---|
[23] | 243 | int sys_close( uint32_t file_id ); |
---|
[16] | 244 | |
---|
[407] | 245 | /****************************************************************************************** |
---|
| 246 | * [18] This function removes a directory entry identified by the <pathname> from the |
---|
[23] | 247 | * directory, and decrement the link count of the file referenced by the link. |
---|
| 248 | * If the link count reduces to zero, and no process has the file open, then all resources |
---|
| 249 | * associated with the file are reclaimed. If one or more process have the file open when |
---|
| 250 | * the last link is removed, the link is removed, but the removal of the file is delayed |
---|
| 251 | * until all references to it have been closed. |
---|
[407] | 252 | ****************************************************************************************** |
---|
[23] | 253 | * @ pathname : pathname (can be relative or absolute). |
---|
| 254 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 255 | *****************************************************************************************/ |
---|
[23] | 256 | int sys_unlink( char * pathname ); |
---|
[16] | 257 | |
---|
[407] | 258 | /****************************************************************************************** |
---|
[23] | 259 | * [19] This function creates in the calling thread cluster an unnamed pipe, and two |
---|
| 260 | * (read and write) file descriptors. |
---|
[407] | 261 | * TODO not implemented yet... |
---|
| 262 | ****************************************************************************************** |
---|
[23] | 263 | * @ file_id[0] : [out] read only file descriptor index. |
---|
| 264 | * @ file_id[1] : [out] write only file descriptor index. |
---|
| 265 | * @ return 0 if success / return -1 if failure. |
---|
[407] | 266 | *****************************************************************************************/ |
---|
[23] | 267 | int sys_pipe( uint32_t file_id[2] ); |
---|
[16] | 268 | |
---|
[407] | 269 | /****************************************************************************************** |
---|
[23] | 270 | * [20] This function change the current working directory in reference process descriptor. |
---|
[407] | 271 | ****************************************************************************************** |
---|
[23] | 272 | * @ pathname : pathname (can be relative or absolute). |
---|
| 273 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 274 | *****************************************************************************************/ |
---|
[23] | 275 | int sys_chdir( char * pathname ); |
---|
[16] | 276 | |
---|
[407] | 277 | /****************************************************************************************** |
---|
[23] | 278 | * [21] This function creates a new directory in file system. |
---|
[407] | 279 | ****************************************************************************************** |
---|
[23] | 280 | * @ pathname : pathname (can be relative or absolute). |
---|
| 281 | * @ mode : access rights (as defined in chmod). |
---|
| 282 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 283 | *****************************************************************************************/ |
---|
[279] | 284 | int sys_mkdir( char * pathname, |
---|
[23] | 285 | uint32_t mode ); |
---|
[16] | 286 | |
---|
[407] | 287 | /****************************************************************************************** |
---|
[23] | 288 | * [22] This function creates a named FIFO file in the calling thread cluster. |
---|
| 289 | * The associated read and write file descriptors mut be be explicitely created |
---|
[407] | 290 | * using the sys_open() function. |
---|
| 291 | ****************************************************************************************** |
---|
[23] | 292 | * @ pathname : pathname (can be relative or absolute). |
---|
| 293 | * @ mode : access rights (as defined in chmod). |
---|
| 294 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 295 | *****************************************************************************************/ |
---|
[23] | 296 | int sys_mkfifo( char * pathname, |
---|
| 297 | uint32_t mode ); |
---|
[16] | 298 | |
---|
[407] | 299 | /****************************************************************************************** |
---|
| 300 | * [23] This function open a directory, that must exist in the file system, returning |
---|
| 301 | * a DIR pointer on the directory in user space. |
---|
| 302 | ****************************************************************************************** |
---|
[23] | 303 | * @ pathname : pathname (can be relative or absolute). |
---|
[407] | 304 | * @ dirp : [out] buffer for pointer on user directory (DIR). |
---|
[23] | 305 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 306 | *****************************************************************************************/ |
---|
| 307 | int sys_opendir( char * pathname, |
---|
| 308 | DIR ** dirp ); |
---|
[16] | 309 | |
---|
[407] | 310 | /****************************************************************************************** |
---|
| 311 | * [24] This function returns an user pointer on the dirent structure describing the |
---|
| 312 | * next directory entry in the directory identified by the <dirp> argument. |
---|
| 313 | ****************************************************************************************** |
---|
| 314 | * @ dirp : user pointer identifying the searched directory. |
---|
| 315 | * @ dentp : [out] buffer for pointer on user direntory entry (dirent). |
---|
| 316 | * @ return O if success / returns -1 if failure. |
---|
| 317 | *****************************************************************************************/ |
---|
| 318 | int sys_readdir( DIR * dirp, |
---|
| 319 | struct dirent ** dentp ); |
---|
| 320 | |
---|
| 321 | /****************************************************************************************** |
---|
| 322 | * [25] This function closes the directory identified by the <dirp> argument, and releases |
---|
| 323 | * all structures associated with the <dirp> pointer. |
---|
| 324 | ****************************************************************************************** |
---|
| 325 | * @ dirp : user pointer identifying the directory. |
---|
[23] | 326 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 327 | *****************************************************************************************/ |
---|
| 328 | int sys_closedir( DIR * dirp ); |
---|
[16] | 329 | |
---|
[407] | 330 | /****************************************************************************************** |
---|
[23] | 331 | * [26] This function returns the pathname of the current working directory. |
---|
[407] | 332 | ****************************************************************************************** |
---|
[23] | 333 | * buf : buffer addres in user space. |
---|
| 334 | * nbytes : user buffer size in bytes. |
---|
| 335 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 336 | *****************************************************************************************/ |
---|
[23] | 337 | int sys_getcwd( char * buf, |
---|
| 338 | uint32_t nbytes ); |
---|
[16] | 339 | |
---|
[407] | 340 | /****************************************************************************************** |
---|
| 341 | * [27] This slot is not used. |
---|
| 342 | *****************************************************************************************/ |
---|
[16] | 343 | |
---|
[407] | 344 | /****************************************************************************************** |
---|
[23] | 345 | * [28] This function forces the calling thread to sleep, for a fixed number of cycles. |
---|
[407] | 346 | ****************************************************************************************** |
---|
[23] | 347 | * cycles : number of cycles. |
---|
[407] | 348 | *****************************************************************************************/ |
---|
[23] | 349 | int sys_alarm( uint32_t cycles ); |
---|
[16] | 350 | |
---|
[407] | 351 | /****************************************************************************************** |
---|
| 352 | * [29] This function removes a directory file whose name is given by <pathname>. |
---|
| 353 | * The directory must not have any entries other than `.' and `..'. |
---|
| 354 | ****************************************************************************************** |
---|
[23] | 355 | * @ pathname : pathname (can be relative or absolute). |
---|
| 356 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 357 | *****************************************************************************************/ |
---|
[23] | 358 | int sys_rmdir( char * pathname ); |
---|
[16] | 359 | |
---|
[407] | 360 | /****************************************************************************************** |
---|
[23] | 361 | * [30] This function implement the operations related to User Thread Local Storage. |
---|
| 362 | * It is actually implemented as an uint32_t variable in the thread descriptor. |
---|
[407] | 363 | ****************************************************************************************** |
---|
[23] | 364 | * @ operation : UTLS operation type as defined below. |
---|
| 365 | * @ value : argument value for the UTLS_SET operation. |
---|
| 366 | * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure. |
---|
[407] | 367 | *****************************************************************************************/ |
---|
[23] | 368 | int sys_utls( uint32_t operation, |
---|
| 369 | uint32_t value ); |
---|
[16] | 370 | |
---|
[407] | 371 | /****************************************************************************************** |
---|
[23] | 372 | * [31] This function change the acces rights for the file/dir identified by the |
---|
| 373 | * pathname argument. |
---|
[407] | 374 | ****************************************************************************************** |
---|
[23] | 375 | * @ pathname : pathname (can be relative or absolute). |
---|
| 376 | * @ rights : acces rights. |
---|
| 377 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 378 | *****************************************************************************************/ |
---|
[23] | 379 | int sys_chmod( char * pathname, |
---|
| 380 | uint32_t rights ); |
---|
[16] | 381 | |
---|
[407] | 382 | /****************************************************************************************** |
---|
[23] | 383 | * [32] This function associate a specific signal handler to a given signal type. |
---|
| 384 | * Tee handlers for the SIGKILL and SIGSTOP signals cannot be redefined. |
---|
[407] | 385 | ****************************************************************************************** |
---|
[23] | 386 | * @ sig_id : index defining signal type (from 1 to 31). |
---|
| 387 | * @ handler : pointer on fonction implementing the specific handler. |
---|
| 388 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 389 | *****************************************************************************************/ |
---|
[23] | 390 | int sys_signal( uint32_t sig_id, |
---|
| 391 | void * handler ); |
---|
[16] | 392 | |
---|
[407] | 393 | /****************************************************************************************** |
---|
[23] | 394 | * [33] This function returns in the structure <tv>, defined in the time.h file, |
---|
| 395 | * the current time (in seconds & micro-seconds). |
---|
| 396 | * It is computed from the calling core descriptor. |
---|
| 397 | * The timezone is not supported. |
---|
[407] | 398 | ****************************************************************************************** |
---|
[23] | 399 | * @ tv : pointer on the timeval structure. |
---|
| 400 | * @ tz : pointer on the timezone structure : must be NULL. |
---|
| 401 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 402 | *****************************************************************************************/ |
---|
[50] | 403 | int sys_timeofday( struct timeval * tv, |
---|
| 404 | struct timezone * tz ); |
---|
[16] | 405 | |
---|
[407] | 406 | /****************************************************************************************** |
---|
[16] | 407 | * [34] This function implements the "kill" system call. |
---|
[23] | 408 | * It register the signal defined by the <sig_id> argument in all thread descriptors |
---|
| 409 | * of a target process identified by the <pid> argument. This is done in all clusters |
---|
| 410 | * containing threads for the target process. |
---|
| 411 | * It can be executed by any thread running in any cluster, as this function uses |
---|
[407] | 412 | * remote access to traverse the list of process copies stored in the owner cluster, |
---|
[23] | 413 | * and the RPC_SIGNAL_RISE to signal the remote threads. |
---|
[407] | 414 | ****************************************************************************************** |
---|
[16] | 415 | * @ pid : target process identifier. |
---|
[23] | 416 | * @ sig_id : index defining the signal type (from 1 to 31). |
---|
| 417 | * @ return 0 if success / returns -1 if failure. |
---|
[407] | 418 | *****************************************************************************************/ |
---|
[16] | 419 | int sys_kill( pid_t pid, |
---|
[23] | 420 | uint32_t sig_id ); |
---|
[16] | 421 | |
---|
[407] | 422 | /****************************************************************************************** |
---|
[23] | 423 | * [35] This function implements the "getpid" system call. |
---|
[407] | 424 | ****************************************************************************************** |
---|
| 425 | * @ returns the process PID for the calling thread. |
---|
| 426 | *****************************************************************************************/ |
---|
[1] | 427 | int sys_getpid(); |
---|
| 428 | |
---|
[407] | 429 | /****************************************************************************************** |
---|
[16] | 430 | * [36] This function implement the "fork" system call. |
---|
[1] | 431 | * The calling process descriptor (parent process), and the associated thread descriptor are |
---|
| 432 | * replicated in the same cluster as the calling thread, but the new process (child process) |
---|
[23] | 433 | * is registered in another target cluster, that is the new process owner. |
---|
[1] | 434 | * The child process and the associated main thread will be migrated to the target cluster |
---|
[407] | 435 | * later, when the child process makes an "exec" or any other system call... TODO [AG] |
---|
[1] | 436 | * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be |
---|
| 437 | * stored in the calling thread descriptor by the specific fork_place() system call. |
---|
| 438 | * If not, the sys_fork() function makes a query to the DQDT to select the target cluster. |
---|
[407] | 439 | ****************************************************************************************** |
---|
| 440 | * @ if success, returns child process PID to parent, and return O to child. |
---|
| 441 | * @ if failure, returns -1 to parent / no child process is created. |
---|
| 442 | *****************************************************************************************/ |
---|
[1] | 443 | int sys_fork(); |
---|
| 444 | |
---|
[407] | 445 | /****************************************************************************************** |
---|
| 446 | * [37] This function implement the "exec" system call, that creates a new process |
---|
| 447 | * descriptor. |
---|
| 448 | * It is executed in the client cluster, but the new process descriptor and the main |
---|
| 449 | * thread are created in a server cluster, that is generally another cluster. |
---|
| 450 | * - if the server_cluster is the client cluster, it calls directly the process_make_exec() |
---|
[23] | 451 | * function to create a new process, and launch a new thread in local cluster. |
---|
[407] | 452 | * - if the target_cluster is remote, it calls the rpc_process_exec_client() to execute |
---|
| 453 | * process_signedmake_exec() on the remote cluster. |
---|
[1] | 454 | * In both case this function build an exec_info_t structure containing all informations |
---|
[23] | 455 | * required to build the new process descriptor and the associated thread. |
---|
| 456 | * Finally, the calling process and thread are deleted. |
---|
[407] | 457 | ****************************************************************************************** |
---|
| 458 | * @ filename : string pointer on .elf filename (pointer in user space) |
---|
| 459 | * @ argv : array of strings on process arguments (pointers in user space) |
---|
| 460 | * @ envp : array of strings on environment variables (pointers in user space) |
---|
[23] | 461 | * @ returns O if success / returns -1 if failure. |
---|
[407] | 462 | *****************************************************************************************/ |
---|
[1] | 463 | int sys_exec( char * filename, |
---|
| 464 | char ** argv, |
---|
| 465 | char ** envp ); |
---|
| 466 | |
---|
[407] | 467 | /****************************************************************************************** |
---|
| 468 | * [38] This function returns in the <stat> structure, defined in the "shared_syscalls.h" |
---|
| 469 | * file, various informations on the file/directory identified by the <pathname> argument. |
---|
| 470 | ****************************************************************************************** |
---|
| 471 | * @ pathname : user pointer on file pathname. |
---|
| 472 | * @ stat : user pointer on the stat structure. |
---|
[23] | 473 | * @ returns O if success / returns -1 if failure. |
---|
[407] | 474 | *****************************************************************************************/ |
---|
| 475 | int sys_stat( const char * pathname, |
---|
| 476 | struct stat * stat ); |
---|
[1] | 477 | |
---|
[407] | 478 | /****************************************************************************************** |
---|
| 479 | * [39] This non-standard function is used to activate / desactivate the trace for a thread |
---|
[23] | 480 | * identified by the <trdid> and <pid> arguments. |
---|
[407] | 481 | * It can be called by any other thread in the same process. |
---|
| 482 | ****************************************************************************************** |
---|
[23] | 483 | * @ operation : operation type as defined below. |
---|
| 484 | * @ pid : process identifier. |
---|
| 485 | * @ trdid : thread identifier. |
---|
| 486 | * @ returns O if success / returns -1 if failure. |
---|
[407] | 487 | *****************************************************************************************/ |
---|
[23] | 488 | int sys_trace( uint32_t operation, |
---|
| 489 | pid_t pid, |
---|
| 490 | uint32_t trdid ); |
---|
[1] | 491 | |
---|
[407] | 492 | /****************************************************************************************** |
---|
| 493 | * [40] This function returns the hardware platform parameters. |
---|
| 494 | ****************************************************************************************** |
---|
| 495 | * @ x_size : [out] number of clusters in a row. |
---|
| 496 | * @ y_size : [out] number of clusters in a column. |
---|
| 497 | * @ ncores : [out] number of cores per cluster. |
---|
| 498 | * @ return 0 if success / return -1 if illegal arguments |
---|
| 499 | *****************************************************************************************/ |
---|
| 500 | int sys_get_config( uint32_t * x_size, |
---|
| 501 | uint32_t * y_size, |
---|
| 502 | uint32_t * ncores ); |
---|
[1] | 503 | |
---|
[407] | 504 | /****************************************************************************************** |
---|
| 505 | * [41] This function returns the calling core cluster and local index. |
---|
| 506 | ****************************************************************************************** |
---|
| 507 | * @ cxy : [out] cluster identifier (fixed format) |
---|
| 508 | * @ lid : [out] core local index in cluster. |
---|
| 509 | * @ return 0 if success / return -1 if illegal arguments |
---|
| 510 | *****************************************************************************************/ |
---|
| 511 | int sys_get_core( uint32_t * cxy, |
---|
| 512 | uint32_t * lid ); |
---|
[1] | 513 | |
---|
[407] | 514 | /****************************************************************************************** |
---|
| 515 | * [42] This function returns in a 64 bits user buffer the calling core cycles count. |
---|
| 516 | * It uses both the hardware register and the core descriptor cycles count to take |
---|
| 517 | * into account a possible harware register overflow in 32 bits architectures. |
---|
| 518 | ****************************************************************************************** |
---|
| 519 | * cycle : [out] address of buffer in user space. |
---|
| 520 | * @ return 0 if success / return -1 if illegal arguments |
---|
| 521 | *****************************************************************************************/ |
---|
| 522 | int sys_get_cycle( uint64_t * cycle ); |
---|
| 523 | |
---|
| 524 | /****************************************************************************************** |
---|
| 525 | * [43] This debug function displays on the kernel terminal the current state of a |
---|
| 526 | * scheduler identified by the <cxy> and <lid> arguments. |
---|
| 527 | ****************************************************************************************** |
---|
| 528 | * cxy : [in] target cluster identifier. |
---|
| 529 | * lid : [in] target core local index. |
---|
| 530 | * @ return 0 if success / return -1 if illegal arguments |
---|
| 531 | *****************************************************************************************/ |
---|
| 532 | int sys_get_sched( uint32_t cxy, |
---|
| 533 | uint32_t lid ); |
---|
| 534 | |
---|
| 535 | /****************************************************************************************** |
---|
| 536 | * [44] This debug function requires the kernel to display on the kernel terminal a message |
---|
| 537 | * containing the thread / process / core identifiers, and the cause of panic, |
---|
| 538 | * as defined by the <string> argument. |
---|
| 539 | ****************************************************************************************** |
---|
| 540 | * string : [in] message to be displayed. |
---|
| 541 | * @ return always 0. |
---|
| 542 | *****************************************************************************************/ |
---|
| 543 | int sys_panic( char * string ); |
---|
| 544 | |
---|
| 545 | /****************************************************************************************** |
---|
| 546 | * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition, |
---|
| 547 | * and deschedule. |
---|
| 548 | ****************************************************************************************** |
---|
| 549 | * @ return 0 if success / returns -1 if failure. |
---|
| 550 | *****************************************************************************************/ |
---|
| 551 | int sys_thread_sleep(); |
---|
| 552 | |
---|
| 553 | /****************************************************************************************** |
---|
| 554 | * [46] This function unblock the thread identified by its <trdid> from the |
---|
| 555 | * THREAD_BLOCKED_GLOBAL condition. |
---|
| 556 | ****************************************************************************************** |
---|
| 557 | * @ trdid : target thread identifier. |
---|
| 558 | * @ return 0 if success / return -1 if failure. |
---|
| 559 | *****************************************************************************************/ |
---|
| 560 | int sys_thread_wakeup(); |
---|
| 561 | |
---|
| 562 | |
---|
[16] | 563 | #endif // _SYSCALLS_H_ |
---|