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
00115 #if defined(__ARM_ARCH_4T__)
00116 #include <arch/arm/armv4t.h>
00117 #elif defined(__ARM_ARCH_7M__)
00118 #include <arch/arm/armv7_m.h>
00119 #else
00120 #error ARM architecture unknown or not specified
00121 #endif
00122
00123
00124 #ifdef __GNUC__
00125 #define CONST const
00126 #define INLINE inline
00127 #else
00128 #ifndef CONST
00129 #define CONST const
00130 #endif
00131 #ifndef INLINE
00132 #define INLINE
00133 #endif
00134 #endif
00135
00137 #define SIGNAL(x) __attribute__((interrupt_handler)) void x(void)
00138
00139
00140
00141
00142
00143
00144 #if defined(MCU_AT91SAM7SE)
00145
00156 #define SECTION_FUNC_IRAM __attribute__ ((long_call, section(".text_iram")))
00157
00167 #define SECTION_DATA_IRAM __attribute__ ((section(".data_iram")))
00168
00178 #define SECTION_BSS_IRAM __attribute__ ((section(".bss_iram")))
00179
00188 #define SECTION_FUNC_XRAM __attribute__ ((long_call, section(".text_xram")))
00189
00199 #define SECTION_BSS_XRAM __attribute__ ((section(".bss_xram")))
00200
00201 #endif
00202
00208 #define RAMFUNC __attribute__ ((long_call, section (".ramfunc")))
00209
00210 #if !defined(__arm__) && !defined(__cplusplus)
00211 #define main NutAppMain
00212 #endif
00213
00214 #define PSTR(p) (p)
00215 #define PRG_RDB(p) (*((const char *)(p)))
00216
00217 #define prog_char const char
00218 #define PGM_P prog_char *
00219
00220 #define strlen_P(x) strlen((char *)(x))
00221 #define strcpy_P(x,y) strcpy(x,(char *)(y))
00222 #define strcat_P(x,y) strcat(x,(char *)(y))
00223
00224 #define strcmp_P(x, y) strcmp((char *)(x), (char *)(y))
00225 #define memcpy_P(x, y, z) memcpy(x, y, z)
00226
00227 #ifndef __ASSEMBLER__
00228
00231 extern void *__bss_end;
00232
00236 extern void *__stack;
00237 #endif
00238
00239 #ifndef _NOP
00240 #ifdef __GNUC__
00241 #define _NOP() __asm__ __volatile__ ("mov r0, r0 @ _NOP")
00242 #else
00243 #define _NOP() asm("mov r0, r0")
00244 #endif
00245 #endif
00246
00247 #define outb(_reg, _val) (*((volatile unsigned char *)(_reg)) = (_val))
00248 #define outw(_reg, _val) (*((volatile unsigned short *)(_reg)) = (_val))
00249 #define outr(_reg, _val) (*((volatile unsigned int *)(_reg)) = (_val))
00250
00251 #define inb(_reg) (*((volatile unsigned char *)(_reg)))
00252 #define inw(_reg) (*((volatile unsigned short *)(_reg)))
00253 #define inr(_reg) (*((volatile unsigned int *)(_reg)))
00254
00255 #define _BV(bit) (1 << (bit))
00256
00257 #define sbi(_reg, _bit) outr(_reg, inr(_reg) | _BV(_bit))
00258 #define cbi(_reg, _bit) outr(_reg, inr(_reg) & ~_BV(_bit))
00259 #define bit_is_set(_reg, _bit) ((inr(_reg) & _BV(_bit)) != 0)
00260
00261 #ifdef __IMAGECRAFT__
00262 #define __attribute__(x)
00263 #endif
00264
00265 #define _SFR_MEM8(addr) (addr)
00266 #define _SFR_MEM16(addr) (addr)
00267
00268 #if !defined (__ASSEMBLER__)
00269 #define mem_barrier() __asm__ __volatile__("":::"memory")
00270
00271 static INLINE void mem_wr(unsigned int reg, unsigned int val)
00272 {
00273 *(volatile unsigned int *) reg = val;
00274 }
00275
00276 static INLINE void mem_wr8(unsigned int reg, uint8_t val)
00277 {
00278 *(volatile uint8_t *) reg = val;
00279 }
00280
00281 static INLINE void mem_wr16(unsigned int reg, uint16_t val)
00282 {
00283 *(volatile uint16_t *) reg = val;
00284 }
00285
00286 static INLINE void mem_wr32(unsigned int reg, uint32_t val)
00287 {
00288 *(volatile uint32_t *) reg = val;
00289 }
00290
00291 static INLINE unsigned int mem_rd(unsigned int reg)
00292 {
00293 return *(const volatile unsigned int *) reg;
00294 }
00295
00296 static INLINE uint8_t mem_rd8(unsigned int reg)
00297 {
00298 return *(const volatile uint8_t *) reg;
00299 }
00300
00301 static INLINE uint16_t mem_rd16(unsigned int reg)
00302 {
00303 return *(const volatile uint16_t *) reg;
00304 }
00305
00306 static INLINE uint32_t mem_rd32(unsigned int reg)
00307 {
00308 return *(const volatile uint32_t *) reg;
00309 }
00310
00311 static INLINE void mem_wr_mb(unsigned int reg, unsigned int val)
00312 {
00313 mem_barrier();
00314 mem_wr(reg, val);
00315 }
00316
00317 static INLINE void mem_wr8_mb(unsigned int reg, uint8_t val)
00318 {
00319 mem_barrier();
00320 mem_wr8(reg, val);
00321 }
00322
00323 static INLINE void mem_wr16_mb(unsigned int reg, uint16_t val)
00324 {
00325 mem_barrier();
00326 mem_wr16(reg, val);
00327 }
00328
00329 static INLINE void mem_wr32_mb(unsigned int reg, uint32_t val)
00330 {
00331 mem_barrier();
00332 mem_wr32(reg, val);
00333 }
00334
00335 static INLINE unsigned int mem_rd_mb(unsigned int reg)
00336 {
00337 unsigned int rc = mem_rd(reg);
00338 mem_barrier();
00339
00340 return rc;
00341 }
00342
00343 static INLINE uint8_t mem_rd8_mb(unsigned int reg)
00344 {
00345 uint8_t rc = mem_rd8(reg);
00346 mem_barrier();
00347
00348 return rc;
00349 }
00350
00351 static INLINE uint16_t mem_rd16_mb(unsigned int reg)
00352 {
00353 uint16_t rc = mem_rd16(reg);
00354 mem_barrier();
00355
00356 return rc;
00357 }
00358
00359 static INLINE uint32_t mem_rd32_mb(unsigned int reg)
00360 {
00361 uint32_t rc = mem_rd32(reg);
00362 mem_barrier();
00363
00364 return rc;
00365 }
00366
00367 #endif
00368
00369 #if !defined (__ASSEMBLER__) && defined(__CROSSWORKS_ARM)
00370
00377 #define strcasecmp(s1, s2) stricmp(s1, s2)
00378 #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
00379
00380
00381
00382
00383 int stricmp(CONST char *s1, CONST char *s2);
00384 int strnicmp(CONST char *s1, CONST char *s2, size_t n);
00385 char *strdup(CONST char *str);
00386
00387
00388
00389
00390
00391
00392
00393 #define asm __asm__
00394 #endif
00395
00396 #endif