Index: trunk/kernel/kern/kernel_init.c
===================================================================
--- trunk/kernel/kern/kernel_init.c	(revision 265)
+++ trunk/kernel/kern/kernel_init.c	(revision 279)
@@ -28,4 +28,5 @@
 #include <hal_special.h>
 #include <hal_context.h>
+#include <hal_irqmask.h>
 #include <barrier.h>
 #include <remote_barrier.h>
@@ -59,5 +60,5 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-// All these global variables are replicated in all clusters.
+// All the following global variables are replicated in all clusters.
 // They are initialised by the kernel_init() function.
 //
@@ -135,5 +136,5 @@
            "    /_/        \\_\\ |______| |_|    |_|   \\_____/  |______/        |_|    |_|  |_|  \\_\\ |_|   |_|  \n"
            "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n"
-           "\n\n\t\t\t Version 0.0   :   %d clusters   /   %d cores per cluster\n\n", nclusters , ncores );
+           "\n\n\t\t\t Version 0.0 : %d cluster(s)   /   %d core(s) per cluster\n\n", nclusters , ncores );
 }
 
@@ -274,7 +275,6 @@
             }
 
-            if( local_cxy == 0 )
-            kinit_dmsg("\n[INFO] %s created MMC chdev in cluster 0 at cycle %d\n",
-                       __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() );
+            kinit_dmsg("\n[INFO] %s created MMC in cluster %x / chdev = %x\n",
+                       __FUNCTION__ , channel , local_cxy , chdev_ptr );
         }
         ///////////////////////////////
@@ -301,6 +301,6 @@
                 chdev_dir.dma[channel] = XPTR( local_cxy , chdev_ptr );
 
-                kinit_dmsg("\n[INFO] %s created DMA[%d] chdev in cluster 0 at cycle %d\n",
-                           __FUNCTION__ , channel , (uint32_t)hal_time_stamp() );
+                kinit_dmsg("\n[INFO] %s created DMA[%d] in cluster %x / chdev = %x\n",
+                           __FUNCTION__ , channel , local_cxy , chdev_ptr );
             }
         }
@@ -433,7 +433,6 @@
                     }
 
-		            kinit_dmsg("\n[INFO] %s create chdev %s[%d] in cluster %x at cycle %d\n",
-                               __FUNCTION__ , chdev_func_str( func ), channel,
-                               local_cxy , (uint32_t)hal_time_stamp() );
+		            kinit_dmsg("\n[INFO] %s create chdev %s[%d] in cluster %x / chdev = %x\n",
+                    __FUNCTION__ , chdev_func_str( func ), channel , local_cxy , chdev );
 
                 }  // end if match
@@ -658,4 +657,68 @@
 }
 
