Author: nwhitehorn
Date: Wed Mar  4 21:06:57 2015
New Revision: 279601
URL: https://svnweb.freebsd.org/changeset/base/279601

Log:
  The AIM DAR (data access fault address register) and Book-E DEAR registers
  have the same meaning and occupy the same memory address in the trapframe
  courtesy of union. Avoid some pointless #ifdef by spelling them both 'DAR'
  in the trapframe.

Modified:
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/booke/interrupt.c
  head/sys/powerpc/booke/trap.c
  head/sys/powerpc/include/frame.h
  head/sys/powerpc/powerpc/db_trace.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/genassym.c

Modified: head/sys/powerpc/aim/trap.c
==============================================================================
--- head/sys/powerpc/aim/trap.c Wed Mar  4 20:47:43 2015        (r279600)
+++ head/sys/powerpc/aim/trap.c Wed Mar  4 21:06:57 2015        (r279601)
@@ -201,8 +201,7 @@ trap(struct trapframe *frame)
                case EXC_ISE:
                case EXC_DSE:
                        if (handle_user_slb_spill(&p->p_vmspace->vm_pmap,
-                           (type == EXC_ISE) ? frame->srr0 :
-                           frame->cpu.aim.dar) != 0) {
+                           (type == EXC_ISE) ? frame->srr0 : frame->dar) != 0){
                                sig = SIGSEGV;
                                ucode = SEGV_MAPERR;
                        }
@@ -326,7 +325,7 @@ trap(struct trapframe *frame)
 #endif
 #ifdef __powerpc64__
                case EXC_DSE:
