Changeset 435
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.tsar
r434 r435 87 87 build/kernel/kern/do_syscall.o \ 88 88 build/kernel/kern/do_interrupt.o \ 89 build/kernel/kern/rpc.o \ 90 build/kernel/kern/signal.o 89 build/kernel/kern/rpc.o 91 90 92 91 HAL_OBJS = build/kernel/hal/hal_special.o \ -
trunk/hal/tsar_mips32/core/hal_exception.c
r432 r435 33 33 #include <scheduler.h> 34 34 #include <core.h> 35 #include <signal.h>36 35 #include <syscalls.h> 37 36 #include <remote_spinlock.h> -
trunk/hal/tsar_mips32/core/hal_interrupt.c
r432 r435 32 32 void hal_do_interrupt() 33 33 { 34 35 irq_dmsg("\n[DBG] %s : core[%x,%d] enter at cycle %d\n", 36 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() ); 37 38 // As ALMOS-MKH does not define a generic interrupt handler, 39 // we directly access the local TSAR ICU to call the relevant ISR 34 // ALMOS-MKH does not define a generic interrupt handler. 35 // we call the specific TSAR IRQ handler to select the relevant ISR 40 36 soclib_pic_irq_handler(); 41 42 irq_dmsg("\n[DBG] %s : core[%x,%d] exit at cycle %d\n",43 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );44 45 37 } -
trunk/hal/tsar_mips32/drivers/soclib_pic.c
r432 r435 130 130 &pti_status ); 131 131 132 irq_dmsg("\n[DBG] %s : core[%x,%d] enter / WTI = %x / HWI = %x / PTI = %x\n", 133 __FUNCTION__ , local_cxy , core->lid , wti_status , hwi_status , pti_status ); 132 #if CONFIG_DEBUG_HAL_IRQS 133 uint32_t cycle = (uint32_t)hal_get_cycles(); 134 if (CONFIG_DEBUG_HAL_IRQS < cycle ) 135 printk("\n[DBG] %s : core[%x,%d] enter / WTI = %x / HWI = %x / PTI = %x / cycle %d\n", 136 __FUNCTION__ , local_cxy , core->lid , wti_status , hwi_status , pti_status, cycle ); 137 #endif 134 138 135 139 // analyse status and handle up to 3 pending IRQ (one WTI, one HWI, one PTI) … … 143 147 assert( (index == core->lid) , __FUNCTION__ , "illegal IPI index" ); 144 148 145 irq_dmsg("\n[DBG] %s : core[%x,%d] received an IPI / cycle %d\n", 146 __FUNCTION__ , local_cxy , core->lid , hal_time_stamp() ); 147 149 #if CONFIG_DEBUG_HAL_IRQS 150 if (CONFIG_DEBUG_HAL_IRQS < cycle ) 151 printk("\n[DBG] %s : core[%x,%d] received an IPI\n", __FUNCTION__ , local_cxy , core->lid ); 152 #endif 148 153 // acknowledge WTI (this require an XCU read) 149 154 uint32_t ack = xcu_base[(XCU_WTI_REG << 5) | core->lid]; … … 171 176 else // call relevant ISR 172 177 { 173 irq_dmsg("\n[DBG] %s : core[%x,%d] received external WTI %d / cycle %d\n", 174 __FUNCTION__ , local_cxy , core->lid , index , hal_time_stamp() ); 175 178 179 #if CONFIG_DEBUG_HAL_IRQS 180 if (CONFIG_DEBUG_HAL_IRQS < cycle ) 181 printk("\n[DBG] %s : core[%x,%d] received external WTI %d\n", 182 __FUNCTION__ , local_cxy , core->lid , index ); 183 #endif 176 184 // call ISR 177 185 src_chdev->isr( src_chdev ); … … 199 207 else // call relevant ISR 200 208 { 201 irq_dmsg("\n[DBG] %s : core[%x,%d] received HWI %d / cycle %d\n", 202 __FUNCTION__ , local_cxy , core->lid , index , hal_time_stamp() ); 203 209 210 #if CONFIG_DEBUG_HAL_IRQS 211 if (CONFIG_DEBUG_HAL_IRQS < cycle ) 212 printk("\n[DBG] %s : core[%x,%d] received HWI %d\n", 213 __FUNCTION__ , local_cxy , core->lid , index ); 214 #endif 204 215 // call ISR 205 216 src_chdev->isr( src_chdev ); … … 211 222 index = pti_status - 1; 212 223 213 irq_dmsg("\n[DBG] %s : core[%x,%d] received PTI %d / cycle %d\n",214 __FUNCTION__ , core->lid , local_cxy , index , hal_time_stamp() );215 216 224 assert( (index == core->lid) , __FUNCTION__ , "unconsistent PTI index\n"); 217 225 226 #if CONFIG_DEBUG_HAL_IRQS 227 if (CONFIG_DEBUG_HAL_IRQS < cycle ) 228 printk("\n[DBG] %s : core[%x,%d] received PTI %d\n", 229 __FUNCTION__ , core->lid , local_cxy , index ); 230 #endif 218 231 // acknowledge PTI (this require a read access to XCU) 219 232 uint32_t ack = xcu_base[(XCU_PTI_ACK << 5) | core->lid]; … … 345 358 chdev_t * src_chdev ) 346 359 { 360 361 #if CONFIG_DEBUG_HAL_IRQS 362 uint32_t cycle = (uint32_t)hal_get_cycles(); 363 if( CONFIG_DEBUG_HAL_IRQS < cycle ) 364 printk("\n[DBG] %s : thread %x enter for core[%x,%d] / cycle %d\n", 365 __FUNCTION__ , CURRENT_THREAD , local_cxy , lid , cycle ); 366 #endif 367 347 368 // get extended & local pointers on PIC chdev descriptor 348 369 xptr_t pic_xp = chdev_dir.pic; … … 401 422 ((soclib_pic_core_t *)core->pic_extend)->wti_vector[wti_id] = src_chdev; 402 423 403 pic_dmsg("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster = %x\n", 424 #if CONFIG_DEBUG_HAL_IRQS 425 if( CONFIG_DEBUG_HAL_IRQS < cycle ) 426 printk("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster = %x\n", 404 427 __FUNCTION__ , chdev_func_str( func ) , channel , is_rx , hwi_id , wti_id , local_cxy ); 428 #endif 405 429 406 430 } … … 420 444 ((soclib_pic_core_t *)core->pic_extend)->wti_vector[hwi_id] = src_chdev; 421 445 422 pic_dmsg("\n[DBG] %s : %s / channel = %d / hwi_id = %d / cluster = %x\n", 446 #if CONFIG_DEBUG_HAL_IRQS 447 if( CONFIG_DEBUG_HAL_IRQS < cycle ) 448 printk("\n[DBG] %s : %s / channel = %d / hwi_id = %d / cluster = %x\n", 423 449 __FUNCTION__ , chdev_func_str( func ) , channel , hwi_id , local_cxy ); 450 #endif 424 451 425 452 } -
trunk/hal/tsar_mips32/drivers/soclib_tty.c
r432 r435 30 30 #include <hal_special.h> 31 31 32 #if CONFIG_READ_DEBUG 33 extern uint32_t enter_tty_cmd; 34 extern uint32_t exit_tty_cmd; 35 36 extern uint32_t enter_tty_isr; 37 extern uint32_t exit_tty_isr; 32 #if (CONFIG_DEBUG_SYS_READ & 1) 33 extern uint32_t enter_tty_cmd_read; 34 extern uint32_t exit_tty_cmd_read; 35 36 extern uint32_t enter_tty_isr_read; 37 extern uint32_t exit_tty_isr_read; 38 #endif 39 40 #if (CONFIG_DEBUG_SYS_WRITE & 1) 41 extern uint32_t enter_tty_cmd_write; 42 extern uint32_t exit_tty_cmd_write; 43 44 extern uint32_t enter_tty_isr_write; 45 extern uint32_t exit_tty_isr_write; 38 46 #endif 39 47 … … 53 61 // get SOCLIB_TTY device cluster and local pointer 54 62 cxy_t tty_cxy = GET_CXY( tty_xp ); 55 uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );56 57 // reset TTY_RX_IRQ_ENABLE63 uint32_t * tty_ptr = GET_PTR( tty_xp ); 64 65 // set TTY_RX_IRQ_ENABLE 58 66 reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_RX_IRQ_ENABLE ); 59 hal_remote_sw( reg_xp , 0);67 hal_remote_sw( reg_xp , 1 ); 60 68 61 69 // reset TTY_TX_IRQ_ENABLE … … 68 76 { 69 77 70 #if CONFIG_READ_DEBUG 71 enter_tty_cmd = hal_time_stamp(); 72 #endif 78 #if (CONFIG_DEBUG_SYS_READ & 1) 79 if( type == TXT_READ) enter_tty_cmd_read = (uint32_t)hal_get_cycles(); 80 #endif 81 82 #if (CONFIG_DEBUG_SYS_WRITE & 1) 83 if( type == TXT_WRITE) enter_tty_cmd_write = (uint32_t)hal_get_cycles(); 84 #endif 85 86 // get client thread cluster and local pointer 87 cxy_t th_cxy = GET_CXY( th_xp ); 88 thread_t * th_ptr = GET_PTR( th_xp ); 89 90 // get command type and extended pointer on TXT device 91 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) ); 73 92 74 93 #if CONFIG_DEBUG_HAL_TXT 75 94 uint32_t cycle = (uint32_t)hal_get_cycles(); 76 95 if (CONFIG_DEBUG_HAL_TXT < cycle ) 77 printk("\n[DBG] %s : thread %x enter / cycle %d\n", 78 __FUNCTION__ , CURRENT_THREAD , cycle ); 79 #endif 80 81 // get client thread cluster and local pointer 82 cxy_t th_cxy = GET_CXY( th_xp ); 83 thread_t * th_ptr = (thread_t *)GET_PTR( th_xp ); 84 85 // get command type and extended pointer on TXT device 86 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) ); 87 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) ); 88 89 assert( (type == TXT_READ) || (type == TXT_WRITE) , __FUNCTION__, "illegal command type"); 90 91 // get TXT device cluster and local pointer 92 cxy_t dev_cxy = GET_CXY( dev_xp ); 93 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 94 95 // get extended pointer on SOCLIB_TTY base segment 96 xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) ); 97 98 // get SOCLIB_TTY base segment cluster and local pointer 99 cxy_t tty_cxy = GET_CXY( tty_xp ); 100 uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp ); 101 102 // get TTY channel index and channel base address 103 uint32_t channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) ); 104 uint32_t * base = tty_ptr + TTY_SPAN * channel; 105 106 // compute extended pointer on relevant TTY register 107 xptr_t reg_xp; 108 if( type == TXT_READ ) reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE ); 109 else reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ); 110 111 // enable relevant IRQ : data transfer will be done by the TTY_RX ISR) 112 hal_remote_sw( reg_xp , 1 ); 96 printk("\n[DBG] %s : thread %x enter for %s / cycle %d\n", 97 __FUNCTION__ , CURRENT_THREAD , dev_txt_type_str(type) , cycle ); 98 #endif 99 100 if( type == TXT_WRITE ) // block, enable TX_IRQ, and dechedule for a WRITE 101 { 102 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) ); 103 104 // get TXT device cluster and local pointer 105 cxy_t dev_cxy = GET_CXY( dev_xp ); 106 chdev_t * dev_ptr = GET_PTR( dev_xp ); 107 108 // get extended pointer on SOCLIB_TTY base segment 109 xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) ); 110 111 // get SOCLIB_TTY base segment cluster and local pointer 112 cxy_t tty_cxy = GET_CXY( tty_xp ); 113 uint32_t * tty_ptr = GET_PTR( tty_xp ); 114 115 // get TTY channel index and channel base address 116 uint32_t channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) ); 117 uint32_t * base = tty_ptr + TTY_SPAN * channel; 118 119 // block server thread 120 thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR ); 121 122 // enable relevant TX_IRQ for a WRITE 123 hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 ); 124 125 // deschedule 126 sched_yield( "waiting TXT_TX_ISR completion" ); 127 } 128 else if( type == TXT_READ ) // block, and deschedule for a READ 129 { 130 // block server thread 131 thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR ); 132 133 // deschedule 134 sched_yield( "waiting TXT_RX_ISR completion" ); 135 } 136 else 137 { 138 assert( false , __FUNCTION__ , "illegal TXT command\n" ); 139 } 113 140 114 141 #if CONFIG_DEBUG_HAL_TXT 115 142 cycle = (uint32_t)hal_get_cycles(); 116 143 if (CONFIG_DEBUG_HAL_TXT < cycle ) 117 printk("\n[DBG] %s : thread %x deschedule / cycle %d\n", 118 __FUNCTION__ , CURRENT_THREAD , cycle ); 119 #endif 120 121 // Block and deschedule server thread 122 thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR ); 123 sched_yield("blocked on ISR"); 124 125 #if CONFIG_DEBUG_HAL_TXT 126 cycle = (uint32_t)hal_get_cycles(); 127 if (CONFIG_DEBUG_HAL_TXT < cycle ) 128 printk("\n[DBG] %s : thread %x resume / cycle %d\n", 129 __FUNCTION__ , CURRENT_THREAD , cycle ); 130 #endif 131 132 #if CONFIG_READ_DEBUG 133 exit_tty_cmd = hal_time_stamp(); 144 printk("\n[DBG] %s : thread %x exit after %s / cycle %d\n", 145 __FUNCTION__ , CURRENT_THREAD , dev_txt_type_str( type ) , cycle ); 146 #endif 147 148 #if (CONFIG_DEBUG_SYS_READ & 1) 149 if( type == TXT_READ ) exit_tty_cmd_read = (uint32_t)hal_get_cycles(); 150 #endif 151 152 #if (CONFIG_DEBUG_SYS_WRITE & 1) 153 if( type == TXT_WRITE ) exit_tty_cmd_write = (uint32_t)hal_get_cycles(); 134 154 #endif 135 155 … … 143 163 uint32_t i; 144 164 145 xptr_t dev_xp = ((txt_ aux_t *)args)->dev_xp;146 char * buffer = ((txt_ aux_t *)args)->buffer;147 uint32_t count = ((txt_ aux_t *)args)->count;165 xptr_t dev_xp = ((txt_sync_args_t *)args)->dev_xp; 166 char * buffer = ((txt_sync_args_t *)args)->buffer; 167 uint32_t count = ((txt_sync_args_t *)args)->count; 148 168 149 169 // get TXT0 chdev cluster and local pointer … … 182 202 void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev ) 183 203 { 184 uint32_t type; // command type 185 uint32_t count; // number of bytes in buffer 186 xptr_t buf_xp; // extended pointer on buffer 187 xptr_t status_xp; // extended pointer on TTY_STATUS register 188 xptr_t write_xp; // extended pointer on TTY_WRITE register 189 xptr_t read_xp; // extended pointer on TTY_READ register 190 uint32_t status; // TTY terminal status 191 char byte; // read byte 192 uint32_t i; 193 194 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1) 195 enter_tty_isr = hal_time_stamp(); 204 uint32_t type; // command type 205 uint32_t count; // number of bytes in buffer 206 xptr_t buf_xp; // extended pointer on buffer 207 xptr_t error_xp; // extended pointer on error field in command 208 xptr_t status_xp; // extended pointer on TTY_STATUS register 209 xptr_t write_xp; // extended pointer on TTY_WRITE register 210 xptr_t read_xp; // extended pointer on TTY_READ register 211 uint32_t status; // TTY terminal status 212 char byte; // read byte 213 xptr_t client_xp; // first client thread in waiting queue 214 cxy_t client_cxy; // firts client thread cluster 215 thread_t * client_ptr; // first client thread pointer 216 pid_t pid; // foreground process identifier 217 xptr_t owner_xp; // extended pointer on foreground process in owner cluster 218 cxy_t owner_cxy; 219 process_t * owner_ptr; 220 uint32_t i; 221 222 #if (CONFIG_DEBUG_SYS_READ & 1) 223 enter_tty_isr_read = (uint32_t)hal_get_cycles(); 224 #endif 225 226 #if (CONFIG_DEBUG_SYS_WRITE & 1) 227 enter_tty_isr_write = (uint32_t)hal_get_cycles(); 196 228 #endif 197 229 … … 202 234 #endif 203 235 204 // get extended pointer on client thread 205 xptr_t root = XPTR( local_cxy , &chdev->wait_root ); 206 xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list ); 207 208 // get client thread cluster and local pointer 209 cxy_t client_cxy = GET_CXY( client_xp ); 210 thread_t * client_ptr = (thread_t *)GET_PTR( client_xp ); 211 212 // get command arguments 213 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type ) ); 214 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ) ); 215 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) ); 236 // get extended pointer on chdev queue root 237 xptr_t root_xp = XPTR( local_cxy , &chdev->wait_root ); 238 239 // get chdev channel 240 uint32_t channel = chdev->channel; 241 242 // get first command if queue non empty 243 if( xlist_is_empty( root_xp ) == false ) 244 { 245 // get extended pointer on first client thread 246 client_xp = XLIST_FIRST_ELEMENT( root_xp , thread_t , wait_list ); 247 248 // get client thread cluster and local pointer 249 client_cxy = GET_CXY( client_xp ); 250 client_ptr = GET_PTR( client_xp ); 251 252 // get command arguments 253 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type ) ); 254 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ) ); 255 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) ); 256 error_xp = XPTR( client_cxy , &client_ptr->txt_cmd.error ); 257 } 258 else 259 { 260 type = 0xFFFFFFFF; 261 262 // these lines to avoid a GCC warning 263 count = 0; 264 buf_xp = XPTR_NULL; 265 error_xp = XPTR_NULL; 266 client_cxy = 0; 267 client_ptr = NULL; 268 } 216 269 217 270 // get SOCLIB_TTY peripheral cluster and local pointer 218 271 cxy_t tty_cxy = GET_CXY( chdev->base ); 219 uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );272 uint32_t * tty_ptr = GET_PTR( chdev->base ); 220 273 221 274 // get channel base address … … 227 280 read_xp = XPTR( tty_cxy , base + TTY_READ ); 228 281 229 if( type == TXT_READ ) // read one single character 230 { 231 // get TTY_STATUS 232 status = hal_remote_lw( status_xp ); 233 234 if( status & TTY_STATUS_RX_FULL ) // TTY_RX full => move one byte 235 { 236 // get a byte from TTY_READ, and acknowledge RX_IRQ 237 byte = (char)hal_remote_lb( read_xp ); 238 239 // write it to command buffer 282 // get TTY_STATUS register value 283 status = hal_remote_lw( status_xp ); 284 285 // 1. handle RX if TTY_READ buffer full 286 if( status & TTY_STATUS_RX_FULL ) 287 { 288 // get a byte from TTY_READ / acknowledge RX_IRQ 289 byte = (char)hal_remote_lb( read_xp ); 290 291 // check character value 292 if( byte == 0x1A ) // ^Z => stop onwner process 293 { 294 // get pid of terminal owner process 295 pid = process_get_txt_owner( channel ); 296 297 // get cluster and pointers on owner process descriptor 298 owner_xp = cluster_get_owner_process_from_pid( pid ); 299 owner_cxy = GET_CXY( owner_xp ); 300 owner_ptr = GET_PTR( owner_xp ); 301 302 // send stop signal to owner process 303 process_sigaction( pid , BLOCK_ALL_THREADS ); 304 305 // atomically update owner process termination state 306 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 307 PROCESS_TERM_STOP ); 308 return; 309 } 310 else if( byte == 0x03 ) // ^C => kill owner process 311 { 312 // get pid of terminal owner process 313 pid = process_get_txt_owner( channel ); 314 315 // get cluster and pointers on owner process descriptor 316 owner_xp = cluster_get_owner_process_from_pid( pid ); 317 owner_cxy = GET_CXY( owner_xp ); 318 owner_ptr = GET_PTR( owner_xp ); 319 320 // send kill signal to owner process 321 process_sigaction( pid , DELETE_ALL_THREADS ); 322 323 // atomically update owner process termination state 324 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 325 PROCESS_TERM_KILL ); 326 return; 327 } 328 else if( type == TXT_READ ) // pending TXT_READ 329 { 330 // write character to command buffer 240 331 hal_remote_sb( buf_xp , byte ); 241 } 242 else // buffer empty => exit ISR for retry243 {244 return; 245 }246 247 // disable RX_IRQ248 xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );249 hal_remote_sw( reg_xp , 0 ); 250 }251 else // type == TXT_WRITE // write all characters in string332 333 // set I/O operation status in command 334 hal_remote_sw( error_xp , 0 ); 335 336 // unblock server thread 337 thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR ); 338 } 339 } 340 341 // 3. handle TX if TXT_WRITE 342 if( type == TXT_WRITE ) 252 343 { 253 344 // loop on characters … … 262 353 byte = (char)hal_remote_lb( buf_xp + i ); 263 354 264 // write byte to TTY_WRITE , andacknowledge TX_IRQ355 // write byte to TTY_WRITE / acknowledge TX_IRQ 265 356 hal_remote_sb( write_xp , byte ); 266 357 } … … 273 364 } 274 365 366 // set I/O operation status in command 367 hal_remote_sw( error_xp , 0 ); 368 275 369 // disable TX_IRQ 276 xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ); 277 hal_remote_sw( reg_xp , 0 ); 278 } 279 280 // The I/O operation completed when we reach this point 281 282 // set I/O operation status in command 283 hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 ); 284 285 // unblock server thread 286 thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR ); 287 288 // unblock client thread 289 // thread_unblock( client_xp , THREAD_BLOCKED_IO ); 370 hal_remote_sw( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 ); 371 372 // unblock server thread 373 thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR ); 374 } 290 375 291 376 hal_fence(); … … 294 379 cycle = (uint32_t)hal_get_cycles(); 295 380 if (CONFIG_DEBUG_HAL_TXT < cycle) 296 { 297 if( type == TXT_READ) 298 printk("\n[DBG] %s : exit after RX / cycle %d\n", __FUNCTION__ , cycle ); 299 else 300 printk("\n[DBG] %s : exit after TX / cycle %d\n", __FUNCTION__ , cycle ); 301 } 302 #endif 303 304 #if (CONFIG_ READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)305 exit_tty_isr = hal_time_stamp();381 printk("\n[DBG] %s : exit after %s / cycle %d\n", 382 __FUNCTION__ , dev_txt_type_str( type ) , cycle ); 383 #endif 384 385 #if (CONFIG_DEBUG_SYS_READ & 1) 386 if( type == TXT_READ) exit_tty_isr_read = (uint32_t)hal_get_cycles(); 387 #endif 388 389 #if (CONFIG_DEBUG_SYS_WRITE & 1) 390 if( type == TXT_WRITE) exit_tty_isr_write = (uint32_t)hal_get_cycles(); 306 391 #endif 307 392 308 393 } // end soclib_tty_isr() 309 394 310 /*311 /////////////////////////////////////////////////////////////////312 void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )313 {314 xptr_t root_xp; // extended pointer on command list root315 xptr_t client_xp; // extended pointer on client thread316 cxy_t client_cxy; // client thread cluster317 thread_t * client_ptr; // client_thread local pointer318 uint32_t type; // command type319 uint32_t count; // number of bytes in buffer320 xptr_t buf_xp; // extended pointer on buffer321 xptr_t status_xp; // extended pointer on TTY_STATUS register322 xptr_t write_xp; // extended pointer on TTY_WRITE register323 xptr_t read_xp; // extended pointer on TTY_READ register324 uint32_t status; // TTY terminal status325 char byte; // read byte326 uint32_t i;327 328 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)329 enter_tty_isr = hal_time_stamp();330 #endif331 332 txt_dmsg("\n[DBG] %s : core[%x,%d] enter / cycle %d\n",333 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid , hal_time_stamp() );334 335 // get SOCLIB_TTY peripheral cluster and local pointer336 cxy_t tty_cxy = GET_CXY( chdev->base );337 uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base );338 339 // get channel base address340 uint32_t * base = tty_ptr + TTY_SPAN * chdev->channel;341 342 // get extended pointer on TTY registers343 status_xp = XPTR( tty_cxy , base + TTY_STATUS );344 write_xp = XPTR( tty_cxy , base + TTY_WRITE );345 read_xp = XPTR( tty_cxy , base + TTY_READ );346 347 // get TTY_STATUS348 status = hal_remote_lw( status_xp );349 350 // get extended pointer on the command list root351 root_xp = XPTR( local_cxy , &chdev->wait_root );352 353 // get extended pointer on client thread354 if(xlist_is_empty(root_xp)) client_xp = XLIST_FIRST_ELEMENT(root, thread_t, wait_list);355 else client_xp = XPTR_NULL;356 357 if( client_xp )358 {359 // get client thread cluster and local pointer360 client_cxy = GET_CXY( client_xp );361 client_ptr = (thread_t *)GET_PTR( client_xp );362 363 // get command arguments364 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.type ) );365 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ) );366 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ) );367 }368 369 ///////////// handle RX if TTY_RX full370 if( status & TTY_STATUS_RX_FULL )371 {372 // get a byte from TTY_READ, and acknowledge RX_IRQ373 byte = (char)hal_remote_lb( read_xp );374 375 // FIXME The RX_IRQ must be always enabled !!!376 // xptr_t reg_xp = XPTR( tty_cxy , base + TTY_RX_IRQ_ENABLE );377 // hal_remote_sw( reg_xp , 0 );378 379 // analyse received character380 switch( byte )381 {382 case CONTROL_C: // SIGINT to process383 case CONTROL_D:384 {385 // TODO SIGINT386 return387 }388 break;389 default:390 {391 if( (type == TXT_READ) && (client_xp != XPTR_NULL) )392 {393 // write byte to command buffer394 hal_remote_sb( buf_xp , byte );395 396 // set status in command397 hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );398 399 hal_fence();400 401 // unblock server thread402 thread_unblock( XPTR(local_cxy,chdev->server), THREAD_BLOCKED_DEV_ISR );403 }404 else // discard byte405 {406 // TODO WARNING407 return408 }409 }410 }411 } // end RX handling412 413 //////////////// handle TX if WRITE command pending414 if( (type == TXT_WRITE) && (client_xp != XPTR_NULL) )415 {416 // loop on characters417 for( i = 0 ; i < count ; i++ )418 {419 // get TTY_STATUS420 status = hal_remote_lw( status_xp );421 422 if( (status & TTY_STATUS_TX_FULL) == 0 ) // TTY_TX empty => move one byte423 {424 // get one byte from command buffer425 byte = (char)hal_remote_lb( buf_xp + i );426 427 // write byte to TTY_WRITE, and acknowledge TX_IRQ428 hal_remote_sb( write_xp , byte );429 }430 else // TTY_TX full => update command arguments and exit ISR for retry431 {432 hal_remote_sw ( XPTR( client_cxy , &client_ptr->txt_cmd.count ), count-i );433 hal_remote_swd( XPTR( client_cxy , &client_ptr->txt_cmd.buf_xp ), buf_xp+i );434 return;435 }436 }437 438 // disable TX_IRQ439 xptr_t reg_xp = XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE );440 hal_remote_sw( reg_xp , 0 );441 442 // set I/O operation status in command443 hal_remote_sw( XPTR( client_cxy , &client_ptr->txt_cmd.error ) , 0 );444 445 hal_fence();446 447 // unblock server thread448 thread_unblock( XPTR( local_cxy , chdev->server ) , THREAD_BLOCKED_DEV_ISR );449 450 } // end TX handling451 452 txt_dmsg("\n[DBG] %s : core[%x,%d] exit / cycle %d\n",453 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );454 455 #if (CONFIG_READ_DEBUG & 0x1) || (CONFIG_WRITE_DEBUG & 0x1)456 exit_tty_isr = hal_time_stamp();457 #endif458 459 } // end soclib_tty_isr()460 461 */ -
trunk/hal/tsar_mips32/drivers/soclib_tty.h
r424 r435 28 28 29 29 /**************************************************************************************** 30 * This driver supports the soclib_multi_ttycomponent.30 * This driver supports the vci_tty_tsar component. 31 31 * It implements the generic TXT device API: 32 32 * - transfer one single character from TTY to command "buffer" if to_mem is non-zero. … … 62 62 63 63 /**************************************************************************************** 64 * This function implements the TXT_READ & TXT_WRITE commands registered in the client 65 * thread descriptor (in the txt_cmd field), identified by the <xp_thread> argument. 66 * Depending on the command type, it only unmasks the relevant TTY_RX / TTY_TX IRQ, 64 * This function implements both the TXT_READ & TXT_WRITE commands registered in the 65 * client thread descriptor (in the txt_cmd field), even if ALMOS-MKH defines two 66 * different chdevs (and consequently two diffeerent server threads) for the RX and TX 67 * directions. The client thread is identified by the <thread_xp> argument. 68 * Depending on the command type, it unmasks the relevant TTY_RX / TTY_TX IRQ, 67 69 * and blocks the TXT device server thread on the THREAD_BLOCKED_DEV_ISR, as the data 68 70 * transfer is done by the ISR. … … 83 85 84 86 /**************************************************************************************** 85 * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ. 86 * - the TTY_RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is set in the 87 * TTY status register, indicating a character registered in the TTY_READ register. 87 * This ISR is executed to handle both the TTY_TX_IRQ and the TTY_RX_IRQ, even if 88 * The RX_IRQ is activated as soon as the TTY_STATUS_RX_FULL bit is 1 in the 89 * TTY_STATUS register, when the TTY_RX_IRQ_ENABLE is non zero, indicating that 90 * the TTY_READ buffer is full and can be read. 91 * The TX_IRQ is activated as soon as the TTY_STATUS_TX_FULL bit is 0 in the 92 * TTY_STATUS register, when the TTY_TX_IRQ_ENABLE is non zero, indicating that 93 * the TTY_WRITE buffer is empty, and can be written. 94 * WARNING : In ALMOS-MKH, the RX_IRQ is always enabled to catch the control signals, 95 * but the TX_IRQ is dynamically enabled by the TXT_WRITE command, and disabled when 96 * the command is completed. 88 97 * 89 * . if it exist a TXT_READ command registered in the command queue, and thit copies the 98 * 1) The ISR first read the TTY_STATUS to get the current state of the TTY_READ and 99 * the TTY_WRITE buffers. 100 * 101 * 2) It try to read the first command registered in the server thread queue associated 102 * to the TTY channel 103 * 104 * 2) The ISR handles the RX when the TTY_READ buffer is full : 105 * . it read the available character from the TTY_READ buffer, and this 106 * acknowledges the RX_IRQ. 107 * . if it is a control character ( ^C / ^D / ^Z ) it translate it to the proper 108 * signal and execute the relevant sigaction for the foreground process. 109 * . if it is a normal character, it try to get the first command registered in the 110 * server thread queue. If it is a TXT_READ, it returns this character to the 111 * command buffer in the client thread. 112 * 113 * 3) The ISR handles the TX when the TTY_WRITE buffer is empty and a TXT_WRITE 114 * . it try to get it copies the 90 115 * character to the command buffer, acknowledges the TTY_RX_IRQ, and unblock the 91 116 * associated server thread. 92 117 93 * . the control characters are directly handled by the txt ^C / ^D / and the this IRQ ca 94 * 118 * . the control characters ^C / ^D / ^Z are directly handled by the ISR and 119 * translated to the foreground process. 120 121 * - the 95 122 the TXT_READ and TXT_WRITE commands. 96 123 * It gets the command arguments from the first client thread in the TXT chdev queue: -
trunk/kernel/devices/dev_txt.c
r433 r435 38 38 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 39 39 40 #if CONFIG_READ_DEBUG40 #if (CONFIG_DEBUG_SYS_READ & 1) 41 41 extern uint32_t enter_txt_read; 42 42 extern uint32_t exit_txt_read; 43 43 #endif 44 45 #if (CONFIG_DEBUG_SYS_WRITE & 1) 46 extern uint32_t enter_txt_write; 47 extern uint32_t exit_txt_write; 48 #endif 49 50 //////////////////////////////////////// 51 char * dev_txt_type_str( uint32_t type ) 52 { 53 if ( type == TXT_SYNC_WRITE ) return "TXT_SYNC_WRITE"; 54 else if( type == TXT_READ ) return "TXT_READ"; 55 else if( type == TXT_WRITE ) return "TXT_WRITE"; 56 else return "undefined"; 57 } 44 58 45 59 ////////////////////////////////// … … 117 131 thread_t * this = CURRENT_THREAD; 118 132 133 #if (CONFIG_DEBUG_SYS_READ & 1) 134 enter_txt_read = hal_time_stamp(); 135 #endif 136 137 #if (CONFIG_DEBUG_SYS_WRITE & 1) 138 enter_txt_write = hal_time_stamp(); 139 #endif 140 119 141 #if CONFIG_DEBUG_DEV_TXT 120 142 uint32_t cycle = (uint32_t)hal_get_cycles(); … … 151 173 #endif 152 174 175 #if (CONFIG_DEBUG_SYS_READ & 1) 176 exit_txt_read = hal_time_stamp(); 177 #endif 178 179 #if (CONFIG_DEBUG_SYS_WRITE & 1) 180 exit_txt_write = hal_time_stamp(); 181 #endif 182 153 183 // return I/O operation status from calling thread descriptor 154 184 return this->txt_cmd.error; … … 160 190 uint32_t count ) 161 191 { 162 error_t error = dev_txt_access( TXT_WRITE , channel , buffer , count ); 163 return error; 192 return dev_txt_access( TXT_WRITE , channel , buffer , count ); 164 193 } 165 194 … … 168 197 char * buffer ) 169 198 { 170 171 #if CONFIG_READ_DEBUG 172 enter_txt_read = hal_time_stamp(); 173 #endif 174 175 error_t error = dev_txt_access( TXT_READ , channel , buffer , 1 ); 176 177 #if CONFIG_READ_DEBUG 178 exit_txt_read = hal_time_stamp(); 179 #endif 180 181 return error; 182 199 return dev_txt_access( TXT_READ , channel , buffer , 1 ); 183 200 } 184 201 … … 201 218 202 219 // build arguments structure 203 txt_ aux_t args;220 txt_sync_args_t args; 204 221 args.dev_xp = dev_xp; 205 222 args.buffer = buffer; -
trunk/kernel/devices/dev_txt.h
r422 r435 82 82 TXT_READ = 0, 83 83 TXT_WRITE = 1, 84 TXT_SYNC_WRITE = 2, 84 85 }; 85 86 … … 87 88 { 88 89 xptr_t dev_xp; /*! extended pointer on the relevant TXT device descriptor */ 89 uint32_t type; /*! TXT_READ / TXT_WRITE / TXT_SYNC_WRITE*/90 uint32_t type; /*! TXT_READ / TXT_WRITE */ 90 91 xptr_t buf_xp; /*! extended pointer on characters array */ 91 92 uint32_t count; /*! number of characters in buffer (must be 1 if to_mem) */ … … 99 100 *****************************************************************************************/ 100 101 101 typedef struct txt_ aux_s102 typedef struct txt_sync_args_s 102 103 { 103 xptr_t dev_xp; /*! extended pointer on the TXT0 device descriptor */104 xptr_t dev_xp; /*! extended pointer on the TXT0_TX device descriptor */ 104 105 char * buffer; /*! local pointer on characters array */ 105 106 uint32_t count; /*! number of characters in buffer */ 106 107 } 107 txt_aux_t; 108 txt_sync_args_t; 109 110 /****************************************************************************************** 111 * This function returns a printable string for the comman type. 112 ****************************************************************************************** 113 * @ type : command type (TXT_READ / TXT_WRITE / TXT_SYNC_WRITE) 114 *****************************************************************************************/ 115 char * dev_txt_type_str( uint32_t type ); 108 116 109 117 /****************************************************************************************** … … 157 165 * As it is used for debug, the command arguments <buffer> and <count> are registerd 158 166 * in a specific "dbg_cmd" field of the calling thread. 159 * other TXT accesses.160 167 **************************************************************************************** 161 168 * @ buffer : local pointer on source buffer containing the string. -
trunk/kernel/fs/devfs.c
r433 r435 42 42 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 43 43 44 #if CONFIG_READ_DEBUG 45 extern uint32_t enter_devfs_move; 46 extern uint32_t exit_devfs_move; 44 #if (CONFIG_DEBUG_SYS_READ & 1) 45 extern uint32_t enter_devfs_read; 46 extern uint32_t exit_devfs_read; 47 #endif 48 49 #if (CONFIG_DEBUG_SYS_WRITE & 1) 50 extern uint32_t enter_devfs_write; 51 extern uint32_t exit_devfs_write; 47 52 #endif 48 53 … … 375 380 char k_buf[CONFIG_TXT_KBUF_SIZE]; // local kernel buffer 376 381 382 #if (CONFIG_DEBUG_SYS_READ & 1) 383 enter_devfs_read = hal_time_stamp(); 384 #endif 385 386 #if (CONFIG_DEBUG_SYS_WRITE & 1) 387 enter_devfs_write = hal_time_stamp(); 388 #endif 389 377 390 #if CONFIG_DEBUG_DEVFS_MOVE 378 391 uint32_t cycle = (uint32_t)hal_get_cycles(); … … 380 393 printk("\n[DBG] %s : thread %x enter / to_mem %d / cycle %d\n", 381 394 __FUNCTION__ , CURRENT_THREAD , to_buffer , cycle ); 382 #endif383 384 #if CONFIG_READ_DEBUG385 enter_devfs_move = hal_time_stamp();386 395 #endif 387 396 … … 424 433 #endif 425 434 426 #if CONFIG_READ_DEBUG427 exit_devfs_ move= hal_time_stamp();435 #if (CONFIG_DEBUG_SYS_READ & 1) 436 exit_devfs_read = hal_time_stamp(); 428 437 #endif 429 438 return size; … … 448 457 #endif 449 458 459 #if (CONFIG_DEBUG_SYS_WRITE & 1) 460 exit_devfs_write = hal_time_stamp(); 461 #endif 450 462 return size; 451 463 } -
trunk/kernel/fs/fatfs.c
r407 r435 262 262 "no FAT access required for first page\n"); 263 263 264 fatfs_dmsg("\n[DBG] %s : core[%x,%d] enters / first_cluster_id = %d / searched_index = %d\n", 265 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first_cluster_id, searched_page_index ); 264 #if CONFIG_DEBUG_FATFS_GET_CLUSTER 265 uint32_t cycle = (uint32_t)hal_get_cycles(); 266 if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle ) 267 printk("\n[DBG] %s : thread %x enter / first_cluster_id %d / searched_index / cycle %d\n", 268 __FUNCTION__, CURRENT_THREAD, first_cluster_id, searched_page_index, cycle ); 269 #endif 266 270 267 271 // get number of FAT slots per page … … 289 293 next_cluster_id = current_page_buffer[current_page_offset]; 290 294 291 fatfs_dmsg("\n[DBG] %s : core[%x,%d] traverse FAT / current_page_index = %d\n" 295 #if (CONFIG_DEBUG_FATFS_GET_CLUSTER & 1) 296 if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle ) 297 printk("\n[DBG] %s : traverse FAT / current_page_index = %d\n" 292 298 "current_page_offset = %d / next_cluster_id = %d\n", 293 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, current_page_index,294 current_page_offset , next_cluster_id ); 299 __FUNCTION__, current_page_index, current_page_offset , next_cluster_id ); 300 #endif 295 301 296 302 // update loop variables … … 302 308 if( next_cluster_id == 0xFFFFFFFF ) return EIO; 303 309 304 fatfs_dmsg("\n[DBG] %s : core[%x;%d] exit / cluster_id = %d\n", 305 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, next_cluster_id ); 310 #if CONFIG_DEBUG_FATFS_GET_CLUSTER 311 cycle = (uint32_t)hal_get_cycles(); 312 if( CONFIG_DEBUG_FATFS_GET_CLUSTER < cycle ) 313 printk("\n[DBG] %s : thread %x exit / searched_cluster_id = %d / cycle %d\n", 314 __FUNCTION__, CURRENT_THREAD, next_cluster_id / cycle ); 315 #endif 306 316 307 317 *searched_cluster_id = next_cluster_id; … … 335 345 uint8_t * buffer; 336 346 337 fatfs_dmsg("\n[DBG] %s : enter for fatfs_ctx = %x\n", 338 __FUNCTION__ , fatfs_ctx ); 347 #if CONFIG_DEBUG_FATFS_INIT 348 uint32_t cycle = (uint32_t)hal_get_cycles(); 349 if( CONFIG_DEBUG_FATFS_INIT < cycle ) 350 printk("\n[DBG] %s : thread %x enter for fatfs_ctx = %x / cycle %d\n", 351 __FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle ); 352 #endif 339 353 340 354 assert( (fatfs_ctx != NULL) , __FUNCTION__ , 341 355 "cannot allocate memory for FATFS context\n" ); 342 356 343 357 // allocate a 512 bytes buffer to store the boot record … … 347 361 348 362 assert( (buffer != NULL) , __FUNCTION__ , 349 363 "cannot allocate memory for 512 bytes buffer\n" ); 350 364 351 fatfs_dmsg("\n[DBG] %s : allocated 512 bytes buffer\n", __FUNCTION__ );352 353 365 // load the boot record from device 354 366 // using a synchronous access to IOC device 355 367 error = dev_ioc_sync_read( buffer , 0 , 1 ); 356 368 357 fatfs_dmsg("\n[DBG] %s : buffer loaded\n", __FUNCTION__ ); 358 359 assert( (error == 0) , __FUNCTION__ , "cannot access boot record\n" ); 360 361 #if (CONFIG_FATFS_DEBUG & 0x1) 362 if( hal_time_stamp() > CONFIG_FATFS_DEBUG ) 369 assert( (error == 0) , __FUNCTION__ , 370 "cannot access boot record\n" ); 371 372 #if (CONFIG_DEBUG_FATFS_INIT & 0x1) 373 if( CONFIG_DEBUG_FATFS_INIT < cycle ) 363 374 { 364 375 uint32_t line; … … 389 400 390 401 assert( (nb_sectors == 8) , __FUNCTION__ , 391 402 "cluster size must be 8 sectors\n" ); 392 403 393 404 // check number of FAT copies from boot record … … 395 406 396 407 assert( (nb_fats == 1) , __FUNCTION__ , 397 408 "number of FAT copies must be 1\n" ); 398 409 399 410 // get & check number of sectors in FAT from boot record … … 401 412 402 413 assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ , 403 414 "FAT not multiple of 16 sectors\n"); 404 415 405 416 // get and check root cluster from boot record … … 407 418 408 419 assert( (root_cluster == 2) , __FUNCTION__ , 409 420 "root cluster index must be 2\n"); 410 421 411 422 // get FAT lba from boot record … … 417 428 kmem_free( &req ); 418 429 419 fatfs_dmsg("\n[DBG] %s : boot record read & released\n",420 __FUNCTION__ );421 422 430 // allocate a mapper for the FAT itself 423 431 mapper_t * fat_mapper = mapper_create( FS_TYPE_FATFS ); 424 432 425 assert( (fat_mapper != NULL) , __FUNCTION__ , "no memory for FAT mapper" ); 433 assert( (fat_mapper != NULL) , __FUNCTION__ , 434 "no memory for FAT mapper" ); 426 435 427 436 // WARNING : the inode field MUST be NULL for the FAT mapper … … 439 448 fatfs_ctx->fat_mapper_xp = XPTR( local_cxy , fat_mapper ); 440 449 441 fatfs_dmsg("\n[DBG] %s : exit for fatfs_ctx = %x\n", __FUNCTION__ , fatfs_ctx ); 450 #if CONFIG_DEBUG_FATFS_INIT 451 cycle = (uint32_t)hal_get_cycles(); 452 if( CONFIG_DEBUG_FATFS_INIT < cycle ) 453 printk("\n[DBG] %s : thread %x exit for fatfs_ctx = %x / cycle %d\n", 454 __FUNCTION__ , CURRENT_THREAD , fatfs_ctx , cycle ); 455 #endif 442 456 443 457 } // end fatfs_ctx_init() … … 472 486 inode = mapper->inode; 473 487 474 fatfs_dmsg("\n[DBG] %s : core[%x,%d] enter for page %d / inode %x / mapper %x\n", 475 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper ); 488 #if CONFIG_DEBUG_FATFS_MOVE 489 uint32_t cycle = (uint32_t)hal_get_cycles(); 490 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 491 printk("\n[DBG] %s : thread %x enter / page %d / inode %x / mapper %x / cycle %d\n", 492 __FUNCTION__ , CURRENT_THREAD , index , inode , mapper , cycle ); 493 #endif 476 494 477 495 // get page base address … … 489 507 lba = fatfs_ctx->fat_begin_lba + (count * index); 490 508 491 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access FAT on device / lba = %d\n", 492 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba ); 509 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 510 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 511 printk("\n[DBG] %s : access FAT on device / lba = %d\n", __FUNCTION__ , lba ); 512 #endif 493 513 494 514 // access device … … 521 541 { 522 542 523 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access local FAT mapper\n" 543 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 544 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 545 print("\n[DBG] %s : access local FAT mapper\n" 524 546 "fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n", 525 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , 526 fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 527 547 __FUNCTION__ , fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 548 #endif 528 549 error = fatfs_get_cluster( fat_mapper_ptr, 529 550 first_cluster_id, … … 534 555 { 535 556 536 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access remote FAT mapper\n" 557 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 558 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 559 printk("\n[DBG] %s : access remote FAT mapper\n" 537 560 "fat_mapper_cxy = %x / fat_mapper_ptr = %x / first_cluster_id = %d / index = %d\n", 538 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , 539 fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 540 561 __FUNCTION__ , fat_mapper_cxy , fat_mapper_ptr , first_cluster_id , index ); 562 #endif 541 563 rpc_fatfs_get_cluster_client( fat_mapper_cxy, 542 564 fat_mapper_ptr, … … 550 572 } 551 573 552 fatfs_dmsg("\n[DBG] %s : core[%x,%d] access device for inode %x / cluster_id %d\n", 553 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , searched_cluster_id ); 574 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 575 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 576 printk("\n[DBG] %s : access device for inode %x / cluster_id %d\n", 577 __FUNCTION__ , inode , searched_cluster_id ); 578 #endif 554 579 555 580 // get lba from cluster_id … … 563 588 } 564 589 565 fatfs_dmsg("\n[DBG] %s : core[%x,%d] exit for page %d / inode %x / mapper %x\n", 566 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , inode , mapper ); 567 568 #if (CONFIG_FATFS_DEBUG & 0x1) 569 if( hal_time_stamp() > CONFIG_FATFS_DEBUG ) 590 #if CONFIG_DEBUG_FATFS_MOVE 591 cycle = (uint32_t)hal_get_cycles(); 592 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 593 printk("\n[DBG] %s : thread %x exit / page %d / inode %x / mapper %x / cycle %d\n", 594 __FUNCTION__ , CURRENT_THREAD , index , inode , mapper , cycle ); 595 #endif 596 597 #if (CONFIG_DEBUG_FATFS_MOVE & 0x1) 598 if( CONFIG_DEBUG_FATFS_MOVE < cycle ) 570 599 { 571 600 uint32_t * tab = (uint32_t *)buffer; … … 594 623 // - scan the directory entries in each 4 Kbytes page 595 624 596 fatfs_dmsg("\n[DBG] %s : enter for child <%s> in parent inode %l\n", 597 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) ); 625 #if CONFIG_DEBUG_FATFS_LOAD 626 uint32_t cycle = (uint32_t)hal_get_cycles(); 627 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 628 printk("\n[DBG] %s : thread %x enter for child <%s> in parent inode %x / cycle %d\n", 629 __FUNCTION__ , CURRENT_THREAD , name , parent_inode , cycle ); 630 #endif 598 631 599 632 mapper_t * mapper = parent_inode->mapper; … … 632 665 base = (uint8_t *)GET_PTR( base_xp ); 633 666 634 #if (CONFIG_ FATFS_DEBUG& 0x1)635 if( hal_time_stamp() > CONFIG_FATFS_DEBUG)667 #if (CONFIG_DEBUG_FATFS_LOAD & 0x1) 668 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 636 669 { 637 670 uint32_t * buf = (uint32_t *)base; … … 716 749 { 717 750 718 fatfs_dmsg("\n[DBG] %s : exit / child <%s> not found in parent inode %l\n", 719 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) ); 751 #if CONFIG_DEBUG_FATFS_LOAD 752 cycle = (uint32_t)hal_get_cycles(); 753 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 754 printk("\n[DBG] %s : thread %x exit / child <%s> not found / cycle %d\n", 755 __FUNCTION__ , CURRENT_THREAD, name, cycle ); 756 #endif 720 757 721 758 return ENOENT; … … 734 771 hal_remote_sw( XPTR( child_cxy , &child_ptr->extend ) , cluster ); 735 772 736 fatfs_dmsg("\n[DBG] %s : exit / child <%s> found in parent inode %l\n", 737 __FUNCTION__ , name , XPTR( local_cxy , parent_inode ) ); 773 #if CONFIG_DEBUG_FATFS_LOAD 774 cycle = (uint32_t)hal_get_cycles(); 775 if( CONFIG_DEBUG_FATFS_LOAD < cycle ) 776 printk("\n[DBG] %s : thread %x exit / child <%s> loaded / cycle %d\n", 777 __FUNCTION__ , CURRENT_THREAD, name, cycle ); 778 #endif 738 779 739 780 return 0; -
trunk/kernel/kern/chdev.c
r433 r435 39 39 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 40 40 41 #if CONFIG_READ_DEBUG 42 extern uint32_t enter_chdev_cmd; 43 extern uint32_t exit_chdev_cmd; 44 extern uint32_t enter_chdev_server; 45 extern uint32_t exit_chdev_server; 41 #if (CONFIG_DEBUG_SYS_READ & 1) 42 extern uint32_t enter_chdev_cmd_read; 43 extern uint32_t exit_chdev_cmd_read; 44 extern uint32_t enter_chdev_server_read; 45 extern uint32_t exit_chdev_server_read; 46 #endif 47 48 #if (CONFIG_DEBUG_SYS_WRITE & 1) 49 extern uint32_t enter_chdev_cmd_write; 50 extern uint32_t exit_chdev_cmd_write; 51 extern uint32_t enter_chdev_server_write; 52 extern uint32_t exit_chdev_server_write; 46 53 #endif 47 54 … … 123 130 uint32_t save_sr; // for critical section 124 131 125 #if CONFIG_READ_DEBUG 126 enter_chdev_cmd = hal_time_stamp(); 132 #if (CONFIG_DEBUG_SYS_READ & 1) 133 enter_chdev_cmd_read = (uint32_t)hal_get_cycles(); 134 #endif 135 136 #if (CONFIG_DEBUG_SYS_WRITE & 1) 137 enter_chdev_cmd_write = (uint32_t)hal_get_cycles(); 127 138 #endif 128 139 … … 178 189 if( different ) dev_pic_send_ipi( chdev_cxy , lid ); 179 190 191 // deschedule 192 assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" ); 193 sched_yield("blocked on I/O"); 194 195 // exit critical section 196 hal_restore_irq( save_sr ); 197 180 198 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND 181 199 cycle = (uint32_t)hal_get_cycles(); … … 185 203 #endif 186 204 187 // deschedule 188 assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" ); 189 sched_yield("blocked on I/O"); 190 191 // exit critical section 192 hal_restore_irq( save_sr ); 193 194 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND 195 cycle = (uint32_t)hal_get_cycles(); 196 if( CONFIG_DEBUG_CHDEV_REGISTER_COMMAND < cycle ) 197 printk("\n[DBG] %s : client_thread %x (%s) resumes / cycle %d\n", 198 __FUNCTION__, this, thread_type_str(this->type) , cycle ); 199 #endif 200 201 #if CONFIG_READ_DEBUG 202 exit_chdev_cmd = hal_time_stamp(); 205 #if (CONFIG_DEBUG_SYS_READ & 1) 206 exit_chdev_cmd_read = (uint32_t)hal_get_cycles(); 207 #endif 208 209 #if (CONFIG_DEBUG_SYS_WRITE & 1) 210 exit_chdev_cmd_write = (uint32_t)hal_get_cycles(); 203 211 #endif 204 212 … … 240 248 remote_spinlock_unlock( lock_xp ); 241 249 242 chdev_dmsg("\n[DBG] %s : thread %x deschedule /cycle %d\n",243 __FUNCTION__ , server , hal_time_stamp() );244 245 250 // deschedule 246 251 sched_yield("I/O queue empty"); 247 248 chdev_dmsg("\n[DBG] %s : thread %x resume /cycle %d\n",249 __FUNCTION__ , server , hal_time_stamp() );250 251 252 } 252 253 else // waiting queue not empty 253 254 { 254 255 255 #if CONFIG_READ_DEBUG 256 enter_chdev_server = hal_time_stamp(); 257 #endif 256 #if (CONFIG_DEBUG_SYS_READ & 1) 257 enter_chdev_server_read = (uint32_t)hal_get_cycles(); 258 #endif 259 260 #if (CONFIG_DEBUG_SYS_WRITE & 1) 261 enter_chdev_server_write = (uint32_t)hal_get_cycles(); 262 #endif 263 258 264 // release lock 259 265 remote_spinlock_unlock( lock_xp ); … … 284 290 #endif 285 291 286 #if CONFIG_READ_DEBUG 287 exit_chdev_server = hal_time_stamp(); 292 #if (CONFIG_DEBUG_SYS_READ & 1) 293 exit_chdev_server_read = (uint32_t)hal_get_cycles(); 294 #endif 295 296 #if (CONFIG_DEBUG_SYS_WRITE & 1) 297 exit_chdev_server_write = (uint32_t)hal_get_cycles(); 288 298 #endif 289 299 -
trunk/kernel/kern/kernel_init.c
r428 r435 123 123 124 124 125 // TODO remove these debug variables used dans sys_read()125 // these debug variables are used to analyse the sys_read() syscall timing 126 126 127 127 #if CONFIG_READ_DEBUG … … 129 129 uint32_t exit_sys_read; 130 130 131 uint32_t enter_devfs_ move;132 uint32_t exit_devfs_ move;131 uint32_t enter_devfs_read; 132 uint32_t exit_devfs_read; 133 133 134 134 uint32_t enter_txt_read; 135 135 uint32_t exit_txt_read; 136 136 137 uint32_t enter_chdev_cmd; 138 uint32_t exit_chdev_cmd; 139 140 uint32_t enter_chdev_server; 141 uint32_t exit_chdev_server; 142 143 uint32_t enter_tty_cmd; 144 uint32_t exit_tty_cmd; 145 146 uint32_t enter_tty_isr; 147 uint32_t exit_tty_isr; 137 uint32_t enter_chdev_cmd_read; 138 uint32_t exit_chdev_cmd_read; 139 140 uint32_t enter_chdev_server_read; 141 uint32_t exit_chdev_server_read; 142 143 uint32_t enter_tty_cmd_read; 144 uint32_t exit_tty_cmd_read; 145 146 uint32_t enter_tty_isr_read; 147 uint32_t exit_tty_isr_read; 148 #endif 149 150 // these debug variables are used to analyse the sys_write() syscall timing 151 152 #if CONFIG_WRITE_DEBUG 153 uint32_t enter_sys_write; 154 uint32_t exit_sys_write; 155 156 uint32_t enter_devfs_write; 157 uint32_t exit_devfs_write; 158 159 uint32_t enter_txt_write; 160 uint32_t exit_txt_write; 161 162 uint32_t enter_chdev_cmd_write; 163 uint32_t exit_chdev_cmd_write; 164 165 uint32_t enter_chdev_server_write; 166 uint32_t exit_chdev_server_write; 167 168 uint32_t enter_tty_cmd_write; 169 uint32_t exit_tty_cmd_write; 170 171 uint32_t enter_tty_isr_write; 172 uint32_t exit_tty_isr_write; 148 173 #endif 149 174 -
trunk/kernel/kern/process.c
r433 r435 51 51 #include <elf.h> 52 52 #include <syscalls.h> 53 #include <s ignal.h>53 #include <shared_syscalls.h> 54 54 55 55 ////////////////////////////////////////////////////////////////////////////////////////// … … 114 114 // get model process cluster and local pointer 115 115 model_cxy = GET_CXY( model_xp ); 116 model_ptr = (process_t *)GET_PTR( model_xp );116 model_ptr = GET_PTR( model_xp ); 117 117 118 118 // get parent process cluster and local pointer 119 119 parent_cxy = GET_CXY( parent_xp ); 120 parent_ptr = (process_t *)GET_PTR( parent_xp );120 parent_ptr = GET_PTR( parent_xp ); 121 121 122 122 // get model_pid and parent_pid … … 209 209 // get cluster and local pointer on chdev 210 210 chdev_cxy = GET_CXY( chdev_xp ); 211 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );211 chdev_ptr = GET_PTR( chdev_xp ); 212 212 213 213 // get TXT terminal index … … 289 289 // get reference process cluster and local pointer 290 290 cxy_t ref_cxy = GET_CXY( reference_process_xp ); 291 process_t * ref_ptr = (process_t *)GET_PTR( reference_process_xp );291 process_t * ref_ptr = GET_PTR( reference_process_xp ); 292 292 293 293 // initialize PID, REF_XP, PARENT_XP, and STATE … … 364 364 process_t * parent_ptr; 365 365 cxy_t parent_cxy; 366 xptr_t parent_thread_xp;367 366 xptr_t children_lock_xp; 368 367 xptr_t copies_lock_xp; … … 450 449 } 451 450 452 //////////////////////////////////////// ////453 void process_sigaction( p rocess_t * process,451 //////////////////////////////////////// 452 void process_sigaction( pid_t pid, 454 453 uint32_t action_type ) 455 454 { … … 467 466 rpc_desc_t rpc; // rpc descriptor allocated in stack 468 467 468 thread_t * client = CURRENT_THREAD; 469 469 470 #if CONFIG_DEBUG_PROCESS_SIGACTION 470 471 uint32_t cycle = (uint32_t)hal_get_cycles(); 471 472 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 472 printk("\n[DBG] %s : thread %x enter to %s process %x in cluster %x / cycle %d\n", 473 __FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) , 474 process->pid , local_cxy , cycle ); 475 #endif 476 477 thread_t * client = CURRENT_THREAD; 473 printk("\n[DBG] %s : thread %x enter to %s process %x / cycle %d\n", 474 __FUNCTION__ , client, process_action_str( action_type ) , pid , cycle ); 475 #endif 478 476 479 477 // get local pointer on local cluster manager … … 481 479 482 480 // get owner cluster identifier and process lpid 483 owner_cxy = CXY_FROM_PID( p rocess->pid );484 lpid = LPID_FROM_PID( p rocess->pid );485 486 // checkowner cluster487 assert( (owner_cxy == local_cxy) , __FUNCTION__ , "must be executed in owner cluster\n" );488 489 // get number of remote copies490 responses = cluster->pmgr.copies_nr[lpid] - 1; 481 owner_cxy = CXY_FROM_PID( pid ); 482 lpid = LPID_FROM_PID( pid ); 483 484 // get root of list of copies, lock, and number of copies from owner cluster 485 responses = hal_remote_lw ( XPTR( owner_cxy , &cluster->pmgr.copies_nr[lpid] ) ); 486 root_xp = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_root[lpid] ) ); 487 lock_xp = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ) ); 488 491 489 rsp_count = 0; 492 490 … … 502 500 rpc.thread = client; 503 501 504 // get extended pointers on copies root and lock505 root_xp = XPTR( local_cxy , &cluster->pmgr.copies_root[lpid] );506 lock_xp = XPTR( local_cxy , &cluster->pmgr.copies_lock[lpid] );507 508 502 // take the lock protecting the copies 509 503 remote_spinlock_lock( lock_xp ); … … 514 508 process_xp = XLIST_ELEMENT( iter_xp , process_t , copies_list ); 515 509 process_cxy = GET_CXY( process_xp ); 516 process_ptr = (process_t *)GET_PTR( process_xp ); 517 518 // send RPC to remote clusters 519 if( process_cxy != local_cxy ) 520 { 510 process_ptr = GET_PTR( process_xp ); 521 511 522 512 #if CONFIG_DEBUG_PROCESS_SIGACTION 523 513 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 524 printk("\n[DBG] %s : send RPC to remote cluster %x\n", __FUNCTION__ , process_cxy ); 525 #endif 526 527 rpc.args[0] = (uint64_t)action_type; 528 rpc.args[1] = (uint64_t)(intptr_t)process_ptr; 529 rpc_process_sigaction_client( process_cxy , &rpc ); 530 rsp_count++; 531 } 514 printk("\n[DBG] %s : send RPC to cluster %x\n", __FUNCTION__ , process_cxy ); 515 #endif 516 517 // check PID 518 assert( (hal_remote_lw( XPTR( process_cxy , &process_ptr->pid) ) == pid), 519 __FUNCTION__ , "unconsistent PID value\n" ); 520 521 rpc.args[0] = (uint64_t)action_type; 522 rpc.args[1] = (uint64_t)pid; 523 rpc_process_sigaction_client( process_cxy , &rpc ); 524 rsp_count++; 532 525 } 533 526 … … 540 533 rsp_count , responses ); 541 534 542 // block and deschedule to wait RPC responses if required 543 if( responses ) 544 { 545 thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC ); 546 sched_yield("BLOCKED on RPC_PROCESS_SIGACTION"); 547 } 548 549 #if CONFIG_DEBUG_PROCESS_SIGACTION 550 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 551 printk("\n[DBG] %s : make action in owner cluster %x\n", __FUNCTION__ , local_cxy ); 552 #endif 553 554 // call directly the relevant function in local owner cluster 555 if (action_type == DELETE_ALL_THREADS ) process_delete_threads ( process ); 556 else if (action_type == BLOCK_ALL_THREADS ) process_block_threads ( process ); 557 else if (action_type == UNBLOCK_ALL_THREADS ) process_unblock_threads( process ); 535 // block and deschedule to wait RPC responses 536 thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC ); 537 sched_yield("BLOCKED on RPC_PROCESS_SIGACTION"); 558 538 559 539 #if CONFIG_DEBUG_PROCESS_SIGACTION … … 561 541 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle ) 562 542 printk("\n[DBG] %s : thread %x exit after %s process %x in cluster %x / cycle %d\n", 563 __FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) ,543 __FUNCTION__ , client, process_action_str( action_type ) , 564 544 process->pid , local_cxy , cycle ); 565 545 #endif … … 778 758 { 779 759 process_xp = XLIST_ELEMENT( iter , process_t , local_list ); 780 process_ptr = (process_t *)GET_PTR( process_xp );760 process_ptr = GET_PTR( process_xp ); 781 761 if( process_ptr->pid == pid ) 782 762 { … … 838 818 839 819 // get reference process cluster and local pointer 840 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );820 process_t * ref_ptr = GET_PTR( ref_xp ); 841 821 cxy_t ref_cxy = GET_CXY( ref_xp ); 842 822 … … 858 838 // get reference process cluster and local pointer 859 839 xptr_t ref_xp = process->ref_xp; 860 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );840 process_t * ref_ptr = GET_PTR( ref_xp ); 861 841 cxy_t ref_cxy = GET_CXY( ref_xp ); 862 842 … … 900 880 xptr_t ref_xp = process->ref_xp; 901 881 cxy_t ref_cxy = GET_CXY( ref_xp ); 902 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );882 process_t * ref_ptr = GET_PTR( ref_xp ); 903 883 904 884 // access reference process descriptor … … 925 905 // get cluster and local pointer for src fd_array 926 906 cxy_t src_cxy = GET_CXY( src_xp ); 927 fd_array_t * src_ptr = (fd_array_t *)GET_PTR( src_xp );907 fd_array_t * src_ptr = GET_PTR( src_xp ); 928 908 929 909 // get cluster and local pointer for dst fd_array 930 910 cxy_t dst_cxy = GET_CXY( dst_xp ); 931 fd_array_t * dst_ptr = (fd_array_t *)GET_PTR( dst_xp );911 fd_array_t * dst_ptr = GET_PTR( dst_xp ); 932 912 933 913 // get the remote lock protecting the src fd_array … … 1044 1024 // get cluster and local pointer for parent process 1045 1025 cxy_t parent_process_cxy = GET_CXY( parent_process_xp ); 1046 process_t * parent_process_ptr = (process_t *)GET_PTR( parent_process_xp );1026 process_t * parent_process_ptr = GET_PTR( parent_process_xp ); 1047 1027 1048 1028 // get parent process PID and extended pointer on .elf file … … 1349 1329 } // end process_make_exec() 1350 1330 1351 ////////////////////////////////////////////1352 void process_make_kill( process_t * process,1353 bool_t is_exit,1354 uint32_t exit_status )1355 {1356 thread_t * this = CURRENT_THREAD;1357 1358 assert( (CXY_FROM_PID( process->pid ) == local_cxy) , __FUNCTION__ ,1359 "must be executed in process owner cluster\n" );1360 1361 assert( ( this->type == THREAD_RPC ) , __FUNCTION__ ,1362 "must be executed by an RPC thread\n" );1363 1364 #if CONFIG_DEBUG_PROCESS_MAKE_KILL1365 uint32_t cycle = (uint32_t)hal_get_cycles();1366 if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )1367 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",1368 __FUNCTION__, this , process->pid , cycle );1369 #endif1370 1371 // register exit_status in owner process descriptor1372 if( is_exit ) process->term_state = exit_status;1373 1374 // atomically update owner process descriptor flags1375 if( is_exit ) hal_atomic_or( &process->term_state , PROCESS_FLAG_EXIT );1376 else hal_atomic_or( &process->term_state , PROCESS_FLAG_KILL );1377 1378 // remove TXT ownership from owner process descriptor1379 process_txt_reset_ownership( XPTR( local_cxy , process ) );1380 1381 // block all process threads in all clusters1382 process_sigaction( process , BLOCK_ALL_THREADS );1383 1384 // mark all process threads in all clusters for delete1385 process_sigaction( process , DELETE_ALL_THREADS );1386 1387 /* unused if sys_wait deschedules without blocking [AG]1388 1389 // get cluster and pointers on reference parent process1390 xptr_t parent_xp = process->parent_xp;1391 process_t * parent_ptr = GET_PTR( parent_xp );1392 cxy_t parent_cxy = GET_CXY( parent_xp );1393 1394 // get loal pointer on parent main thread1395 thread_t * main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) );1396 1397 // reset THREAD_BLOCKED_WAIT bit in parent process main thread1398 thread_unblock( XPTR( parent_cxy , main_ptr ) , THREAD_BLOCKED_WAIT );1399 */1400 1401 #if CONFIG_DEBUG_PROCESS_MAKE_KILL1402 cycle = (uint32_t)hal_get_cycles();1403 if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )1404 printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n",1405 __FUNCTION__, this, process->pid , cycle );1406 #endif1407 1408 } // end process_make_kill()1409 1410 1331 /////////////////////////////////////////////// 1411 1332 void process_zero_create( process_t * process ) … … 1679 1600 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1680 1601 printk("\n[DBG] %s : thread %x enter for process %x / txt_id = %d / cycle %d\n", 1681 __FUNCTION__, CURRENT_THREAD, process ->pid, txt_id, cycle );1602 __FUNCTION__, CURRENT_THREAD, process, txt_id, cycle ); 1682 1603 #endif 1683 1604 … … 1708 1629 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1709 1630 printk("\n[DBG] %s : thread %x exit for process %x / txt_id = %d / cycle %d\n", 1710 __FUNCTION__, CURRENT_THREAD, process ->pid, txt_id , cycle );1631 __FUNCTION__, CURRENT_THREAD, process, txt_id , cycle ); 1711 1632 #endif 1712 1633 … … 1721 1642 xptr_t lock_xp; // extended pointer on list lock in chdev 1722 1643 1723 #if CONFIG_DEBUG_PROCESS_TXT_ DETACH1644 #if CONFIG_DEBUG_PROCESS_TXT_ATTACH 1724 1645 uint32_t cycle = (uint32_t)hal_get_cycles(); 1725 if( CONFIG_DEBUG_PROCESS_TXT_ DETACH < cycle )1646 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1726 1647 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n", 1727 __FUNCTION__, CURRENT_THREAD, process ->pid, cycle );1648 __FUNCTION__, CURRENT_THREAD, process, cycle ); 1728 1649 #endif 1729 1650 … … 1745 1666 remote_spinlock_unlock( lock_xp ); 1746 1667 1747 #if CONFIG_DEBUG_PROCESS_TXT_ DETACH1748 cycle = (uint32_t)hal_get_cycles(); 1749 if( CONFIG_DEBUG_PROCESS_TXT_ DETACH < cycle )1668 #if CONFIG_DEBUG_PROCESS_TXT_ATTACH 1669 cycle = (uint32_t)hal_get_cycles(); 1670 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle ) 1750 1671 printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n", 1751 __FUNCTION__, CURRENT_THREAD, process ->pid, cycle );1672 __FUNCTION__, CURRENT_THREAD, process, cycle ); 1752 1673 #endif 1753 1674 … … 1766 1687 // get cluster and local pointer on process 1767 1688 process_cxy = GET_CXY( process_xp ); 1768 process_ptr = (process_t *)GET_PTR( process_xp );1689 process_ptr = GET_PTR( process_xp ); 1769 1690 1770 1691 // get extended pointer on stdin pseudo file … … 1774 1695 txt_xp = chdev_from_file( file_xp ); 1775 1696 txt_cxy = GET_CXY( txt_xp ); 1776 txt_ptr = (chdev_t *)GET_PTR( txt_xp );1697 txt_ptr = GET_PTR( txt_xp ); 1777 1698 1778 1699 // set owner field in TXT chdev … … 1804 1725 // get cluster and local pointer on process 1805 1726 process_cxy = GET_CXY( process_xp ); 1806 process_ptr = (process_t *)GET_PTR( process_xp );1727 process_ptr = GET_PTR( process_xp ); 1807 1728 1808 1729 // get extended pointer on stdin pseudo file … … 1831 1752 current_ptr = GET_PTR( current_xp ); 1832 1753 parent_xp = hal_remote_lwd( XPTR( current_cxy , ¤t_ptr->parent_xp ) ); 1833 1834 1754 parent_cxy = GET_CXY( parent_xp ); 1835 1755 parent_ptr = GET_PTR( parent_xp ); 1836 1756 ppid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 1757 1758 printk("\n@@@ %s : pid = %x / process = %x\n", __FUNCTION__ , current_ptr->pid, current_ptr ); 1837 1759 1838 1760 if( ppid == 1 ) // current is KSH … … 1849 1771 1850 1772 1851 1773 ////////////////////////////////////////////////////// 1774 inline pid_t process_get_txt_owner( uint32_t channel ) 1775 { 1776 xptr_t txt_rx_xp = chdev_dir.txt_rx[channel]; 1777 cxy_t txt_rx_cxy = GET_CXY( txt_rx_xp ); 1778 chdev_t * txt_rx_ptr = GET_PTR( txt_rx_xp ); 1779 1780 xptr_t process_xp = (xptr_t)hal_remote_lwd( XPTR( txt_rx_cxy, 1781 &txt_rx_ptr->ext.txt.owner_xp ) ); 1782 1783 cxy_t process_cxy = GET_CXY( process_xp ); 1784 process_t * process_ptr = GET_PTR( process_xp ); 1785 1786 return (pid_t)hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) ); 1787 } 1788 1789 /////////////////////////////////////////// 1790 void process_txt_display( uint32_t txt_id ) 1791 { 1792 xptr_t chdev_xp; 1793 cxy_t chdev_cxy; 1794 chdev_t * chdev_ptr; 1795 xptr_t root_xp; 1796 xptr_t lock_xp; 1797 xptr_t current_xp; 1798 xptr_t iter_xp; 1799 1800 // check terminal index 1801 assert( (txt_id < LOCAL_CLUSTER->nb_txt_channels) , 1802 __FUNCTION__ , "illegal TXT terminal index" ); 1803 1804 // get pointers on TXT_RX[txt_id] chdev 1805 chdev_xp = chdev_dir.txt_rx[txt_id]; 1806 chdev_cxy = GET_CXY( chdev_xp ); 1807 chdev_ptr = GET_PTR( chdev_xp ); 1808 1809 // get extended pointer on root & lock of attached process list 1810 root_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.root ); 1811 lock_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.lock ); 1812 1813 // display header 1814 printk("\n***** processes attached to TXT_%d\n", txt_id ); 1815 1816 // get lock 1817 remote_spinlock_lock( lock_xp ); 1818 1819 // scan attached process list to find KSH process 1820 XLIST_FOREACH( root_xp , iter_xp ) 1821 { 1822 current_xp = XLIST_ELEMENT( iter_xp , process_t , txt_list ); 1823 process_display( current_xp ); 1824 } 1825 1826 // release lock 1827 remote_spinlock_unlock( lock_xp ); 1828 1829 } // end process_txt_display -
trunk/kernel/kern/process.h
r433 r435 36 36 #include <hal_atomic.h> 37 37 #include <vmm.h> 38 #include <signal.h>39 38 #include <cluster.h> 40 39 #include <vfs.h> … … 63 62 DELETE_ALL_THREADS = 33, 64 63 }; 65 66 /*********************************************************************************************67 * The termination state is a 32 bits word:68 * - the 8 LSB bits contain the user defined exit status69 * - the 24 other bits contain the flags defined below70 ********************************************************************************************/71 72 #define PROCESS_FLAG_BLOCK 0x100 /*! process received as SIGSTOP signal */73 #define PROCESS_FLAG_KILL 0x200 /*! process terminated by a sys_kill() */74 #define PROCESS_FLAG_EXIT 0x400 /*! process terminated by a sys_exit() */75 #define PROCESS_FLAG_WAIT 0x800 /*! parent process executed successfully a sys_wait() */76 64 77 65 /********************************************************************************************* … … 291 279 292 280 /********************************************************************************************* 293 * This function allows a client thread running in the owner cluster of a process identified294 * by the <process> argument to block, unblock or delete all threads of the target process,295 * depending on the<action_type> argument. The scenario is the following:281 * This function allows a client thread running in any cluster to block, unblock or delete 282 * all threads of a process identified by the <pid> argument, depending on the 283 * <action_type> argument. The scenario is the following: 296 284 * - It uses the multicast, non blocking rpc_process_sigaction_client() function to send 297 285 * parallel requests to all remote clusters containing a process copy. Then it blocks … … 305 293 * It is used by the sys_kill() & sys_exit() functions to handle the "kill" & "exit" syscalls. 306 294 * It is also used by the process_make_exec() function to handle the "exec" syscall. 307 * WARNING : the DELETE and the BLOCK actions are NOT executed on the client thread. 308 ********************************************************************************************* 309 * @ process : pointer on the process descriptor in owner cluster. 295 * It is also called by the TXT device to execute the ctrl C & ctrl Z commands. 296 * WARNING : the DELETE action is NOT executed on the main thread (thread 0 in owner cluster). 297 ********************************************************************************************* 298 * @ pid : target process identifier. 310 299 * @ action_type : BLOCK_ALL_THREADS / UNBLOCK_ALL_THREADS / DELETE_ALL_THREADS 311 300 ********************************************************************************************/ 312 void process_sigaction( p rocess_t * process,301 void process_sigaction( pid_t pid, 313 302 uint32_t action_type ); 314 303 … … 403 392 struct thread_s ** child_thread_ptr ); 404 393 405 /*********************************************************************************************406 * This function is called by both the sys_kill() and sys_exit() system calls.407 * It must be executed by an RPC thread running in the target process owner cluster.408 * It uses twice the process_sigaction() function:409 * - first, to block all target process threads, in all clusters.410 * - second, to delete all target process threads in all clusters.411 * Finally, it synchronizes with the parent process sys_wait() function that MUST be called412 * by the parent process main thread.413 *********************************************************************************************414 * @ process : pointer on process descriptor in owner cluster.415 * @ is_exit : true when called by sys_exit() / false when called by sys_kill().416 * @ exit_status : exit status, when called by sys_exit().417 ********************************************************************************************/418 void process_make_kill( process_t * process,419 bool_t is_exit,420 uint32_t exit_status );421 422 394 423 395 /******************** File Management Operations ****************************************/ … … 573 545 void process_txt_reset_ownership( xptr_t process_xp ); 574 546 547 /********************************************************************************************* 548 * This function returns the terminal owner process (foreground process) 549 * for a given TXT terminal identified by its <channel> index. 550 ********************************************************************************************* 551 * @ channel : TXT terminal channel. 552 * @ return owner process identifier. 553 ********************************************************************************************/ 554 pid_t process_get_txt_owner( uint32_t channel ); 555 556 /********************************************************************************************* 557 * This debug function diplays on the kernel terminal the list of processes attached 558 * to a given terminal identified by the <txt_id> argument. 559 ********************************************************************************************* 560 * @ txt_id : TXT terminal channel. 561 ********************************************************************************************/ 562 void process_txt_display( uint32_t txt_id ); 563 564 575 565 #endif /* _PROCESS_H_ */ -
trunk/kernel/kern/rpc.c
r433 r435 39 39 #include <vfs.h> 40 40 #include <fatfs.h> 41 #include <signal.h>42 41 #include <rpc.h> 43 42 … … 80 79 &rpc_process_make_fork_server, // 3 81 80 &rpc_undefined, // 4 unused slot 82 &rpc_ process_make_kill_server, // 581 &rpc_undefined, // 5 unused slot 83 82 &rpc_thread_user_create_server, // 6 84 83 &rpc_thread_kernel_create_server, // 7 … … 610 609 611 610 ///////////////////////////////////////////////////////////////////////////////////////// 612 // [5] Marshaling functions attached to RPC_PROCESS_MAKE_KILL (blocking) 613 ///////////////////////////////////////////////////////////////////////////////////////// 614 615 /////////////////////////////////////////////////// 616 void rpc_process_make_kill_client( cxy_t cxy, 617 process_t * process, 618 bool_t is_exit, 619 uint32_t status ) 620 { 621 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 622 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 623 CURRENT_THREAD->core->lid , hal_time_stamp() ); 624 625 // initialise RPC descriptor header 626 rpc_desc_t rpc; 627 rpc.index = RPC_PROCESS_MAKE_KILL; 628 rpc.response = 1; 629 rpc.blocking = true; 630 631 // set input arguments in RPC descriptor 632 rpc.args[0] = (uint64_t)(intptr_t)process; 633 rpc.args[1] = (uint64_t)is_exit; 634 rpc.args[2] = (uint64_t)status; 635 636 // register RPC request in remote RPC fifo (blocking function) 637 rpc_send( cxy , &rpc ); 638 639 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 640 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 641 CURRENT_THREAD->core->lid , hal_time_stamp() ); 642 } 643 644 ////////////////////////////////////////////// 645 void rpc_process_make_kill_server( xptr_t xp ) 646 { 647 rpc_dmsg("\n[DBG] %s : enter / thread %x on core[%x,%d] / cycle %d\n", 648 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 649 CURRENT_THREAD->core->lid , hal_time_stamp() ); 650 651 process_t * process; 652 bool_t is_exit; 653 uint32_t status; 654 655 // get client cluster identifier and pointer on RPC descriptor 656 cxy_t client_cxy = (cxy_t)GET_CXY( xp ); 657 rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp ); 658 659 // get arguments from RPC descriptor 660 process = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &desc->args[0] ) ); 661 is_exit = (bool_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[1] ) ); 662 status = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &desc->args[2] ) ); 663 664 // call local kernel function 665 process_make_kill( process , is_exit , status ); 666 667 rpc_dmsg("\n[DBG] %s : exit / thread %x on core[%x,%d] / cycle %d\n", 668 __FUNCTION__ , CURRENT_THREAD->trdid , local_cxy, 669 CURRENT_THREAD->core->lid , hal_time_stamp() ); 670 } 611 // [5] undefined slot 612 ///////////////////////////////////////////////////////////////////////////////////////// 671 613 672 614 ///////////////////////////////////////////////////////////////////////////////////////// … … 906 848 rpc_desc_t * rpc_ptr ) 907 849 { 908 sigaction_dmsg("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n",850 rpc_dmsg("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n", 909 851 __FUNCTION__ , process_action_str( (uint32_t)rpc_ptr->args[0] ) , 910 852 ((process_t *)(intptr_t)rpc_ptr->args[1])->pid , cxy , (uint32_t)hal_get_cycles() ); … … 913 855 rpc_send( cxy , rpc_ptr ); 914 856 915 sigaction_dmsg("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n",857 rpc_dmsg("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n", 916 858 __FUNCTION__ , process_action_str( (uint32_t)rpc_ptr->args[0] ) , 917 859 ((process_t *)(intptr_t)rpc_ptr->args[1])->pid , cxy , (uint32_t)hal_get_cycles() ); … … 921 863 void rpc_process_sigaction_server( xptr_t xp ) 922 864 { 865 pid_t pid; // target process identifier 923 866 process_t * process; // pointer on local process descriptor 924 867 uint32_t action; // sigaction index … … 934 877 935 878 // get arguments from RPC descriptor 936 action = (uint32_t) 937 p rocess = (process_t *)(intptr_t)hal_remote_lwd( XPTR( client_cxy , &rpc->args[1] ) );879 action = (uint32_t) hal_remote_lwd( XPTR( client_cxy , &rpc->args[0] ) ); 880 pid = (pid_t) hal_remote_lwd( XPTR( client_cxy , &rpc->args[1] ) ); 938 881 client_ptr = (thread_t *)hal_remote_lpt( XPTR( client_cxy , &rpc->thread ) ); 882 883 rpc_dmsg("\n[DBG] %s : enter to %s process %x / cycle %d\n", 884 __FUNCTION__ , process_action_str( action ) , pid , (uint32_t)hal_get_cycles() ); 885 886 // get local process descriptor 887 process = process_get_local_copy( pid ); 939 888 940 889 // build extended pointer on client thread 941 890 client_xp = XPTR( client_cxy , client_ptr ); 942 943 sigaction_dmsg("\n[DBG] %s : enter to %s process %x / cycle %d\n",944 __FUNCTION__ , process_action_str( action ) , process->pid , (uint32_t)hal_get_cycles() );945 891 946 892 // call relevant kernel function … … 958 904 } 959 905 960 sigaction_dmsg("\n[DBG] %s : exit after %s process %x / cycle %d\n",961 __FUNCTION__ , process_action_str( action ) , p rocess->pid , (uint32_t)hal_get_cycles() );906 rpc_dmsg("\n[DBG] %s : exit after %s process %x / cycle %d\n", 907 __FUNCTION__ , process_action_str( action ) , pid , (uint32_t)hal_get_cycles() ); 962 908 } 963 909 -
trunk/kernel/kern/rpc.h
r433 r435 32 32 #include <vseg.h> 33 33 #include <remote_fifo.h> 34 #include <signal.h>35 34 36 35 /**** Forward declarations ****/ … … 65 64 RPC_PROCESS_MAKE_FORK = 3, 66 65 RPC_UNDEFINED_4 = 4, 67 RPC_ PROCESS_MAKE_KILL= 5,66 RPC_UNDEFINED_5 = 5, 68 67 RPC_THREAD_USER_CREATE = 6, 69 68 RPC_THREAD_KERNEL_CREATE = 7, … … 242 241 243 242 /*********************************************************************************** 244 * [5] The RPC_PROCESS_MAKE_KILL can be called by any thread to request the owner 245 * cluster to execute the process_make_kill() function for a target process. 246 *********************************************************************************** 247 * @ cxy : owner cluster identifier. 248 * @ process : pointer on process in owner cluster. 249 * @ is_exit : true if called by sys_exit() / false if called by sys_kill() 250 * @ status : exit status (only when called by sys_exit() 251 **********************************************************************************/ 252 void rpc_process_make_kill_client( cxy_t cxy, 253 struct process_s * process, 254 bool_t is_exit, 255 uint32_t status ); 256 257 void rpc_process_make_kill_server( xptr_t xp ); 243 * [5] undefined slot 244 **********************************************************************************/ 258 245 259 246 /*********************************************************************************** … … 314 301 /*********************************************************************************** 315 302 * [9] The RPC_PROCESS_SIGACTION allows the owner cluster to request any other 316 * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all threads317 * of a given process.303 * cluster to execute a given sigaction (BLOCK / UNBLOCK / DELETE) for all 304 * threads of a given process. 318 305 * 319 306 * WARNING : It is implemented as a NON BLOCKING multicast RPC, that can be sent -
trunk/kernel/kern/scheduler.c
r433 r435 280 280 } 281 281 282 // enter critical section / save SR in current thread context283 hal_disable_irq( & current->save_sr );282 // enter critical section / save SR in current thread descriptor 283 hal_disable_irq( &CURRENT_THREAD->save_sr ); 284 284 285 285 // loop on threads to select next thread … … 321 321 } 322 322 323 // switch CPU from c allingthread context to new thread context323 // switch CPU from current thread context to new thread context 324 324 hal_do_cpu_switch( current->cpu_context, next->cpu_context ); 325 325 } … … 330 330 uint32_t cycle = (uint32_t)hal_get_cycles(); 331 331 if( CONFIG_DEBUG_SCHED_YIELD < cycle ) 332 printk("\n[DBG] %s : core[%x,%d] / cause = %s / thread %x (%s) (%x,%x) continue / cycle %d\n", 332 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 333 " thread %x (%s) (%x,%x) continue / cycle %d\n", 333 334 __FUNCTION__, local_cxy, core->lid, cause, 334 335 current, thread_type_str(current->type), current->process->pid, current->trdid, cycle ); … … 340 341 sched_handle_signals( core ); 341 342 342 // exit critical section / restore SR from next thread context343 hal_restore_irq( next->save_sr );343 // exit critical section / restore SR from current thread descriptor 344 hal_restore_irq( CURRENT_THREAD->save_sr ); 344 345 345 346 } // end sched_yield() -
trunk/kernel/kern/signal.h
r409 r435 28 28 29 29 #include <hal_types.h> 30 31 #define SIG_DEFAULT (void*)0L32 #define SIG_IGNORE (void*)1L33 #define SIG_ERROR -1L34 35 #define SIGHUP 1 /*! hangup */36 #define SIGINT 2 /*! interrupt */37 #define SIGQUIT 3 /*! quit */38 #define SIGILL 4 /*! illegal instruction (not reset when caught) */39 #define SIGTRAP 5 /*! trace trap (not reset when caught) */40 #define SIGIOT 6 /*! IOT instruction */41 #define SIGABRT 6 /*! used by abort, replace SIGIOT in the future */42 #define SIGEMT 7 /*! EMT instruction */43 #define SIGFPE 8 /*! floating point exception */44 #define SIGKILL 9 /*! kill (cannot be caught or ignored) */45 #define SIGBUS 10 /*! bus error */46 #define SIGSEGV 11 /*! segmentation violation */47 #define SIGSYS 12 /*! bad argument to system call */48 #define SIGPIPE 13 /*! write on a pipe with no one to read it */49 #define SIGALRM 14 /*! alarm clock */50 #define SIGTERM 15 /*! software termination signal from kill */51 #define SIGURG 16 /*! urgent condition on IO channel */52 #define SIGSTOP 17 /*! sendable stop signal not from tty */53 #define SIGTSTP 18 /*! stop signal from tty */54 #define SIGCONT 19 /*! continue a stopped process */55 #define SIGCHLD 20 /*! to parent on child stop or exit */56 #define SIGCLD 20 /*! System V name for SIGCHLD */57 #define SIGTTIN 21 /*! to readers pgrp upon background tty read */58 #define SIGTTOU 22 /*! like TTIN for output if (tp->t_local<OSTOP) */59 #define SIGIO 23 /*! input/output possible signal */60 #define SIGPOLL SIGIO /*! System V name for SIGIO */61 #define SIGXCPU 24 /*! exceeded CPU time limit */62 #define SIGXFSZ 25 /*! exceeded file size limit */63 #define SIGVTALRM 26 /*! virtual time alarm */64 #define SIGPROF 27 /*! profiling time alarm */65 #define SIGWINCH 28 /*! window changed */66 #define SIGLOST 29 /*! resource lost (eg, record-lock lost) */67 #define SIGUSR1 30 /*! user defined signal 1 */68 #define SIGUSR2 31 /*! user defined signal 2 */69 #define SIG_NR 32 /*! signal 0 implied */70 71 #define SIG_DEFAULT_MASK 0xFFEEFFFF72 30 73 31 -
trunk/kernel/libk/xlist.h
r24 r435 72 72 * extended double linked list, identified by the extended pointer on 73 73 * the root xlist_entry_t. 74 * WARNING : check list non empty before using this macro. 74 75 * @ root_xp : extended pointer on the root xlist_entry_t 75 76 * @ type : type of the linked elements … … 85 86 * extended double linked list, identified by the extended pointer on 86 87 * the root xlist_entry_t. 88 * WARNING : check list non empty before using this macro. 87 89 * @ root_xp : extended pointer on the root xlist_entry_t 88 90 * @ type : type of the linked elements -
trunk/kernel/mm/kcm.c
r433 r435 48 48 { 49 49 50 #if CONFIG_DEBUG_KCM _ALLOC50 #if CONFIG_DEBUG_KCM 51 51 uint32_t cycle = (uint32_t)hal_get_cycles(); 52 if( CONFIG_DEBUG_KCM _ALLOC< cycle )52 if( CONFIG_DEBUG_KCM < cycle ) 53 53 printk("\n[DBG] %s : thread %x enters for %s / page %x / count %d / active %d\n", 54 54 __FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) , … … 85 85 + (index * kcm->block_size) ); 86 86 87 #if CONFIG_DEBUG_KCM _ALLOC87 #if CONFIG_DEBUG_KCM 88 88 cycle = (uint32_t)hal_get_cycles(); 89 if( CONFIG_DEBUG_KCM _ALLOC< cycle )89 if( CONFIG_DEBUG_KCM < cycle ) 90 90 printk("\n[DBG] %s : thread %x exit / type %s / ptr %p / page %x / count %d\n", 91 91 __FUNCTION__ , CURRENT_THREAD , kmem_type_str( kcm->type ) , ptr , -
trunk/kernel/mm/kmem.c
r433 r435 145 145 assert( ((type > 1) && (type < KMEM_TYPES_NR) ) , __FUNCTION__ , "illegal KCM type" ); 146 146 147 kmem_dmsg("\n[DBG] %s : enters / KCM type %s missing in cluster %x\n", 148 __FUNCTION__ , kmem_type_str( type ) , local_cxy ); 147 #if CONFIG_DEBUG_KMEM 148 uint32_t cycle = (uint32_t)hal_get_cycles(); 149 if( CONFIG_DEBUG_KMEM < cycle ) 150 printk("\n[DBG] %s : thread %x enter / KCM type %s missing in cluster %x / cycle %d\n", 151 __FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), local_cxy, cycle ); 152 #endif 149 153 150 154 cluster_t * cluster = LOCAL_CLUSTER; … … 169 173 hal_fence(); 170 174 171 kmem_dmsg("\n[DBG] %s : exit / KCM type %s created in cluster %x\n", 172 __FUNCTION__ , kmem_type_str( type ) , local_cxy ); 175 #if CONFIG_DEBUG_KMEM 176 cycle = (uint32_t)hal_get_cycles(); 177 if( CONFIG_DEBUG_KMEM < cycle ) 178 printk("\n[DBG] %s : thread %x exit / cycle %d\n", 179 __FUNCTION__, CURRENT_THREAD, cycle ); 180 #endif 173 181 174 182 return 0; … … 192 200 assert( (type < KMEM_TYPES_NR) , __FUNCTION__ , "illegal KMEM request type" ); 193 201 194 kmem_dmsg("\n[DBG] %s : enters in cluster %x for type %s\n", 195 __FUNCTION__ , local_cxy , kmem_type_str( type ) ); 202 #if CONFIG_DEBUG_KMEM 203 uint32_t cycle = (uint32_t)hal_get_cycles(); 204 if( CONFIG_DEBUG_KMEM < cycle ) 205 printk("\n[DBG] %s : thread %x enter / type %s / cluster %x / cycle %d\n", 206 __FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), local_cxy, cycle ); 207 #endif 196 208 197 209 // analyse request type 198 210 if( type == KMEM_PAGE ) // PPM allocator 199 211 { 200 201 #if CONFIG_DEBUG_KMEM_ALLOC202 if( CONFIG_DEBUG_KMEM_ALLOC < (uint32_t)hal_get_cycles() )203 printk("\n[DBG] in %s : thread %x enter for %d page(s)\n",204 __FUNCTION__ , CURRENT_THREAD , 1<<size );205 #endif206 207 212 // allocate the number of requested pages 208 213 ptr = (void *)ppm_alloc_pages( size ); … … 217 222 if( flags & AF_ZERO ) page_zero( (page_t *)ptr ); 218 223 219 kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / page = %x / base = %x\n", 220 __FUNCTION__, local_cxy , kmem_type_str( type ) , 221 (intptr_t)ptr , (intptr_t)ppm_page2base( ptr ) ); 222 223 #if CONFIG_DEBUG_KMEM_ALLOC 224 if( CONFIG_DEBUG_KMEM_ALLOC < (uint32_t)hal_get_cycles() ) 225 printk("\n[DBG] in %s : thread %x exit / %d page(s) allocated / ppn = %x\n", 226 __FUNCTION__ , CURRENT_THREAD , 1<<size , ppm_page2ppn( XPTR( local_cxy , ptr ) ) ); 224 #if CONFIG_DEBUG_KMEM 225 cycle = (uint32_t)hal_get_cycles(); 226 if( CONFIG_DEBUG_KMEM < cycle ) 227 printk("\n[DBG] %s : thread %x exit / %d page(s) allocated / ppn %x / cycle %d\n", 228 __FUNCTION__, CURRENT_THREAD, 1<<size, ppm_page2ppn(XPTR(local_cxy,ptr)), cycle ); 227 229 #endif 228 230 … … 242 244 if( flags & AF_ZERO ) memset( ptr , 0 , size ); 243 245 244 kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / base = %x / size = %d\n", 245 __FUNCTION__, local_cxy , kmem_type_str( type ) , 246 (intptr_t)ptr , req->size ); 246 #if CONFIG_DEBUG_KMEM 247 cycle = (uint32_t)hal_get_cycles(); 248 if( CONFIG_DEBUG_KMEM < cycle ) 249 printk("\n[DBG] %s : thread %x exit / type %s allocated / base %x / size %d / cycle %d\n", 250 __FUNCTION__, CURRENT_THREAD, kmem_type_str( type ), (intptr_t)ptr, size, cycle ); 251 #endif 252 247 253 } 248 254 else // KCM allocator … … 269 275 if( flags & AF_ZERO ) memset( ptr , 0 , kmem_type_size( type ) ); 270 276 271 kmem_dmsg("\n[DBG] %s : exit in cluster %x for type %s / base = %x / size = %d\n", 272 __FUNCTION__, local_cxy , kmem_type_str( type ) , 273 (intptr_t)ptr , kmem_type_size( type ) ); 277 #if CONFIG_DEBUG_KMEM 278 cycle = (uint32_t)hal_get_cycles(); 279 if( CONFIG_DEBUG_KMEM < cycle ) 280 printk("\n[DBG] %s : thread %x exit / type %s allocated / base %x / size %d / cycle %d\n", 281 __FUNCTION__, CURRENT_THREAD, kmem_type_str(type), (intptr_t)ptr, 282 kmem_type_size(type), cycle ); 283 #endif 284 274 285 } 275 286 -
trunk/kernel/mm/mapper.c
r408 r435 143 143 error_t error; 144 144 145 mapper_dmsg("\n[DBG] %s : core[%x,%d] enters for page %d / mapper %x\n", 146 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , index , mapper ); 145 #if CONFIG_DEBUG_MAPPER_GET_PAGE 146 uint32_t cycle = (uint32_t)hal_get_cycles(); 147 if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle ) 148 printk("\n[DBG] %s : thread %x enter for page %d / mapper %x / cycle %d\n", 149 __FUNCTION__ , CURRENT_THREAD , index , mapper , cycle ); 150 #endif 147 151 148 152 thread_t * this = CURRENT_THREAD; … … 171 175 { 172 176 173 mapper_dmsg("\n[DBG] %s : core[%x,%d] missing page => load from device\n", 174 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ); 175 177 #if (CONFIG_DEBUG_MAPPER_GET_PAGE & 1) 178 if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle ) 179 printk("\n[DBG] %s : missing page => load from device\n", __FUNCTION__ ); 180 #endif 176 181 // allocate one page from PPM 177 182 req.type = KMEM_PAGE; … … 230 235 // reset the page INLOAD flag to make the page available to all readers 231 236 page_clear_flag( page , PG_INLOAD ); 232 233 mapper_dmsg("\n[DBG] %s : missing page loaded / ppn = %x\n",234 __FUNCTION__ , ppm_page2ppn(XPTR(local_cxy,page)) );235 236 237 } 237 238 else if( page_is_flag( page , PG_INLOAD ) ) // page is loaded by another thread … … 256 257 } 257 258 258 mapper_dmsg("\n[DBG] %s : exit for page %d / mapper %x / page_desc = %x\n", 259 __FUNCTION__ , index , mapper , page ); 259 #if CONFIG_DEBUG_MAPPER_GET_PAGE 260 cycle = (uint32_t)hal_get_cycles(); 261 if( CONFIG_DEBUG_MAPPER_GET_PAGE < cycle ) 262 printk("\n[DBG] %s : thread %x exit for page %d / ppn %x / cycle %d\n", 263 __FUNCTION__, CURRENT_THREAD, index, ppm_page2ppn(XPTR(local_cxy, page)), cycle ); 264 #endif 260 265 261 266 return page; … … 312 317 uint8_t * buf_ptr; // current buffer address 313 318 314 mapper_dmsg("\n[DBG] %s : enters / to_buf = %d / buffer = %x\n", 315 __FUNCTION__ , to_buffer , buffer ); 319 #if CONFIG_DEBUG_MAPPER_MOVE_USER 320 uint32_t cycle = (uint32_t)hal_get_cycles(); 321 if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle ) 322 printk("\n[DBG] %s : thread %x enter / to_buf %d / buffer %x / cycle %d\n", 323 __FUNCTION__ , CURRENT_THREAD , to_buffer , buffer , cycle ); 324 #endif 316 325 317 326 // compute offsets of first and last bytes in file … … 338 347 else page_count = CONFIG_PPM_PAGE_SIZE; 339 348 340 mapper_dmsg("\n[DBG] %s : index = %d / offset = %d / count = %d\n", 341 __FUNCTION__ , index , page_offset , page_count ); 349 #if (CONFIG_DEBUG_MAPPER_MOVE_USER & 1) 350 if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle ) 351 printk("\n[DBG] %s : index = %d / offset = %d / count = %d\n", 352 __FUNCTION__ , index , page_offset , page_count ); 353 #endif 342 354 343 355 // get page descriptor … … 353 365 buf_ptr = (uint8_t *)buffer + done; 354 366 355 mapper_dmsg("\n[DBG] %s : index = %d / buf_ptr = %x / map_ptr = %x\n",356 __FUNCTION__ , index , buf_ptr , map_ptr );357 358 367 // move fragment 359 368 if( to_buffer ) … … 370 379 } 371 380 372 mapper_dmsg("\n[DBG] %s : exit for buffer %x\n", 373 __FUNCTION__, buffer ); 381 #if CONFIG_DEBUG_MAPPER_MOVE_USER 382 cycle = (uint32_t)hal_get_cycles(); 383 if( CONFIG_DEBUG_MAPPER_MOVE_USER < cycle ) 384 printk("\n[DBG] %s : thread %x exit / to_buf %d / buffer %x / cycle %d\n", 385 __FUNCTION__ , CURRENT_THREAD , to_buffer , buffer , cycle ); 386 #endif 374 387 375 388 return 0; … … 399 412 uint8_t * buffer_ptr = (uint8_t *)GET_PTR( buffer_xp ); 400 413 401 mapper_dmsg("\n[DBG] %s : core[%x,%d] / to_buf = %d / buf_cxy = %x / buf_ptr = %x / size = %x\n", 402 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, to_buffer, buffer_cxy, buffer_ptr, size ); 414 #if CONFIG_DEBUG_MAPPER_MOVE_KERNEL 415 uint32_t cycle = (uint32_t)hal_get_cycles(); 416 if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle ) 417 printk("\n[DBG] %s : thread %x enter / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n", 418 __FUNCTION__ , CURRENT_THREAD , to_buffer , buffer_cxy , buffer_ptr , cycle ); 419 #endif 403 420 404 421 // compute offsets of first and last bytes in file … … 410 427 uint32_t last = max_byte >> CONFIG_PPM_PAGE_SHIFT; 411 428 412 mapper_dmsg("\n[DBG] %s : core[%x,%d] / first_page = %d / last_page = %d\n", 413 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, first, last ); 429 #if (CONFIG_DEBUG_MAPPER_MOVE_KERNEL & 1) 430 if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle ) 431 printk("\n[DBG] %s : first_page %d / last_page %d\n", __FUNCTION__, first, last ); 432 #endif 414 433 415 434 // compute source and destination clusters … … 440 459 else page_count = CONFIG_PPM_PAGE_SIZE; 441 460 442 mapper_dmsg("\n[DBG] %s : core[%x;%d] / page_index = %d / offset = %d / bytes = %d\n", 443 __FUNCTION__ , local_cxy, CURRENT_THREAD->core->lid, index, page_offset, page_count ); 461 #if (CONFIG_DEBUG_MAPPER_MOVE_KERNEL & 1) 462 if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle ) 463 printk("\n[DBG] %s : page_index = %d / offset = %d / bytes = %d\n", 464 __FUNCTION__ , index , page_offset , page_count ); 465 #endif 444 466 445 467 // get page descriptor … … 472 494 } 473 495 474 mapper_dmsg("\n[DBG] %s : core_cxy[%x,%d] / exit / buf_cxy = %x / buf_ptr = %x / size = %x\n", 475 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, buffer_cxy, buffer_ptr, size ); 496 #if CONFIG_DEBUG_MAPPER_MOVE_KERNEL 497 cycle = (uint32_t)hal_get_cycles(); 498 if( CONFIG_DEBUG_MAPPER_MOVE_KERNEL < cycle ) 499 printk("\n[DBG] %s : thread %x exit / to_buf %d / buf_cxy %x / buf_ptr %x / cycle %d\n", 500 __FUNCTION__ , CURRENT_THREAD , to_buffer , buffer_cxy , buffer_ptr , cycle ); 501 #endif 476 502 477 503 return 0; -
trunk/kernel/mm/vmm.c
r433 r435 1643 1643 #if CONFIG_DEBUG_VMM_GET_PTE 1644 1644 uint32_t cycle = (uint32_t)hal_get_cycles(); 1645 if( CONFIG_DEBUG_VMM_GET_PTE >cycle )1645 if( CONFIG_DEBUG_VMM_GET_PTE < cycle ) 1646 1646 printk("\n[DBG] %s : thread %x enter for vpn = %x / process %x / cow = %d / cycle %d\n", 1647 1647 __FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cow , cycle ); … … 1800 1800 error_t error; 1801 1801 1802 #if CONFIG_DEBUG_VMM_GET_PTE 1803 uint32_t cycle = (uint32_t)hal_get_cycles(); 1804 if( CONFIG_DEBUG_VMM_GET_PTE < cycle ) 1805 printk("\n[DBG] %s : thread %x enter for vpn %x / process %x / cycle %d\n", 1806 __FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle ); 1807 #endif 1808 1802 1809 // get reference process cluster and local pointer 1803 1810 cxy_t ref_cxy = GET_CXY( process->ref_xp ); … … 1833 1840 } 1834 1841 1842 #if CONFIG_DEBUG_VMM_GET_PTE 1843 cycle = (uint32_t)hal_get_cycles(); 1844 if( CONFIG_DEBUG_VMM_GET_PTE < cycle ) 1845 printk("\n[DBG] %s : thread %x exit for vpn %x / process %x / cycle %d\n", 1846 __FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle ); 1847 #endif 1848 1835 1849 return error; 1836 1850 … … 1845 1859 error_t error; 1846 1860 1861 #if CONFIG_DEBUG_VMM_GET_PTE 1862 uint32_t cycle = (uint32_t)hal_get_cycles(); 1863 if( CONFIG_DEBUG_VMM_GET_PTE < cycle ) 1864 printk("\n[DBG] %s : thread %x enter for vpn %x / process %x / cycle %d\n", 1865 __FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle ); 1866 #endif 1847 1867 1848 1868 // get reference process cluster and local pointer … … 1879 1899 } 1880 1900 1901 #if CONFIG_DEBUG_VMM_GET_PTE 1902 cycle = (uint32_t)hal_get_cycles(); 1903 if( CONFIG_DEBUG_VMM_GET_PTE < cycle ) 1904 printk("\n[DBG] %s : thread %x exit for vpn %x / process %x / cycle %d\n", 1905 __FUNCTION__ , CURRENT_THREAD , vpn , process->pid , cycle ); 1906 #endif 1907 1881 1908 return error; 1882 1909 -
trunk/kernel/syscalls/shared_syscalls.h
r421 r435 321 321 typedef enum 322 322 { 323 DISPLAY_STRING = 0, 324 DISPLAY_VMM = 1, 325 DISPLAY_SCHED = 2, 326 DISPLAY_PROCESS = 3, 327 DISPLAY_VFS = 4, 328 DISPLAY_CHDEV = 5, 323 DISPLAY_STRING = 0, 324 DISPLAY_VMM = 1, 325 DISPLAY_SCHED = 2, 326 DISPLAY_CLUSTER_PROCESSES = 3, 327 DISPLAY_VFS = 4, 328 DISPLAY_CHDEV = 5, 329 DISPLAY_TXT_PROCESSES = 6, 329 330 } 330 331 display_type_t; … … 391 392 392 393 394 /********************************************************************************************* 395 * These macros can be used by the parent process to analyze a child process 396 * termination status, as returned by the wait() syscall. 397 * The termination state is a 32 bits word: 398 * - the 8 LSB bits contain the user defined exit status 399 * - the 24 other bits contain the flags defined below 400 ********************************************************************************************/ 401 402 #define PROCESS_TERM_STOP 0x100 /*! process received a SIGSTOP signal */ 403 #define PROCESS_TERM_KILL 0x200 /*! process killed by a SIGKILL signal */ 404 #define PROCESS_TERM_EXIT 0x400 /*! process terminated by a sys_exit() */ 405 #define PROCESS_TERM_WAIT 0x800 /*! parent process executed a sys_wait() */ 406 407 #define WIFEXITED( status ) (status & PROCESS_TERM_EXIT) 408 #define WIFSIGNALED( status ) (status & PROCESS_TERM_KILL) 409 #define WIFSTOPPED( status ) (status & PROCESS_TERM_STOP) 410 #define WEXITSTATUS( status ) (status & 0xFF) 411 393 412 394 413 #endif // _SHARED_SYSCALLS_H_ -
trunk/kernel/syscalls/sys_display.c
r433 r435 142 142 } 143 143 } 144 else if( type == DISPLAY_ PROCESS )144 else if( type == DISPLAY_CLUSTER_PROCESSES ) 145 145 { 146 146 cxy_t cxy = (cxy_t)arg0; … … 155 155 156 156 cluster_processes_display( cxy ); 157 } 158 else if( type == DISPLAY_TXT_PROCESSES ) 159 { 160 uint32_t txt_id = (uint32_t)arg0; 161 162 // check argument 163 if( txt_id >= LOCAL_CLUSTER->nb_txt_channels ) 164 { 165 printk("\n[ERROR] in %s : undefined TXT channel %x\n", 166 __FUNCTION__ , txt_id ); 167 return -1; 168 } 169 170 process_txt_display( txt_id ); 157 171 } 158 172 else if( type == DISPLAY_VFS ) -
trunk/kernel/syscalls/sys_exec.c
r433 r435 221 221 printk("\n[ERROR] in %s : cannot access args\n", __FUNCTION__ ); 222 222 #endif 223 this->errno = error;223 this->errno = EINVAL; 224 224 return -1; 225 225 } … … 235 235 printk("\n[ERROR] in %s : cannot access envs\n", __FUNCTION__ ); 236 236 #endif 237 this->errno = error;237 this->errno = EINVAL; 238 238 return -1; 239 239 } … … 248 248 #if CONFIG_DEBUG_SYSCALLS_ERROR 249 249 printk("\n[ERROR] in %s : cannot create process %x in cluster %x\n", 250 __FUNCTION__, pid, CXY_FROM_PID( pid);250 __FUNCTION__, pid, CXY_FROM_PID(pid) ); 251 251 #endif 252 252 this->errno = error; -
trunk/kernel/syscalls/sys_exit.c
r433 r435 29 29 #include <printk.h> 30 30 #include <process.h> 31 #include <s ignal.h>31 #include <shared_syscalls.h> 32 32 #include <cluster.h> 33 33 #include <rpc.h> … … 51 51 #endif 52 52 53 // get cluster and pointers on process in owner cluster 54 xptr_t owner_xp = cluster_get_owner_process_from_pid( pid ); 55 cxy_t owner_cxy = GET_CXY( owner_xp ); 56 process_t * owner_ptr = GET_PTR( owner_xp ); 53 // get owner cluster 54 cxy_t owner_cxy = CXY_FROM_PID( pid ); 57 55 58 assert( (owner_xp != XPTR_NULL) , __FUNCTION__ , "owner_xp cannot be NULL\n" ); 56 // exit must be called by the main thread 57 if( (owner_cxy != local_cxy) || (LTID_FROM_TRDID( this->trdid ) != 0) ) 58 { 59 60 #if CONFIG_DEBUG_SYSCALLS_ERROR 61 printk("\n[ERROR] %s must be called by thread 0 in process owner cluster\n" 62 " trdid = %x / pid = %x / local_cxy = %x\n", 63 __FUNCTION__, this->trdid, pid, local_cxy ); 64 #endif 65 this->errno = EINVAL; 66 return -1; 67 } 59 68 60 69 // enable IRQs 61 70 hal_enable_irq( &save_sr ); 62 71 63 // the process_make_kill() function must be executed 64 // by an RPC thread in reference cluster 65 rpc_process_make_kill_client( owner_cxy, owner_ptr, true , status ); 72 // register exit_status in owner process descriptor 73 process->term_state = status; 74 75 // remove TXT ownership from owner process descriptor 76 process_txt_reset_ownership( XPTR( local_cxy , process ) ); 77 78 // block all process threads in all clusters 79 process_sigaction( pid , BLOCK_ALL_THREADS ); 80 81 // mark all process threads in all clusters for delete 82 process_sigaction( pid , DELETE_ALL_THREADS ); 66 83 67 84 // restore IRQs 68 85 hal_restore_irq( save_sr ); 69 86 87 // atomically update owner process descriptor term_state 88 hal_remote_atomic_or( XPTR( local_cxy , &process->term_state ) , 89 PROCESS_TERM_EXIT ); 70 90 hal_fence(); 71 91 -
trunk/kernel/syscalls/sys_fork.c
r433 r435 81 81 if( hal_remote_atomic_add( children_xp , 1 ) >= CONFIG_PROCESS_MAX_CHILDREN ) 82 82 { 83 printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__); 83 84 #if CONFIG_DEBUG_SYSCALLS_ERROR 85 printk("\n[ERROR] in %s : too much children processes\n", __FUNCTION__); 86 #endif 84 87 hal_remote_atomic_add ( children_xp , -1 ); 85 88 parent_thread_ptr->errno = EAGAIN; … … 119 122 if( error ) 120 123 { 121 printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n", 122 __FUNCTION__, parent_pid, local_cxy ); 124 125 #if CONFIG_DEBUG_SYSCALLS_ERROR 126 printk("\n[ERROR] in %s : cannot fork process %x in cluster %x\n", 127 __FUNCTION__, parent_pid, local_cxy ); 128 #endif 123 129 parent_thread_ptr->errno = EAGAIN; 124 130 return -1; -
trunk/kernel/syscalls/sys_get_config.c
r421 r435 35 35 int sys_get_config( uint32_t * x_size, 36 36 uint32_t * y_size, 37 uint32_t * y_width,38 37 uint32_t * ncores ) 39 38 { … … 41 40 uint32_t k_x_size; 42 41 uint32_t k_y_size; 43 uint32_t k_y_width;44 42 uint32_t k_ncores; 45 43 … … 49 47 process_t * process = this->process; 50 48 49 #if CONFIG_DEBUG_SYS_GET_CONFIG 50 uint64_t tm_start; 51 uint64_t tm_end; 52 tm_start = hal_get_cycles(); 53 if( CONFIG_DEBUG_SYS_GET_CONFIG < tm_start ) 54 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n", 55 __FUNCTION__, this, process->pid, (uint32_t)tm_start ); 56 #endif 57 51 58 // check buffer in user space 52 59 error |= vmm_v2p_translate( false , x_size , &paddr ); 53 60 error |= vmm_v2p_translate( false , y_size , &paddr ); 54 error |= vmm_v2p_translate( false , y_width , &paddr );55 61 error |= vmm_v2p_translate( false , ncores , &paddr ); 56 62 57 63 if( error ) 58 64 { 59 printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n", 60 __FUNCTION__ , this->trdid , process->pid ); 65 66 #if CONFIG_DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s : user buffer unmapped for thread %x in process %x\n", 68 __FUNCTION__ , this->trdid , process->pid ); 69 #endif 61 70 this->errno = EFAULT; 62 71 return -1; … … 66 75 k_x_size = LOCAL_CLUSTER->x_size; 67 76 k_y_size = LOCAL_CLUSTER->y_size; 68 k_y_width = LOCAL_CLUSTER->y_width;69 77 k_ncores = LOCAL_CLUSTER->cores_nr; 70 78 … … 72 80 hal_copy_to_uspace( x_size , &k_x_size , sizeof(uint32_t) ); 73 81 hal_copy_to_uspace( y_size , &k_y_size , sizeof(uint32_t) ); 74 hal_copy_to_uspace( y_width , &k_y_width , sizeof(uint32_t) );75 82 hal_copy_to_uspace( ncores , &k_ncores , sizeof(uint32_t) ); 83 84 hal_fence(); 85 86 #if CONFIG_DEBUG_SYS_GET_CONFIG 87 tm_end = hal_get_cycles(); 88 if( CONFIG_DEBUG_SYS_GET_CONFIG < tm_end ) 89 printk("\n[DBG] %s : thread %x exit / process %x / cost %d / tycle %d\n", 90 __FUNCTION__, this, process->pid, (uint32_t)(tm_end-tm_start), (uint32_t)tm_end ); 91 #endif 76 92 77 93 return 0; -
trunk/kernel/syscalls/sys_kill.c
r433 r435 48 48 49 49 thread_t * this = CURRENT_THREAD; 50 process_t * process = this->process; 50 51 51 52 #if CONFIG_DEBUG_SYS_KILL … … 58 59 #endif 59 60 60 // get cluster and pointers on owner process 61 // process cannot kill itself 62 if( pid == process->pid ) 63 { 64 65 #if CONFIG_DEBUG_SYSCALLS_ERROR 66 printk("\n[ERROR] in %s : process %d cannot kill itself\n", __FUNCTION__ , pid ); 67 #endif 68 this->errno = EINVAL; 69 return -1; 70 } 71 72 // get cluster and pointers on owner target process descriptor 61 73 owner_xp = cluster_get_owner_process_from_pid( pid ); 62 74 owner_cxy = GET_CXY( owner_xp ); … … 67 79 { 68 80 69 syscall_dmsg("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid ); 70 81 #if CONFIG_DEBUG_SYSCALLS_ERROR 82 printk("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid ); 83 #endif 71 84 this->errno = EINVAL; 72 85 return -1; … … 79 92 ppid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 80 93 81 // processes INIT and processes KSH cannot be stoped or killed82 if( p pid < 2)94 // processes INIT 95 if( pid == 1 ) 83 96 { 84 97 85 syscall_dmsg("\n[ERROR] in %s : process %x cannot be killed\n", __FUNCTION__ , pid ); 86 98 #if CONFIG_DEBUG_SYSCALLS_ERROR 99 printk("\n[ERROR] in %s : process_init cannot be killed\n", __FUNCTION__ ); 100 #endif 87 101 this->errno = EINVAL; 88 102 return -1; … … 92 106 hal_enable_irq( &save_sr ); 93 107 94 // analyse signal type 95 // supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 108 // analyse signal type / supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 96 109 switch( sig_id ) 97 110 { … … 108 121 109 122 // block all threads in all clusters 110 process_sigaction( owner_ptr, BLOCK_ALL_THREADS );123 process_sigaction( pid , BLOCK_ALL_THREADS ); 111 124 112 // atomically update referenceprocess termination state125 // atomically update owner process termination state 113 126 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 114 PROCESS_ FLAG_BLOCK);127 PROCESS_TERM_STOP ); 115 128 116 129 retval = 0; … … 120 133 { 121 134 // unblock all threads in all clusters 122 process_sigaction( owner_ptr, UNBLOCK_ALL_THREADS );135 process_sigaction( pid , UNBLOCK_ALL_THREADS ); 123 136 124 137 // atomically update reference process termination state 125 138 hal_remote_atomic_and( XPTR( owner_cxy , &owner_ptr->term_state ) , 126 ~PROCESS_ FLAG_BLOCK);139 ~PROCESS_TERM_STOP ); 127 140 retval = 0; 128 141 break; … … 131 144 case SIGKILL: 132 145 { 133 // the process_make_kill() function must be executed 134 // by an RPC thread in process owner cluster 135 // It deletes all target process threads in all clusters, 136 // and updates the process termination state 137 rpc_process_make_kill_client( owner_cxy , owner_ptr , false , 0 ); 146 // remove TXT ownership from owner process descriptor 147 process_txt_reset_ownership( owner_xp ); 148 149 // block all process threads in all clusters 150 process_sigaction( pid , BLOCK_ALL_THREADS ); 151 152 // mark all process threads in all clusters for delete 153 process_sigaction( pid , DELETE_ALL_THREADS ); 154 155 // atomically update owner process descriptor flags 156 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 157 PROCESS_TERM_KILL ); 138 158 139 159 retval = 0; … … 143 163 { 144 164 145 syscall_dmsg("\n[ERROR] in %s : illegal signal type %d for process %x\n", 146 __FUNCTION__ , sig_id, pid );147 165 #if CONFIG_DEBUG_SYSCALLS_ERROR 166 printk("\n[ERROR] in %s : illegal signal %d / process %x\n", __FUNCTION__, sig_id, pid ); 167 #endif 148 168 this->errno = EINVAL; 149 169 retval = -1; -
trunk/kernel/syscalls/sys_mmap.c
r407 r435 25 25 #include <hal_types.h> 26 26 #include <hal_uspace.h> 27 #include <hal_irqmask.h> 27 28 #include <shared_syscalls.h> 28 29 #include <errno.h> … … 44 45 error_t error; 45 46 paddr_t paddr; // unused, but required for user space checking 46 47 uint64_t tm_start; 48 uint64_t tm_end; 49 50 tm_start = hal_get_cycles(); 47 reg_t save_sr; // required to enable IRQs 51 48 52 49 thread_t * this = CURRENT_THREAD; 53 50 process_t * process = this->process; 54 51 52 #if CONFIG_DEBUG_SYS_MMAP 53 uint64_t tm_start; 54 uint64_t tm_end; 55 tm_start = hal_get_cycles(); 56 if ( CONFIG_DEBUG_SYS_MMAP < tm_start ) 57 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n", 58 __FUNCTION__, this, process->pid, (uint32_t)tm_start ); 59 #endif 60 55 61 // check arguments in user space 56 62 error = vmm_v2p_translate( false , attr , &paddr ); … … 58 64 if ( error ) 59 65 { 60 printk("\n[ERROR] in %s : arguments not in used space = %x\n", 61 __FUNCTION__ , (intptr_t)attr ); 66 67 #if CONFIG_DEBUG_SYSCALLS_ERROR 68 printk("\n[ERROR] in %s : arguments not in used space = %x\n", __FUNCTION__ , (intptr_t)attr ); 69 #endif 62 70 this->errno = EINVAL; 63 71 return -1; … … 82 90 if( map_fixed ) 83 91 { 84 printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ ); 92 93 #if CONFIG_DEBUG_SYSCALLS_ERROR 94 printk("\n[ERROR] in %s : MAP_FIXED not supported\n", __FUNCTION__ ); 95 #endif 85 96 this->errno = EINVAL; 86 97 return -1; … … 89 100 if( map_shared == map_private ) 90 101 { 91 printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ ); 102 103 #if CONFIG_DEBUG_SYSCALLS_ERROR 104 printk("\n[ERROR] in %s : MAP_SHARED xor MAP_PRIVATE\n", __FUNCTION__ ); 105 #endif 92 106 this->errno = EINVAL; 93 107 return -1; … … 108 122 if( fdid >= CONFIG_PROCESS_FILE_MAX_NR ) 109 123 { 110 printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid ); 124 125 #if CONFIG_DEBUG_SYSCALLS_ERROR 126 printk("\n[ERROR] in %s: bad file descriptor = %d\n", __FUNCTION__ , fdid ); 127 #endif 111 128 this->errno = EBADFD; 112 129 return -1; … … 118 135 if( file_xp == XPTR_NULL ) 119 136 { 120 printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid ); 137 138 #if CONFIG_DEBUG_SYSCALLS_ERROR 139 printk("\n[ERROR] in %s: file %d not found\n", __FUNCTION__ , fdid ); 140 #endif 121 141 this->errno = EBADFD; 122 142 return -1; … … 138 158 if( (offset + length) > size) 139 159 { 140 printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n", 141 __FUNCTION__, k_attr.offset, k_attr.length, size ); 160 161 #if CONFIG_DEBUG_SYSCALLS_ERROR 162 printk("\n[ERROR] in %s: offset (%d) + len (%d) >= file's size (%d)\n", 163 __FUNCTION__, k_attr.offset, k_attr.length, size ); 164 #endif 142 165 this->errno = ERANGE; 143 166 return -1; … … 148 171 (prot_write && !(file_attr & FD_ATTR_WRITE_ENABLE)) ) 149 172 { 150 printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n", 151 __FUNCTION__ , k_attr.prot , file_attr ); 173 174 #if CONFIG_DEBUG_SYSCALLS_ERROR 175 printk("\n[ERROR] in %s: prot = %x / file_attr = %x)\n", 176 __FUNCTION__ , k_attr.prot , file_attr ); 177 #endif 152 178 this->errno = EACCES; 153 179 return -1; … … 178 204 if( cluster_is_undefined( vseg_cxy ) ) 179 205 { 180 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ ); 206 207 #if CONFIG_DEBUG_SYSCALLS_ERROR 208 printk("\n[ERROR] in %s : illegal cxy for MAP_REMOTE\n", __FUNCTION__ ); 209 #endif 181 210 this->errno = EINVAL; 182 211 return -1; … … 184 213 } 185 214 } 215 216 // enable IRQs 217 hal_enable_irq( &save_sr ); 186 218 187 219 // get reference process cluster and local pointer … … 216 248 } 217 249 250 // restore IRQs 251 hal_restore_irq( save_sr ); 252 218 253 if( vseg == NULL ) 219 254 { 220 printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ ); 255 256 #if CONFIG_DEBUG_SYSCALLS_ERROR 257 printk("\n[ERROR] in %s : cannot create vseg\n", __FUNCTION__ ); 258 #endif 221 259 this->errno = ENOMEM; 222 260 return -1; … … 226 264 hal_copy_to_uspace( &attr->addr , &vseg->min , sizeof(intptr_t) ); 227 265 228 tm_end = hal_get_cycles(); 229 230 syscall_dmsg("\n[DBG] %s : core[%x,%d] created vseg %s in cluster %x / cycle %d\n" 231 " base = %x / length = %x / cost = %d\n", 232 __FUNCTION__, local_cxy , this->core->lid , vseg_type_str(vseg->type) , 233 vseg->cxy , (uint32_t)tm_start , vseg->min , length , (uint32_t)(tm_end - tm_start) ); 266 hal_fence(); 267 268 #if CONFIG_DEBUG_SYS_MMAP 269 tm_end = hal_get_cycles(); 270 if ( CONFIG_DEBUG_SYS_MMAP < tm_start ) 271 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n" 272 "vseg %s / cluster %x / base %x / size %x / cost %d\n", 273 __FUNCTION__, this, process->pid, (uint32_t)tm_end, 274 vseg_type_str(vseg->type), vseg->cxy, vseg->min, length, (uint32_t)(tm_end - tm_start) ); 275 #endif 234 276 235 277 return 0; -
trunk/kernel/syscalls/sys_read.c
r433 r435 36 36 // TODO: concurrent user page(s) munmap need to be handled [AG] 37 37 38 // TODO : remove these debug variables39 38 extern uint32_t enter_sys_read; 40 39 extern uint32_t enter_devfs_move; … … 64 63 reg_t save_sr; // required to enable IRQs during syscall 65 64 66 #if CONFIG_READ_DEBUG65 #if (CONFIG_DEBUG_SYS_READ & 1) 67 66 enter_sys_read = (uint32_t)tm_start; 68 67 #endif … … 76 75 tm_start = hal_get_cycles(); 77 76 if( CONFIG_DEBUG_SYS_READ < tm_start ) 78 printk("\n[DBG] %s : thread % denter / process %x / vaddr = %x / count %d / cycle %d\n",77 printk("\n[DBG] %s : thread %x enter / process %x / vaddr = %x / count %d / cycle %d\n", 79 78 __FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start ); 80 79 #endif … … 83 82 if( file_id >= CONFIG_PROCESS_FILE_MAX_NR ) 84 83 { 85 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", 86 __FUNCTION__ , file_id ); 84 85 #if CONFIG_DEBUG_SYSCALLS_ERROR 86 printk("\n[ERROR] in %s : illegal file descriptor index = %d\n", __FUNCTION__ , file_id ); 87 #endif 87 88 this->errno = EBADFD; 88 89 return -1; … … 94 95 if ( error ) 95 96 { 96 printk("\n[ERROR] in %s : user buffer unmapped = %x\n", 97 __FUNCTION__ , (intptr_t)vaddr ); 97 98 #if CONFIG_DEBUG_SYSCALLS_ERROR 99 printk("\n[ERROR] in %s : user buffer unmapped = %x\n", 100 __FUNCTION__ , (intptr_t)vaddr ); 101 #endif 98 102 this->errno = EINVAL; 99 103 return -1; … … 108 112 if( file_xp == XPTR_NULL ) 109 113 { 110 printk("\n[ERROR] in %s : undefined file descriptor index = %d in process %x\n", 111 __FUNCTION__ , file_id , process->pid ); 114 115 #if CONFIG_DEBUG_SYSCALLS_ERROR 116 printk("\n[ERROR] in %s : undefined fd_id %d in process %x\n", 117 __FUNCTION__ , file_id , process->pid ); 118 #endif 112 119 this->errno = EBADFD; 113 120 return -1; … … 122 129 if( (attr & FD_ATTR_READ_ENABLE) == 0 ) 123 130 { 124 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 125 __FUNCTION__ , file_id , process->pid ); 131 132 #if CONFIG_DEBUG_SYSCALLS_ERROR 133 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 134 __FUNCTION__ , file_id , process->pid ); 135 #endif 126 136 this->errno = EBADFD; 127 137 return -1; … … 138 148 if( (attr & FD_ATTR_READ_ENABLE) == 0 ) 139 149 { 140 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 141 __FUNCTION__ , file_id , process->pid ); 150 151 #if CONFIG_DEBUG_SYSCALLS_ERROR 152 printk("\n[ERROR] in %s : file %d not readable in process %x\n", 153 __FUNCTION__ , file_id , process->pid ); 154 #endif 142 155 this->errno = EBADFD; 143 156 return -1; … … 166 179 if( XPTR( local_cxy , process ) != owner_xp ) 167 180 { 168 printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n", 169 __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) ); 181 182 #if CONFIG_DEBUG_SYSCALLS_ERROR 183 printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n", 184 __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) ); 185 #endif 170 186 this->errno = EBADFD; 171 187 return -1; … … 180 196 if( nbytes != count ) 181 197 { 182 printk("\n[ERROR] in %s cannot read data from file %d in process %x\n", 183 __FUNCTION__ , file_id , process->pid ); 198 199 #if CONFIG_DEBUG_SYSCALLS_ERROR 200 printk("\n[ERROR] in %s cannot read data from file %d in process %x\n", 201 __FUNCTION__ , file_id , process->pid ); 202 #endif 184 203 this->errno = error; 185 204 return -1; … … 194 213 tm_end = hal_get_cycles(); 195 214 if( CONFIG_DEBUG_SYS_READ < tm_end ) 196 printk("\n[DBG] %s : thread %x / process %x / cycle %d\n"215 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n" 197 216 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n", 198 217 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid , … … 201 220 #endif 202 221 203 #if (CONFIG_ READ_DEBUG & 0x1)222 #if (CONFIG_DEBUG_SYS_READ & 1) 204 223 exit_sys_read = (uint32_t)tm_end; 205 224 206 225 printk("\n@@@@@@@@@@@@ timing to read character %c\n" 207 " - enter_sys_read = %d / delta %d\n"208 " - enter_devfs_ move= %d / delta %d\n"209 " - enter_txt_read = %d / delta %d\n"210 " - enter_chdev_cmd = %d / delta %d\n"211 " - enter_chdev_server = %d / delta %d\n"212 " - enter_tty_cmd = %d / delta %d\n"213 " - enter_tty_isr = %d / delta %d\n"214 " - exit_tty_isr = %d / delta %d\n"215 " - exit_tty_cmd = %d / delta %d\n"216 " - exit_chdev_server = %d / delta %d\n"217 " - exit_chdev_cmd = %d / delta %d\n"218 " - exit_txt_read = %d / delta %d\n"219 " - exit_devfs_ move= %d / delta %d\n"220 " - exit_sys_read = %d / delta %d\n",226 " - enter_sys_read = %d / delta %d\n" 227 " - enter_devfs_read = %d / delta %d\n" 228 " - enter_txt_read = %d / delta %d\n" 229 " - enter_chdev_cmd_read = %d / delta %d\n" 230 " - enter_chdev_server_read = %d / delta %d\n" 231 " - enter_tty_cmd_read = %d / delta %d\n" 232 " - enter_tty_isr_read = %d / delta %d\n" 233 " - exit_tty_isr_read = %d / delta %d\n" 234 " - exit_tty_cmd_read = %d / delta %d\n" 235 " - exit_chdev_server_read = %d / delta %d\n" 236 " - exit_chdev_cmd_read = %d / delta %d\n" 237 " - exit_txt_read = %d / delta %d\n" 238 " - exit_devfs_read = %d / delta %d\n" 239 " - exit_sys_read = %d / delta %d\n", 221 240 *((char *)(intptr_t)paddr) , 222 enter_sys_read , 0 ,223 enter_devfs_ move , enter_devfs_move - enter_sys_read,224 enter_txt_read , enter_txt_read - enter_devfs_move,225 enter_chdev_cmd , enter_chdev_cmd - enter_txt_read,226 enter_chdev_server , enter_chdev_server - enter_chdev_cmd ,227 enter_tty_cmd , enter_tty_cmd - enter_chdev_server,228 enter_tty_isr , enter_tty_isr - enter_tty_cmd ,229 exit_tty_isr , exit_tty_isr - enter_tty_isr,230 exit_tty_cmd , exit_tty_cmd - exit_tty_isr,231 exit_chdev_server , exit_chdev_server - exit_tty_cmd ,232 exit_chdev_cmd , exit_chdev_cmd - exit_chdev_server,233 exit_txt_read , exit_txt_read - exit_chdev_cmd ,234 exit_devfs_ move , exit_devfs_move - exit_txt_read,235 exit_sys_read , exit_sys_read - exit_devfs_move);241 enter_sys_read , 0 , 242 enter_devfs_read , enter_devfs_read - enter_sys_read , 243 enter_txt_read , enter_txt_read - enter_devfs_read , 244 enter_chdev_cmd_read , enter_chdev_cmd_read - enter_txt_read , 245 enter_chdev_server_read , enter_chdev_server_read - enter_chdev_cmd_read , 246 enter_tty_cmd_read , enter_tty_cmd_read - enter_chdev_server_read , 247 enter_tty_isr_read , enter_tty_isr_read - enter_tty_cmd_read , 248 exit_tty_isr_read , exit_tty_isr_read - enter_tty_isr_read , 249 exit_tty_cmd_read , exit_tty_cmd_read - exit_tty_isr_read , 250 exit_chdev_server_read , exit_chdev_server_read - exit_tty_cmd_read , 251 exit_chdev_cmd_read , exit_chdev_cmd_read - exit_chdev_server_read , 252 exit_txt_read , exit_txt_read - exit_chdev_cmd_read , 253 exit_devfs_read , exit_devfs_read - exit_txt_read , 254 exit_sys_read , exit_sys_read - exit_devfs_read ); 236 255 #endif 237 256 -
trunk/kernel/syscalls/sys_signal.c
r409 r435 27 27 #include <thread.h> 28 28 #include <printk.h> 29 #include <signal.h>30 29 31 30 ////////////////////////////////// -
trunk/kernel/syscalls/sys_wait.c
r433 r435 24 24 #include <hal_types.h> 25 25 #include <hal_uspace.h> 26 #include <hal_irqmask.h> 26 27 #include <core.h> 27 28 #include <thread.h> … … 42 43 int child_state; 43 44 thread_t * child_thread; 45 reg_t save_sr; 44 46 45 47 thread_t * this = CURRENT_THREAD; … … 61 63 if( error ) 62 64 { 63 printk("\n[ERROR] in %s : status buffer unmapped for thread %x in process %x\n", 64 __FUNCTION__ , this->trdid , process->pid ); 65 66 #if CONFIG_DEBUG_SYSCALLS_ERROR 67 printk("\n[ERROR] in %s : status buffer unmapped for thread %x in process %x\n", 68 __FUNCTION__ , this->trdid , process->pid ); 69 #endif 65 70 this->errno = EFAULT; 66 71 return -1; … … 85 90 while( 1 ) 86 91 { 92 // enable IRQS 93 hal_enable_irq( &save_sr ); 94 87 95 // get lock protecting children list 88 96 remote_spinlock_lock( children_lock_xp ); … … 101 109 // test if child process is terminated, 102 110 // but termination not yet reported to parent process 103 if( ((child_state & PROCESS_ FLAG_EXIT)||104 (child_state & PROCESS_ FLAG_KILL)||105 (child_state & PROCESS_ FLAG_BLOCK)) &&106 ((child_state & PROCESS_ FLAG_WAIT) == 0) )111 if( ((child_state & PROCESS_TERM_EXIT) || 112 (child_state & PROCESS_TERM_KILL) || 113 (child_state & PROCESS_TERM_STOP)) && 114 ((child_state & PROCESS_TERM_WAIT) == 0) ) 107 115 { 108 116 // get pointer on main thread and PID from child owner process … … 112 120 // set the PROCESS_FLAG_WAIT in owner child descriptor 113 121 hal_remote_atomic_or( XPTR( child_cxy , &child_ptr->term_state ), 114 PROCESS_ FLAG_WAIT );122 PROCESS_TERM_WAIT ); 115 123 116 124 // set the THREAD_FLAG_REQ_DELETE in child main thread … … 118 126 THREAD_FLAG_REQ_DELETE ); 119 127 128 // release lock protecting children list 129 remote_spinlock_unlock( children_lock_xp ); 130 120 131 #if CONFIG_DEBUG_SYS_WAIT 121 132 tm_end = hal_get_cycles(); 122 133 if( CONFIG_DEBUG_SYS_WAIT < tm_end ) 123 printk("\n[DBG] %s : thread %x exit / p rocess%x / cycle %d\n",124 __FUNCTION__, this, process->pid, (uint32_t)tm_end );134 printk("\n[DBG] %s : thread %x exit / parent %x / child %x / cycle %d\n", 135 __FUNCTION__, this, process->pid, child_pid, (uint32_t)tm_end ); 125 136 #endif 126 127 137 // return relevant info to calling parent process 128 138 hal_copy_to_uspace( status , &child_state , sizeof(int) ); … … 131 141 } 132 142 133 // release lock 143 // release lock protecting children list 134 144 remote_spinlock_unlock( children_lock_xp ); 135 145 136 146 // deschedule without blocking 137 147 sched_yield( "parent wait children termination" ); 138 } 148 149 } // end while 139 150 140 151 // never executed -
trunk/kernel/syscalls/sys_write.c
r433 r435 41 41 { 42 42 error_t error; 43 paddr_t paddr; // unused, butrequired for user space checking43 paddr_t paddr; // required for user space checking 44 44 xptr_t file_xp; // remote file extended pointer 45 45 uint32_t nbytes; // number of bytes actually written 46 46 reg_t save_sr; // required to enable IRQs during syscall 47 48 #if (CONFIG_DEBUG_SYS_WRITE_DEBUG & 1) 49 enter_sys_read = (uint32_t)tm_start; 50 #endif 47 51 48 52 thread_t * this = CURRENT_THREAD; … … 54 58 tm_start = hal_get_cycles(); 55 59 if( CONFIG_DEBUG_SYS_WRITE < tm_start ) 56 printk("\n[DBG] %s : thread %x / process %x / vaddr %x / count %d / cycle %d\n",60 printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / count %d / cycle %d\n", 57 61 __FUNCTION__, this, process->pid, vaddr, count, (uint32_t)tm_start ); 58 62 #endif … … 162 166 tm_end = hal_get_cycles(); 163 167 if( CONFIG_DEBUG_SYS_WRITE < tm_end ) 164 printk("\n[DBG] %s : thread %x inprocess %x / cycle %d\n"168 printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n" 165 169 "nbytes = %d / first byte = %c / file_id = %d / cost = %d\n", 166 170 __FUNCTION__, this, process->pid, (uint32_t)tm_start, … … 168 172 #endif 169 173 174 #if (CONFIG_DEBUG_SYS_WRITE & 1) 175 exit_sys_write = (uint32_t)tm_end; 176 177 printk("\n@@@@@@@@@@@@ timing to write string %c\n" 178 " - enter_sys_write = %d / delta %d\n" 179 " - enter_devfs_write = %d / delta %d\n" 180 " - enter_txt_write = %d / delta %d\n" 181 " - enter_chdev_cmd_write = %d / delta %d\n" 182 " - enter_chdev_server_write = %d / delta %d\n" 183 " - enter_tty_cmd_write = %d / delta %d\n" 184 " - enter_tty_isr_write = %d / delta %d\n" 185 " - exit_tty_isr_write = %d / delta %d\n" 186 " - exit_tty_cmd_write = %d / delta %d\n" 187 " - exit_chdev_server_write = %d / delta %d\n" 188 " - exit_chdev_cmd_write = %d / delta %d\n" 189 " - exit_txt_write = %d / delta %d\n" 190 " - exit_devfs_write = %d / delta %d\n" 191 " - exit_sys_write = %d / delta %d\n", 192 *((char *)(intptr_t)paddr) , 193 enter_sys_write , 0 , 194 enter_devfs_write , enter_devfs_write - enter_sys_write , 195 enter_txt_write , enter_txt_write - enter_devfs_write , 196 enter_chdev_cmd_write , enter_chdev_cmd_write - enter_txt_write , 197 enter_chdev_server_write , enter_chdev_server_write - enter_chdev_cmd_write , 198 enter_tty_cmd_write , enter_tty_cmd_write - enter_chdev_server_write , 199 enter_tty_isr_write , enter_tty_isr_write - enter_tty_cmd_write , 200 exit_tty_isr_write , exit_tty_isr_write - enter_tty_isr_write , 201 exit_tty_cmd_write , exit_tty_cmd_write - exit_tty_isr_write , 202 exit_chdev_server_write , exit_chdev_server_write - exit_tty_cmd_write , 203 exit_chdev_cmd_write , exit_chdev_cmd_write - exit_chdev_server_write , 204 exit_txt_write , exit_txt_write - exit_chdev_cmd_write , 205 exit_devfs_write , exit_devfs_write - exit_txt_write , 206 exit_sys_write , exit_sys_write - exit_devfs_write ); 207 #endif 208 170 209 return nbytes; 171 210 -
trunk/kernel/syscalls/syscalls.h
r433 r435 508 508 * The following macros can be used to extract information from status: 509 509 * - WIFEXITED(status) : is true if the child process terminated with an exit(). 510 * - WIFSIGNALED(status) : is true if the child process terminated by a signal.510 * - WIFSIGNALED(status) : is true if the child process killed by a signal. 511 511 * - WIFSTOPPED(status) : is true if the child process is stopped by a signal. 512 512 * - WEXITSTATUS(status) : returns the low-order 8 bits of the exit() argument. … … 558 558 * [43] This debug function displays on the kernel terminal TXT0 an user defined string, 559 559 * or the current state of a kernel structure, identified by the <type> argument. 560 * The <arg0> and <arg1> arguments depends on the structure type. It can be: 561 * - VMM : VSL and GPT for a process identified by <pid>. 562 * - SCHED : all threads allocated to a scheduler identified by <cxy> & <lid>. 563 * - PROCESS : all processes registered in a cluster identified by <cxy>. 564 * - VFS : all files registered in the VFS cache. 565 * - CHDEV : all registered channel devices. 566 ****************************************************************************************** 567 * type : [in] STRING / VMM / SCHED / PROCESS / VSEG / VFS 560 * The <arg0> and <arg1> arguments depends on the structure type: 561 * - DISPLAY_STRING : an user defined string 562 * - DISPLAY_VMM : VSL and GPT for a process identified by <pid>. 563 * - DISPLAY_SCHED : all threads allocated to a scheduler <cxy> & <lid>. 564 * - DISPLAY_CLUSTER_PROCESS : all processes registered in a cluster identified by <cxy>. 565 * - DISPLAY_TXT_PROCESS : all processes registered in a cluster identified by <cxy>. 566 * - DISPLAY_VFS : all files registered in the VFS cache. 567 * - DISPLAY_CHDEV : all registered channel devices. 568 ****************************************************************************************** 569 * type : [in] type of display 568 570 * arg0 : [in] type dependant argument. 569 571 * arg1 : [in] type dependant argument. -
trunk/kernel_config.h
r434 r435 31 31 //////////////////////////////////////////////////////////////////////////////////////////// 32 32 // KERNEL DEBUG 33 //34 33 // Each debug variable control one kernel function, or one small group of functions. 35 34 // - trace is generated only when cycle > debug_value. … … 37 36 //////////////////////////////////////////////////////////////////////////////////////////// 38 37 39 #define CONFIG_FATFS_DEBUG 0 40 #define CONFIG_FBF_DEBUG 0 41 #define CONFIG_GRPC_DEBUG 0 42 #define CONFIG_IOC_DEBUG 0 43 #define CONFIG_IRQ_DEBUG 0 44 #define CONFIG_KHM_DEBUG 0 45 #define CONFIG_KMEM_DEBUG 0 46 #define CONFIG_MMAP_DEBUG 0 47 #define CONFIG_MMC_DEBUG 0 48 #define CONFIG_MAPPER_DEBUG 0 49 #define CONFIG_NIC_DEBUG 0 50 #define CONFIG_PIC_DEBUG 0 51 #define CONFIG_READ_DEBUG 0 52 53 54 #define CONFIG_DEBUG_CHDEV_REGISTER_COMMAND 3000000 55 #define CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER 3000000 38 39 40 #define CONFIG_DEBUG_CHDEV_REGISTER_COMMAND 0 41 #define CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER 0 56 42 57 43 #define CONFIG_DEBUG_CLUSTER_INIT 0 58 44 59 #define CONFIG_DEBUG_DEV_TXT 3000000 45 #define CONFIG_DEBUG_DEV_TXT 0 46 #define CONFIG_DEBUG_DEV_IOC 0 47 #define CONFIG_DEBUG_DEV_NIC 0 48 #define CONFIG_DEBUG_DEV_FBF 0 49 #define CONFIG_DEBUG_DEV_MMC 0 60 50 61 51 #define CONFIG_DEBUG_DEVFS_INIT 0 62 #define CONFIG_DEBUG_DEVFS_MOVE 3000000 52 #define CONFIG_DEBUG_DEVFS_MOVE 0 53 54 #define CONFIG_DEBUG_FATFS_INIT 0 55 #define CONFIG_DEBUG_FATFS_MOVE 0 56 #define CONFIG_DEBUG_FATFS_LOAD 0 63 57 64 58 #define CONFIG_DEBUG_GPT_ACCESS 0 65 59 66 60 #define CONFIG_DEBUG_HAL_KENTRY 0 67 #define CONFIG_DEBUG_HAL_TXT 300000061 #define CONFIG_DEBUG_HAL_TXT 0 68 62 #define CONFIG_DEBUG_HAL_EXCEPTIONS 0 69 70 #define CONFIG_DEBUG_KCM_ALLOC 0 63 #define CONFIG_DEBUG_HAL_IRQS 0 64 65 #define CONFIG_DEBUG_KCM 0 66 #define CONFIG_DEBUG_KMEM 0 71 67 72 68 #define CONFIG_DEBUG_KERNEL_INIT 0 … … 74 70 75 71 #define CONFIG_DEBUG_LOCKS 0 72 73 #define CONFIG_DEBUG_MAPPER_GET_PAGE 0 74 #define CONFIG_DEBUG_MAPPER_MOVE_USER 0 75 #define CONFIG_DEBUG_MAPPER_MOVE_KERNEL 0 76 76 77 77 #define CONFIG_DEBUG_PPM_ALLOC_PAGES 0 … … 83 83 #define CONFIG_DEBUG_PROCESS_MAKE_EXEC 0 84 84 #define CONFIG_DEBUG_PROCESS_MAKE_FORK 0 85 #define CONFIG_DEBUG_PROCESS_MAKE_KILL 086 85 #define CONFIG_DEBUG_PROCESS_REFERENCE_INIT 0 87 86 #define CONFIG_DEBUG_PROCESS_SIGACTION 0 88 #define CONFIG_DEBUG_PROCESS_ATTACH 0 89 #define CONFIG_DEBUG_PROCESS_DETACH 0 87 #define CONFIG_DEBUG_PROCESS_TXT_ATTACH 2 90 88 #define CONFIG_DEBUG_PROCESS_ZERO_CREATE 0 91 89 … … 94 92 95 93 #define CONFIG_DEBUG_SCHED_HANDLE_SIGNALS 0 96 #define CONFIG_DEBUG_SCHED_YIELD 500000197 98 #define CONFIG_DEBUG_SYSCALLS_ERROR 094 #define CONFIG_DEBUG_SCHED_YIELD 0 95 96 #define CONFIG_DEBUG_SYSCALLS_ERROR 2 99 97 100 98 #define CONFIG_DEBUG_SYS_DISPLAY 0 101 #define CONFIG_DEBUG_SYS_EXEC 3000000 102 #define CONFIG_DEBUG_SYS_EXIT 3000000 103 #define CONFIG_DEBUG_SYS_FORK 3000000 104 #define CONFIG_DEBUG_SYS_KILL 3000000 105 #define CONFIG_DEBUG_SYS_READ 3000000 106 #define CONFIG_DEBUG_SYS_WAIT 3000000 107 #define CONFIG_DEBUG_SYS_WRITE 3000000 99 #define CONFIG_DEBUG_SYS_EXEC 2 100 #define CONFIG_DEBUG_SYS_EXIT 0 101 #define CONFIG_DEBUG_SYS_FORK 2 102 #define CONFIG_DEBUG_SYS_GET_CONFIG 2 103 #define CONFIG_DEBUG_SYS_KILL 2 104 #define CONFIG_DEBUG_SYS_MMAP 0 105 #define CONFIG_DEBUG_SYS_READ 0 106 #define CONFIG_DEBUG_SYS_WAIT 2 107 #define CONFIG_DEBUG_SYS_WRITE 0 108 108 109 109 #define CONFIG_DEBUG_THREAD_DESTROY 0 -
trunk/libs/stdio.c
r426 r435 292 292 ///////////// Non standard system calls //////////////////////////////////// 293 293 294 294 295 ////////////////////////// 295 296 int fg( unsigned int pid ) … … 345 346 } 346 347 347 /////////////////////////////////////// 348 int display_ process( unsigned int cxy )349 { 350 return hal_user_syscall( SYS_DISPLAY, 351 DISPLAY_ PROCESS,348 ///////////////////////////////////////////////// 349 int display_cluster_processes( unsigned int cxy ) 350 { 351 return hal_user_syscall( SYS_DISPLAY, 352 DISPLAY_CLUSTER_PROCESSES, 352 353 (reg_t)cxy, 0, 0 ); 353 354 } … … 365 366 return hal_user_syscall( SYS_DISPLAY, 366 367 DISPLAY_VFS, 0, 0, 0 ); 368 } 369 370 //////////////////////////////////////////////// 371 int display_txt_processes( unsigned int txt_id ) 372 { 373 return hal_user_syscall( SYS_DISPLAY, 374 DISPLAY_TXT_PROCESSES, 375 (reg_t)txt_id, 0, 0 ); 367 376 } 368 377 -
trunk/libs/stdio.h
r434 r435 347 347 int wait( int * status ); 348 348 349 349 350 /****************** Non standard (ALMOS_MKH specific) system calls **********************/ 350 351 … … 429 430 * @ return 0 if success / return -1 if illegal argument. 430 431 **************************************************************************************/ 431 int display_ process( unsigned int cxy );432 int display_cluster_processes( unsigned int cxy ); 432 433 433 434 /*************************************************************************************** … … 448 449 **************************************************************************************/ 449 450 int display_vfs(); 451 452 /*************************************************************************************** 453 * This debug function displays on the kernel terminal TXT0 454 * the list of processes attached to a given TXT channel. 455 * It can be called by any thread running in any cluster. 456 *************************************************************************************** 457 * @ return always 0. 458 **************************************************************************************/ 459 int display_txt_processes( unsigned int txt_id ); 450 460 451 461 /***************************************************************************************** -
trunk/params.mk
r434 r435 5 5 Y_SIZE = 1 6 6 NB_PROCS = 1 7 NB_TTYS = 27 NB_TTYS = 3 8 8 FBF_WIDTH = 128 9 9 IOC_TYPE = IOC_BDV -
trunk/user/init/init.c
r434 r435 38 38 for( i = 1 ; i < NB_TXT_CHANNELS ; i++ ) 39 39 { 40 41 snprintf( string , 64 , "@@@ before fork / iter = %d\n" , i );42 display_string( string );43 44 40 // INIT process fork process CHILD[i] 45 41 ret_fork = fork(); 46 47 snprintf( string , 64 , "@@@ after fork / iter = %d / ret_fork = %d\n" , i , ret_fork );48 display_string( string );49 42 50 43 if( ret_fork< 0 ) // error in fork 51 44 { 52 45 // INIT display error message on TXT0 terminal 53 snprintf( string , 64 , "init cannot fork child[%d]\n" , i ); 46 snprintf( string , 64 , 47 "INIT cannot fork child[%d]\n" , i ); 54 48 display_string( string ); 55 49 … … 65 59 { 66 60 // display error message on TXT0 terminal 67 snprintf( string , 64 , "child[%d] cannot exec ksh[%d]\n" , i , i ); 61 snprintf( string , 64 , 62 "CHILD[%d] cannot exec KSH[%d] / ret_exec = %d\n" , i , i , ret_exec ); 68 63 display_string( string ); 69 70 // CHILD[i] exit71 // exit( 0 );72 64 } 73 65 } … … 75 67 { 76 68 // INIT display CHILD[i] process PID 77 snprintf( string , 64 , "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork ); 69 snprintf( string , 64 , 70 "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork ); 78 71 display_string( string ); 79 80 // INIT delay81 int x;82 for( x=0 ; x<DELAY_BETWEEN_FORK ; x++) asm volatile ("nop");83 84 /*85 // INIT wait exec completion by CHILD[i]86 while( 1 )87 {88 // get terminating process PID89 received_pid = wait( &status );90 91 if( received_pid == ret_fork ) break;92 else93 {94 snprintf( string , 64 ,95 "expected_pid %d / received_pid %d" , ret_fork , received_pid );96 display_string( string );97 }98 }99 100 */101 // INIT display string on kernel TXT0102 snprintf( string , 64 , "INIT created KSH[%d]\n", i );103 display_string( string );104 // @@@105 display_process( 0 );106 display_sched( 0 , 0 );107 // @@@108 72 } 109 73 110 74 } 111 75 112 // This blocking loop is only for debug, because KSH[i] processes113 // should never be killed, and INIT should never return from the wait() function.76 // This loop detects the termination of the KSH[i] processes, 77 // to recreate these process when required. 114 78 while( 1 ) 115 79 { 116 // block on child process termination117 received_pid = wait( &status ); 80 // block on child processes termination 81 received_pid = wait( &status ); 118 82 119 // display string to report unexpected KSH process termination 120 snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid ); 121 display_string( string ); 83 if( WIFSTOPPED( status ) ) // stopped => unblock it 84 { 85 // display string to report unexpected KSH process block 86 snprintf( string , 64 , "KSH process %x unexpectedly stopped" , received_pid ); 87 display_string( string ); 88 89 } 90 91 if( WIFSIGNALED( status ) || WIFEXITED( status ) ) // killed => recreate it 92 { 93 // display string to report unexpected KSH process termination 94 snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid ); 95 display_string( string ); 96 } 122 97 } 123 98 -
trunk/user/ksh/ksh.c
r434 r435 484 484 unsigned int lid; 485 485 unsigned int pid; 486 unsigned int txt_id; 486 487 487 488 if( strcmp( argv[1] , "vmm" ) == 0 ) … … 526 527 cxy = atoi(argv[2]); 527 528 528 if( display_ process( cxy ) )529 if( display_cluster_processes( cxy ) ) 529 530 { 530 531 printf(" error: illegal argument cxy = %x\n", cxy ); 531 532 } 532 533 } 534 else if( strcmp( argv[1] , "txt" ) == 0 ) 535 { 536 if( argc != 3 ) 537 { 538 printf(" usage: display txt txt_id\n"); 539 return; 540 } 541 542 txt_id = atoi(argv[2]); 543 544 if( display_txt_processes( txt_id ) ) 545 { 546 printf(" error: illegal argument txt_id = %x\n", txt_id ); 547 } 548 } 533 549 else if( strcmp( argv[1] , "vfs" ) == 0 ) 534 550 { … … 553 569 else 554 570 { 555 printf(" usage display (vmm/sched/process/vfs/chdev) [cxy] [lid]\n");571 printf(" usage: display (vmm/sched/process/vfs/chdev/txt) [arg2] [arg3]\n"); 556 572 } 557 573 } … … 563 579 ksh_cmd_t cmd[] = 564 580 { 565 { "cat", "display file content", cmd_cat },566 { "cd", "change current directory", cmd_cd },567 { "cp", "replicate a file in file system", cmd_cp },568 { "fg", "put a process in foreground", cmd_fg },569 { "display", "display vmm/sched/process/vfs/chdev ",cmd_display },570 { "load", "load an user application", cmd_load },571 { "help", "list available commands", cmd_help },572 { "kill", "kill an application (all threads)", cmd_kill },573 { "log", "list registered commands", cmd_log },574 { "ls", "list directory entries", cmd_ls },575 { "mkdir", "create a new directory", cmd_mkdir },576 { "mv", "move a file in file system", cmd_mv },577 { "pwd", "print current working directory", cmd_pwd },578 { "rm", "remove a file from file system", cmd_rm },579 { "rmdir", "remove a directory from file system", cmd_rmdir },580 { NULL, NULL, NULL}581 { "cat", "display file content", cmd_cat }, 582 { "cd", "change current directory", cmd_cd }, 583 { "cp", "replicate a file in file system", cmd_cp }, 584 { "fg", "put a process in foreground", cmd_fg }, 585 { "display", "display vmm/sched/process/vfs/chdev/txt", cmd_display }, 586 { "load", "load an user application", cmd_load }, 587 { "help", "list available commands", cmd_help }, 588 { "kill", "kill an application (all threads)", cmd_kill }, 589 { "log", "list registered commands", cmd_log }, 590 { "ls", "list directory entries", cmd_ls }, 591 { "mkdir", "create a new directory", cmd_mkdir }, 592 { "mv", "move a file in file system", cmd_mv }, 593 { "pwd", "print current working directory", cmd_pwd }, 594 { "rm", "remove a file from file system", cmd_rm }, 595 { "rmdir", "remove a directory from file system", cmd_rmdir }, 596 { NULL, NULL, NULL } 581 597 }; 582 598 -
trunk/user/sort/sort.c
r434 r435 265 265 266 266 get_cycle( &cycle ); 267 printf("\n[SORT] completes barrier init at cycle %d\n", (unsigned int)cycle ); 267 printf("\n[SORT] completes barrier init at cycle %d continue ?\n", (unsigned int)cycle ); 268 getchar(); 268 269 269 270 // Array to sort initialization
Note: See TracChangeset
for help on using the changeset viewer.