Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2008 02:37:21 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 135935 for review
Message-ID:  <200802220237.m1M2bL1j026613@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=135935

Change 135935 by marcel@marcel_jnpr on 2008/02/22 02:36:54

	Unify <machine/frame.h>
	
	In this case the difference between Book E and AIM is
	just the name of the DAR/DEAR and DSISR/ESR registers.
	One can argue that this can be eliminated by using
	structure fields that match neither, but imply either.
	Euh... right...
	However, it's valuable to keep the fields the same as
	the register names, so in this case a simple union is
	enough to eliminate the #ifdefs.

Affected files ...

.. //depot/projects/e500/sys/powerpc/aim/machdep.c#8 edit
.. //depot/projects/e500/sys/powerpc/aim/trap.c#7 edit
.. //depot/projects/e500/sys/powerpc/aim/trap_subr.S#4 edit
.. //depot/projects/e500/sys/powerpc/booke/interrupt.c#4 edit
.. //depot/projects/e500/sys/powerpc/booke/machdep.c#10 edit
.. //depot/projects/e500/sys/powerpc/booke/trap.c#4 edit
.. //depot/projects/e500/sys/powerpc/booke/trap_subr.S#4 edit
.. //depot/projects/e500/sys/powerpc/include/frame.h#3 edit
.. //depot/projects/e500/sys/powerpc/powerpc/db_trace.c#4 edit
.. //depot/projects/e500/sys/powerpc/powerpc/genassym.c#4 edit

Differences ...

==== //depot/projects/e500/sys/powerpc/aim/machdep.c#8 (text+ko) ====

@@ -519,13 +519,13 @@
 		 */
 		sf.sf_si = ksi->ksi_info;
 		sf.sf_si.si_signo = sig;
-		sf.sf_si.si_addr = (void *) ((tf->exc == EXC_DSI) ? 
-		                             tf->dar : tf->srr0);
+		sf.sf_si.si_addr = (void *)((tf->exc == EXC_DSI) ? 
+		    tf->cpu.aim.dar : tf->srr0);
 	} else {
 		/* Old FreeBSD-style arguments. */
 		tf->fixreg[FIRSTARG+1] = code;
 		tf->fixreg[FIRSTARG+3] = (tf->exc == EXC_DSI) ? 
-		                             tf->dar : tf->srr0;
+		    tf->cpu.aim.dar : tf->srr0;
 	}
 	mtx_unlock(&psp->ps_mtx);
 	PROC_UNLOCK(p);

==== //depot/projects/e500/sys/powerpc/aim/trap.c#7 (text+ko) ====

