Changeset 491 for trunk/kernel
- Timestamp:
- Aug 22, 2018, 11:55:11 PM (6 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/printk.c
r469 r491 386 386 387 387 //////////////////////////////////// 388 void assert( bool_t condition, 389 const char * function_name, 390 char * format, ... ) 391 { 392 va_list args; 393 uint32_t save_sr; 394 395 if( condition == false ) 388 void __panic( const char * file_name, 389 const char * function_name, 390 uint32_t line, 391 cycle_t cycle, 392 char * format, 393 ... ) 394 { 395 // get pointers on TXT0 chdev 396 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 397 cxy_t txt0_cxy = GET_CXY(txt0_xp); 398 chdev_t * txt0_ptr = GET_PTR(txt0_xp); 399 400 // get extended pointer on remote TXT0 lock 401 xptr_t lock_txt0_xp = XPTR(txt0_cxy, &txt0_ptr->wait_lock); 402 403 // get TXT0 lock in busy waiting mode 396 404 { 397 // get pointers on TXT0 chdev 398 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 399 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 400 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); 401 402 // get extended pointer on remote TXT0 lock 403 xptr_t lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 404 405 // get TXT0 lock in busy waiting mode 406 remote_spinlock_lock_busy( lock_xp , &save_sr ); 407 408 // call nolock_printk to print core, function_name, and cycle 409 nolock_printk("\n[PANIC] in %s => core[%x,%d] blocked at cycle %d : " , 410 function_name, local_cxy, CURRENT_THREAD->core->lid, (uint32_t)hal_get_cycles() ); 405 uint32_t save_sr; 406 remote_spinlock_lock_busy(lock_txt0_xp, &save_sr); 407 408 thread_t *current = CURRENT_THREAD; 409 nolock_printk( 410 "\n[PANIC] in %s: line %d | funct %s | cycle %d\n" 411 "core[%x,%d] | thread %x in process %x\n" 412 " | thread_ptr %x | procress_ptr %x\n", 413 file_name, line, function_name, (uint32_t) cycle, 414 local_cxy, current->core->lid, current->trdid, current->process->pid, 415 current, current->process); 411 416 412 417 // call kernel_printf on TXT0, in busy waiting to print format 413 va_start( args , format ); 414 kernel_printf( format , &args ); 415 va_end( args ); 418 va_list args; 419 va_start(args, format); 420 kernel_printf(format, &args); 421 va_end(args); 416 422 417 423 // release TXT0 lock 418 remote_spinlock_unlock_busy( lock_xp , save_sr);419 420 // suicide 421 while( 1 ) asm volatile ("nop");422 }424 remote_spinlock_unlock_busy(lock_txt0_xp, save_sr); 425 } 426 427 // suicide 428 hal_core_sleep(); 423 429 } 424 430 -
trunk/kernel/kern/printk.h
r457 r491 44 44 #include <stdarg.h> 45 45 46 #include <hal_special.h> // hal_get_cycles() 46 47 47 48 /********************************************************************************** … … 82 83 void nolock_printk( char* format, ... ); 83 84 84 /********************************************************************************** 85 * This function displays a formated message on kernel TXT0 terminal, 85 86 /********************************************************************************** 87 * Private function designed to be called by the assert macro (below) 88 ********************************************************************************** 89 * @ file_name : File where the assert macro was invoked 90 * @ function_name : Name of the calling function. 91 * @ line : Line number where the assert macro was invoked 92 * @ cycle : Cycle where the macro was invoked 93 * @ format : Formatted string 94 * ... : arguments of the format string 95 * 96 * See assert macro documentation for information about printed information. 97 *********************************************************************************/ 98 void __panic( const char * file_name, 99 const char * function_name, 100 uint32_t line, 101 cycle_t cycle, 102 const char * format, ... ) 103 __attribute__((__noreturn__)); 104 105 /********************************************************************************** 106 * This macro displays a formated message on kernel TXT0 terminal, 86 107 * and forces the calling core in sleeping mode if a Boolean condition is false. 87 * This function is actually used to debug the kernel... 108 * Actually used to debug the kernel. 109 * 110 * Information printed by assert: 111 * Current running thread: 112 * - thread descriptior adress 113 * - thread id (trdid) 114 * 115 * Current Process: 116 * - Process descriptor adress 117 * - Process id (pid) 118 * 119 * Current Core: 120 * - local cluster position (local_cxy) 121 * - local core id (lid) 122 * 123 * File name (__FILE__) and were the assert is invoked. 124 * And the assert message. 125 * 126 * Cycle: before the assert branchment. 127 * Note: cycle may change due to compiler optimisation. 128 * 129 * Exemple: 130 * assert( my_ptr != NULL, "my_ptr should not be NULL") 88 131 ********************************************************************************** 89 132 * @ condition : condition that must be true. 90 * @ function_name : name of the calling function.91 133 * @ format : formatted string 92 134 *********************************************************************************/ 93 void assert( bool_t condition, 94 const char * function_name, 95 char * format , ... ); 135 #define assert( expr, format, ... ) { uint32_t __line_at_expansion = __LINE__; \ 136 const volatile cycle_t __assert_cycle = hal_get_cycles(); \ 137 if ( ( expr ) == false ) { \ 138 __panic( __FILE__, __FUNCTION__, \ 139 __line_at_expansion, __assert_cycle, \ 140 ( format ), ##__VA_ARGS__ ); \ 141 } \ 142 } 96 143 97 144 /**********************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.