Changeset 669 for trunk/kernel/kern/printk.h
- Timestamp:
- Nov 19, 2020, 11:44:34 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/printk.h
r657 r669 26 26 // to display messages on the kernel terminal TXT0, using a busy waiting policy. 27 27 // It calls synchronously the TXT0 driver, without descheduling. 28 // 29 // For the formated string, the supported formats are defined below : 30 // %c : single ascii character (8 bits) 31 // %d : up to 10 digits decimal integer (32 bits) 32 // %u : up to 10 digits unsigned decimal (32 bits) 33 // %x : up to 8 digits hexadecimal integer (32 bits) 34 // %X : exactly 8 digits hexadecimal integer (32 bits) 35 // %l : up to 16 digits hexadecimal integer (64 bits) 36 // %L : exactly 16 digits hexadecimal integer (64 bits) 37 // %s : NUL terminated character string 28 38 /////////////////////////////////////////////////////////////////////////////////// 29 39 … … 37 47 38 48 /********************************************************************************** 39 * This function build a formatted string. 40 * The supported formats are defined below : 41 * %b : exactly 2 digits hexadecimal integer (8 bits) 42 * %c : single ascii character (8 bits) 43 * %d : up to 10 digits decimal integer (32 bits) 44 * %u : up to 10 digits unsigned decimal (32 bits) 45 * %x : up to 8 digits hexadecimal integer (32 bits) 46 * %X : exactly 8 digits hexadecimal integer (32 bits) 47 * %l : up to 16 digits hexadecimal integer (64 bits) 48 * %L : exactly 16 digits hexadecimal integer (64 bits) 49 * %s : NUL terminated character string 49 * These debug functions display a formated string defined by the <format,...> 50 * argument on the kernel terminal TXT0, with or without taking the TXT0 lock. 50 51 ********************************************************************************** 51 * @ string : pointer on target buffer (allocated by caller). 52 * @ length : target buffer length (number of bytes). 53 * @ format : format respecting the printf syntax. 54 * @ returns the string length (including NUL) if success / return -1 if error. 55 *********************************************************************************/ 56 uint32_t snprintf( char * string, 57 uint32_t length, 58 char * format, ... ); 59 60 /********************************************************************************** 61 * This function displays a formatted string on the kernel terminal TXT0, 62 * after taking the TXT0 lock. 63 * It uses a busy waiting policy, calling directly the relevant TXT driver, 52 * Implementation note: 53 * It uses a buffer allocated in the stack, defined by CONFIG_PRINTK_BUFFER_SIZE. 54 * It calls the snprintk() function to build a printable string in this buffer, 55 * and calls directly the dev_txt_sync_write() driver function without using the 56 * TXT server thread. 57 * It displays a [PANIC] message on kernel TXT0 terminal if the formated string 58 * exceeds the buffer size, or if the format is undefined. 64 59 ********************************************************************************** 65 60 * @ format : formatted string. 66 61 *********************************************************************************/ 67 void printk( char* format, ... ); 62 void printk ( char * format, ... ); 63 void nolock_printk( char * format, ... ); 68 64 69 65 /********************************************************************************** 70 * This function displays a formatted string on the kernel terminal TXT0, 71 * without taking the TXT0 lock. 72 * It uses a busy waiting policy, calling directly the relevant TXT driver, 66 * This debug function displays a [ASSERT] message on kernel TXT0 terminal 67 * if Boolean expression <expr> is false. It prints a detailed message including: 68 * - the calling core [cxy,lpid] 69 * - the calling thread[pid,trdid] 70 * - the current cycle 71 * - the <func_name> argument 72 * - the <string> argument 73 73 ********************************************************************************** 74 * @ format : formatted string. 74 * @ func_name : calling function name. 75 * @ expr : Boolean expression to be checked. 76 * @ format : formated message argument. 75 77 *********************************************************************************/ 76 void nolock_printk( char* format, ... ); 77 78 void assert( const char * func_name, 79 bool_t expr, 80 char * format , ... ); 78 81 79 82 /********************************************************************************** 80 * This function is called in case of kernel panic. It printt a detailed message81 * on the TXT0 terminal after taking the TXT0 lock, and call the hal_core_sleep()82 * function to block the calling core. It is used by the assert macro (below).83 * This function build a formated string in a buffer defined by the <buffer> 84 * and <buf_size> arguments, from the format defined by the <format,...> argument. 85 * This function set the NUL terminating character in target <buffer>. 83 86 ********************************************************************************** 84 * @ file_name : File where the assert macro was invoked 85 * @ function_name : Name of the calling function. 86 * @ line : Line number where the assert macro was invoked 87 * @ cycle : Cycle where the macro was invoked 88 * @ format : Formatted string 89 * ... : arguments of the format string 90 * 91 * See assert macro documentation for information about printed information. 87 * @ buffer : pointer on target buffer (allocated by caller). 88 * @ buf_size : target buffer length (number of bytes). 89 * @ format : format respecting the printf syntax. 90 * @ returns string length (not including NUL) if success / -1 if error. 92 91 *********************************************************************************/ 93 void panic( const char * function_name, 94 uint32_t line, 95 cycle_t cycle, 96 const char * format, 97 ... ) __attribute__((__noreturn__)); 92 int32_t snprintk( char * buffer, 93 uint32_t buf_size, 94 char * format, ... ); 98 95 99 96 /********************************************************************************** 100 * This macro displays a formated message on kernel TXT0 terminal, 101 * and forces the calling core in sleeping mode if a Boolean condition is false. 102 * Actually used to debug the kernel. 103 * 104 * Extra information printed by assert: 105 * - Current thread, process, and core 106 * - Function name / line number in file / cycle 97 * These functions displays a non-formated string on TXT0 terminal. 98 * They are actually used for low level debug, and call directly the TXT driver, 99 * without using the TXT server thread. 107 100 ********************************************************************************** 108 * @ condition : condition that must be true. 109 * @ format : formatted string 101 * @ string : non-formatted, NUL terminated string. 110 102 *********************************************************************************/ 111 #define assert( expr, format, ... ) \ 112 { \ 113 uint32_t __line_at_expansion = __LINE__; \ 114 const volatile cycle_t __assert_cycle = hal_get_cycles(); \ 115 if ( ( expr ) == false ) \ 116 { \ 117 panic( __FUNCTION__, \ 118 __line_at_expansion, \ 119 __assert_cycle, \ 120 ( format ), ##__VA_ARGS__ ); \ 121 } \ 122 } 103 void puts( const char * string ); 104 void nolock_puts( const char * string ); 123 105 124 106 /********************************************************************************** 125 * This debug function displays a non-formated message on TXT0 terminal. 126 * This function is actually used to debug the assembly level kernel functions. 127 ********************************************************************************** 128 * @ string : non-formatted string. 129 *********************************************************************************/ 130 void puts( char * string ); 131 132 /********************************************************************************** 133 * This debug function displays a 32 bits value in hexadecimal on TXT0 terminal. 134 * This function is actually used to debug the assembly level kernel functions. 107 * These functions display a 32 bits value in hexadecimal on TXT0 terminal. 108 * They are actually used for low level debug, and call directly the TXT driver, 109 * without using the TXT server thread. 135 110 ********************************************************************************** 136 111 * @ val : 32 bits unsigned value. 137 112 *********************************************************************************/ 138 113 void putx( uint32_t val ); 114 void nolock_putx( uint32_t val ); 139 115 140 116 /********************************************************************************** 141 * This debug function displays a 32 bits signed value in decimal on TXT0 terminal. 142 * This function is actually used to debug the assembly level kernel functions. 117 * These functions display a 32 bits signed value in decimal on TXT0 terminal. 118 * They are actually used for low level debug, and call directly the TXT driver, 119 * without using the TXT server thread. 143 120 ********************************************************************************** 144 121 * @ val : 32 bits signed value. 145 122 *********************************************************************************/ 146 123 void putd( int32_t val ); 124 void nolock_putd( int32_t val ); 147 125 148 126 /********************************************************************************** 149 * This debug function displays a 64 bits value in hexadecimal on TXT0 terminal. 150 * This function is actually used to debug the assembly level kernel functions. 127 * These functions display a 64 bits value in hexadecimal on TXT0 terminal. 128 * They are actually used low level debug, and call directly the TXT driver, 129 * without using the TXT server thread. 151 130 ********************************************************************************** 152 131 * @ val : 64 bits unsigned value. 153 132 *********************************************************************************/ 154 133 void putl( uint64_t val ); 134 void nolock_putl( uint64_t val ); 155 135 156 136 /**********************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.