Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.1
      1 /* $NetBSD: asm.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Matt Thomas of 3am Software Foundry.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _AARCH64_ASM_H_
     33 #define _AARCH64_ASM_H_
     34 
     35 #ifdef __aarch64__
     36 
     37 #define	__BIT(n)	(1 << (n))
     38 #define __BITS(hi,lo)	((~((~0)<<((hi)+1)))&((~0)<<(lo)))
     39 
     40 #define _C_LABEL(x)	x
     41 #define	_ASM_LABEL(x)	x
     42 
     43 #define __CONCAT(x,y)	x ## y
     44 #define __STRING(x)	#x
     45 
     46 #ifndef _ALIGN_TEXT
     47 # define _ALIGN_TEXT .align 2
     48 #endif
     49 
     50 #ifndef _TEXT_SECTION
     51 #define _TEXT_SECTION	.text
     52 #endif
     53 #define _ASM_TYPE_FUNCTION	@function
     54 #define _ASM_TYPE_OBJECT	@object
     55 #define _ENTRY(x) \
     56 	_TEXT_SECTION; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
     57 #define	_END(x)		.size x,.-x
     58 
     59 #ifdef GPROF
     60 # define _PROF_PROLOGUE	\
     61 	mov x9, x30; bl __mcount
     62 #else
     63 # define _PROF_PROLOGUE
     64 #endif
     65 
     66 #define	ENTRY(y)		_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
     67 #define	ENTRY_NP(y)		_ENTRY(_C_LABEL(y))
     68 #define	END(y)			_END(_C_LABEL(y))
     69 #define	END(y)			_END(_C_LABEL(y))
     70 #define	ASENTRY(y)		_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
     71 #define	ASENTRY_NP(y)		_ENTRY(_ASM_LABEL(y))
     72 #define	ASEND(y)		_END(_ASM_LABEL(y))
     73 
     74 #define	ASMSTR		.asciz
     75 
     76 #ifdef __PIC__
     77 #define	GOTREF(x)		:got:x
     78 #define GOTLO12(x)		:got_lo12:x
     79 #else
     80 #define GOTREF(x)		x
     81 #define GOTLO12(x)		:lo12:x
     82 #endif
     83 
     84 #define RCSID(x)	.pushsection ".ident"; .asciz x; .popsection
     85 
     86 #define	WEAK_ALIAS(alias,sym)						\
     87 	.weak alias;							\
     88 	alias = sym
     89 
     90 /*
     91  * STRONG_ALIAS: create a strong alias.
     92  */
     93 #define STRONG_ALIAS(alias,sym)						\
     94 	.globl alias;							\
     95 	alias = sym
     96 
     97 #define	WARN_REFERENCES(sym,msg)					\
     98 	.pushsection .gnu.warning. ## sym;				\
     99 	.ascii msg;							\
    100 	.popsection
    101 
    102 #elif defined(__arm__)
    103 
    104 #include <arm/asm.h>
    105 
    106 #endif
    107 
    108 #endif /* !_AARCH64_ASM_H_ */
    109