summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-07-24 19:12:35 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-07-24 19:12:35 +0000
commitb3fe4a6b5199e81079fe4fe09cbc4dffdfa5e83a (patch)
tree67cbf792cb765a146e724c3195e46cae6f802353
parent4daf6b3f120b07ffbb2da94bdb111c02d4d3d706 (diff)
New, working, profiling code for m88k.
-rw-r--r--lib/csu/m88k/crt0.c21
-rw-r--r--sys/arch/m88k/include/profile.h85
2 files changed, 51 insertions, 55 deletions
diff --git a/lib/csu/m88k/crt0.c b/lib/csu/m88k/crt0.c
index 494c4a1b8a1..00e194a48f3 100644
--- a/lib/csu/m88k/crt0.c
+++ b/lib/csu/m88k/crt0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crt0.c,v 1.7 2004/01/04 20:05:38 pvalchev Exp $ */
+/* $OpenBSD: crt0.c,v 1.8 2004/07/24 19:12:33 miod Exp $ */
/*
* Mach Operating System
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: crt0.c,v 1.7 2004/01/04 20:05:38 pvalchev Exp $";
+static char rcsid[] = "$OpenBSD: crt0.c,v 1.8 2004/07/24 19:12:33 miod Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -76,8 +76,23 @@ start(struct kframe *kfp)
__progname = __progname_storage;
}
-asm ("__callmain:"); /* Defined for the benefit of debuggers */
+__asm__ ("eprol:");
+
+#ifdef MCRT0
+ atexit(_mcleanup);
+ monstartup((u_long)&eprol, (u_long)&etext);
+#endif
+
+__asm__ ("__callmain:"); /* Defined for the benefit of debuggers */
exit(main(kfp->argc, argv, environ));
}
#include "common.c"
+
+#ifdef MCRT0
+__asm__ ("\
+ text\n\
+ global _eprol\n\
+_eprol:\n\
+");
+#endif
diff --git a/sys/arch/m88k/include/profile.h b/sys/arch/m88k/include/profile.h
index 1985c9b0443..3bf23c9d8f7 100644
--- a/sys/arch/m88k/include/profile.h
+++ b/sys/arch/m88k/include/profile.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: profile.h,v 1.1 2004/04/29 06:25:34 miod Exp $ */
+#ifndef __M88K_PROFILE_H__
+#define __M88K_PROFILE_H__
+/* $OpenBSD: profile.h,v 1.2 2004/07/24 19:12:34 miod Exp $ */
/*
- * Copyright (c) 1996 Nivas Madhur
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2004, Miodrag Vallat.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -12,60 +12,41 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)profile.h 8.1 (Berkeley) 6/11/93
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __MACHINE_PROFILE_H__
-#define __MACHINE_PROFILE_H__
+
#define _MCOUNT_DECL static inline void _mcount
+/*
+ * On OpenBSD, calls to the function profiler save r2-r9 on stack. The
+ * monitor point is found in r1. The function's return address is taken
+ * from the stack frame pointed to by r30.
+ */
#define MCOUNT \
-extern void mcount() __asm__ ("mcount"); \
-void \
-mcount() \
-{ \
- int selfret; \
- int callerret; \
- /* \
- * find the return address for mcount, \
- * and the return address for mcount's caller. \
- * \
- * selfret = ret pushed by mcount call \
- */ \
- __asm__ __volatile__ ("or %0,r1,0" : "=r" (selfret)); \
- /* \
- * callerret = ret pushed by call into self. \
- */ \
- /* \
- * This may not be right. It all depends on where the \
- * caller stores the return address. XXX \
- */ \
- __asm__ __volatile__("addu r10,r31,48"); \
- __asm__ __volatile__("ld %0,r10,36" : "=r" (callerret)); \
- _mcount(callerret, selfret); \
+extern void mcount(void) __asm__ ("mcount"); \
+void \
+mcount() \
+{ \
+ int returnaddress, monpoint; \
+ __asm__ __volatile__ ("or %0, r1, r0" : "=r"(returnaddress)); \
+ __asm__ __volatile__ ("ld %0, r30, 4" : "=r"(monpoint)); \
+ _mcount(monpoint, returnaddress); \
}
#ifdef _KERNEL
-/*
- * Note that we assume splhigh() and splx() cannot call mcount()
- * recursively.
- */
-#define MCOUNT_ENTER s = splhigh()
-#define MCOUNT_EXIT splx(s)
+#define MCOUNT_ENTER s = disable_interrupt()
+#define MCOUNT_EXIT set_psr(s)
#endif /* _KERNEL */
-#endif /* __MACHINE_PROFILE_H__ */
+
+#endif /* __M88K_PROFILE_H__ */