Index: trunk/boot/tsar_mips32/boot.c
===================================================================
--- trunk/boot/tsar_mips32/boot.c	(revision 623)
+++ trunk/boot/tsar_mips32/boot.c	(revision 624)
@@ -25,6 +25,5 @@
 /****************************************************************************
  * This file contains the ALMOS-MKH. boot-loader for the TSAR architecture. *
- *                                                                          *
- * It supports a clusterised, shared memory, multi-processor architecture,  *
+ * that is a clusterised, shared memory, multi-processor architecture,      *
  * where each processor core is identified by a composite index [cxy,lid]   *
  * with one physical memory bank per cluster.                               *
@@ -86,5 +85,5 @@
 // the Boot Page Table contains two PTE1, and should be aligned on 8 Kbytes 
 
-uint32_t                        boot_pt[2] __attribute__((aligned(2048)));
+uint32_t                        boot_pt[2] __attribute__((aligned(0x2000)));
 
 // synchronization variables. 
@@ -101,8 +100,6 @@
 uint32_t                        seg_kdata_base;   // kdata segment base address
 uint32_t                        seg_kdata_size;   // kdata segment size (bytes) 
-uint32_t                        seg_kentry_base;  // kcode segment base address
-uint32_t                        seg_kentry_size;  // kcode segment size (bytes) 
-
-uint32_t                        kernel_entry;    // kernel entry point
+
+uint32_t                        kernel_entry;     // kernel_init() function
 
 // Functions 
@@ -147,12 +144,11 @@
 static void boot_archinfo_load( void )
 {
-    archinfo_header_t* header = (archinfo_header_t*)ARCHINFO_BASE;  
+    archinfo_header_t * header = (archinfo_header_t*)ARCHINFO_BASE;  
     
     // Load file into memory
     if (boot_fat32_load(ARCHINFO_PATHNAME, ARCHINFO_BASE, ARCHINFO_MAX_SIZE))
     {
-        boot_printf("\n[BOOT ERROR]: boot_archinfo_load(): "
-        "<%s> file not found\n",
-        ARCHINFO_PATHNAME);
+        boot_printf("\n[BOOT ERROR]in %s : <%s> file not found\n",
+        __FUNCTION__, ARCHINFO_PATHNAME);
         boot_exit();
     }
@@ -175,7 +171,6 @@
 /**************************************************************************************
  * This function loads the 'kernel.elf' file into the boot cluster memory buffer,
- * analyzes it, and places the three kcode, kentry, kdata segments at their final
- * physical adresses (defined the .elf file).        
- * It set the global variables defining the kernel layout.
+ * analyzes it, and places the kcode and kdata segments at their final physical
+ * adresses (defined the .elf file), and set the kernel layout global variables.
  *************************************************************************************/
 static void boot_kernel_load( void )
@@ -192,5 +187,4 @@
     bool_t       kcode_found;     // kcode segment found.
     bool_t       kdata_found;     // kdata segment found.
-    bool_t       kentry_found;    // kentry segment found.
     uint32_t     seg_id;          // iterator for segments loop.
 
@@ -233,5 +227,4 @@
     kcode_found  = false;
     kdata_found  = false;
-    kentry_found = false;
     for (seg_id = 0; seg_id < segments_nb; seg_id++) 
     {
@@ -265,10 +258,7 @@
 
             // Note: we suppose that the 'kernel.elf' file contains exactly
-            // three loadable segments ktext, kentry, & kdata:
-            // - the kcode segment is read-only and base == KCODE_BASE
-            // - the kentry segment is read-only and base == KENTRY_BASE
-
-            if( ((program_header[seg_id].p_flags & PF_W) == 0) &&
-                 (program_header[seg_id].p_paddr == KCODE_BASE) )     // kcode segment
+            // two loadable segments : kcode & kdata
+
+            if( program_header[seg_id].p_paddr == KCODE_BASE )     // kcode segment
             {
                 if( kcode_found )
@@ -283,18 +273,4 @@
                 seg_kcode_base = seg_paddr;
                 seg_kcode_size = seg_memsz;
-            }
-            else if( program_header[seg_id].p_paddr == KENTRY_BASE ) // kentry segment
-            {
-                if( kentry_found )
-                {
-                    boot_printf("\n[BOOT_ERROR] in %s for file %s :\n"
-                    "   two kentry segments found\n",
-                    __FUNCTION__ , KERNEL_PATHNAME );
-                    boot_exit();
-                } 
-
-                kentry_found     = true;
-                seg_kentry_base = seg_paddr;
-                seg_kentry_size = seg_memsz;
             }
             else                                                    // kdata segment
@@ -322,10 +298,4 @@
         boot_exit();
     }
