profile.h revision 1.14 1 /* $NetBSD: profile.h,v 1.14 2000/05/25 03:07:10 simonb Exp $ */
2
3 /*
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)profile.h 8.1 (Berkeley) 6/10/93
39 */
40
41 #ifndef _MIPS_PROFILE_H_
42 #define _MIPS_PROFILE_H_
43
44 #ifdef _KERNEL
45 # define _PROF_CPLOAD ""
46 #else
47 # define _PROF_CPLOAD ".cpload $25;"
48 #endif
49
50 #define _MCOUNT_DECL \
51 static void __attribute__((unused)) __mcount
52
53 #define MCOUNT \
54 __asm__(".globl _mcount;" \
55 ".type _mcount,@function;" \
56 "_mcount:;" \
57 ".set noreorder;" \
58 ".set noat;" \
59 _PROF_CPLOAD \
60 "subu $29,$29,16;" \
61 "sw $4,8($29);" \
62 "sw $5,12($29);" \
63 "sw $6,16($29);" \
64 "sw $7,20($29);" \
65 "sw $1,0($29);" \
66 "sw $31,4($29);" \
67 "move $5,$31;" \
68 "jal __mcount;" \
69 "move $4,$1;" \
70 "lw $4,8($29);" \
71 "lw $5,12($29);" \
72 "lw $6,16($29);" \
73 "lw $7,20($29);" \
74 "lw $31,4($29);" \
75 "lw $1,0($29);" \
76 "addu $29,$29,24;" \
77 "j $31;" \
78 "move $31,$1;" \
79 ".set reorder;" \
80 ".set at");
81
82 #ifdef _KERNEL
83 /*
84 * Block interrupts during mcount so that those interrupts can also be
85 * counted (as soon as we get done with the current counting).
86 */
87
88 /* $1 is at, $8 is t0, $12 is MIPS_COP_0_STATUS */
89 #define MCOUNT_ENTER __asm__( \
90 ".set noat;" \
91 ".set noreorder;" \
92 "mfc0 $1,$12;" \
93 "nop;" \
94 "andi %0,$1,1;" \
95 "beq $1,$0,1f;" \
96 "li $8,-2;" \
97 "and $1,$1,$8;" \
98 "mtc0 $1,$12;" \
99 "nop;" \
100 "1:;" \
101 ".set at;" \
102 ".set reorder" : "=g" (s) :: "t0", "at");
103
104 #define MCOUNT_EXIT __asm__( \
105 ".set noat;" \
106 ".set noreorder;" \
107 "beq %0,$0,1f;" \
108 "mfc0 $1,$12;" \
109 "nop;" \
110 "ori $1,$1,1;" \
111 "mtc0 $1,$12;" \
112 "nop;" \
113 "1:;" \
114 ".set at;" \
115 ".set reorder" :: "g" (s) : "at");
116
117 #endif /* _KERNEL */
118 #endif /* _MIPS_PROFILE_H_ */
119