[BACK]Return to main.c CVS log [TXT][DIR] Up to [local] / prex-old / boot / common

Diff for /prex-old/boot/common/main.c between version 1.1.1.1.2.1 and 1.2

version 1.1.1.1.2.1, 2008/08/13 17:12:20 version 1.2, 2008/07/18 21:47:57
Line 36 
Line 36 
 #include <boot.h>  #include <boot.h>
 #include <ar.h>  #include <ar.h>
   
 #ifdef DEBUG  u_long load_base;       /* current load address */
 #define DPRINTF(a) printf a  u_long load_start;      /* start address for loading */
 #else  
 #define DPRINTF(a)  
 #endif  
   
 paddr_t load_base;      /* current load address */  
 paddr_t load_start;     /* start address for loading */  
 int nr_img;             /* number of module images */  int nr_img;             /* number of module images */
   
 struct boot_info *boot_info;     /* pointer to boot information. */  struct boot_info *boot_info;     /* pointer to boot information. */
Line 52 
Line 46 
  * Define memory block as reserved area.   * Define memory block as reserved area.
  */   */
 void  void
 reserve_memory(paddr_t start, size_t size)  reserve_memory(u_long start, size_t size)
 {  {
         int i;          int i;
         paddr_t mem_end;          u_long mem_end;
   
         DPRINTF(("reserved memory: start=%x size=%x\n", start, size));          printk("reserve_memory: start=%x size=%x\n", start, size);
   
         if (boot_info->main_mem.size == 0)          if (boot_info->main_mem.size == 0)
                 panic("bad mem size");                  panic("bad mem size");
Line 66 
Line 60 
         if (start > mem_end)          if (start > mem_end)
                 return;                  return;
         if (start + size > mem_end)          if (start + size > mem_end)
                 size = (size_t)(mem_end - start);                  size = mem_end - start;
   
         for (i = 0; i < NRESMEM; i++) {          for (i = 0; i < NRESMEM; i++) {
                 if (boot_info->reserved[i].size == 0) {                  if (boot_info->reserved[i].size == 0) {
Line 96 
Line 90 
         while (*c != '/' && *c != ' ')          while (*c != '/' && *c != ' ')
                 c++;                  c++;
         *c = '\0';          *c = '\0';
           printk("load_image hdr=%x module=%x name=%s\n",
         DPRINTF(("loading: hdr=%x module=%x name=%s\n",                 (int)hdr, (int)m, (char *)&m->name);
                  (int)hdr, (int)m, (char *)&m->name));  
   
         if (elf_load((char *)hdr + sizeof(struct ar_hdr), m))          if (elf_load((char *)hdr + sizeof(struct ar_hdr), m))
                 panic("Load error");                  panic("Load error");
         return 0;          return 0;
Line 122 
Line 114 
                 return;                  return;
   
         ram_disk = (struct mem_map *)&boot_info->ram_disk;          ram_disk = (struct mem_map *)&boot_info->ram_disk;
         ram_disk->start = (paddr_t)hdr + sizeof(struct ar_hdr);          ram_disk->start = (u_long)hdr + sizeof(struct ar_hdr);
         ram_disk->size = size;          ram_disk->size = size;
   
         reserve_memory(ram_disk->start, ram_disk->size);          reserve_memory(ram_disk->start, ram_disk->size);
   
         DPRINTF(("RAM disk base=%x size=%x\n", ram_disk->start,          printk("RAM disk base=%x size=%x\n", ram_disk->start, ram_disk->size);
                  ram_disk->size));  
 }  }
 #endif /* CONFIG_RAMDISK */  #endif /* CONFIG_RAMDISK */
   
Line 138 
Line 129 
  * It reads each module file image and copy it to the appropriate   * It reads each module file image and copy it to the appropriate
  * memory area. The image is built as generic archive (.a) file.   * memory area. The image is built as generic archive (.a) file.
  *   *
  * The image information is stored into the boot information area.   * The image information is strored into the boot information area.
  */   */
 static void  static void
 setup_image(void)  setup_image(void)
Line 159 
Line 150 
         /*          /*
          * Load kernel image           * Load kernel image
          */           */
         hdr = (char *)((paddr_t)magic + 8);          hdr = (char *)((u_long)magic + 8);
         if (load_image((struct ar_hdr *)hdr, &boot_info->kernel))          if (load_image((struct ar_hdr *)hdr, &boot_info->kernel))
                 panic("Can not load kernel");                  panic("Can not load kernel");
   
Line 169 
Line 160 
         len = atol((char *)&((struct ar_hdr *)hdr)->ar_size);          len = atol((char *)&((struct ar_hdr *)hdr)->ar_size);
         if (len == 0)          if (len == 0)
                 panic("Invalid OS image");                  panic("Invalid OS image");
         hdr = (char *)((paddr_t)hdr + sizeof(struct ar_hdr) + len);          hdr = (char *)((u_long)hdr + sizeof(struct ar_hdr) + len);
         if (load_image((struct ar_hdr *)hdr, &boot_info->driver))          if (load_image((struct ar_hdr *)hdr, &boot_info->driver))
                 panic("Can not load driver");                  panic("Can not load driver");
   
Line 183 
Line 174 
                 len = atol((char *)&((struct ar_hdr *)hdr)->ar_size);                  len = atol((char *)&((struct ar_hdr *)hdr)->ar_size);
                 if (len == 0)                  if (len == 0)
                         break;                          break;
                 hdr = (char *)((paddr_t)hdr + sizeof(struct ar_hdr) + len);                  hdr = (char *)((u_long)hdr + sizeof(struct ar_hdr) + len);
   
                 /* Pad to even boundary */                  /* Pad to even boundary */
                 hdr += ((paddr_t)hdr % 2);                  hdr += ((u_long)hdr % 2);
   
                 /* Check archive header */                  /* Check archive header */
                 if (strncmp((char *)&((struct ar_hdr *)hdr)->ar_fmag,                  if (strncmp((char *)&((struct ar_hdr *)hdr)->ar_fmag,
Line 210 
Line 201 
   
         boot_info->nr_tasks = i;          boot_info->nr_tasks = i;
   
   #if 0
         if (boot_info->nr_tasks == 0)          if (boot_info->nr_tasks == 0)
                 panic("No boot task found!");                  panic("No boot task found!");
   #endif
         /*          /*
          * Save information for boot modules.           * Save information for boot modules.
          * This includes kernel, driver, and boot tasks.           * This includes kernel, driver, and boot tasks.
Line 221 
Line 213 
         boot_info->modules.size = (size_t)(load_base - load_start);          boot_info->modules.size = (size_t)(load_base - load_start);
 }  }
   
 #ifdef DEBUG_BOOTINFO  #ifdef DEBUG_BOOT
 static void  static void
 dump_image(struct module *m)  dump_image(struct module *m)
 {  {
         printf("%s: entry=%x phys=%x size=%x text=%x data=%x textsz=%x datasz=%x bss=%x\n",          printk
                m->name, (int)m->entry, (int)m->phys, (int)m->size,              ("%s: entry=%x phys=%x size=%x text=%x data=%x textsz=%x datasz=%x bss=%x\n",
                (int)m->text, (int)m->data, (int)m->textsz,               m->name, (int)m->entry, (int)m->phys, (int)m->size,
                (int)m->datasz, (int)m->bsssz);               (int)m->text, (int)m->data, (int)m->textsz,
                (int)m->datasz, (int)m->bsssz);
 }  }
   
 static void  static void
Line 237 
Line 230 
         struct module *m;          struct module *m;
         int i;          int i;
   
         printf("main memory start=%x size=%x\n",          printk("main memory start=%x size=%x\n",
                (int)boot_info->main_mem.start,                 (int)boot_info->main_mem.start,
                (int)boot_info->main_mem.size);                 (int)boot_info->main_mem.size);
   
         for (i = 0; i < NRESMEM; i++) {          for (i = 0; i < NRESMEM; i++) {
                 if (boot_info->reserved[i].size != 0) {                  if (boot_info->reserved[i].size != 0) {
                         printf("reserved mem start=%x size=%x\n",                          printk("reserved mem start=%x size=%x\n",
                                (int)boot_info->reserved[i].start,                                 (int)boot_info->reserved[i].start,
                                (int)boot_info->reserved[i].size);                                 (int)boot_info->reserved[i].size);
                 }                  }
         }          }
         printf("ramdisk     start=%x size=%x\n",          printk("ramdisk     start=%x size=%x\n",
                (int)boot_info->ram_disk.start,                 (int)boot_info->ram_disk.start,
                (int)boot_info->ram_disk.size);                 (int)boot_info->ram_disk.size);
   
Line 267 
Line 260 
 void  void
 loader_main(void)  loader_main(void)
 {  {
         paddr_t kernel_entry;          u_int kernel_entry;
   
         DPRINTF(("Prex Boot Loader V1.00\n"));          printk("Prex Boot Loader V1.00\n");
   
         load_base = 0;          load_base = 0;
         load_start = 0;          load_start = 0;
         nr_img = 0;          nr_img = 0;
   
         /*  
          * Get machine-dependent information.  
          */  
         setup_bootinfo(&boot_info);          setup_bootinfo(&boot_info);
   
         /*  
          * Load program image.  
          */  
         setup_image();          setup_image();
   #ifdef DEBUG_BOOT
 #ifdef DEBUG_BOOTINFO  
         dump_bootinfo();          dump_bootinfo();
 #endif  #endif
           kernel_entry = (unsigned int)phys_to_virt(boot_info->kernel.entry);
         /*          printk("kernel_entry=%x\n", kernel_entry);
          * Jump to the kernel entry point          printk("Entering kernel...\n\n");
          * via machine-dependent code.          start_kernel(kernel_entry, (unsigned int)boot_info);
          */  
         kernel_entry = (paddr_t)phys_to_virt(boot_info->kernel.entry);  
         DPRINTF(("kernel_entry=%x\n", kernel_entry));  
         DPRINTF(("Entering kernel...\n\n"));  
         start_kernel(kernel_entry, (paddr_t)boot_info);  
   
         /* NOTREACHED */  
 }  }

Legend:
Removed from v.1.1.1.1.2.1  
changed lines
  Added in v.1.2

CVSweb