Index: trunk/kernel/kern/kernel_init.c
===================================================================
--- trunk/kernel/kern/kernel_init.c	(revision 669)
+++ trunk/kernel/kern/kernel_init.c	(revision 683)
@@ -3,5 +3,5 @@
  *
  * Authors :  Mohamed Lamine Karaoui (2015)
- *            Alain Greiner  (2016,2017,2018,2019,2020)
+ *            Alain Greiner          (2016,2017,2018,2019,2020)
  *
  * Copyright (c) Sorbonne Universites
@@ -46,4 +46,5 @@
 #include <memcpy.h>
 #include <ppm.h>
+#include <kcm.h>
 #include <page.h>
 #include <chdev.h>
@@ -379,13 +380,4 @@
         if( func == DEV_FUNC_MMC )  
         {
-
-            // check channels
-            if( channels != 1 )
-            {
-                printk("\n[PANIC] in %s : MMC device must be single channel\n",
-                __FUNCTION__ );
-                hal_core_sleep();
-            }
-
             // create chdev in local cluster
             chdev_ptr = chdev_create( func,
@@ -394,6 +386,4 @@
                                       false,      // direction
                                       base );
-
-            // check memory
             if( chdev_ptr == NULL )
             {
@@ -403,4 +393,9 @@
             }
             
+#if (DEBUG_KERNEL_INIT & 0x1)
+if( hal_time_stamp() > DEBUG_KERNEL_INIT )
+printk("\n[%s] created chdev[%x,%x] for MMC\n",
+__FUNCTION__ , local_cxy , chdev_ptr );
+#endif
             // make MMC specific initialisation
             dev_mmc_init( chdev_ptr );
@@ -423,5 +418,5 @@
 #if( DEBUG_KERNEL_INIT & 0x1 )
 if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[%s] : created MMC in cluster %x / chdev = %x\n",
+printk("\n[%s] initialised chdev[%x,%x] for MMC\n",
 __FUNCTION__ , local_cxy , chdev_ptr );
 #endif
@@ -439,6 +434,4 @@
                                           false,     // direction
                                           base );
-
-                // check memory
                 if( chdev_ptr == NULL )
                 {
@@ -448,4 +441,9 @@
                 }
             
+#if (DEBUG_KERNEL_INIT & 0x1)
+if( hal_time_stamp() > DEBUG_KERNEL_INIT )
+printk("\n[%s] cxy %x : created chdev[%x,%x] for DMA[%d]\n",
+__FUNCTION__ , local_cxy , chdev_ptr , channel );
+#endif
                 // make DMA specific initialisation
                 dev_dma_init( chdev_ptr );     
@@ -457,6 +455,6 @@
 #if( DEBUG_KERNEL_INIT & 0x1 )
 if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[%s] : created DMA[%d] in cluster %x / chdev = %x\n",
-__FUNCTION__ , channel , local_cxy , chdev_ptr );
+printk("\n[%s] initialised chdev[%x,%x] for DMA[%d]\n",
+__FUNCTION__ , local_cxy , chdev_ptr , channel );
 #endif
             }
@@ -471,7 +469,7 @@
 // These chdev descriptors are distributed on all clusters, using a modulo on a global 
 // index, identically computed in all clusters.
-// This function is executed in all clusters by the core[0] core, that computes a global index
-// for all external chdevs. Each core[0] core creates only the chdevs that must be placed in 
-// the local cluster, because the global index matches the local index. 
+// This function is executed in all clusters by the core[0], that computes a global index
+// for all external chdevs. Each core[0] core creates only the chdevs that must be placed  
+// in the local cluster, because the global index matches the local index. 
 // The relevant entries in all copies of the devices directory are initialised.
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -499,5 +497,5 @@
     dev_tbl     = info->ext_dev;
 
-    // initializes global index (PIC is already placed in cluster 0
+    // initializes global index (PIC is already placed in cluster 0)
     ext_chdev_gid = 1;
 
@@ -529,6 +527,9 @@
 
         // check external device functionnal type
