1139825Simp/*- 270740Sbenno * Copyright (C) 1995, 1996 Wolfgang Solfrank. 370740Sbenno * Copyright (C) 1995, 1996 TooLs GmbH. 470740Sbenno * All rights reserved. 570740Sbenno * 670740Sbenno * Redistribution and use in source and binary forms, with or without 770740Sbenno * modification, are permitted provided that the following conditions 870740Sbenno * are met: 970740Sbenno * 1. Redistributions of source code must retain the above copyright 1070740Sbenno * notice, this list of conditions and the following disclaimer. 1170740Sbenno * 2. Redistributions in binary form must reproduce the above copyright 1270740Sbenno * notice, this list of conditions and the following disclaimer in the 1370740Sbenno * documentation and/or other materials provided with the distribution. 1470740Sbenno * 3. All advertising materials mentioning features or use of this software 1570740Sbenno * must display the following acknowledgement: 1670740Sbenno * This product includes software developed by TooLs GmbH. 1770740Sbenno * 4. The name of TooLs GmbH may not be used to endorse or promote products 1870740Sbenno * derived from this software without specific prior written permission. 1970740Sbenno * 2070740Sbenno * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 2170740Sbenno * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2270740Sbenno * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2370740Sbenno * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2470740Sbenno * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2570740Sbenno * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2670740Sbenno * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2770740Sbenno * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2870740Sbenno * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2970740Sbenno * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3070740Sbenno * 3170740Sbenno * $NetBSD: asm.h,v 1.6.18.1 2000/07/25 08:37:14 kleink Exp $ 3277930Sobrien * $FreeBSD: releng/10.2/sys/powerpc/include/asm.h 232488 2012-03-04 11:55:28Z andreast $ 3370740Sbenno */ 3470740Sbenno 3570740Sbenno#ifndef _MACHINE_ASM_H_ 3670740Sbenno#define _MACHINE_ASM_H_ 3770740Sbenno 38109602Sgallatin#include <sys/cdefs.h> 39109602Sgallatin 40218824Snwhitehorn#if defined(PIC) && !defined(__powerpc64__) 4170740Sbenno#define PIC_PROLOGUE XXX 4270740Sbenno#define PIC_EPILOGUE XXX 4370740Sbenno#define PIC_PLT(x) x@plt 4470740Sbenno#ifdef __STDC__ 4570740Sbenno#define PIC_GOT(x) XXX 4670740Sbenno#else /* not __STDC__ */ 4770740Sbenno#define PIC_GOT(x) XXX 4870740Sbenno#endif /* __STDC__ */ 4970740Sbenno#else 5070740Sbenno#define PIC_PROLOGUE 5170740Sbenno#define PIC_EPILOGUE 5270740Sbenno#define PIC_PLT(x) x 5370740Sbenno#define PIC_GOT(x) x 5470740Sbenno#endif 5570740Sbenno 5696773Sbenno#define CNAME(csym) csym 5796773Sbenno#define ASMNAME(asmsym) asmsym 58209975Snwhitehorn#ifdef __powerpc64__ 59209975Snwhitehorn#define HIDENAME(asmsym) __CONCAT(_,asmsym) 60209975Snwhitehorn#else 6196773Sbenno#define HIDENAME(asmsym) __CONCAT(.,asmsym) 62209975Snwhitehorn#endif 6370740Sbenno 64232488Sandreast#ifdef _KERNEL 65232488Sandreast#define DOT_LABEL(name) __CONCAT(.,name) 66232488Sandreast#define TYPE_ENTRY(name) .size name,24; \ 67232488Sandreast .type DOT_LABEL(name),@function; \ 68232488Sandreast .globl DOT_LABEL(name); 69232488Sandreast#define END_SIZE(name) .size DOT_LABEL(name),.-DOT_LABEL(name); 70232488Sandreast#else /* !_KERNEL */ 71232488Sandreast#define DOT_LABEL(name) __CONCAT(.L.,name) 72232488Sandreast#define TYPE_ENTRY(name) .type name,@function; 73232488Sandreast#define END_SIZE(name) .size name,.-DOT_LABEL(name); 74232488Sandreast#endif /* _KERNEL */ 7570740Sbenno 76232488Sandreast#define _GLOBAL(name) \ 77232488Sandreast .data; \ 78232488Sandreast .p2align 2; \ 79232488Sandreast .globl name; \ 80232488Sandreast name: 8170740Sbenno 82232488Sandreast#ifdef __powerpc64__ 83232488Sandreast#define _ENTRY(name) \ 84232488Sandreast .section ".text"; \ 85232488Sandreast .p2align 2; \ 86232488Sandreast .globl name; \ 87232488Sandreast .section ".opd","aw"; \ 88232488Sandreast .p2align 3; \ 89232488Sandreast name: \ 90232488Sandreast .quad DOT_LABEL(name),.TOC.@tocbase,0; \ 91232488Sandreast .previous; \ 92232488Sandreast .p2align 4; \ 93232488Sandreast TYPE_ENTRY(name) \ 94232488SandreastDOT_LABEL(name): 95232488Sandreast 96232488Sandreast#define _END(name) \ 97232488Sandreast .long 0; \ 98232488Sandreast .byte 0,0,0,0,0,0,0,0; \ 99232488Sandreast END_SIZE(name) 100232488Sandreast#else /* !__powerpc64__ */ 101232488Sandreast#define _ENTRY(name) \ 102232488Sandreast .text; \ 103232488Sandreast .p2align 4; \ 104232488Sandreast .globl name; \ 105232488Sandreast .type name,@function; \ 106232488Sandreast name: 107232488Sandreast#define _END(name) 108232488Sandreast#endif /* __powerpc64__ */ 109232488Sandreast 110209621Smarcel#if defined(PROF) || (defined(_KERNEL) && defined(GPROF)) 111230400Sandreast# ifdef __powerpc64__ 112230400Sandreast# define _PROF_PROLOGUE mflr 0; \ 113230400Sandreast std 3,48(1); \ 114230400Sandreast std 4,56(1); \ 115230400Sandreast std 5,64(1); \ 116230400Sandreast std 0,16(1); \ 117230400Sandreast stdu 1,-112(1); \ 118230400Sandreast bl _mcount; \ 119230400Sandreast nop; \ 120230400Sandreast ld 0,112+16(1); \ 121230400Sandreast ld 3,112+48(1); \ 122230400Sandreast ld 4,112+56(1); \ 123230400Sandreast ld 5,112+64(1); \ 124230400Sandreast mtlr 0; \ 125230400Sandreast addi 1,1,112 126230400Sandreast# else 127230400Sandreast# define _PROF_PROLOGUE mflr 0; stw 0,4(1); bl _mcount 128230400Sandreast# endif 12970740Sbenno#else 13070740Sbenno# define _PROF_PROLOGUE 13170740Sbenno#endif 13270740Sbenno 133230400Sandreast#define ASENTRY(y) _ENTRY(ASMNAME(y)); _PROF_PROLOGUE 134232488Sandreast#define END(y) _END(CNAME(y)) 13596773Sbenno#define ENTRY(y) _ENTRY(CNAME(y)); _PROF_PROLOGUE 13696773Sbenno#define GLOBAL(y) _GLOBAL(CNAME(y)) 13770740Sbenno 138230400Sandreast#define ASENTRY_NOPROF(y) _ENTRY(ASMNAME(y)) 139230400Sandreast#define ENTRY_NOPROF(y) _ENTRY(CNAME(y)) 140230400Sandreast 14170740Sbenno#define ASMSTR .asciz 14270740Sbenno 14370740Sbenno#define RCSID(x) .text; .asciz x 14470740Sbenno 145109975Sbenno#undef __FBSDID 146109975Sbenno#if !defined(lint) && !defined(STRIP_FBSDID) 147109975Sbenno#define __FBSDID(s) .ident s 148109975Sbenno#else 149109975Sbenno#define __FBSDID(s) /* nothing */ 150109975Sbenno#endif /* not lint and not STRIP_FBSDID */ 151109975Sbenno 152231044Sandreast#define WEAK_REFERENCE(sym, alias) \ 15377930Sobrien .weak alias; \ 154231044Sandreast .equ alias,sym 15570740Sbenno 15670740Sbenno#ifdef __STDC__ 15770740Sbenno#define WARN_REFERENCES(_sym,_msg) \ 15870740Sbenno .section .gnu.warning. ## _sym ; .ascii _msg ; .text 15970740Sbenno#else 16070740Sbenno#define WARN_REFERENCES(_sym,_msg) \ 16170740Sbenno .section .gnu.warning./**/_sym ; .ascii _msg ; .text 16270740Sbenno#endif /* __STDC__ */ 16370740Sbenno 16470740Sbenno#endif /* !_MACHINE_ASM_H_ */ 165