xref: /openbsd-src/sys/arch/powerpc/include/profile.h (revision 0a2d9455081334e8c49b84ff2c991705f4c147d1)
1*0a2d9455Smpi /*	$OpenBSD: profile.h,v 1.7 2013/08/19 08:39:30 mpi Exp $ */
2ae8d02faSrahnds 
3ae8d02faSrahnds /*
49230ee6aSdrahn  * Copyright (c) 1998 Dale Rahn.
59230ee6aSdrahn  * All rights reserved.
6ae8d02faSrahnds  *
76a1aaa0fSderaadt  *
8ae8d02faSrahnds  * Redistribution and use in source and binary forms, with or without
9ae8d02faSrahnds  * modification, are permitted provided that the following conditions
10ae8d02faSrahnds  * are met:
11ae8d02faSrahnds  * 1. Redistributions of source code must retain the above copyright
12ae8d02faSrahnds  *    notice, this list of conditions and the following disclaimer.
13ae8d02faSrahnds  * 2. Redistributions in binary form must reproduce the above copyright
14ae8d02faSrahnds  *    notice, this list of conditions and the following disclaimer in the
15ae8d02faSrahnds  *    documentation and/or other materials provided with the distribution.
16ae8d02faSrahnds  *
17ae8d02faSrahnds  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18ae8d02faSrahnds  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19ae8d02faSrahnds  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20ae8d02faSrahnds  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21ae8d02faSrahnds  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22ae8d02faSrahnds  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23ae8d02faSrahnds  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24ae8d02faSrahnds  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25ae8d02faSrahnds  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26ae8d02faSrahnds  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27ae8d02faSrahnds  */
28ae8d02faSrahnds #define	MCOUNT \
29ae8d02faSrahnds 	__asm__(" \
30ae8d02faSrahnds 		.section \".text\" \n\
31ae8d02faSrahnds 		.align 2 \n\
32ae8d02faSrahnds 		.globl _mcount \n\
33ae8d02faSrahnds 		.type	_mcount,@function \n\
34ae8d02faSrahnds 	_mcount: \n\
35ae8d02faSrahnds 		lwz	11, 4(1) \n\
36ae8d02faSrahnds 		mflr	0 \n\
37ae8d02faSrahnds 		stw	0, 4(1) \n\
38ae8d02faSrahnds 		stwu	1, -48(1) \n\
39ae8d02faSrahnds 		stw	3, 8(1) \n\
40ae8d02faSrahnds 		stw	4, 12(1) \n\
41ae8d02faSrahnds 		stw	5, 16(1) \n\
42ae8d02faSrahnds 		stw	6, 20(1) \n\
43ae8d02faSrahnds 		stw	7, 24(1) \n\
44ae8d02faSrahnds 		stw	8, 28(1) \n\
45ae8d02faSrahnds 		stw	9, 32(1) \n\
46ae8d02faSrahnds 		stw	10,36(1) \n\
47ae8d02faSrahnds 		stw	11,40(1) \n\
48ae8d02faSrahnds 		mr	4, 0 \n\
49ae8d02faSrahnds 		mr 	3, 11 \n\
50ae8d02faSrahnds 		bl __mcount \n\
51ae8d02faSrahnds 		lwz	3, 8(1) \n\
52ae8d02faSrahnds 		lwz	4, 12(1) \n\
53ae8d02faSrahnds 		lwz	5, 16(1) \n\
54ae8d02faSrahnds 		lwz	6, 20(1) \n\
55ae8d02faSrahnds 		lwz	7, 24(1) \n\
56ae8d02faSrahnds 		lwz	8, 28(1) \n\
57ae8d02faSrahnds 		lwz	9, 32(1) \n\
58ae8d02faSrahnds 		lwz	10,36(1) \n\
59ae8d02faSrahnds 		lwz	11,40(1) \n\
60ae8d02faSrahnds 		addi	1, 1, 48 \n\
61ae8d02faSrahnds 		lwz	0, 4(1) \n\
62ae8d02faSrahnds 		mtlr	11 \n\
63ae8d02faSrahnds 		stw	11, 4(1) \n\
64ae8d02faSrahnds 		mtctr	0 \n\
65ae8d02faSrahnds 		bctr \n\
66ae8d02faSrahnds 	.Lfe2: \n\
67ae8d02faSrahnds 		.size _mcount, .Lfe2-_mcount \n\
68ae8d02faSrahnds 	");
699b473eecSdrahn #define _MCOUNT_DECL static void __mcount
709b473eecSdrahn #ifdef _KERNEL
719b473eecSdrahn #define MCOUNT_ENTER						\
729b473eecSdrahn 	__asm volatile("mfmsr %0" : "=r"(s));			\
739b473eecSdrahn 	s &= ~PSL_POW;						\
749b473eecSdrahn 	__asm volatile("mtmsr %0" :: "r"(s & ~PSL_EE))
759b473eecSdrahn 
769b473eecSdrahn #define	MCOUNT_EXIT						\
779b473eecSdrahn 	__asm volatile("mtmsr %0" :: "r"(s))
789b473eecSdrahn #endif /* _KERNEL */
79