Back to home page

LXR

 
 

    


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

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) 1994-1997.
0026  *  On-Line Applications Research Corporation (OAR).
0027  */
0028 
0029 #ifndef _RTEMS_ASM_H
0030 #define _RTEMS_ASM_H
0031 
0032 /*
0033  *  Indicate we are in an assembly file and get the basic CPU definitions.
0034  */
0035 
0036 #ifndef ASM
0037 #define ASM
0038 #endif
0039 #include <rtems/score/cpuopts.h>
0040 #include <rtems/score/i386.h>
0041 #include <rtems/score/percpu.h>
0042 
0043 /**
0044  * @defgroup RTEMSScoreCPUi386ASM i386 Assembler Support
0045  *
0046  * @ingroup RTEMSScoreCPUi386
0047  *
0048  * @brief i386 Assembler Support
0049  */
0050 /**@{**/
0051 
0052 /*
0053  *  Recent versions of GNU cpp define variables which indicate the
0054  *  need for underscores and percents.  If not using GNU cpp or
0055  *  the version does not support this, then you will obviously
0056  *  have to define these as appropriate.
0057  */
0058 
0059 #ifndef __USER_LABEL_PREFIX__
0060 #define __USER_LABEL_PREFIX__
0061 #endif
0062 
0063 /*
0064  *  Looks like there is a bug in gcc 2.6.2 where this is not
0065  *  defined correctly when configured as i386-coff and
0066  *  i386-aout.
0067  */
0068 
0069 #undef __REGISTER_PREFIX__
0070 #define __REGISTER_PREFIX__ %
0071 
0072 /*
0073 #ifndef __REGISTER_PREFIX__
0074 #define __REGISTER_PREFIX__
0075 #endif
0076 */
0077 
0078 #include <rtems/concat.h>
0079 
0080 /* Use the right prefix for global labels.  */
0081 
0082 #define SYM(x) CONCAT0 (__USER_LABEL_PREFIX__, x)
0083 
0084 /* Use the right prefix for registers.  */
0085 
0086 #define REG(x) CONCAT0 (__REGISTER_PREFIX__, x)
0087 
0088 #define eax REG (eax)
0089 #define ebx REG (ebx)
0090 #define ecx REG (ecx)
0091 #define edx REG (edx)
0092 #define esi REG (esi)
0093 #define edi REG (edi)
0094 #define esp REG (esp)
0095 #define ebp REG (ebp)
0096 #define cr0 REG (cr0)
0097 #define cr4 REG (cr4)
0098 
0099 #define ax REG (ax)
0100 #define bx REG (bx)
0101 #define cx REG (cx)
0102 #define dx REG (dx)
0103 #define si REG (si)
0104 #define di REG (di)
0105 #define sp REG (sp)
0106 #define bp REG (bp)
0107 
0108 #define ah REG (ah)
0109 #define bh REG (bh)
0110 #define ch REG (ch)
0111 #define dh REG (dh)
0112 
0113 #define al REG (al)
0114 #define bl REG (bl)
0115 #define cl REG (cl)
0116 #define dl REG (dl)
0117 
0118 #define cs REG (cs)
0119 #define ds REG (ds)
0120 #define es REG (es)
0121 #define fs REG (fs)
0122 #define gs REG (gs)
0123 #define ss REG (ss)
0124 
0125 /*
0126  *  Define macros to handle section beginning and ends.
0127  */
0128 
0129 
0130 #define BEGIN_CODE_DCL .text
0131 #define END_CODE_DCL
0132 #define BEGIN_DATA_DCL .data
0133 #define END_DATA_DCL
0134 #define BEGIN_CODE .text
0135 #define END_CODE
0136 #define BEGIN_DATA .data
0137 #define END_DATA
0138 #define BEGIN_BSS .bss
0139 #define END_BSS
0140 #define END
0141 
0142 /*
0143  *  Following must be tailor for a particular flavor of the C compiler.
0144  *  They may need to put underscores in front of the symbols.
0145  */
0146 
0147 #define PUBLIC(sym) .globl SYM (sym)
0148 #define EXTERN(sym) .globl SYM (sym)
0149 
0150 #ifdef RTEMS_SMP
0151 .macro GET_CPU_ID REG
0152     .set  LAPIC_ID,         0x20
0153     .set  LAPIC_ID_SHIFT,   0x18L
0154     movl     imps_lapic_addr,\REG
0155     movl     LAPIC_ID(\REG),\REG
0156     shrl     $LAPIC_ID_SHIFT,\REG                /* LAPIC_ID in REG */
0157     movzbl   imps_apic_cpu_map(\REG),\REG        /* CPU ID in REG */
0158 .endm
0159 
0160 .macro GET_SELF_CPU_CONTROL REG
0161     GET_CPU_ID \REG
0162     shll     $PER_CPU_CONTROL_SIZE_LOG2,\REG     /* Calculate offset for CPU structure */
0163     leal     _Per_CPU_Information(\REG),\REG     /* Address of info for current CPU in REG */
0164 .endm
0165 #else
0166 .macro GET_CPU_ID REG
0167     movl  $0,\REG
0168 .endm
0169 
0170 .macro GET_SELF_CPU_CONTROL REG
0171     leal     _Per_CPU_Information, \REG
0172 .endm
0173 #endif
0174 
0175 /**@}**/
0176 
0177 #endif