Changeset 664 for trunk/kernel/syscalls
- Timestamp:
- Oct 10, 2020, 5:11:27 PM (4 years ago)
- Location:
- trunk/kernel/syscalls
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/shared_include/shared_almos.h
r641 r664 55 55 DISPLAY_BARRIER = 10, 56 56 DISPLAY_FAT = 11, 57 DISPLAY_SOCKET = 12, 57 58 } 58 59 display_type_t; … … 82 83 thread_info_t; 83 84 85 /******************************************************************************************* 86 * This structure defines the - user accessible - global hardware configuration. 87 * It is used by the get_config() syscall. 88 ******************************************************************************************/ 89 90 typedef struct hard_config_s 91 { 92 unsigned int x_size; /*! number of clusters in a row */ 93 unsigned int y_size; /*! number of clusters in a column */ 94 unsigned int ncores; /*! max number of cores per cluster */ 95 96 unsigned int txt_channels; /*! number of TXT channels */ 97 unsigned int nic_channels; /*! number of NIC channels */ 98 unsigned int ioc_channels; /*! number of IOC channels */ 99 unsigned int fbf_channels; /*! number of FBF channels */ 100 } 101 hard_config_t; 102 103 84 104 #endif /* _SHARED_ALMOS_H_ */ 85 105 -
trunk/kernel/syscalls/sys_close.c
r625 r664 2 2 * sys_close.c close an open file 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 28 28 #include <process.h> 29 29 #include <thread.h> 30 #include <ksocket.h> 30 31 #include <printk.h> 31 32 32 33 #include <syscalls.h> 33 34 34 /////////////////////////////// ///35 int sys_close ( uint32_t f ile_id )35 /////////////////////////////// 36 int sys_close ( uint32_t fdid ) 36 37 { 37 38 error_t error; … … 51 52 if( DEBUG_SYS_CLOSE < tm_start ) 52 53 printk("\n[%s] thread[%x,%x] enter / fdid %d / cycle %d\n", 53 __FUNCTION__, process->pid, this->trdid, f ile_id, (uint32_t)tm_start );54 __FUNCTION__, process->pid, this->trdid, fdid, (uint32_t)tm_start ); 54 55 #endif 55 56 56 // check f ile_id argument57 if( f ile_id >= CONFIG_PROCESS_FILE_MAX_NR )57 // check fdid argument 58 if( fdid >= CONFIG_PROCESS_FILE_MAX_NR ) 58 59 { 59 60 60 61 #if DEBUG_SYSCALLS_ERROR 61 62 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", 62 __FUNCTION__ , f ile_id );63 __FUNCTION__ , fdid ); 63 64 #endif 64 65 this->errno = EBADFD; … … 67 68 68 69 // get extended pointer on remote file descriptor 69 file_xp = process_fd_get_xptr ( process , file_id );70 file_xp = process_fd_get_xptr_from_local( process , fdid ); 70 71 71 72 if( file_xp == XPTR_NULL ) … … 74 75 #if DEBUG_SYSCALLS_ERROR 75 76 printk("\n[ERROR] in %s : undefined file descriptor %d\n", 76 __FUNCTION__ , f ile_id );77 __FUNCTION__ , fdid ); 77 78 #endif 78 79 this->errno = EBADFD; … … 90 91 #if DEBUG_SYSCALLS_ERROR 91 92 printk("\n[ERROR] in %s : file descriptor %d is a directory\n", 92 __FUNCTION__ , f ile_id );93 __FUNCTION__ , fdid ); 93 94 #endif 94 95 this->errno = EBADFD; 95 96 return -1; 96 97 } 97 98 // call the relevant VFS function 99 error = vfs_close( file_xp , file_id ); 98 else if( file_type == INODE_TYPE_SOCK ) 99 { 100 // call the relevant socket function 101 error = socket_close( file_xp , fdid ); 102 } 103 else if( file_type == INODE_TYPE_FILE ) 104 { 105 // call the relevant VFS function 106 error = vfs_close( file_xp , fdid ); 107 } 108 else 109 { 110 111 #if DEBUG_SYSCALLS_ERROR 112 printk("\n[WARNING] in %s : type (%d) not supported / fdid %d\n", 113 __FUNCTION__ , file_type , fdid ); 114 #endif 115 error = 0; 116 } 100 117 101 118 if( error ) … … 104 121 #if DEBUG_SYSCALLS_ERROR 105 122 printk("\n[ERROR] in %s : cannot close file descriptor %d\n", 106 __FUNCTION__ , f ile_id );123 __FUNCTION__ , fdid ); 107 124 #endif 108 125 this->errno = error; -
trunk/kernel/syscalls/sys_display.c
r657 r664 35 35 #include <vfs.h> 36 36 #include <mapper.h> 37 37 #include <ksocket.h> 38 38 #include <syscalls.h> 39 39 … … 57 57 else if( type == DISPLAY_BARRIER ) return "BARRIER"; 58 58 else if( type == DISPLAY_FAT ) return "FAT"; 59 else if( type == DISPLAY_SOCKET ) return "SOCKET"; 59 60 else return "undefined"; 60 61 } … … 81 82 tm_start = hal_get_cycles(); 82 83 if( DEBUG_SYS_DISPLAY < tm_start ) 83 printk("\n[%s] thread[%x,%x] enter / type %s / cycle = %d\n", 84 __FUNCTION__, process->pid, this->trdid, display_type_str(type), (uint32_t)tm_start ); 84 printk("\n[%s] thread[%x,%x] enter / type %s / arg0 %x / arg1 %x / arg2 %x / cycle = %d\n", 85 __FUNCTION__, process->pid, this->trdid, display_type_str(type), 86 (uint32_t)arg0, (uint32_t)arg1, (uint32_t)arg2, (uint32_t)tm_start ); 85 87 #endif 86 88 … … 114 116 115 117 #if DEBUG_SYSCALLS_ERROR 116 printk("\n[ERROR] in %s forSTRING : string length %d too large\n",118 printk("\n[ERROR] in %s STRING : string length %d too large\n", 117 119 __FUNCTION__ , length ); 118 120 #endif … … 143 145 144 146 #if DEBUG_SYSCALLS_ERROR 145 printk("\n[ERROR] in %s forVMM : process %x in cluster %x not found\n",147 printk("\n[ERROR] in %s VMM : process %x in cluster %x not found\n", 146 148 __FUNCTION__ , pid , cxy ); 147 149 #endif … … 156 158 157 159 #if DEBUG_SYSCALLS_ERROR 158 printk("\n[ERROR] in %s forVMM : process %x in cluster %x not found\n",160 printk("\n[ERROR] in %s VMM : process %x in cluster %x not found\n", 159 161 __FUNCTION__ , pid , cxy ); 160 162 #endif … … 179 181 180 182 #if DEBUG_SYSCALLS_ERROR 181 printk("\n[ERROR] in %s forSCHED : illegal cxy argument %x\n",183 printk("\n[ERROR] in %s SCHED : illegal cxy argument %x\n", 182 184 __FUNCTION__ , cxy ); 183 185 #endif … … 191 193 192 194 #if DEBUG_SYSCALLS_ERROR 193 printk("\n[ERROR] in %s forSCHED : illegal lid argument %x\n",195 printk("\n[ERROR] in %s SCHED : illegal lid argument %x\n", 194 196 __FUNCTION__ , lid ); 195 197 #endif … … 214 216 215 217 #if DEBUG_SYSCALLS_ERROR 216 printk("\n[ERROR] in %s forCLUSTER_PROCESSES : illegal cxy argument %x\n",218 printk("\n[ERROR] in %s CLUSTER_PROCESSES : illegal cxy argument %x\n", 217 219 __FUNCTION__ , cxy ); 218 220 #endif … … 249 251 250 252 #if DEBUG_SYSCALLS_ERROR 251 printk("\n[ERROR] in %s forTXT_PROCESSES : illegal txt_id argument %d\n",253 printk("\n[ERROR] in %s TXT_PROCESSES : illegal txt_id argument %d\n", 252 254 __FUNCTION__ , txt_id ); 253 255 #endif … … 280 282 281 283 #if DEBUG_SYSCALLS_ERROR 282 printk("\n[ERROR] in %s forBUSYLOCKS : thread[%x,%x] not found\n",284 printk("\n[ERROR] in %s BUSYLOCKS : thread[%x,%x] not found\n", 283 285 __FUNCTION__ , pid, trdid ); 284 286 #endif … … 313 315 314 316 #if DEBUG_SYSCALLS_ERROR 315 printk("\n[ERROR] in %s forMAPPER : pathname too long\n",317 printk("\n[ERROR] in %s MAPPER : pathname too long\n", 316 318 __FUNCTION__ ); 317 319 #endif … … 325 327 326 328 #if DEBUG_SYSCALLS_ERROR 327 printk("\n[ERROR] in %s forMAPPER : nbytes cannot be larger than 4096\n",329 printk("\n[ERROR] in %s MAPPER : nbytes cannot be larger than 4096\n", 328 330 __FUNCTION__ ); 329 331 #endif … … 386 388 387 389 #if DEBUG_SYSCALLS_ERROR 388 printk("\n[ERROR] in %s forMAPPER : cannot get page %d\n",390 printk("\n[ERROR] in %s MAPPER : cannot get page %d\n", 389 391 __FUNCTION__ , page_id ); 390 392 #endif … … 414 416 415 417 #if DEBUG_SYSCALLS_ERROR 416 printk("\n[ERROR] in %s forBARRIER : process %x not found\n",418 printk("\n[ERROR] in %s BARRIER : process %x not found\n", 417 419 __FUNCTION__ , pid ); 418 420 #endif … … 428 430 429 431 #if DEBUG_SYSCALLS_ERROR 430 printk("\n[ERROR] in %s forBARRIER : no registered barrier in process %x\n",432 printk("\n[ERROR] in %s BARRIER : no registered barrier in process %x\n", 431 433 __FUNCTION__ , pid ); 432 434 #endif … … 452 454 453 455 #if DEBUG_SYSCALLS_ERROR 454 printk("\n[ERROR] in %s forFAT : nb_slots larger than 1024\n",456 printk("\n[ERROR] in %s FAT : nb_slots larger than 1024\n", 455 457 __FUNCTION__ ); 456 458 #endif … … 467 469 468 470 #if DEBUG_SYSCALLS_ERROR 469 printk("\n[ERROR] in %s forFAT : illegal cxy argument %x\n",471 printk("\n[ERROR] in %s FAT : illegal cxy argument %x\n", 470 472 __FUNCTION__ , cxy ); 471 473 #endif … … 482 484 fatfs_display_fat( min , slots ); 483 485 } 486 487 break; 488 } 489 //////////////////// 490 case DISPLAY_SOCKET: 491 { 492 pid_t pid = (pid_t)arg0; 493 trdid_t fdid = (trdid_t)arg1; 494 495 // get extended pointer on owner process descriptor 496 xptr_t owner_xp = cluster_get_owner_process_from_pid( pid ); 497 498 if( owner_xp == XPTR_NULL ) 499 { 500 501 #if DEBUG_SYSCALLS_ERROR 502 printk("\n[ERROR] in %s SOCKET : pid %x not found\n", __FUNCTION__ , pid ); 503 #endif 504 this->errno = EINVAL; 505 return -1; 506 } 507 508 // get extended pointer on file descriptor 509 xptr_t file_xp = process_fd_get_xptr_from_owner( owner_xp , fdid ); 510 511 if( file_xp == XPTR_NULL ) 512 { 513 514 #if DEBUG_SYSCALLS_ERROR 515 printk("\n[ERROR] in %s SOCKET : fdid %d not found\n", __FUNCTION__ , fdid ); 516 #endif 517 this->errno = EINVAL; 518 return -1; 519 } 520 521 // get local pointer and cluster for file 522 vfs_file_t * file_ptr = GET_PTR( file_xp ); 523 cxy_t file_cxy = GET_CXY( file_xp ); 524 525 // get local pointer on socket descriptor 526 socket_t * socket = hal_remote_lpt( XPTR( file_cxy , &file_ptr->socket ) ); 527 528 // display socket descriptor on TXT0 529 socket_display( XPTR( file_cxy , socket ), NULL ); 484 530 485 531 break; -
trunk/kernel/syscalls/sys_exit.c
r651 r664 89 89 #endif 90 90 91 // close all open files 92 process_fd_clean_all( owner_xp ); 93 94 #if( DEBUG_SYS_EXIT & 1) 95 if( DEBUG_SYS_EXIT < tm_start ) 96 printk("\n[%s] thread[%x,%x] closed all files for process %x\n", 97 __FUNCTION__, pid, this->trdid, pid ); 98 #endif 99 91 100 // mark for delete all process threads in all clusters, 92 101 // but the main thread and this calling thread -
trunk/kernel/syscalls/sys_get_config.c
r637 r664 2 2 * sys_get_config.c - get hardware platform parameters. 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 … … 34 34 35 35 #include <syscalls.h> 36 #include <shared_syscalls.h> 36 37 37 ////////////////////////////////////// 38 int sys_get_config( uint32_t * x_size, 39 uint32_t * y_size, 40 uint32_t * ncores ) 38 ////////////////////////////////////////////// 39 int sys_get_config( hard_config_t * u_config ) 41 40 { 42 error_t error; 43 vseg_t * vseg; 44 uint32_t k_x_size; 45 uint32_t k_y_size; 46 uint32_t k_ncores; 41 vseg_t * vseg; 42 hard_config_t k_config; // hard_config structure in kernel space 47 43 48 44 thread_t * this = CURRENT_THREAD; … … 60 56 #endif 61 57 62 // check x_size buffer in user space 63 error = vmm_get_vseg( process , (intptr_t)x_size , &vseg ); 64 65 if( error ) 58 // check u_config mapped in user space 59 if( vmm_get_vseg( process , (intptr_t)u_config , &vseg ) ) 66 60 { 67 61 68 62 #if DEBUG_SYSCALLS_ERROR 69 printk("\n[ERROR] in %s : x_size bufferunmapped / thread %x / process %x\n",70 __FUNCTION__ , (intptr_t) x_size, this->trdid , process->pid );63 printk("\n[ERROR] in %s : config pointer %x unmapped / thread %x / process %x\n", 64 __FUNCTION__ , (intptr_t)u_config , this->trdid , process->pid ); 71 65 #endif 72 66 this->errno = EINVAL; … … 74 68 } 75 69 76 // check y_size buffer in user space 77 error = vmm_get_vseg( process , (intptr_t)y_size , &vseg ); 70 // copy config parameters from cluster descriptor to kernel structure 71 k_config.x_size = LOCAL_CLUSTER->x_size; 72 k_config.y_size = LOCAL_CLUSTER->y_size; 73 k_config.ncores = LOCAL_CLUSTER->cores_nr; 74 k_config.txt_channels = LOCAL_CLUSTER->nb_txt_channels; 75 k_config.nic_channels = LOCAL_CLUSTER->nb_nic_channels; 76 k_config.ioc_channels = LOCAL_CLUSTER->nb_ioc_channels; 77 k_config.fbf_channels = LOCAL_CLUSTER->nb_fbf_channels; 78 78 79 if( error ) 80 { 81 82 #if DEBUG_SYSCALLS_ERROR 83 printk("\n[ERROR] in %s : y_size buffer unmapped / thread %x / process %x\n", 84 __FUNCTION__ , (intptr_t)y_size , this->trdid , process->pid ); 85 #endif 86 this->errno = EINVAL; 87 return -1; 88 } 89 90 // check ncores buffer in user space 91 error = vmm_get_vseg( process , (intptr_t)ncores , &vseg ); 92 93 if( error ) 94 { 95 96 #if DEBUG_SYSCALLS_ERROR 97 printk("\n[ERROR] in %s : ncores buffer unmapped / thread %x / process %x\n", 98 __FUNCTION__ , (intptr_t)ncores , this->trdid , process->pid ); 99 #endif 100 this->errno = EINVAL; 101 return -1; 102 } 103 104 // get parameters 105 k_x_size = LOCAL_CLUSTER->x_size; 106 k_y_size = LOCAL_CLUSTER->y_size; 107 k_ncores = LOCAL_CLUSTER->cores_nr; 108 109 // copy to user space 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) ); 79 // copy k_config structure to user space 80 hal_copy_to_uspace( u_config , XPTR(local_cxy, &k_config ), sizeof(hard_config_t) ); 113 81 114 82 hal_fence(); -
trunk/kernel/syscalls/sys_isatty.c
r566 r664 71 71 72 72 // get extended pointer on remote file descriptor 73 file_xp = process_fd_get_xptr ( process , file_id );73 file_xp = process_fd_get_xptr_from_local( process , file_id ); 74 74 75 75 if( file_xp == XPTR_NULL ) -
trunk/kernel/syscalls/sys_kill.c
r624 r664 195 195 process_txt_detach( owner_xp ); 196 196 197 // close all open files 198 process_fd_clean_all( owner_xp ); 199 197 200 // mark for delete all threads in all clusters, but the main 198 201 process_sigaction( pid , DELETE_ALL_THREADS ); -
trunk/kernel/syscalls/sys_lseek.c
r651 r664 67 67 68 68 // get extended pointer on remote file descriptor 69 file_xp = process_fd_get_xptr ( process , file_id );69 file_xp = process_fd_get_xptr_from_local( process , file_id ); 70 70 71 71 if( file_xp == XPTR_NULL ) -
trunk/kernel/syscalls/sys_mmap.c
r657 r664 26 26 #include <hal_vmm.h> 27 27 #include <hal_irqmask.h> 28 #include <shared_syscalls.h>29 28 #include <errno.h> 30 29 #include <thread.h> … … 36 35 37 36 #include <syscalls.h> 37 #include <shared_syscalls.h> 38 38 39 39 ////////////////////////////////// … … 141 141 142 142 // get extended pointer on file descriptor 143 xptr_t file_xp = process_fd_get_xptr ( process , fdid );143 xptr_t file_xp = process_fd_get_xptr_from_local( process , fdid ); 144 144 145 145 if( file_xp == XPTR_NULL ) -
trunk/kernel/syscalls/sys_read.c
r656 r664 114 114 115 115 // get extended pointer on remote file descriptor 116 file_xp = process_fd_get_xptr ( process , file_id );116 file_xp = process_fd_get_xptr_from_local( process , file_id ); 117 117 118 118 if( file_xp == XPTR_NULL ) -
trunk/kernel/syscalls/sys_write.c
r656 r664 82 82 83 83 #if (DEBUG_SYS_WRITE & 1) 84 if( DEBUG_SYS_WRITE < tm_start ) 84 85 enter_sys_write = (uint32_t)tm_start; 85 86 #endif … … 112 113 113 114 // get extended pointer on remote file descriptor 114 file_xp = process_fd_get_xptr ( process , file_id );115 file_xp = process_fd_get_xptr_from_local( process , file_id ); 115 116 116 117 if( file_xp == XPTR_NULL ) … … 215 216 216 217 #if (DEBUG_SYS_WRITE & 1) 218 if( DEBUG_SYS_WRITE < tm_start ) 217 219 exit_sys_write = (uint32_t)tm_end; 218 220 221 if( DEBUG_SYS_WRITE < tm_start ) 219 222 printk("\n***** timing to write a string *****\n" 220 223 " - enter_sys_write = %d / delta %d\n" -
trunk/kernel/syscalls/syscalls.h
r657 r664 348 348 * but the directory must exist in the file system. 349 349 * It returns a DIR pointer <dirp> on the dirent array in user space. 350 * The calling process fd_array is NOT modified. 350 351 ****************************************************************************************** 351 352 * @ pathname : [in] pathname (can be relative or absolute). … … 558 559 /****************************************************************************************** 559 560 * [40] This function implement the non-standard get_config() syscall. 560 * It returns in <x_size>, <y_size>, <ncores> the hardware platform parameters. 561 ****************************************************************************************** 562 * @ x_size : [out] number of clusters in a row. 563 * @ y_size : [out] number of clusters in a column. 564 * @ ncores : [out] number of cores per cluster. 565 * @ return 0 if success / return -1 if illegal arguments 566 *****************************************************************************************/ 567 int sys_get_config( uint32_t * x_size, 568 uint32_t * y_size, 569 uint32_t * ncores ); 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 ); 570 568 571 569 /******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.