-    if( kentry_found == false )
-    {
-        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry not found\n",
-        __FUNCTION__ , KERNEL_PATHNAME );
-        boot_exit();
-    }
     if( kdata_found == false )
     {
@@ -336,11 +306,4 @@
 
     // check segments sizes
-    if( seg_kentry_size > KENTRY_MAX_SIZE )
-    {
-        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry too large\n",
-        __FUNCTION__ , KERNEL_PATHNAME );
-        boot_exit();
-    }
-
     if( (seg_kcode_size + seg_kdata_size) > KCODE_MAX_SIZE )
     {
@@ -386,5 +349,10 @@
     boot_device_t      * boot_dev; 
 
-    // get pointer on ARCHINFO header  and on the four arch_info arrays
+ #if DEBUG_BOOT_INFO
+boot_printf("\n[BOOT INFO] %s : enter at cycle %d\n",
+__FUNCTION__ , boot_get_proctime() );
+#endif
+
+   // get pointer on ARCHINFO header  and on the four arch_info arrays
     header       = (archinfo_header_t*)ARCHINFO_BASE;
     core_base    = archinfo_get_core_base   (header);
@@ -406,6 +374,4 @@
     boot_info->kdata_base  = seg_kdata_base;
     boot_info->kdata_size  = seg_kdata_size;
-    boot_info->kentry_base = seg_kentry_base;
-    boot_info->kentry_size = seg_kentry_size;
 
     // loop on arch_info clusters to build cluster_info[][] array
@@ -806,6 +772,6 @@
         if (cxy == 0)
         {
-            boot_printf("\n[BOOT] core[%x,%d] enters at cycle %d\n",
-                        cxy , lid , boot_get_proctime() );
+            boot_printf("\n[BOOT] core[%x,%d] active at cycle %d\n",
+            cxy, lid, boot_get_proctime() );
 
             // Initialize IOC driver 
@@ -858,11 +824,9 @@
             boot_check_core(boot_info, lid);
 
-// TO BE DONE 
-// core[0][0] identity maps two big pages for the boot and kernel code,
-// boot_page_table_init( 0 );
-
-// TO BE DONE
-// core[0][0] activates the instruction MMU to use the local copy of boot code
-// boot_activate_ins_mmu( 0 );
+            // identity maps two big pages for the boot and kernel code,
+            boot_page_table_init( 0 );
+
+            // activate the instruction MMU to use the local copy of boot code
+            boot_activate_ins_mmu( 0 );
 
             // Activate other core[cxy][0] / get number of activated cores
@@ -889,5 +853,9 @@
             // but all cores must access the code stored in cluster 0 
 
-            // Each CP0 copies the boot code (data and instructions)
+#if DEBUG_BOOT_MULTI
+boot_printf("\n[BOOT] core[%x,%d] active at cycle %d\n",
+cxy, lid, boot_get_proctime() );
+#endif
+            // Each core[cxy][0] copies the boot code (data and instructions)
             // from the cluster 0 to the local cluster.
             boot_remote_memcpy( XPTR( cxy           , BOOT_BASE ),
@@ -899,10 +867,9 @@
             cxy , lid , boot_get_proctime() );
 
-// TO BE DONE 
-// Each core identity maps two big pages for the boot and kernel code,
-// boot_page_table_init( cxy );
-
-// Each core activates the instruction MMU to use the local copy of boot code
-// boot_activate_ins_mmu( cxy );
+            // identity maps two big pages for the boot and kernel code,
+            boot_page_table_init( cxy );
+
+            // activate the instruction MMU to use the local copy of boot code
+            boot_activate_ins_mmu( cxy );
 
             // Each CP0 copies the arch_info.bin into the local memory.
@@ -914,5 +881,5 @@
             cxy , lid , boot_get_proctime() );
 
-            // Each CP0 copies the kcode segment into local memory 
+            // copy the kcode segment into local memory 
             boot_remote_memcpy( XPTR( cxy           , seg_kcode_base ),
                                 XPTR( BOOT_CORE_CXY , seg_kcode_base ),
@@ -924,10 +891,4 @@
                                 seg_kdata_size );
 
-            // [TO BE REMOVED<D-°>
-            // Each CP0 copies the kentry segment into local memory
-            boot_remote_memcpy( XPTR( cxy           , seg_kentry_base ),
-                                XPTR( BOOT_CORE_CXY , seg_kentry_base ),
-                                seg_kentry_size );
-
             boot_printf("\n[BOOT] core[%x,%d] replicated kernel code at cycle %d\n",
             cxy , lid , boot_get_proctime() );
@@ -965,7 +926,10 @@
          **********************************************************************/
 
-// TO BE DONE
-// each core activate the instruction MMU to use the local copy of the boot code
-// boot_activate_ins_mmu( cxy );
+#if DEBUG_BOOT_MULTI
+boot_printf("\n[BOOT] core[%x,%d] active at cycle %d\n",
+cxy, lid, boot_get_proctime() );
+#endif
+        // activate the instruction MMU to use the local copy of the boot code
+        boot_activate_ins_mmu( cxy );
 
         // Get local boot_info_t structure base address.
@@ -979,15 +943,18 @@
     }
 
