Home | History | Annotate | Line # | Download | only in include
profile.h revision 1.5
      1  1.5   tsubai /*	$NetBSD: profile.h,v 1.5 2000/04/18 17:06:01 tsubai 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.2  thorpej #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.4   tsubai #define MCOUNT __asm("		\
     38  1.4   tsubai 	.globl _mcount;		\
     39  1.4   tsubai _mcount:			\
     40  1.4   tsubai 	stwu	1,-64(1);	\
     41  1.4   tsubai 	stw	3,16(1);	\
     42  1.4   tsubai 	stw	4,20(1);	\
     43  1.4   tsubai 	stw	5,24(1);	\
     44  1.4   tsubai 	stw	6,28(1);	\
     45  1.4   tsubai 	stw	7,32(1);	\
     46  1.4   tsubai 	stw	8,36(1);	\
     47  1.4   tsubai 	stw	9,40(1);	\
     48  1.4   tsubai 	stw	10,44(1);	\
     49  1.4   tsubai 				\
     50  1.4   tsubai 	mflr	4;		\
     51  1.4   tsubai 	stw	4,48(1);	\
     52  1.4   tsubai 	lwz	3,68(1);	\
     53  1.4   tsubai 	bl	mcount" _PLT ";	\
     54  1.4   tsubai 	lwz	3,68(1);	\
     55  1.4   tsubai 	mtlr	3;		\
     56  1.4   tsubai 	lwz	4,48(1);	\
     57  1.4   tsubai 	mtctr	4;		\
     58  1.4   tsubai 				\
     59  1.4   tsubai 	lwz	3,16(1);	\
     60  1.4   tsubai 	lwz	4,20(1);	\
     61  1.4   tsubai 	lwz	5,24(1);	\
     62  1.4   tsubai 	lwz	6,28(1);	\
     63  1.4   tsubai 	lwz	7,32(1);	\
     64  1.4   tsubai 	lwz	8,36(1);	\
     65  1.4   tsubai 	lwz	9,40(1);	\
     66  1.4   tsubai 	lwz	10,44(1);	\
     67  1.4   tsubai 	addi	1,1,64;		\
     68  1.4   tsubai 	bctr;			");
     69  1.3  thorpej 
     70  1.3  thorpej #ifdef _KERNEL
     71  1.5   tsubai #define MCOUNT_ENTER						\
     72  1.5   tsubai 	__asm volatile("mfmsr %0" : "=r"(s));			\
     73  1.5   tsubai 	if ((s & (PSL_IR | PSL_DR)) != (PSL_IR | PSL_DR))	\
     74  1.5   tsubai 		return;		/* XXX */			\
     75  1.5   tsubai 	s &= ~PSL_POW;						\
     76  1.5   tsubai 	__asm volatile("mtmsr %0" :: "r"(s & ~PSL_EE))
     77  1.5   tsubai 
     78  1.5   tsubai #define MCOUNT_EXIT						\
     79  1.5   tsubai 	__asm volatile("mtmsr %0" :: "r"(s))
     80  1.3  thorpej #endif
     81