xref: /freebsd/sys/riscv/include/profile.h (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1 /*-
2  * SPDX-License-Identifier: MIT-CMU
3  *
4  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  *
29  *	from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp
30  *	from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29
31  */
32 
33 #ifndef _MACHINE_PROFILE_H_
34 #define	_MACHINE_PROFILE_H_
35 
36 #define	FUNCTION_ALIGNMENT	32
37 
38 typedef u_long	fptrdiff_t;
39 
40 #ifdef _KERNEL
41 
42 #include <machine/cpufunc.h>
43 
44 #define	_MCOUNT_DECL	void mcount
45 #define	MCOUNT
46 
47 #define	MCOUNT_DECL(s)	register_t s;
48 #define	MCOUNT_ENTER(s)	{s = intr_disable(); }
49 #define	MCOUNT_EXIT(s)	{intr_restore(s); }
50 
51 void bintr(void);
52 void btrap(void);
53 void eintr(void);
54 void user(void);
55 
56 #define	MCOUNT_FROMPC_USER(pc)					\
57 	((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc)
58 
59 #define	MCOUNT_FROMPC_INTR(pc)					\
60 	((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ?	\
61 	    ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr :	\
62 		(uintfptr_t)btrap) : ~0UL)
63 
64 void	mcount(uintfptr_t frompc, uintfptr_t selfpc);
65 
66 #else /* !_KERNEL */
67 
68 typedef	__uintfptr_t	uintfptr_t;
69 
70 #define	_MCOUNT_DECL	void mcount
71 #define	MCOUNT
72 
73 #endif /* _KERNEL */
74 
75 #endif /* !_MACHINE_PROFILE_H_ */
76