Changeset 637 for trunk/kernel/syscalls
- Timestamp:
- Jul 18, 2019, 2:06:55 PM (5 years ago)
- Location:
- trunk/kernel/syscalls
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/shared_include/shared_mman.h
r623 r637 51 51 typedef struct mmap_attr_s 52 52 { 53 void * addr; /*! requested virtual address (unused : should be NULL)*/53 void * addr; /*! buffer for allocated vseg base address (return value) */ 54 54 unsigned int length; /*! requested vseg size (bytes) */ 55 55 unsigned int prot; /*! access modes */ -
trunk/kernel/syscalls/shared_include/syscalls_numbers.h
r626 r637 29 29 * It must be kept consistent with the array defined in do_syscalls.c 30 30 *****************************************************************************************/ 31 typedef enum { 31 typedef enum 32 { 32 33 SYS_THREAD_EXIT = 0, 33 34 SYS_THREAD_YIELD = 1, … … 75 76 76 77 SYS_GET_CONFIG = 40, 77 SYS_GET_CORE 78 SYS_GET_CORE_ID = 41, 78 79 SYS_GET_CYCLE = 42, 79 80 SYS_DISPLAY = 43, … … 88 89 SYS_SYNC = 51, 89 90 SYS_FSYNC = 52, 91 SYS_GET_BEST_CORE = 53, 92 SYS_GET_NB_CORES = 54, 90 93 91 SYSCALLS_NR = 5 3,94 SYSCALLS_NR = 55, 92 95 93 96 } syscalls_t; -
trunk/kernel/syscalls/sys_barrier.c
r635 r637 33 33 #include <remote_barrier.h> 34 34 35 #if DEBUG_SYS_BARRIER36 35 ////////////////////////////////////////////////////// 37 36 static char * sys_barrier_op_str( uint32_t operation ) … … 42 41 else return "undefined"; 43 42 } 44 #endif45 43 46 44 ////////////////////////////////// … … 74 72 75 73 #if DEBUG_SYSCALLS_ERROR 76 printk("\n[ERROR] in %s : unmapped barrier %x / thread %x / process %x\n",77 __FUNCTION__ , vaddr , this->trdid , process->pid );74 printk("\n[ERROR] in %s for %s : unmapped barrier %x / thread[%x,%x]\n", 75 __FUNCTION__, sys_barrier_op_str(operation), vaddr, process->pid, this->trdid ); 78 76 #endif 79 77 this->errno = error; … … 94 92 95 93 #if DEBUG_SYSCALLS_ERROR 96 printk("\n[ERROR] in %s : unmapped barrier attributes %x / thread %x / process %x\n",97 __FUNCTION__ , attr , this->trdid , process->pid );94 printk("\n[ERROR] in %s for INIT : unmapped barrier attributes %x / thread[%x,%x]\n", 95 __FUNCTION__ , attr , process->pid , this->trdid ); 98 96 #endif 99 97 this->errno = EINVAL; … … 102 100 103 101 // copy barrier attributes into kernel space 104 hal_copy_from_uspace( local_cxy, 105 &k_attr, 106 (void*)attr, 102 hal_copy_from_uspace( XPTR( local_cxy , &k_attr ), 103 (void *)attr, 107 104 sizeof(pthread_barrierattr_t) ); 108 105 … … 111 108 112 109 #if DEBUG_SYSCALLS_ERROR 113 printk("\n[ERROR] in %s : wrong arguments / count %d / x_size %d / y_size %d / nthreads %x\n",110 printk("\n[ERROR] in %s for INIT : count (%d) != x_size (%d) * y_size (%d) * nthreads (%x)\n", 114 111 __FUNCTION__, count, k_attr.x_size, k_attr.y_size, k_attr.nthreads ); 115 112 #endif … … 131 128 132 129 #if DEBUG_SYSCALLS_ERROR 133 printk("\n[ERROR] in %s : cannot create barrier %x / thread %x / process %x\n",134 __FUNCTION__ , vaddr , this->trdid , process->pid );130 printk("\n[ERROR] in %s for INIT : cannot create barrier %x / thread[%x,%x]\n", 131 __FUNCTION__ , vaddr , process->pid , this->trdid ); 135 132 #endif 136 133 this->errno = ENOMEM; … … 148 145 149 146 #if DEBUG_SYSCALLS_ERROR 150 printk("\n[ERROR] in %s : barrier %x not registered / thread %x / process %x\n",151 __FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );147 printk("\n[ERROR] in %s for WAIT : barrier %x not registered / thread[%x,%x]\n", 148 __FUNCTION__ , (intptr_t)vaddr , process->pid, this->trdid ); 152 149 #endif 153 150 this->errno = EINVAL; … … 169 166 170 167 #if DEBUG_SYSCALLS_ERROR 171 printk("\n[ERROR] in %s : barrier %x not registered / thread %x / process %x\n",172 __FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );168 printk("\n[ERROR] in %s for DESTROY : barrier %x not registered / thread[%x,%x]\n", 169 __FUNCTION__ , (intptr_t)vaddr , process->pid, this->trdid ); 173 170 #endif 174 171 this->errno = EINVAL; -
trunk/kernel/syscalls/sys_chdir.c
r610 r637 2 2 * sys_chdir.c - kernel function implementing the "chdir" syscall. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018, 2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 75 75 76 76 // copy pathname in kernel space 77 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 77 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 78 pathname, 79 CONFIG_VFS_MAX_PATH_LENGTH ); 78 80 79 81 #if DEBUG_SYS_CHDIR -
trunk/kernel/syscalls/sys_chmod.c
r566 r637 2 2 * sys_chmod.c - Change file access rights. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) 2015 UPMC Sorbonne Universites … … 47 47 48 48 #if DEBUG_SYSCALLS_ERROR 49 50 49 printk("\n[ERROR] in %s : pathname too long / thread %x in process %x\n", 50 __FUNCTION__, this->trdid, process->pid ); 51 51 #endif 52 52 this->errno = ENFILE; … … 55 55 56 56 // copy pathname in kernel space 57 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 57 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 58 pathname, 59 CONFIG_VFS_MAX_PATH_LENGTH ); 58 60 59 61 printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ ); -
trunk/kernel/syscalls/sys_display.c
r635 r637 122 122 123 123 // copy string to kernel space 124 hal_strcpy_from_uspace( kbuf , string , 512 ); 124 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 125 string, 126 512 ); 125 127 126 128 // print message on TXT0 kernel terminal … … 136 138 137 139 // check cxy argument 138 if( cluster_is_ undefined( cxy ))140 if( cluster_is_active( cxy ) == false ) 139 141 { 140 142 … … 172 174 173 175 // check cxy argument 174 if( cluster_is_ undefined( cxy ))176 if( cluster_is_active( cxy ) == false ) 175 177 { 176 178 … … 213 215 214 216 // check cxy argument 215 if( cluster_is_ undefined( cxy ))217 if( cluster_is_active( cxy ) == false ) 216 218 { 217 219 … … 323 325 324 326 // copy pathname in kernel space 325 hal_strcpy_from_uspace( kbuf , path , CONFIG_VFS_MAX_PATH_LENGTH ); 327 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 328 path, 329 CONFIG_VFS_MAX_PATH_LENGTH ); 326 330 327 331 // compute root inode for pathname … … 447 451 uint32_t cxy = (uint32_t)arg0; 448 452 449 if( cluster_is_ undefined( cxy ))453 if( cluster_is_active( cxy ) == false ) 450 454 { 451 455 -
trunk/kernel/syscalls/sys_exec.c
r635 r637 89 89 90 90 // copy the array of pointers to kernel buffer 91 hal_copy_from_uspace( local_cxy, 92 k_pointers, 91 hal_copy_from_uspace( XPTR( local_cxy , k_pointers ), 93 92 u_pointers, 94 93 CONFIG_PPM_PAGE_SIZE ); … … 109 108 110 109 // copy the user string to kernel buffer 111 hal_copy_from_uspace( local_cxy, 112 k_buf_ptr, 110 hal_copy_from_uspace( XPTR( local_cxy , k_buf_ptr ), 113 111 k_pointers[index], 114 112 length ); … … 199 197 200 198 // copy pathname in exec_info structure (kernel space) 201 hal_strcpy_from_uspace( exec_info.path , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 199 hal_strcpy_from_uspace( XPTR( local_cxy , exec_info.path ), 200 pathname, 201 CONFIG_VFS_MAX_PATH_LENGTH ); 202 202 203 203 #if DEBUG_SYS_EXEC -
trunk/kernel/syscalls/sys_fork.c
r635 r637 105 105 else // DQDT placement 106 106 { 107 child_cxy = dqdt_get_cluster_for_ process();107 child_cxy = dqdt_get_cluster_for_thread( LOCAL_CLUSTER->dqdt_root_xp ); 108 108 } 109 109 -
trunk/kernel/syscalls/sys_get_config.c
r635 r637 108 108 109 109 // copy to user space 110 hal_copy_to_uspace( local_cxy, &k_x_size, x_size, sizeof(uint32_t) );111 hal_copy_to_uspace( local_cxy, &k_y_size, y_size, sizeof(uint32_t) );112 hal_copy_to_uspace( local_cxy, &k_ncores, ncores, sizeof(uint32_t) );110 hal_copy_to_uspace( x_size, XPTR( local_cxy , &k_x_size ), sizeof(uint32_t) ); 111 hal_copy_to_uspace( y_size, XPTR( local_cxy , &k_y_size ), sizeof(uint32_t) ); 112 hal_copy_to_uspace( ncores, XPTR( local_cxy , &k_ncores ), sizeof(uint32_t) ); 113 113 114 114 hal_fence(); -
trunk/kernel/syscalls/sys_get_cycle.c
r635 r637 45 45 process_t * process = this->process; 46 46 47 #if (DEBUG_SYS_GET_CYCLE || CONFIG_INSTRUMENTATION_SYSCALLS) 48 uint64_t tm_start = hal_get_cycles(); 49 #endif 50 47 51 // check buffer in user space 48 52 error = vmm_get_vseg( process , (intptr_t)cycle , &vseg ); … … 63 67 64 68 // copy to user space 65 hal_copy_to_uspace( local_cxy, &k_cycle, cycle, sizeof(uint64_t) ); 69 hal_copy_to_uspace( cycle, 70 XPTR( local_cxy , &k_cycle ), 71 sizeof(uint64_t) ); 72 73 #if (DEBUG_SYS_GET_CYCLE || CONFIG_INSTRUMENTATION_SYSCALLS) 74 uint64_t tm_end = hal_get_cycles(); 75 #endif 76 77 #if DEBUG_SYS_GET_CYCLE 78 if( DEBUG_SYS_GET_CYCLE < tm_end ) 79 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 80 __FUNCTION__ , process->pid, this->trdid, (uint32_t)tm_end ); 81 #endif 82 83 #if CONFIG_INSTRUMENTATION_SYSCALLS 84 hal_atomic_add( &syscalls_cumul_cost[SYS_GET_CYCLE] , tm_end - tm_start ); 85 hal_atomic_add( &syscalls_occurences[SYS_GET_CYCLE] , 1 ); 86 #endif 66 87 67 88 return 0; -
trunk/kernel/syscalls/sys_getcwd.c
r610 r637 2 2 * sys_getcwd.c - kernel function implementing the "getcwd" syscall. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 97 97 98 98 // copy kernel buffer to user space 99 hal_strcpy_to_uspace( buffer , first , CONFIG_VFS_MAX_PATH_LENGTH ); 99 hal_strcpy_to_uspace( buffer, 100 XPTR( local_cxy , first ), 101 CONFIG_VFS_MAX_PATH_LENGTH ); 100 102 101 103 hal_fence(); -
trunk/kernel/syscalls/sys_is_fg.c
r635 r637 90 90 91 91 // copy to user space 92 hal_copy_to_uspace( local_cxy, &is_txt_owner, is_fg, sizeof(uint32_t) ); 92 hal_copy_to_uspace( is_fg, 93 XPTR( local_cxy , &is_txt_owner ), 94 sizeof(uint32_t) ); 93 95 94 96 hal_fence(); -
trunk/kernel/syscalls/sys_mkdir.c
r610 r637 60 60 61 61 // copy pathname in kernel space 62 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 62 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 63 pathname, 64 CONFIG_VFS_MAX_PATH_LENGTH ); 63 65 64 66 #if DEBUG_SYS_MKDIR -
trunk/kernel/syscalls/sys_mkfifo.c
r566 r637 2 2 * sys_mkfifo.c - creates a named FIFO file. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 33 33 uint32_t mode __attribute__((unused)) ) 34 34 { 35 error_t error;36 35 char kbuf[CONFIG_VFS_MAX_PATH_LENGTH]; 37 36 … … 39 38 process_t * process = this->process; 40 39 40 #if (DEBUG_SYS_MKFIFO || CONFIG_INSTRUMENTATION_SYSCALLS) 41 uint64_t tm_start = hal_get_cycles(); 42 #endif 43 44 #if DEBUG_SYS_MKFIFO 45 if( DEBUG_SYS_MKFIFO < tm_end ) 46 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n", 47 __FUNCTION__, process->pid, this->trdid, pathname, (uint32_t)tm_end ); 48 #endif 49 41 50 // check fd_array not full 42 51 if( process_fd_array_full() ) 43 52 { 44 printk("\n[ERROR] in %s : file descriptor array full for process %x\n", 45 __FUNCTION__ , process->pid ); 53 54 #if DEBUG_SYSCALLS_ERROR 55 printk("\n[ERROR] in %s : file descriptor array full for process %x\n", 56 __FUNCTION__ , process->pid ); 57 #endif 46 58 this->errno = ENFILE; 47 59 return -1; … … 51 63 if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH ) 52 64 { 53 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 65 66 #if DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s : pathname too long\n", __FUNCTION__ ); 68 #endif 54 69 this->errno = ENFILE; 55 70 return -1; … … 57 72 58 73 // copy pathname in kernel space 59 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 74 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 75 pathname, 76 CONFIG_VFS_MAX_PATH_LENGTH ); 60 77 61 78 printk("\n[ERROR] in %s : not implemented yet\n", __FUNCTION__ ); 62 79 return -1; 63 80 64 if( error ) 65 { 66 printk("\n[ERROR] in %s : cannot create named FIFO %s\n", 67 __FUNCTION__ , kbuf ); 68 this->errno = error; 69 return -1; 70 } 81 #if (DEBUG_SYS_MKFIFO || CONFIG_INSTRUMENTATION_SYSCALLS) 82 uint64_t tm_end = hal_get_cycles(); 83 #endif 71 84 72 return 0; 85 #if DEBUG_SYS_MKFIFO 86 if( DEBUG_SYS_MKFIFO < tm_end ) 87 printk("\n[%s] thread[%x,%x] exit for <%s> / cycle %d\n", 88 __FUNCTION__, process->pid, this->trdid, pathname, (uint32_t)tm_end ); 89 #endif 90 91 #if CONFIG_INSTRUMENTATION_SYSCALLS 92 hal_atomic_add( &syscalls_cumul_cost[SYS_MKFIFO] , tm_end - tm_start ); 93 hal_atomic_add( &syscalls_occurences[SYS_MKFIFO] , 1 ); 94 #endif 73 95 74 96 } // end sys_mkfifo() -
trunk/kernel/syscalls/sys_mmap.c
r635 r637 41 41 { 42 42 vseg_t * vseg; 43 cxy_t vseg_cxy; 44 vseg_type_t vseg_type; 43 cxy_t vseg_cxy; // target cluster for the vseg 44 vseg_type_t vseg_type; // vseg type 45 45 mmap_attr_t k_attr; // attributes copy in kernel space 46 46 xptr_t mapper_xp; 47 error_t error;48 47 reg_t save_sr; // required to enable IRQs 49 48 … … 62 61 63 62 // check user buffer (containing attributes) is mapped 64 error = vmm_get_vseg( process , (intptr_t)attr , &vseg ); 65 66 if( error ) 63 if( vmm_get_vseg( process , (intptr_t)attr , &vseg ) ) 67 64 { 68 65 … … 76 73 77 74 // copy attributes from user space to kernel space 78 hal_copy_from_uspace( local_cxy, 79 &k_attr, 75 hal_copy_from_uspace( XPTR( local_cxy , &k_attr ), 80 76 attr, 81 77 sizeof(mmap_attr_t) ); … … 119 115 120 116 // test mmap type : can be FILE / ANON / REMOTE 117 // to define vseg_type & vseg_cxy 121 118 122 119 /////////////////////////////////////////////////////////// MAP_FILE … … 126 123 #if (DEBUG_SYS_MMAP & 1) 127 124 if ( DEBUG_SYS_MMAP < tm_start ) 128 printk("\n[%s] thread[%x,%x] map file : fdid %d / offset %d / %dbytes\n",125 printk("\n[%s] thread[%x,%x] type file : fdid %d / offset %x / %x bytes\n", 129 126 __FUNCTION__, process->pid, this->trdid, fdid, offset, length ); 130 127 #endif 131 128 132 // FIXME: handle concurent delete of file by another thread closing it129 // FIXME: handle concurent delete of file by another thread 133 130 134 131 if( fdid >= CONFIG_PROCESS_FILE_MAX_NR ) … … 228 225 #if (DEBUG_SYS_MMAP & 1) 229 226 if ( DEBUG_SYS_MMAP < tm_start ) 230 printk("\n[%s] thread[%x,%x] map anon / %dbytes / cluster %x\n",227 printk("\n[%s] thread[%x,%x] type anon / %x bytes / cluster %x\n", 231 228 __FUNCTION__, process->pid, this->trdid, length, vseg_cxy ); 232 229 #endif … … 242 239 #if (DEBUG_SYS_MMAP & 1) 243 240 if ( DEBUG_SYS_MMAP < tm_start ) 244 printk("\n[%s] thread[%x,%x] map remote / %d bytes /cluster %x\n",241 printk("\n[%s] thread[%x,%x] type remote / %x bytes / target cluster %x\n", 245 242 __FUNCTION__, process->pid, this->trdid, length, vseg_cxy ); 246 243 #endif 247 244 248 if( cluster_is_ undefined( vseg_cxy ))245 if( cluster_is_active( vseg_cxy ) == false ) 249 246 { 250 247 … … 266 263 process_t * ref_ptr = GET_PTR( ref_xp ); 267 264 268 // create the vseg in reference cluster265 // register vseg in reference VSL 269 266 if( local_cxy == ref_cxy ) 270 267 { … … 306 303 } 307 304 308 // copy vseg base address to user space 309 hal_copy_to_uspace( local_cxy, 310 &vseg->min, 311 &attr->addr, 305 // copy vseg base address to user space mmap_attr_t 306 hal_copy_to_uspace( &attr->addr, 307 XPTR( ref_cxy , &vseg->min ), 312 308 sizeof(intptr_t) ); 313 309 hal_fence(); … … 324 320 #if DEBUG_SYS_MMAP 325 321 if ( DEBUG_SYS_MMAP < tm_end ) 326 printk("\n[%s] thread[%x,%x] exit / %s / cxy %x / base %x / size % d/ cycle %d\n",322 printk("\n[%s] thread[%x,%x] exit / %s / cxy %x / base %x / size %x / cycle %d\n", 327 323 __FUNCTION__, process->pid, this->trdid, 328 324 vseg_type_str(vseg->type), vseg->cxy, vseg->min, length, (uint32_t)tm_end ); -
trunk/kernel/syscalls/sys_open.c
r625 r637 77 77 78 78 // copy pathname in kernel space 79 hal_strcpy_from_uspace( kbuf, pathname , CONFIG_VFS_MAX_PATH_LENGTH );79 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ) , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 80 80 81 81 #if DEBUG_SYS_OPEN -
trunk/kernel/syscalls/sys_opendir.c
r635 r637 85 85 86 86 // copy pathname in kernel space 87 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 87 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 88 pathname, 89 CONFIG_VFS_MAX_PATH_LENGTH ); 88 90 89 91 #if DEBUG_SYS_OPENDIR … … 174 176 175 177 // set ident value in user buffer 176 hal_copy_to_uspace( local_cxy, 177 &ident, 178 dirp, 178 hal_copy_to_uspace( dirp, 179 XPTR( local_cxy , &ident ), 179 180 sizeof(intptr_t) ); 180 181 -
trunk/kernel/syscalls/sys_place_fork.c
r623 r637 40 40 process_t * process = this->process; 41 41 42 #if (DEBUG_SYS_PLACE_FORK || CONFIG_INSTRUMENTATION_SYSCALLS) 43 uint64_t tm_start = hal_get_cycles(); 44 #endif 45 46 #if DEBUG_SYS_PLACE_FORK 47 if( DEBUG_SYS_PLACE_FORK < tm_start ) 48 printk("\n[%s] thread[%x,%x] enter / cxy %x / cycle %d\n", 49 __FUNCTION__, process->pid, this->trdid, cxy, (uint32_t)tm_start ); 50 #endif 51 42 52 // check cxy argument 43 if( cluster_is_ undefined( cxy ))53 if( cluster_is_active( cxy ) == false ) 44 54 { 45 55 … … 56 66 this->fork_cxy = cxy; 57 67 68 #if (DEBUG_SYS_PLACE_FORK || CONFIG_INSTRUMENTATION_SYSCALLS) 69 uint64_t tm_end = hal_get_cycles(); 70 #endif 71 72 #if DEBUG_SYS_PLACE_FORK 73 if( DEBUG_SYS_PLACE_FORK < tm_end ) 74 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 75 __FUNCTION__ , process->pid, this->trdid, (uint32_t)tm_end ); 76 #endif 77 78 #if CONFIG_INSTRUMENTATION_SYSCALLS 79 hal_atomic_add( &syscalls_cumul_cost[SYS_PLACE_FORK] , tm_end - tm_start ); 80 hal_atomic_add( &syscalls_occurences[SYS_PLACE_FORK] , 1 ); 81 #endif 82 58 83 return 0; 59 84 -
trunk/kernel/syscalls/sys_readdir.c
r635 r637 112 112 113 113 // copy dirent pointer to user buffer 114 hal_copy_to_uspace( local_cxy, 115 &direntp, 116 buffer, 114 hal_copy_to_uspace( buffer, 115 XPTR( local_cxy , &direntp ), 117 116 sizeof(void *) ); 118 117 -
trunk/kernel/syscalls/sys_rename.c
r613 r637 2 2 * sys_rename.c - Rename a file or a directory. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 75 75 76 76 // copy old name an new name in kernel space 77 hal_strcpy_from_uspace( k_old, old , CONFIG_VFS_MAX_PATH_LENGTH );78 hal_strcpy_from_uspace( k_new, new , CONFIG_VFS_MAX_PATH_LENGTH );77 hal_strcpy_from_uspace( XPTR( local_cxy , k_old ) , old , CONFIG_VFS_MAX_PATH_LENGTH ); 78 hal_strcpy_from_uspace( XPTR( local_cxy , k_new ) , new , CONFIG_VFS_MAX_PATH_LENGTH ); 79 79 80 80 #if DEBUG_SYS_RENAME -
trunk/kernel/syscalls/sys_rmdir.c
r604 r637 2 2 * sys_rmdir.c - Remove a directory from file system. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) 2015 UPMC Sorbonne Universites … … 42 42 process_t * process = this->process; 43 43 44 #if (DEBUG_SYS_RMDIR || CONFIG_INSTRUMENTATION_SYSCALLS) 45 uint64_t tm_start = hal_get_cycles(); 46 #endif 47 44 48 // check pathname length 45 49 if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH ) … … 54 58 55 59 // copy pathname in kernel space 56 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 60 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 61 pathname, 62 CONFIG_VFS_MAX_PATH_LENGTH ); 57 63 58 64 // get cluster and local pointer on reference process -
trunk/kernel/syscalls/sys_sem.c
r635 r637 58 58 process_t * process = this->process; 59 59 60 #if (DEBUG_SYS_SEM || CONFIG_INSTRUMENTATION_SYSCALLS) 61 uint64_t tm_start = hal_get_cycles(); 62 #endif 63 60 64 #if DEBUG_SYS_SEM 61 uint64_t tm_start;62 uint64_t tm_end;63 tm_start = hal_get_cycles();64 65 if( DEBUG_SYS_SEM < tm_start ) 65 66 printk("\n[DBG] %s : thread %x in process %x enter for %s / cycle %d\n", … … 137 138 138 139 // return value to user 139 hal_copy_to_uspace( local_cxy, 140 ¤t, 141 current_value, 140 hal_copy_to_uspace( current_value, 141 XPTR( local_cxy , ¤t ), 142 142 sizeof(uint32_t) ); 143 143 } … … 224 224 hal_fence(); 225 225 226 #if (DEBUG_SYS_SEM || CONFIG_INSTRUMENTATION_SYSCALLS) 227 uint64_t tm_end = hal_get_cycles(); 228 #endif 229 226 230 #if DEBUG_SYS_SEM 227 tm_end = hal_get_cycles();228 231 if( DEBUG_SYS_SEM < tm_end ) 229 232 printk("\n[DBG] %s : thread %x in process %x exit for %s / cost = %d / cycle %d\n", … … 232 235 #endif 233 236 237 #if CONFIG_INSTRUMENTATION_SYSCALLS 238 hal_atomic_add( &syscalls_cumul_cost[SYS_SEM] , tm_end - tm_start ); 239 hal_atomic_add( &syscalls_occurences[SYS_SEM] , 1 ); 240 #endif 241 234 242 return 0; 235 243 -
trunk/kernel/syscalls/sys_stat.c
r635 r637 80 80 81 81 // copy pathname in kernel space 82 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 82 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 83 pathname, 84 CONFIG_VFS_MAX_PATH_LENGTH ); 83 85 84 86 #if DEBUG_SYS_STAT … … 121 123 122 124 // copy k_stat to u_stat 123 hal_copy_to_uspace( local_cxy, 124 &k_stat, 125 u_stat, 125 hal_copy_to_uspace( u_stat, 126 XPTR( local_cxy , &k_stat ), 126 127 sizeof(struct stat) ); 127 128 -
trunk/kernel/syscalls/sys_thread_create.c
r635 r637 66 66 67 67 #if DEBUG_SYS_THREAD_CREATE 68 tm_start = hal_get_cycles();69 68 if( DEBUG_SYS_THREAD_CREATE < tm_start ) 70 69 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", … … 73 72 74 73 // check trdid buffer in user space 75 error = vmm_get_vseg( process , (intptr_t)trdid_ptr , &vseg ); 76 77 if ( error ) 74 if( vmm_get_vseg( process , (intptr_t)trdid_ptr , &vseg ) ) 78 75 { 79 76 … … 89 86 if( user_attr != NULL ) 90 87 { 91 error = vmm_get_vseg( process , (intptr_t)user_attr , &vseg ); 92 93 if( error ) 88 if( vmm_get_vseg( process , (intptr_t)user_attr , &vseg ) ) 94 89 { 95 90 … … 102 97 } 103 98 104 hal_copy_from_uspace( local_cxy, 105 &kern_attr, 99 hal_copy_from_uspace( XPTR( local_cxy , &kern_attr ), 106 100 user_attr, 107 101 sizeof(pthread_attr_t) ); … … 109 103 110 104 // check start_func in user space 111 error = vmm_get_vseg( process , (intptr_t)start_func , &vseg ); 112 113 if( error ) 105 if( vmm_get_vseg( process , (intptr_t)start_func , &vseg ) ) 114 106 { 115 107 … … 125 117 if( start_args != NULL ) 126 118 { 127 error = vmm_get_vseg( process , (intptr_t)start_args , &vseg ); 128 129 if( error ) 119 if( vmm_get_vseg( process , (intptr_t)start_args , &vseg ) ) 130 120 { 131 121 … … 145 135 if( kern_attr.attributes & PT_ATTR_CLUSTER_DEFINED ) 146 136 { 147 if( cluster_is_ undefined( kern_attr.cxy ))137 if( cluster_is_active( kern_attr.cxy ) == false ) 148 138 { 149 139 … … 159 149 else 160 150 { 161 child_cxy = dqdt_get_cluster_for_ process();151 child_cxy = dqdt_get_cluster_for_thread( LOCAL_CLUSTER->dqdt_root_xp ); 162 152 } 163 153 } … … 165 155 { 166 156 kern_attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED; 167 child_cxy = dqdt_get_cluster_for_process();157 child_cxy = dqdt_get_cluster_for_thread( LOCAL_CLUSTER->dqdt_root_xp ); 168 158 } 169 159 … … 209 199 // returns trdid to user space 210 200 trdid = hal_remote_l32( XPTR( child_cxy , &child_ptr->trdid ) ); 211 hal_copy_to_uspace( local_cxy, 212 &trdid, 213 trdid_ptr, 201 hal_copy_to_uspace( trdid_ptr, 202 XPTR( local_cxy , &trdid ), 214 203 sizeof(pthread_t) ); 215 204 -
trunk/kernel/syscalls/sys_thread_detach.c
r566 r637 2 2 * sys_thread_detach.c - detach a joinable thread 3 3 * 4 * Authors Alain Greiner (2016,2017 )4 * Authors Alain Greiner (2016,2017,2018,2019) 5 5 * 6 * Copyright (c) 2011,2012UPMC Sorbonne Universites6 * Copyright (c) UPMC Sorbonne Universites 7 7 * 8 8 * This file is part of ALMOS-MKH. … … 48 48 49 49 // check trdid argument 50 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 50 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || 51 (cluster_is_active( target_cxy ) == false) ) 51 52 { 52 53 printk("\n[ERROR] in %s : illegal trdid argument\n", __FUNCTION__ ); -
trunk/kernel/syscalls/sys_thread_join.c
r633 r637 2 2 * sys_thread_join.c - passive wait on the end of a given thread. 3 3 * 4 * Authors Alain Greiner (2016,2017 )5 * 6 * Copyright (c) 2011,2012UPMC Sorbonne Universites4 * Authors Alain Greiner (2016,2017,2018,2019) 5 * 6 * Copyright (c) UPMC Sorbonne Universites 7 7 * 8 8 * This file is part of ALMOS-MKH. … … 72 72 73 73 // check trdid argument 74 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined(target_cxy) ) 74 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || 75 (cluster_is_active(target_cxy) == false) ) 75 76 { 76 77 -
trunk/kernel/syscalls/sys_thread_wakeup.c
r566 r637 1 1 /* 2 * sys_thread_wakeup.c - wakeup all indicated threads2 * sys_thread_wakeup.c - wakeup indicated thread 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 36 36 process_t * process = this->process; 37 37 38 #if (DEBUG_SYS_THREAD_WAKEUP || CONFIG_INSTRUMENTATION_SYSCALLS) 39 uint64_t tm_start = hal_get_cycles(); 40 #endif 41 38 42 #if DEBUG_SYS_THREAD_WAKEUP 39 uint64_t tm_start;40 uint64_t tm_end;41 tm_start = hal_get_cycles();42 43 if( DEBUG_SYS_THREAD_WAKEUP < tm_start ) 43 printk("\n[ DBG] %s :thread %x in process enter to activate thread %x / cycle %d\n",44 printk("\n[%s] thread %x in process enter to activate thread %x / cycle %d\n", 44 45 __FUNCTION__, this->trdid, process->pid, trdid, (uint32_t)tm_start ); 45 46 #endif … … 50 51 51 52 // check trdid argument 52 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || cluster_is_undefined( target_cxy ) ) 53 if( (target_ltid >= CONFIG_THREADS_MAX_PER_CLUSTER) || 54 (cluster_is_active( target_cxy ) == false) ) 53 55 { 54 56 … … 78 80 thread_unblock( thread_xp , THREAD_BLOCKED_GLOBAL ); 79 81 82 #if (DEBUG_SYS_THREAD_WAKEUP || CONFIG_INSTRUMENTATION_SYSCALLS) 83 uint64_t tm_end = hal_get_cycles(); 84 #endif 85 86 80 87 #if DEBUG_SYS_THREAD_WAKEUP 81 tm_end = hal_get_cycles();82 88 if( DEBUG_SYS_THREAD_WAKEUP < tm_end ) 83 printk("\n[ DBG] %s :thread %x in process %x exit / thread %x activated / cycle %d\n",89 printk("\n[%s] thread %x in process %x exit / thread %x activated / cycle %d\n", 84 90 __FUNCTION__ , this->trdid, process->pid, trdid, (uint32_t)tm_end ); 91 #endif 92 93 #if CONFIG_INSTRUMENTATION_SYSCALLS 94 hal_atomic_add( &syscalls_cumul_cost[SYS_THREAD_WAKEUP] , tm_end - tm_start ); 95 hal_atomic_add( &syscalls_occurences[SYS_THREAD_WAKEUP] , 1 ); 85 96 #endif 86 97 -
trunk/kernel/syscalls/sys_timeofday.c
r635 r637 50 50 process_t * process = this->process; 51 51 52 #if (DEBUG_SYS_TIMEOFDAY || CONFIG_INSTRUMENTATION_SYSCALLS) 53 uint64_t tm_start = hal_get_cycles(); 54 #endif 55 56 #if DEBUG_SYS_TIMEOFDAY 57 if( DEBUG_SYS_TIMEOFDAY < tm_start ) 58 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", 59 __FUNCTION__, process->pid, this->trdid, (uint32_t)tm_start ); 60 #endif 61 52 62 // check tz (non supported / must be null) 53 63 if( tz ) … … 82 92 83 93 // copy values to user space 84 hal_copy_to_uspace( local_cxy, 85 &k_tv, 86 tv, 94 hal_copy_to_uspace( tv, 95 XPTR( local_cxy , &k_tv ), 87 96 sizeof(struct timeval) ); 88 97 89 98 hal_fence(); 90 99 100 #if (DEBUG_SYS_TIMEOFDAY || CONFIG_INSTRUMENTATION_SYSCALLS) 101 uint64_t tm_end = hal_get_cycles(); 102 #endif 103 104 #if DEBUG_SYS_TIMEOFDAY 105 if( DEBUG_SYS_TIMEOFDAY < tm_end ) 106 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 107 __FUNCTION__, process->pid, this->trdid, (uint32_t)tm_end ); 108 #endif 109 110 #if CONFIG_INSTRUMENTATION_SYSCALLS 111 hal_atomic_add( &syscalls_cumul_cost[SYS_TIMEOFDAY] , tm_end - tm_start ); 112 hal_atomic_add( &syscalls_occurences[SYS_TIMEOFDAY] , 1 ); 113 #endif 114 91 115 return 0; 92 116 -
trunk/kernel/syscalls/sys_trace.c
r566 r637 2 2 * sys_trace.c - activate / desactivate the context switches trace for a given core 3 3 * 4 * Author Alain Greiner (c) (2016,2017,2018 )4 * Author Alain Greiner (c) (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 40 40 process_t * process = this->process; 41 41 42 #if (DEBUG_SYS_TRACE || CONFIG_INSTRUMENTATION_SYSCALLS) 43 uint64_t tm_start = hal_get_cycles(); 44 #endif 45 42 46 #if DEBUG_SYS_TRACE 43 uint64_t tm_start;44 uint64_t tm_end;45 tm_start = hal_get_cycles();46 47 if( DEBUG_SYS_TRACE < tm_start ) 47 printk("\n[ DBG] %s : thread %d enter / process %x/ cycle = %d\n",48 __FUNCTION__, this , this->process->pid, (uint32_t)tm_start );48 printk("\n[%s] thread[%x,%x] enters / cycle = %d\n", 49 __FUNCTION__, this->process->pid, this->trdid, (uint32_t)tm_start ); 49 50 #endif 50 51 51 52 // check cluster identifier 52 if( cluster_is_ undefined( cxy ))53 if( cluster_is_active( cxy ) == false ) 53 54 { 54 55 … … 85 86 hal_fence(); 86 87 87 #if DEBUG_SYS_TRACE 88 tm_end = hal_get_cycles(); 89 if( DEBUG_SYS_TRACE < tm_end ) 90 printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n", 91 __FUNCTION__, this, this->process->pid, (uint32_t)(tm_end - tm_start) , (uint32_t)tm_end ); 88 #if (DEBUG_SYS_TRACE || CONFIG_INSTRUMENTATION_SYSCALLS) 89 uint64_t tm_end = hal_get_cycles(); 92 90 #endif 93 91 92 #if DEBUG_SYS_TRACE 93 if( DEBUG_SYS_TRACE < tm_end ) 94 printk("\n[%s] thread[%x,%x] exit / cycle %d\n", 95 __FUNCTION__, this->process->pid, this->trdid, (uint32_t)tm_end ); 96 #endif 97 98 #if CONFIG_INSTRUMENTATION_SYSCALLS 99 hal_atomic_add( &syscalls_cumul_cost[SYS_TRACE] , tm_end - tm_start ); 100 hal_atomic_add( &syscalls_occurences[SYS_TRACE] , 1 ); 101 #endif 94 102 return 0; 95 103 -
trunk/kernel/syscalls/sys_unlink.c
r610 r637 2 2 * sys_unlink.c - unlink a file or directorya from VFS 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 60 60 61 61 // copy pathname in kernel space 62 hal_strcpy_from_uspace( kbuf , pathname , CONFIG_VFS_MAX_PATH_LENGTH ); 62 hal_strcpy_from_uspace( XPTR( local_cxy , kbuf ), 63 pathname, 64 CONFIG_VFS_MAX_PATH_LENGTH ); 63 65 64 66 #if DEBUG_SYS_UNLINK -
trunk/kernel/syscalls/sys_wait.c
r635 r637 53 53 pid_t pid = process->pid; 54 54 55 55 56 #if DEBUG_SYS_WAIT 56 uint64_t 57 uint64_t cycle = hal_get_cycles(); 57 58 if( DEBUG_SYS_WAIT < cycle ) 58 59 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", … … 153 154 #endif 154 155 // return child termination state to parent process 155 hal_copy_to_uspace( local_cxy, 156 &child_state, 157 status, 156 hal_copy_to_uspace( status, 157 XPTR( local_cxy , &child_state ), 158 158 sizeof(int) ); 159 159 return child_pid; … … 192 192 193 193 // never executed 194 return -1;194 return 0; 195 195 196 196 } // end sys_wait() -
trunk/kernel/syscalls/syscalls.h
r626 r637 210 210 /****************************************************************************************** 211 211 * [13] This function map physical memory (or a file) in the calling thread virtual space. 212 * The <attr> argument is a pointer on a structure for arguments (see shared_ syscalls.h).212 * The <attr> argument is a pointer on a structure for arguments (see shared_mman.h). 213 213 * The user defined virtual address (MAP_FIXED flag) is not supported. 214 214 * TODO : the access rights checking is not implemented yet [AG] … … 560 560 561 561 /****************************************************************************************** 562 * [41] This function implements the non-standard get_core () syscall.562 * [41] This function implements the non-standard get_core_id() syscall. 563 563 * It returns in <cxy> and <lid> the calling core cluster and local index. 564 564 ****************************************************************************************** … … 567 567 * @ return 0 if success / return -1 if illegal arguments 568 568 *****************************************************************************************/ 569 int sys_get_core ( uint32_t * cxy,570 uint32_t * lid );569 int sys_get_core_id( uint32_t * cxy, 570 uint32_t * lid ); 571 571 572 572 /****************************************************************************************** … … 696 696 int sys_fsync( uint32_t file_id ); 697 697 698 /****************************************************************************************** 699 * [53] This function implements the non-standard "get_best_core" syscall. 700 * It selects, in a macro-cluster specified by the <base_cxy> and <level> arguments, 701 * the core that has the lowest load. 702 * When an active core has been found in the target macro-cluster, it writes into the 703 * <cxy> and <lid> buffers the cluster identifier and the core local index, and return 0. 704 * It returns -1 in case of illegal arguments (level / cxy / lid). 705 * It returns +1 if there is no active core in specified macro-cluster. 706 ****************************************************************************************** 707 * @ base_cxy : [in] any cluster identifier in macro-cluster. 708 * @ level : [in] macro-cluster level in [1,2,3,4,5]. 709 * @ cxy : [out] selected core cluster identifier. 710 * @ lid : [out] selected core local index in cluster. 711 * @ return 0 if success / -1 if illegal arguments / +1 if no core in macro-clusters. 712 *****************************************************************************************/ 713 int sys_get_best_core( uint32_t base_cxy, 714 uint32_t level, 715 uint32_t * cxy, 716 uint32_t * lid ); 717 718 /****************************************************************************************** 719 * [54] This function implements the non-standard "get_nb_cores" syscall. 720 * It writes in the <ncores> buffer the number of cores in the target cluster <cxy>. 721 ****************************************************************************************** 722 * @ cxy : [in] target cluster identifier. 723 * @ ncores : [out] number of cores / 0 if cluster cxy undefined in architecture. 724 * @ return 0 if success / return -1 if illegal "ncores" arguments. 725 *****************************************************************************************/ 726 int sys_get_nb_cores( uint32_t cxy, 727 uint32_t * ncores ); 728 698 729 #endif // _SYSCALLS_H_
Note: See TracChangeset
for help on using the changeset viewer.