Subversion Repositories Kolibri OS

Rev

Rev 854 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. #include <types.h>
  4. #include <core.h>
  5.  
  6. #include "multiboot.h"
  7.  
  8. extern u32_t pg_balloc;
  9.  
  10. extern u32_t mem_amount;
  11. extern u32_t rd_base;
  12. extern u32_t rd_fat      ;
  13. extern u32_t rd_fat_end  ;
  14. extern u32_t rd_root     ;
  15. extern u32_t rd_root_end ;
  16.  
  17. extern multiboot_info_t *boot_mbi;
  18.  
  19. /* Check if the bit BIT in FLAGS is set.  */
  20. #define CHECK_FLAG(flags,bit)   ((flags) & (1 << (bit)))
  21.  
  22. void init()
  23. {
  24.    u32_t   last_page = 0;
  25.  
  26.    if (CHECK_FLAG (boot_mbi->flags, 1))
  27.      printf ("boot_device = 0x%x\n", (unsigned) boot_mbi->boot_device);
  28.  
  29.   /* Is the command line passed?  */
  30.    if (CHECK_FLAG (boot_mbi->flags, 2))
  31.      printf ("cmdline = %s\n", (char *) boot_mbi->cmdline);
  32.  
  33.   /* Are mods_* valid?  */
  34.    if (CHECK_FLAG (boot_mbi->flags, 3))
  35.    {
  36.      module_t *mod;
  37.      int i;
  38.  
  39.    //  printf ("mods_count = %d, mods_addr = 0x%x\n",
  40.    //          (u32_t) boot_mbi->mods_count, (u32_t) boot_mbi->mods_addr);
  41.      for (i = 0, mod = (module_t *) boot_mbi->mods_addr;
  42.           i < boot_mbi->mods_count;i++, mod++)
  43.      {
  44.         pg_balloc = mod->mod_end;
  45.     //    printf (" mod_start = 0x%x, mod_end = 0x%x, string = %s\n",
  46.     //          (u32_t) mod->mod_start,(u32_t) mod->mod_end, (char *) mod->string);
  47.      };
  48.      mod--;
  49.      rd_base     = mod->mod_start+OS_BASE;
  50.      rd_fat      = rd_base + 512;
  51.      rd_fat_end  = rd_base + 512 + 4278;
  52.      rd_root     = rd_base + 512*19;
  53.      rd_root_end = rd_base + 512*33;
  54.    //  printf(" rd_base = %x\n", rd_base);
  55.    }
  56.  
  57.    if (CHECK_FLAG (boot_mbi->flags, 6))
  58.    {
  59.       memory_map_t *mmap;
  60.       u32_t page;
  61.  
  62.     //  printf ("mmap_addr = 0x%x, mmap_length = 0x%x\n",
  63.     //    (unsigned) boot_mbi->mmap_addr, (unsigned) boot_mbi->mmap_length);
  64.  
  65.       for (mmap = (memory_map_t *) boot_mbi->mmap_addr;
  66.           (u32_t) mmap < boot_mbi->mmap_addr + boot_mbi->mmap_length;
  67.            mmap = (memory_map_t *) ((u32_t) mmap
  68.                                     + mmap->size + sizeof (mmap->size)))
  69.       {
  70.          u32_t page;
  71.         /*
  72.          printf (" size = 0x%x, base_addr = 0x%x%x,"
  73.                  " length = 0x%x%x, type = 0x%x\n",
  74.                  (unsigned) mmap->size,
  75.                  (unsigned) mmap->base_addr_high,
  76.                  (unsigned) mmap->base_addr_low,
  77.                  (unsigned) mmap->length_high,
  78.                  (unsigned) mmap->length_low,
  79.                  (unsigned) mmap->type);
  80.           */
  81.          if( mmap->type != 1)
  82.            continue;
  83.          page = (mmap->base_addr_low+mmap->length_low)&(~4095);
  84.          if(page > last_page)
  85.          last_page = page;
  86.       }
  87.    }
  88.  
  89.    if(last_page > 256*1024*1024)
  90.      last_page = 256*1024*1024;
  91.  
  92.    mem_amount = last_page;
  93.  
  94.  };
  95.  
  96.