Back to home page

LXR

 
 

    


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

0001 /**
0002  * @file
0003  * 
0004  * @brief Address the Problems Caused by Incompatible Flavor of 
0005  * Assemblers and Toolsets
0006  *
0007  * This include file attempts to address the problems
0008  * caused by incompatible flavors of assemblers and
0009  * toolsets.  It primarily addresses variations in the
0010  * use of leading underscores on symbols and the requirement
0011  * that register names be preceded by a %.
0012  * 
0013  * NOTE: The spacing in the use of these macros
0014  *       is critical to them working as advertised.
0015  */
0016 
0017 /*
0018  *  COPYRIGHT:
0019  *
0020  *  This file is based on similar code found in newlib available
0021  *  from ftp.cygnus.com.  The file which was used had no copyright
0022  *  notice.  This file is freely distributable as long as the source
0023  *  of the file is noted.  This file is:
0024  *
0025  *  COPYRIGHT (c) 1995.
0026  *  i-cubed ltd.
0027  *
0028  *  COPYRIGHT (c) 1994.
0029  *  On-Line Applications Research Corporation (OAR).
0030  */
0031 
0032 #ifndef _RTEMS_ASM_H
0033 #define _RTEMS_ASM_H
0034 
0035 /*
0036  *  Indicate we are in an assembly file and get the basic CPU definitions.
0037  */
0038 
0039 #ifndef ASM
0040 #define ASM
0041 #endif
0042 #include <rtems/score/cpuopts.h>
0043 #include <rtems/score/powerpc.h>
0044 
0045 /**
0046  * @defgroup RTEMSScoreCPUPowerPCASM PowerPC Assembler Support
0047  *
0048  * @ingroup RTEMSScoreCPUPowerPC
0049  *
0050  * @brief PowerPC Assembler Support
0051  *
0052  * @{
0053  */
0054 
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 
0062 #ifndef __USER_LABEL_PREFIX__
0063 #define __USER_LABEL_PREFIX__
0064 #endif
0065 
0066 #ifndef __REGISTER_PREFIX__
0067 #define __REGISTER_PREFIX__
0068 #endif
0069 
0070 #ifndef __FLOAT_REGISTER_PREFIX__
0071 #define __FLOAT_REGISTER_PREFIX__  __REGISTER_PREFIX__
0072 #endif
0073 
0074 #ifndef __PROC_LABEL_PREFIX__
0075 #define __PROC_LABEL_PREFIX__  __USER_LABEL_PREFIX__
0076 #endif
0077 
0078 /* Use the right prefix for global labels.  */
0079 
0080 #define SYM(x) RTEMS_XCONCAT (__USER_LABEL_PREFIX__, x)
0081 
0082 /* Use the right prefix for procedure labels.  */
0083 
0084 #define PROC(x) RTEMS_XCONCAT (__PROC_LABEL_PREFIX__, x)
0085 
0086 /* Use the right prefix for registers.  */
0087 
0088 #define REG(x) RTEMS_XCONCAT (__REGISTER_PREFIX__, x)
0089 
0090 /* Use the right prefix for floating point registers.  */
0091 
0092 #define FREG(x) RTEMS_XCONCAT (__FLOAT_REGISTER_PREFIX__, x)
0093 
0094 /*
0095  *  define macros for all of the registers on this CPU
0096  *
0097  *  EXAMPLE:     #define d0 REG (d0)
0098  */
0099 #define r0 REG(0)
0100 #define r1 REG(1)
0101 #define r2 REG(2)
0102 #define r3 REG(3)
0103 #define r4 REG(4)
0104 #define r5 REG(5)
0105 #define r6 REG(6)
0106 #define r7 REG(7)
0107 #define r8 REG(8)
0108 #define r9 REG(9)
0109 #define r10 REG(10)
0110 #define r11 REG(11)
0111 #define r12 REG(12)
0112 #define r13 REG(13)
0113 #define r14 REG(14)
0114 #define r15 REG(15)
0115 #define r16 REG(16)
0116 #define r17 REG(17)
0117 #define r18 REG(18)
0118 #define r19 REG(19)
0119 #define r20 REG(20)
0120 #define r21 REG(21)
0121 #define r22 REG(22)
0122 #define r23 REG(23)
0123 #define r24 REG(24)
0124 #define r25 REG(25)
0125 #define r26 REG(26)
0126 #define r27 REG(27)
0127 #define r28 REG(28)
0128 #define r29 REG(29)
0129 #define r30 REG(30)
0130 #define r31 REG(31)
0131 #define f0 FREG(0)
0132 #define f1 FREG(1)
0133 #define f2 FREG(2)
0134 #define f3 FREG(3)
0135 #define f4 FREG(4)
0136 #define f5 FREG(5)
0137 #define f6 FREG(6)
0138 #define f7 FREG(7)
0139 #define f8 FREG(8)
0140 #define f9 FREG(9)
0141 #define f10 FREG(10)
0142 #define f11 FREG(11)
0143 #define f12 FREG(12)
0144 #define f13 FREG(13)
0145 #define f14 FREG(14)
0146 #define f15 FREG(15)
0147 #define f16 FREG(16)
0148 #define f17 FREG(17)
0149 #define f18 FREG(18)
0150 #define f19 FREG(19)
0151 #define f20 FREG(20)
0152 #define f21 FREG(21)
0153 #define f22 FREG(22)
0154 #define f23 FREG(23)
0155 #define f24 FREG(24)
0156 #define f25 FREG(25)
0157 #define f26 FREG(26)
0158 #define f27 FREG(27)
0159 #define f28 FREG(28)
0160 #define f29 FREG(29)
0161 #define f30 FREG(30)
0162 #define f31 FREG(31)
0163 #define v0 0
0164 #define v1 1
0165 #define v2 2
0166 #define v3 3
0167 #define v4 4
0168 #define v5 5
0169 #define v6 6
0170 #define v7 7
0171 #define v8 8
0172 #define v9 9
0173 #define v10 10
0174 #define v11 11
0175 #define v12 12
0176 #define v13 13
0177 #define v14 14
0178 #define v15 15
0179 #define v16 16
0180 #define v17 17
0181 #define v18 18
0182 #define v19 19
0183 #define v20 20
0184 #define v21 21
0185 #define v22 22
0186 #define v23 23
0187 #define v24 24
0188 #define v25 25
0189 #define v26 26
0190 #define v27 27
0191 #define v28 28
0192 #define v29 29
0193 #define v30 30
0194 #define v31 31
0195 
0196 /*
0197  * Some special purpose registers (SPRs).
0198  */
0199 #define srr0    0x01a
0200 #define srr1    0x01b
0201 #define srr2    0x3de /* IBM 400 series only */
0202 #define srr3    0x3df /* IBM 400 series only */
0203 #define csrr0   58 /* Book E */
0204 #define csrr1   59 /* Book E */
0205 #define mcsrr0  570 /* e500 */
0206 #define mcsrr1  571 /* e500 */
0207 #define dsrr0   574 /* e200 */
0208 #define dsrr1   575 /* e200 */
0209 
0210 #define sprg0   0x110
0211 #define sprg1   0x111
0212 #define sprg2   0x112
0213 #define sprg3   0x113
0214 #define sprg4   276
0215 #define sprg5   277
0216 #define sprg6   278
0217 #define sprg7   279
0218 
0219 #define usprg0  256
0220 
0221 #define dar     0x013   /* Data Address Register */
0222 #define dec     0x016   /* Decrementer Register */
0223 
0224 #if defined(ppc403) || defined(ppc405)
0225 /* the following SPR/DCR registers exist only in IBM 400 series */
0226 #define dear    0x3d5
0227 #define evpr    0x3d6   /* SPR: exception vector prefix register   */
0228 #define iccr    0x3fb   /* SPR: instruction cache control reg.     */
0229 #define dccr    0x3fa   /* SPR: data cache control reg.            */
0230 
0231 #if defined (ppc403)
0232 #define exisr   0x040   /* DCR: external interrupt status register */
0233 #define exier   0x042   /* DCR: external interrupt enable register */
0234 #endif /* ppc403 */
0235 #if defined(ppc405)
0236 #define exisr   0x0C0   /* DCR: external interrupt status register */
0237 #define exier   0x0C2   /* DCR: external interrupt enable register */
0238 #endif /* ppc405 */
0239 
0240 #define br0     0x080   /* DCR: memory bank register 0             */
0241 #define br1     0x081   /* DCR: memory bank register 1             */
0242 #define br2     0x082   /* DCR: memory bank register 2             */
0243 #define br3     0x083   /* DCR: memory bank register 3             */
0244 #define br4     0x084   /* DCR: memory bank register 4             */
0245 #define br5     0x085   /* DCR: memory bank register 5             */
0246 #define br6     0x086   /* DCR: memory bank register 6             */
0247 #define br7     0x087   /* DCR: memory bank register 7             */
0248 
0249 /* end of IBM400 series register definitions */
0250 
0251 #elif defined(mpc860) || defined(mpc821)
0252 /* The following registers are for the MPC8x0 */
0253 #define der     0x095   /* Debug Enable Register */
0254 #define ictrl   0x09E   /* Instruction Support Control Register */
0255 #define immr    0x27E   /* Internal Memory Map Register */
0256 /* end of MPC8x0 registers */
0257 #endif
0258 
0259 /*
0260  *  Following must be tailor for a particular flavor of the C compiler.
0261  *  They may need to put underscores in front of the symbols.
0262  */
0263 
0264 #define PUBLIC_VAR(sym) .globl SYM (sym)
0265 #define EXTERN_VAR(sym) .extern SYM (sym)
0266 #define PUBLIC_PROC(sym) .globl PROC (sym)
0267 #define EXTERN_PROC(sym) .extern PROC (sym)
0268 
0269 /* Other potentially assembler specific operations */
0270 #if PPC_ASM == PPC_ASM_ELF
0271 #define ALIGN(n,p)  .align  p
0272 #define DESCRIPTOR(x)   \
0273     .section .descriptors,"aw"; \
0274     PUBLIC_VAR (x);         \
0275 SYM (x):;               \
0276     .long   PROC (x);       \
0277     .long   s.got;          \
0278     .long   0
0279 
0280 #define EXT_SYM_REF(x)  .long x
0281 #define EXT_PROC_REF(x) .long x
0282 
0283 /*
0284  *  Define macros to handle section beginning and ends.
0285  */
0286 
0287 #define BEGIN_CODE_DCL .text
0288 #define END_CODE_DCL
0289 #define BEGIN_DATA_DCL .data
0290 #define END_DATA_DCL
0291 #define BEGIN_CODE .text
0292 #define END_CODE
0293 #define BEGIN_DATA .data
0294 #define END_DATA
0295 #define BEGIN_BSS  .bss
0296 #define END_BSS
0297 #define END
0298 
0299 #else
0300 #error "PPC_ASM_TYPE is not properly defined"
0301 #endif
0302 #ifndef PPC_ASM
0303 #error "PPC_ASM_TYPE is not properly defined"
0304 #endif
0305 
0306 #if defined(__powerpc64__)
0307 #define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE nop
0308 #else
0309 #define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE
0310 #endif
0311 
0312 #endif
0313 
0314 /** @} */