Index: trunk/kernel/kernel_config.h
===================================================================
--- trunk/kernel/kernel_config.h	(revision 675)
+++ trunk/kernel/kernel_config.h	(revision 683)
@@ -25,10 +25,37 @@
 #define _KERNEL_CONFIG_H_
 
-////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////
 //                              KERNEL DEBUG
-//  Each debug variable control one kernel function, or one small group of functions. 
-//  - trace is generated only when cycle > debug_value.
-//  - detailed trace is enabled when (debug_value & Ox1) is non zero.
-////////////////////////////////////////////////////////////////////////////////////////////
+//
+// 1) All errors detected by the kernel caused by a system call are reported to the
+//    user process using the ERRNO mechanism. Moreover, the DEBUG_***_ERROR variables
+//    force the compiler to display on TXT0 the error messages generated by
+//    the low-level kernel function, to help the error cause analysis.
+//
+// 2) The other debug variable forece the compiler to display on TXT0 a trace for one
+//    specific kernel function, or one small group of functions.
+//    All these trace variables (but locks, kmem, kcm) respect the following rules: 
+//    - the trace is generated if the debug variable is non zeo.
+//    - trace is generated only when cycle > debug_value.
+//    - detailed trace is enabled when (debug_value & 0x1) is non zero.
+////////////////////////////////////////////////////////////////////////////////////////
+
+// error reporting variables
+
+#define DEBUG_DEV_NIC_ERROR               1
+#define DEBUG_KCM_ERROR                   1
+#define DEBUG_KMEM_ERROR                  1
+#define DEBUG_MAPPER_ERROR                1
+#define DEBUG_PPM_ERROR                   1
+#define DEBUG_PROCESS_ERROR               1
+#define DEBUG_SOCKET_ERROR                1
+#define DEBUG_SYSCALLS_ERROR              1
+#define DEBUG_THREAD_ERROR                1
+#define DEBUG_USER_DIR_ERROR              1
+#define DEBUG_VFS_ERROR                   1
+#define DEBUG_VMM_ERROR                   1
+
+
+// trace activation variables
 
 #define DEBUG_BARRIER_CREATE              0
@@ -36,7 +63,7 @@
 #define DEBUG_BARRIER_WAIT                0
 
-#define DEBUG_BUSYLOCK_TYPE               0
-#define DEBUG_BUSYLOCK_PID                0         
-#define DEBUG_BUSYLOCK_TRDID              0       
+#define DEBUG_BUSYLOCK_TYPE               0   // type 0 undefined => no debug
+#define DEBUG_BUSYLOCK_PID                0   // owner process PID
+#define DEBUG_BUSYLOCK_TRDID              0   // owner thread TRDID
                  
 #define DEBUG_CHDEV_CMD_RX                0
@@ -115,10 +142,12 @@
 
 #define DEBUG_KCM                         0
-#define DEBUG_KCM_REMOTE                  0
+#define DEBUG_KCM_ORDER                   0    // filter for DEBUG_KCM
+#define DEBUG_KCM_CXY                     0    // filter for DEBUG_KCM
+
+#define DEBUG_KERNEL_INIT                 0
 
 #define DEBUG_KMEM                        0
-#define DEBUG_KMEM_REMOTE                 0
-
-#define DEBUG_KERNEL_INIT                 0
+#define DEBUG_KMEM_ORDER                  0    // filter for DEBUG_KMEM
+#define DEBUG_KMEM_CXY                    0    // filter for DEBUG_KMEM
 
 #define DEBUG_MAPPER_GET_PAGE             0
@@ -133,10 +162,7 @@
 #define DEBUG_PPM_ALLOC_PAGES             0
 #define DEBUG_PPM_FREE_PAGES              0
-#define DEBUG_PPM_REMOTE_ALLOC_PAGES      0
-#define DEBUG_PPM_REMOTE_FREE_PAGES       0
    
 #define DEBUG_PROCESS_COPY_INIT           0
 #define DEBUG_PROCESS_DESTROY             0
-#define DEBUG_PROCESS_EXEC_GET_STRINGS    0
 #define DEBUG_PROCESS_FD_REGISTER         0
 #define DEBUG_PROCESS_FD_REMOVE           0
@@ -151,7 +177,7 @@
 #define DEBUG_PROCESS_ZERO_CREATE         0
 
