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     #define CPU_RAM_START       0x200
00108 
00109     #ifdef __IAR_SYSTEMS_ICC__
00110         #warning Check CPU_BYTE_ORDER
00111         #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
00112 
00113         #define NOP            __no_operation()
00114 
00115     #else /* GCC and compatibles */
00116 
00117         #if defined(__ARMEB__)
00118             #define CPU_BYTE_ORDER CPU_BIG_ENDIAN
00119         #elif defined(__ARMEL__)
00120             #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN
00121         #else
00122             #error Unable to detect ARM endianness!
00123         #endif
00124 
00125         #define NOP            asm volatile ("mov r0,r0" ::)
00126         #define BREAKPOINT  /* asm("bkpt 0") DOES NOT WORK */
00127 
00128         #if CONFIG_FAST_MEM
00129 
00137             #define FAST_FUNC __attribute__((section(".data")))
00138 
00144             #define FAST_RODATA __attribute__((section(".data")))
00145 
00146         #else // !CONFIG_FAST_MEM
00147             #define FAST_RODATA 
00148             #define FAST_FUNC 
00149         #endif
00150 
00154         #define ISR_FUNC __attribute__((interrupt))
00155 
00156     #endif /* !__IAR_SYSTEMS_ICC_ */
00157 
00158 #elif CPU_PPC
00159 
00160     #define CPU_REG_BITS           (CPU_PPC32 ? 32 : 64)
00161     #define CPU_REGS_CNT           FIXME
00162     #define CPU_BYTE_ORDER         (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN)
00163     #define CPU_HARVARD            0
00164 
00166     #define CPU_RAM_START          0x1000
00167 
00168     #ifdef __GNUC__
00169         #define NOP         asm volatile ("nop" ::)
00170         #define BREAKPOINT  asm volatile ("twge 2,2" ::)
00171     #endif
00172 
00173 #elif CPU_DSP56K
00174 
00175     #define CPU_REG_BITS            16
00176     #define CPU_REGS_CNT            FIXME
00177     #define CPU_BYTE_ORDER          CPU_BIG_ENDIAN
00178     #define CPU_HARVARD     1
00179 
00180     /* Memory is word-addessed in the DSP56K */
00181     #define CPU_BITS_PER_CHAR  16
00182     #define SIZEOF_SHORT        1
00183     #define SIZEOF_INT          1
00184     #define SIZEOF_LONG         2
00185     #define SIZEOF_PTR          1
00186 
00188     #define CPU_RAM_START       0x200
00189 
00190     #define NOP                     asm(nop)
00191     #define BREAKPOINT              asm(debug)
00192 
00193 #elif CPU_AVR
00194 
00195     #define NOP                     asm volatile ("nop" ::)
00196 
00197     #define CPU_REG_BITS            8
00198     #define CPU_REGS_CNT           33 /* Includes SREG */
00199     #define CPU_BYTE_ORDER          CPU_LITTLE_ENDIAN
00200     #define CPU_HARVARD             1
00201 
00203     #define CPU_RAM_START       0x100
00204 
00205 #else
00206     #error No CPU_... defined.
00207 #endif
00208 
00209 #ifndef BREAKPOINT
00210 #define BREAKPOINT /* nop */
00211 #endif
00212 
00213 #ifndef FAST_FUNC
00215     #define FAST_FUNC /* */
00216 #endif
00217 
00218 #ifndef FAST_RODATA
00220     #define FAST_RODATA /* */
00221 #endif
00222 
00223 #endif /* CPU_ATTR_H */