Index: trunk/kernel/kern/printk.h
===================================================================
--- trunk/kernel/kern/printk.h	(revision 657)
+++ trunk/kernel/kern/printk.h	(revision 669)
@@ -26,4 +26,14 @@
 // to display messages on the kernel terminal TXT0, using a busy waiting policy. 
 // It calls synchronously the TXT0 driver, without descheduling.
+//
+// For the formated string, the supported formats are defined below :
+//   %c : single ascii character (8 bits)
+//   %d : up to 10 digits decimal integer (32 bits)
+//   %u : up to 10 digits unsigned decimal (32 bits) 
+//   %x : up to 8 digits hexadecimal integer (32 bits) 
+//   %X : exactly 8 digits hexadecimal integer (32 bits) 
+//   %l : up to 16 digits hexadecimal integer (64 bits)
+//   %L : exactly 16 digits hexadecimal integer (64 bits)
+//   %s : NUL terminated character string
 ///////////////////////////////////////////////////////////////////////////////////
 
@@ -37,120 +47,90 @@
 
 /**********************************************************************************
- * This function build a formatted string.
- * The supported formats are defined below :
- *   %b : exactly 2 digits hexadecimal integer (8 bits)
- *   %c : single ascii character (8 bits)
- *   %d : up to 10 digits decimal integer (32 bits)
- *   %u : up to 10 digits unsigned decimal (32 bits) 
- *   %x : up to 8 digits hexadecimal integer (32 bits) 
- *   %X : exactly 8 digits hexadecimal integer (32 bits) 
- *   %l : up to 16 digits hexadecimal integer (64 bits)
- *   %L : exactly 16 digits hexadecimal integer (64 bits)
- *   %s : NUL terminated character string
+ * These debug functions display a formated string defined by the <format,...>
+ * argument on the kernel terminal TXT0, with or without taking the TXT0 lock. 
  **********************************************************************************
- * @ string     : pointer on target buffer (allocated by caller).
- * @ length     : target buffer length (number of bytes).
- * @ format     : format respecting the printf syntax.
- * @ returns the string length (including NUL) if success / return -1 if error.
- *********************************************************************************/
-uint32_t snprintf( char     * string,
-                   uint32_t   length,
-                   char     * format, ... );
-
-/**********************************************************************************
- * This function displays a formatted string on the kernel terminal TXT0,
- * after taking the TXT0 lock.
- * It uses a busy waiting policy, calling directly the relevant TXT driver,
+ * Implementation note:
+ * It uses a buffer allocated in the stack, defined by CONFIG_PRINTK_BUFFER_SIZE.
+ * It calls the snprintk() function to build a printable string in this buffer, 
+ * and calls directly the dev_txt_sync_write() driver function without using the
+ * TXT server thread.
+ * It displays a [PANIC] message on kernel TXT0 terminal if the formated string
+ * exceeds the buffer size, or if the format is undefined. 
  **********************************************************************************
  * @ format     : formatted string.
  *********************************************************************************/
-void printk( char* format, ... );
+void printk       ( char * format, ... );
+void nolock_printk( char * format, ... );
 
 /**********************************************************************************
- * This function displays a formatted string on the kernel terminal TXT0,
- * without taking the TXT0 lock.
- * It uses a busy waiting policy, calling directly the relevant TXT driver,
+ * This debug function displays a [ASSERT] message on kernel TXT0 terminal
+ * if Boolean expression <expr> is false. It prints a detailed message including:
+ * - the calling core [cxy,lpid]
+ * - the calling thread[pid,trdid]
+ * - the current cycle
+ * - the <func_name> argument
+ * - the <string> argument
  **********************************************************************************
- * @ format     : formatted string.
+ * @ func_name  : calling function name.
+ * @ expr       : Boolean expression to be checked.
+ * @ format     : formated message argument.
  *********************************************************************************/
