void c_undefined_handler(void* lr) { bool doubleFault = in_fault == true; in_fault = true; printf("Undefined instruction at 0x%h. (instruction: %d).\n", lr, *((unsigned int*)lr)); //unsigned int* instAddr = (unsigned int*)*(r14 - 1) + 4; //printf("Instruction that cause abort is at 0x%h (%d) - SPSR: 0x%h.\n", instAddr, *instAddr, 42);// spsr); wait(INTERRUPT_HANDLER_DELAY); in_fault = false; if (doubleFault) double_fault(); }
/** * panic: * Display reason for kernel panic * Display last crash context value, if it exists * Display no-heap backtrace of stack * Call on_panic handler function, to allow application specific panic behavior * Print EOT character to stderr, to signal outside that PANIC output completed * If the handler returns, go to (permanent) sleep **/ void panic(const char* why) { cpu_enable_panicking(); if (PER_CPU(contexts).panics > 4) double_fault(why); const int current_cpu = SMP::cpu_id(); SMP::global_lock(); // Tell the System log that we have paniced SystemLog::set_flags(SystemLog::PANIC); /// display informacion ... fprintf(stderr, "\n%s\nCPU: %d, Reason: %s\n", panic_signature, current_cpu, why); // crash context (can help determine source of crash) const int len = strnlen(get_crash_context_buffer(), get_crash_context_length()); if (len > 0) { printf("\n\t**** CPU %d CONTEXT: ****\n %*s\n\n", current_cpu, len, get_crash_context_buffer()); } // heap info typedef unsigned long ulong; uintptr_t heap_total = OS::heap_max() - heap_begin; fprintf(stderr, "Heap is at: %p / %p (diff=%lu)\n", (void*) heap_end, (void*) OS::heap_max(), (ulong) (OS::heap_max() - heap_end)); fprintf(stderr, "Heap usage: %lu / %lu Kb\n", // (%.2f%%)\n", (ulong) (heap_end - heap_begin) / 1024, (ulong) heap_total / 1024); //, total * 100.0); print_backtrace(); fflush(stderr); SMP::global_unlock(); // action that restores some system functionality intended for inspection // NB: Don't call this from double faults panic_perform_inspection_procedure(); panic_epilogue(why); }
void c_abort_instruction_handler(unsigned int address, unsigned int errorType) { bool doubleFault = in_fault == true; in_fault = true; if (*(unsigned int*)address == 0xE1200070) { printf("* * Breakpoint! * * \n"); } else { printf("Instruction at 0x%h (value: %d) caused instruction abort ", address, *(unsigned int*)address); print_abort_error(errorType); } wait(INTERRUPT_HANDLER_DELAY); in_fault = false; if (doubleFault) double_fault(); }