Changeset 670
- Timestamp:
- Nov 19, 2020, 11:45:52 PM (4 years ago)
- Location:
- trunk/kernel/syscalls
- Files:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/shared_include/shared_almos.h
r664 r670 56 56 DISPLAY_FAT = 11, 57 57 DISPLAY_SOCKET = 12, 58 DISPLAY_FD = 13, 59 DISPLAY_WINDOWS = 14, 58 60 } 59 61 display_type_t; -
trunk/kernel/syscalls/shared_include/shared_fbf.h
r657 r670 1 1 /* 2 * shared_fbf.h - Shared mnemonics used by the frame buffer related syscalls.2 * shared_fbf.h - Shared mnemonics used by the Frame Buffer related syscalls. 3 3 * 4 4 * Author Alain Greiner (2016,2017,2018,2019,2020) … … 35 35 FBF_DIRECT_WRITE = 2, 36 36 FBF_CREATE_WINDOW = 3, 37 FBF_DELETE_WINDOW = 4, 38 FBF_REFRESH_WINDOW = 5, 39 FBF_MOVE_WINDOW = 6, 40 FBF_RESIZE_WINDOW = 7, 37 FBF_ACTIVE_WINDOW = 4, 38 FBF_DELETE_WINDOW = 5, 39 FBF_REFRESH_WINDOW = 6, 40 FBF_FRONT_WINDOW = 7, 41 FBF_MOVE_WINDOW = 8, 42 FBF_RESIZE_WINDOW = 9, 41 43 } 42 44 fbf_usr_operation_type_t; -
trunk/kernel/syscalls/shared_include/shared_socket.h
r664 r670 69 69 SOCK_SEND = 5, 70 70 SOCK_RECV = 6, 71 SOCK_SENDTO = 7,72 SOCK_RECVFROM = 8,73 71 } 74 72 socket_operation_type_t; -
trunk/kernel/syscalls/shared_include/shared_stat.h
r611 r670 28 28 * This structure define the informations associated to a file descriptor, 29 29 * returned to user space by the stat() syscall. 30 * 31 * The st_mode field contains informations on both access rights and file types. 32 * - access rights (defined by the inode <rights> field) are stored in st_mode[15:0] 33 * - file types (defined by the inode <type> field) are stored in st_mode[19:16] 30 34 *****************************************************************************************/ 31 35 … … 45 49 46 50 /****************************************************************************************** 47 * The st_mode field contains informations on both access rights and file types.48 * - access rights (defined by the inode <rights> field) are stored in st_mode[15:0]49 * - file types (defined by the inode <type> field) are stored in st_mode[19:16]50 51 * The following macros can be used to extract file type information. 51 52 * -
trunk/kernel/syscalls/sys_barrier.c
r637 r670 33 33 #include <remote_barrier.h> 34 34 35 //////////////////////////////////////////////////////36 static char * sys_barrier_op_str( uint32_t operation )37 {38 if ( operation == BARRIER_INIT ) return "INIT";39 else if( operation == BARRIER_DESTROY ) return "DESTROY";40 else if( operation == BARRIER_WAIT ) return "WAIT";41 else return "undefined";42 }43 44 35 ////////////////////////////////// 45 36 int sys_barrier( intptr_t vaddr, … … 55 46 process_t * process = this->process; 56 47 57 #if (DEBUG_SYS_BARRIER || CONFIG_INSTRUMENTATION_SYSCALLS)48 #if DEBUG_SYS_BARRIER || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 58 49 uint64_t tm_start = hal_get_cycles(); 59 50 #endif … … 72 63 73 64 #if DEBUG_SYSCALLS_ERROR 65 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 74 66 printk("\n[ERROR] in %s for %s : unmapped barrier %x / thread[%x,%x]\n", 75 67 __FUNCTION__, sys_barrier_op_str(operation), vaddr, process->pid, this->trdid ); … … 92 84 93 85 #if DEBUG_SYSCALLS_ERROR 86 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 94 87 printk("\n[ERROR] in %s for INIT : unmapped barrier attributes %x / thread[%x,%x]\n", 95 88 __FUNCTION__ , attr , process->pid , this->trdid ); … … 108 101 109 102 #if DEBUG_SYSCALLS_ERROR 103 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 110 104 printk("\n[ERROR] in %s for INIT : count (%d) != x_size (%d) * y_size (%d) * nthreads (%x)\n", 111 105 __FUNCTION__, count, k_attr.x_size, k_attr.y_size, k_attr.nthreads ); … … 128 122 129 123 #if DEBUG_SYSCALLS_ERROR 124 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 130 125 printk("\n[ERROR] in %s for INIT : cannot create barrier %x / thread[%x,%x]\n", 131 126 __FUNCTION__ , vaddr , process->pid , this->trdid ); … … 145 140 146 141 #if DEBUG_SYSCALLS_ERROR 142 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 147 143 printk("\n[ERROR] in %s for WAIT : barrier %x not registered / thread[%x,%x]\n", 148 144 __FUNCTION__ , (intptr_t)vaddr , process->pid, this->trdid ); … … 166 162 167 163 #if DEBUG_SYSCALLS_ERROR 164 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 168 165 printk("\n[ERROR] in %s for DESTROY : barrier %x not registered / thread[%x,%x]\n", 169 166 __FUNCTION__ , (intptr_t)vaddr , process->pid, this->trdid ); … … 181 178 default: 182 179 { 183 assert (false, "illegal operation type <%x>", operation );180 assert( __FUNCTION__, false, "illegal operation type <%x>", operation ); 184 181 } 185 182 } // end switch -
trunk/kernel/syscalls/sys_chdir.c
r637 r670 46 46 process_t * process = this->process; 47 47 48 #if (DEBUG_SYS_CHDIR || CONFIG_INSTRUMENTATION_SYSCALLS)48 #if DEBUG_SYS_CHDIR || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 49 49 uint64_t tm_start = hal_get_cycles(); 50 50 #endif … … 55 55 56 56 #if DEBUG_SYSCALLS_ERROR 57 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 57 58 printk("\n[ERROR] in %s : pathname too long / thread[%x,%x]\n", 58 59 __FUNCTION__, process->pid, this->trdid ); … … 67 68 68 69 #if DEBUG_SYSCALLS_ERROR 70 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 69 71 printk("\n[ERROR] in %s : user buffer unmapped %x for thread[%x,%x]\n", 70 72 __FUNCTION__ , (intptr_t)pathname , process->pid, this->trdid ); … … 80 82 81 83 #if DEBUG_SYS_CHDIR 82 if( DEBUG_SYS_CHDIR < tm_start )84 if( DEBUG_SYS_CHDIR < (uint32_t)tm_start ) 83 85 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 84 86 __FUNCTION__, process->pid, this->trdid, kbuf, (uint32_t)tm_start ); … … 109 111 110 112 #if DEBUG_SYSCALLS_ERROR 113 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 111 114 printk("\n[ERROR] in %s / thread[%x,%x] : cannot change CWD\n", 112 115 __FUNCTION__ , process->pid , this->trdid ); -
trunk/kernel/syscalls/sys_chmod.c
r637 r670 2 2 * sys_chmod.c - Change file access rights. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019)4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) 2015 UPMC Sorbonne Universites … … 29 29 #include <thread.h> 30 30 #include <process.h> 31 32 31 #include <syscalls.h> 33 32 … … 36 35 uint32_t rights __attribute__((unused)) ) 37 36 { 38 error_t error;39 37 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 40 38 41 39 thread_t * this = CURRENT_THREAD; 42 process_t * process = this->process; 40 41 #if DEBUG_SYS_CHMOD || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 42 process_t * process = this->process; 43 uint64_t tm_start = hal_get_cycles(); 44 #endif 43 45 44 46 // check pathname length … … 47 49 48 50 #if DEBUG_SYSCALLS_ERROR 49 printk("\n[ERROR] in %s : pathname too long / thread %x in process %x\n", 51 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 52 printk("\n[ERROR] in %s : thread[%x,%x] / pathname too long\n", 50 53 __FUNCTION__, this->trdid, process->pid ); 51 54 #endif … … 59 62 CONFIG_VFS_MAX_PATH_LENGTH ); 60 63 64 65 66 61 67 printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ ); 62 68 return -1; 63 69 64 // get cluster and local pointer on reference process65 // xptr_t ref_xp = process->ref_xp;66 // process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );67 // cxy_t ref_cxy = GET_CXY( ref_xp );68 70 69 // call the relevant VFS function70 // error = vfs_chmod( cwd_xp,71 // kbuf,72 // rights );73 71 74 if( error ) 75 { 76 printk("\n[ERROR] in %s : cannot remove directory %s\n", 77 __FUNCTION__ , kbuf ); 78 this->errno = error; 79 return -1; 80 } 72 73 hal_fence(); 74 75 #if (DEBUG_SYS_CHMOD || CONFIG_INSTRUMENTATION_SYSCALLS) 76 uint64_t tm_end = hal_get_cycles(); 77 #endif 78 79 #if DEBUG_SYS_CHMOD 80 if( DEBUG_SYS_CHMOD < tm_end ) 81 printk("\n[%s] thread[%x,%x] exit for / cycle %d\n", 82 __FUNCTION__, process->pid, this->trdid, (uint32_t)tm_end ); 83 #endif 84 85 #if CONFIG_INSTRUMENTATION_SYSCALLS 86 hal_atomic_add( &syscalls_cumul_cost[SYS_CHMOD] , tm_end - tm_start ); 87 hal_atomic_add( &syscalls_occurences[SYS_CHMOD] , 1 ); 88 #endif 81 89 82 90 return 0; -
trunk/kernel/syscalls/sys_close.c
r664 r670 1 1 /* 2 * sys_close.c close an open file2 * sys_close.c kernel function implementing the <close> syscall 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019,2020)4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 40 40 cxy_t file_cxy; 41 41 vfs_file_t * file_ptr; 42 vfs_ inode_type_t file_type;42 vfs_file_type_t file_type; 43 43 44 44 thread_t * this = CURRENT_THREAD; 45 45 process_t * process = this->process; 46 46 47 #if (DEBUG_SYS_CLOSE || CONFIG_INSTRUMENTATION_SYSCALLS)47 #if DEBUG_SYS_CLOSE || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 48 48 uint64_t tm_start = hal_get_cycles(); 49 49 #endif 50 50 51 51 #if DEBUG_SYS_CLOSE 52 if( DEBUG_SYS_CLOSE < tm_start )52 if( DEBUG_SYS_CLOSE < (uint32_t)tm_start ) 53 53 printk("\n[%s] thread[%x,%x] enter / fdid %d / cycle %d\n", 54 54 __FUNCTION__, process->pid, this->trdid, fdid, (uint32_t)tm_start ); … … 60 60 61 61 #if DEBUG_SYSCALLS_ERROR 62 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", 63 __FUNCTION__ , fdid ); 62 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 63 printk("\n[ERROR] in %s : thread[%x,%x] / illegal file descriptor index = %d\n", 64 __FUNCTION__ , process->pid , this->trdid , fdid ); 64 65 #endif 65 66 this->errno = EBADFD; … … 74 75 75 76 #if DEBUG_SYSCALLS_ERROR 76 printk("\n[ERROR] in %s : undefined file descriptor %d\n", 77 __FUNCTION__ , fdid ); 77 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 78 printk("\n[ERROR] in %s : thread[%x,%x] / undefined file descriptor %d\n", 79 __FUNCTION__ , process->pid , this->trdid , fdid ); 78 80 #endif 79 81 this->errno = EBADFD; … … 86 88 file_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 87 89 88 if( file_type == INODE_TYPE_DIR )90 if( file_type == FILE_TYPE_DIR ) 89 91 { 90 92 91 93 #if DEBUG_SYSCALLS_ERROR 92 printk("\n[ERROR] in %s : file descriptor %d is a directory\n", 93 __FUNCTION__ , fdid ); 94 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 95 printk("\n[ERROR] in %s : thread[%x,%x] / file descriptor %d is a directory\n", 96 __FUNCTION__ , process->pid , this->trdid , fdid ); 94 97 #endif 95 98 this->errno = EBADFD; 96 99 return -1; 97 100 } 98 else if( file_type == INODE_TYPE_SOCK )101 else if( file_type == FILE_TYPE_SOCK ) 99 102 { 100 103 // call the relevant socket function 101 104 error = socket_close( file_xp , fdid ); 102 105 } 103 else if( file_type == INODE_TYPE_FILE ) 106 else if( (file_type == FILE_TYPE_REG) || 107 (file_type == FILE_TYPE_FIFO) ) 104 108 { 105 109 // call the relevant VFS function … … 110 114 111 115 #if DEBUG_SYSCALLS_ERROR 112 printk("\n[WARNING] in %s : type (%d) not supported / fdid %d\n", 113 __FUNCTION__ , file_type , fdid ); 116 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 117 printk("\n[WARNING] in %s : thread[%x,%x] / file_type (%s) unsupported / fdid %d\n", 118 __FUNCTION__ , process->pid , this->trdid , vfs_inode_type_str(file_type) , fdid ); 114 119 #endif 115 120 error = 0; … … 120 125 121 126 #if DEBUG_SYSCALLS_ERROR 122 printk("\n[ERROR] in %s : cannot close file descriptor %d\n", 123 __FUNCTION__ , fdid ); 127 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 128 printk("\n[ERROR] in %s : thread[%x,%x] cannot close file descriptor %d\n", 129 __FUNCTION__ , process->pid , this->trdid , fdid ); 124 130 #endif 125 131 this->errno = error; -
trunk/kernel/syscalls/sys_closedir.c
r614 r670 2 2 * sys_closedir.c - Close an open VFS directory. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019,20120) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 37 37 { 38 38 xptr_t dir_xp; // extended pointer on user_dir_t structure 39 user_dir_t * dir_ptr; // l cal pointer on user_dir_t structure39 user_dir_t * dir_ptr; // local pointer on user_dir_t structure 40 40 cxy_t dir_cxy; // cluster identifier (inode cluster) 41 41 … … 43 43 process_t * process = this->process; // client process 44 44 45 #if (DEBUG_SYS_CLOSEDIR || CONFIG_INSTRUMENTATION_SYSCALLS)45 #if DEBUG_SYS_CLOSEDIR || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 46 46 uint64_t tm_start = hal_get_cycles(); 47 47 #endif … … 60 60 61 61 #if DEBUG_SYSCALLS_ERROR 62 printk("\n[ERROR] in %s / thread[%x,%x] : DIR pointer %x not registered\n", 62 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 63 printk("\n[ERROR] in %s : thread[%x,%x] / DIR pointer %x not registered\n", 63 64 __FUNCTION__ , process->pid , this->trdid, dirp ); 64 65 #endif … … 67 68 } 68 69 69 // get cluster and local pointer for user_dir_t structure70 // get cluster and local pointer for user_dir_t structure 70 71 dir_ptr = GET_PTR( dir_xp ); 71 72 dir_cxy = GET_CXY( dir_xp ); -
trunk/kernel/syscalls/sys_condvar.c
r635 r670 209 209 } 210 210 ///////// 211 default: { 212 assert ( false, "illegal operation type <%x>\n", operation ); 211 default: 212 { 213 assert( __FUNCTION__, false, "illegal operation type <%x>\n", operation ); 213 214 } 214 215 } // end switch -
trunk/kernel/syscalls/sys_display.c
r664 r670 58 58 else if( type == DISPLAY_FAT ) return "FAT"; 59 59 else if( type == DISPLAY_SOCKET ) return "SOCKET"; 60 else if( type == DISPLAY_FD ) return "FD"; 61 else if( type == DISPLAY_WINDOWS ) return "WINDOWS"; 60 62 else return "undefined"; 61 63 } … … 500 502 501 503 #if DEBUG_SYSCALLS_ERROR 502 printk("\n[ERROR] in %s SOCKET : pid %x not found\n", __FUNCTION__ , pid );504 printk("\n[ERROR] in %s for SOCKET : pid %x not found\n", __FUNCTION__ , pid ); 503 505 #endif 504 506 this->errno = EINVAL; … … 513 515 514 516 #if DEBUG_SYSCALLS_ERROR 515 printk("\n[ERROR] in %s SOCKET : fdid %d not found\n", __FUNCTION__ , fdid );517 printk("\n[ERROR] in %s for SOCKET : fdid %d not found\n", __FUNCTION__ , fdid ); 516 518 #endif 517 519 this->errno = EINVAL; … … 528 530 // display socket descriptor on TXT0 529 531 socket_display( XPTR( file_cxy , socket ), NULL ); 532 533 break; 534 } 535 //////////////// 536 case DISPLAY_FD: 537 { 538 pid_t pid = (pid_t)arg0; 539 540 // get extended pointer on owner process descriptor 541 xptr_t owner_xp = cluster_get_owner_process_from_pid( pid ); 542 543 if( owner_xp == XPTR_NULL ) 544 { 545 546 #if DEBUG_SYSCALLS_ERROR 547 printk("\n[ERROR] in %s for FD : pid %x not found\n", __FUNCTION__ , pid ); 548 #endif 549 this->errno = EINVAL; 550 return -1; 551 } 552 553 // display fd_array on TXT0 554 process_fd_display( owner_xp ); 555 556 break; 557 } 558 ///////////////////// 559 case DISPLAY_WINDOWS: 560 { 561 pid_t pid = (pid_t)arg0; 562 563 if( pid != 0 ) // only one target process 564 { 565 // get extended pointer on owner process descriptor 566 xptr_t owner_xp = cluster_get_owner_process_from_pid( pid ); 567 568 if( owner_xp == XPTR_NULL ) 569 { 570 571 #if DEBUG_SYSCALLS_ERROR 572 printk("\n[ERROR] in %s for FD : pid %x not found\n", __FUNCTION__ , pid ); 573 #endif 574 this->errno = EINVAL; 575 return -1; 576 } 577 } 578 579 // display windows state for one, or for all processes 580 dev_fbf_display_windows( pid ); 530 581 531 582 break; -
trunk/kernel/syscalls/sys_exec.c
r637 r670 2 2 * sys_exec.c - Kernel function implementing the "exec" system call. 3 3 * 4 * Authors Alain Greiner (2016,2017,2017,2019 )4 * Authors Alain Greiner (2016,2017,2017,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 38 38 #include <syscalls.h> 39 39 40 ////////////////////////////////////////////////i////////////////////////////////////// 41 // This static function is called twice by the sys_exec() function : 42 // - to register the main() arguments (args) in the exec_info structure. 43 // - to register the environment variables (envs) in the exec_info structure. 44 // In both cases the input is an array of string pointers in user space, 45 // and a set of strings in user space. 46 // We allocate one physical page to store a kernel copy of the array of pointers, 47 // we allocate one or several physical pages to store the strings themselve, 48 // and register these buffers and the number of strings in the exec_info structure. 49 // The max number of strings is 1024 (for both args and envs). The numbers of pages 50 // to store the (args) and (envs) strings are configuration parameters. 51 /////////////////////////////////////////////////////////////////////////////////////// 52 // @ exec_info : pointer on the exec_info structure. 53 // @ is_args : true if called for (args) / false if called for (envs). 54 // @ u_pointers : array of pointers on the strings (in user space). 55 // @ return 0 if success / non-zero if too many strings or no more memory. 56 /////////////////////////////////////////////////////////////////////////////////////// 57 static error_t process_exec_get_strings( exec_info_t * exec_info, 58 bool_t is_args, 59 char ** u_pointers ) 40 /////////////////////////////// 41 int sys_exec( char * pathname, // .elf file pathname in user space 42 char ** user_args, // pointer on process arguments in user space 43 char ** user_envs ) // pointer on env variables in user space 60 44 { 61 uint32_t index; // string index62 uint32_t found_null; // NULL pointer found in array of pointers63 uint32_t length; // string length64 kmem_req_t req; // kmem request65 uint32_t order; // ln2( number of pages to store strings )66 char ** k_pointers; // base of kernel array of pointers67 char * k_buf_base; // base address of the kernel strings buffer68 char * k_buf_ptr; // pointer on first empty slot in kernel strings buffer69 70 // compute ln2( number of pages for kernel strings buffer )71 if( is_args ) order = bits_log2( CONFIG_VMM_ARGS_SIZE );72 else order = bits_log2( CONFIG_VMM_ENVS_SIZE );73 74 // allocate one physical page for kernel array of pointers75 req.type = KMEM_PPM;76 req.order = 0;77 req.flags = AF_KERNEL | AF_ZERO;78 k_pointers = kmem_alloc( &req );79 80 if( k_pointers == NULL ) return ENOMEM;81 82 // allocate several physical pages to store the strings themselve83 req.type = KMEM_PPM;84 req.order = order;85 req.flags = AF_KERNEL | AF_ZERO;86 k_buf_base = kmem_alloc( &req );87 88 if( k_buf_base == NULL ) return ENOMEM;89 90 // copy the array of pointers to kernel buffer91 hal_copy_from_uspace( XPTR( local_cxy , k_pointers ),92 u_pointers,93 CONFIG_PPM_PAGE_SIZE );94 95 // scan kernel array of pointers to copy the strings96 found_null = 0;97 k_buf_ptr = k_buf_base;98 for( index = 0 ; index < 1024 ; index++ )99 {100 if( k_pointers[index] == NULL )101 {102 found_null = 1;103 break;104 }105 106 // compute string length107 length = hal_strlen_from_uspace( k_pointers[index] );108 109 // copy the user string to kernel buffer110 hal_copy_from_uspace( XPTR( local_cxy , k_buf_ptr ),111 k_pointers[index],112 length );113 114 // update k_pointer[index] entry115 k_pointers[index] = k_buf_ptr;116 117 // increment pointer on kernel strings buffer118 k_buf_ptr += (length + 1);119 }120 121 // update into exec_info structure122 if( found_null && is_args )123 {124 exec_info->args_pointers = k_pointers;125 exec_info->args_buf_base = k_buf_base;126 exec_info->args_nr = index;127 }128 else if( found_null && !is_args )129 {130 exec_info->envs_pointers = k_pointers;131 exec_info->envs_buf_base = k_buf_base;132 exec_info->envs_buf_free = k_buf_ptr;133 exec_info->envs_nr = index;134 }135 else136 {137 return EINVAL;138 }139 140 return 0;141 } // end process_exec_get_strings()142 143 /////////////////////////////////////////////////////////////////////////////////////////144 // Implementation note:145 // This function must be called by the main thread (thread 0 in owner cluster).146 // It build an exec_info_t structure containing all informations147 // required to initialize the new process descriptor and the associated thread.148 // It includes the new process main() arguments, the environment variables,149 // and the pathname to the new process .elf file.150 // It calls the process_exec_get_strings() functions to copy the main() arguments and151 // the environment variables from user buffers to the exec_info_t structure, allocate152 // and call the process_make_exec() function.153 // As it must destroy all process copies, and all other threads in all clusters,154 // the process_make_exec() function must be executed in the owner cluster.155 //156 // TODO : the args & envs arguments are not supported yet : both must be NULL [AG]157 /////////////////////////////////////////////////////////////////////////////////////////158 int sys_exec( char * pathname, // .elf file pathname159 char ** args, // process arguments160 char ** envs ) // environment variables161 {162 exec_info_t exec_info; // structure to pass to process_make_exec()163 45 error_t error; 46 vseg_t * vseg; 164 47 165 48 // get calling thread, process, & pid … … 167 50 process_t * process = this->process; 168 51 pid_t pid = process->pid; 52 trdid_t trdid = this->trdid; 169 53 170 #if DEBUG_SYS_EXEC 54 assert( __FUNCTION__, (CXY_FROM_PID( pid ) == local_cxy) , 55 "must be called in the owner cluster\n"); 56 57 assert( __FUNCTION__, (LTID_FROM_TRDID( trdid ) == 0) , 58 "must be called by the main thread\n"); 59 60 assert( __FUNCTION__, (user_envs == NULL) , 61 "environment variables not supported yet\n" ); 62 63 #if DEBUG_SYS_EXEC || DEBUG_SYSCALLS_ERROR 171 64 uint64_t tm_start = hal_get_cycles(); 172 65 #endif 173 66 174 assert( (CXY_FROM_PID( pid ) == local_cxy) , 175 "must be called in the owner cluster\n"); 67 // check "pathname" mapped in user space 68 if( vmm_get_vseg( process , (intptr_t)pathname , &vseg ) ) 69 { 176 70 177 assert( (LTID_FROM_TRDID( this->trdid ) == 0) , 178 "must be called by the main thread\n"); 71 #if DEBUG_SYSCALLS_ERROR 72 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 73 printk("\n[ERROR] in %s : thread[%x,%] / pathname pointer %x unmapped\n", 74 __FUNCTION__, pid, trdid, pathname ); 75 #endif 76 this->errno = EINVAL; 77 return -1; 78 } 179 79 180 assert( (args == NULL) , 181 "args not supported yet\n" ); 182 183 assert( (envs == NULL) , 184 "args not supported yet\n" ); 185 186 // check pathname length 80 // check "pathname" length 187 81 if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH ) 188 82 { 189 83 190 84 #if DEBUG_SYSCALLS_ERROR 191 printk("\n[ERROR] in %s : thread[%x,%x] pathname too long\n", 192 __FUNCTION__, pid, this->trdid ); 85 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 86 printk("\n[ERROR] in %s : thread[%x,%x] / pathname too long\n", 87 __FUNCTION__, pid, trdid ); 193 88 #endif 194 89 this->errno = ENFILE; … … 196 91 } 197 92 198 // copy pathname in exec_info structure (kernel space) 199 hal_strcpy_from_uspace( XPTR( local_cxy , exec_info.path ), 93 // check "args" mapped in user space if non NULL 94 if( (user_args != NULL) && (vmm_get_vseg( process , (intptr_t)user_args , &vseg )) ) 95 { 96 97 #if DEBUG_SYSCALLS_ERROR 98 printk("\n[ERROR] in %s for thread[%x,%] : user_args pointer %x unmapped\n", 99 __FUNCTION__, pid, trdid, user_args ); 100 #endif 101 this->errno = EINVAL; 102 return -1; 103 } 104 105 // check "envs" mapped in user space if not NULL 106 if( (user_envs != NULL) && (vmm_get_vseg( process , (intptr_t)user_envs , &vseg )) ) 107 { 108 109 #if DEBUG_SYSCALLS_ERROR 110 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 111 printk("\n[ERROR] in %s : thread[%x,%] / user_envs pointer %x unmapped\n", 112 __FUNCTION__, pid, trdid, user_envs ); 113 #endif 114 this->errno = EINVAL; 115 return -1; 116 } 117 118 #if DEBUG_SYS_EXEC 119 if( DEBUG_SYS_EXEC < (uint32_t)tm_start ) 120 printk("\n[%s] thread[%x,%x] enter / path <%s> / args %x / envs %x / cycle %d\n", 121 __FUNCTION__, pid, trdid, &process->exec_info.path[0], user_args, user_envs, cycle ); 122 #endif 123 124 // 1. copy "pathname" in kernel exec_info structure 125 hal_strcpy_from_uspace( XPTR( local_cxy , &process->exec_info.path[0] ), 200 126 pathname, 201 127 CONFIG_VFS_MAX_PATH_LENGTH ); 202 128 203 #if DEBUG_SYS_EXEC 204 if( DEBUG_SYS_EXEC < tm_start ) 205 printk("\n[%s] thread[%x,%x] enter for path <%s> / cycle = %d\n", 206 __FUNCTION__, pid, this->trdid, exec_info.path, (uint32_t)tm_start ); 207 #endif 208 209 // check and store args in exec_info structure if required 210 if( args != NULL ) 129 // 2. copy "arguments" pointers & strings in process exec_info if required 130 if( user_args != NULL ) 211 131 { 212 if( process_exec_get_strings( &exec_info , true , args) )132 if( process_exec_get_strings( true , user_args , &process->exec_info ) ) 213 133 { 214 134 215 135 #if DEBUG_SYSCALLS_ERROR 216 printk("\n[ERROR] in %s : thread[%x,%x] cannot access args for <%s>\n", 217 __FUNCTION__, pid, this->trdid, exec_info.path ); 136 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 137 printk("\n[ERROR] in %s : thread[%x,%] get arguments for <%s>\n", 138 __FUNCTION__, pid, trdid, pathname ); 218 139 #endif 219 140 this->errno = EINVAL; 220 141 return -1; 221 142 } 143 144 #if DEBUG_SYS_EXEC 145 if( DEBUG_SYS_EXEC < (uint32_t)tm_start ) 146 printk("\n[%s] thread[%x,%x] got arguments / arg[0] = <%s>\n", 147 __FUNCTION__, pid, trdid, process->exec_info.args_pointers[0] ); 148 #endif 149 222 150 } 223 151 224 // check and store envs in exec_info structureif required225 if( envs != NULL )152 // 3. copy "environment" pointers & strings in process exec_info if required 153 if( user_envs != NULL ) 226 154 { 227 if( process_exec_get_strings( &exec_info , false , envs) )155 if( process_exec_get_strings( false , user_envs , &process->exec_info ) ) 228 156 { 229 157 230 158 #if DEBUG_SYSCALLS_ERROR 231 printk("\n[ERROR] in %s : thread[%x,%x] cannot access envs for <%s>\n", 232 __FUNCTION__ , pid, this->trdid, exec_info.path ); 159 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 160 printk("\n[ERROR] in %s : thread[%x,%] get env variables for <%s>\n", 161 __FUNCTION__, pid, trdid, pathname ); 233 162 #endif 234 163 this->errno = EINVAL; 235 164 return -1; 236 165 } 166 167 #if DEBUG_SYS_EXEC 168 if( DEBUG_SYS_EXEC < (uint32_t)tm_start ) 169 printk("\n[%s] thread[%x,%x] got envs / env[0] = <%s>\n", 170 __FUNCTION__, pid, trdid, process->exec_info.envs_pointers[0] ); 171 #endif 172 237 173 } 238 174 239 // call relevant kernel function 240 error = process_make_exec( &exec_info);175 // call relevant kernel function (no return if success) 176 error = process_make_exec(); 241 177 242 178 if( error ) … … 244 180 245 181 #if DEBUG_SYSCALLS_ERROR 246 printk("\n[ERROR] in %s : thread[%x,%x] cannot create process for <%s>\n", 247 __FUNCTION__, pid, this->trdid, exec_info.path ); 182 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 183 printk("\n[ERROR] in %s : thread[%x,%x] cannot create process <%s>\n", 184 __FUNCTION__, pid, trdid, process->exec_info.path ); 248 185 #endif 249 186 this->errno = error; … … 251 188 } 252 189 253 assert( false , "we should never execute this code" );254 255 190 return 0; 256 191 -
trunk/kernel/syscalls/sys_exit.c
r664 r670 29 29 #include <printk.h> 30 30 #include <process.h> 31 #include <dev_fbf.h> 31 32 #include <shared_syscalls.h> 32 33 #include <cluster.h> … … 98 99 #endif 99 100 101 // delete all process registered FBF windows 102 dev_fbf_cleanup( pid ); 103 104 #if( DEBUG_SYS_EXIT & 1) 105 if( DEBUG_SYS_EXIT < tm_start ) 106 printk("\n[%s] thread[%x,%x] deleted all FBF windows for process %x\n", 107 __FUNCTION__, pid, this->trdid, pid ); 108 #endif 109 100 110 // mark for delete all process threads in all clusters, 101 111 // but the main thread and this calling thread … … 117 127 __FUNCTION__, pid, this->trdid ); 118 128 #endif 119 thread_delete ( XPTR( local_cxy , this ) , true ); // forced129 thread_delete_request( XPTR( local_cxy , this ) , true ); // forced 120 130 } 121 131 -
trunk/kernel/syscalls/sys_fbf.c
r657 r670 54 54 #if DEBUG_SYS_FBF 55 55 if( DEBUG_SYS_FBF < tm_start ) 56 printk("\n[%s] thread[%x,%x] enter for %s / arg1 %x / arg2 %x / arg3 %x / cycle %d\n",56 printk("\n[%s] thread[%x,%x] %s / a1 %x / a2 %x / a3 %x / cycle %d\n", 57 57 __FUNCTION__, process->pid, this->trdid, dev_fbf_cmd_str( operation ), 58 58 arg1, arg2, arg3, (uint32_t)tm_start ); … … 203 203 } 204 204 /////////////////////// 205 case FBF_ACTIVE_WINDOW: 206 { 207 uint32_t wid = arg1; 208 uint32_t active = arg2; 209 210 // call relevant kernel function 211 error = dev_fbf_active_window( wid , active ); 212 213 if( error ) 214 { 215 216 #if DEBUG_SYSCALLS_ERROR 217 printk("\n[ERROR] in %s : cannot %s / thread[%x,%x]\n", 218 __FUNCTION__ , dev_fbf_cmd_str(operation), process->pid, this->trdid ); 219 #endif 220 this->errno = EINVAL; 221 } 222 break; 223 } 224 /////////////////////// 205 225 case FBF_DELETE_WINDOW: 206 226 { … … 214 234 215 235 #if DEBUG_SYSCALLS_ERROR 216 printk("\n[ERROR] in %s : cannot delete window for%s / thread[%x,%x]\n",236 printk("\n[ERROR] in %s : cannot %s / thread[%x,%x]\n", 217 237 __FUNCTION__ , dev_fbf_cmd_str(operation), process->pid, this->trdid ); 218 238 #endif … … 237 257 238 258 #if DEBUG_SYSCALLS_ERROR 239 printk("\n[ERROR] in %s : cannot refresh window for%s / thread[%x,%x]\n",259 printk("\n[ERROR] in %s : cannot %s / thread[%x,%x]\n", 240 260 __FUNCTION__ , dev_fbf_cmd_str(operation), process->pid, this->trdid ); 241 261 #endif … … 258 278 259 279 #if DEBUG_SYSCALLS_ERROR 260 printk("\n[ERROR] in %s : cannot move window/ thread[%x,%x]\n",280 printk("\n[ERROR] in %s : cannot %s / thread[%x,%x]\n", 261 281 __FUNCTION__ , dev_fbf_cmd_str(operation), process->pid, this->trdid ); 262 282 #endif … … 279 299 280 300 #if DEBUG_SYSCALLS_ERROR 281 printk("\n[ERROR] in %s : cannot move window / thread[%x,%x]\n", 301 printk("\n[ERROR] in %s : cannot %s / thread[%x,%x]\n", 302 __FUNCTION__ , dev_fbf_cmd_str(operation), process->pid, this->trdid ); 303 #endif 304 this->errno = EINVAL; 305 } 306 break; 307 } 308 ////////////////////// 309 case FBF_FRONT_WINDOW: 310 { 311 uint32_t wid = arg1; 312 313 // call relevant kernel function 314 error = dev_fbf_front_window( wid ); 315 316 if( error ) 317 { 318 319 #if DEBUG_SYSCALLS_ERROR 320 printk("\n[ERROR] in %s : cannot %s / thread[%x,%x]\n", 282 321 __FUNCTION__ , dev_fbf_cmd_str(operation), process->pid, this->trdid ); 283 322 #endif -
trunk/kernel/syscalls/sys_fork.c
r637 r670 2 2 * sys_fork.c - Kernel function implementing the "fork" system call. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 46 46 xptr_t parent_thread_xp; // extended pointer on parent thread descriptor 47 47 pid_t parent_pid; // parent process identifier 48 thread_t * parent_thread_ptr; // local pointer on local parent thread descriptor48 thread_t * parent_thread_ptr; // local pointer on local parent thread 49 49 cxy_t parent_cxy; // parent thread cluster 50 50 51 51 pid_t child_pid; // child process identifier 52 thread_t * child_thread_ptr; // local pointer on remote child thread descriptor52 thread_t * child_thread_ptr; // local pointer on remote child thread 53 53 cxy_t child_cxy; // target cluster for forked child process 54 54 … … 58 58 59 59 error_t error; 60 61 60 62 61 // get pointers on local parent process and thread … … 67 66 parent_cxy = local_cxy; 68 67 69 #if (DEBUG_SYS_FORK || CONFIG_INSTRUMENTATION_SYSCALLS)68 #if DEBUG_SYS_FORK || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 70 69 uint64_t tm_start = hal_get_cycles(); 71 70 #endif … … 88 87 89 88 #if DEBUG_SYSCALLS_ERROR 90 printk("\n[ERROR] in %s : thread[%x,%x] cannot fork : too much children\n", 89 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 90 printk("\n[ERROR] in %s : thread[%x,%x] / too much children\n", 91 91 __FUNCTION__, parent_pid, parent_thread_ptr->trdid ); 92 92 #endif … … 136 136 137 137 #if DEBUG_SYSCALLS_ERROR 138 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 138 139 printk("\n[ERROR] in %s : thread[%x,%x] cannot fork\n", 139 140 __FUNCTION__, parent_pid, parent_thread_ptr->trdid ); -
trunk/kernel/syscalls/sys_isatty.c
r664 r670 89 89 90 90 // get file type 91 vfs_ inode_type_t type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) );91 vfs_file_type_t type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 92 92 93 93 // action depend on file type 94 if( type != INODE_TYPE_DEV ) // not a device94 if( type != FILE_TYPE_DEV ) // not a device 95 95 { 96 96 retval = 0; -
trunk/kernel/syscalls/sys_mkfifo.c
r637 r670 2 2 * sys_mkfifo.c - creates a named FIFO file. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 31 31 //////////////////////////////////// 32 32 int sys_mkfifo ( char * pathname, 33 uint32_t mode __attribute__((unused)))33 uint32_t mode ) 34 34 { 35 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 35 vseg_t * vseg; 36 error_t error; 37 xptr_t root_inode_xp; 38 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 36 39 37 thread_t * this = CURRENT_THREAD;38 process_t * process = this->process;40 thread_t * this = CURRENT_THREAD; 41 process_t * process = this->process; 39 42 40 #if (DEBUG_SYS_MKFIFO || CONFIG_INSTRUMENTATION_SYSCALLS)43 #if DEBUG_SYS_MKFIFO || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 41 44 uint64_t tm_start = hal_get_cycles(); 42 45 #endif … … 45 48 if( DEBUG_SYS_MKFIFO < tm_end ) 46 49 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 47 __FUNCTION__, process->pid, this->trdid, pathname, (uint32_t)tm_ end);50 __FUNCTION__, process->pid, this->trdid, pathname, (uint32_t)tm_start ); 48 51 #endif 49 52 50 // check fd_array not full51 if( process_fd_array_full() )52 53 // check pathname in user space 54 if( vmm_get_vseg( process, (intptr_t)pathname , &vseg ) ) 55 { 53 56 54 57 #if DEBUG_SYSCALLS_ERROR 55 printk("\n[ERROR] in %s : file descriptor array full for process %x\n", 56 __FUNCTION__ , process->pid ); 58 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 59 printk("\n[ERROR] in %s : user buffer unmapped %x for thread[%x,%x]\n", 60 __FUNCTION__ , (intptr_t)pathname , process->pid, this->trdid ); 57 61 #endif 58 this->errno = ENFILE;62 this->errno = EINVAL; 59 63 return -1; 60 64 } 61 65 62 66 // check pathname length … … 65 69 66 70 #if DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 71 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 72 printk("\n[ERROR] in %s : pathname too long for thread[%x,%x]\n", 73 __FUNCTION__ , process->pid , this->trdid ); 68 74 #endif 69 75 this->errno = ENFILE; … … 76 82 CONFIG_VFS_MAX_PATH_LENGTH ); 77 83 78 printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ ); 79 return -1; 84 #if DEBUG_SYS_MKFIFO 85 if( DEBUG_SYS_MKFIFO < tm_end ) 86 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 87 __FUNCTION__, process->pid, this->trdid, kbuf, (uint32_t)tm_start ); 88 #endif 89 90 // get cluster and local pointer on reference process 91 xptr_t ref_xp = process->ref_xp; 92 process_t * ref_ptr = GET_PTR( ref_xp ); 93 cxy_t ref_cxy = GET_CXY( ref_xp ); 94 95 // get extended pointer on root inode in path 96 if( kbuf[0] == '/' ) // absolute path 97 { 98 // use extended pointer on VFS root inode 99 root_inode_xp = process->vfs_root_xp; 100 } 101 else // relative path 102 { 103 // use extended pointer on CWD inode 104 root_inode_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->cwd_xp ) ); 105 } 106 107 // call the relevant VFS function 108 error = vfs_mkfifo( root_inode_xp, 109 kbuf, 110 mode ); 111 if( error ) 112 { 113 114 #if DEBUG_SYSCALLS_ERROR 115 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 116 printk("\n[ERROR] in %s : thread[%x,%x] cannot create node in VFS for <%s> path\n", 117 __FUNCTION__ , process->pid , this->trdid , kbuf ); 118 #endif 119 this->errno = ENFILE; 120 return -1; 121 } 80 122 81 123 #if (DEBUG_SYS_MKFIFO || CONFIG_INSTRUMENTATION_SYSCALLS) … … 94 136 #endif 95 137 138 return 0; 139 96 140 } // end sys_mkfifo() -
trunk/kernel/syscalls/sys_mmap.c
r664 r670 193 193 */ 194 194 195 // increment file refcount196 vfs_file_count_up( file_xp );197 198 195 mapper_xp = XPTR( file_cxy , mapper_ptr ); 199 196 vseg_type = VSEG_TYPE_FILE; -
trunk/kernel/syscalls/sys_mutex.c
r635 r670 216 216 default: 217 217 { 218 assert (false, "illegal operation type <%x>", operation );218 assert( __FUNCTION__, false, "illegal operation type <%x>", operation ); 219 219 } 220 220 } -
trunk/kernel/syscalls/sys_open.c
r637 r670 39 39 uint32_t mode ) 40 40 { 41 vseg_t * vseg; 41 42 error_t error; 42 43 xptr_t file_xp; // extended pointer on vfs_file_t 43 44 uint32_t file_id; // file descriptor index 44 xptr_t root_inode_xp; // extended pointer on pathroot inode45 xptr_t root_inode_xp; // extended pointer on root inode 45 46 46 47 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; … … 49 50 process_t * process = this->process; 50 51 51 #if (DEBUG_SYS_OPEN || CONFIG_INSTRUMENTATION_SYSCALLS)52 #if DEBUG_SYS_OPEN || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 52 53 uint64_t tm_start = hal_get_cycles(); 53 54 #endif … … 58 59 59 60 #if DEBUG_SYSCALLS_ERROR 60 printk("\n[ERROR] in %s : file descriptor array full for process %x\n", 61 __FUNCTION__ , process->pid ); 61 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 62 printk("\n[ERROR] in %s : file descriptor array full for thread[%x,%x]\n", 63 __FUNCTION__ , process->pid , this->trdid ); 62 64 #endif 63 65 this->errno = ENFILE; 64 66 return -1; 65 67 } 68 69 // check pathname in user space 70 if( vmm_get_vseg( process, (intptr_t)pathname , &vseg ) ) 71 { 72 73 #if DEBUG_SYSCALLS_ERROR 74 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 75 printk("\n[ERROR] in %s : user buffer unmapped %x for thread[%x,%x]\n", 76 __FUNCTION__ , (intptr_t)pathname , process->pid, this->trdid ); 77 #endif 78 this->errno = EINVAL; 79 return -1; 80 } 66 81 67 82 // check pathname length … … 70 85 71 86 #if DEBUG_SYSCALLS_ERROR 72 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 87 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 88 printk("\n[ERROR] in %s : pathname too long for thread[%x,%x]\n", 89 __FUNCTION__ , process->pid , this->trdid ); 73 90 #endif 74 91 this->errno = ENFILE; … … 77 94 78 95 // copy pathname in kernel space 79 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ) , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 80 96 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 97 pathname, 98 CONFIG_VFS_MAX_PATH_LENGTH ); 81 99 #if DEBUG_SYS_OPEN 82 100 if( DEBUG_SYS_OPEN < tm_start ) … … 86 104 87 105 // get cluster and local pointer on reference process 88 xptr_t ref_xp = process->ref_xp;89 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );90 cxy_t ref_cxy = GET_CXY( ref_xp );106 xptr_t owner_xp = process->owner_xp; 107 process_t * owner_ptr = GET_PTR( owner_xp ); 108 cxy_t owner_cxy = GET_CXY( owner_xp ); 91 109 92 // compute root inode for path93 if( kbuf[0] == '/' ) // absolute path110 // get extended pointer on root inode in path 111 if( kbuf[0] == '/' ) // absolute path 94 112 { 95 113 // use extended pointer on VFS root inode 96 114 root_inode_xp = process->vfs_root_xp; 97 115 } 98 else // relative path116 else // relative path 99 117 { 100 118 // use extended pointer on CWD inode 101 root_inode_xp = hal_remote_l64( XPTR( ref_cxy , &ref_ptr->cwd_xp ) );119 root_inode_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->cwd_xp ) ); 102 120 } 103 121 … … 105 123 error = vfs_open( root_inode_xp, 106 124 kbuf, 107 ref_xp,125 owner_xp, 108 126 flags, 109 127 mode, … … 113 131 if( error ) 114 132 { 115 printk("\n[ERROR] in %s : cannot create file descriptor for %s\n", 116 __FUNCTION__ , kbuf ); 133 134 #if DEBUG_SYSCALLS_ERROR 135 if( DEBUG_SYSCALLS_ERROR < tm_start ) 136 printk("\n[ERROR] in %s : thread[%x,%x] cannot create file descriptor for %s\n", 137 __FUNCTION__ , process->pid , this->trdid , kbuf ); 138 #endif 117 139 this->errno = ENFILE; 118 140 return -1; -
trunk/kernel/syscalls/sys_opendir.c
r637 r670 2 2 * sys_opendir.c - Open an user accessible VFS directory. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 54 54 process_t * process = this->process; // client process 55 55 56 #if (DEBUG_SYS_OPENDIR || CONFIG_INSTRUMENTATION_SYSCALLS)56 #if DEBUG_SYS_OPENDIR || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 57 57 uint64_t tm_start = hal_get_cycles(); 58 58 #endif … … 65 65 66 66 #if DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s / thread[%x,%x] : DIR buffer %x unmapped\n", 67 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 68 printk("\n[ERROR] in %s : thread[%x,%x] / DIR buffer %x unmapped\n", 68 69 __FUNCTION__ , process->pid , this->trdid, dirp ); 69 70 #endif … … 72 73 } 73 74 75 // check pathname in user space 76 error = vmm_get_vseg( process , (intptr_t)pathname, &vseg ); 77 78 if( error ) 79 { 80 81 #if DEBUG_SYSCALLS_ERROR 82 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 83 printk("\n[ERROR] in %s : thread[%x,%x] / pathname %x unmapped\n", 84 __FUNCTION__ , process->pid , this->trdid, pathname ); 85 #endif 86 this->errno = EINVAL; 87 return -1; 88 } 74 89 // check pathname length 75 90 if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH ) … … 77 92 78 93 #if DEBUG_SYSCALLS_ERROR 94 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 79 95 printk("\n[ERROR] in %s / thread[%x,%x] : pathname too long\n", 80 96 __FUNCTION__ , process->pid , this->trdid ); … … 90 106 91 107 #if DEBUG_SYS_OPENDIR 92 if( DEBUG_SYS_OPENDIR < tm_start )108 if( DEBUG_SYS_OPENDIR < (uint32_t)tm_start ) 93 109 printk("\n[%s] thread[%x,%x] enter for directory <%s> / cycle %d\n", 94 110 __FUNCTION__, process->pid, this->trdid, kbuf, (uint32_t)tm_start ); … … 122 138 123 139 #if DEBUG_SYSCALLS_ERROR 124 printk("\n[ERROR] in %s / thread[%x,%x] : cannot found directory <%s>\n", 140 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 141 printk("\n[ERROR] in %s : thread[%x,%x] / cannot found directory <%s>\n", 125 142 __FUNCTION__ , process->pid , this->trdid , kbuf ); 126 143 #endif … … 134 151 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 135 152 136 if( inode_type != INODE_TYPE_DIR ) 137 { 138 139 #if DEBUG_SYSCALLS_ERROR 140 printk("\n[ERROR] in %s / thread[%x,%x] : cannot found directory <%s>\n", 153 if( inode_type != FILE_TYPE_DIR ) 154 { 155 156 #if DEBUG_SYSCALLS_ERROR 157 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 158 printk("\n[ERROR] in %s : thread[%x,%x] / <%s> is not a directory\n", 141 159 __FUNCTION__ , process->pid , this->trdid , kbuf ); 142 160 #endif … … 165 183 166 184 #if DEBUG_SYSCALLS_ERROR 167 printk("\n[ERROR] in %s / thread[%x,%x] : cannot create user_dir for <%s>\n", 185 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 186 printk("\n[ERROR] in %s : thread[%x,%x] / cannot create user_dir for <%s>\n", 168 187 __FUNCTION__ , process->pid , this->trdid , kbuf ); 169 188 #endif -
trunk/kernel/syscalls/sys_pipe.c
r506 r670 2 2 * sys_pipe.c - open a pipe communication channel 3 3 * 4 * Author Alain Greiner (2016,1017 )4 * Author Alain Greiner (2016,1017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 24 24 #include <hal_kernel_types.h> 25 25 #include <vfs.h> 26 #include <hal_uspace.h> 26 27 #include <process.h> 27 28 #include <thread.h> 28 29 #include <printk.h> 30 #include <pipe.h> 29 31 30 32 #include <syscalls.h> 31 33 32 //////////////////////////// //////////33 int sys_pipe ( uint32_t file_fd[2])34 //////////////////////////// 35 int sys_pipe ( fdid_t * fd ) 34 36 { 35 printk("\n[ERROR] in %d : not implemented yet\n", __FUNCTION__, file_fd ); 36 return ENOSYS; 37 } 37 vseg_t * vseg; 38 kmem_req_t req; 39 pipe_t * pipe; 40 vfs_file_t * file_0; 41 vfs_file_t * file_1; 42 fdid_t fdid_0; 43 fdid_t fdid_1; 44 error_t error; 45 46 thread_t * this = CURRENT_THREAD; 47 process_t * process = this->process; 48 49 #if DEBUG_SYS_PIPE || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 50 uint64_t tm_start = hal_get_cycles(); 51 #endif 52 53 #if DEBUG_SYS_PIPE 54 if( DEBUG_SYS_PIPE < tm_end ) 55 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 56 __FUNCTION__, process->pid, this->trdid, pathname, (uint32_t)tm_end ); 57 #endif 58 59 // check user buffer is mapped 60 if( vmm_get_vseg( process , (intptr_t)fd , &vseg ) ) 61 { 62 63 #if DEBUG_SYSCALLS_ERROR 64 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 65 printk("\n[ERROR] in %s : thread[%x,%x] / output user buffer unmapped %x\n", 66 __FUNCTION__ , process->pid, this->trdid, (intptr_t)fd ); 67 #endif 68 this->errno = EINVAL; 69 return -1; 70 } 71 72 // 1. allocate memory in local cluster for pipe descriptor, 73 // remote buf_descriptor, and associated data buffer 74 pipe = pipe_create( local_cxy, 75 CONFIG_PIPE_BUF_SIZE ); 76 77 if( pipe == NULL ) 78 { 79 80 #if DEBUG_SYSCALLS_ERROR 81 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 82 printk("\n[ERROR] in %s : thread[%x,%x] / no memory for pipe\n", 83 __FUNCTION__ , process->pid, this->trdid ); 84 #endif 85 goto error_1; 86 } 87 88 // 2. allocate memory for fd[0] file descriptor in local cluster 89 // we don't use the vfs_file_create function because there is no inode. 90 req.type = KMEM_KCM; 91 req.order = bits_log2( sizeof(vfs_file_t) ); 92 req.flags = AF_ZERO; 93 file_0 = kmem_alloc( &req ); 94 95 if( file_0 == NULL ) 96 { 97 98 #if DEBUG_SYSCALLS_ERROR 99 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 100 printk("\n[ERROR] in %s : thread[%x,%x] / no memory for file descriptor\n", 101 __FUNCTION__, process->pid, this->trdid ); 102 #endif 103 goto error_2; 104 } 105 106 // 3. get fd[0] fdid value and register it in owner process fd_array[] 107 error = process_fd_register( process->owner_xp, 108 XPTR( local_cxy , file_0 ), 109 &fdid_0 ); 110 if ( error ) 111 { 112 113 #if DEBUG_SYSCALLS_ERROR 114 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 115 printk("\n[ERROR] in %s : thread[%x,%x] / cannot register file descriptor \n", 116 __FUNCTION__, process->pid, this->trdid ); 117 #endif 118 goto error_3; 119 } 120 121 // 4. allocate memory for fd[1] file descriptor in local cluster 122 req.type = KMEM_KCM; 123 req.order = bits_log2( sizeof(vfs_file_t) ); 124 req.flags = AF_ZERO; 125 file_1 = kmem_alloc( &req ); 126 127 if( file_1 == NULL ) 128 { 129 130 #if DEBUG_SYSCALLS_ERROR 131 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 132 printk("\n[ERROR] in %s : thread[%x,%x] / no memory for file descriptor\n", 133 __FUNCTION__, process->pid, this->trdid ); 134 #endif 135 goto error_4; 136 } 137 138 // 5. get fd[1] fdid value and register it in owner process fd_array[] 139 error = process_fd_register( process->owner_xp, 140 XPTR( local_cxy , file_1 ), 141 &fdid_1 ); 142 if ( error ) 143 { 144 145 #if DEBUG_SYSCALLS_ERROR 146 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 147 printk("\n[ERROR] in %s : thread[%x,%x] / cannot register file descriptor \n", 148 __FUNCTION__, process->pid, this->trdid ); 149 #endif 150 goto error_5; 151 } 152 153 // link the two file descriptors to the pipe 154 file_0->pipe = pipe; 155 file_1->pipe = pipe; 156 157 // copy fdid_0 & fdid_1 values to user buffer 158 hal_copy_to_uspace( &fd[0] , XPTR( local_cxy , &fdid_0 ) , sizeof(fdid_t) ); 159 hal_copy_to_uspace( &fd[1] , XPTR( local_cxy , &fdid_1 ) , sizeof(fdid_t) ); 160 161 #if (DEBUG_SYS_PIPE || CONFIG_INSTRUMENTATION_SYSCALLS) 162 uint64_t tm_end = hal_get_cycles(); 163 #endif 164 165 #if DEBUG_SYS_PIPE 166 if( DEBUG_SYS_PIPE < tm_end ) 167 printk("\n[%s] thread[%x,%x] exit for <%s> / cycle %d\n", 168 __FUNCTION__, this->process->pid, this->trdid, pathname, (uint32_t)tm_end ); 169 #endif 170 171 #if CONFIG_INSTRUMENTATION_SYSCALLS 172 hal_atomic_add( &syscalls_cumul_cost[SYS_PIPE] , tm_end - tm_start ); 173 hal_atomic_add( &syscalls_occurences[SYS_PIPE] , 1 ); 174 #endif 175 176 return 0; 177 178 error_5: // release memory allocated for fd[1] file descriptor 179 180 req.ptr = file_1; 181 kmem_free( &req ); 182 183 error_4: // release fdid_0 from fd_array[] 184 185 process_fd_remove( process->ref_xp , fdid_0 ); 186 187 error_3: // release memory allocated for fd[0] file descriptor 188 189 req.ptr = file_0; 190 kmem_free( &req ); 191 192 error_2: // release memory allocated for the pipe 193 194 pipe_destroy( XPTR( local_cxy , pipe ) ); 195 196 error_1: // set errno and return error 197 198 this->errno = ENOMEM; 199 return -1; 200 201 } // end sys_pipe() -
trunk/kernel/syscalls/sys_place_fork.c
r637 r670 38 38 { 39 39 thread_t * this = CURRENT_THREAD; 40 process_t * process = this->process;41 40 42 #if (DEBUG_SYS_PLACE_FORK || CONFIG_INSTRUMENTATION_SYSCALLS) 43 uint64_t tm_start = hal_get_cycles(); 41 #if DEBUG_SYS_PLACE_FORK || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 42 uint64_t tm_start = hal_get_cycles(); 43 process_t * process = this->process; 44 44 #endif 45 45 … … 55 55 56 56 #if DEBUG_SYSCALLS_ERROR 57 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ); 57 58 printk("\n[ERROR] in %s : thread[%x,‰x] / illegal cxy argument %x\n", 58 59 __FUNCTION__ , process->pid , this->trdid , cxy ); -
trunk/kernel/syscalls/sys_read.c
r664 r670 2 2 * sys_read.c - Kernel function implementing the "read" system call. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 33 33 #include <thread.h> 34 34 #include <printk.h> 35 #include <pipe.h> 35 36 #include <process.h> 36 37 … … 73 74 xptr_t process_owner_xp = process->owner_xp; 74 75 75 #if (DEBUG_SYS_READ || CONFIG_INSTRUMENTATION_SYSCALLS)76 #if DEBUG_SYS_READ || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 76 77 uint64_t tm_start = hal_get_cycles(); 77 78 #endif … … 92 93 93 94 #if DEBUG_SYSCALLS_ERROR 94 printk("\n[ERROR] in %s : thread[%x,%x] illegal file descriptor index %d\n", 95 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 96 printk("\n[ERROR] in %s : thread[%x,%x] / illegal file descriptor index %d\n", 95 97 __FUNCTION__ , process->pid, this->trdid, file_id ); 96 98 #endif … … 106 108 107 109 #if DEBUG_SYSCALLS_ERROR 108 printk("\n[ERROR] in %s : thread[%x,%x] user buffer unmapped %x\n", 110 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 111 printk("\n[ERROR] in %s : thread[%x,%x] / user buffer unmapped %x\n", 109 112 __FUNCTION__ , process->pid, this->trdid, (intptr_t)vaddr ); 110 113 #endif … … 120 123 121 124 #if DEBUG_SYSCALLS_ERROR 122 printk("\n[ERROR] in %s : thread[%x,%x] undefined fd_id %d\n", 125 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 126 printk("\n[ERROR] in %s : thread[%x,%x] / undefined fd_id %d\n", 123 127 __FUNCTION__, process->pid, this->trdid, file_id ); 124 128 #endif … … 140 144 hal_enable_irq( &save_sr ); 141 145 146 // check file readable 147 if( (file_attr & FD_ATTR_READ_ENABLE) == 0 ) 148 { 149 150 #if DEBUG_SYSCALLS_ERROR 151 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 152 printk("\n[ERROR] in %s : thread[%x,%x] / file %d not readable\n", 153 __FUNCTION__, process->pid, this->trdid, file_id ); 154 #endif 155 hal_restore_irq( save_sr ); 156 this->errno = EBADFD; 157 return -1; 158 } 159 142 160 // action depend on file type: 143 144 if( file_type == INODE_TYPE_FILE ) // read from file mapper 145 { 146 // check file readable 147 if( (file_attr & FD_ATTR_READ_ENABLE) == 0 ) 148 { 149 150 #if DEBUG_SYSCALLS_ERROR 151 printk("\n[ERROR] in %s : thread[%x,%x] file %d not readable\n", 152 __FUNCTION__, process->pid, this->trdid, file_id ); 153 #endif 154 hal_restore_irq( save_sr ); 155 this->errno = EBADFD; 156 return -1; 157 } 158 161 if( file_type == FILE_TYPE_REG ) // read from mapper 162 { 159 163 // try to move count bytes from mapper 160 nbytes = vfs_user_move( true, // from mapper to buffer164 nbytes = vfs_user_move( true, // from mapper 161 165 file_xp, 162 166 vaddr, 163 167 count ); 164 168 } 165 else if( file_type == INODE_TYPE_DEV )// read from TXT device169 else if( file_type == FILE_TYPE_DEV ) // read from TXT device 166 170 { 167 171 // get cluster and pointers on TXT_RX chdev … … 176 180 { 177 181 // extended pointer on TXT owner process 178 txt_owner_xp = hal_remote_l64( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) );179 182 txt_owner_xp = hal_remote_l64( XPTR( chdev_cxy , 183 &chdev_ptr->ext.txt.owner_xp ) ); 180 184 // wait for TXT_RX ownership 181 185 if ( process_owner_xp != txt_owner_xp ) … … 197 201 198 202 // try to move count bytes from TXT device 199 nbytes = devfs_user_move( true, // from device to buffer203 nbytes = devfs_user_move( true, // from device 200 204 file_xp, 201 205 vaddr, 202 206 count ); 203 207 } 204 else // not FILE and not DEV 205 { 206 207 #if DEBUG_SYSCALLS_ERROR 208 printk("\n[ERROR] in %s : thread[%x,%x] / illegal inode type %\n", 208 else if( (file_type == FILE_TYPE_PIPE) || 209 (file_type == FILE_TYPE_FIFO) ) // read from pipe 210 { 211 // try to move count bytes from pipe 212 nbytes = pipe_user_move( true, // from pipe 213 file_xp, 214 vaddr, 215 count ); 216 } 217 else // unsupported type 218 { 219 220 #if DEBUG_SYSCALLS_ERROR 221 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 222 printk("\n[ERROR] in %s : thread[%x,%x] / unsupported inode type %d\n", 209 223 __FUNCTION__, vfs_inode_type_str( file_type ) ); 210 224 #endif … … 219 233 220 234 #if DEBUG_SYSCALLS_ERROR 235 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 221 236 printk("\n[ERROR] in %s : thread[%x,‰x] cannot read data from file %d\n", 222 237 __FUNCTION__, process->pid, this->trdid, file_id ); -
trunk/kernel/syscalls/sys_readdir.c
r637 r670 2 2 * sys_readdir.c - Copy one entry from an open VFS directory to an user buffer. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 51 51 process_t * process = this->process; // client process 52 52 53 #if (DEBUG_SYS_READDIR || CONFIG_INSTRUMENTATION_SYSCALLS)53 #if (DEBUG_SYS_READDIR || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS) 54 54 uint64_t tm_start = hal_get_cycles(); 55 55 #endif … … 61 61 #endif 62 62 63 // check buffer in user space63 // check dirent buffer in user space 64 64 error = vmm_get_vseg( process , (intptr_t)buffer, &vseg ); 65 65 … … 68 68 69 69 #if DEBUG_SYSCALLS_ERROR 70 printk("\n[ERROR] in %s / thread[%x,%x] : user buffer %x unmapped\n", 70 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 71 printk("\n[ERROR] in %s : thread[%x,%x] / dirent user buffer %x unmapped\n", 71 72 __FUNCTION__ , process->pid , this->trdid, buffer ); 72 73 #endif … … 84 85 85 86 #if DEBUG_SYSCALLS_ERROR 86 printk("\n[ERROR] in %s / thread[%x,%x] : dirp %x not registered\n", 87 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 88 printk("\n[ERROR] in %s : thread[%x,%x] / dirp %x not registered\n", 87 89 __FUNCTION__ , process->pid , this->trdid, dirp ); 88 90 #endif … … 106 108 107 109 #if (DEBUG_SYS_READDIR & 1) 108 if( DEBUG_SYS_READDIR < tm_start )110 if( DEBUG_SYS_READDIR < (uint32_t)tm_start ) 109 111 printk("\n[%s] entries = %d / current = %d / direntp = %x\n", 110 112 __FUNCTION__, entries, current, direntp ); … … 126 128 127 129 #if DEBUG_SYS_READDIR 128 if( DEBUG_SYS_READDIR < tm_end )130 if( DEBUG_SYS_READDIR < (uint32_t)tm_end ) 129 131 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 130 132 __FUNCTION__, process->pid, this->trdid, (uint32_t)tm_end ); -
trunk/kernel/syscalls/sys_socket.c
r664 r670 53 53 else if( type == SOCK_ACCEPT ) return "ACCEPT"; 54 54 else if( type == SOCK_SEND ) return "SEND"; 55 else if( type == SOCK_SENDTO ) return "SENDTO";56 55 else if( type == SOCK_RECV ) return "RECV"; 57 else if( type == SOCK_RECVFROM ) return "RECVFROM";58 56 else return "undefined"; 59 57 } … … 66 64 reg_t arg3 ) 67 65 { 68 69 int32_t ret; 66 int ret; 70 67 vseg_t * vseg; 71 68 … … 77 74 uint32_t cmd = arg0; 78 75 79 #if (DEBUG_SYS_SOCKET || CONFIG_INSTRUMENTATION_SYSCALLS)76 #if DEBUG_SYS_SOCKET || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 80 77 uint64_t tm_start = hal_get_cycles(); 81 78 #endif 82 79 83 80 #if DEBUG_SYS_SOCKET 84 tm_start = hal_get_cycles(); 85 if( DEBUG_SYS_SOCKET < tm_start ) 81 if( DEBUG_SYS_SOCKET < (uint32_t)tm_start ) 86 82 printk("\n[%s] thread[%x,%x] enter / %s / a1 %x / a2 %x / a3 %x / cycle %d\n", 87 83 __FUNCTION__, process->pid, this->trdid, socket_cmd_type_str(cmd), … … 101 97 102 98 #if DEBUG_SYSCALLS_ERROR 103 printk("\n[ERROR] in %s for CREATE domain %d =! AF_INET\n", 104 __FUNCTION__ , domain ); 99 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 100 printk("\n[ERROR] in %s : thread[%x,%x] / CREATE / domain %d =! AF_INET\n", 101 __FUNCTION__ , process->pid , this->trdid , domain ); 105 102 #endif 106 103 this->errno = EINVAL; … … 113 110 114 111 #if DEBUG_SYSCALLS_ERROR 115 printk("\n[ERROR] in %s for CREATE : socket must be SOCK_STREAM(TCP) or SOCK_DGRAM(UDP)\n", 116 __FUNCTION__ ); 112 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 113 printk("\n[ERROR] in %s : thread[%x,%x] / CREATE / illegal socket type\n", 114 __FUNCTION__ , process->pid , this->trdid ); 117 115 #endif 118 116 this->errno = EINVAL; … … 124 122 ret = socket_build( domain , type ); 125 123 126 if( ret == -1 ) 127 { 128 129 #if DEBUG_SYSCALLS_ERROR 130 printk("\n[ERROR] in %s for CREATE : cannot create socket\n", 131 __FUNCTION__ ); 132 #endif 133 this->errno = EINVAL; 134 } 124 if( ret < 0 ) 125 { 126 127 #if DEBUG_SYSCALLS_ERROR 128 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 129 printk("\n[ERROR] in %s : thread[%x,%x] / CREATE / cannot create socket\n", 130 __FUNCTION__ , process->pid , this->trdid ); 131 #endif 132 this->errno = EINVAL; 133 ret = -1; 134 break; 135 } 136 135 137 break; 136 138 } … … 146 148 147 149 #if DEBUG_SYSCALLS_ERROR 148 printk("\n[ERROR] in %s for BIND : address %x unmapped\n", 149 __FUNCTION__ , (intptr_t)arg2 ); 150 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 151 printk("\n[ERROR] in %s : thread[%x,%x] / BIND / socket address %x unmapped\n", 152 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 150 153 #endif 151 154 this->errno = EINVAL; … … 164 167 k_sockaddr.sin_port ); 165 168 166 if( ret ) 167 { 168 169 #if DEBUG_SYSCALLS_ERROR 170 printk("\n[ERROR] in %s for BIND : cannot access socket[%x,%d]\n", 171 __FUNCTION__ , process->pid, fdid ); 172 #endif 173 this->errno = EINVAL; 174 } 169 if( ret < 0 ) 170 { 171 172 #if DEBUG_SYSCALLS_ERROR 173 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 174 printk("\n[ERROR] in %s : thread[%x,%x] / BIND / cannot access socket[%x,%d]\n", 175 __FUNCTION__ , process->pid , this->trdid , process->pid, fdid ); 176 #endif 177 this->errno = EINVAL; 178 ret = -1; 179 break; 180 } 181 175 182 break; 176 183 } … … 184 191 ret = socket_listen( fdid , max_pending ); 185 192 186 if( ret ) 187 { 188 189 #if DEBUG_SYSCALLS_ERROR 190 printk("\n[ERROR] in %s for LISTEN : cannot access socket[%x,%d]\n", 191 __FUNCTION__ , process->pid, fdid ); 192 #endif 193 this->errno = EINVAL; 194 } 193 if( ret < 0 ) 194 { 195 196 #if DEBUG_SYSCALLS_ERROR 197 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 198 printk("\n[ERROR] in %s : thread[%x,%x] / LISTEN / cannot access socket[%x,%d]\n", 199 __FUNCTION__ , process->pid , this->trdid , process->pid, fdid ); 200 #endif 201 this->errno = EINVAL; 202 ret = -1; 203 break; 204 } 205 195 206 break; 196 207 } … … 206 217 207 218 #if DEBUG_SYSCALLS_ERROR 208 printk("\n[ERROR] in %s for CONNECT : server address %x unmapped\n", 209 __FUNCTION__ , (intptr_t)arg2 ); 219 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 220 printk("\n[ERROR] in %s : thread[%x,%x] / CONNECT / server address %x unmapped\n", 221 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 210 222 #endif 211 223 this->errno = EINVAL; … … 223 235 k_sockaddr.sin_addr, 224 236 k_sockaddr.sin_port ); 225 226 if( ret ) 227 { 228 229 #if DEBUG_SYSCALLS_ERROR 230 printk("\n[ERROR] in %s for CONNECT : cannot access socket[%x,%d]\n", 231 __FUNCTION__ , process->pid, fdid ); 232 #endif 233 this->errno = EINVAL; 234 } 237 if( ret < 0 ) 238 { 239 240 #if DEBUG_SYSCALLS_ERROR 241 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 242 printk("\n[ERROR] in %s : thread[%x,%x] / LISTEN / cannot access socket[%x,%d]\n", 243 __FUNCTION__ , process->pid , this->trdid , process->pid, fdid ); 244 #endif 245 this->errno = EINVAL; 246 ret = -1; 247 break; 248 } 249 235 250 break; 236 251 } … … 246 261 247 262 #if DEBUG_SYSCALLS_ERROR 248 printk("\n[ERROR] in %s for CONNECT : server address %x unmapped\n", 249 __FUNCTION__ , (intptr_t)arg2 ); 263 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 264 printk("\n[ERROR] in %s : thread[%x,%x] / CONNECT / server address %x unmapped\n", 265 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 250 266 #endif 251 267 this->errno = EINVAL; … … 259 275 &k_sockaddr.sin_port ); 260 276 261 if( ret < 0 ) 262 { 263 264 #if DEBUG_SYSCALLS_ERROR 265 printk("\n[ERROR] in %s for ACCEPT : cannot access socket[%x,%d]\n", 266 __FUNCTION__ , process->pid, fdid ); 277 if( ret ) 278 { 279 280 #if DEBUG_SYSCALLS_ERROR 281 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 282 printk("\n[ERROR] in %s : thread[%x,%x] / ACCEPT / cannot access socket[%x,%d]\n", 283 __FUNCTION__ , process->pid , this->trdid , process->pid, fdid ); 267 284 #endif 268 285 this->errno = EINVAL; … … 288 305 289 306 #if DEBUG_SYSCALLS_ERROR 290 printk("\n[ERROR] in %s for SEND : buffer %x unmapped\n", 291 __FUNCTION__ , (intptr_t)arg2 ); 307 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 308 printk("\n[ERROR] in %s : thread[%x,%x] / SEND / buffer %x unmapped\n", 309 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 292 310 #endif 293 311 this->errno = EINVAL; … … 301 319 302 320 #if DEBUG_SYSCALLS_ERROR 303 printk("\n[ERROR] in %s for SEND : buffer length is 0\n", 304 __FUNCTION__ , (intptr_t)arg2 ); 321 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 322 printk("\n[ERROR] in %s : thread[%x,%x] / SEND / buffer length is 0\n", 323 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 305 324 #endif 306 325 this->errno = EINVAL; … … 316 335 317 336 #if DEBUG_SYSCALLS_ERROR 318 printk("\n[ERROR] in %s for SEND : cannot access socket[%x,%d] \n", 319 __FUNCTION__ , process->pid, fdid ); 337 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 338 printk("\n[ERROR] in %s : thread[%x,%x] / SEND / cannot access socket[%x,%d] \n", 339 __FUNCTION__ , process->pid , this->trdid , process->pid, fdid ); 320 340 #endif 321 341 this->errno = EINVAL; … … 335 355 336 356 #if DEBUG_SYSCALLS_ERROR 337 printk("\n[ERROR] in %s for SEND : buffer %x unmapped\n", 338 __FUNCTION__ , (intptr_t)arg2 ); 357 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 358 printk("\n[ERROR] in %s : thread[%x,%x] / RECV / buffer %x unmapped\n", 359 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 339 360 #endif 340 361 this->errno = EINVAL; … … 348 369 349 370 #if DEBUG_SYSCALLS_ERROR 350 printk("\n[ERROR] in %s for SEND : buffer length is 0\n", 351 __FUNCTION__ , (intptr_t)arg2 ); 371 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 372 printk("\n[ERROR] in %s : thread[%x,%x] / RECV / buffer length is 0\n", 373 __FUNCTION__ , process->pid , this->trdid , (intptr_t)arg2 ); 352 374 #endif 353 375 this->errno = EINVAL; … … 363 385 364 386 #if DEBUG_SYSCALLS_ERROR 365 printk("\n[ERROR] in %s for RECV : cannot access socket[%x,%d] \n", 366 __FUNCTION__ , process->pid, fdid ); 387 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 388 printk("\n[ERROR] in %s : thread[%x,%x] / RECV / cannot access socket[%x,%d] \n", 389 __FUNCTION__ , process->pid , this->trdid , process->pid, fdid ); 367 390 #endif 368 391 this->errno = EINVAL; … … 375 398 376 399 #if DEBUG_SYSCALLS_ERROR 377 printk("\n[ERROR] in %s : undefined socket operation %d\n", 378 __FUNCTION__ , cmd ); 400 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 401 printk("\n[ERROR] in %s : thread[%x,%x] / undefined socket operation %d\n", 402 __FUNCTION__ , process->pid , this->trdid , cmd ); 379 403 #endif 380 404 this->errno = EINVAL; -
trunk/kernel/syscalls/sys_thread_cancel.c
r651 r670 101 101 { 102 102 // block target thread and mark it for delete 103 thread_delete ( target_xp , false ); // not forced103 thread_delete_request( target_xp , false ); // not forced 104 104 } 105 105 -
trunk/kernel/syscalls/sys_thread_exit.c
r651 r670 105 105 106 106 // block calling thread and mark it for delete, 107 thread_delete ( XPTR( local_cxy , this ) , false ); // not forced107 thread_delete_request( XPTR( local_cxy , this ) , false ); // not forced 108 108 109 109 // deschedule -
trunk/kernel/syscalls/sys_trace.c
r637 r670 38 38 39 39 thread_t * this = CURRENT_THREAD; 40 process_t * process = this->process;41 40 42 #if (DEBUG_SYS_TRACE || CONFIG_INSTRUMENTATION_SYSCALLS) 43 uint64_t tm_start = hal_get_cycles(); 41 #if DEBUG_SYS_TRACE || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 42 process_t * process = this->process; 43 uint64_t tm_start = hal_get_cycles(); 44 44 #endif 45 45 … … 55 55 56 56 #if DEBUG_SYSCALLS_ERROR 57 printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n", 58 __FUNCTION__ , cxy , this->trdid , process->pid ); 57 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 58 printk("\n[ERROR] in %s : thread[%x,%x] / illegal cxy argument %x\n", 59 __FUNCTION__ , this->trdid , process->pid , cxy ); 59 60 #endif 60 61 this->errno = EINVAL; … … 68 69 69 70 #if DEBUG_SYSCALLS_ERROR 70 printk("\n[ERROR] in %s : illegal lid argument %x / thread %x / process %x\n", 71 __FUNCTION__ , lid , this->trdid , process->pid ); 71 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 72 printk("\n[ERROR] in %s : thread[%x,%x] / illegal lid argument %x\n", 73 __FUNCTION__ , this->trdid , process->pid , lid ); 72 74 #endif 73 75 this->errno = EINVAL; … … 100 102 hal_atomic_add( &syscalls_occurences[SYS_TRACE] , 1 ); 101 103 #endif 104 102 105 return 0; 103 106 -
trunk/kernel/syscalls/sys_write.c
r664 r670 2 2 * sys_write.c - Kernel function implementing the "write" system call. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 33 33 #include <thread.h> 34 34 #include <printk.h> 35 #include <pipe.h> 35 36 #include <process.h> 36 37 … … 71 72 process_t * process = this->process; 72 73 73 #if (DEBUG_SYS_WRITE || CONFIG_INSTRUMENTATION_SYSCALLS)74 #if DEBUG_SYS_WRITE || DEBUG_SYSCALLS_ERROR || CONFIG_INSTRUMENTATION_SYSCALLS 74 75 uint64_t tm_start = hal_get_cycles(); 75 76 #endif … … 91 92 92 93 #if DEBUG_SYSCALLS_ERROR 93 printk("\n[ERROR] in %s : thread[%x,%x] illegal file descriptor index %d\n", 94 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 95 printk("\n[ERROR] in %s : thread[%x,%x] / illegal file descriptor index %d\n", 94 96 __FUNCTION__, process->pid, this->trdid, file_id ); 95 97 #endif … … 105 107 106 108 #if DEBUG_SYSCALLS_ERROR 107 printk("\n[ERROR] in %s : thread[%x,%x] user buffer unmapped %x\n", 109 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 110 printk("\n[ERROR] in %s : thread[%x,%x] / user buffer unmapped %x\n", 108 111 __FUNCTION__ , process->pid, this->trdid, (intptr_t)vaddr ); 109 112 #endif … … 119 122 120 123 #if DEBUG_SYSCALLS_ERROR 121 printk("\n[ERROR] in %s : thread[%x,%x] undefined file descriptor = %d\n", 124 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 125 printk("\n[ERROR] in %s : thread[%x,%x] / undefined file descriptor = %d\n", 122 126 __FUNCTION__, process->pid, this->trdid, file_id ); 123 127 #endif … … 139 143 hal_enable_irq( &save_sr ); 140 144 141 // action depend on file type: 142 143 if( file_type == INODE_TYPE_FILE ) // write to a file mapper 144 { 145 // check file writable 146 if( (file_attr & FD_ATTR_WRITE_ENABLE) == 0 ) 147 { 148 149 #if DEBUG_SYSCALLS_ERROR 150 printk("\n[ERROR] in %s : thread[%x,%x] file %d not writable\n", 145 // check file writable 146 if( (file_attr & FD_ATTR_WRITE_ENABLE) == 0 ) 147 { 148 149 #if DEBUG_SYSCALLS_ERROR 150 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 151 printk("\n[ERROR] in %s : thread[%x,%x] / file %d not writable\n", 151 152 __FUNCTION__ , process->pid, this->trdid, file_id ); 152 153 #endif … … 154 155 this->errno = EBADFD; 155 156 return -1; 156 } 157 157 } 158 159 // action depend on file type: 160 if( file_type == FILE_TYPE_REG ) // write to mapper 161 { 158 162 // move count bytes to mapper 159 nbytes = vfs_user_move( false, // from bufferto mapper163 nbytes = vfs_user_move( false, // to mapper 160 164 file_xp, 161 165 vaddr, 162 166 count ); 163 167 } 164 else if( file_type == INODE_TYPE_DEV )// write to TXT device168 else if( file_type == FILE_TYPE_DEV ) // write to TXT device 165 169 { 166 170 // move count bytes to device 167 nbytes = devfs_user_move( false, // from bufferto device171 nbytes = devfs_user_move( false, // to device 168 172 file_xp, 169 173 vaddr, 170 174 count ); 171 175 } 172 else // not FILE and not DEV 173 { 174 175 #if DEBUG_SYSCALLS_ERROR 176 else if( (file_type == FILE_TYPE_PIPE) || 177 (file_type == FILE_TYPE_FIFO) ) // write to pipe 178 { 179 // move count bytes to pipe 180 nbytes = pipe_user_move( false, // to pipe 181 file_xp, 182 vaddr, 183 count ); 184 } 185 else // unsupported type 186 { 187 188 #if DEBUG_SYSCALLS_ERROR 189 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 176 190 printk("\n[ERROR] in %s : thread[%x,%x] / illegal inode type %\n", 177 191 __FUNCTION__, vfs_inode_type_str( file_type ) ); … … 187 201 188 202 #if DEBUG_SYSCALLS_ERROR 203 if( DEBUG_SYSCALLS_ERROR < (uint32_t)tm_start ) 189 204 printk("\n[ERROR] in %s : thread[%x,‰x] cannot write data to file %d\n", 190 205 __FUNCTION__ , process->pid, this->trdid, file_id ); -
trunk/kernel/syscalls/syscalls.h
r664 r670 36 36 struct mmap_attr_s; // defined in vmm.h 37 37 38 /****************************************************************************************** 39 * [0] This function terminates the execution of the calling user thread, and makes 40 * the <exit_status> pointer available to any successful pthread_join() with the 41 * terminating thread. 42 * - If the calling thread is the main thread, it calls the sys_exit() function to delete 43 * completely the user process. 44 * - if the calling thread is not the main thread, it registers the <exit_status> pointer 45 * in the thread descriptor, and calls the thread_delete() function, that will set the 46 * THREAD_SIG_EXIT signal, set the THREAD_BLOCKED_GLOBAL bit in thread descriptor, and 47 * deschedules. All memory allocated to the thread is released later by the scheduler. 48 * If the thread is in "detached" mode, the thread_delete() function implements 49 * the synchonisation with the joining thread. 50 ****************************************************************************************** 51 * @ exit_status : pointer to be returned to joining thread if thread is attached. 52 * @ return 0 if success / return -1 if all locks not released or illegal argument. 53 *****************************************************************************************/ 54 int sys_thread_exit( void * exit_status ); 55 56 /****************************************************************************************** 57 * [1] This function calls the scheduler for the core running the calling thread. 58 ****************************************************************************************** 59 * @ x_size : [out] number of clusters in a row. 60 * @ y_size : [out] number of clusters in a column. 61 * @ ncores : [out] number of cores per cluster. 62 * @ return always 0. 63 *****************************************************************************************/ 64 int sys_thread_yield( void ); 65 66 /****************************************************************************************** 67 * [2] This function creates a new user thread. The <user_attr> argument is a pointer 68 * on astructure containing the thread attributes, defined in thread.h file. 69 ****************************************************************************************** 70 * @ trdid_ptr : [out] pointer on buffer for created thread trdid. 71 * @ user_attr : [in] pointer on thread attributes structure. 72 * @ start_func : [in] pointer on start function. 73 * @ start_args : [in] pointer on start function arguments. 74 * @ return 0 if success / return -1 if failure. 75 *****************************************************************************************/ 76 int sys_thread_create( trdid_t * trdid_ptr, 77 struct pthread_attr_s * user_attr, 78 void * start_func, 79 void * start_args ); 80 81 /****************************************************************************************** 82 * [3] This blocking function suspend execution of the calling thread until completion 83 * of another target thread identified by the <trdid> argument. 84 * The target thread must be joinable (running in ATTACHED mode), and must be different 85 * from the calling thread. 86 * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the 87 * target thread is stored in the location referenced by exit_value. 88 ****************************************************************************************** 89 * @ trdid : [in] target thread identifier. 90 * @ thread : [out] buffer for exit_value returned by target thread. 91 * @ return 0 if success / return -1 if failure. 92 *****************************************************************************************/ 93 int sys_thread_join( trdid_t trdid, 94 void ** exit_value ); 95 96 /****************************************************************************************** 97 * [4] This function detach a joinable thread. 98 ****************************************************************************************** 99 * @ trdid : thread identifier. 100 * @ return 0 if success / return -1 if failure. 101 *****************************************************************************************/ 102 int sys_thread_detach( trdid_t trdid ); 103 104 /****************************************************************************************** 105 * [5] This function requests a target thread identified by its <trdid> argument 106 * to be cancelled. It calls the thread_kill() function to block the target thread 107 * on the THREAD_BLOCKED_GLOBAL condition, and to set the THREAD_FLAG_REQ_DELETE. 108 * The thread will be detached from its process, and the memory allocated to the thread 109 * descriptor will be released by the scheduler at the next scheduling point. 110 ****************************************************************************************** 111 * @ trdid : thread identifier. 112 * @ return 0 if success / return -1 if illegal argument. 113 *****************************************************************************************/ 114 int sys_thread_cancel( trdid_t trdid ); 115 116 /****************************************************************************************** 117 * [6] This function implement all operations on a POSIX unnamed semaphore, 118 * that can be shared by threads running in different clusters. 119 * The kernel structure representing a remote semaphore is in the remote_sem.h file, 120 * and the code implementing the operations is in the remore_sem.c file. 121 ****************************************************************************************** 122 * @ vaddr : semaphore virtual address in user space == identifier. 123 * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT. 124 * @ init_value : initial semaphore value. 125 * @ current_value : pointer on buffer for current semaphore value. 126 * @ return 0 if success / return -1 if failure. 127 *****************************************************************************************/ 128 int sys_sem( void * vaddr, 129 uint32_t operation, 130 uint32_t init_value, 131 uint32_t * current_value ); 132 133 /****************************************************************************************** 134 * [7] This function implement all operations on a POSIX condition variable. 135 * The kernel structure representing a condvar is defined in the remote_condvar.h file, 136 * The code implementing the operations is defined in the remote_condvar.c file. 137 ****************************************************************************************** 138 * @ vaddr : condvar virtual address in user space == identifier. 139 * @ operation : operation type (see below). 140 * @ attr : mutex virtual address in user space == identifier. 141 * @ return 0 if success / return -1 if failure. 142 *****************************************************************************************/ 143 int sys_condvar( void * condvar, 144 uint32_t operation, 145 void * mutex ); 146 147 /****************************************************************************************** 148 * [8] This function implement all operations on a POSIX barrier. 38 39 /****************************************************************************************** 40 * This function forces the calling thread to sleep, for a fixed number of cycles. 41 ****************************************************************************************** 42 * cycles : number of cycles. 43 *****************************************************************************************/ 44 int sys_alarm( uint32_t cycles ); 45 46 /****************************************************************************************** 47 * This function implement all operations on a POSIX barrier. 149 48 * The kernel structure representing a barrier is defined in the remote_barrier.h file. 150 49 * The code implementting the operations is defined in the remote_barrier.c file. … … 162 61 163 62 /****************************************************************************************** 164 * [9] This function implement all operations on a POSIX mutex. 165 * The kernel structure representing a barrier is defined in the remote_barrier.h file. 166 * The code implementting the operations is defined in the remote_barrier.c file. 167 ****************************************************************************************** 168 * @ vaddr : mutex virtual address in user space == identifier. 169 * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK 170 * @ attr : mutex attributes (non supported yet => must be 0). 171 * @ return 0 if success / return -1 if failure. 172 *****************************************************************************************/ 173 int sys_mutex( void * vaddr, 174 uint32_t operation, 175 uint32_t count ); 176 177 /****************************************************************************************** 178 * [10] This function causes the file named <old> to be renamed as <new>. 179 * If new exists, it is first removed. Both old and new must be of the same type (both 180 * must be either directories or non-directories) and must reside on the same file system. 181 * It guarantees that an instance of <new> will always exist, even if the system should 182 * crash in the middle of the operation. 183 ****************************************************************************************** 184 * @ old : old file name. 185 * @ new : new file name. 186 * @ return 0 if success / return -1 if failure. 187 *****************************************************************************************/ 188 int sys_rename( char *old, 189 char *new ); 190 191 /****************************************************************************************** 192 * [11] This function remove an existing mapping defined by the <addr> and <size> 193 * arguments in user space. This can modify the number of vsegs: 194 * (a) if the region is not entirely mapped in one existing vseg, it's an error. 195 * (b) if the region has same base and size as an existing vseg, the vseg is removed. 196 * (c) if the removed region cut the exiting vseg in two parts, it is resized. 197 * (d) if the removed region cut the vseg in three parts, it is modified, and a new 198 * vseg is created with same type. 199 * All existing VSL copies are updated. 200 ****************************************************************************************** 201 * @ addr : base address in user space. 202 * @ size : number of bytes. 203 * @ return 0 if success / return -1 if failure. 204 *****************************************************************************************/ 205 int sys_munmap( void * addr, 206 uint32_t size ); 207 208 /****************************************************************************************** 209 * [12] This function open or create an open file descriptor. 63 * This function change the current working directory in reference process descriptor. 210 64 ****************************************************************************************** 211 65 * @ pathname : pathname (can be relative or absolute). 212 * @ flags : bit vector attributes (see in shared_fcntl.h file) 213 * @ mode : access rights. 214 * @ return file descriptor index in fd_array if success / return -1 if failure. 215 *****************************************************************************************/ 216 int sys_open( char * pathname, 217 uint32_t flags, 218 uint32_t mode ); 219 220 /****************************************************************************************** 221 * [13] This function map physical memory (or a file) in the calling thread virtual space. 222 * The <attr> argument is a pointer on a structure for arguments (see shared_mman.h). 223 * The user defined virtual address (MAP_FIXED flag) is not supported. 224 * TODO : the access rights checking is not implemented yet [AG] 225 * TODO : the Copy on Write for MAP_PRIVATE is not implemented yet [AG] 226 ****************************************************************************************** 227 * @ attr : pointer on attributes structure. 228 * @ returns 0 if success / returns -1 if failure. 229 *****************************************************************************************/ 230 int sys_mmap( mmap_attr_t * attr ); 231 232 /****************************************************************************************** 233 * [14] This function read bytes from an open file identified by its file descriptor. 234 * The file can be a regular file or character oriented device. 235 * IRQs are enabled during this system call. 236 ****************************************************************************************** 237 * @ file_id : open file index in fd_array. 238 * @ buf : buffer virtual address in user space. 239 * @ count : number of bytes. 240 * @ returns number of bytes actually read if success / returns -1 if failure. 241 *****************************************************************************************/ 242 int sys_read( uint32_t file_id, 243 void * buf, 244 uint32_t count ); 245 246 /****************************************************************************************** 247 * [15] This function writes bytes to an open file identified by its file descriptor. 248 * The file can be a regular file or character oriented device. For a regular file, 249 * the target inode "size" field is updated if (offset + count) is larger than the 250 * current "size" value. The size value registered in the mappers of the parent(s) 251 * directory are not modified and will be asynchronously updated when the file is closed. 252 * IRQs are enabled during this system call. 253 ****************************************************************************************** 254 * @ file_id : open file index in fd_array. 255 * @ buf : buffer virtual address in user space. 256 * @ count : number of bytes. 257 * @ returns number of bytes actually written if success / returns -1 if failure. 258 *****************************************************************************************/ 259 int sys_write( uint32_t file_id, 260 void * buf, 261 uint32_t count ); 262 263 /****************************************************************************************** 264 * [16] This function repositions the offset of the file descriptor identified by the 265 * <file_id> argument, according to the operation type defined by the <whence> argument. 266 ****************************************************************************************** 267 * @ file_id : open file index in fd_array. 268 * @ offset : used to compute new offset value. 269 * @ whence : operation type (see below). 270 * @ returns new offset value if success / returns -1 if failure. 271 *****************************************************************************************/ 272 int sys_lseek( xptr_t file_id, 273 uint32_t offset, 274 uint32_t whence ); 275 276 /****************************************************************************************** 277 * [17] This function release the memory allocated for the file descriptor identified by 66 * @ return 0 if success / returns -1 if failure. 67 *****************************************************************************************/ 68 int sys_chdir( char * pathname ); 69 70 /****************************************************************************************** 71 * This function change the acces rights for the file/directory inode identified by the 72 * <pathname> argument, as specified by the <mode> argument. 73 ****************************************************************************************** 74 * @ pathname : pathname (can be relative or absolute). 75 * @ mode : acces rights. 76 * @ return 0 if success / returns -1 if failure. 77 *****************************************************************************************/ 78 int sys_chmod( char * pathname, 79 uint32_t mode ); 80 81 /****************************************************************************************** 82 * This function release the memory allocated for the file descriptor identified by 278 83 * the <file_id> argument, and remove the fd array_entry in all copies of the process 279 84 * descriptor. … … 285 90 286 91 /****************************************************************************************** 287 * [18] This function removes a directory entry identified by the <pathname> from the 288 * directory, and decrement the link count of the file referenced by the link. 289 * If the link count reduces to zero, and no process has the file open, then all resources 290 * associated with the file are reclaimed. If one or more process have the file open when 291 * the last link is removed, the link is removed, but the removal of the file is delayed 292 * until all references to it have been closed. 293 ****************************************************************************************** 294 * @ pathname : pathname (can be relative or absolute). 295 * @ returns 0 if success / returns -1 if failure. 296 *****************************************************************************************/ 297 int sys_unlink( char * pathname ); 298 299 /****************************************************************************************** 300 * [19] This function creates in the calling thread cluster an unnamed pipe, and two 301 * (read and write) file descriptors. 302 * TODO not implemented yet [AG] 303 ****************************************************************************************** 304 * @ file_id[0] : [out] read only file descriptor index. 305 * @ file_id[1] : [out] write only file descriptor index. 306 * @ return 0 if success / return -1 if failure. 307 *****************************************************************************************/ 308 int sys_pipe( uint32_t file_id[2] ); 309 310 /****************************************************************************************** 311 * [20] This function change the current working directory in reference process descriptor. 312 ****************************************************************************************** 313 * @ pathname : pathname (can be relative or absolute). 314 * @ return 0 if success / returns -1 if failure. 315 *****************************************************************************************/ 316 int sys_chdir( char * pathname ); 317 318 /****************************************************************************************** 319 * [21] This function implements the "mkdir" system call, creating a new directory in 320 * the file system, as defined by the <pathname> argument, with the access permission 321 * defined by the <rights> argument. All nodes but the last in the pathname must exist. 92 * This function closes the directory identified by the <dirp> argument, and releases 93 * all structures associated with the <dirp> pointer. 94 ****************************************************************************************** 95 * @ dirp : [in] user pointer on dirent array identifying the open directory. 96 * @ return 0 if success / returns -1 if failure. 97 *****************************************************************************************/ 98 int sys_closedir( DIR * dirp ); 99 100 /****************************************************************************************** 101 * This function implement all operations on a POSIX condition variable. 102 * The kernel structure representing a condvar is defined in the remote_condvar.h file, 103 * The code implementing the operations is defined in the remote_condvar.c file. 104 ****************************************************************************************** 105 * @ vaddr : condvar virtual address in user space == identifier. 106 * @ operation : operation type (see below). 107 * @ attr : mutex virtual address in user space == identifier. 108 * @ return 0 if success / return -1 if failure. 109 *****************************************************************************************/ 110 int sys_condvar( void * condvar, 111 uint32_t operation, 112 void * mutex ); 113 114 /****************************************************************************************** 115 * This debug function displays on the kernel terminal TXT0 an user defined string, 116 * or the current state of a kernel structure, identified by the <type> argument. 117 * The <arg0>, <arg1>, and <arg2> arguments depends on the structure type. 118 ****************************************************************************************** 119 * type : [in] type of display 120 * arg0 : [in] type dependant argument. 121 * arg1 : [in] type dependant argument. 122 * arg2 : [in] type dependant argument. 123 * @ return 0 if success / return -1 if illegal arguments 124 *****************************************************************************************/ 125 int sys_display( reg_t type, 126 reg_t arg0, 127 reg_t arg1, 128 reg_t arg2 ); 129 130 /****************************************************************************************** 131 * This function implement the "exec" system call on the kernel side. 132 * It creates, in the same cluster as the calling thread, a new process descriptor, 133 * and a new associated main thread descriptor, executing a new memory image defined 134 * by the <filename> argument. This new process inherit from the old process the PID 135 * and the PPID, as well as all open files registered in fd_array, including the TXT. 136 * The old process descriptor, and all its threads are blocked, and marked for deletion. 137 * Therefore the exec syscall does not return to the calling thread in case of success. 138 * This function must be called by the main thread (thread 0 in owner cluster), of the 139 * calling process, to destroy all process copies, and all other threads in all clusters. 140 ****************************************************************************************** 141 * Implementation note: 142 * It fill the calling process "exec_info" structure containing all informations required 143 * to initialize the new process descriptor and the associated main thread. This includes: 144 * - pathname to the new process .elf> file in VFS. 145 * - array of string pointers defining the process arguments, and the associated strings. 146 * - array of string pointers defining environment variables, and the associated strings. 147 * To do this, it calls the process_exec_get_strings function, that copies all relevant 148 * information from user space to kernel space, using functions defined in <hal_uspace.h>. 149 * Then it calls the process_make_exec() function that returns only in case of failure. 150 * 151 * TODO : the <envs> argument is not supported yet and must be NULL. 152 ****************************************************************************************** 153 * @ filename : string pointer on .elf filename (pointer in user space) 154 * @ user_args : array of strings on process arguments (pointers in user space) 155 * @ user_envs : array of strings on environment variables (pointers in user space) 156 * @ does not return if success / returns -1 if failure. 157 *****************************************************************************************/ 158 int sys_exec( char * filename, 159 char ** user_args, 160 char ** user_envs ); 161 162 /****************************************************************************************** 163 * This function implements the "exit" system call terminating a POSIX process. 322 164 * It can be called by any thread running in any cluster. 323 ****************************************************************************************** 324 * @ pathname : pathname defining the new directory location in file system. 325 * @ rights : access rights (non used yet). 326 * @ return 0 if success / return -1 if failure. 327 *****************************************************************************************/ 328 int sys_mkdir( char * pathname, 329 uint32_t rights ); 330 331 /****************************************************************************************** 332 * [22] This function creates a named FIFO file in the calling thread cluster. 333 * The associated read and write file descriptors mut be be explicitely created 334 * using the sys_open() function. 335 ****************************************************************************************** 336 * @ pathname : pathname (can be relative or absolute). 337 * @ mode : access rights (as defined in chmod). 338 * @ return 0 if success / returns -1 if failure. 339 *****************************************************************************************/ 340 int sys_mkfifo( char * pathname, 341 uint32_t mode ); 342 343 /****************************************************************************************** 344 * [23] This function creates an user level directory descriptor (including the associated 345 * array of user level dirents), and intialise it from the kernel directory mapper, that 346 * contains all entries in this directory). The directory is identified by the <pathname> 347 * argument. If the corresponding inode is missing in the Inode Tree, the inode is created, 348 * but the directory must exist in the file system. 349 * It returns a DIR pointer <dirp> on the dirent array in user space. 350 * The calling process fd_array is NOT modified. 351 ****************************************************************************************** 352 * @ pathname : [in] pathname (can be relative or absolute). 353 * @ dirp : [out] buffer for pointer on user directory (DIR). 354 * @ return 0 if success / returns -1 if failure. 355 *****************************************************************************************/ 356 int sys_opendir( char * pathname, 357 DIR ** dirp ); 358 359 /****************************************************************************************** 360 * [24] This function returns an user pointer on the dirent structure describing the 361 * next directory entry in the directory identified by the <dirp> argument. 362 ****************************************************************************************** 363 * @ dirp : [in] user pointer on dirent array identifying the open directory. 364 * @ buffer : [out] pointer on user buffer for a pointer on dirent in user space. 365 * @ return O if success / returns -1 if failure. 366 *****************************************************************************************/ 367 int sys_readdir( DIR * dirp, 368 struct dirent ** buffer ); 369 370 /****************************************************************************************** 371 * [25] This function closes the directory identified by the <dirp> argument, and releases 372 * all structures associated with the <dirp> pointer. 373 ****************************************************************************************** 374 * @ dirp : [in] user pointer on dirent array identifying the open directory. 375 * @ return 0 if success / returns -1 if failure. 376 *****************************************************************************************/ 377 int sys_closedir( DIR * dirp ); 378 379 /****************************************************************************************** 380 * [26] This function returns the pathname of the current working directory. 165 * It uses both remote accesses to access the owner process descriptor, and the 166 * RPC_PROCESS_SIGACTION to delete remote process copies and thread descriptors. 167 * In the present implementation, this function implements actually the _exit(): 168 * - it does not flush open output streams. 169 * - it does not close open streams. 170 ****************************************************************************************** 171 * @ status : terminaison status returned to parent process. 172 * @ return 0 if success / return -1 if failure. 173 *****************************************************************************************/ 174 int sys_exit( uint32_t status ); 175 176 /****************************************************************************************** 177 * This generic function implements the non-standard FBF related syscalls. 178 * The operation types mnemonics are defined in the <shared_fbf> file. 179 * The supported operations are defined in the <almosmkh.h> & <almosmkh.c> files. 180 * This function ckecks the syscall arguments, and call the relevant kernel function. 181 ****************************************************************************************** 182 * @ arg0 : operation type (mnemonics defined in shared_fbf.h) 183 * @ arg1 : depends on operation type 184 * @ arg2 : depends on operation type 185 * @ arg3 : depends on operation type 186 * @ return 0 if success / return -1 if illegal argument. 187 *****************************************************************************************/ 188 int sys_fbf( reg_t arg0, 189 reg_t arg1, 190 reg_t arg2, 191 reg_t arg3 ); 192 193 /****************************************************************************************** 194 * This function gives the process identified by the <pid> argument 195 * the exclusive ownership of its TXT_TX terminal (put it in foreground). 196 ****************************************************************************************** 197 * @ pid : process identifier. 198 * @ return 0 if success / return -1 if failure. 199 *****************************************************************************************/ 200 int sys_fg( pid_t pid ); 201 202 /****************************************************************************************** 203 * This function implements the "fsync" system call. 204 * It forces all modified pages of the file mapper identified by the <fd> argument 205 * to be copied to the IOC device. 206 * It can be called by any thread running in any cluster. 207 * TODO not implemented yet. 208 ****************************************************************************************** 209 * @ file_id : file descriptor index in fd_array. 210 * @ return 0 if success / return -1 if failure. 211 *****************************************************************************************/ 212 int sys_fsync( uint32_t file_id ); 213 214 /****************************************************************************************** 215 * This function implement the "fork" system call on the kernel side. 216 * The calling process descriptor (parent process), and the associated thread descriptor 217 * are replicated in a - likely - remote cluster, that becomes the child process owner. 218 * The child process get a new PID, and is linked to the parent PID. The child process 219 * inherit from its parent the memory image, and all open files (including the TXT). 220 * The child process becomes the TXT terminal owner. 221 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be 222 * stored in the calling thread descriptor by the specific fork_place() system call. 223 * If not, the kernel function makes a query to the DQDT to select the target cluster. 224 ****************************************************************************************** 225 * @ if success, returns child process PID to parent, and return O to child. 226 * @ if failure, returns -1 to parent / no child process is created. 227 *****************************************************************************************/ 228 int sys_fork( void ); 229 230 /****************************************************************************************** 231 * This function implements the non-standard "get_best_core" syscall. 232 * It selects, in a macro-cluster specified by the <base_cxy> and <level> arguments, 233 * the core that has the lowest load. 234 * When an active core has been found in the target macro-cluster, it writes into the 235 * <cxy> and <lid> buffers the cluster identifier and the core local index, and return 0. 236 * It returns -1 in case of illegal arguments (level / cxy / lid). 237 * It returns +1 if there is no active core in specified macro-cluster. 238 ****************************************************************************************** 239 * @ base_cxy : [in] any cluster identifier in macro-cluster. 240 * @ level : [in] macro-cluster level in [1,2,3,4,5]. 241 * @ cxy : [out] selected core cluster identifier. 242 * @ lid : [out] selected core local index in cluster. 243 * @ return 0 if success / -1 if illegal arguments / +1 if no core in macro-clusters. 244 *****************************************************************************************/ 245 int sys_get_best_core( uint32_t base_cxy, 246 uint32_t level, 247 uint32_t * cxy, 248 uint32_t * lid ); 249 250 /****************************************************************************************** 251 * This function implement the non-standard get_config() syscall. 252 * It returns the global hardware platform parameters in the <config> shared structure, 253 * that is defined in the shared_almos.h file. 254 ****************************************************************************************** 255 * @ config : [out] pointer on the hard_config_t structure in user space. 256 * @ return 0 if success / return -1 if illegal argument 257 *****************************************************************************************/ 258 int sys_get_config( struct hard_config_s * config ); 259 260 /****************************************************************************************** 261 * This function implements the non-standard get_core_id() syscall. 262 * It returns in <cxy> and <lid> the calling core cluster and local index. 263 ****************************************************************************************** 264 * @ cxy : [out] cluster identifier (fixed format) 265 * @ lid : [out] core local index in cluster. 266 * @ return 0 if success / return -1 if illegal arguments 267 *****************************************************************************************/ 268 int sys_get_core_id( uint32_t * cxy, 269 uint32_t * lid ); 270 271 /****************************************************************************************** 272 * This function implements the non-standard get_cycle() syscall. 273 * It returns in a 64 bits user buffer the calling core cycles count. 274 * It uses both the hardware register and the core descriptor cycles count to take 275 * into account a possible harware register overflow in 32 bits architectures. 276 ****************************************************************************************** 277 * cycle : [out] address of buffer in user space. 278 * @ return 0 if success / return -1 if illegal arguments 279 *****************************************************************************************/ 280 int sys_get_cycle( uint64_t * cycle ); 281 282 /****************************************************************************************** 283 * This function returns the pathname of the current working directory. 381 284 ****************************************************************************************** 382 285 * buf : buffer addres in user space. … … 388 291 389 292 /****************************************************************************************** 390 * [27] This function tests whether a given file descriptor dentified by the <file_id> 293 * This function implements the non-standard "get_nb_cores" syscall. 294 * It writes in the <ncores> buffer the number of cores in the target cluster <cxy>. 295 ****************************************************************************************** 296 * @ cxy : [in] target cluster identifier. 297 * @ ncores : [out] number of cores / 0 if cluster cxy undefined in architecture. 298 * @ return 0 if success / return -1 if illegal "ncores" arguments. 299 *****************************************************************************************/ 300 int sys_get_nb_cores( uint32_t cxy, 301 uint32_t * ncores ); 302 303 /****************************************************************************************** 304 * This function implements the "getpid" system call on the kernel side. 305 ****************************************************************************************** 306 * @ returns the process PID for the calling thread. 307 *****************************************************************************************/ 308 int sys_getpid( void ); 309 310 /****************************************************************************************** 311 * This function implements the non-standard "get_thread_info" syscall. 312 * It copies in the user structure defined by the <info> argument the values registered 313 * in the calling thread "thread_info_t" kernel structure. 314 ****************************************************************************************** 315 * @ info : [out] pointer on thread_info_t structure in user space. 316 * @ return 0 if success / return -1 if illegal argument. 317 *****************************************************************************************/ 318 int sys_get_thread_info( thread_info_t * info ); 319 320 /****************************************************************************************** 321 * This function tests whether a given file descriptor dentified by the <file_id> 391 322 * argument is an open file descriptor referring to a terminal. 392 323 ****************************************************************************************** … … 397 328 398 329 /****************************************************************************************** 399 * [28] This function forces the calling thread to sleep, for a fixed number of cycles. 400 ****************************************************************************************** 401 * cycles : number of cycles. 402 *****************************************************************************************/ 403 int sys_alarm( uint32_t cycles ); 404 405 /****************************************************************************************** 406 * [29] This function removes a directory file whose name is given by <pathname>. 407 * The directory must not have any entries other than `.' and `..'. 408 ****************************************************************************************** 409 * @ pathname : pathname (can be relative or absolute). 410 * @ return 0 if success / returns -1 if failure. 411 *****************************************************************************************/ 412 int sys_rmdir( char * pathname ); 413 414 /****************************************************************************************** 415 * [30] This function implement the operations related to User Thread Local Storage. 416 * It is actually implemented as an uint32_t variable in the thread descriptor. 417 ****************************************************************************************** 418 * @ operation : UTLS operation type as defined below. 419 * @ value : argument value for the UTLS_SET operation. 420 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure. 421 *****************************************************************************************/ 422 int sys_utls( uint32_t operation, 423 uint32_t value ); 424 425 /****************************************************************************************** 426 * [31] This function change the acces rights for the file/dir identified by the 427 * pathname argument. 428 ****************************************************************************************** 429 * @ pathname : pathname (can be relative or absolute). 430 * @ rights : acces rights. 431 * @ return 0 if success / returns -1 if failure. 432 *****************************************************************************************/ 433 int sys_chmod( char * pathname, 434 uint32_t rights ); 435 436 /****************************************************************************************** 437 * [32] This function associate a specific signal handler to a given signal type. 438 * The handlers for the SIGKILL and SIGSTOP signals cannot be redefined. 439 ****************************************************************************************** 440 * @ sig_id : index defining signal type (from 1 to 31). 441 * @ handler : pointer on fonction implementing the specific handler. 442 * @ return 0 if success / returns -1 if failure. 443 *****************************************************************************************/ 444 int sys_signal( uint32_t sig_id, 445 void * handler ); 446 447 /****************************************************************************************** 448 * [33] This function returns in the structure <tv>, defined in the time.h file, 449 * the current time (in seconds & micro-seconds). 450 * It is computed from the calling core descriptor. 451 * The timezone is not supported. 452 ****************************************************************************************** 453 * @ tv : pointer on the timeval structure. 454 * @ tz : pointer on the timezone structure : must be NULL. 455 * @ return 0 if success / returns -1 if failure. 456 *****************************************************************************************/ 457 int sys_timeofday( struct timeval * tv, 458 struct timezone * tz ); 459 460 /****************************************************************************************** 461 * [34] This function implements the "kill" system call on the kernel side. 330 * This function returns a non-zero value in the <is_fg> buffer when the process 331 * identified by the <pid> argument is the current TXT owner. 332 ****************************************************************************************** 333 * @ pid : process identifier. 334 * @ is_fg : pointer on buffer. 335 * @ return 0 if success / return -1 if failure. 336 *****************************************************************************************/ 337 int sys_is_fg( pid_t pid, 338 uint32_t * is_fg ); 339 340 /****************************************************************************************** 341 * This function implements the "kill" system call on the kernel side. 462 342 * It register the signal defined by the <sig_id> argument in all thread descriptors 463 343 * of a target process identified by the <pid> argument. This is done in all clusters … … 477 357 478 358 /****************************************************************************************** 479 * [35] This function implements the "getpid" system call on the kernel side. 359 * This function repositions the offset of the file descriptor identified by the 360 * <file_id> argument, according to the operation type defined by the <whence> argument. 361 ****************************************************************************************** 362 * @ file_id : open file index in fd_array. 363 * @ offset : used to compute new offset value. 364 * @ whence : operation type (see below). 365 * @ returns new offset value if success / returns -1 if failure. 366 *****************************************************************************************/ 367 int sys_lseek( xptr_t file_id, 368 uint32_t offset, 369 uint32_t whence ); 370 371 /****************************************************************************************** 372 * This function implements the "mkdir" system call, creating a new directory in 373 * the file system, as defined by the <pathname> argument, with the access permission 374 * defined by the <rights> argument. All nodes but the last in the pathname must exist. 375 * It can be called by any thread running in any cluster. 376 ****************************************************************************************** 377 * @ pathname : pathname defining the new directory location in file system. 378 * @ rights : access rights (non used yet). 379 * @ return 0 if success / return -1 if failure. 380 *****************************************************************************************/ 381 int sys_mkdir( char * pathname, 382 uint32_t rights ); 383 384 /****************************************************************************************** 385 * This function creates a new inode/dentry couple of type FIFO, and registers it in 386 * the Inode-Tree, as specified by the <pathname> and <mode> arguments. 387 * The associated file descriptors are created later, using the sys_open() function. 388 ****************************************************************************************** 389 * @ pathname : pathname (can be relative or absolute). 390 * @ mode : access rights (as defined in chmod). 391 * @ return 0 if success / returns -1 if failure. 392 *****************************************************************************************/ 393 int sys_mkfifo( char * pathname, 394 uint32_t mode ); 395 396 /****************************************************************************************** 397 * This function map physical memory (or a file) in the calling thread virtual space. 398 * The <attr> argument is a pointer on a structure for arguments (see shared_mman.h). 399 * The user defined virtual address (MAP_FIXED flag) is not supported. 400 * TODO : the access rights checking is not implemented yet [AG] 401 * TODO : the Copy on Write for MAP_PRIVATE is not implemented yet [AG] 402 ****************************************************************************************** 403 * @ attr : pointer on attributes structure. 404 * @ returns 0 if success / returns -1 if failure. 405 *****************************************************************************************/ 406 int sys_mmap( mmap_attr_t * attr ); 407 408 /****************************************************************************************** 409 * This function remove an existing mapping defined by the <addr> and <size> 410 * arguments in user space. This can modify the number of vsegs: 411 * (a) if the region is not entirely mapped in one existing vseg, it's an error. 412 * (b) if the region has same base and size as an existing vseg, the vseg is removed. 413 * (c) if the removed region cut the exiting vseg in two parts, it is resized. 414 * (d) if the removed region cut the vseg in three parts, it is modified, and a new 415 * vseg is created with same type. 416 * All existing VSL copies are updated. 417 ****************************************************************************************** 418 * @ addr : base address in user space. 419 * @ size : number of bytes. 420 * @ return 0 if success / return -1 if failure. 421 *****************************************************************************************/ 422 int sys_munmap( void * addr, 423 uint32_t size ); 424 425 /****************************************************************************************** 426 * This function implement all operations on a POSIX mutex. 427 * The kernel structure representing a barrier is defined in the remote_barrier.h file. 428 * The code implementting the operations is defined in the remote_barrier.c file. 429 ****************************************************************************************** 430 * @ vaddr : mutex virtual address in user space == identifier. 431 * @ operation : MUTEX_INIT / MUTEX_DESTROY / MUTEX_LOCK / MUTEX_UNLOCK 432 * @ attr : mutex attributes (non supported yet => must be 0). 433 * @ return 0 if success / return -1 if failure. 434 *****************************************************************************************/ 435 int sys_mutex( void * vaddr, 436 uint32_t operation, 437 uint32_t count ); 438 439 /****************************************************************************************** 440 * This function creates a new file descriptor for an existing inode. 441 * It creates a new inode if required by the flags. 442 ****************************************************************************************** 443 * @ pathname : pathname in the inode tree (can be relative or absolute). 444 * @ flags : bit vector attributes (see in shared_fcntl.h file) 445 * @ mode : access rights. 446 * @ return file descriptor index in fd_array if success / return -1 if failure. 447 *****************************************************************************************/ 448 int sys_open( char * pathname, 449 uint32_t flags, 450 uint32_t mode ); 451 452 /****************************************************************************************** 453 * This function creates an user level directory descriptor (including the associated 454 * array of user level dirents), and intialise it from the kernel directory mapper, that 455 * contains all entries in this directory). The directory is identified by the <pathname> 456 * argument. If the corresponding inode is missing in the Inode Tree, the inode is created, 457 * but the directory must exist in the file system. 458 * It returns a DIR pointer <dirp> on the dirent array in user space. 459 * The calling process fd_array is NOT modified. 460 ****************************************************************************************** 461 * @ pathname : [in] pathname (can be relative or absolute). 462 * @ dirp : [out] buffer for pointer on user directory (DIR). 463 * @ return 0 if success / returns -1 if failure. 464 *****************************************************************************************/ 465 int sys_opendir( char * pathname, 466 DIR ** dirp ); 467 468 /****************************************************************************************** 469 * This function creates in the calling thread cluster an unnamed pipe, implemented 470 * as a remote_buffer_t, creates two (read and write) file descriptors, and links these 471 * two file descriptors to the pipe. 472 * TODO : the dynamic memory allocation in case of buffer full is not implemented. 473 ****************************************************************************************** 474 * @ fd : pointeur on a 2 slots array of fdid : fd[0] read / fd[1] write. 475 * @ return 0 if success / return -1 if failure. 476 *****************************************************************************************/ 477 int sys_pipe( fdid_t * fd ); 478 479 /****************************************************************************************** 480 * This function implements the non-standard place_fork() syscall. 481 * It can be used to specify the target cluster <cxy> for a new process created 482 * by a subsequent fork() syscall. 483 * WARNING: it must be called before each fork() syscall, as the placement specification 484 * is reset by the fork syscall. 485 ****************************************************************************************** 486 * @ cxy : cluster identifier. 487 * @ return 0 if success / return -1 if failure. 488 *****************************************************************************************/ 489 int sys_place_fork( uint32_t cxy ); 490 491 /****************************************************************************************** 492 * This function read bytes from an open file identified by its file descriptor. 493 * The file can be a regular file or character oriented device. 494 * IRQs are enabled during this system call. 495 ****************************************************************************************** 496 * @ file_id : open file index in fd_array. 497 * @ buf : buffer virtual address in user space. 498 * @ count : number of bytes. 499 * @ returns number of bytes actually read if success / returns -1 if failure. 500 *****************************************************************************************/ 501 int sys_read( uint32_t file_id, 502 void * buf, 503 uint32_t count ); 504 505 /****************************************************************************************** 506 * This function returns an user pointer on the dirent structure describing the 507 * next directory entry in the directory identified by the <dirp> argument. 508 ****************************************************************************************** 509 * @ dirp : [in] user pointer on dirent array identifying the open directory. 510 * @ buffer : [out] pointer on user buffer for a pointer on dirent in user space. 511 * @ return O if success / returns -1 if failure. 512 *****************************************************************************************/ 513 int sys_readdir( DIR * dirp, 514 struct dirent ** buffer ); 515 516 /****************************************************************************************** 517 * This function causes the file named <old> to be renamed as <new>. 518 * If new exists, it is first removed. Both old and new must be of the same type (both 519 * must be either directories or non-directories) and must reside on the same file system. 520 * It guarantees that an instance of <new> will always exist, even if the system should 521 * crash in the middle of the operation. 522 ****************************************************************************************** 523 * @ old : old file name. 524 * @ new : new file name. 525 * @ return 0 if success / return -1 if failure. 526 *****************************************************************************************/ 527 int sys_rename( char *old, 528 char *new ); 529 530 /****************************************************************************************** 531 * This function removes a directory file whose name is given by <pathname>. 532 * The directory must not have any entries other than `.' and `..'. 533 ****************************************************************************************** 534 * @ pathname : pathname (can be relative or absolute). 535 * @ return 0 if success / returns -1 if failure. 536 *****************************************************************************************/ 537 int sys_rmdir( char * pathname ); 538 539 /****************************************************************************************** 540 * This function implement all operations on a POSIX unnamed semaphore, 541 * that can be shared by threads running in different clusters. 542 * The kernel structure representing a remote semaphore is in the remote_sem.h file, 543 * and the code implementing the operations is in the remore_sem.c file. 544 ****************************************************************************************** 545 * @ vaddr : semaphore virtual address in user space == identifier. 546 * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT. 547 * @ init_value : initial semaphore value. 548 * @ current_value : pointer on buffer for current semaphore value. 549 * @ return 0 if success / return -1 if failure. 550 *****************************************************************************************/ 551 int sys_sem( void * vaddr, 552 uint32_t operation, 553 uint32_t init_value, 554 uint32_t * current_value ); 555 556 /****************************************************************************************** 557 * This function associate a specific signal handler to a given signal type. 558 * The handlers for the SIGKILL and SIGSTOP signals cannot be redefined. 480 559 ****************************************************************************************** 481 * @ returns the process PID for the calling thread. 482 *****************************************************************************************/ 483 int sys_getpid( void ); 484 485 /****************************************************************************************** 486 * [36] This function implement the "fork" system call on the kernel side. 487 * The calling process descriptor (parent process), and the associated thread descriptor 488 * are replicated in a - likely - remote cluster, that becomes the child process owner. 489 * The child process get a new PID, and is linked to the parent PID. The child process 490 * inherit from its parent the memory image, and all open files (including the TXT). 491 * The child process becomes the TXT terminal owner. 492 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be 493 * stored in the calling thread descriptor by the specific fork_place() system call. 494 * If not, the kernel function makes a query to the DQDT to select the target cluster. 495 ****************************************************************************************** 496 * @ if success, returns child process PID to parent, and return O to child. 497 * @ if failure, returns -1 to parent / no child process is created. 498 *****************************************************************************************/ 499 int sys_fork( void ); 500 501 /****************************************************************************************** 502 * [37] This function implement the "exec" system call on the kernel side. 503 * It creates, in the same cluster as the calling thread, a new process descriptor, 504 * and a new associated main thread descriptor, executing a new memory image defined 505 * by the <filename> argument. This new process inherit from the old process the PID 506 * and the PPID, as well as all open files (including the TXT). 507 * The old process descriptor, and all its threads are blocked, and marked for deletion. 508 * Therefore the exec syscall does not return to the calling thread in case of success. 509 * This function build an exec_info_t structure containing the new process arguments, 510 * as defined by the <arv> argument, and the new process environment variables, 511 * as defined by the <envp> argument. 512 * TODO : the <argv> and <envp> arguments are not supported yet (both must be NULL). 513 ****************************************************************************************** 514 * @ filename : string pointer on .elf filename (pointer in user space) 515 * @ argv : array of strings on process arguments (pointers in user space) 516 * @ envp : array of strings on environment variables (pointers in user space) 517 * @ does not return if success / returns -1 if failure. 518 *****************************************************************************************/ 519 int sys_exec( char * filename, 520 char ** argv, 521 char ** envp ); 522 523 /****************************************************************************************** 524 * [38] This function returns in the <stat> structure, defined in the "shared_syscalls.h" 560 * @ sig_id : index defining signal type (from 1 to 31). 561 * @ handler : pointer on fonction implementing the specific handler. 562 * @ return 0 if success / returns -1 if failure. 563 *****************************************************************************************/ 564 int sys_signal( uint32_t sig_id, 565 void * handler ); 566 567 /****************************************************************************************** 568 * This generic function implements the socket related syscalls. 569 * The operation types mnemonics are defined in the <shared_socket> file. 570 * The supported operations are defined in the <socket.h> & <socket.c> files. 571 * This function ckecks the syscall arguments, and call the relevant kernel function. 572 ****************************************************************************************** 573 * @ arg0 : operation type (mnemonics defined in shared_socket.h) 574 * @ arg1 : depends on operation type 575 * @ arg2 : depends on operation type 576 * @ arg3 : depends on operation type 577 * @ return 0 if success / return -1 if illegal argument. 578 *****************************************************************************************/ 579 int sys_socket( reg_t arg0, 580 reg_t arg1, 581 reg_t arg2, 582 reg_t arg3 ); 583 584 /****************************************************************************************** 585 * This function returns in the <stat> structure, defined in the "shared_syscalls.h" 525 586 * file, various informations on the file/directory identified by the <pathname> argument. 526 587 * TODO only the <st_ino>, <st_mode>,<st_uid>,<st_gid>,<st_size> are set. … … 534 595 535 596 /****************************************************************************************** 536 * [39] This blocking function waits a change of a child process state, that can be: 597 * This function implements the "sync" system call. 598 * It forces all modified pages in all kernel mappers to be copied to the IOC device. 599 * It can be called by any thread running in any cluster. 600 * TODO not implemented yet. 601 ****************************************************************************************** 602 * @ return 0 if success / return -1 if failure. 603 *****************************************************************************************/ 604 int sys_sync( void ); 605 606 /****************************************************************************************** 607 * This function returns in the structure <tv>, defined in the time.h file, 608 * the current time (in seconds & micro-seconds). 609 * It is computed from the calling core descriptor. 610 * The timezone is not supported. 611 ****************************************************************************************** 612 * @ tv : pointer on the timeval structure. 613 * @ tz : pointer on the timezone structure : must be NULL. 614 * @ return 0 if success / returns -1 if failure. 615 *****************************************************************************************/ 616 int sys_timeofday( struct timeval * tv, 617 struct timezone * tz ); 618 619 /****************************************************************************************** 620 * This function requests a target thread identified by its <trdid> argument 621 * to be cancelled. It calls the thread_kill() function to block the target thread 622 * on the THREAD_BLOCKED_GLOBAL condition, and to set the THREAD_FLAG_REQ_DELETE. 623 * The thread will be detached from its process, and the memory allocated to the thread 624 * descriptor will be released by the scheduler at the next scheduling point. 625 ****************************************************************************************** 626 * @ trdid : thread identifier. 627 * @ return 0 if success / return -1 if illegal argument. 628 *****************************************************************************************/ 629 int sys_thread_cancel( trdid_t trdid ); 630 631 /****************************************************************************************** 632 * This function creates a new user thread. The <user_attr> argument is a pointer 633 * on astructure containing the thread attributes, defined in thread.h file. 634 ****************************************************************************************** 635 * @ trdid_ptr : [out] pointer on buffer for created thread trdid. 636 * @ user_attr : [in] pointer on thread attributes structure. 637 * @ start_func : [in] pointer on start function. 638 * @ start_args : [in] pointer on start function arguments. 639 * @ return 0 if success / return -1 if failure. 640 *****************************************************************************************/ 641 int sys_thread_create( trdid_t * trdid_ptr, 642 struct pthread_attr_s * user_attr, 643 void * start_func, 644 void * start_args ); 645 646 /****************************************************************************************** 647 * This function detach a joinable thread. 648 ****************************************************************************************** 649 * @ trdid : thread identifier. 650 * @ return 0 if success / return -1 if failure. 651 *****************************************************************************************/ 652 int sys_thread_detach( trdid_t trdid ); 653 654 /****************************************************************************************** 655 * This function terminates the execution of the calling user thread, and makes 656 * the <exit_status> pointer available to any successful pthread_join() with the 657 * terminating thread. 658 * - If the calling thread is the main thread, it calls the sys_exit() function to delete 659 * completely the user process. 660 * - if the calling thread is not the main thread, it registers the <exit_status> pointer 661 * in the thread descriptor, and calls the thread_delete() function, that will set the 662 * THREAD_SIG_EXIT signal, set the THREAD_BLOCKED_GLOBAL bit in thread descriptor, and 663 * deschedules. All memory allocated to the thread is released later by the scheduler. 664 * If the thread is in "detached" mode, the thread_delete() function implements 665 * the synchonisation with the joining thread. 666 ****************************************************************************************** 667 * @ exit_status : [out] pointer to be returned to joining thread if thread is attached. 668 * @ return 0 if success / return -1 if all locks not released or illegal argument. 669 *****************************************************************************************/ 670 int sys_thread_exit( void * exit_status ); 671 672 /****************************************************************************************** 673 * This blocking function suspend execution of the calling thread until completion 674 * of another target thread identified by the <trdid> argument. 675 * The target thread must be joinable (running in ATTACHED mode), and must be different 676 * from the calling thread. 677 * If the <exit_value> argument is not NULL, the value passed to pthread_exit() by the 678 * target thread is stored in the location referenced by exit_value. 679 ****************************************************************************************** 680 * @ trdid : [in] target thread identifier. 681 * @ thread : [out] buffer for exit_value returned by target thread. 682 * @ return 0 if success / return -1 if failure. 683 *****************************************************************************************/ 684 int sys_thread_join( trdid_t trdid, 685 void ** exit_value ); 686 687 /****************************************************************************************** 688 * This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition, 689 * and deschedule. 690 ****************************************************************************************** 691 * @ return 0 if success / returns -1 if failure. 692 *****************************************************************************************/ 693 int sys_thread_sleep( void ); 694 695 /****************************************************************************************** 696 * This function unblock the thread identified by its <trdid> from the 697 * THREAD_BLOCKED_GLOBAL condition. 698 ****************************************************************************************** 699 * @ trdid : target thread identifier. 700 * @ return 0 if success / return -1 if failure. 701 *****************************************************************************************/ 702 int sys_thread_wakeup( trdid_t trdid ); 703 704 /****************************************************************************************** 705 * This function calls the scheduler for the core running the calling thread. 706 ****************************************************************************************** 707 * @ x_size : [out] number of clusters in a row. 708 * @ y_size : [out] number of clusters in a column. 709 * @ ncores : [out] number of cores per cluster. 710 * @ return always 0. 711 *****************************************************************************************/ 712 int sys_thread_yield( void ); 713 714 /****************************************************************************************** 715 * This debug function is used to activate / desactivate the context switches trace 716 * for a core identified by the <cxy> and <lid> arguments. 717 * It can be called by any other thread in the same process. 718 ****************************************************************************************** 719 * @ active : activate trace if true / desactivate trace if false. 720 * @ cxy : cluster identifier. 721 * @ lid : core local index. 722 * @ returns O if success / returns -1 if failure. 723 *****************************************************************************************/ 724 int sys_trace( bool_t active, 725 cxy_t cxy, 726 lid_t lid ); 727 728 /****************************************************************************************** 729 * This function implement the operations related to User Thread Local Storage. 730 * It is actually implemented as an uint32_t variable in the thread descriptor. 731 ****************************************************************************************** 732 * @ operation : UTLS operation type as defined below. 733 * @ value : argument value for the UTLS_SET operation. 734 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure. 735 *****************************************************************************************/ 736 int sys_utls( uint32_t operation, 737 uint32_t value ); 738 739 /****************************************************************************************** 740 * This function removes a directory entry identified by the <pathname> from the 741 * directory, and decrement the link count of the file referenced by the link. 742 * If the link count reduces to zero, and no process has the file open, then all resources 743 * associated with the file are reclaimed. If one or more process have the file open when 744 * the last link is removed, the link is removed, but the removal of the file is delayed 745 * until all references to it have been closed. 746 ****************************************************************************************** 747 * @ pathname : pathname (can be relative or absolute). 748 * @ returns 0 if success / returns -1 if failure. 749 *****************************************************************************************/ 750 int sys_unlink( char * pathname ); 751 752 /****************************************************************************************** 753 * This blocking function waits a change of a child process state, that can be: 537 754 * - a termination of child following a process_make_exit(). 538 755 * - a termination of child following a process_make_kill(). … … 558 775 559 776 /****************************************************************************************** 560 * [40] This function implement the non-standard get_config() syscall. 561 * It returns the global hardware platform parameters in the <config> shared structure, 562 * that is defined in the shared_almos.h file. 563 ****************************************************************************************** 564 * @ config : [out] pointer on the hard_config_t structure in user space. 565 * @ return 0 if success / return -1 if illegal argument 566 *****************************************************************************************/ 567 int sys_get_config( struct hard_config_s * config ); 568 569 /****************************************************************************************** 570 * [41] This function implements the non-standard get_core_id() syscall. 571 * It returns in <cxy> and <lid> the calling core cluster and local index. 572 ****************************************************************************************** 573 * @ cxy : [out] cluster identifier (fixed format) 574 * @ lid : [out] core local index in cluster. 575 * @ return 0 if success / return -1 if illegal arguments 576 *****************************************************************************************/ 577 int sys_get_core_id( uint32_t * cxy, 578 uint32_t * lid ); 579 580 /****************************************************************************************** 581 * [42] This function implements the non-standard get_cycle() syscall. 582 * It returns in a 64 bits user buffer the calling core cycles count. 583 * It uses both the hardware register and the core descriptor cycles count to take 584 * into account a possible harware register overflow in 32 bits architectures. 585 ****************************************************************************************** 586 * cycle : [out] address of buffer in user space. 587 * @ return 0 if success / return -1 if illegal arguments 588 *****************************************************************************************/ 589 int sys_get_cycle( uint64_t * cycle ); 590 591 /****************************************************************************************** 592 * [43] This debug function displays on the kernel terminal TXT0 an user defined string, 593 * or the current state of a kernel structure, identified by the <type> argument. 594 * The <arg0>, <arg1>, and <arg2> arguments depends on the structure type. 595 ****************************************************************************************** 596 * type : [in] type of display 597 * arg0 : [in] type dependant argument. 598 * arg1 : [in] type dependant argument. 599 * arg2 : [in] type dependant argument. 600 * @ return 0 if success / return -1 if illegal arguments 601 *****************************************************************************************/ 602 int sys_display( reg_t type, 603 reg_t arg0, 604 reg_t arg1, 605 reg_t arg2 ); 606 607 /****************************************************************************************** 608 * [44] This function implements the non-standard place_fork() syscall. 609 * It can be used to specify the target cluster <cxy> for a new process created 610 * by a subsequent fork() syscall. 611 * WARNING: it must be called before each fork() syscall, as the placement specification 612 * is reset by the fork syscall. 613 ****************************************************************************************** 614 * @ cxy : cluster identifier. 615 * @ return 0 if success / return -1 if failure. 616 *****************************************************************************************/ 617 int sys_place_fork( uint32_t cxy ); 618 619 /****************************************************************************************** 620 * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition, 621 * and deschedule. 622 ****************************************************************************************** 623 * @ return 0 if success / returns -1 if failure. 624 *****************************************************************************************/ 625 int sys_thread_sleep( void ); 626 627 /****************************************************************************************** 628 * [46] This function unblock the thread identified by its <trdid> from the 629 * THREAD_BLOCKED_GLOBAL condition. 630 ****************************************************************************************** 631 * @ trdid : target thread identifier. 632 * @ return 0 if success / return -1 if failure. 633 *****************************************************************************************/ 634 int sys_thread_wakeup( trdid_t trdid ); 635 636 /****************************************************************************************** 637 * [47] This debug function is used to activate / desactivate the context switches trace 638 * for a core identified by the <cxy> and <lid> arguments. 639 * It can be called by any other thread in the same process. 640 ****************************************************************************************** 641 * @ active : activate trace if true / desactivate trace if false. 642 * @ cxy : cluster identifier. 643 * @ lid : core local index. 644 * @ returns O if success / returns -1 if failure. 645 *****************************************************************************************/ 646 int sys_trace( bool_t active, 647 cxy_t cxy, 648 lid_t lid ); 649 650 /****************************************************************************************** 651 * [48] This function gives the process identified by the <pid> argument 652 * the exclusive ownership of its TXT_TX terminal (put it in foreground). 653 ****************************************************************************************** 654 * @ pid : process identifier. 655 * @ return 0 if success / return -1 if failure. 656 *****************************************************************************************/ 657 int sys_fg( pid_t pid ); 658 659 /****************************************************************************************** 660 * [49] This function returns a non-zero value in the <is_fg> buffer when the process 661 * identified by the <pid> argument is the current TXT owner. 662 ****************************************************************************************** 663 * @ pid : process identifier. 664 * @ is_fg : pointer on buffer. 665 * @ return 0 if success / return -1 if failure. 666 *****************************************************************************************/ 667 int sys_is_fg( pid_t pid, 668 uint32_t * is_fg ); 669 670 /****************************************************************************************** 671 * [50] This function implements the "exit" system call terminating a POSIX process. 672 * It can be called by any thread running in any cluster. 673 * It uses both remote accesses to access the owner process descriptor, and the 674 * RPC_PROCESS_SIGACTION to delete remote process copies and thread descriptors. 675 * In the present implementation, this function implements actually the _exit(): 676 * - it does not flush open output streams. 677 * - it does not close open streams. 678 ****************************************************************************************** 679 * @ status : terminaison status returned to parent process. 680 * @ return 0 if success / return -1 if failure. 681 *****************************************************************************************/ 682 int sys_exit( uint32_t status ); 683 684 /****************************************************************************************** 685 * [51] This function implements the "sync" system call. 686 * It forces all modified pages in all kernel mappers to be copied to the IOC device. 687 * It can be called by any thread running in any cluster. 688 * TODO not implemented yet. 689 ****************************************************************************************** 690 * @ return 0 if success / return -1 if failure. 691 *****************************************************************************************/ 692 int sys_sync( void ); 693 694 /****************************************************************************************** 695 * [52] This function implements the "fsync" system call. 696 * It forces all modified pages of the file mapper identified by the <fd> argument 697 * to be copied to the IOC device. 698 * It can be called by any thread running in any cluster. 699 * TODO not implemented yet. 700 ****************************************************************************************** 701 * @ file_id : file descriptor index in fd_array. 702 * @ return 0 if success / return -1 if failure. 703 *****************************************************************************************/ 704 int sys_fsync( uint32_t file_id ); 705 706 /****************************************************************************************** 707 * [53] This function implements the non-standard "get_best_core" syscall. 708 * It selects, in a macro-cluster specified by the <base_cxy> and <level> arguments, 709 * the core that has the lowest load. 710 * When an active core has been found in the target macro-cluster, it writes into the 711 * <cxy> and <lid> buffers the cluster identifier and the core local index, and return 0. 712 * It returns -1 in case of illegal arguments (level / cxy / lid). 713 * It returns +1 if there is no active core in specified macro-cluster. 714 ****************************************************************************************** 715 * @ base_cxy : [in] any cluster identifier in macro-cluster. 716 * @ level : [in] macro-cluster level in [1,2,3,4,5]. 717 * @ cxy : [out] selected core cluster identifier. 718 * @ lid : [out] selected core local index in cluster. 719 * @ return 0 if success / -1 if illegal arguments / +1 if no core in macro-clusters. 720 *****************************************************************************************/ 721 int sys_get_best_core( uint32_t base_cxy, 722 uint32_t level, 723 uint32_t * cxy, 724 uint32_t * lid ); 725 726 /****************************************************************************************** 727 * [54] This function implements the non-standard "get_nb_cores" syscall. 728 * It writes in the <ncores> buffer the number of cores in the target cluster <cxy>. 729 ****************************************************************************************** 730 * @ cxy : [in] target cluster identifier. 731 * @ ncores : [out] number of cores / 0 if cluster cxy undefined in architecture. 732 * @ return 0 if success / return -1 if illegal "ncores" arguments. 733 *****************************************************************************************/ 734 int sys_get_nb_cores( uint32_t cxy, 735 uint32_t * ncores ); 736 737 /****************************************************************************************** 738 * [55] This function implements the non-standard "get_thread_info" syscall. 739 * It copies in the user structure defined by the <info> argument the values registered 740 * in the calling thread "thread_info_t" kernel structure. 741 ****************************************************************************************** 742 * @ info : [out] pointer on thread_info_t structure in user space. 743 * @ return 0 if success / return -1 if illegal argument. 744 *****************************************************************************************/ 745 int sys_get_thread_info( thread_info_t * info ); 746 747 /****************************************************************************************** 748 * [56] This generic function implements the non-standard FBF related syscalls. 749 * The operation types mnemonics are defined in the <shared_fbf> file. 750 * The supported operations are defined in the <almosmkh.h> & <almosmkh.c> files. 751 * This function ckecks the syscall arguments, and call the relevant kernel function. 752 ****************************************************************************************** 753 * @ arg0 : operation type (mnemonics defined in shared_fbf.h) 754 * @ arg1 : depends on operation type 755 * @ arg2 : depends on operation type 756 * @ arg3 : depends on operation type 757 * @ return 0 if success / return -1 if illegal argument. 758 *****************************************************************************************/ 759 int sys_fbf( reg_t arg0, 760 reg_t arg1, 761 reg_t arg2, 762 reg_t arg3 ); 763 764 /****************************************************************************************** 765 * [57] This generic function implements the socket related syscalls. 766 * The operation types mnemonics are defined in the <shared_socket> file. 767 * The supported operations are defined in the <socket.h> & <socket.c> files. 768 * This function ckecks the syscall arguments, and call the relevant kernel function. 769 ****************************************************************************************** 770 * @ arg0 : operation type (mnemonics defined in shared_socket.h) 771 * @ arg1 : depends on operation type 772 * @ arg2 : depends on operation type 773 * @ arg3 : depends on operation type 774 * @ return 0 if success / return -1 if illegal argument. 775 *****************************************************************************************/ 776 int sys_socket( reg_t arg0, 777 reg_t arg1, 778 reg_t arg2, 779 reg_t arg3 ); 777 * This function writes bytes to an open file identified by its file descriptor. 778 * The file can be a regular file or character oriented device. For a regular file, 779 * the target inode "size" field is updated if (offset + count) is larger than the 780 * current "size" value. The size value registered in the mappers of the parent(s) 781 * directory are not modified and will be asynchronously updated when the file is closed. 782 * IRQs are enabled during this system call. 783 ****************************************************************************************** 784 * @ file_id : open file index in fd_array. 785 * @ buf : buffer virtual address in user space. 786 * @ count : number of bytes. 787 * @ returns number of bytes actually written if success / returns -1 if failure. 788 *****************************************************************************************/ 789 int sys_write( uint32_t file_id, 790 void * buf, 791 uint32_t count ); 792 780 793 781 794 #endif // _SYSCALLS_H_
Note: See TracChangeset
for help on using the changeset viewer.