+////////////////////////////////////////////////////////////////////////////////////////////
+// This function display on TXT0 the content of the external chdev directory,
+// in the local cluster.
+////////////////////////////////////////////////////////////////////////////////////////////
+static void chdev_dir_display( )
+{
+    cxy_t     iob_cxy  = GET_CXY( chdev_dir.iob );
+    chdev_t * iob_ptr  = (chdev_t *)GET_PTR( chdev_dir.iob );
+    xptr_t    iob_base = hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
+
+    cxy_t     pic_cxy  = GET_CXY( chdev_dir.pic );
+    chdev_t * pic_ptr  = (chdev_t *)GET_PTR( chdev_dir.pic );
+    xptr_t    pic_base = hal_remote_lwd( XPTR( pic_cxy , &pic_ptr->base ) );
+
+    cxy_t     txt0_cxy  = GET_CXY( chdev_dir.txt[0] );
+    chdev_t * txt0_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[0] );
+    xptr_t    txt0_base = hal_remote_lwd( XPTR( txt0_cxy , &txt0_ptr->base ) );
+
+    cxy_t     txt1_cxy  = GET_CXY( chdev_dir.txt[1] );
+    chdev_t * txt1_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[1] );
+    xptr_t    txt1_base = hal_remote_lwd( XPTR( txt1_cxy , &txt1_ptr->base ) );
+
+    cxy_t     txt2_cxy  = GET_CXY( chdev_dir.txt[2] );
+    chdev_t * txt2_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[2] );
+    xptr_t    txt2_base = hal_remote_lwd( XPTR( txt2_cxy , &txt2_ptr->base ) );
+
+    cxy_t     ioc_cxy  = GET_CXY( chdev_dir.ioc[0] );
+    chdev_t * ioc_ptr  = (chdev_t *)GET_PTR( chdev_dir.ioc[0] );
+    xptr_t    ioc_base = hal_remote_lwd( XPTR( ioc_cxy , &ioc_ptr->base ) );
+
+    cxy_t     fbf_cxy  = GET_CXY( chdev_dir.fbf[0] );
+    chdev_t * fbf_ptr  = (chdev_t *)GET_PTR( chdev_dir.fbf[0] );
+    xptr_t    fbf_base = hal_remote_lwd( XPTR( fbf_cxy , &fbf_ptr->base ) );
+
+    cxy_t     nic_rx_cxy  = GET_CXY( chdev_dir.nic_rx[0] );
+    chdev_t * nic_rx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_rx[0] );
+    xptr_t    nic_rx_base = hal_remote_lwd( XPTR( nic_rx_cxy , &nic_rx_ptr->base ) );
+
+    cxy_t     nic_tx_cxy  = GET_CXY( chdev_dir.nic_tx[0] );
+    chdev_t * nic_tx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_tx[0] );
+    xptr_t    nic_tx_base = hal_remote_lwd( XPTR( nic_tx_cxy , &nic_tx_ptr->base ) );
+
+    printk("\n*** external chdev directory in cluster %x\n"
+           "  - iob       = %l / base = %l\n"
+           "  - pic       = %l / base = %l\n"
+           "  - txt[0]    = %l / base = %l\n"
+           "  - txt[1]    = %l / base = %l\n"
+           "  - txt[2]    = %l / base = %l\n"
+           "  - ioc[0]    = %l / base = %l\n"
+           "  - fbf[0]    = %l / base = %l\n"
+           "  - nic_rx[0] = %l / base = %l\n"
+           "  - nic_tx[0] = %l / base = %l\n",
+           local_cxy,
+           chdev_dir.iob, iob_base,
+           chdev_dir.pic, pic_base,
+           chdev_dir.txt[0], txt0_base,
+           chdev_dir.txt[1], txt1_base,
+           chdev_dir.txt[2], txt2_base,
+           chdev_dir.ioc[0], ioc_base,
+           chdev_dir.fbf[0], fbf_base,
+           chdev_dir.nic_rx[0], nic_rx_base,
+           chdev_dir.nic_tx[0], nic_tx_base );
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////
 // This function is the entry point for the kernel initialisation.
@@ -683,4 +746,5 @@
 
     error_t      error;
+    uint32_t     status;                    // running core status register
 
     cxy_t        io_cxy = info->io_cxy;
