svn commit: r184319 - in head/sys/powerpc: aim booke include

Marcel Moolenaar marcel at FreeBSD.org
Sun Oct 26 19:36:04 PDT 2008


Author: marcel
Date: Mon Oct 27 02:36:03 2008
New Revision: 184319
URL: http://svn.freebsd.org/changeset/base/184319

Log:
  Add support for kernel profiling for both AIM and BookE.
  
  Obtained from:	Juniper Networks, Inc (BookE support).

Modified:
  head/sys/powerpc/aim/locore.S
  head/sys/powerpc/booke/locore.S
  head/sys/powerpc/include/profile.h

Modified: head/sys/powerpc/aim/locore.S
==============================================================================
--- head/sys/powerpc/aim/locore.S	Mon Oct 27 01:51:30 2008	(r184318)
+++ head/sys/powerpc/aim/locore.S	Mon Oct 27 02:36:03 2008	(r184319)
@@ -111,11 +111,14 @@ openfirmware_entry:
 srsave:
 	.long	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 
+	.text
+	.globl	btext
+btext:
+
 /*
  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
  * mark the start of kernel text.
  */
-	.text
 	.globl	kernel_text
 kernel_text:
 

Modified: head/sys/powerpc/booke/locore.S
==============================================================================
--- head/sys/powerpc/booke/locore.S	Mon Oct 27 01:51:30 2008	(r184318)
+++ head/sys/powerpc/booke/locore.S	Mon Oct 27 02:36:03 2008	(r184319)
@@ -41,11 +41,14 @@
 
 #define TMPSTACKSZ	16384
 
+	.text
+	.globl	btext
+btext:
+
 /*
  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
  * mark the start of kernel text.
  */
-	.text
 	.globl	kernel_text
 kernel_text:
 

Modified: head/sys/powerpc/include/profile.h
==============================================================================
--- head/sys/powerpc/include/profile.h	Mon Oct 27 01:51:30 2008	(r184318)
+++ head/sys/powerpc/include/profile.h	Mon Oct 27 02:36:03 2008	(r184319)
@@ -81,61 +81,87 @@ typedef u_int	fptrdiff_t;
 #define _PLT
 #endif
 
-#define	MCOUNT \
-__asm("	.globl	_mcount						\n" \
-"	.type	_mcount, at function				\n" \
-"_mcount:							\n" \
-"	stwu	%r1,-64(%r1)	/* alloca for reg save space */	\n" \
-"	stw	%r3,16(%r1)	/* save parameter registers, */	\n" \
-"	stw	%r4,20(%r1)    	/*  r3-10		     */	\n" \
-"	stw	%r5,24(%r1)	       				\n" \
-"	stw	%r6,28(%r1)	       				\n" \
-"	stw	%r7,32(%r1)	       				\n" \
-"	stw	%r8,36(%r1)	       				\n" \
-"	stw	%r9,40(%r1)	       				\n" \
-"	stw	%r10,44(%r1)					\n" \
-"								\n" \
-"	mflr	%r4		/* link register is 'selfpc' */	\n" \
-"	stw	%r4,48(%r1)    	/* save since bl will scrub  */	\n" \
-"	lwz	%r3,68(%r1)    	/* get 'frompc' from LR-save */	\n" \
-"	bl	__mcount" _PLT "  /* __mcount(frompc, selfpc)*/	\n" \
-"	lwz	%r3,68(%r1)					\n" \
-"	mtlr	%r3		/* restore caller's lr	     */	\n" \
-"	lwz	%r4,48(%r1)     			       	\n" \
-"	mtctr	%r4		/* set up ctr for call back  */	\n" \
-"				/* note that blr is not used!*/	\n" \
-"	lwz	%r3,16(%r1)	/* restore r3-10 parameters  */	\n" \
-"	lwz	%r4,20(%r1)	       				\n" \
-"	lwz	%r5,24(%r1)	       				\n" \
-"	lwz	%r6,28(%r1)	       				\n" \
-"	lwz	%r7,32(%r1)	       				\n" \
-"	lwz	%r8,36(%r1)	       				\n" \
-"	lwz	%r9,40(%r1)	       				\n" \
-"	lwz	%r10,44(%r1)					\n" \
-"	addi	%r1,%r1,64	/* blow away alloca save area */ \n" \
-"	bctr			/* return with indirect call */	\n" \
-"_mcount_end:				\n" \
-"	.size	_mcount,_mcount_end-_mcount");
-
+#define	MCOUNT					\
+__asm(	"	.globl	_mcount			\n" \
+	"	.type	_mcount, at function	\n" \
+	"	.align	4			\n" \
+	"_mcount:				\n" \
+	"	stwu	%r1,-64(%r1)		\n" \
+	"	stw	%r3,16(%r1)		\n" \
+	"	stw	%r4,20(%r1)		\n" \
+	"	stw	%r5,24(%r1)		\n" \
+	"	stw	%r6,28(%r1)		\n" \
+	"	stw	%r7,32(%r1)		\n" \
+	"	stw	%r8,36(%r1)		\n" \
+	"	stw	%r9,40(%r1)		\n" \
+	"	stw	%r10,44(%r1)		\n" \
+	"	mflr	%r4			\n" \
+	"	stw	%r4,48(%r1)		\n" \
+	"	lwz	%r3,68(%r1)		\n" \
+	"	bl	__mcount" _PLT "	\n" \
+	"	lwz	%r3,68(%r1)		\n" \
+	"	mtlr	%r3			\n" \
+	"	lwz	%r4,48(%r1)		\n" \
+	"	mtctr	%r4			\n" \
+	"	lwz	%r3,16(%r1)		\n" \
+	"	lwz	%r4,20(%r1)		\n" \
+	"	lwz	%r5,24(%r1)		\n" \
+	"	lwz	%r6,28(%r1)		\n" \
+	"	lwz	%r7,32(%r1)		\n" \
+	"	lwz	%r8,36(%r1)		\n" \
+	"	lwz	%r9,40(%r1)		\n" \
+	"	lwz	%r10,44(%r1)		\n" \
+	"	addi	%r1,%r1,64		\n" \
+	"	bctr				\n" \
+	"_mcount_end:				\n" \
+	"	.size	_mcount,_mcount_end-_mcount");
 
 #ifdef _KERNEL
