コード例 #1
0
ファイル: page.c プロジェクト: 304471720/GridOS
/**	
	@brief Page fault handler
*/
asmregparm void do_page_fault(struct pt_regs * regs, long error_code)
{
	unsigned long error_address = read_cr2();	
	bool in_user = address_in_user(error_address);
	struct ko_thread *current;	 

	//printk("PAGE fault: eip %x addr %x code %x\n", regs->ip, error_address, error_code);
	/*
		Access violation.
		读、写和u/s异常
		如果是用户模式,那么访问核心层空间时崩溃,其他地方尝试修复
		如果是特权模式,都尝试修复
	*/
	if (error_code & PAGE_FAULT_U)
	{
		if (in_user == false)
			goto die_cur;
	}
	
	current = kt_current();
	if (unlikely(false == ks_exception(current, error_address, error_code)))
		goto die_cur;

	return;	

die_cur:
	printk("TODO: Thread deing :eip %x addr %x code %x\n", regs->ip, error_address, error_code);

	//TODO kill thread
	//fak_arch_x86_dump_register(regs);
	kt_delete_current();
}
コード例 #2
0
ファイル: fault.c プロジェクト: LastRitter/GridOS
static bool recover(unsigned long address, int write, int present)
{
	unsigned long core_error_code = 0;

	if (write)
		core_error_code |= PAGE_FAULT_W;
	if (present)
		core_error_code |= PAGE_FAULT_P;

	/* Call the exception handler of section */
	return ks_exception(kt_current(), address, core_error_code);
}