Exemplo n.º 1
0
int kernel_main() {
	init_kernel_stack(KERN_HEAP_OFFSET);

	init_device_drivers();
	device_open(TTY, 0);

	k_printf("entered into main kernel..!\n");
	k_printf("and initialized device drivers.\n");

	init_gdt();
	k_printf("initialized protected mode.\n");

	check_physical_mem_size();
	k_printf("physical memory size : %d megabytes.\n", physical_mem_size>>20);

	init_paging();
	k_printf("initialized paging.\n");

	init_vfs();
	k_printf("initialized file system (fat16).\n");

	init_idt();
	k_printf("initialized interrupt.\n");

	init_tss();

	struct fat16_file_kt f;
	f = fs_open_fat16("/apps/snake.bin");
	create_task(f.buffer, f.information.file_size); 
	dump_task_queue();
	current_task = pop_task_queue();
	create_task(init1, 256);
	create_task(init2, 256);
	create_task(init3, 256);
	create_task(init4, 256);
	create_task(init5, 256);
	dump_task_queue();

	/*
	do {
		struct task_struct_kt *cur = task_head;
		do {
			k_printf("#%d - stack %x, start %x\n", cur->tid, cur->sp_page, cur->start_entry);
			cur = cur->next;
		} while (cur != task_head);
	} while(0);
	*/

	//for(;;);  // user page가 제대로 동작할때까지 막아둠.

	cli();
	SCHEDULE();
	
	for(;;);
	
	device_close(TTY, 0);

	return 0;
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: Bth8/Dionysus
void kmain(uint32_t magic, multiboot_info_t *mboot, uintptr_t ebp) {
	monitor_clear();

	printf("Booting Dionysus!\n");

	ASSERT(magic == MULTIBOOT_BOOTLOADER_MAGIC && "Not booted with multiboot.");
	ASSERT(mboot->flags & MULTIBOOT_INFO_MEMORY && "No memory info.");
	ASSERT(mboot->flags & MULTIBOOT_INFO_MEM_MAP && "No memory map.");

	printf("Initializing GDT\n");
	init_gdt();

	printf("Initializing IDT\n");
	init_idt();

	// Check for modules
	if (mboot->flags & MULTIBOOT_INFO_MODS && mboot->mods_count) {
		multiboot_module_t *mods = (multiboot_module_t *)mboot->mods_addr;
		placement_address = mods[mboot->mods_count - 1].mod_end + KERNEL_BASE;
	}

	printf("Setting up paging\n");
	init_paging(mboot->mem_lower + mboot->mem_upper, mboot->mmap_addr,
		mboot->mmap_length);

	printf("Initializing timers\n");
	init_time();
	init_timer();

	printf("Starting task scheduling\n");
	init_tasking(ebp);
	init_syscalls();

	printf("Initializing vfs\n");
	init_vfs();

	printf("Initializing driver subsystem\n");
	init_blockdev();

	init_chardev();
	init_term();

	printf("Enumerating PCI bus(ses)\n");
	init_pci();
	dump_pci();

	init_devfs();
	ASSERT(mount(NULL, "/dev", "devfs", 0) == 0);

	init_ide();

	halt();
}
Exemplo n.º 3
0
/* This is the C kernel entry point */
void kmain(struct multiboot *mboot_header, addr_t initial_stack)
{
	/* Store passed values, and initiate some early things
	 * We want serial log output as early as possible */
	kernel_state_flags=0;
	mtboot = mboot_header;
	i_stack = initial_stack;
	parse_kernel_elf(mboot_header, &kernel_elf);
#if CONFIG_MODULES
	init_kernel_symbols();
#endif
	init_serial();
	console_init_stage1();
	load_tables();
	puts("~ SeaOS Version ");	
	char ver[32];
	get_kernel_version(ver);
	puts(ver);
	puts(" Booting Up ~\n\r");
#if CONFIG_MODULES
	init_module_system();
#endif
	init_syscalls();
	load_initrd(mtboot);
	install_timer(1000);
	pm_init(placement, mtboot);
	init_main_cpu_1();

	/* Now get the management stuff going */
	printk(1, "[kernel]: Starting system management\n");
	init_memory(mtboot);
	init_main_cpu_2();
	console_init_stage2();
	parse_kernel_cmd((char *)(addr_t)mtboot->cmdline);
	init_multitasking();
	init_cache();
	init_dm();
	init_vfs();
	/* Load the rest... */
	process_initrd();
	init_kern_task();
	get_timed(&kernel_start_time);
	printk(KERN_MILE, "[kernel]: Kernel is setup (%2.2d:%2.2d:%2.2d, %s, kv=%d, ts=%d bytes: ok)\n", 
	       kernel_start_time.tm_hour, kernel_start_time.tm_min, 
	       kernel_start_time.tm_sec, kernel_name, KVERSION, sizeof(task_t));
	assert(!set_int(1));
	if(!fork())
		init();
	sys_setsid();
	enter_system(255);
	kernel_idle_task();
}