-#define DEBUG_QUEUELOCK_TYPE              0           // type 0 undefined => no debug
-#define DEBUG_QUEUELOCK_PTR               0
-#define DEBUG_QUEUELOCK_CXY               0
+#define DEBUG_QUEUELOCK_TYPE              0   // type 0 undefined => no debug
+#define DEBUG_QUEUELOCK_PTR               0   // lock local pointer
+#define DEBUG_QUEUELOCK_CXY               0   // lock cluster identifier
 
 #define DEBUG_RPC_CLIENT_GENERIC          0
@@ -170,7 +196,7 @@
 #define DEBUG_RPC_VMM_SET_COW             0
 
-#define DEBUG_RWLOCK_TYPE                 0           // type 0 undefined => no debug
-#define DEBUG_RWLOCK_PTR                  0
-#define DEBUG_RWLOCK_CXY                  0
+#define DEBUG_RWLOCK_TYPE                 0   // type 0 undefined => no debug
+#define DEBUG_RWLOCK_PTR                  0   // lock local pointer
+#define DEBUG_RWLOCK_CXY                  0   // lock cluster identifier
 
 #define DEBUG_SCHED_HANDLE_SIGNALS        0
@@ -189,9 +215,7 @@
 #define DEBUG_SOCKET_DESTROY              0
 #define DEBUG_SOCKET_LISTEN               0
+#define DEBUG_SOCKET_SEND                 0
 #define DEBUG_SOCKET_RECV                 0
-#define DEBUG_SOCKET_SEND                 0
 #define DEBUG_SOCKET_LINK                 0
-
-#define DEBUG_SYSCALLS_ERROR              0
 
 #define DEBUG_SYS_BARRIER                 0
@@ -205,11 +229,7 @@
 #define DEBUG_SYS_FG                      0
 #define DEBUG_SYS_FORK                    0
-#define DEBUG_SYS_GET_CONFIG              0
+#define DEBUG_SYS_GET                     0  
 #define DEBUG_SYS_GETCWD                  0
 #define DEBUG_SYS_GETPID                  0
-#define DEBUG_SYS_GET_BEST_CORE           0
-#define DEBUG_SYS_GET_CORE_ID             0
-#define DEBUG_SYS_GET_NB_CORES            0
-#define DEBUG_SYS_GET_THREAD_INFO         0
 #define DEBUG_SYS_ISATTY                  0
 #define DEBUG_SYS_IS_FG                   0
@@ -250,7 +270,6 @@
 #define DEBUG_THREAD_USER_EXEC            0
 
-#define DEBUG_USER_DIR                    0
-
-#define DEBUG_VFS_ERROR                   0
+#define DEBUG_USER_DIR_CREATE             0
+#define DEBUG_USER_DIR_DESTROY            0
 
 #define DEBUG_VFS_ADD_CHILD               0
@@ -277,4 +296,5 @@
 #define DEBUG_VFS_UNLINK                  0
 
+
 #define DEBUG_VMM_CREATE_VSEG             0
 #define DEBUG_VMM_DESTROY                 0
@@ -352,5 +372,5 @@
 ////////////////////////////////////////////////////////////////////////////////////////////
 
-#define CONFIG_VERSION           "Version 2.3 / November 2019"
+#define CONFIG_VERSION           "Version 2.4 / November 2020"
 
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -370,4 +390,5 @@
 #define CONFIG_CLUSTER_SPAN                 32         // ln(phys. address space per cluster)
 #define CONFIG_CACHE_LINE_SIZE              64         // number of bytes in cache line
+#define CONFIG_CACHE_LINE_ORDER             6          // ln( cache line size )
 
 #define CONFIG_CACHE_LINE_ALIGNED           __attribute__((aligned(CONFIG_CACHE_LINE_SIZE)))
@@ -389,7 +410,22 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////
+//                                  DQDT        
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_DQDT_LEVELS_NR               5
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                              FBF WINDOWS       
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_FBF_WINDOWS_MAX_NR           64         // max number of windows
+#define CONFIG_FBF_WINDOWS_MAX_WIDTH        1024       // max number of pixels in FBF line
+#define CONFIG_FBF_WINDOWS_MAX_HEIGHT       1024       // max number of lines in FBF
+
+////////////////////////////////////////////////////////////////////////////////////////////
 //                            PROCESS MANAGEMENT       
 ////////////////////////////////////////////////////////////////////////////////////////////
 
