Index: trunk/kernel/kern/printk.h
===================================================================
--- trunk/kernel/kern/printk.h	(revision 690)
+++ trunk/kernel/kern/printk.h	(revision 1)
@@ -1,6 +1,6 @@
 /*
  * printk.h - Kernel Log & debug messages API definition.
- *
- * authors  Alain Greiner (2016,2017,2018,2019,2020)
+ * 
+ * authors  Alain Greiner (2016)
  *
  * Copyright (c) UPMC Sorbonne Universites
@@ -24,17 +24,9 @@
 ///////////////////////////////////////////////////////////////////////////////////
 // The printk.c and printk.h files define the functions used by the kernel
-// to build, or display on terminal TXT0, formated strings.
-// In case ofdisplay, it calls synchronously the TXT0 driver, without descheduling.
-//
-// The supported formats are defined below :
-//   %c : single ascii character (8 bits)
-//   %b : exactly 2 hexadecimal digits (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
+// to display messages on the kernel text terminal, using a busy waiting
+// policy if required : these functions does not use the TXT kernel thread,
+// and does not deschedule if TXT peripheral is not available.
+// These functions use the generic TXT device to call the proper implementation
+// dependant TXT driver.
 ///////////////////////////////////////////////////////////////////////////////////
 
@@ -42,112 +34,131 @@
 #define _PRINTK_H
 
-#include <hal_kernel_types.h>
-#include <stdarg.h>
+///////////////////////////////////////////////////////////////////////////////////
+//       Access functions to kernel terminal TTY0 
+///////////////////////////////////////////////////////////////////////////////////
 
-#include <hal_special.h> 
+extern void         printk( char* format, ... );
 
-/**********************************************************************************
- * These functions display a formated string defined by the <format,...>
- * argument on the kernel terminal TXT0, with or without taking the TXT0 lock. 
- **********************************************************************************
- * 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 nolock_printk( char * format, ... );
+extern void         nolock_printk( char* format, ... );
 
-/**********************************************************************************
- * This function displays an [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
- **********************************************************************************
- * @ func_name  : calling function name.
- * @ expr       : Boolean expression to be checked.
- * @ format     : formated message argument.
- *********************************************************************************/
-void assert( const char   * func_name,
-             bool_t         expr,
-             char         * format , ... );
+extern void         user_printk( char* format, ... );
 
-/**********************************************************************************
- * 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>,
- * but the returned length does not include this NUL character.
- **********************************************************************************
- * @ 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.
- *********************************************************************************/
-int32_t snprintk( char       * buffer,
-                  uint32_t     buf_size,
-                  char       * format, ... );
+///////////////////////////////////////////////////////////////////////////////////
+//       Conditionnal debug macros
+///////////////////////////////////////////////////////////////////////////////////
 
-/**********************************************************************************
- * 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.
- **********************************************************************************
- * @ string   : non-formatted, NUL terminated string.
- *********************************************************************************/
-void puts( const char * string );
-void nolock_puts( const char * string );
+#if CONFIG_CORE_DEBUG
+#define core_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define core_dmsg(...)
+#endif
 
-/**********************************************************************************
- * 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 );
+#if CONFIG_DQDT_DEBUG
+#define dqdt_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define dqdt_dmsg(...)
+#endif
 
-/**********************************************************************************
- * 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 );
+#if CONFIG_ELF_DEBUG
+#define elf_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define elf_dmsg(...)
+#endif
 
-/**********************************************************************************
- * 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 );
+#if CONFIG_FORK_DEBUG
+#define fork_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define fork_dmsg(...)
+#endif
 
-/**********************************************************************************
- * This debug function displays on the TXT0 terminal the content of an
- * array of bytes defined by <buffer> and <size> arguments (16 bytes per line).
- * The <string> argument is displayed before the buffer content.
- * The line format is an address followed by 16 (hexa) bytes.
- **********************************************************************************
- * @ string   : buffer name or identifier.
- * @ buffer   : local pointer on bytes array.
- * @ size     : number of bytes to display.
- *********************************************************************************/
-void putb( char     * string,
-           uint8_t  * buffer,
-           uint32_t   size );
+#if CONFIG_EXEC_DEBUG
+#define exec_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define exec_dmsg(...)
+#endif
 
+#if CONFIG_ICU_DEBUG
+#define icu_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define icu_dmsg(...)
+#endif
+
+#if CONFIG_IOC_DEBUG
+#define ioc_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define ioc_dmsg(...)
+#endif
+
+#if CONFIG_KINIT_DEBUG
+#define kinit_dmsg(...) printk(__VA_ARGS__)
+#else
+#define kinit_dmsg(...)
+#endif
+
+#if CONFIG_KMEM_DEBUG
+#define kmem_dmsg(...) printk(__VA_ARGS__)
+#else
+#define kmem_dmsg(...)
+#endif
+
+#if CONFIG_MMC_DEBUG
+#define mmc_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define mmc_dmsg(...)
+#endif
+
+#if CONFIG_NIC_DEBUG
+#define nic_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define nic_dmsg(...)
+#endif
+
+#if CONFIG_PIC_DEBUG
+#define pic_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define pic_dmsg(...)
+#endif
+
+#if CONFIG_PROCESS_DEBUG
+#define process_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define process_dmsg(...)
+#endif
+
+#if CONFIG_RPC_DEBUG
+#define rpc_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define rpc_dmsg(...)
+#endif
+
+#if CONFIG_SCHED_DEBUG
+#define sched_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define sched_dmsg(...)
+#endif
+
+#if CONFIG_THREAD_DEBUG
+#define thread_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define thread_dmsg(...)
+#endif
+
+#if CONFIG_TXT_DEBUG
+#define txt_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define txt_dmsg(...)
+#endif
+
+#if CONFIG_VFS_DEBUG
+#define vfs_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define vfs_dmsg(...)
+#endif
+
+#if CONFIG_VMM_DEBUG
+#define vmm_dmsg(...)   printk(__VA__ARGS__)
+#else
+#define vmm_dmsg(...)
+#endif
 
 
