Index: trunk/kernel/kern/kernel_init.c
===================================================================
--- trunk/kernel/kern/kernel_init.c	(revision 583)
+++ trunk/kernel/kern/kernel_init.c	(revision 601)
@@ -159,6 +159,6 @@
 
     "CLUSTER_PREFTBL",       // 21
+
     "PPM_DIRTY",             // 22
-
     "CLUSTER_LOCALS",        // 23
     "CLUSTER_COPIES",        // 24
@@ -166,16 +166,17 @@
     "PROCESS_USERSYNC",      // 26
     "PROCESS_FDARRAY",       // 27
-
-    "MAPPER_STATE",          // 28
+    "FATFS_FREE",            // 28
+
     "PROCESS_THTBL",         // 29
 
-    "PROCESS_CWD",           // 30
-    "VFS_INODE",             // 31
-    "VFS_FILE",              // 32
-    "VMM_VSL",               // 33
-    "VMM_GPT",               // 34
+    "MAPPER_STATE",          // 30
+    "PROCESS_CWD",           // 31
+    "VFS_INODE",             // 32
+    "VFS_FILE",              // 33
+    "VMM_VSL",               // 34
+    "VMM_GPT",               // 35
 };        
 
-// these debug variables are used to analyse the sys_read() and sys_write() syscalls timing
+// debug variables to analyse the sys_read() and sys_write() syscalls timing
 
 #if DEBUG_SYS_READ
@@ -417,5 +418,5 @@
 #if( DEBUG_KERNEL_INIT & 0x1 )
 if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[DBG] %s : created MMC in cluster %x / chdev = %x\n",
+printk("\n[%s] : created MMC in cluster %x / chdev = %x\n",
 __FUNCTION__ , local_cxy , chdev_ptr );
 #endif
@@ -451,5 +452,5 @@
 #if( DEBUG_KERNEL_INIT & 0x1 )
 if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[DBG] %s : created DMA[%d] in cluster %x / chdev = %x\n",
+printk("\n[%s] : created DMA[%d] in cluster %x / chdev = %x\n",
 __FUNCTION__ , channel , local_cxy , chdev_ptr );
 #endif
@@ -611,5 +612,5 @@
 #if( DEBUG_KERNEL_INIT & 0x1 )
 if( hal_time_stamp() > DEBUG_KERNEL_INIT )
