profile.h revision 1.2
11.2Stsubai/*	$NetBSD: profile.h,v 1.2 2000/08/22 11:25:49 tsubai Exp $	*/
21.1Sitojun
31.2Stsubai/*-
41.2Stsubai * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
51.1Sitojun *
61.1Sitojun * Redistribution and use in source and binary forms, with or without
71.1Sitojun * modification, are permitted provided that the following conditions
81.1Sitojun * are met:
91.1Sitojun * 1. Redistributions of source code must retain the above copyright
101.1Sitojun *    notice, this list of conditions and the following disclaimer.
111.1Sitojun * 2. Redistributions in binary form must reproduce the above copyright
121.1Sitojun *    notice, this list of conditions and the following disclaimer in the
131.1Sitojun *    documentation and/or other materials provided with the distribution.
141.2Stsubai * 3. The name of the author may not be used to endorse or promote products
151.2Stsubai *    derived from this software without specific prior written permission.
161.1Sitojun *
171.2Stsubai * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181.2Stsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191.2Stsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201.2Stsubai * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211.2Stsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221.2Stsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231.2Stsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241.2Stsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251.2Stsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261.2Stsubai * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271.1Sitojun */
281.1Sitojun
291.2Stsubai#define _MCOUNT_DECL static void mcount
301.1Sitojun
311.2Stsubai#define MCOUNT __asm ("			\n\
321.2Stsubai	.text				\n\
331.2Stsubai	.align	2			\n\
341.2Stsubai	.globl	__mcount		\n\
351.2Stsubai__mcount:				\n\
361.2Stsubai	mov.l	r0,@-r15		\n\
371.2Stsubai	mov.l	r4,@-r15		\n\
381.2Stsubai	mov.l	r5,@-r15		\n\
391.2Stsubai	mov.l	r6,@-r15		\n\
401.2Stsubai	mov.l	r7,@-r15		\n\
411.2Stsubai	mov.l	r14,@-r15		\n\
421.2Stsubai	sts.l	pr,@-r15		\n\
431.2Stsubai	mov	r15,r14			\n\
441.2Stsubai					\n\
451.2Stsubai	mov.l	1f,r1	! _mcount	\n\
461.2Stsubai	sts	pr,r4	! frompc	\n\
471.2Stsubai	mov	r0,r5	! selfpc	\n\
481.2Stsubai	jsr	@r1			\n\
491.2Stsubai	nop				\n\
501.2Stsubai					\n\
511.2Stsubai	mov	r14,r15			\n\
521.2Stsubai	lds.l	@r15+,pr		\n\
531.2Stsubai	mov.l	@r15+,r14		\n\
541.2Stsubai	mov.l	@r15+,r7		\n\
551.2Stsubai	mov.l	@r15+,r6		\n\
561.2Stsubai	mov.l	@r15+,r5		\n\
571.2Stsubai	mov.l	@r15+,r4		\n\
581.2Stsubai	mov.l	@r15+,r0		\n\
591.2Stsubai					\n\
601.2Stsubai	jmp	@r0	! return	\n\
611.2Stsubai	nop				\n\
621.2Stsubai					\n\
631.2Stsubai	.align	2			\n\
641.2Stsubai1:	.long	_mcount			");
651.1Sitojun
661.1Sitojun#ifdef _KERNEL
671.1Sitojun#define MCOUNT_ENTER	s = splhigh()
681.1Sitojun#define MCOUNT_EXIT	splx(s)
691.2Stsubai#endif
70