Home | History | Annotate | Line # | Download | only in include
profile.h revision 1.6
      1  1.6   briggs /*	$NetBSD: profile.h,v 1.6 2002/02/07 05:13:35 briggs Exp $	*/
      2  1.5   tsubai 
      3  1.5   tsubai /*-
      4  1.5   tsubai  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
      5  1.5   tsubai  *
      6  1.5   tsubai  * Redistribution and use in source and binary forms, with or without
      7  1.5   tsubai  * modification, are permitted provided that the following conditions
      8  1.5   tsubai  * are met:
      9  1.5   tsubai  * 1. Redistributions of source code must retain the above copyright
     10  1.5   tsubai  *    notice, this list of conditions and the following disclaimer.
     11  1.5   tsubai  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.5   tsubai  *    notice, this list of conditions and the following disclaimer in the
     13  1.5   tsubai  *    documentation and/or other materials provided with the distribution.
     14  1.5   tsubai  * 3. The name of the author may not be used to endorse or promote products
     15  1.5   tsubai  *    derived from this software without specific prior written permission.
     16  1.5   tsubai  *
     17  1.5   tsubai  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  1.5   tsubai  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  1.5   tsubai  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.5   tsubai  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21  1.5   tsubai  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22  1.5   tsubai  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23  1.5   tsubai  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24  1.5   tsubai  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25  1.5   tsubai  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26  1.5   tsubai  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27  1.5   tsubai  */
     28  1.2  thorpej 
     29  1.6   briggs #define	_MCOUNT_DECL	void __mcount
     30  1.2  thorpej 
     31  1.4   tsubai #ifdef PIC
     32  1.4   tsubai #define _PLT "@plt"
     33  1.4   tsubai #else
     34  1.4   tsubai #define _PLT
     35  1.4   tsubai #endif
     36  1.2  thorpej 
     37  1.6   briggs #define MCOUNT				\
     38  1.6   briggs __asm("	.globl	_mcount			\n" \
     39  1.6   briggs "	.type	_mcount,@function	\n" \
     40  1.6   briggs "_mcount:				\n" \
     41  1.6   briggs "	stwu	1,-64(1)		\n" \
     42  1.6   briggs "	stw	3,16(1)			\n" \
     43  1.6   briggs "	stw	4,20(1)			\n" \
     44  1.6   briggs "	stw	5,24(1)			\n" \
     45  1.6   briggs "	stw	6,28(1)			\n" \
     46  1.6   briggs "	stw	7,32(1)			\n" \
     47  1.6   briggs "	stw	8,36(1)			\n" \
     48  1.6   briggs "	stw	9,40(1)			\n" \
     49  1.6   briggs "	stw	10,44(1)		\n" \
     50  1.6   briggs "					\n" \
     51  1.6   briggs "	mflr	4			\n" \
     52  1.6   briggs "	stw	4,48(1)			\n" \
     53  1.6   briggs "	lwz	3,68(1)			\n" \
     54  1.6   briggs "	bl	__mcount" _PLT "	\n" \
     55  1.6   briggs "	lwz	3,68(1)			\n" \
     56  1.6   briggs "	mtlr	3			\n" \
     57  1.6   briggs "	lwz	4,48(1)			\n" \
     58  1.6   briggs "	mtctr	4			\n" \
     59  1.6   briggs "					\n" \
     60  1.6   briggs "	lwz	3,16(1)			\n" \
     61  1.6   briggs "	lwz	4,20(1)			\n" \
     62  1.6   briggs "	lwz	5,24(1)			\n" \
     63  1.6   briggs "	lwz	6,28(1)			\n" \
     64  1.6   briggs "	lwz	7,32(1)			\n" \
     65  1.6   briggs "	lwz	8,36(1)			\n" \
     66  1.6   briggs "	lwz	9,40(1)			\n" \
     67  1.6   briggs "	lwz	10,44(1)		\n" \
     68  1.6   briggs "	addi	1,1,64			\n" \
     69  1.6   briggs "	bctr				\n" \
     70  1.6   briggs "_mcount_end:				\n" \
     71  1.6   briggs "	.size	_mcount,_mcount_end-_mcount");
     72  1.3  thorpej 
     73  1.3  thorpej #ifdef _KERNEL
     74  1.5   tsubai #define MCOUNT_ENTER						\
     75  1.5   tsubai 	__asm volatile("mfmsr %0" : "=r"(s));			\
     76  1.5   tsubai 	if ((s & (PSL_IR | PSL_DR)) != (PSL_IR | PSL_DR))	\
     77  1.5   tsubai 		return;		/* XXX */			\
     78  1.5   tsubai 	s &= ~PSL_POW;						\
     79  1.5   tsubai 	__asm volatile("mtmsr %0" :: "r"(s & ~PSL_EE))
     80  1.5   tsubai 
     81  1.5   tsubai #define MCOUNT_EXIT						\
     82  1.5   tsubai 	__asm volatile("mtmsr %0" :: "r"(s))
     83  1.3  thorpej #endif
     84