-                       if ((frame->cpu.aim.dar & SEGMENT_MASK) == USER_ADDR) {
+                       if ((frame->dar & SEGMENT_MASK) == USER_ADDR) {
                                __asm __volatile ("slbmte %0, %1" ::
                                        "r"(td->td_pcb->pcb_cpu.aim.usr_vsid),
                                        "r"(USER_SLB_SLBE));
@@ -387,8 +386,7 @@ printtrap(u_int vector, struct trapframe
        switch (vector) {
        case EXC_DSE:
        case EXC_DSI:
-               printf("   virtual address = 0x%" PRIxPTR "\n",
-                   frame->cpu.aim.dar);
+               printf("   virtual address = 0x%" PRIxPTR "\n", frame->dar);
                printf("   dsisr           = 0x%" PRIxPTR "\n",
                    frame->cpu.aim.dsisr);
                break;
@@ -642,7 +640,7 @@ trap_pfault(struct trapframe *frame, int
                if (frame->srr1 & SRR1_ISI_PFAULT)
                        ftype |= VM_PROT_READ;
        } else {
-               eva = frame->cpu.aim.dar;
+               eva = frame->dar;
                if (frame->cpu.aim.dsisr & DSISR_STORE)
                        ftype = VM_PROT_WRITE;
                else
@@ -736,12 +734,12 @@ fix_unaligned(struct thread *td, struct 
                save_fpu(td);
 
                if (indicator == EXC_ALI_LFD) {
-                       if (copyin((void *)frame->cpu.aim.dar, fpr,
+                       if (copyin((void *)frame->dar, fpr,
                            sizeof(double)) != 0)
                                return -1;
                        enable_fpu(td);
                } else {
-                       if (copyout(fpr, (void *)frame->cpu.aim.dar,
+                       if (copyout(fpr, (void *)frame->dar,
                            sizeof(double)) != 0)
                                return -1;
                }

Modified: head/sys/powerpc/booke/interrupt.c
==============================================================================
--- head/sys/powerpc/booke/interrupt.c  Wed Mar  4 20:47:43 2015        
(r279600)
+++ head/sys/powerpc/booke/interrupt.c  Wed Mar  4 21:06:57 2015        
(r279601)
@@ -79,7 +79,7 @@ dump_frame(struct trapframe *frame)
        printf("  exc  = 0x%x\n", frame->exc);
        printf("  srr0 = 0x%08x\n", frame->srr0);
        printf("  srr1 = 0x%08x\n", frame->srr1);
-       printf("  dear = 0x%08x\n", frame->cpu.booke.dear);
+       printf("  dear = 0x%08x\n", frame->dar);
        printf("  esr  = 0x%08x\n", frame->cpu.booke.esr);
        printf("  lr   = 0x%08x\n", frame->lr);
        printf("  cr   = 0x%08x\n", frame->cr);

Modified: head/sys/powerpc/booke/trap.c
==============================================================================
--- head/sys/powerpc/booke/trap.c       Wed Mar  4 20:47:43 2015        
(r279600)
+++ head/sys/powerpc/booke/trap.c       Wed Mar  4 21:06:57 2015        
(r279601)
@@ -263,7 +263,7 @@ printtrap(u_int vector, struct trapframe
        switch (vector) {
        case EXC_DTMISS:
        case EXC_DSI:
-               va = frame->cpu.booke.dear;
+               va = frame->dar;
                break;
 
        case EXC_ITMISS:
@@ -400,7 +400,7 @@ trap_pfault(struct trapframe *frame, int
                ftype = VM_PROT_READ | VM_PROT_EXECUTE;
 
        } else {
-               eva = frame->cpu.booke.dear;
+               eva = frame->dar;
                if (frame->cpu.booke.esr & ESR_ST)
                        ftype = VM_PROT_WRITE;
                else

Modified: head/sys/powerpc/include/frame.h
==============================================================================
--- head/sys/powerpc/include/frame.h    Wed Mar  4 20:47:43 2015        
(r279600)
+++ head/sys/powerpc/include/frame.h    Wed Mar  4 21:06:57 2015        
(r279601)
@@ -56,14 +56,13 @@ struct trapframe {
        register_t srr0;
        register_t srr1;
        register_t exc;
+       register_t dar; /* DAR/DEAR filled in on DSI traps */
        union {
                struct {
-                       /* dar & dsisr are only filled on a DSI trap */
-                       register_t dar;
+                       /* dsisr only filled on a DSI trap */
                        register_t dsisr;
                } aim;
                struct {
-                       register_t dear;
                        register_t esr;
                        register_t dbcr0;
                } booke;

Modified: head/sys/powerpc/powerpc/db_trace.c
==============================================================================
--- head/sys/powerpc/powerpc/db_trace.c Wed Mar  4 20:47:43 2015        
(r279600)
+++ head/sys/powerpc/powerpc/db_trace.c Wed Mar  4 21:06:57 2015        
(r279601)
@@ -98,12 +98,11 @@ struct db_variable db_regs[] = {
        { "ctr", DB_OFFSET(ctr),        db_frame },
        { "cr",  DB_OFFSET(cr),         db_frame },
        { "xer", DB_OFFSET(xer),        db_frame },
+       { "dar", DB_OFFSET(dar),        db_frame },
 #ifdef AIM
-       { "dar", DB_OFFSET(cpu.aim.dar),        db_frame },
        { "dsisr", DB_OFFSET(cpu.aim.dsisr),    db_frame },
 #endif
 #if defined(BOOKE)
-       { "dear", DB_OFFSET(cpu.booke.dear),    db_frame },
        { "esr", DB_OFFSET(cpu.booke.esr),      db_frame },
 #endif
 };
@@ -218,18 +217,16 @@ db_backtrace(struct thread *td, db_addr_
                                /* XXX take advantage of the union. */
                                db_printf("DSI %s trap @ %#zx by ",
                                    (tf->cpu.aim.dsisr & DSISR_STORE) ? "write"
-                                   : "read", tf->cpu.aim.dar);
+                                   : "read", tf->dar);
                                goto print_trap;
                        case EXC_ALI:
                                /* XXX take advantage of the union. */
                                db_printf("ALI trap @ %#zx (xSR %#x) ",
-                                   tf->cpu.aim.dar,
-                                   (uint32_t)tf->cpu.aim.dsisr);
+                                   tf->dar, (uint32_t)tf->cpu.aim.dsisr);
                                goto print_trap;
 #ifdef __powerpc64__
                        case EXC_DSE:
-                               db_printf("DSE trap @ %#zx by ",
-                                   tf->cpu.aim.dar);
+                               db_printf("DSE trap @ %#zx by ", tf->dar);
                                goto print_trap;
                        case EXC_ISE:
                                db_printf("ISE trap @ %#zx by ", tf->srr0);

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/exec_machdep.c     Wed Mar  4 20:47:43 2015        
(r279600)
+++ head/sys/powerpc/powerpc/exec_machdep.c     Wed Mar  4 21:06:57 2015        
(r279601)
@@ -152,13 +152,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, 
         * Fill siginfo structure.
         */
        ksi->ksi_info.si_signo = ksi->ksi_signo;
-       #ifdef AIM
        ksi->ksi_info.si_addr = (void *)((tf->exc == EXC_DSI) ? 
-           tf->cpu.aim.dar : tf->srr0);
-       #else
-       ksi->ksi_info.si_addr = (void *)((tf->exc == EXC_DSI) ? 
-           tf->cpu.booke.dear : tf->srr0);
-       #endif
+           tf->dar : tf->srr0);
 
        #ifdef COMPAT_FREEBSD32
        if (SV_PROC_FLAG(p, SV_ILP32)) {
@@ -284,13 +279,8 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, 
        } else {
                /* Old FreeBSD-style arguments. */
                tf->fixreg[FIRSTARG+1] = code;
-               #ifdef AIM
                tf->fixreg[FIRSTARG+3] = (tf->exc == EXC_DSI) ? 
-                   tf->cpu.aim.dar : tf->srr0;
-               #else
-               tf->fixreg[FIRSTARG+3] = (tf->exc == EXC_DSI) ? 
-                   tf->cpu.booke.dear : tf->srr0;
-               #endif
+                   tf->dar : tf->srr0;
        }
        mtx_unlock(&psp->ps_mtx);
        PROC_UNLOCK(p);

Modified: head/sys/powerpc/powerpc/genassym.c
==============================================================================
--- head/sys/powerpc/powerpc/genassym.c Wed Mar  4 20:47:43 2015        
(r279600)
+++ head/sys/powerpc/powerpc/genassym.c Wed Mar  4 21:06:57 2015        
(r279601)
@@ -171,9 +171,9 @@ ASSYM(FRAME_XER, offsetof(struct trapfra
 ASSYM(FRAME_SRR0, offsetof(struct trapframe, srr0));
 ASSYM(FRAME_SRR1, offsetof(struct trapframe, srr1));
 ASSYM(FRAME_EXC, offsetof(struct trapframe, exc));
-ASSYM(FRAME_AIM_DAR, offsetof(struct trapframe, cpu.aim.dar));
+ASSYM(FRAME_AIM_DAR, offsetof(struct trapframe, dar));
 ASSYM(FRAME_AIM_DSISR, offsetof(struct trapframe, cpu.aim.dsisr));
-ASSYM(FRAME_BOOKE_DEAR, offsetof(struct trapframe, cpu.booke.dear));
+ASSYM(FRAME_BOOKE_DEAR, offsetof(struct trapframe, dar));
 ASSYM(FRAME_BOOKE_ESR, offsetof(struct trapframe, cpu.booke.esr));
 ASSYM(FRAME_BOOKE_DBCR0, offsetof(struct trapframe, cpu.booke.dbcr0));
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to