Go to the documentation of this file.00001 #ifndef _ARCH_ARM_H_
00002 #define _ARCH_ARM_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 #include <cfg/arch.h>
00114 #if defined (MCU_AT91)
00115 #include <arch/arm/at91.h>
00116 #elif defined (MCU_GBA)
00117 #include <arch/arm/gba.h>
00118 #elif defined (MCU_LPC2XXX)
00119 #include <arch/arm/lpc2xxx.h>
00120 #endif
00121
00122 #ifndef __ASSEMBLER__
00123 #include <dev/mweeprom.h>
00124 #endif
00125
00126 #define ARM_MODE_USER 0x10
00127 #define ARM_MODE_FIQ 0x11
00128 #define ARM_MODE_IRQ 0x12
00129 #define ARM_MODE_SVC 0x13
00130 #define ARM_MODE_ABORT 0x17
00131 #define ARM_MODE_UNDEF 0x1B
00132 #define ARM_MODE_SYS 0x1F
00133 #define ARM_MODE_MASK 0x1F
00134
00135 #define I_BIT 0x80
00136 #define ARM_CPSR_I_BIT 0x80
00137 #define F_BIT 0x40
00138 #define ARM_CPSR_F_BIT 0x40
00139 #define T_BIT 0x20
00140 #define ARM_CPSR_T_BIT 0x20
00141
00142 #ifdef __GNUC__
00143 #define CONST const
00144 #define INLINE inline
00145 #else
00146 #ifndef CONST
00147 #define CONST const
00148 #endif
00149 #ifndef INLINE
00150 #define INLINE
00151 #endif
00152 #endif
00153
00154 #define PSTR(p) (p)
00155 #define PRG_RDB(p) (*((const char *)(p)))
00156
00157 #define prog_char const char
00158 #define PGM_P prog_char *
00159
00160 #define SIGNAL(x) __attribute__((interrupt_handler)) void x(void)
00161 #define RAMFUNC __attribute__ ((long_call, section (".ramfunc")))
00162
00163 #if !defined(__arm__) && !defined(__cplusplus)
00164 #define main NutAppMain
00165 #endif
00166
00167 #define strlen_P(x) strlen((char *)(x))
00168 #define strcpy_P(x,y) strcpy(x,(char *)(y))
00169 #define strcat_P(x,y) strcat(x,(char *)(y))
00170
00171 #define strcmp_P(x, y) strcmp((char *)(x), (char *)(y))
00172 #define memcpy_P(x, y, z) memcpy(x, y, z)
00173
00174 #ifndef __ASSEMBLER__
00175
00178 extern void *__bss_end;
00179
00183 extern void *__stack;
00184 #endif
00185
00186 #ifndef _NOP
00187 #ifdef __GNUC__
00188 #define _NOP() __asm__ __volatile__ ("mov r0, r0 @ _NOP")
00189 #else
00190 #define _NOP() asm("mov r0, r0")
00191 #endif
00192 #endif
00193
00194 #define outb(_reg, _val) (*((volatile unsigned char *)(_reg)) = (_val))
00195 #define outw(_reg, _val) (*((volatile unsigned short *)(_reg)) = (_val))
00196 #define outr(_reg, _val) (*((volatile unsigned int *)(_reg)) = (_val))
00197
00198 #define inb(_reg) (*((volatile unsigned char *)(_reg)))
00199 #define inw(_reg) (*((volatile unsigned short *)(_reg)))
00200 #define inr(_reg) (*((volatile unsigned int *)(_reg)))
00201
00202 #define _BV(bit) (1 << (bit))
00203
00204 #define sbi(_reg, _bit) outr(_reg, inr(_reg) | _BV(_bit))
00205 #define cbi(_reg, _bit) outr(_reg, inr(_reg) & ~_BV(_bit))
00206 #define bit_is_set(_reg, _bit) ((inr(_reg) & _BV(_bit)) != 0)
00207
00208 #ifdef __IMAGECRAFT__
00209 #define __attribute__(x)
00210 #endif
00211
00212 #define _SFR_MEM8(addr) (addr)
00213 #define _SFR_MEM16(addr) (addr)
00214
00215 #ifndef __ASSEMBLER__
00216 #ifdef __GNUC__
00217 #define ARM_SET_CP15_CR(val) __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 0" :: "r"(val) : "cc")
00218 #define ARM_GET_CP15_CR() ( \
00219 { \
00220 unsigned int val; \
00221 __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 0" : "=r"(val) :: "cc"); \
00222 val; \
00223 } \
00224 )
00225 #endif
00226 #endif
00227
00228 #if !defined (__ASSEMBLER__) && defined(__CROSSWORKS_ARM)
00229
00236 #define strcasecmp(s1, s2) stricmp(s1, s2)
00237 #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
00238
00239
00240
00241
00242 int stricmp(CONST char *s1, CONST char *s2);
00243 int strnicmp(CONST char *s1, CONST char *s2, size_t n);
00244 char *strdup(CONST char *str);
00245
00246
00247
00248
00249
00250
00251
00252 #define asm __asm__
00253 #endif
00254
00255 #endif