attr.h

Go to the documentation of this file.
00001 
00040 #ifndef CPU_ATTR_H
00041 #define CPU_ATTR_H
00042 
00043 #include "detect.h"
00044 
00045 #include "cfg/cfg_attr.h"      /* CONFIG_FAST_MEM */
00046 
00047 
00052 #define CPU_BIG_ENDIAN    0x1234
00053 #define CPU_LITTLE_ENDIAN 0x3412 /* Look twice, pal. This is not a bug. */
00054 /*\}*/
00055 
00057 #define CPU_HEADER(module)          PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).h)
00058 
00060 #define CPU_CSOURCE(module)         PP_STRINGIZE(drv/PP_CAT3(module, _, CPU_ID).c)
00061 
00062 
00063 #if CPU_I196
00064 
00065     #define NOP                     nop_instruction()
00066 
00067     #define CPU_REG_BITS            16
00068     #define CPU_REGS_CNT            16
00069     #define CPU_BYTE_ORDER          CPU_LITTLE_ENDIAN
00070     #define CPU_HARVARD             0
00071 
00073     #define CPU_RAM_START       0x100
00074 
00075 #elif CPU_X86
00076 
00077     #define CPU_REGS_CNT            7
00078     #define CPU_BYTE_ORDER          CPU_LITTLE_ENDIAN
00079     #define CPU_HARVARD             0
00080 
00081     #if CPU_X86_64
00082         #define CPU_REG_BITS    64
00083 
00084         #ifdef __WIN64__
00085             /* WIN64 is an IL32-P64 weirdo. */
00086             #define SIZEOF_LONG  4
00087         #endif
00088     #else
00089         #define CPU_REG_BITS    32
00090     #endif
00091 
00093     #define CPU_RAM_START      0x1000
00094 
00095     #ifdef __GNUC__
00096         #define NOP         asm volatile ("nop")
00097         #define BREAKPOINT  asm volatile ("int3" ::)
00098     #endif
00099 
00100 #elif CPU_ARM
00101 
00102     #define CPU_REG_BITS           32
00103     #define CPU_REGS_CNT           16
00104     #define CPU_HARVARD            0
00105 
00107     #if CPU_ARM_AT91
00108         #define CPU_RAM_START       0x00200000
00109     #else
00110         #warning Fix CPU_RAM_START address for your ARM, default value set to 0x200
00111         #define CPU_RAM_START       0x200
00112     #endif
00113 
00114     #ifdef __IAR_SYSTEMS_ICC__
00115         #warning Check CPU_BYTE_ORDER
00116         #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
00117 
00118         #define NOP            __no_operation()
00119 
00120     #else /* GCC and compatibles */
00121 
00122         #if defined(__ARMEB__)
00123             #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
00124         #elif defined(__ARMEL__)
00125             #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
00126         #else
00127             #error Unable to detect ARM endianness!
00128         #endif
00129 
00130         #define NOP            asm volatile ("mov r0,r0" ::)
00131         #define BREAKPOINT  /* asm("bkpt 0") DOES NOT WORK */
00132 
00133         #if CONFIG_FAST_MEM
00134 
00142             #define FAST_FUNC __attribute__((section(".data")))
00143 
00149             #define FAST_RODATA __attribute__((section(".data")))
00150 
00151         #else // !CONFIG_FAST_MEM
00152             #define FAST_RODATA 
00153             #define FAST_FUNC 
00154         #endif
00155 
00159         #define ISR_FUNC __attribute__((interrupt))
00160 
00161     #endif /* !__IAR_SYSTEMS_ICC_ */
00162 
00163 #elif CPU_PPC
00164 
00165     #define CPU_REG_BITS           (CPU_PPC32 ? 32 : 64)
00166     #define CPU_REGS_CNT           FIXME
00167     #define CPU_BYTE_ORDER         (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
00168     #define CPU_HARVARD            0
00169 
00171     #define CPU_RAM_START          0x1000
00172 
00173     #ifdef __GNUC__
00174         #define NOP         asm volatile ("nop" ::)
00175         #define BREAKPOINT  asm volatile ("twge 2,2" ::)
00176     #endif
00177 
00178 #elif CPU_DSP56K
00179 
00180     #define CPU_REG_BITS            16
00181     #define CPU_REGS_CNT            FIXME
00182     #define CPU_BYTE_ORDER          CPU_BIG_ENDIAN
00183     #define CPU_HARVARD     1
00184 
00185     /* Memory is word-addessed in the DSP56K */
00186     #define CPU_BITS_PER_CHAR  16
00187     #define SIZEOF_SHORT        1
00188     #define SIZEOF_INT          1
00189     #define SIZEOF_LONG         2
00190     #define SIZEOF_PTR          1
00191 
00193     #define CPU_RAM_START       0x200
00194 
00195     #define NOP                     asm(nop)
00196     #define BREAKPOINT              asm(debug)
00197 
00198 #elif CPU_AVR
00199 
00200     #define NOP                     asm volatile ("nop" ::)
00201 
00202     #define CPU_REG_BITS            8
00203     #define CPU_REGS_CNT           33 /* Includes SREG */
00204     #define CPU_BYTE_ORDER          CPU_LITTLE_ENDIAN
00205     #define CPU_HARVARD             1
00206 
00208     #if CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA32 || CPU_AVR_ATMEGA103
00209         #define CPU_RAM_START       0x60
00210     #elif CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA168
00211         #define CPU_RAM_START       0x100
00212     #elif CPU_AVR_ATMEGA1281
00213         #define CPU_RAM_START       0x200
00214     #else
00215         #warning Fix CPU_RAM_START address for your AVR, default value set to 0x100
00216         #define CPU_RAM_START       0x100
00217     #endif
00218 
00219 #else
00220     #error No CPU_... defined.
00221 #endif
00222 
00223 #ifndef BREAKPOINT
00224 #define BREAKPOINT /* nop */
00225 #endif
00226 
00227 #ifndef FAST_FUNC
00229     #define FAST_FUNC /* */
00230 #endif
00231 
00232 #ifndef FAST_RODATA
00234     #define FAST_RODATA /* */
00235 #endif
00236 
00237 #endif /* CPU_ATTR_H */