Index: trunk/softs/tsar_boot/src/reset_elf_loader.c
===================================================================
--- trunk/softs/tsar_boot/src/boot_elf_loader.c	(revision 570)
+++ trunk/softs/tsar_boot/src/reset_elf_loader.c	(revision 586)
@@ -1,21 +1,22 @@
 /**
- * \file    : boot_elf_loader.c
+ * \file    : reset_elf_loader.c
  * \date    : August 2012
  * \author  : Cesar Fuguet
  *
- * This file defines an elf file loader which reads an executable elf file
- * starting at a sector passed as argument of a disk and copy the different
+ * This file defines an elf file loader which reads an executable .elf file
+ * starting at a sector passed as argument on a disk and copy the different
  * ELF program segments in the appropriate memory address using as information
- * the virtual address read from the elf file.
+ * the virtual address read from the .elf file.
  */
 
-#include <boot_ioc.h>
+#include <reset_ioc.h>
 #include <elf-types.h>
-#include <boot_tty.h>
-#include <boot_utils.h>
+#include <reset_tty.h>
+#include <reset_utils.h>
 #include <defs.h>
 
-#if (BOOT_DEBUG == 1)
-static char const * const init_state_str[] = {
+#if (RESET_DEBUG == 1)
+static char const * const init_state_str[] = 
+{
     "ELF_HEADER_STATE",
     "ELF_PROGRAM_HEADER_STATE",
@@ -26,10 +27,12 @@
 #endif
 
-unsigned char boot_elf_loader_buffer[512] __attribute__((aligned(CACHE_LINE_SIZE)));
-
-void * boot_elf_loader(unsigned int lba)
+unsigned char reset_elf_loader_buffer[512] __attribute__((aligned(CACHE_LINE_SIZE)));
+
+/////////////////////////////////////////////////////////////////////////////////////
+void * reset_elf_loader(unsigned int lba)
+/////////////////////////////////////////////////////////////////////////////////////
 {
     /*
-     * Temporary variables used by the boot loader
+     * Temporary variables used by the loader
      */
     Elf32_Ehdr      elf_header;
@@ -67,10 +70,12 @@
     init_state = ELF_HEADER_STATE;
 
-#if (BOOT_DEBUG == 1)
+#if (RESET_DEBUG == 1)
     elf_loader_t init_state_debug;
     init_state_debug = ELF_END_STATE;
 #endif
 
-    boot_puts("Starting boot_elf_loader function...\n\r");
+    reset_puts("\n[RESET] Start reset_elf_loader at cycle ");
+    reset_putd( proctime() );
+    reset_puts("\n");
 
     nb_block     = lba;
@@ -86,15 +91,10 @@
         if (nb_available == 0 )
         {
-            buffer_ptr = &boot_elf_loader_buffer[0];
-
-            if (boot_ioc_read(nb_block , buffer_ptr, 1))
+            buffer_ptr = &reset_elf_loader_buffer[0];
+
+            if (reset_ioc_read(nb_block , buffer_ptr, 1))
             {
-                boot_puts (
-                    "ERROR: "
-                    "boot_ioc_read() failed"
-                    "\n"
-                );
-
-                boot_exit();
+                reset_puts ("[RESET ERROR] reset_ioc_read() failed\n");
+                reset_exit();
             }
 
@@ -106,10 +106,10 @@
         offset  +=  nb_read;
 
-#if (BOOT_DEBUG == 1)
+#if (RESET_DEBUG == 1)
         if (init_state != init_state_debug)
         {
-            boot_puts("\ninit_state = ");
-            boot_puts(init_state_str[init_state]);
-            boot_puts("\n");
+            reset_puts("\ninit_state = ");
+            reset_puts(init_state_str[init_state]);
+            reset_puts("\n");
             init_state_debug = init_state;
         }
@@ -129,5 +129,4 @@
                 {
                     nb_rest = elf_ehdr_ptr->e_phnum * elf_ehdr_ptr->e_phentsize;
-
                     /*
                      * Verification of ELF Magic Number
@@ -138,11 +137,6 @@
                          (elf_ehdr_ptr->e_ident[EI_MAG3] != ELFMAG3) )
                     {
-                        boot_puts(
-                            "ERROR: "
-                            "Input file does not use ELF format"
-                            "\n"
-                        );
-
-                        boot_exit();
+                        reset_puts("[RESET ERROR] boot-loader file is not an ELF format\n");
+                        reset_exit();
                     }
 
@@ -154,12 +148,6 @@
                     if (elf_ehdr_ptr->e_phnum > PHDR_ARRAY_SIZE)
                     {
-                        boot_puts(
-                            "ERROR: "
-                            "ELF PHDR table size is bigger than the allocated"
-                            "work space"
-                            "\n"
-                        );
-
-                        boot_exit();
+                        reset_puts("[RESET ERROR] ELF PHDR table size too large\n");
+                        reset_exit();
                     }
 
@@ -191,7 +179,7 @@
                         if(elf_phdr_ptr[pseg].p_type == PT_LOAD)
                         {
-#if (BOOT_DEBUG == 1)
-                            boot_puts("loadable segment found:\n");
-                            boot_print_elf_phdr(&elf_phdr_ptr[pseg]);
+#if (RESET_DEBUG == 1)
+                            reset_puts("loadable segment found:\n");
+                            reset_print_elf_phdr(&elf_phdr_ptr[pseg]);
 #endif
                             if (elf_phdr_ptr[pseg].p_offset < offset)
@@ -218,10 +206,6 @@
                     if (pseg == elf_ehdr_ptr->e_phnum)
                     {
-                        boot_puts(
-                            "ERROR: "
-                            "No PT_LOAD found"
-                            "\n"
-                        );
-                        boot_exit();
+                        reset_puts("[RESET ERROR] No PT_LOAD found\n");
+                        reset_exit();
                     }
 
@@ -270,10 +254,6 @@
                     (pseg_start <  0xBFC00000 && pseg_end   >  0xBFC10000))
                 {
-                    boot_puts(
-                        "ERROR: "
-                        "Program segment conflits with pre-loader memory space"
-                        "\n"
-                    );
-                    boot_exit();
+                    reset_puts("[RESET ERROR] conflict with pre-loader memory space\n");
+                    reset_exit();
                 }
 
@@ -304,9 +284,11 @@
                         elf_phdr_ptr[pseg].p_filesz ;
 
-                    memset(pseg_ptr, 0, pseg_remainder);
-
-                    boot_puts("Copied segment at address ");
-                    boot_putx(elf_phdr_ptr[pseg].p_vaddr);
-                    boot_puts("\n");
+//                  memset(pseg_ptr, 0, pseg_remainder);
+
+                    reset_puts("\n[RESET] Segment loaded : address = ");
+                    reset_putx(elf_phdr_ptr[pseg].p_vaddr);
+                    reset_puts(" / size = ");
+                    reset_putx(elf_phdr_ptr[pseg].p_filesz);
+                    reset_puts("\n");
 
                     /*
@@ -317,7 +299,7 @@
                         if(elf_phdr_ptr[pseg].p_type == PT_LOAD)
                         {
-#if (BOOT_DEBUG == 1)
-                            boot_puts("loadable segment found:\n");
-                            boot_print_elf_phdr(&elf_phdr_ptr[pseg]);
+#if (RESET_DEBUG == 1)
+                            reset_puts("loadable segment found:\n");
+                            reset_print_elf_phdr(&elf_phdr_ptr[pseg]);
 #endif
                             nb_rest = elf_phdr_ptr[pseg].p_offset - offset;
@@ -347,11 +329,9 @@
     }
 
-    boot_puts (
-        "Finishing boot_elf_loader function.\n"
-        "Entry point address: "
-    );
-
-    boot_putx(elf_ehdr_ptr->e_entry);
-    boot_puts("\n");
+    reset_puts("\n[RESET] Complete reset_elf_loader at cycle ");
+    reset_putd( proctime() );
+    reset_puts(" / boot entry = ");
+    reset_putx( (unsigned int)(elf_ehdr_ptr->e_entry) );
+    reset_puts("\n");
 
     return ((void *) elf_ehdr_ptr->e_entry);
