1/* $OpenBSD: profile.h,v 1.5 2019/04/19 09:19:22 visa 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. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)profile.h 8.1 (Berkeley) 6/10/93
35 */
36#ifndef _MIPS64_PROFILE_H_
37#define _MIPS64_PROFILE_H_
38
39#define _MCOUNT_DECL static void ___mcount
40
41/*XXX The cprestore instruction is a "dummy" to shut up as(1). */
42
43#define MCOUNT \
44 __asm(".globl _mcount;" \
45 ".type _mcount,@function;" \
46 "_mcount:;" \
47 ".set noreorder;" \
48 ".set noat;" \
49 ".cpload $25;" \
50 ".cprestore 4;" \
51 "sd $4,16($29);" \
52 "sd $5,24($29);" \
53 "sd $6,32($29);" \
54 "sd $7,40($29);" \
55 "sd $1,0($29);" \
56 "sd $31,8($29);" \
57 "move $5,$31;" \
58 ".local ___mcount;" \
59 "jal ___mcount;" \
60 "move $4,$1;" \
61 "ld $4,16($29);" \
62 "ld $5,24($29);" \
63 "ld $6,32($29);" \
64 "ld $7,40($29);" \
65 "ld $31,8($29);" \
66 "ld $1,0($29);" \
67 "daddu $29,$29,16;" \
68 "j $31;" \
69 "move $31,$1;" \
70 ".set reorder;" \
71 ".set at");
72
73#ifdef _KERNEL
74/*
75 * The following two macros do splhigh and splx respectively.
76 * They have to be defined this way because these are real
77 * functions on the MIPS, and we do not want to invoke mcount
78 * recursively.
79 */
80#define MCOUNT_ENTER s = _splhigh()
81
82#define MCOUNT_EXIT _splx(s)
83#endif /* _KERNEL */
84
85#endif /* !_MIPS64_PROFILE_H_ */