Пример #1
0
/* Init task - the job of this task is to initialise all
 * installed drivers, mount the root filesystem and
 * bootstrap the system */
int init_task(void *priv)
{
	uint32_t ret;
	struct file *file;
	char buf[20];
	int rval;

	/* Initialise kernel subsystems */
	blk_init();
	vfs_init();
	pci_init();

	do_initcalls();

	/* Mount the root filesystem etc.. */
	if ( vfs_mount_root("ext2", "floppy0") ) {
		panic("Unable to mount root filesystem\n");
	}

	file = kernel_open("/test.txt", 0);
	if ( NULL == file ) {
		printk("init_task: open failed, returned %u\n", -1);
	} else {
		rval = kernel_read(file, buf, 16);
		if ( rval < 0 )
			printk("read error: %d\n", rval);
		else if ( rval == 0 )
			printk("read returned EOF\n");
		else {
			buf[rval] = '\0';
			printk("read: %s.\n", buf);
		}
		rval = kernel_write(file, buf, 16);
		kernel_close(file);
	}

	ret = _kernel_exec("/bin/bash");
	ret = _kernel_exec("/sbin/init");
	ret = _kernel_exec("/bin/cat");
	printk("exec: /sbin/init: %i\n", (int)ret);

	return ret;
}
Пример #2
0
/* Init task - the job of this task is to initialise all
 * installed drivers, mount the root filesystem and
 * bootstrap the system */
int init_task(void *priv)
{
	uint32_t ret;

	/* Initialise kernel subsystems */
	blk_init();
	vfs_init();
	pci_init();

	do_initcalls();

	/* Mount the root filesystem etc.. */
	if ( vfs_mount_root("ext2", "floppy0") ) {
		panic("Unable to mount root filesystem\n");
	}

	ret = _kernel_exec("/bin/bash");
	ret = _kernel_exec("/sbin/init");
	ret = _kernel_exec("/bin/cat");
	printk("exec: /sbin/init: %i\n", (int)ret);

	return ret;
}
Пример #3
0
void kmain(void)
{
	kernel_end = (uint64_t)heap_addr;
	kernel_heap_ptr = (uint8_t*)((uint64_t)&VMA + kernel_end + heap_size) ;
	UPD = (uint64_t*)((uint64_t)&VMA + kernel_end + 0x3000);
	KPD = (uint64_t*)((uint64_t)&VMA + kernel_end + 0x4000);
	PML4 = (uint64_t*)((uint64_t)&VMA + kernel_end);
	*(KPD + 511) = (kernel_end + 0x4000) | 3;
	map_mem(mboot_info);

#if _GFX_
	init_video();
#endif
	
	idt_install();
	isr_install();

	vmem_init();
	
	serial.init();

	extern void load_tss(void);
	load_tss();
	extern uint64_t k_tss64_sp;
	*(uint64_t*)( (uint64_t)&VMA + (uint64_t)&k_tss64_sp ) = 0xFFFFFFFFC0008000;

	pit_set_freq(2000);	// timer tick = 500 us
	pit_install();
	irq_install();

	extern void mouse_init();
	//mouse_init();
	extern void mouse_handler(void*);
	//irq_install_handler(12, mouse_handler);

	multiboot_module_t *mod = (multiboot_module_t*)(uint64_t)mboot_info->mods_addr;

	ramdev_private_t ramdev_private = 
		(ramdev_private_t) 
		{ 
			.ptr  = (void*)((uint64_t)&VMA + mod->mod_start),
			.size = (uint32_t)(mod->mod_end - mod->mod_start),
		};
		
 	inode_t ramdisk_inode =
	 	(inode_t) 
 		{
 			.name 	= "ramdisk",
 			.type	= FS_CHRDEV,
 			.fs		= &devfs,
 			.dev	= &ramdev,
 			.p 		= &ramdev_private, 
 		};
 	
 	vfs_create(&dev_root, "/", &ramdisk_inode);

	inode_t *rootfs = initramfs.load(&ramdisk_inode);
	
	vfs_mount_root(rootfs);
	
	irq_install_handler(1, kbd_handler);
	
	devman.init();
	fsman.init();
	
#if _DBG_CON_
	// We should disable debugging by this stage!
	serial.end();
#endif

	process_t *init = load_elf("/bin/init");
		
	extern void spawn_init(process_t*);
	spawn_init(init);
	for(;;);
}