-#define MCOUNT_ENTER(s)		s = intr_disable();
-#define MCOUNT_EXIT(s)		intr_restore(s);
-#define	MCOUNT_DECL(s)		register_t s
-
-void bintr(void);
-void btrap(void);
-void eintr(void);
-void user(void);
-
-#define	MCOUNT_FROMPC_USER(pc)					\
-	((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc)
-
-#define	MCOUNT_FROMPC_INTR(pc)					\
-	((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ?	\
-	    ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr :	\
-		(uintfptr_t)btrap) : ~0U)
+#define	MCOUNT_ENTER(s)		s = intr_disable()
+#define	MCOUNT_EXIT(s)		intr_restore(s)
+#define	MCOUNT_DECL(s)		register_t s;
+
+#ifndef COMPILING_LINT
+#ifdef AIM
+#include <machine/trap.h>
+#define	__PROFILE_VECTOR_BASE	EXC_RST
+#define	__PROFILE_VECTOR_TOP	(EXC_LAST + 0x100)
+#endif	/* AIM */
+#ifdef E500
+extern char interrupt_vector_base[];
+extern char interrupt_vector_top[];
+#define	__PROFILE_VECTOR_BASE	(uintfptr_t)interrupt_vector_base
+#define	__PROFILE_VECTOR_TOP	(uintfptr_t)interrupt_vector_top
+#endif	/* E500 */
+#endif	/* !COMPILING_LINT */
+
+#ifndef __PROFILE_VECTOR_BASE
+#define	__PROFILE_VECTOR_BASE	0
+#endif
+#ifndef __PROFILE_VECTOR_TOP
+#define	__PROFILE_VECTOR_TOP	1
+#endif
+
+static __inline void
+powerpc_profile_interrupt(void)
+{
+}
+
+static __inline void
+powerpc_profile_userspace(void)
+{
+}
+
+#define	MCOUNT_FROMPC_USER(pc)				\
+	((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ?	\
+	    (uintfptr_t)powerpc_profile_userspace : pc)
+
+#define	MCOUNT_FROMPC_INTR(pc)				\
+	((pc >= __PROFILE_VECTOR_BASE &&		\
+	  pc < __PROFILE_VECTOR_TOP) ?			\
+	    (uintfptr_t)powerpc_profile_interrupt : ~0U)
 
+void __mcount(uintfptr_t frompc, uintfptr_t selfpc);
 
 #else	/* !_KERNEL */
 


More information about the svn-src-head mailing list