Пример #1
0
/**
 * Initializes the container data for the root process (the one with index 0).
 * The root process is the one that gets spawned first by the kernel.
 */
void container_init(unsigned int mbi_addr)
{
  unsigned int real_quota;
  // TODO: define your local variables here.
  int max_nps;
  int i;
  pmem_init(mbi_addr);
  real_quota = 0;
  max_nps = get_nps();
  /**
   * TODO: compute the available quota and store it into the variable real_quota.
   * It should be the number of the unallocated pages with the normal permission
   * in the physical memory allocation table.
   */
  for (i = 0; i < max_nps; i++) 
  {
    if (at_is_norm(i) == 1 && at_is_allocated(i) == 0)
    {
      real_quota += 1;
    }
  }
  KERN_DEBUG("\nreal quota: %d\n\n", real_quota);

  CONTAINER[0].quota = real_quota;
  CONTAINER[0].usage = 0;
  CONTAINER[0].parent = 0;
  CONTAINER[0].nchildren = 0;
  CONTAINER[0].used = 1;
}
Пример #2
0
void _kmain(struct multiboot_info *mboot) {
	clrscr();

	// This will make sure there's about 4K of space for malloc to use until physical
	// memory management is available for proper virtual memory.
	kprintf("Initialising malloc()...\n");
	dlmalloc_sbrk(0);

	kprintf("Initialising physical memory manager...\n");
	pmem_init(mboot);

	kprintf("Completing virtual memory initialisation...\n");
	vmem_init();

	kprintf("Configuring software and hardware interrupts...\n");
	interrupts_init();

	kprintf("Initialising machine devices...\n");
	init_devices();

	kprintf("Enabling interrupts...\n");
	interrupts_enable();

	kprintf("Startup complete!\n");

	while(1) __asm__ volatile("hlt");
}
Пример #3
0
void mm_init() {

    /* Initialize physical memory: */
    pmem_init();

    /* Initialize kernel memory: */
    kmem_init();

#if 0
    /* Output statistics: */
    printk("\n");
    printk("Physical Memory Manager Statistics: \n");
    printk("====================================\n");
    printk("kernel: start: %x, end: %x\n",
            KERNEL_PHYSICAL_START, KERNEL_PHYSICAL_END);
    printk("Accessible RAM Size (Approximate): %dMB.\n",
            ((pmem_usable_pages + 0x100 - 1) & 0xFFFFFF00)>>8);

    printk("\n");
    printk("Kernel Space Memory:\n");
    printk("=====================\n");
    printk("0x%x:0x%x - Kernel image.\n",
            KERNEL_VIRTUAL_START, KERNEL_VIRTUAL_END);
    printk("0x%x:0x%x - Lower memory image.\n",
            LOWMEM_VIRTUAL_START, LOWMEM_VIRTUAL_END);
#endif

}
Пример #4
0
/**
 * Initializes the container data for the root process (the one with index 0).
 * The root process is the one that gets spawned first by the kernel.
 */
void container_init(unsigned int mbi_addr)
{
  unsigned int real_quota;
  unsigned int nps, i, norm, used;

  pmem_init(mbi_addr);
  real_quota = 0;

  /**
   * compute the available quota and store it into the variable real_quota.
   * It should be the number of the unallocated pages with the normal permission
   * in the physical memory allocation table.
   */
  nps = get_nps();
  i = 1;
  while (i < nps) {
    norm = at_is_norm(i);
    used = at_is_allocated(i);
    if (norm == 1 && used == 0)
      real_quota++;
    i++;
  }
  KERN_DEBUG("\nreal quota: %d\n\n", real_quota);

  CONTAINER[0].quota = real_quota;
  CONTAINER[0].usage = 0;
  CONTAINER[0].parent = 0;
  CONTAINER[0].nchildren = 0;
  CONTAINER[0].used = 1;
}
Пример #5
0
/* init_itron --- ITRON の初期化を行う。
 *
 */