-        if( (func != DEV_FUNC_IOB) && (func != DEV_FUNC_IOC) && (func != DEV_FUNC_TXT) &&
-            (func != DEV_FUNC_NIC) && (func != DEV_FUNC_FBF) )
+        if( (func != DEV_FUNC_IOB) && 
+            (func != DEV_FUNC_IOC) && 
+            (func != DEV_FUNC_TXT) &&
+            (func != DEV_FUNC_NIC) && 
+            (func != DEV_FUNC_FBF) )
         {
             printk("\n[PANIC] in %s : undefined peripheral type\n",
@@ -537,5 +538,5 @@
         }
 
-        // loops on channels
+        // loop on channels
         for( channel = 0 ; channel < channels ; channel++ )
         {
@@ -547,5 +548,5 @@
 
                 // all kernel instances compute the target cluster for all chdevs,
-                // computing the global index ext_chdev_gid[func,channel,direction]
+                // and the global index ext_chdev_gid[func,channel,direction]
                 cxy_t target_cxy;
                 while( 1 )
@@ -568,10 +569,4 @@
                 if( target_cxy == local_cxy )
                 {
-
-#if( DEBUG_KERNEL_INIT & 0x3 )
-if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[%s] : found chdev %s / channel = %d / rx = %d / cluster %x\n",
-__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy );
-#endif
                     chdev = chdev_create( func,
                                           impl,
@@ -587,4 +582,9 @@
                     }
 
+#if (DEBUG_KERNEL_INIT & 0x1)
+if( hal_time_stamp() > DEBUG_KERNEL_INIT )
+printk("\n[%s] created chdev[%x,%x] for %s[%d] / is_rx %d\n",
+__FUNCTION__ , local_cxy , chdev , chdev_func_str(func) , channel , rx );
+#endif
                     // make device type specific initialisation
                     if     ( func == DEV_FUNC_IOB ) dev_iob_init( chdev );
@@ -621,9 +621,10 @@
                     }
 
-#if( DEBUG_KERNEL_INIT & 0x3 )
+#if( DEBUG_KERNEL_INIT & 1 )
 if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[%s] : created chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
-__FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev );
-#endif
+printk("\n[%s] initialised chdev[%x,%x] for %s\n",
+__FUNCTION__ , local_cxy, chdev , chdev->name );
+#endif
+
                 }  // end if match
 
@@ -637,5 +638,5 @@
 
 ///////////////////////////////////////////////////////////////////////////////////////////
-// This function is called by core[0] in cluster 0 to allocate memory and initialize the PIC
+// This function is called by core[0][0] to allocate memory and initialize the PIC
 // device, namely the informations attached to the external IOPIC controller, that
 // must be replicated in all clusters (struct iopic_input).
@@ -1102,5 +1103,4 @@
     // and allocates memory for the corresponding chdev descriptors.
     if( core_lid == 0 ) internal_devices_init( info );
-        
 
     // All core[0]s contribute to initialise external peripheral chdev descriptors.
@@ -1494,5 +1494,5 @@
                    " - core descriptor    : %d bytes\n"
                    " - scheduler          : %d bytes\n"
-                   " - socket             : %d bytes\n"
+                   " - socket descriptor  : %d bytes\n"
                    " - rpc fifo           : %d bytes\n"
                    " - page descriptor    : %d bytes\n"
@@ -1501,5 +1501,4 @@
                    " - ppm manager        : %d bytes\n"
                    " - kcm manager        : %d bytes\n"
-                   " - khm manager        : %d bytes\n"
                    " - vmm manager        : %d bytes\n"
                    " - vfs inode          : %d bytes\n"
@@ -1529,5 +1528,4 @@
                    sizeof( ppm_t              ),
                    sizeof( kcm_t              ),
-                   sizeof( khm_t              ),
                    sizeof( vmm_t              ),
                    sizeof( vfs_inode_t        ),
@@ -1546,6 +1544,9 @@
 #endif
 
+    // number of cycles per TICK (depends on the actual system clock frequency
+    uint32_t cycles_per_tick = cluster->sys_clk / CONFIG_SCHED_TICKS_PER_SECOND;
+
     // each core activates its private TICK IRQ
-    dev_pic_enable_timer( CONFIG_SCHED_TICK_MS_PERIOD );
+    dev_pic_enable_timer( cycles_per_tick );
 
     /////////////////////////////////////////////////////////////////////////////////
