Index: trunk/user/init/init.c
===================================================================
--- trunk/user/init/init.c	(revision 438)
+++ trunk/user/init/init.c	(revision 440)
@@ -7,9 +7,7 @@
 // It uses the fork/exec syscalls to create N KSH child processes 
 // (one child process per user terminal).
-// It includes the hard_config.h file to get th NB_TXT_CHANNELS parameter.
-//
-// TODO : Register the PIDs for all KSH[i] in a ksh_pid[] array. 
 // Then calls the wait() function to block, and reactivate any child KSH process
 // that has been deleted, using a new fork/exec.
+// It includes the hard_config.h file to get th NB_TXT_CHANNELS parameter.
 ///////////////////////////////////////////////////////////////////////////////////////
 
@@ -19,4 +17,9 @@
 #include <stdio.h>
 #include <pthread.h>
+
+#define DEBUG_INIT 1
+
+// TODO make the cxy computation portable [AG]
+#define CXY_FROM_XY( x , y )  ((x<<4) + y)
 
 //////////
@@ -43,5 +46,5 @@
         {
             // INIT display error message  
-            snprintf( string , 64 , "INIT cannot fork child[%d] => suicide" , i );
+            snprintf( string , 64 , "[INIT] cannot fork child[%d] => suicide" , i );
             display_string( string );
 
@@ -58,5 +61,5 @@
                 // CHILD[i] display error message
                 snprintf( string , 64 , 
-                "CHILD[%d] cannot exec KSH[%d] / ret_exec = %d" , i , i , ret_exec );
+                "[INIT ERROR] CHILD[%d] cannot exec KSH / ret_exec = %d" , i , ret_exec );
                 display_string( string );
             }
@@ -65,5 +68,5 @@
         {
              // INIT display CHILD[i] process PID
-             snprintf( string , 64 , "INIT created KSH[%d] / pid = %x", i , ret_fork ); 
+             snprintf( string , 64 , "[INIT] created KSH[%d] / pid = %x", i , ret_fork ); 
              display_string( string );
 
@@ -72,10 +75,33 @@
         }
     } 
+  
+#if DEBUG_INIT
 
-// INIT display processes and threads in clusters 0 & 1 
-display_cluster_processes( 0 );
-display_sched( 0 , 0 );
-display_cluster_processes( 1 );
-display_sched( 1 , 0 );
+    unsigned int  x_size;        // number of clusters in a row
+    unsigned int  y_size;        // number of clusters in a column
+    unsigned int  ncores;        // number of cores per cluster
+    unsigned int  x;             // cluster x coordinate
+    unsigned int  y;             // cluster y coordinate
+    unsigned int  cxy;           // cluster identifier
+    unsigned int  lid;           // core local index
+
+    // get hardware config
+    get_config( &x_size , &y_size , &ncores );
+    
+    // INIT displays processes and threads in all clusters 
+    for( x = 0 ; x < x_size ; x++ )
+    {
+        for( y = 0 ; y < y_size ; y++ )
+        {
+            cxy = CXY_FROM_XY( x , y );
+            display_cluster_processes( cxy );
+            for( lid = 0 ; lid < ncores ; lid++ )
+            { 
+                display_sched( cxy , lid );
+            }
+        }
+    }
+
+#endif
 
     // This loop detects the termination of the KSH[i] processes,
@@ -89,8 +115,8 @@
         {
             // display string to report unexpected KSH process block
-            snprintf( string , 64 , "KSH process %x stopped => unblock it" , rcv_pid );
+            snprintf( string , 64 , "[INIT] KSH process %x stopped => unblock it" , rcv_pid );
             display_string( string ); 
 
-            // TODO : unblock KSH
+            // TODO : unblock KSH [AG]
 
         }  // end KSH stopped handling
@@ -99,5 +125,5 @@
         {
             // display string to report KSH process termination
-            snprintf( string , 64 , "KSH process %x terminated => recreate KSH", rcv_pid );
+            snprintf( string , 64 , "[INIT] KSH process %x terminated => recreate", rcv_pid );
             display_string( string ); 
 
@@ -108,5 +134,5 @@
             {
                 // INIT display error message
-                snprintf( string , 64 , "INIT cannot fork child => suicide");
+                snprintf( string , 64 , "[INIT ERROR] cannot fork child => suicide");
                 display_string( string );
 
@@ -122,5 +148,5 @@
                 {
                     // CHILD display error message on TXT0 terminal
-                    snprintf( string , 64 , "CHILD cannot exec KSH" );
+                    snprintf( string , 64 , "[INIT ERROR] CHILD cannot exec KSH" );
                     display_string( string );
                 }
@@ -129,17 +155,26 @@
             {
                 // INIT display new CHILD process PID
-                snprintf( string , 64 , "INIT forked CHILD / pid = %x", ret_fork ); 
+                snprintf( string , 64 , "[INIT] forked CHILD / pid = %x", ret_fork ); 
                 display_string( string );
             }
         } // end KSH kill handling
 
-// INIT wait a fixed delay 
-for( delay = 0 ; delay < 50000 ; delay++ ) asm volatile( "nop" );
+#if( DEBUG_INIT )
 
-// INIT display processes and threads in clusters 0 & 1 
-display_cluster_processes( 0 );
-display_sched( 0 , 0 );
-display_cluster_processes( 1 );
-display_sched( 1 , 0 );
+        // INIT displays processes and threads in all clusters 
+        for( x = 0 ; x < x_size ; x++ )
+        {
+            for( y = 0 ; y < y_size ; y++ )
+            {
+                cxy = CXY_FROM_XY( x , y );
+                display_cluster_processes( cxy );
+                for( lid = 0 ; lid < ncores ; lid++ )
+                { 
+                    display_sched( cxy , lid );
+                }
+            }
+        }
+
+#endif
 
     }  // end while waiting KSH[i] termination