@@ -732,5 +796,5 @@
     if( error )
     {
-        nolock_printk("\n[PANIC] in %s : illegal core identifiers"
+        printk("\n[PANIC] in %s : illegal core identifiers"
                " gid = %x / cxy = %x / lid = %d\n",
                __FUNCTION__ , core_lid , core_cxy , core_lid );
@@ -745,5 +809,5 @@
         if( error )
         {
-            nolock_printk("\n[PANIC] in %s : cannot initialise cluster %x",
+            printk("\n[PANIC] in %s : cannot initialise cluster %x",
                    __FUNCTION__ , local_cxy );
             hal_core_sleep();
@@ -764,5 +828,4 @@
     // STEP 2 : all CP0s initialize the process_zero descriptor.
     //          CP0 in cluster 0 initialises the IOPIC device.
-    //          all CP0s complete the distibuted LAPIC initialization.
     /////////////////////////////////////////////////////////////////////////////////
 
@@ -777,7 +840,4 @@
     if( (core_lid == 0) && (local_cxy == 0) ) iopic_init( info );
     
-    // all CP0s initialize their local LAPIC extension,
-    if( core_lid == 0 ) lapic_init( info );
-
     ////////////////////////////////////////////////////////////////////////////////
     if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), 
@@ -791,7 +851,11 @@
 
     ////////////////////////////////////////////////////////////////////////////////
-    // STEP 3 : all CP0s initialize their local chdev descriptors
-    //          (both internal devices and external devices).
+    // STEP 3 : all CP0s complete the distibuted LAPIC initialization.
+    //          all CP0s initialize their internal chdev descriptors
+    //          all CP0s initialize their local external chdev descriptors
     ////////////////////////////////////////////////////////////////////////////////
+
+    // all CP0s initialize their local LAPIC extension,
+    if( core_lid == 0 ) lapic_init( info );
 
     // CP0 scan the internal (private) peripherals,
@@ -818,10 +882,25 @@
 
     /////////////////////////////////////////////////////////////////////////////////
-    // STEP 4 : Alls cores initialize their private IDLE thread.
+    // STEP 4 : All cores enable IPI (Inter Procesor Interrupt),
+    //          Alh cores initialize IDLE thread.
     //          Only CP0 in cluster 0 creates the VFS root inode.
     //          It access the boot device to initialize the file system context.
     /////////////////////////////////////////////////////////////////////////////////
 
-    // all cores create idle thread descriptor
+    if( CONFIG_KINIT_DEBUG ) chdev_dir_display();
+    
+    // All cores enable the shared IPI channel
+
+// @@@
+    hal_set_ebase( 0x1000 );
+// @@@
+
+    dev_pic_enable_ipi();
+    hal_enable_irq( &status );
+
+    kinit_dmsg("\n[INFO] %s : IRQs enabled for core[%x,%d] / SR = %x\n", 
+               __FUNCTION__ , local_cxy , core_lid , hal_get_sr() );
+
+    // all cores create the idle thread descriptor
     error = thread_kernel_init( thread,
                                 THREAD_IDLE,
@@ -831,5 +910,5 @@
     if( error )
     {
-        nolock_printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",
+        printk("\n[PANIC] in %s : core[%x][%d] cannot initialize idle thread\n",
                       __FUNCTION__ , local_cxy , core_lid );
         hal_core_sleep();
@@ -860,6 +939,6 @@
             fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
 
-            nolock_assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
-                           "cannot create FATFS context in cluster 0\n" );
+            assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
+                    "cannot create FATFS context in cluster 0\n" );
 
             // 2. access boot device to initialize FATFS context
@@ -883,6 +962,6 @@
                                       &vfs_root_inode_xp );                // return
 
-            nolock_assert( (error == 0) , __FUNCTION__ , 
-                           "cannot create VFS root inode\n" );
+            assert( (error == 0) , __FUNCTION__ , 
+                    "cannot create VFS root inode\n" );
 
             // 5. initialize VFS context for FAT in cluster 0
@@ -896,5 +975,5 @@
         else
         {
-            nolock_printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );
+            printk("\n[PANIC] in %s : root FS must be FATFS\n", __FUNCTION__ );
             hal_core_sleep();
         }
@@ -931,6 +1010,6 @@
             fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
 
-            nolock_assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
-                           "cannot create FATFS context\n" );
+            assert( (fatfs_ctx != NULL) , __FUNCTION__ ,
+                    "cannot create FATFS context\n" );
 
             // get local pointer on VFS context for FATFS
@@ -965,5 +1044,5 @@
     /////////////////////////////////////////////////////////////////////////////////
 
-    if( (core_lid ==  0) && (local_cxy == 0) ) 
+//    if( (core_lid ==  0) && (local_cxy == 0) ) 
     kinit_dmsg("\n[INFO] %s exit barrier 5 at cycle %d : VFS OK in all clusters\n",
                __FUNCTION__, (uint32_t)hal_time_stamp());
@@ -986,6 +1065,6 @@
         devfs_ctx_t * devfs_ctx = devfs_ctx_alloc();
 
-        nolock_assert( (devfs_ctx != NULL) , __FUNCTION__ ,
-                       "cannot create DEVFS context in cluster IO\n");
+        assert( (devfs_ctx != NULL) , __FUNCTION__ ,
+                "cannot create DEVFS context in cluster IO\n");
 
         // register DEVFS root and external directories
@@ -993,4 +1072,6 @@
     }    
 
+printk("\n@@@ %s : cluster %x reach barrier 6\n", __FUNCTION__ , local_cxy );
+
     /////////////////////////////////////////////////////////////////////////////////
     if( core_lid == 0 ) remote_barrier( XPTR( io_cxy , &global_barrier ), 
@@ -999,5 +1080,5 @@
     /////////////////////////////////////////////////////////////////////////////////
 
-    if( (core_lid ==  0) && (local_cxy == 0) ) 
+//    if( (core_lid ==  0) && (local_cxy == 0) ) 
     kinit_dmsg("\n[INFO] %s exit barrier 6 at cycle %d : DEVFS OK in cluster IO\n",
                __FUNCTION__, (uint32_t)hal_time_stamp());
@@ -1071,5 +1152,5 @@
         print_banner( (info->x_size * info->y_size) , info->cores_nr );
 
-        kinit_dmsg("\n\n*** memory fooprint of main kernet objects ***\n"
+        kinit_dmsg("\n\n*** memory fooprint for main kernet objects ***\n\n"
                    " - thread descriptor  : %d bytes\n"
                    " - process descriptor : %d bytes\n"
@@ -1114,5 +1195,5 @@
     }
 
-    // each core activates its private PTI IRQ
+    // each core activates its private TICK IRQ
     dev_pic_enable_timer( CONFIG_SCHED_TICK_PERIOD );
 
