⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traps.c

📁 microwindows移植到S3C44B0的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		 * the cause bit set in $fcr31.		 */		current->thread.fpu.soft.sr &= ~FPU_CSR_ALL_X;		/* Restore the hardware register state */		restore_fp(current);		/* If something went wrong, signal */		if (sig)		{			/* 			 * Return EPC is not calculated in the FPU emulator, 			 * if a signal is being send. So we calculate it here.			 */			compute_return_epc(regs);			force_sig(sig, current);		}		return;	}	if (compute_return_epc(regs))		return;	force_sig(SIGFPE, current);}void do_bp(struct pt_regs *regs){	unsigned int opcode, bcode;	unsigned int *epc;	siginfo_t info;	epc = (unsigned int *) regs->cp0_epc +	      ((regs->cp0_cause & CAUSEF_BD) != 0);	if (get_user(opcode, epc))		goto sigsegv;	/*	 * There is the ancient bug in the MIPS assemblers that the break	 * code starts left to bit 16 instead to bit 6 in the opcode.	 * Gas is bug-compatible ...	 */	bcode = ((opcode >> 16) & ((1 << 20) - 1));	/*	 * (A short test says that IRIX 5.3 sends SIGTRAP for all break	 * insns, even for break codes that indicate arithmetic failures.	 * Weird ...)	 * But should we continue the brokenness???  --macro	 */	switch (bcode) {	case 6:	case 7:		if (bcode == 7)			info.si_code = FPE_INTDIV;		else			info.si_code = FPE_INTOVF;		info.si_signo = SIGFPE;		info.si_errno = 0;		info.si_addr = (void *)regs->cp0_epc;		force_sig_info(SIGFPE, &info, current);		break;	default:		force_sig(SIGTRAP, current);	}	force_sig(SIGTRAP, current);	return;sigsegv:	force_sig(SIGSEGV, current);}void do_tr(struct pt_regs *regs){	unsigned int opcode, bcode;	unsigned int *epc;	siginfo_t info;	epc = (unsigned int *) regs->cp0_epc +	      ((regs->cp0_cause & CAUSEF_BD) != 0);	if (get_user(opcode, epc))		goto sigsegv;	bcode = ((opcode >> 6) & ((1 << 20) - 1));	/*	 * (A short test says that IRIX 5.3 sends SIGTRAP for all break	 * insns, even for break codes that indicate arithmetic failures.	 * Wiered ...)	 * But should we continue the brokenness???  --macro	 */	switch (bcode) {	case 6:	case 7:		if (bcode == 7)			info.si_code = FPE_INTDIV;		else			info.si_code = FPE_INTOVF;		info.si_signo = SIGFPE;		info.si_errno = 0;		info.si_addr = (void *)regs->cp0_epc;		force_sig_info(SIGFPE, &info, current);		break;	default:		force_sig(SIGTRAP, current);	}	return;sigsegv:	force_sig(SIGSEGV, current);}void do_ri(struct pt_regs *regs){	if (compute_return_epc(regs))		return;	force_sig(SIGILL, current);}void do_cpu(struct pt_regs *regs){	u32 cpid;	int sig;	cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;	if (cpid != 1)		goto bad_cid;	if (!(mips_cpu.options & MIPS_CPU_FPU))		goto fp_emul;	regs->cp0_status |= ST0_CU1;#ifdef CONFIG_SMP	if (current->used_math) {		lazy_fpu_switch(0, current);	} else {		init_fpu();		current->used_math = 1;	}	current->flags |= PF_USEDFPU;#else	if (last_task_used_math == current)		return;	if (current->used_math) {		/* Using the FPU again.  */		lazy_fpu_switch(last_task_used_math, current);	} else {				/* First time FPU user.  */		lazy_fpu_switch(last_task_used_math, 0);		init_fpu();		current->used_math = 1;	}	last_task_used_math = current;#endif	return;fp_emul:	if (!current->used_math) {		fpu_emulator_init_fpu();		current->used_math = 1;	}	sig = fpu_emulator_cop1Handler(regs);	if (sig)	{		/* 		 * Return EPC is not calculated in the FPU emulator, if 		 * a signal is being send. So we calculate it here.		 */		compute_return_epc(regs);		force_sig(sig, current);	}	return;bad_cid:	compute_return_epc(regs);	force_sig(SIGILL, current);}void do_watch(struct pt_regs *regs){	/*	 * We use the watch exception where available to detect stack	 * overflows.	 */	show_regs(regs);	panic("Caught WATCH exception - probably caused by stack overflow.");}asmlinkage void do_mcheck(struct pt_regs *regs){	show_regs(regs);	panic("Caught Machine Check exception - probably caused by multiple "	      "matching entries in the TLB.");}void do_reserved(struct pt_regs *regs){	/*	 * Game over - no way to handle this if it ever occurs.  Most probably	 * caused by a new unknown cpu type or after another deadly	 * hard/software error.	 */	panic("Caught reserved exception %ld - should not happen.",	      (regs->cp0_cause & 0x1f) >> 2);}static inline void watch_init(unsigned long cputype){	switch(cputype) {	case CPU_R10000:	case CPU_R4000MC:	case CPU_R4400MC:	case CPU_R4000SC:	case CPU_R4400SC:	case CPU_R4000PC:	case CPU_R4400PC:	case CPU_R4200:	case CPU_R4300:		set_except_vector(23, handle_watch);		watch_available = 1;		break;	}}unsigned long exception_handlers[32];/* * As a side effect of the way this is implemented we're limited * to interrupt handlers in the address range from * KSEG0 <= x < KSEG0 + 256mb on the Nevada.  Oh well ... */void set_except_vector(int n, void *addr){	unsigned long handler = (unsigned long) addr;	exception_handlers[n] = handler;	if (n == 0 && mips_cpu.options & MIPS_CPU_DIVEC) {		*(volatile u32 *)(KSEG0+0x200) = 0x08000000 |		                                 (0x03ffffff & (handler >> 2));		flush_icache_range(KSEG0+0x200, KSEG0 + 0x204);	}}void __init per_cpu_trap_init(void){	unsigned int cpu = smp_processor_id();	/* Some firmware leaves the BEV flag set, clear it.  */	clear_cp0_status(ST0_CU1|ST0_CU2|ST0_CU3|ST0_BEV);	set_cp0_status(ST0_CU0|ST0_FR|ST0_KX|ST0_SX|ST0_UX);	/*	 * Some MIPS CPUs have a dedicated interrupt vector which reduces the	 * interrupt processing overhead.  Use it where available.	 */	if (mips_cpu.options & MIPS_CPU_DIVEC)		set_cp0_cause(CAUSEF_IV);	cpu_data[cpu].asid_cache = ASID_FIRST_VERSION;	set_context(((long)(&pgd_current[cpu])) << 23);	set_wired(0);}void __init trap_init(void){	extern char except_vec0;	extern char except_vec1_r10k;	extern char except_vec2_generic;	extern char except_vec3_generic, except_vec3_r4000;	extern char except_vec4;	unsigned long i;	int dummy;	per_cpu_trap_init();	/* Copy the generic exception handlers to their final destination. */	memcpy((void *)(KSEG0 + 0x100), &except_vec2_generic, 0x80);	memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic, 0x80);	/*	 * Setup default vectors	 */	for(i = 0; i <= 31; i++)		set_except_vector(i, handle_reserved);	/*	 * Only some CPUs have the watch exceptions or a dedicated	 * interrupt vector.	 */	watch_init(mips_cpu.cputype);	/*	 * Some MIPS CPUs have a dedicated interrupt vector which reduces the	 * interrupt processing overhead.  Use it where available.	 */	memcpy((void *)(KSEG0 + 0x200), &except_vec4, 8);	if (mips_cpu.options & MIPS_CPU_MCHECK)		set_except_vector(24, handle_mcheck);	/*	 * The Data Bus Errors / Instruction Bus Errors are signaled	 * by external hardware.  Therefore these two exceptions	 * may have board specific handlers.	 */	bus_error_init();	/*	 * Handling the following exceptions depends mostly of the cpu type	 */	switch(mips_cpu.cputype) {        case CPU_SB1:#ifdef CONFIG_SB1_CACHE_ERROR		{		/* Special cache error handler for SB1 */		extern char except_vec2_sb1;		memcpy((void *)(KSEG0 + 0x100), &except_vec2_sb1, 0x80);		memcpy((void *)(KSEG1 + 0x100), &except_vec2_sb1, 0x80);		}#endif		/* Enable timer interrupt and scd mapped interrupt */		clear_cp0_status(0xf000);		set_cp0_status(0xc00);		/* Fall through. */	case CPU_R10000:	case CPU_R4000MC:	case CPU_R4400MC:	case CPU_R4000SC:	case CPU_R4400SC:	case CPU_R4000PC:	case CPU_R4400PC:	case CPU_R4200:	case CPU_R4300:	case CPU_R4600:	case CPU_R5000:	case CPU_NEVADA:		/* Debug TLB refill handler.  */		memcpy((void *)KSEG0, &except_vec0, 0x80);		memcpy((void *)KSEG0 + 0x080, &except_vec1_r10k, 0x80);		if (mips_cpu.options & MIPS_CPU_VCE) {			memcpy((void *)(KSEG0 + 0x180), &except_vec3_r4000,			       0x80);		} else {			memcpy((void *)(KSEG0 + 0x180), &except_vec3_generic,			       0x80);		}		set_except_vector(1, __xtlb_mod);		set_except_vector(2, __xtlb_tlbl);		set_except_vector(3, __xtlb_tlbs);		set_except_vector(4, handle_adel);		set_except_vector(5, handle_ades);		set_except_vector(6, handle_ibe);		set_except_vector(7, handle_dbe);		set_except_vector(8, handle_sys);		set_except_vector(9, handle_bp);		set_except_vector(10, handle_ri);		set_except_vector(11, handle_cpu);		set_except_vector(12, handle_ov);		set_except_vector(13, handle_tr);		set_except_vector(15, handle_fpe);		break;	case CPU_R8000:		panic("R8000 is unsupported");		break;	case CPU_UNKNOWN:	default:		panic("Unknown CPU type");	}	flush_icache_range(KSEG0, KSEG0 + 0x200);	if (mips_cpu.isa_level == MIPS_CPU_ISA_IV)		set_cp0_status(ST0_XX);	atomic_inc(&init_mm.mm_count);	/* XXX UP?  */	current->active_mm = &init_mm;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -