- cr0, cr2, cr3, cr4);
-
- if (regs->isf.trapno < TRAP_TYPES)
- trapname = trap_type[regs->isf.trapno];
-#undef panic
- panic("Kernel trap at 0x%016llx, type %d=%s, registers:\n"
- "CR0: 0x%016llx, CR2: 0x%016llx, CR3: 0x%016llx, CR4: 0x%016llx\n"
- "RAX: 0x%016llx, RBX: 0x%016llx, RCX: 0x%016llx, RDX: 0x%016llx\n"
- "RSP: 0x%016llx, RBP: 0x%016llx, RSI: 0x%016llx, RDI: 0x%016llx\n"
- "R8: 0x%016llx, R9: 0x%016llx, R10: 0x%016llx, R11: 0x%016llx\n"
- "R12: 0x%016llx, R13: 0x%016llx, R14: 0x%016llx, R15: 0x%016llx\n"
- "RFL: 0x%016llx, RIP: 0x%016llx, CS: 0x%016llx, SS: 0x%016llx\n"
- "Error code: 0x%016llx\n",
- regs->isf.rip, regs->isf.trapno, trapname,
- cr0, cr2, cr3, cr4,
- regs->rax, regs->rbx, regs->rcx, regs->rdx,
- regs->isf.rsp, regs->rbp, regs->rsi, regs->rdi,
- regs->r8, regs->r9, regs->r10, regs->r11,
- regs->r12, regs->r13, regs->r14, regs->r15,
- regs->isf.rflags, regs->isf.rip, regs->isf.cs, regs->isf.ss,
- regs->isf.err);
- /*
- * This next statement is not executed,
- * but it's needed to stop the compiler using tail call optimization
- * for the panic call - which confuses the subsequent backtrace.
- */
- cr0 = 0;
-}
-#endif
-
-extern void kprintf_break_lock(void);
-
-#ifdef __i386__
-static void
-panic_32(__unused int code, __unused int pc, __unused const char *msg, boolean_t do_mca_dump, boolean_t do_bt)
-{
- struct i386_tss *my_ktss = current_ktss();
-
- /* Set postcode (DEBUG only) */
- postcode(pc);
-
- /*
- * Issue an I/O port read if one has been requested - this is an
- * event logic analyzers can use as a trigger point.
- */
- panic_io_port_read();
-
- /*
- * Break kprintf lock in case of recursion,
- * and record originally faulted instruction address.
- */
- kprintf_break_lock();
-
- if (do_mca_dump) {
-#if CONFIG_MCA
- /*
- * Dump the contents of the machine check MSRs (if any).
- */
- mca_dump();
-#endif
- }
-
-#if MACH_KDP
- /*
- * Print backtrace leading to first fault:
- */
- if (do_bt)
- panic_i386_backtrace((void *) my_ktss->ebp, 10, NULL, FALSE, NULL);
-#endif
-
- panic("%s at 0x%08x, thread:%p, code:0x%x, "
- "registers:\n"
- "CR0: 0x%08x, CR2: 0x%08x, CR3: 0x%08x, CR4: 0x%08x\n"
- "EAX: 0x%08x, EBX: 0x%08x, ECX: 0x%08x, EDX: 0x%08x\n"
- "ESP: 0x%08x, EBP: 0x%08x, ESI: 0x%08x, EDI: 0x%08x\n"
- "EFL: 0x%08x, EIP: 0x%08x\n",
- msg,
- my_ktss->eip, current_thread(), code,
- (uint32_t)get_cr0(), (uint32_t)get_cr2(), (uint32_t)get_cr3(), (uint32_t)get_cr4(),
- my_ktss->eax, my_ktss->ebx, my_ktss->ecx, my_ktss->edx,
- my_ktss->esp, my_ktss->ebp, my_ktss->esi, my_ktss->edi,
- my_ktss->eflags, my_ktss->eip);
-}
-
-/*
- * Called from locore on a special reserved stack after a double-fault
- * is taken in kernel space.
- * Kernel stack overflow is one route here.
- */
-void
-panic_double_fault32(int code)
-{
- panic_32(code, PANIC_DOUBLE_FAULT, "Double fault", FALSE, TRUE);
-}
-
-/*
- * Called from locore on a special reserved stack after a machine-check
- */
-void
-panic_machine_check32(int code)
-{
- panic_32(code, PANIC_MACHINE_CHECK, "Machine-check", TRUE, FALSE);
-}
-#endif /* __i386__ */
-
-static void
-panic_64(x86_saved_state_t *sp, __unused int pc, __unused const char *msg, boolean_t do_mca_dump)
-{
- /* Set postcode (DEBUG only) */
- postcode(pc);