Пример #1
0
void panic_exc(volatile struct intr_ctx ctx)
{
	cli();
	ctx_dump((struct intr_ctx *)&ctx);
	stack_dump((struct intr_ctx *)&ctx);
	idle_task_func();
}
Пример #2
0
void panic(const char *fmt, ...)
{
	va_list va;
	va_start(va, fmt);
	printk("Panic: ");
	printkv(fmt, va);
	va_end(va);

	asm volatile("int $0xf0");
	idle_task_func();
}
Пример #3
0
/* Entry point in to the kernel proper */
_noreturn _asmlinkage void setup(multiboot_info_t *mbi)
{
	serio_init();
	vga_preinit();

	/* Need this mmediately to catch exceptions */
	idt_init();

	/* print a pretty message */
	printk("ScaraOS v0.0.7 for IA-32");
	if ( mbi->flags & MBF_CMDLINE ) {
		cmdline = __va(mbi->cmdline);
		printk(": %s", cmdline);
	}
	printk("\n");

	/* Prints out CPU MHz */
	calibrate_delay_loop();

	/* Identify CPU features, also needs to be early because
	 * mm init may need to know which paging features are
	 * available 
	 */
	cpuid_init();

	/* Fire up the kernel memory allocators */
	BUG_ON((mbi->flags & MBF_MMAP) == 0);
	ia32_mm_init(__va(mbi->mmap), mbi->mmap_length);

	/* setup the idle task */
	sched_init();
	ia32_gdt_finalize();

	/* enable hardware interrupts */
	pic_init();

	/* start jiffie counter */
	pit_start_timer1();

	/* initialise fdt logic ready for use */
	_fdt_init();

	/* Setup the init task */
	kernel_thread("[init]", init_task, NULL);

	/* Finally, enable interupts and let it rip */
	sti();
	sched();
	idle_task_func();
}
Пример #4
0
unsigned exc_handler(uint32_t exc_num, volatile struct intr_ctx ctx)
{
	static const char * const tname[] = {
		"UNKNOWN",
		"fault",
		"trap",
		"abort condition",
	};

	if ( exc[exc_num].handler ) {
		(*exc[exc_num].handler)((struct intr_ctx *)&ctx);
		return return_from_intr(&ctx);
	}

	if ( (ctx.cs & __CPL3) == __CPL3 ) {
		_sys_exit(~0);
	}

	cli();
	printk("%s: %s @ 0x%.8lx",
		tname[exc[exc_num].type], exc[exc_num].name, ctx.eip);
	if ( exc[exc_num].err_code ) {
		if ( ctx.err_code & 0x1 )
			printk(" EXT");
		switch ( ctx.err_code & 0x6 ) {
		case 0:
			printk(" GDT");
			break;
		case 2:
			printk(" IDT");
			break;
		case 4:
			printk(" LDT");
			break;
		}
		printk(" selector=0x%.lx", ctx.err_code & 0xfff8);
	}
	printk("\n");
	ctx_dump((struct intr_ctx *)&ctx);
	idle_task_func();
}
Пример #5
0
static void page_fault(struct intr_ctx *ctx)
{
	if ( 0 == (ctx->err_code & (PAGEFAULT_PROTECTION)) ) {
		unsigned prot;
		if ( (ctx->err_code & PAGEFAULT_WRITE) )
			prot = PROT_WRITE;
		else
			prot = PROT_READ;
		if ( !mm_pagefault(__this_task, pf_address(), prot) )
			return;
	}

	if ( ctx->err_code & PAGEFAULT_USER )
		_sys_exit(~0);
	else{
		struct pagefault_fixup *fix;
		for(fix = &__rodata_pagefault;
				fix < &__rodata_pagefault_end; fix++) {
			if ( fix->fault_addr == ctx->eip ) {
				ctx->eip = fix->fixup_addr;
				return;
			}
		}
	}

	cli();
	printk("Unhandled #PF in %s mode: %s fault_addr=0x%.8lx/%s%s\n",
		(ctx->err_code & PAGEFAULT_USER) ?
			"user" : "supervisor",
		(ctx->err_code & PAGEFAULT_PROTECTION) ?
			"PROTECTION_VIOLATION" : "NONPRESENT",
		pf_address(),
		(ctx->err_code & PAGEFAULT_WRITE) ?
			"WRITE" : "READ",
		(ctx->err_code & PAGEFAULT_RESERVED_BIT) ?
			" RESERVED_BIT" : "");
	ctx_dump(ctx);
	idle_task_func();
}