コード例 #1
0
ファイル: main.c プロジェクト: hominlinx/hot-pot-lab
/**
 * 主核初始化
 */
asmlinkage void __init start_master(void)
{
	debug_printstr_mmu("xby_debug, start cpu 0\n");

	local_irq_disable();

	//tick_init();
	
	/* 为当前CPU设置其活动掩码 */
	boot_cpu_init();
	/* 体系结构特定的初始化过程 */
	start_arch();

	//初始化boot内存分配器
	InitBootMemory(0xc0000000 + 8 * 1024 * 1024, 0xc0000000 + 24 * 1024 * 1024);
	
	init_IRQ();
	//体系结构和驱动的一些初始化过程
	//run_initcall();

	//为VFS分配一些大的内存块,用于哈希表。此过程必须在boot阶段分配。
	//vfs_caches_init_early();

#ifdef FS
	blk_dev_init();
	inode_init();
	file_table_init();
	name_cache_init();
	buffer_init_early();
#endif
	memory_init();
#ifdef FS
	buffer_init_tail();
	tty_init();
#endif
	sched_init();
	time_init();
	setup_timer();
	serial_init();
	//mmc_init();
	//omap_gpio_init();
	//初始化文件系统
	//vfs_caches_init(num_physpages);
	local_irq_enable();

	//创建系统任务,以及用户任务入口
	TaskEntry();
	cpu_idle();

	//不可能运行到这里来
	BUG();
}
コード例 #2
0
ファイル: namei_cache.c プロジェクト: aunali1/exopc
void 
namei_init(void) {
  START(namei,init);
  nc = name_cache_init(4096,64);
  name_cache_removefunc(namei_cache_remove_func);
#ifdef CACHEDLOOKUP
//  kprintf("Namei with cached lookups\n");
#endif
  assert(nc);

  //atexit(pr_namei_stat);
  STOP(namei,init);
}
コード例 #3
0
ファイル: main.c プロジェクト: rohsaini/mkunity
asmlinkage void start_kernel(void)
{
	char * command_line;

/*
 *	This little check will move.
 */

#ifdef __SMP__
	static int first_cpu=1;
	
	if(!first_cpu)
		start_secondary();
	first_cpu=0;
	
#endif	
/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
	setup_arch(&command_line, &memory_start, &memory_end);
	memory_start = paging_init(memory_start,memory_end);
	trap_init();
#ifndef	CONFIG_OSFMACH3
	init_IRQ();
#endif	/* CONFIG_OSFMACH3 */
	sched_init();
	time_init();
	parse_options(command_line);
#ifdef CONFIG_MODULES
	init_modules();
#endif
#ifdef CONFIG_PROFILE
	if (!prof_shift)
#ifdef CONFIG_PROFILE_SHIFT
		prof_shift = CONFIG_PROFILE_SHIFT;
#else
		prof_shift = 2;
#endif
#endif
	if (prof_shift) {
		prof_buffer = (unsigned int *) memory_start;
		/* only text is profiled */
		prof_len = (unsigned long) &_etext - (unsigned long) &_stext;
		prof_len >>= prof_shift;
		memory_start += prof_len * sizeof(unsigned int);
		memset(prof_buffer, 0, prof_len * sizeof(unsigned int));
	}
	memory_start = console_init(memory_start,memory_end);
#ifdef CONFIG_PCI
	memory_start = pci_init(memory_start,memory_end);
#endif
	memory_start = kmalloc_init(memory_start,memory_end);
	sti();
	calibrate_delay();
	memory_start = inode_init(memory_start,memory_end);
	memory_start = file_table_init(memory_start,memory_end);
	memory_start = name_cache_init(memory_start,memory_end);
#ifndef	CONFIG_OSFMACH3
#ifdef CONFIG_BLK_DEV_INITRD
	if (initrd_start && initrd_start < memory_start) {
		printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
		    "disabling it.\n",initrd_start,memory_start);
		initrd_start = 0;
	}
#endif
#endif	/* CONFIG_OSFMACH3 */
	mem_init(memory_start,memory_end);
	buffer_init();
	sock_init();
#if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
	ipc_init();
#endif
	dquot_init();
	arch_syms_export();
	sti();
	check_bugs();

	printk(linux_banner);
#ifdef __SMP__
	smp_init();
#endif
	sysctl_init();
	/* 
	 *	We count on the initial thread going ok 
	 *	Like idlers init is an unlocked kernel thread, which will
	 *	make syscalls (and thus be locked).
	 */
