Author: jhibbits
Date: Sun Jan 28 19:18:40 2018
New Revision: 328516
URL: https://svnweb.freebsd.org/changeset/base/328516

Log:
  Consolidate trap instruction checks to a single function
  
  Summary:
  Rather than duplicating the checks for programmatic traps all over the code, 
put
  it all in one function.  This helps to remove some of the #ifdefs between AIM
  and Book-E.
  
  Reviewed By: nwhitehorn
  Differential Revision: https://reviews.freebsd.org/D14082

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==============================================================================
--- head/sys/powerpc/powerpc/trap.c     Sun Jan 28 18:38:17 2018        
(r328515)
+++ head/sys/powerpc/powerpc/trap.c     Sun Jan 28 19:18:40 2018        
(r328516)
@@ -183,6 +183,16 @@ trapname(u_int vector)
        return ("unknown");
 }
 
+static inline bool
+frame_is_trap_inst(struct trapframe *frame)
+{
+#ifdef AIM
+       return (frame->exc == EXC_PGM && frame->srr1 & EXC_PGM_TRAP);
+#else
+       return (frame->exc == EXC_DEBUG || frame->cpu.booke.esr & ESR_PTR);
+#endif
+}
+
 void
 trap(struct trapframe *frame)
 {
@@ -323,11 +333,7 @@ trap(struct trapframe *frame)
 
                case EXC_PGM:
                        /* Identify the trap reason */
-#ifdef AIM
-                       if (frame->srr1 & EXC_PGM_TRAP) {
-#else
-                       if (frame->cpu.booke.esr & ESR_PTR) {
-#endif
+                       if (frame_is_trap_inst(frame)) {
 #ifdef KDTRACE_HOOKS
                                inst = fuword32((const void *)frame->srr0);
                                if (inst == 0x0FFFDDDD &&
@@ -371,11 +377,7 @@ trap(struct trapframe *frame)
                switch (type) {
                case EXC_PGM:
 #ifdef KDTRACE_HOOKS
-#ifdef AIM
-                       if (frame->srr1 & EXC_PGM_TRAP) {
-#else
-                       if (frame->cpu.booke.esr & ESR_PTR) {
-#endif
+                       if (frame_is_trap_inst(frame)) {
                                if (*(uint32_t *)frame->srr0 == EXC_DTRACE) {
                                        if (dtrace_invop_jump_addr != NULL) {
                                                dtrace_invop_jump_addr(frame);
@@ -886,13 +888,7 @@ db_trap_glue(struct trapframe *frame)
 
        if (!(frame->srr1 & PSL_PR)
            && (frame->exc == EXC_TRC || frame->exc == EXC_RUNMODETRC
-#ifdef AIM
-               || (frame->exc == EXC_PGM
-                   && (frame->srr1 & EXC_PGM_TRAP))
-#else
-               || (frame->exc == EXC_DEBUG)
-               || (frame->cpu.booke.esr & ESR_PTR)
-#endif
+               || frame_is_trap_inst(frame)
                || frame->exc == EXC_BPT
                || frame->exc == EXC_DSI)) {
                int type = frame->exc;
@@ -900,12 +896,7 @@ db_trap_glue(struct trapframe *frame)
                /* Ignore DTrace traps. */
                if (*(uint32_t *)frame->srr0 == EXC_DTRACE)
                        return (0);
-#ifdef AIM
-               if (type == EXC_PGM && (frame->srr1 & EXC_PGM_TRAP)) {
-#else
-               if (type == EXC_DEBUG ||
-                   (frame->cpu.booke.esr & ESR_PTR)) {
-#endif
+               if (frame_is_trap_inst(frame)) {
                        type = T_BREAKPOINT;
                }
                return (kdb_trap(type, 0, frame));
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to