static ER
init_itron ()
{
  init_interrupt ();
  simple_init_console ();	/* コンソールに文字を出力できるようにする */
  pmem_init ();			/* 物理メモリ管理機能の初期化		*/
  banner ();			/* 立ち上げメッセージ出力		*/
  printf ("init_itron: start\n");
  init_kalloc ();		/* バイト単位のメモリ管理機能の初期化	*/
  init_semaphore ();		/* セマフォの管理機能の初期化		*/
  init_msgbuf ();		/* メッセージ管理機能の初期化		*/
  init_eventflag ();		/* イベントフラグ管理機能の初期化	*/
#ifdef notdef
  init_mpl ();			/* メモリプール管理機能の初期化		*/
  simple_init_console ();	/* コンソールに文字を出力できるようにする */
#endif
  init_task ();			/* タスク管理機能の初期化 */

  /* 1番目のタスクを初期化する。そしてそのタスクを以後の処
   * 理で使用する。
   */
  init_task1 ();

  printf ("call init_timer\n"); 
  init_timer ();	/* インターバルタイマ機能の初期化 */
  start_interval ();	/* インターバルタイマの起動	  */
  init_io ();
  return (E_OK);
}
Пример #6
0
static void
libpmem_init(void)
{
	out_init(PMEM_LOG_PREFIX, PMEM_LOG_LEVEL_VAR, PMEM_LOG_FILE_VAR,
			PMEM_MAJOR_VERSION, PMEM_MINOR_VERSION);
	LOG(3, NULL);
	util_init();
	pmem_init();
}
Пример #7
0
/*
 * libpmem_init -- load-time initialization for libpmem
 *
 * Called automatically by the run-time loader.
 */
ATTR_CONSTRUCTOR
void
libpmem_init(void)
{
    pmem_init();
}
Пример #8
0
void kernel_init(multiboot_info_t *mboot_info)
{
	extern char __start_bss[], __stop_bss[];

	memset(__start_bss, 0, __stop_bss - __start_bss);
	/* mboot_info is a physical address.  while some arches currently have the
	 * lower memory mapped, everyone should have it mapped at kernbase by now.
	 * also, it might be in 'free' memory, so once we start dynamically using
	 * memory, we may clobber it. */
	multiboot_kaddr = (struct multiboot_info*)((physaddr_t)mboot_info
                                               + KERNBASE);
	extract_multiboot_cmdline(multiboot_kaddr);

	cons_init();
	print_cpuinfo();

	printk("Boot Command Line: '%s'\n", boot_cmdline);

	exception_table_init();
	cache_init();					// Determine systems's cache properties
	pmem_init(multiboot_kaddr);
	kmem_cache_init();              // Sets up slab allocator
	kmalloc_init();
	hashtable_init();
	radix_init();
	cache_color_alloc_init();       // Inits data structs
	colored_page_alloc_init();      // Allocates colors for agnostic processes
	acpiinit();
	topology_init();
	kthread_init();					/* might need to tweak when this happens */
	vmr_init();
	file_init();
	page_check();
	idt_init();
	kernel_msg_init();
	timer_init();
	vfs_init();
	devfs_init();
	train_timing();
	kb_buf_init(&cons_buf);
	arch_init();
	block_init();
	enable_irq();
	run_linker_funcs();
	/* reset/init devtab after linker funcs 3 and 4.  these run NIC and medium
	 * pre-inits, which need to happen before devether. */
	devtabreset();
	devtabinit();

#ifdef CONFIG_EXT2FS
	mount_fs(&ext2_fs_type, "/dev/ramdisk", "/mnt", 0);
#endif /* CONFIG_EXT2FS */
#ifdef CONFIG_ETH_AUDIO
	eth_audio_init();
#endif /* CONFIG_ETH_AUDIO */
	get_coreboot_info(&sysinfo);
	booting = 0;

#ifdef CONFIG_RUN_INIT_SCRIPT
	if (run_init_script()) {
		printk("Configured to run init script, but no script specified!\n");
		manager();
	}
#else
	manager();
#endif
}