-    // the "kernel_entry" global variable, set by boot_kernel_load() define
-    // the adress of the kernel_init() function.
+    // All cores enter the kernel_init() function. The address is contained in 
+    // the "kernel_entry" global variable, set by boot_kernel_load() function.
     // Each core initialise the following registers before jumping to kernel: 
     // - gr_29    : stack pointer / kernel stack allocated in idle thread descriptor,
     // - c0_sr    : status register / reset BEV bit
     // - gr_04    : kernel_init() argument / pointer on boot_info structure
-    // - c0_ebase : kentry_base 
-
-    // compute "sp" from base address of idle thread descriptors array and lid.
     // The array of idle-thread descriptors is allocated in the kdata segment,
     // just after the boot_info structure.
+
+#if DEBUG_BOOT_MULTI
+boot_printf("\n[BOOT] core[%x,%d] jump to kernel_init = %x at cycle %d\n",
+cxy, lid, __FUNCTION__, kernel_entry, boot_get_proctime() );
+#endif
+
     uint32_t base;
     uint32_t offset = sizeof( boot_info_t );
@@ -998,11 +965,4 @@
     uint32_t sp = base + ((lid + 1) * CONFIG_THREAD_DESC_SIZE) - 16;
 
-    // get "ebase" from kerneL_info
-    uint32_t ebase = boot_info->kentry_base;
-
-// TO BE DONE
-// The cp0_ebase will not be set by the assenbly code below
-// when the kentry segment will be removed => done in kernel init
-
     asm volatile( "mfc0  $27,  $12           \n"
                   "lui   $26,  0xFFBF        \n"
@@ -1012,10 +972,8 @@
                   "move  $4,   %0            \n"
                   "move  $29,  %1            \n"
-                  "mtc0  %2,   $15,  1       \n"
-                  "jr    %3                  \n"
+                  "jr    %2                  \n"
                   :
                   : "r"(boot_info) ,
                     "r"(sp) ,
-                    "r"(ebase) ,
                     "r"(kernel_entry) 
                   : "$26" , "$27" , "$29" , "$4" );