@@ -292,7 +292,7 @@
 	    trapname(vector));
 	switch (vector) {
 	case EXC_DSI:
-		printf("   virtual address = 0x%x\n", frame->dar);
+		printf("   virtual address = 0x%x\n", frame->cpu.aim.dar);
 		break;
 	case EXC_ISI:
 		printf("   virtual address = 0x%x\n", frame->srr0);
@@ -510,8 +510,8 @@
 		eva = frame->srr0;
 		ftype = VM_PROT_READ | VM_PROT_EXECUTE;
 	} else {
-		eva = frame->dar;
-		if (frame->dsisr & DSISR_STORE)
+		eva = frame->cpu.aim.dar;
+		if (frame->cpu.aim.dsisr & DSISR_STORE)
 			ftype = VM_PROT_WRITE;
 		else
 			ftype = VM_PROT_READ;
@@ -643,12 +643,12 @@
 	int		indicator, reg;
 	double		*fpr;
 
-	indicator = EXC_ALI_OPCODE_INDICATOR(frame->dsisr);
+	indicator = EXC_ALI_OPCODE_INDICATOR(frame->cpu.aim.dsisr);
 
 	switch (indicator) {
 	case EXC_ALI_LFD:
 	case EXC_ALI_STFD:
-		reg = EXC_ALI_RST(frame->dsisr);
+		reg = EXC_ALI_RST(frame->cpu.aim.dsisr);
 		fpr = &td->td_pcb->pcb_fpu.fpr[reg];
 		fputhread = PCPU_GET(fputhread);
 
@@ -664,12 +664,12 @@
 		save_fpu(td);
 
 		if (indicator == EXC_ALI_LFD) {
-			if (copyin((void *)frame->dar, fpr,
+			if (copyin((void *)frame->cpu.aim.dar, fpr,
 			    sizeof(double)) != 0)
 				return -1;
 			enable_fpu(td);
 		} else {
-			if (copyout(fpr, (void *)frame->dar,
+			if (copyout(fpr, (void *)frame->cpu.aim.dar,
 			    sizeof(double)) != 0)
 				return -1;
 		}

==== //depot/projects/e500/sys/powerpc/aim/trap_subr.S#4 (text+ko) ====

@@ -151,8 +151,8 @@
 	stw	%r3, FRAME_XER+8(1);	/* save xer/ctr/exc */		\
 	stw	%r4, FRAME_CTR+8(1);					\
 	stw	%r5, FRAME_EXC+8(1);					\
-	stw	%r28,FRAME_DAR+8(1);					\
-	stw	%r29,FRAME_DSISR+8(1);	/* save dsisr/srr0/srr1 */	\
+	stw	%r28,FRAME_AIM_DAR+8(1);				\
+	stw	%r29,FRAME_AIM_DSISR+8(1); /* save dsisr/srr0/srr1 */	\
 	stw	%r30,FRAME_SRR0+8(1);					\
 	stw	%r31,FRAME_SRR1+8(1)
 

==== //depot/projects/e500/sys/powerpc/booke/interrupt.c#4 (text+ko) ====

@@ -82,8 +82,8 @@
 	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->dear);
-	printf("  esr  = 0x%08x\n", frame->esr);
+	printf("  dear = 0x%08x\n", frame->cpu.booke.dear);
+	printf("  esr  = 0x%08x\n", frame->cpu.booke.esr);
 	printf("  lr   = 0x%08x\n", frame->lr);
 	printf("  cr   = 0x%08x\n", frame->cr);
 	printf("  sp   = 0x%08x\n", frame->fixreg[1]);

==== //depot/projects/e500/sys/powerpc/booke/machdep.c#10 (text+ko) ====

@@ -871,12 +871,12 @@
 		sf.sf_si = ksi->ksi_info;
 		sf.sf_si.si_signo = sig;
 		sf.sf_si.si_addr = (void *) ((tf->exc == EXC_DSI) ?
-		                             tf->dear : tf->srr0);
+		    tf->cpu.booke.dear : tf->srr0);
 	} else {
 		/* Old FreeBSD-style arguments. */
 		tf->fixreg[FIRSTARG+1] = code;
 		tf->fixreg[FIRSTARG+3] = (tf->exc == EXC_DSI) ?
-		                          tf->dear : tf->srr0;
+		    tf->cpu.booke.dear : tf->srr0;
 	}
 	mtx_unlock(&psp->ps_mtx);
 	PROC_UNLOCK(p);

==== //depot/projects/e500/sys/powerpc/booke/trap.c#4 (text+ko) ====

@@ -222,7 +222,7 @@
 			break;
 #ifdef KDB
 		case EXC_PGM:
-			if (frame->esr & ESR_PTR)
+			if (frame->cpu.booke.esr & ESR_PTR)
 				kdb_trap(EXC_PGM, 0, frame);
 			return;
 #endif
@@ -274,7 +274,7 @@
 	switch (vector) {
 	case EXC_DTMISS:
 	case EXC_DSI:
-		va = frame->dear;
+		va = frame->cpu.booke.dear;
 		break;
 
 	case EXC_ITMISS:
@@ -499,8 +499,8 @@
 		ftype = VM_PROT_READ | VM_PROT_EXECUTE;
 
 	} else {
-		eva = frame->dear;
-		if (frame->esr & ESR_ST)
+		eva = frame->cpu.booke.dear;
+		if (frame->cpu.booke.esr & ESR_ST)
 			ftype = VM_PROT_WRITE;
 		else
 			ftype = VM_PROT_READ;

==== //depot/projects/e500/sys/powerpc/booke/trap_subr.S#4 (text+ko) ====

@@ -198,8 +198,8 @@
 	/* save DEAR, ESR */						\
 	lwz	%r28, (savearea+CPUSAVE_DEAR)(%r2);			\
 	lwz	%r29, (savearea+CPUSAVE_ESR)(%r2);			\
-	stw	%r28, FRAME_DEAR+8(1);					\
-	stw	%r29, FRAME_ESR+8(1);					\
+	stw	%r28, FRAME_BOOKE_DEAR+8(1);				\
+	stw	%r29, FRAME_BOOKE_ESR+8(1);				\
 	/* save XER, CTR, exc number */					\
 	mfxer	%r3;							\
 	mfctr	%r4;							\

==== //depot/projects/e500/sys/powerpc/include/frame.h#3 (text+ko) ====

@@ -50,20 +50,25 @@
 struct trapframe {
 	register_t fixreg[32];
 	register_t lr;
-	int cr;
-	int xer;
+	int	cr;
+	int	xer;
 	register_t ctr;
 	register_t srr0;
 	register_t srr1;
-#if defined(AIM)
-	register_t dar;		/* dar & dsisr are only filled on a DSI trap */
-	int dsisr;
-#elif defined(E500)
-	register_t dear;
-	register_t esr;
-#endif
-	int exc;
+	int	exc;
+	union {
+		struct {
+			/* dar & dsisr are only filled on a DSI trap */
+			register_t dar;
+			int	dsisr;
+		} aim;
+		struct {
+			register_t dear;
+			register_t esr;
+		} booke;
+	} cpu;
 };
+
 /*
  * This is to ensure alignment of the stackpointer
  */

==== //depot/projects/e500/sys/powerpc/powerpc/db_trace.c#4 (text+ko) ====

@@ -92,12 +92,13 @@
 	{ "ctr", DB_OFFSET(ctr),	db_frame },
 	{ "cr",	 DB_OFFSET(cr),		db_frame },
 	{ "xer", DB_OFFSET(xer),	db_frame },
+#ifdef AIM
+	{ "dar", DB_OFFSET(cpu.aim.dar),	db_frame },
+	{ "dsisr", DB_OFFSET(cpu.aim.dsisr),	db_frame },
+#endif
 #ifdef E500
-	{ "dear", DB_OFFSET(dear),	db_frame },
-	{ "esr", DB_OFFSET(esr),	db_frame },
-#else
-	{ "dar", DB_OFFSET(dar),	db_frame },
-	{ "dsisr", DB_OFFSET(dsisr),	db_frame },
+	{ "dear", DB_OFFSET(cpu.booke.dear),	db_frame },
+	{ "esr", DB_OFFSET(cpu.booke.esr),	db_frame },
 #endif
 };
 struct db_variable *db_eregs = db_regs + sizeof (db_regs)/sizeof (db_regs[0]);
@@ -199,24 +200,15 @@
 			db_printf("%s ", tf->srr1 & PSL_PR ? "user" : "kernel");
 			switch (tf->exc) {
 			case EXC_DSI:
-#ifdef E500
+				/* XXX take advantage of the union. */
 				db_printf("DSI %s trap @ %#x by ",
-				    tf->esr & DSISR_STORE ? "write" : "read",
-				    tf->dear);
-#else
-				db_printf("DSI %s trap @ %#x by ",
-				    tf->dsisr & DSISR_STORE ? "write" : "read",
-				    tf->dar);
-#endif
+				    (tf->cpu.aim.dsisr & DSISR_STORE) ? "write"
+				    : "read", tf->cpu.aim.dar);
 				goto print_trap;
 			case EXC_ALI:
-#ifdef E500
-				db_printf("ALI trap @ %#x (ESR %#x) ",
-					  tf->dear, tf->esr);
-#else
-				db_printf("ALI trap @ %#x (DSISR %#x) ",
-					  tf->dar, tf->dsisr);
-#endif
+				/* XXX take advantage of the union. */
+				db_printf("ALI trap @ %#x (xSR %#x) ",
+				    tf->cpu.aim.dar, tf->cpu.aim.dsisr);
 				goto print_trap;
 			case EXC_ISI: trapstr = "ISI"; break;
 			case EXC_PGM: trapstr = "PGM"; break;
@@ -257,13 +249,8 @@
 			}
 			db_printf("%-10s  r1=%#x cr=%#x xer=%#x ctr=%#x",
 			    "", tf->fixreg[1], tf->cr, tf->xer, tf->ctr);
-#ifdef E500
 			if (tf->exc == EXC_DSI)
-				db_printf(" esr=%#x", tf->esr);
-#else
-			if (tf->exc == EXC_DSI)
-				db_printf(" dsisr=%#x", tf->dsisr);
-#endif
+				db_printf(" sr=%#x", tf->cpu.aim.dsisr);
 			db_printf("\n");
 			stackframe = (db_addr_t) tf->fixreg[1];
 			if (kernel_only && (tf->srr1 & PSL_PR))

==== //depot/projects/e500/sys/powerpc/powerpc/genassym.c#4 (text+ko) ====

@@ -160,14 +160,11 @@
 ASSYM(FRAME_XER, offsetof(struct trapframe, xer));
 ASSYM(FRAME_SRR0, offsetof(struct trapframe, srr0));
 ASSYM(FRAME_SRR1, offsetof(struct trapframe, srr1));
-#if defined(AIM)
-ASSYM(FRAME_DAR, offsetof(struct trapframe, dar));
-ASSYM(FRAME_DSISR, offsetof(struct trapframe, dsisr));
-#elif defined(E500)
-ASSYM(FRAME_DEAR, offsetof(struct trapframe, dear));
-ASSYM(FRAME_ESR, offsetof(struct trapframe, esr));
-#endif
 ASSYM(FRAME_EXC, offsetof(struct trapframe, exc));
+ASSYM(FRAME_AIM_DAR, offsetof(struct trapframe, cpu.aim.dar));
+ASSYM(FRAME_AIM_DSISR, offsetof(struct trapframe, cpu.aim.dsisr));
+ASSYM(FRAME_BOOKE_DEAR, offsetof(struct trapframe, cpu.booke.dear));
+ASSYM(FRAME_BOOKE_ESR, offsetof(struct trapframe, cpu.booke.esr));
 
 ASSYM(CF_FUNC, offsetof(struct callframe, cf_func));
 ASSYM(CF_ARG0, offsetof(struct callframe, cf_arg0));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802220237.m1M2bL1j026613>