+#define CONFIG_PROCESS_INIT_PATH            "/bin/user/init.elf"
 #define CONFIG_MAX_PROCESS_PER_CLUSTER      16         // max number of owned process
 #define CONFIG_PROCESS_ARGS_MAX_NR          4          // max number of args per process 
@@ -399,5 +435,65 @@
 #define CONFIG_PROCESS_HEAP_MIN_SIZE        0x00010000 // user heap min size (bytes)
 #define CONFIG_PROCESS_HEAP_MAX_SIZE        0x30000000 // user heap max size (bytes)
-#define CONFIG_PROCESS_INIT_PATH            "/bin/user/init.elf"
+#define CONFIG_PROCESS_DISPLAY_BUF_SIZE     128        // display one process on one line 
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                          PHYSICAL MEMORY MANAGEMENT         
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_PPM_PAGE_SIZE          4096          // physical page size (bytes)
+#define CONFIG_PPM_PAGE_ORDER         12            // ln(physical page size)
+#define CONFIG_PPM_PAGE_MASK          0x00000FFF    // physical page mask     
+#define CONFIG_PPM_MAX_ORDER          16            // ln(total number of pages per cluster)
+#define CONFIG_PPM_MAX_RSVD           32            // max reserved zones on the machine
+
+#define CONFIG_PPM_PAGE_ALIGNED       __attribute__((aligned(CONFIG_PPM_PAGE_SIZE)))
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                              RANDOM NUMBERS 
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_RDNG_PARAM_A                 65519
+#define CONFIG_RDNG_PARAM_C                 64037
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                             REMOTE PROCEDURE CALL
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_RPC_FIFO_SLOTS		        16
+#define CONFIG_RPC_FIFO_MAX_ITERATIONS      1024
+#define CONFIG_RPC_THREADS_MAX              4       // max number of RPC threads per core
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                                SCHEDULING 
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_SCHED_TICKS_PER_SECOND       1        // number of TICKS per seconds   
+#define CONFIG_SCHED_TICKS_PER_QUANTUM      1        // number of ticks between scheduling
+#define CONFIG_SCHED_MAX_THREADS_NR         32       // max number of threads per core
+#define CONFIG_SCHED_IDLE_MODE_SLEEP        0        // idle thread use sleep mode if non 0
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                                TCP/UDP/IP 
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_SOCK_ISS_CLIENT        0x10000      // initial sequence number for TCP client
+#define CONFIG_SOCK_ISS_SERVER        0x20000      // initial sequence number for TCP server
+#define CONFIG_SOCK_MAX_WINDOW        0xFFFFF      // initial window (bytes) for TCP
+#define CONFIG_SOCK_RETRY_TIMEOUT     1000000      // number of cycles before retry for TCP
+#define CONFIG_SOCK_QUEUES_DEPTH      4            // max number of packets in RX/TX queues 
+#define CONFIG_SOCK_RX_BUF_ORDER      20           // ln( number of bytes in socket rx_buf )
+#define CONFIG_SOCK_TX_BUF_ORDER      20           // ln( number of bytes in socket tx_buf )
+#define CONFIG_SOCK_R2T_BUF_SIZE      8            // max number of requests in R2T queue 
+#define CONFIG_SOCK_CRQ_BUF_SIZE      8            // max number of requests in CRQ queue
+#define CONFIG_SOCK_PKT_BUF_SIZE      2048         // max length for one ETH/IP/TCP packet
+#define CONFIG_SOCK_PAYLOAD_MAX       1500         // max user payload length for packet
+
+////////////////////////////////////////////////////////////////////////////////////////////
+//                                 THREADS 
+////////////////////////////////////////////////////////////////////////////////////////////
+
+#define CONFIG_THREADS_MAX_PER_CLUSTER      32       // max threads per cluster per process
+#define CONFIG_THREAD_DESC_SIZE             0x4000   // thread desc size (with kernel stack)
+#define CONFIG_THREAD_DESC_ORDER            14       // ln( number of bytes )
 
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -419,50 +515,4 @@
 #define CONFIG_MAPPER_GRDXT_W2              7          // number of bits for RADIX_TREE_IX2
 #define CONFIG_MAPPER_GRDXT_W3              7          // number of bits for RADIX_TREE_IX3
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                              FBF WINDOWS       
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_FBF_WINDOWS_MAX_NR           64         // max number of windows
-#define CONFIG_FBF_WINDOWS_MAX_WIDTH        1024       // max number of pixels in FBF line
-#define CONFIG_FBF_WINDOWS_MAX_HEIGHT       1024       // max number of lines in FBF
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                                  DQDT        
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_DQDT_LEVELS_NR               5
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                              RANDOM NUMBERS 
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_RDNG_PARAM_A                 65519
-#define CONFIG_RDNG_PARAM_C                 64037
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                                SCHEDULING 
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_SCHED_TICK_MS_PERIOD         10000    // number of milliseconds per period
-#define CONFIG_SCHED_TICKS_PER_QUANTUM      1        // number of ticks between scheduling
-#define CONFIG_SCHED_MAX_THREADS_NR         32       // max number of threads per core
-#define CONFIG_SCHED_IDLE_MODE_SLEEP        0        // idle thread use sleep mode if non 0
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                                 THREADS 
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_THREADS_MAX_PER_CLUSTER      32       // max threads per cluster per process
-#define CONFIG_THREAD_DESC_SIZE             0x4000   // thread desc size (with kernel stack)
-#define CONFIG_THREAD_DESC_ORDER            2        // ln( number of 4K pages )
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                             REMOTE PROCEDURE CALL
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_REMOTE_FIFO_SLOTS		    16
-#define CONFIG_REMOTE_FIFO_MAX_ITERATIONS   1024
-#define CONFIG_RPC_THREADS_MAX              4       // max number of RPC threads per core
 
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -479,20 +529,7 @@
 #define CONFIG_VMM_ARGS_SIZE          0x000001      // args vseg size         : 4   Kbytes
 #define CONFIG_VMM_ENVS_SIZE          0x000004      // envs vseg size         : 16  Kbytes
