Beispiel #1
0
void main(BootInformation* boot_info)
{
    asm("cli");
    // Memory
    mm_initialize(boot_info);
    // IDT and IRQ
    idt_install();
    irq_install();
    // Install handlers
    timer_init();
    // Re-enable interrupts
    asm("sti");
    // Initialize IO
    io_init();
    // Initialize modules
    mod_init_all();

    // Welcome
    printf("Stage 2 loaded from drive %i\n", boot_info->boot_drive);

    printf("%d entries found for the memory\n", boot_info->smap_size);
    int i = 0;
    for (i = 0; i < boot_info->smap_size; ++i) {
        SMAPEntry *ent = &(boot_info->smap_entries[i]);
        printf("\tACPI Flags 0x%x Type %d ",
                ent->acpi & 0x03, ent->type);
        printf("Base 0x%016llx\tSize %lld\n", ent->base, ent->length);
    }

    // Launch command line interpreter
    cli_start();

    // Should never reach this, but just in case...
    while (1)
        asm("hlt");
}
Beispiel #2
0
FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr,
                  uintptr_t maxbreak)
{
  uintptr_t brkaddr;
  uintptr_t allocbase;
  unsigned int pgincr;
  size_t bytesize;
  int err;

  DEBUGASSERT(incr >= 0);
  if (incr < 0)
    {
      err = ENOSYS;
      goto errout;
    }

  /* Get the current break address (NOTE: assumes region 0).  If
   * the memory manager is uninitialized, mm_brkaddr() will return
   * zero.
   */

  brkaddr = (uintptr_t)mm_brkaddr(heap, 0);
  if (incr > 0)
    {
      /* Convert the increment to multiples of the page size */

      pgincr = MM_NPAGES(incr);

      /* Check if this increment would exceed the maximum break value */

      if ((brkaddr > 0) && ((maxbreak - brkaddr) < (pgincr << MM_PGSHIFT)))
        {
          err = ENOMEM;
          goto errout;
        }

      /* Allocate the requested number of pages and map them to the
       * break address.  If we provide a zero brkaddr to pgalloc(),  it
       * will create the first block in the correct virtual address
       * space and return the start address of that block.
       */

      allocbase = pgalloc(brkaddr, pgincr);
      if (allocbase == 0)
        {
          err = EAGAIN;
          goto errout;
        }

      /* Has the been been initialized?  brkaddr will be zero if the
       * memory manager has not yet been initialized.
       */

      bytesize = pgincr << MM_PGSHIFT;
      if (brkaddr != 0)
        {
          /* No... then initialize it now */

          mm_initialize(heap, (FAR void *)allocbase, bytesize);
        }
      else
        {
          /* Extend the heap (region 0) */

          mm_extend(heap, (FAR void *)allocbase, bytesize, 0);
        }
    }

  return (FAR void *)brkaddr;

errout:
  set_errno(err);
  return (FAR void *)-1;
}
Beispiel #3
0
void umm_initialize(FAR void *heap_start, size_t heap_size)
{
  mm_initialize(USR_HEAP, heap_start, heap_size);
}
Beispiel #4
0
void kmm_initialize(FAR void *heap_start, size_t heap_size)
{
  return mm_initialize(&g_kmmheap, heap_start, heap_size);
}
Beispiel #5
0
void CPU_InitUserHeap(void)
{
  mm_initialize(&g_mmheap_user, CPU_GetUserHeapStart(), CPU_GetUserHeapSize());
}