コード例 #1
0
void
multiboot_main(unsigned int boot_info_pa)
{
	int argc = 0;
	char **argv = 0;
	int ret;

	/* Copy the multiboot_info structure into our pre-reserved area.
	   This avoids one loose fragment of memory that has to be avoided.  */
	boot_info = *(struct multiboot_info*)phystokv(boot_info_pa);

	/*
	 * Initialize the processor tables. ie default handlers etc.
	 */
	base_cpu_setup();

	/*
	 * Initialize the floating point unit.
	 */
	/*base_fpu_init();*/

	/* Initialize the memory allocator and find all available memory.  */
	base_multiboot_init_mem();

	/* Parse the command line into nice POSIX-like args and environment.  */
	base_multiboot_init_cmdline(&argc, &argv);

	enable_interrupts();

	/* Invoke the main program. */
	ret = kernel_main(argc, argv, environ);
	printf( "base_multiboot_main.c: kernel main returned with code %d\n", 
                ret );
	while(1);
}
コード例 #2
0
ファイル: multiboot_main.c プロジェクト: dzavalishin/oskit
void
multiboot_main(oskit_addr_t boot_info_pa)
{
	int argc = 0;
	char **argv = 0;
	int i;
	char **ep;

	/* Copy the multiboot_info structure into our pre-reserved area.
	   This avoids one loose fragment of memory that has to be avoided.  */
	boot_info = *(struct multiboot_info*)phystokv(boot_info_pa);

	/* Identify the CPU and get the processor tables set up.  */
	base_cpu_setup();

	/* Initialize the memory allocator and find all available memory.  */
	base_multiboot_init_mem();

	/* Parse the command line into nice POSIX-like args and environment.  */
	base_multiboot_init_cmdline(&argc, &argv);

	/* Remove the -d flag because we don't want to be debugged, we
           want to debug our kids. */
	for (i = 0; i < oskit_bootargc; i++)
		if (strcmp(oskit_bootargv[i], "-d") == 0) {
			int j;

			enable_debug_arg = oskit_bootargv[i];
			for (j = i; j < oskit_bootargc; j++)
				oskit_bootargv[j] = oskit_bootargv[j + 1];
			oskit_bootargc--;
			break;
		}
	/* Likewise for a "GDB_COM" environment variable.  */
	for (ep = environ; *ep; ++ep)
		if (strncmp(*ep, "GDB_COM=", 8) == 0) {
			enable_debug_arg = *ep;
			i = 0;
			do
				ep[i] = ep[i + 1];
			while (ep[i++]);
			break;
		}


	/* Look for a return address. */
	for (i = 0; i < oskit_bootargc; i++)
		if (strcmp(oskit_bootargv[i], "-retaddr") == 0
		    && i+1 < oskit_bootargc) {
			return_address = strtoul(oskit_bootargv[i+1], 0, 0);
			break;
		}

	/* Enable interrupts, since we may be using remote gdb. */
	sti();

	/* Initialize the console */
	base_console_init(oskit_bootargc, oskit_bootargv);

#ifdef GPROF
	if (enable_gprof)
		base_gprof_init();
#endif

#ifdef __ELF__
	/* Make sure deinit code gets called on exit. */
	atexit(__oskit_fini);

	/* Call init code. */
	__oskit_init();
#endif

	/* Invoke the main program. */
	exit(main(argc, argv, environ));
}