#include "hv/arch.h" #include "hv/log.h" #include "hv/panic.h" #include "hv/uart.h" #include "hv/vcpu.h" void panic_dump_value(const char *name, uint64_t value) { uart_puts("panic "); uart_puts(name); uart_puts("="); uart_put_hex64(value); uart_puts("\n"); } void panic_with_code(const char *reason, uint64_t code) { struct log_event ev; ev.seq = 0; ev.cpu = 0; ev.vcpu = vcpu_current() != (struct vcpu *)0 ? vcpu_current()->id : UINT64_MAX; ev.timestamp = 0; ev.kind = LOG_PANIC; ev.ec = 0; ev.iss = code; ev.elr = 0; ev.far = 0; ev.hpfar = 0; ev.sysreg_key = 0; ev.is_read = 0; ev.rt = 0; ev.operand = code; ev.result = 0; ev.action = LOG_ACT_PANIC; ev.reason = 999u; ev.pstate = 0; ev.name = reason; log_event_commit(&ev); uart_puts("\nPANIC reason="); uart_puts(reason); uart_puts(" code="); uart_put_hex64(code); uart_puts(" current_el="); uart_put_dec64(arch_current_el()); uart_puts("\n"); panic_dump_value("code", code); arch_dump_el2_state(); vcpu_dump(vcpu_current()); uart_puts("recent log:\n"); log_dump(32u); arch_halt(); } void panic(const char *reason) { panic_with_code(reason, 0u); }