示例#1
0
文件: fault.c 项目: arrow2004/osdev
int fix_fault(FAULT_TYPES type, uint32_t addr)
{
    printk("status = %x, pc = %x, addr = %x \n", get_fsr() & 0xf, addr, get_far());
    if (type == DATA_FAULT)
        addr = get_far();
    uint32_t index = addr >> 20;
    uint32_t *base = (uint32_t *)get_pagetable_base();
    base[index] = addr | (3 << 10) | CACHE_WRITEBACK;   
    return 0;
}
示例#2
0
文件: exception.c 项目: marcan/spmp
void exc_handler(u32 type, u32 spsr, u32 *regs)
{
	if (type > 8) type = 8;
	debug_printf("\nException %d (%s):\n", type, exceptions[type]);

	u32 pc, fsr;

	switch(type) {
		case 1: // UND
		case 2: // SWI
		case 3: // INSTR ABORT
		case 7: // FIQ
			pc = regs[15] - 4;
			break;
		case 4: // DATA ABORT
			pc = regs[15] - 8;
			break;
		default:
			pc = regs[15];
			break;
	}

	debug_printf("Registers (%p):\n", regs);
	debug_printf("  R0-R3: %08x %08x %08x %08x\n", regs[0], regs[1], regs[2], regs[3]);
	debug_printf("  R4-R7: %08x %08x %08x %08x\n", regs[4], regs[5], regs[6], regs[7]);
	debug_printf(" R8-R11: %08x %08x %08x %08x\n", regs[8], regs[9], regs[10], regs[11]);
	debug_printf("R12-R15: %08x %08x %08x %08x\n", regs[12], regs[13], regs[14], pc);

	debug_printf("SPSR: %08x\n", spsr);
	debug_printf("CPSR: %08x\n", get_cpsr());
	debug_printf("CR:   %08x\n", get_cr());
	debug_printf("TTBR: %08x\n", get_ttbr());
	debug_printf("DACR: %08x\n", get_dacr());

	switch (type) {
		case 3: // INSTR ABORT
		case 4: // DATA ABORT 
			if(type == 3)
				fsr = get_ifsr();
			else
				fsr = get_dfsr();
			debug_printf("Abort type: %s\n", aborts[fsr&0xf]);
			if(domvalid[fsr&0xf])
				debug_printf("Domain: %d\n", (fsr>>4)&0xf);
			if(type == 4)
				debug_printf("Address: 0x%08x\n", get_far());
		break;
		default: break;
	}

	if(type != 3) {
		debug_printf("Code dump:\n");
		debug_printf("%08x:  %08x %08x %08x %08x\n", pc-16, read32(pc-16), read32(pc-12), read32(pc-8), read32(pc-4));
		debug_printf("%08x: *%08x %08x %08x %08x\n", pc, read32(pc), read32(pc+4), read32(pc+8), read32(pc+12));
		debug_printf("%08x:  %08x %08x %08x %08x\n", pc+16, read32(pc+16), read32(pc+20), read32(pc+24), read32(pc+28));
	}
	panic2(0, PANIC_EXCEPTION);
}