xref: /netbsd-src/sys/arch/sh3/include/profile.h (revision 5e4c038a45edbc7d63b7c2daa76e29f88b64a4e3)
1 /*	$NetBSD: profile.h,v 1.4 2002/04/28 17:10:36 uch Exp $	*/
2 
3 /*-
4  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #if defined(__ELF__) && defined(__NO_LEADING_UNDERSCORES__)
30 #define	_MCOUNT_DECL static void _mcount
31 #else
32 #define	_MCOUNT_DECL static void mcount
33 #endif
34 
35 #define	MCOUNT __asm ("			\n\
36 	.text				\n\
37 	.align	2			\n\
38 	.globl	__mcount		\n\
39 __mcount:				\n\
40 	mov.l	r0,@-r15		\n\
41 	mov.l	r4,@-r15		\n\
42 	mov.l	r5,@-r15		\n\
43 	mov.l	r6,@-r15		\n\
44 	mov.l	r7,@-r15		\n\
45 	mov.l	r14,@-r15		\n\
46 	sts.l	pr,@-r15		\n\
47 	mov	r15,r14			\n\
48 					\n\
49 	mov.l	1f,r1	! _mcount	\n\
50 	sts	pr,r4	! frompc	\n\
51 	mov	r0,r5	! selfpc	\n\
52 	jsr	@r1			\n\
53 	nop				\n\
54 					\n\
55 	mov	r14,r15			\n\
56 	lds.l	@r15+,pr		\n\
57 	mov.l	@r15+,r14		\n\
58 	mov.l	@r15+,r7		\n\
59 	mov.l	@r15+,r6		\n\
60 	mov.l	@r15+,r5		\n\
61 	mov.l	@r15+,r4		\n\
62 	mov.l	@r15+,r0		\n\
63 					\n\
64 	jmp	@r0	! return	\n\
65 	nop				\n\
66 					\n\
67 	.align	2			\n\
68 1:	.long	_mcount			");
69 
70 #ifdef _KERNEL
71 #define	MCOUNT_ENTER	s = splhigh()
72 #define	MCOUNT_EXIT	splx(s)
73 #endif
74