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