-#define CONFIG_VMM_STACK_SIZE         0x001000      // single stack vseg size : 16  Mbytes
-
-#define CONFIG_VMM_HEAP_MAX_ORDER     18           // max size of MMAP vseg  :  1   Gbytes
-
-////////////////////////////////////////////////////////////////////////////////////////////
-//                      PHYSICAL MEMORY MANAGEMENT         
-////////////////////////////////////////////////////////////////////////////////////////////
-
-#define CONFIG_PPM_PAGE_SIZE          4096          // physical page size (bytes)
-#define CONFIG_PPM_PAGE_SHIFT         12            // physical page shift (bits)
-#define CONFIG_PPM_PAGE_MASK          0x00000FFF    // physical page mask     
-#define CONFIG_PPM_MAX_ORDER          16            // ln(total number of pages per cluster)
-#define CONFIG_PPM_HEAP_ORDER         10            // ln(number of heap pages per cluster)
-#define CONFIG_PPM_MAX_RSVD           32            // max reserved zones on the machine
-
-#define CONFIG_PPM_PAGE_ALIGNED       __attribute__((aligned(CONFIG_PPM_PAGE_SIZE)))
+#define CONFIG_VMM_STACK_SIZE         0x000100      // single stack vseg size : 1   Mbytes
+
+#define CONFIG_VMM_HEAP_MAX_ORDER     18            // max size of MMAP vseg  : 1   Gbytes
 
 ////////////////////////////////////////////////////////////////////////////////////////////
@@ -502,8 +539,4 @@
 #define CONFIG_PRINTK_BUF_SIZE        0x800        // max length of a formated string
 #define CONFIG_PIPE_BUF_SIZE          0x1000       // max number of bytes in a pipe buffer
-#define CONFIG_SOCK_RX_BUF_SIZE       0x100000     // max number of bytes in  RX buffer
-#define CONFIG_SOCK_R2T_BUF_SIZE      0x64         // max number of requests in R2T queue 
-#define CONFIG_SOCK_CRQ_BUF_SIZE      0x8          // max number of requests in CRQ queue
-#define CONFIG_SOCK_PKT_BUF_SIZE      0x800        // max length for one ETH/IP/TCP packet
 
 ////////////////////////////////////////////////////////////////////////////////////////////