#ifdef	CONFIG_OSFMACH3
	osfmach3_start_init(argv_init, envp_init);
#else	/* CONFIG_OSFMACH3 */
	kernel_thread(init, NULL, 0);
#endif	/* CONFIG_OSFMACH3 */
/*
 * task[0] is meant to be used as an "idle" task: it may not sleep, but
 * it might do some general things like count free pages or it could be
 * used to implement a reasonable LRU algorithm for the paging routines:
 * anything that can be useful, but shouldn't take time from the real
 * processes.
 *
 * Right now task[0] just does a infinite idle loop.
 */
 	cpu_idle(NULL);
}
コード例 #4
0
ファイル: namecache-test.c プロジェクト: aunali1/exopc
void main ()
{
   nc_t *namecache;
   int value;
   int ret;

   printf("sizeof(nc_t) == %d\n", sizeof(nc_t));
   printf("sizeof(nc_entry_t) == %d\n", sizeof(nc_entry_t));
   namecache = name_cache_init (176, 2);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 1, "hello", 5, 42);

   name_cache_printContents (namecache);

   ret = name_cache_findEntry (namecache, 1, "hello", 5, &value);
   assert ((ret == 1) && (value == 42));

   printf("found simple entry\n");

   ret = name_cache_findEntry (namecache, 1, "hello", 4, &value);
   assert (ret == 0);
   ret = name_cache_findEntry (namecache, 1, "hello", 6, &value);
   assert (ret == 0);
   ret = name_cache_findEntry (namecache, 2, "hello", 5, &value);
   assert (ret == 0);
   ret = name_cache_findEntry (namecache, 1, "hellp", 5, &value);
   assert (ret == 0);

   printf("didn't find it incorrectly\n");
   name_cache_printContents (namecache);

   name_cache_removeEntry (namecache, 1, "hello", 4);
   name_cache_removeEntry (namecache, 1, "hello", 6);
   name_cache_removeEntry (namecache, 2, "hello", 5);
   name_cache_removeEntry (namecache, 1, "hellp", 5);

   name_cache_printContents (namecache);
   printf("was it removed incorrectly??\n");

   name_cache_removeEntry (namecache, 1, "hello", 5);

   name_cache_printContents (namecache);
   printf("now it should be gone\n");

   ret = name_cache_findEntry (namecache, 1, "hello", 5, &value);
   assert (ret == 0);

   printf("didn't find removed entry\n");

   name_cache_addEntry (namecache, 1, "hello", 5, 42);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 3, "hello", 5, 42);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 2, "hello", 5, 42);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 2, "hello", 5, 42);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 2, "hello", 5, 43);

   name_cache_printContents (namecache);

   name_cache_removeEntry (namecache, 2, "hello", 5);

   name_cache_printContents (namecache);

   ret = name_cache_findEntry (namecache, 1, "hello", 5, &value);
   printf("find 1 hello: ret %d, value %d\n", ret, value);
   assert (ret == 1);
   ret = name_cache_findEntry (namecache, 3, "hello", 5, &value);
   printf("find 3 hello: ret %d, value %d\n", ret, value);
   assert (ret == 1);
   ret = name_cache_findEntry (namecache, 2, "hello", 5, &value);
   printf("find 2 hello: ret %d, value %d\n", ret, value);
   assert (ret == 0);

   name_cache_addEntry (namecache, 5, "hello", 5, 47);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 7, "he lo", 4, 49);

   name_cache_printContents (namecache);

   ret = name_cache_findEntry (namecache, 1, "he lo", 4, &value);
   assert (ret == 0);

   name_cache_addEntry (namecache, 7, "hellothereworldhowyadoin", 24, 49);

   name_cache_printContents (namecache);

   name_cache_removeID (namecache, 7);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 7, "he lo", 4, 49);

   name_cache_printContents (namecache);

   name_cache_removeValue (namecache, 49);

   name_cache_printContents (namecache);

   name_cache_shutdown(namecache);

   name_cache_addEntry (namecache, 6, "hello", 5, 67);
   name_cache_addEntry (namecache, 7, "hello", 5, 77);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 8, "hello", 5, 87);

   name_cache_printContents (namecache);

   name_cache_addEntry (namecache, 6, "hello", 5, 87);

   name_cache_printContents (namecache);

   name_cache_removeValue (namecache, 87);

   name_cache_printContents (namecache);

   name_cache_printStats (namecache);

   printf ("Done\n");
   exit (0);
}