-void nolock_printk( char* format, ... );
-
+void assert( const char   * func_name,
+             bool_t         expr,
+             char         * format , ... );
 
 /**********************************************************************************
- * This function is called in case of kernel panic. It printt a detailed message
- * on the TXT0 terminal after taking the TXT0 lock, and call the hal_core_sleep()
- * function to block the calling core.  It is used by the assert macro (below).
+ * This function build a formated string in a buffer defined by the <buffer> 
+ * and <buf_size> arguments, from the format defined by the <format,...> argument.
+ * This function set the NUL terminating character in target <buffer>.
  **********************************************************************************
- * @ file_name     : File where the assert macro was invoked
- * @ function_name : Name of the calling function.
- * @ line          : Line number where the assert macro was invoked
- * @ cycle         : Cycle where the macro was invoked
- * @ format        : Formatted string
- * ...             : arguments of the format string
- *
- * See assert macro documentation for information about printed information.
+ * @ buffer     : pointer on target buffer (allocated by caller).
+ * @ buf_size   : target buffer length (number of bytes).
+ * @ format     : format respecting the printf syntax.
+ * @ returns  string length (not including NUL) if success / -1 if error.
  *********************************************************************************/
-void panic( const char * function_name,
-            uint32_t     line,
-            cycle_t      cycle,
-            const char * format,
-            ... ) __attribute__((__noreturn__));
+int32_t snprintk( char       * buffer,
+                  uint32_t     buf_size,
+                  char       * format, ... );
 
 /**********************************************************************************
- * This macro displays a formated message on kernel TXT0 terminal,
- * and forces the calling core in sleeping mode if a Boolean condition is false.
- * Actually used to debug the kernel.
- *
- * Extra information printed by assert:
- * - Current thread, process, and core
- * - Function name / line number in file / cycle
+ * These functions displays a non-formated string on TXT0 terminal.
+ * They are actually used for low level debug, and call directly the TXT driver,
+ * without using the TXT server thread.
  **********************************************************************************
- * @ condition     : condition that must be true.
- * @ format        : formatted string
+ * @ string   : non-formatted, NUL terminated string.
  *********************************************************************************/
-#define assert( expr, format, ... )                                               \
-{                                                                                 \
-    uint32_t __line_at_expansion = __LINE__;                                      \
-    const volatile cycle_t __assert_cycle = hal_get_cycles();                     \
-    if ( ( expr ) == false )                                                      \
-    {                                                                             \
-        panic( __FUNCTION__,                                                      \
-               __line_at_expansion,                                               \
-               __assert_cycle,                                                    \
-               ( format ), ##__VA_ARGS__ );                                       \
-    }                                                                             \
-}
+void puts( const char * string );
+void nolock_puts( const char * string );
 
 /**********************************************************************************
- * This debug function displays a non-formated message on TXT0 terminal.
- * This function is actually used to debug the assembly level kernel functions.
- **********************************************************************************
- * @ string   : non-formatted string.
- *********************************************************************************/
-void puts( char * string );
-
-/**********************************************************************************
- * This debug function displays a 32 bits value in hexadecimal on TXT0 terminal.
- * This function is actually used to debug the assembly level kernel functions.
+ * These functions display a 32 bits value in hexadecimal on TXT0 terminal.
+ * They are actually used for low level debug, and call directly the TXT driver,
+ * without using the TXT server thread.
  **********************************************************************************
  * @ val   : 32 bits unsigned value.
  *********************************************************************************/
 void putx( uint32_t val );
+void nolock_putx( uint32_t val );
 
 /**********************************************************************************
- * This debug function displays a 32 bits signed value in decimal on TXT0 terminal.
- * This function is actually used to debug the assembly level kernel functions.
+ * These functions display a 32 bits signed value in decimal on TXT0 terminal.
+ * They are actually used for low level debug, and call directly the TXT driver,
+ * without using the TXT server thread.
  **********************************************************************************
  * @ val   : 32 bits signed value.
  *********************************************************************************/
 void putd( int32_t val );
+void nolock_putd( int32_t val );
 
 /**********************************************************************************
- * This debug function displays a 64 bits value in hexadecimal on TXT0 terminal.
- * This function is actually used to debug the assembly level kernel functions.
+ * These functions display a 64 bits value in hexadecimal on TXT0 terminal.
+ * They are actually used low level debug, and call directly the TXT driver,
+ * without using the TXT server thread.
  **********************************************************************************
  * @ val   : 64 bits unsigned value.
  *********************************************************************************/
 void putl( uint64_t val );
+void nolock_putl( uint64_t val );
 
 /**********************************************************************************
