![]() |
|
|||
File indexing completed on 2025-05-11 08:24:25
0001 /** 0002 * @file 0003 * 0004 * This include file attempts to address the problems 0005 * caused by incompatible flavors of assemblers and 0006 * toolsets. It primarily addresses variations in the 0007 * use of leading underscores on symbols and the requirement 0008 * that register names be preceded by a %. 0009 */ 0010 0011 /* 0012 * NOTE: The spacing in the use of these macros 0013 * is critical to them working as advertised. 0014 * 0015 * This file is based on similar code found in newlib available 0016 * from ftp.cygnus.com. The file which was used had no copyright 0017 * notice. This file is freely distributable as long as the source 0018 * of the file is noted. This file is: 0019 * 0020 * Copyright (c) 2015 University of York. 0021 * Hesham Almatary <hesham@alumni.york.ac.uk> 0022 * 0023 * 0024 * COPYRIGHT (c) 1994-1997. 0025 * On-Line Applications Research Corporation (OAR). 0026 * 0027 * Redistribution and use in source and binary forms, with or without 0028 * modification, are permitted provided that the following conditions 0029 * are met: 0030 * 1. Redistributions of source code must retain the above copyright 0031 * notice, this list of conditions and the following disclaimer. 0032 * 2. Redistributions in binary form must reproduce the above copyright 0033 * notice, this list of conditions and the following disclaimer in the 0034 * documentation and/or other materials provided with the distribution. 0035 * 0036 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 0037 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0038 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0039 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 0040 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 0041 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 0042 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 0043 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 0044 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 0045 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 0046 * SUCH DAMAGE. 0047 */ 0048 0049 #ifndef __RISCV_ASM_H 0050 #define __RISCV_ASM_H 0051 0052 /* 0053 * Indicate we are in an assembly file and get the basic CPU definitions. 0054 */ 0055 0056 #ifndef ASM 0057 #define ASM 0058 #endif 0059 #include <rtems/score/cpuopts.h> 0060 #include <rtems/score/riscv.h> 0061 0062 /** 0063 * @defgroup RTEMSScoreCPURISCVASM RISC-V Assembler Support 0064 * 0065 * @ingroup RTEMSScoreCPURISCV 0066 * 0067 * @brief RISC-V Assembler Support 0068 * 0069 * @{ 0070 */ 0071 0072 /* 0073 * Recent versions of GNU cpp define variables which indicate the 0074 * need for underscores and percents. If not using GNU cpp or 0075 * the version does not support this, then you will obviously 0076 * have to define these as appropriate. 0077 */ 0078 0079 #ifndef __USER_LABEL_PREFIX__ 0080 #define __USER_LABEL_PREFIX__ _ 0081 #endif 0082 0083 #ifndef __REGISTER_PREFIX__ 0084 #define __REGISTER_PREFIX__ 0085 #endif 0086 0087 /* ANSI concatenation macros. */ 0088 0089 #define CONCAT1(a, b) CONCAT2(a, b) 0090 #define CONCAT2(a, b) a ## b 0091 0092 /* Use the right prefix for global labels. */ 0093 0094 #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) 0095 0096 /* Use the right prefix for registers. */ 0097 0098 #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) 0099 0100 /* 0101 * define macros for all of the registers on this CPU 0102 * 0103 * EXAMPLE: #define d0 REG (d0) 0104 */ 0105 0106 /* 0107 * Define macros to handle section beginning and ends. 0108 */ 0109 #define BEGIN_CODE_DCL .text 0110 #define END_CODE_DCL 0111 #define BEGIN_DATA_DCL .data 0112 #define END_DATA_DCL 0113 #define BEGIN_CODE .text 0114 #define END_CODE 0115 #define BEGIN_DATA 0116 #define END_DATA 0117 #define BEGIN_BSS 0118 #define END_BSS 0119 #define END 0120 0121 /* 0122 * Following must be tailor for a particular flavor of the C compiler. 0123 * They may need to put underscores in front of the symbols. 0124 */ 0125 0126 #define PUBLIC(sym) .global SYM (sym) 0127 #define EXTERN(sym) .extern SYM (sym) 0128 #define TYPE_FUNC(sym) .type SYM (sym), %function 0129 0130 #if __riscv_xlen == 32 0131 0132 #define LREG lw 0133 0134 #define SREG sw 0135 0136 #elif __riscv_xlen == 64 0137 0138 #define LREG ld 0139 0140 #define SREG sd 0141 0142 #endif /* __riscv_xlen */ 0143 0144 #ifdef __riscv_cmodel_medany 0145 0146 #define LADDR lla 0147 0148 #else /* !__riscv_cmodel_medany */ 0149 0150 #define LADDR la 0151 0152 #endif /* __riscv_cmodel_medany */ 0153 0154 #if __riscv_flen == 32 0155 0156 #define FLREG flw 0157 0158 #define FSREG fsw 0159 0160 #define FMVYX fmv.s.x 0161 0162 #define FMVXY fmv.x.s 0163 0164 #elif __riscv_flen == 64 0165 0166 #define FLREG fld 0167 0168 #define FSREG fsd 0169 0170 #if __riscv_xlen == 32 0171 0172 #define FMVYX fmv.s.x 0173 0174 #define FMVXY fmv.x.s 0175 0176 #elif __riscv_xlen == 64 0177 0178 #define FMVYX fmv.d.x 0179 0180 #define FMVXY fmv.x.d 0181 0182 #endif /* __riscv_xlen */ 0183 0184 #endif /* __riscv_flen */ 0185 0186 .macro GET_SELF_CPU_CONTROL REG 0187 #ifdef RTEMS_SMP 0188 csrr \REG, mscratch 0189 #else 0190 LADDR \REG, _Per_CPU_Information 0191 #endif 0192 .endm 0193 0194 .macro CLEAR_RESERVATIONS REG 0195 #ifdef __riscv_atomic 0196 /* 0197 * Clear reservations, see also RISC-V User-Level ISA V2.3, comment in 0198 * section 8.2 "Load-Reserved/Store-Conditional Instructions". 0199 */ 0200 sc.w zero, zero, (\REG) 0201 #endif 0202 .endm 0203 0204 #endif 0205 0206 /** @} */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |