1*ba36fba2Svisa /* $OpenBSD: profile.h,v 1.5 2019/04/19 09:19:22 visa Exp $ */ 2f58c7388Spefo 3f58c7388Spefo /* 4f58c7388Spefo * Copyright (c) 1992, 1993 5f58c7388Spefo * The Regents of the University of California. All rights reserved. 6f58c7388Spefo * 7f58c7388Spefo * This code is derived from software contributed to Berkeley by 8f58c7388Spefo * Ralph Campbell. 9f58c7388Spefo * 10f58c7388Spefo * Redistribution and use in source and binary forms, with or without 11f58c7388Spefo * modification, are permitted provided that the following conditions 12f58c7388Spefo * are met: 13f58c7388Spefo * 1. Redistributions of source code must retain the above copyright 14f58c7388Spefo * notice, this list of conditions and the following disclaimer. 15f58c7388Spefo * 2. Redistributions in binary form must reproduce the above copyright 16f58c7388Spefo * notice, this list of conditions and the following disclaimer in the 17f58c7388Spefo * documentation and/or other materials provided with the distribution. 1853aa784aSmiod * 3. Neither the name of the University nor the names of its contributors 19f58c7388Spefo * may be used to endorse or promote products derived from this software 20f58c7388Spefo * without specific prior written permission. 21f58c7388Spefo * 22f58c7388Spefo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23f58c7388Spefo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24f58c7388Spefo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25f58c7388Spefo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26f58c7388Spefo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27f58c7388Spefo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28f58c7388Spefo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29f58c7388Spefo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30f58c7388Spefo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31f58c7388Spefo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32f58c7388Spefo * SUCH DAMAGE. 33f58c7388Spefo * 34f58c7388Spefo * from: @(#)profile.h 8.1 (Berkeley) 6/10/93 35f58c7388Spefo */ 362fa72412Spirofti #ifndef _MIPS64_PROFILE_H_ 372fa72412Spirofti #define _MIPS64_PROFILE_H_ 38f58c7388Spefo 39f58c7388Spefo #define _MCOUNT_DECL static void ___mcount 40f58c7388Spefo 41f58c7388Spefo /*XXX The cprestore instruction is a "dummy" to shut up as(1). */ 42f58c7388Spefo 43f58c7388Spefo #define MCOUNT \ 44f58c7388Spefo __asm(".globl _mcount;" \ 45f58c7388Spefo ".type _mcount,@function;" \ 46f58c7388Spefo "_mcount:;" \ 47f58c7388Spefo ".set noreorder;" \ 48f58c7388Spefo ".set noat;" \ 49f58c7388Spefo ".cpload $25;" \ 50f58c7388Spefo ".cprestore 4;" \ 5150027fe1Smiod "sd $4,16($29);" \ 5250027fe1Smiod "sd $5,24($29);" \ 5350027fe1Smiod "sd $6,32($29);" \ 5450027fe1Smiod "sd $7,40($29);" \ 5550027fe1Smiod "sd $1,0($29);" \ 5650027fe1Smiod "sd $31,8($29);" \ 57f58c7388Spefo "move $5,$31;" \ 58*ba36fba2Svisa ".local ___mcount;" \ 59f58c7388Spefo "jal ___mcount;" \ 60f58c7388Spefo "move $4,$1;" \ 6150027fe1Smiod "ld $4,16($29);" \ 6250027fe1Smiod "ld $5,24($29);" \ 6350027fe1Smiod "ld $6,32($29);" \ 6450027fe1Smiod "ld $7,40($29);" \ 6550027fe1Smiod "ld $31,8($29);" \ 6650027fe1Smiod "ld $1,0($29);" \ 6750027fe1Smiod "daddu $29,$29,16;" \ 68f58c7388Spefo "j $31;" \ 69f58c7388Spefo "move $31,$1;" \ 70f58c7388Spefo ".set reorder;" \ 71f58c7388Spefo ".set at"); 72f58c7388Spefo 73f58c7388Spefo #ifdef _KERNEL 74f58c7388Spefo /* 75f58c7388Spefo * The following two macros do splhigh and splx respectively. 76f58c7388Spefo * They have to be defined this way because these are real 77f58c7388Spefo * functions on the MIPS, and we do not want to invoke mcount 78f58c7388Spefo * recursively. 79f58c7388Spefo */ 80f58c7388Spefo #define MCOUNT_ENTER s = _splhigh() 81f58c7388Spefo 82f58c7388Spefo #define MCOUNT_EXIT _splx(s) 83f58c7388Spefo #endif /* _KERNEL */ 84f58c7388Spefo 852fa72412Spirofti #endif /* !_MIPS64_PROFILE_H_ */ 86