Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:24

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief MicroBlaze assembler support
0007  *
0008  * This include file attempts to address the problems
0009  * caused by incompatible flavors of assemblers and
0010  * toolsets.  It primarily addresses variations in the
0011  * use of leading underscores on symbols and the requirement
0012  * that register names be preceded by a %.
0013  */
0014 
0015 /*
0016  * Copyright (c) 2015, Hesham Almatary
0017  * Copyright (C) 2021 On-Line Applications Research Corporation (OAR)
0018  *
0019  * Redistribution and use in source and binary forms, with or without
0020  * modification, are permitted provided that the following conditions
0021  * are met:
0022  * 1. Redistributions of source code must retain the above copyright
0023  *    notice, this list of conditions and the following disclaimer.
0024  * 2. Redistributions in binary form must reproduce the above copyright
0025  *    notice, this list of conditions and the following disclaimer in the
0026  *    documentation and/or other materials provided with the distribution.
0027  *
0028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0029  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0030  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0031  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0032  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0033  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0034  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0035  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0036  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0037  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038  * POSSIBILITY OF SUCH DAMAGE.
0039  */
0040 
0041 #ifndef _RTEMS_ASM_H
0042 #define _RTEMS_ASM_H
0043 
0044 /*
0045  *  Indicate we are in an assembly file and get the basic CPU definitions.
0046  */
0047 
0048 #ifndef ASM
0049 #define ASM
0050 #endif
0051 
0052 #include <rtems/score/cpuopts.h>
0053 
0054 #ifndef __USER_LABEL_PREFIX__
0055 /**
0056  *  Recent versions of GNU cpp define variables which indicate the
0057  *  need for underscores and percents.  If not using GNU cpp or
0058  *  the version does not support this, then you will obviously
0059  *  have to define these as appropriate.
0060  *
0061  *  This symbol is prefixed to all C program symbols.
0062  */
0063 #define __USER_LABEL_PREFIX__ _
0064 #endif
0065 
0066 #ifndef __REGISTER_PREFIX__
0067 /**
0068  *  Recent versions of GNU cpp define variables which indicate the
0069  *  need for underscores and percents.  If not using GNU cpp or
0070  *  the version does not support this, then you will obviously
0071  *  have to define these as appropriate.
0072  *
0073  *  This symbol is prefixed to all register names.
0074  */
0075 #define __REGISTER_PREFIX__
0076 #endif
0077 
0078 #include <rtems/concat.h>
0079 
0080 /** Use the right prefix for global labels.  */
0081 #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
0082 
0083 /** Use the right prefix for registers.  */
0084 #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
0085 
0086 /*
0087  *  define macros for all of the registers on this CPU
0088  *
0089  *  EXAMPLE:     #define d0 REG (d0)
0090  */
0091 
0092 /*
0093  *  Define macros to handle section beginning and ends.
0094  */
0095 
0096 
0097 /** This macro is used to denote the beginning of a code declaration. */
0098 #define BEGIN_CODE_DCL .text
0099 /** This macro is used to denote the end of a code declaration. */
0100 #define END_CODE_DCL
0101 /** This macro is used to denote the beginning of a data declaration section. */
0102 #define BEGIN_DATA_DCL .data
0103 /** This macro is used to denote the end of a data declaration section. */
0104 #define END_DATA_DCL
0105 /** This macro is used to denote the beginning of a code section. */
0106 #define BEGIN_CODE .text
0107 /** This macro is used to denote the end of a code section. */
0108 #define END_CODE
0109 /** This macro is used to denote the beginning of a data section. */
0110 #define BEGIN_DATA
0111 /** This macro is used to denote the end of a data section. */
0112 #define END_DATA
0113 /** This macro is used to denote the beginning of the
0114  *  unitialized data section.
0115  */
0116 #define BEGIN_BSS
0117 /** This macro is used to denote the end of the unitialized data section.  */
0118 #define END_BSS
0119 /** This macro is used to denote the end of the assembly file.  */
0120 #define END
0121 
0122 /**
0123  *  This macro is used to declare a public global symbol.
0124  *
0125  *  @note This must be tailored for a particular flavor of the C compiler.
0126  *  They may need to put underscores in front of the symbols.
0127  */
0128 #define PUBLIC(sym) .globl SYM (sym)
0129 
0130 /**
0131  *  This macro is used to prototype a public global symbol.
0132  *
0133  *  @note This must be tailored for a particular flavor of the C compiler.
0134  *  They may need to put underscores in front of the symbols.
0135  */
0136 #define EXTERN(sym) .globl SYM (sym)
0137 
0138 #endif