Split printtrap() into generic and CPU-specific components

Summary:
This compartmentalizes the CPU-specific trap components into its own
function, rather than littering the general printtrap() with various checks.
This will let us replace a series of #ifdef's with a runtime conditional check
in the future.

Reviewed By:	nwhitehorn
Differential Revision:	https://reviews.freebsd.org/D14416
This commit is contained in:
jhibbits 2018-02-21 03:34:33 +00:00
parent 7704db0f8f
commit 225ff95e18

View File

@ -444,13 +444,45 @@ trap_fatal(struct trapframe *frame)
panic("%s trap", trapname(frame->exc));
}
static void
cpu_printtrap(u_int vector, struct trapframe *frame, int isfatal, int user)
{
#ifdef AIM
uint16_t ver;
switch (vector) {
case EXC_DSE:
case EXC_DSI:
case EXC_DTMISS:
printf(" dsisr = 0x%lx\n",
(u_long)frame->cpu.aim.dsisr);
break;
case EXC_MCHK:
ver = mfpvr() >> 16;
if (MPC745X_P(ver))
printf(" msssr0 = 0x%b\n",
(int)mfspr(SPR_MSSSR0), MSSSR_BITMASK);
break;
}
#elif defined(BOOKE)
vm_paddr_t pa;
switch (vector) {
case EXC_MCHK:
pa = mfspr(SPR_MCARU);
pa = (pa << 32) | (u_register_t)mfspr(SPR_MCAR);
printf(" mcsr = 0x%b\n",
(int)mfspr(SPR_MCSR), MCSR_BITMASK);
printf(" mcar = 0x%jx\n", (uintmax_t)pa);
}
printf(" esr = 0x%b\n",
(int)frame->cpu.booke.esr, ESR_BITMASK);
#endif
}
static void
printtrap(u_int vector, struct trapframe *frame, int isfatal, int user)
{
uint16_t ver;
#ifdef BOOKE
vm_paddr_t pa;
#endif
printf("\n");
printf("%s %s trap:\n", isfatal ? "fatal" : "handled",
@ -462,10 +494,6 @@ printtrap(u_int vector, struct trapframe *frame, int isfatal, int user)
case EXC_DSI:
case EXC_DTMISS:
printf(" virtual address = 0x%" PRIxPTR "\n", frame->dar);
#ifdef AIM
printf(" dsisr = 0x%lx\n",
(u_long)frame->cpu.aim.dsisr);
#endif
break;
case EXC_ISE:
case EXC_ISI:
@ -473,24 +501,9 @@ printtrap(u_int vector, struct trapframe *frame, int isfatal, int user)
printf(" virtual address = 0x%" PRIxPTR "\n", frame->srr0);
break;
case EXC_MCHK:
ver = mfpvr() >> 16;
#if defined(AIM)
if (MPC745X_P(ver))
printf(" msssr0 = 0x%b\n",
(int)mfspr(SPR_MSSSR0), MSSSR_BITMASK);
#elif defined(BOOKE)
pa = mfspr(SPR_MCARU);
pa = (pa << 32) | (u_register_t)mfspr(SPR_MCAR);
printf(" mcsr = 0x%b\n",
(int)mfspr(SPR_MCSR), MCSR_BITMASK);
printf(" mcar = 0x%jx\n", (uintmax_t)pa);
#endif
break;
}
#ifdef BOOKE
printf(" esr = 0x%b\n",
(int)frame->cpu.booke.esr, ESR_BITMASK);
#endif
cpu_printtrap(vector, frame, isfatal, user);
printf(" srr0 = 0x%" PRIxPTR " (0x%" PRIxPTR ")\n",
frame->srr0, frame->srr0 - (register_t)(__startkernel - KERNBASE));
printf(" srr1 = 0x%lx\n", (u_long)frame->srr1);