arm.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #ifndef _ARCH_ARM_H_
  2. #define _ARCH_ARM_H_
  3. /*
  4. * Copyright (C) 2001-2006 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log: arm.h,v $
  36. * Revision 1.17 2007/05/02 11:32:07 haraldkipp
  37. * Mapping of Harvard specific stdio functions moved to stdio.h and io.h.
  38. *
  39. * Revision 1.16 2006/08/31 19:04:08 haraldkipp
  40. * Added support for the AT91SAM9260 and Atmel's AT91SAM9260 Evaluation Kit.
  41. *
  42. * Revision 1.15 2006/08/05 11:58:22 haraldkipp
  43. * Missing brackets may result in unexpected expansion of the _BV() macro.
  44. *
  45. * Revision 1.14 2006/08/01 07:35:59 haraldkipp
  46. * Exclude function prototypes when included by assembler.
  47. *
  48. * Revision 1.13 2006/07/21 09:08:58 haraldkipp
  49. * Map puts_P to puts and _write_P to _write for non-Harvard architectures.
  50. *
  51. * Revision 1.12 2006/07/10 14:27:03 haraldkipp
  52. * C++ will use main instead of NutAppMain. Contributed by Matthias Wilde.
  53. *
  54. * Revision 1.11 2006/07/05 07:45:25 haraldkipp
  55. * Split on-chip interface definitions.
  56. *
  57. * Revision 1.10 2006/06/28 17:22:34 haraldkipp
  58. * Make it compile for AT91SAM7X256.
  59. *
  60. * Revision 1.9 2006/05/25 09:35:27 haraldkipp
  61. * Dummy macros added to support the avr-libc special function register
  62. * definitions.
  63. *
  64. * Revision 1.8 2006/03/16 15:25:26 haraldkipp
  65. * Changed human readable strings from u_char to char to stop GCC 4 from
  66. * nagging about signedness.
  67. *
  68. * Revision 1.7 2006/03/02 20:02:05 haraldkipp
  69. * Added a few macros to allow compilation with ICCARM.
  70. *
  71. * Revision 1.6 2006/02/23 15:34:00 haraldkipp
  72. * Support for Philips LPC2xxx Family and LPC-E2294 Board from Olimex added.
  73. * Many thanks to Michael Fischer for this port.
  74. *
  75. * Revision 1.5 2005/11/20 14:45:15 haraldkipp
  76. * Define printf_P for non Harvard architectures.
  77. *
  78. * Revision 1.4 2005/10/24 18:03:02 haraldkipp
  79. * GameBoy header file added.
  80. *
  81. * Revision 1.3 2005/10/24 10:35:05 haraldkipp
  82. * Port I/O macros added.
  83. *
  84. * Revision 1.2 2004/09/08 10:24:26 haraldkipp
  85. * RAMSTART is too platform dependant
  86. *
  87. * Revision 1.1 2004/03/16 16:48:28 haraldkipp
  88. * Added Jan Dubiec's H8/300 port.
  89. *
  90. * Revision 1.1 2004/02/01 18:49:47 haraldkipp
  91. * Added CPU family support
  92. *
  93. */
  94. #include <cfg/arch.h>
  95. #if defined (MCU_AT91R40008) || defined (MCU_AT91SAM7X256) || defined (MCU_AT91SAM9260)
  96. #include <arch/arm/at91.h>
  97. #elif defined (MCU_GBA)
  98. #include <arch/arm/gba.h>
  99. #elif defined (MCU_LPC2XXX)
  100. #include <arch/arm/lpc2xxx.h>
  101. #endif
  102. #ifndef __ASSEMBLER__
  103. #include <dev/mweeprom.h>
  104. #endif
  105. #define ARM_MODE_USER 0x10
  106. #define ARM_MODE_FIQ 0x11
  107. #define ARM_MODE_IRQ 0x12
  108. #define ARM_MODE_SVC 0x13
  109. #define ARM_MODE_ABORT 0x17
  110. #define ARM_MODE_UNDEF 0x1B
  111. #define ARM_MODE_SYS 0x1F
  112. #define ARM_MODE_MASK 0x1F
  113. #define I_BIT 0x80
  114. #define F_BIT 0x40
  115. #define T_BIT 0x20
  116. #ifdef __GNUC__
  117. #define CONST const
  118. #define INLINE inline
  119. #else
  120. #ifndef CONST
  121. #define CONST const
  122. #endif
  123. #ifndef INLINE
  124. #define INLINE
  125. #endif
  126. #endif
  127. #define PSTR(p) (p)
  128. #define PRG_RDB(p) (*((const char *)(p)))
  129. #define prog_char const char
  130. #define PGM_P prog_char *
  131. #define SIGNAL(x) __attribute__((interrupt_handler)) void x(void)
  132. #define RAMFUNC __attribute__ ((long_call, section (".ramfunc")))
  133. #if !defined(__arm__) && !defined(__cplusplus)
  134. #define main NutAppMain
  135. #endif
  136. #define strlen_P(x) strlen((char *)(x))
  137. #define strcpy_P(x,y) strcpy(x,(char *)(y))
  138. #define strcmp_P(x, y) strcmp((char *)(x), (char *)(y))
  139. #define memcpy_P(x, y, z) memcpy(x, y, z)
  140. #ifndef __ASSEMBLER__
  141. /*!
  142. * \brief End of uninitialised data segment. Defined in the linker script.
  143. */
  144. extern void *__bss_end;
  145. /*!
  146. * \brief Begin of the stack segment. Defined in the linker script.
  147. */
  148. extern void *__stack;
  149. #endif
  150. #ifndef _NOP
  151. #ifdef __GNUC__
  152. #define _NOP() __asm__ __volatile__ ("mov r0, r0")
  153. #else
  154. #define _NOP() asm("mov r0, r0")
  155. #endif
  156. #endif
  157. #define outb(_reg, _val) (*((volatile unsigned char *)(_reg)) = (_val))
  158. #define outw(_reg, _val) (*((volatile unsigned short *)(_reg)) = (_val))
  159. #define outr(_reg, _val) (*((volatile unsigned int *)(_reg)) = (_val))
  160. #define inb(_reg) (*((volatile unsigned char *)(_reg)))
  161. #define inw(_reg) (*((volatile unsigned short *)(_reg)))
  162. #define inr(_reg) (*((volatile unsigned int *)(_reg)))
  163. #define _BV(bit) (1 << (bit))
  164. #ifdef __IMAGECRAFT__
  165. #define __attribute__(x)
  166. #endif
  167. #define _SFR_MEM8(addr) (addr)
  168. #define _SFR_MEM16(addr) (addr)
  169. #endif