xref: /openbsd/sys/arch/sparc64/include/profile.h (revision 32b97ded)
1*32b97dedSpascal /*	$OpenBSD: profile.h,v 1.4 2012/08/22 17:19:35 pascal Exp $	*/
28a753c22Sart 
38a753c22Sart /*
48a753c22Sart  * Copyright (c) 1992, 1993
58a753c22Sart  *	The Regents of the University of California.  All rights reserved.
68a753c22Sart  *
78a753c22Sart  * This software was developed by the Computer Systems Engineering group
88a753c22Sart  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
98a753c22Sart  * contributed to Berkeley.
108a753c22Sart  *
118a753c22Sart  * All advertising materials mentioning features or use of this software
128a753c22Sart  * must display the following acknowledgement:
138a753c22Sart  *	This product includes software developed by the University of
148a753c22Sart  *	California, Lawrence Berkeley Laboratory.
158a753c22Sart  *
168a753c22Sart  * Redistribution and use in source and binary forms, with or without
178a753c22Sart  * modification, are permitted provided that the following conditions
188a753c22Sart  * are met:
198a753c22Sart  * 1. Redistributions of source code must retain the above copyright
208a753c22Sart  *    notice, this list of conditions and the following disclaimer.
218a753c22Sart  * 2. Redistributions in binary form must reproduce the above copyright
228a753c22Sart  *    notice, this list of conditions and the following disclaimer in the
238a753c22Sart  *    documentation and/or other materials provided with the distribution.
2429295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
258a753c22Sart  *    may be used to endorse or promote products derived from this software
268a753c22Sart  *    without specific prior written permission.
278a753c22Sart  *
288a753c22Sart  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
298a753c22Sart  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
308a753c22Sart  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
318a753c22Sart  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
328a753c22Sart  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
338a753c22Sart  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
348a753c22Sart  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
358a753c22Sart  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
368a753c22Sart  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
378a753c22Sart  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
388a753c22Sart  * SUCH DAMAGE.
398a753c22Sart  *
408a753c22Sart  *	@(#)profile.h	8.1 (Berkeley) 6/11/93
418a753c22Sart  */
428a753c22Sart 
43*32b97dedSpascal #ifdef __PIC__
448a753c22Sart /* Inline expansion of PICCY_SET() (see <machine/asm.h>). */
458a753c22Sart #define MCOUNT \
468a753c22Sart 	__asm__(".global _mcount");\
478a753c22Sart 	__asm__("_mcount:");\
488a753c22Sart 	__asm__("add %o7, 8, %o1");\
498a753c22Sart 	__asm__("1: rd %pc, %o2");\
50ac28fa59Sart 	__asm__("add %o2, __mcount-1b, %o2");\
518a753c22Sart 	__asm__("ld [%o2], %o2");\
528a753c22Sart 	__asm__("jmpl %o2, %g0");\
538a753c22Sart 	__asm__("add %i7, 8, %o0");
548a753c22Sart #else
558a753c22Sart #define MCOUNT \
568a753c22Sart 	__asm__(".global _mcount");\
578a753c22Sart 	__asm__("_mcount:");\
588a753c22Sart 	__asm__("add %i7, 8, %o0");\
598a753c22Sart 	__asm__("sethi %hi(__mcount), %o2");\
608a753c22Sart 	__asm__("jmpl %o2 + %lo(__mcount), %g0");\
618a753c22Sart 	__asm__("add %o7, 8, %o1");
628a753c22Sart #endif
638a753c22Sart 
648a753c22Sart #define	_MCOUNT_DECL	static void __mcount
658a753c22Sart 
668a753c22Sart #ifdef _KERNEL
678a753c22Sart /*
688a753c22Sart  * Block interrupts during mcount so that those interrupts can also be
698a753c22Sart  * counted (as soon as we get done with the current counting).  On the
708a753c22Sart  * SPARC, we just splhigh/splx as those do not recursively invoke mcount.
718a753c22Sart  */
728a753c22Sart #define	MCOUNT_ENTER	s = splhigh()
738a753c22Sart #define	MCOUNT_EXIT	splx(s)
748a753c22Sart #endif /* _KERNEL */
75