-printk("\n[DBG] %s : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
+printk("\n[%s] : create chdev %s / channel = %d / rx = %d / cluster %x / chdev = %x\n",
 __FUNCTION__ , chdev_func_str( func ), channel , rx , local_cxy , chdev );
 #endif
@@ -779,7 +780,7 @@
 
 #if( DEBUG_KERNEL_INIT & 0x1 )
-if( hal_tim_stamp() > DEBUG_KERNEL_INIT )
+if( hal_time_stamp() > DEBUG_KERNEL_INIT )
 {
-    printk("\n[DBG] %s created PIC chdev in cluster %x at cycle %d\n",
+    printk("\n[%s] created PIC chdev in cluster %x at cycle %d\n",
     __FUNCTION__ , local_cxy , (uint32_t)hal_time_stamp() );
     dev_pic_inputs_display();
@@ -969,5 +970,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 0 : TXT0 initialized / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 0 : TXT0 initialized / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1011,5 +1012,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 1 : clusters initialised / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 1 : clusters initialised / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1038,5 +1039,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 2 : PIC initialised / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 2 : PIC initialised / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1071,5 +1072,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 3 : all chdev initialised / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 3 : all chdevs initialised / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1115,5 +1116,5 @@
         if( CONFIG_VFS_ROOT_IS_FATFS )
         {
-            // 1. allocate memory for FATFS context in cluster 0
+            // 1. allocate memory for FATFS context extension in cluster 0
             fatfs_ctx_t * fatfs_ctx = fatfs_ctx_alloc();
 
@@ -1134,17 +1135,8 @@
             uint32_t total_clusters   = fatfs_ctx->fat_sectors_count << 7;
  
-            // 4. initialize the FATFS entry in the vfs_context[] array 
-            vfs_ctx_init( FS_TYPE_FATFS,                               // fs type
-                          0,                                           // attributes: unused 
-	                      total_clusters,                
-	                      cluster_size,
-	                      vfs_root_inode_xp,                           // VFS root
-                          fatfs_ctx );                                 // extend
-
-            // 5. create VFS root inode in cluster 0
+            // 4. create VFS root inode in cluster 0
             error = vfs_inode_create( XPTR_NULL,                           // dentry_xp
                                       FS_TYPE_FATFS,                       // fs_type
                                       INODE_TYPE_DIR,                      // inode_type
-                                      (void *)(intptr_t)root_dir_cluster,  // extend
                                       0,                                   // attr
                                       0,                                   // rights
@@ -1159,17 +1151,17 @@
             }
 
-            // 6. update the FATFS entry in vfs_context[] array
-            fs_context[FS_TYPE_FATFS].vfs_root_xp = vfs_root_inode_xp;
-
-            // 7. check FATFS initialization
-            vfs_ctx_t   * vfs_ctx = &fs_context[FS_TYPE_FATFS];
-
-            if( ((fatfs_ctx_t *)vfs_ctx->extend)->sectors_per_cluster != 8 )
-            {
-                printk("\n[PANIC] in %s : illegal FATFS context in cluster 0\n",
-                __FUNCTION__ );
-                hal_core_sleep();
-            }
-                
+            // 5. update FATFS root inode extension  
+            cxy_t         vfs_root_cxy = GET_CXY( vfs_root_inode_xp );
+            vfs_inode_t * vfs_root_ptr = GET_PTR( vfs_root_inode_xp );
+            hal_remote_spt( XPTR( vfs_root_cxy , &vfs_root_ptr->extend ), 
+                            (void*)(intptr_t)root_dir_cluster );
+
+            // 6. initialize the generic VFS context for FATFS 
+            vfs_ctx_init( FS_TYPE_FATFS,                               // fs type
+                          0,                                           // attributes: unused 
+	                      total_clusters,                              // number of clusters
+	                      cluster_size,                                // bytes
+	                      vfs_root_inode_xp,                           // VFS root
+                          fatfs_ctx );                                 // extend
         }
         else
@@ -1193,5 +1185,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 4 : VFS root initialized in cluster 0 / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 4 : VFS root initialized in cluster 0 / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1262,5 +1254,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 1) ) 
-printk("\n[DBG] %s : exit barrier 5 : VFS root initialized in cluster 1 / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 5 : VFS root initialized in cluster 1 / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1311,5 +1303,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 6 : DEVFS root initialized in cluster 0 / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 6 : DEVFS root initialized in cluster 0 / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1348,5 +1340,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 7 : DEV initialized in cluster 0 / sr %x / cycle %d\n",
+printk("\n[%s] : exit barrier 7 : DEV initialized in cluster 0 / sr %x / cycle %d\n",
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1374,5 +1366,5 @@
 #if DEBUG_KERNEL_INIT
 if( (core_lid ==  0) & (local_cxy == 0) ) 
-printk("\n[DBG] %s : exit barrier 8 : process init created / sr %x / cycle %d\n", 
+printk("\n[%s] : exit barrier 8 : process init created / sr %x / cycle %d\n", 
 __FUNCTION__, (uint32_t)hal_get_sr(), (uint32_t)hal_get_cycles() );
 #endif
@@ -1445,5 +1437,5 @@
 
 #if DEBUG_KERNEL_INIT
-printk("\n[DBG] %s : thread %x on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
+printk("\n[%s] : thread %x on core[%x,%d] jumps to thread_idle_func() / cycle %d\n",
 __FUNCTION__ , CURRENT_THREAD , local_cxy , core_lid , (uint32_t)hal_get_cycles() );
 #endif
