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