arm.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:6k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* arm.h - ARM CPU flags etc */
  2. /* Copyright 1996-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01e,15jan02,m_h  ARMARCH5 thumb problem
  7. 01d,05nov01,t_m  remove leading underscores via FUNC/VAR macros
  8. 01c,05nov01,t_m  Undo underscores
  9. 01b,19jul01,ed   Fixing to be compatible with Diab compiler.
  10. 01d,17oct01,t_m  Merge in DIAB 
  11. 01c,10oct01,jb  Enabling removal of pre-pended underscores for new compilers
  12.                  (Diab/Gnu elf)
  13. 01b,23jul01,scm  change XScale name to conform to coding standards...
  14. 01a,11dec00,scm  replace references to ARMSA2 with XScale
  15. 01g,16oct00,scm  reverse back I & F bits for SA2
  16. 01f,01sep00,scm  add sa2 support...
  17. 01e,08feb99,jpd  added further MMU/CACHE types.
  18. 01d,20jan99,cdp  removed support for old ARM libraries.
  19. 01c,24aug98,cdp  added MMU/cache types, ARM_HAS_MPU/ARM_THUMB, ARMST16/ARMST32.
  20. 01b,21aug97,cdp  added _?_FUNCTION macros and HAS_HALFWORD_
  21. 01a,08may96,cdp  written
  22. */
  23. #ifndef __INCarmh
  24. #define __INCarmh
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Make sure excArmLib.h also has same settings */
  29. /* bits in the PSR */
  30. #define V_BIT (1<<28)
  31. #define C_BIT (1<<29)
  32. #define Z_BIT (1<<30)
  33. #define N_BIT (1<<31)
  34. #define I_BIT   (1<<7)
  35. #define F_BIT   (1<<6)
  36. #define T_BIT (1<<5)
  37. /* mode bits */
  38. #define MODE_SYSTEM32 0x1F
  39. #define MODE_UNDEF32 0x1B
  40. #define MODE_ABORT32 0x17
  41. #define MODE_SVC32 0x13
  42. #define MODE_IRQ32      0x12
  43. #define MODE_FIQ32      0x11
  44. #define MODE_USER32 0x10
  45. /* masks for getting bits from PSR */
  46. #define MASK_MODE 0x0000003F
  47. #define MASK_32MODE 0x0000001F
  48. #define MASK_SUBMODE 0x0000000F
  49. #define MASK_INT 0x000000C0
  50. #define MASK_CC 0xF0000000
  51. /* shifts to access bits in the PSR */
  52. #define INT_MASK_SHIFT 6
  53. /* The coprocessor number of the MMU System Control Processor */
  54. #define CP_MMU 15
  55. /* ARM MMU types */
  56. #define ARMMMU_NONE 0
  57. #define ARMMMU_710A 1
  58. #define ARMMMU_810 2
  59. #define ARMMMU_SA110 3
  60. #define ARMMMU_940T 4
  61. #define ARMMMU_740T 5
  62. #define ARMMMU_SA1100 6
  63. #define ARMMMU_SA1500 7
  64. #define ARMMMU_720T 8
  65. #define ARMMMU_920T 9
  66. #define ARMMMU_946E     10
  67. #define ARMMMU_XSCALE   11
  68. /* ARM cache types */
  69. #define ARMCACHE_NONE 0
  70. #define ARMCACHE_710A 1
  71. #define ARMCACHE_810 2
  72. #define ARMCACHE_SA110 3
  73. #define ARMCACHE_940T 4
  74. #define ARMCACHE_740T 5
  75. #define ARMCACHE_SA1100 6
  76. #define ARMCACHE_SA1500 7
  77. #define ARMCACHE_720T 8
  78. #define ARMCACHE_920T 9
  79. #define ARMCACHE_946E   10
  80. #define ARMCACHE_XSCALE 11
  81. /* check CPU/cache/MMU features */
  82. /* Cache Line sizes */
  83. #undef _CACHE_ALIGN_SIZE
  84. #if ((ARMCACHE == ARMCACHE_SA110)  || (ARMCACHE == ARMCACHE_SA1100) || 
  85.      (ARMCACHE == ARMCACHE_SA1500) || (ARMCACHE == ARMCACHE_920T) || 
  86.      (ARMCACHE == ARMCACHE_946E)   || (ARMCACHE == ARMCACHE_XSCALE) )
  87. #define _CACHE_ALIGN_SIZE 32
  88. #else
  89. #define _CACHE_ALIGN_SIZE 16
  90. #endif
  91. #if (CPU == ARMARCH3)
  92. #define ARM_HAS_HALFWORD_INSTRUCTIONS FALSE
  93. #else
  94. #define ARM_HAS_HALFWORD_INSTRUCTIONS TRUE
  95. #endif
  96. #if defined(ARMMMU) && 
  97.  ((ARMMMU == ARMMMU_940T) || (ARMMMU == ARMMMU_740T) || (ARMMMU == ARMMMU_946E))
  98. #define ARM_HAS_MPU TRUE
  99. #else
  100. #define ARM_HAS_MPU FALSE
  101. #endif
  102. #if defined(ARMMMU) && (ARMMMU == ARMMMU_NONE)
  103. #define ARM_HAS_NO_MMU TRUE
  104. #else
  105. #define ARM_HAS_NO_MMU FALSE
  106. #endif
  107. #if (CPU == ARMARCH4_T) || (CPU == ARMARCH5_T)
  108. #define ARM_THUMB TRUE
  109. #else
  110. #define ARM_THUMB FALSE
  111. #endif
  112. #ifdef _ASMLANGUAGE
  113. #if FALSE 
  114. /* Build for old coff compiler */
  115. #define FUNC(a) _##a
  116. #define VAR(name) _##name
  117. #define FUNC_LABEL(func)      FUNC(func)##:
  118. #define VAR_LABEL(name)               VAR(name)##:
  119. #if ARM_THUMB
  120. #define _ARM_FUNCTION_CALLED_FROM_C(a) 
  121. .code 16 ;
  122. .balign 4 ;
  123. .thumb_func ;
  124. _##a: ;
  125. BX pc ;
  126. NOP ;
  127. .code 32 ;
  128. A_##a:
  129. #else
  130. #define _ARM_FUNCTION_CALLED_FROM_C(a) 
  131. .code 32 ;
  132. .balign 4 ;
  133. _##a:
  134. #endif
  135. #define _ARM_FUNCTION(a)
  136. .code 32 ;
  137. .balign 4 ;
  138. _##a:
  139. #if ARM_THUMB
  140. #define _THUMB_FUNCTION(a)
  141. .code 16 ;
  142. .balign 2 ;
  143. .thumb_func ;
  144. _##a:
  145. #endif
  146. #else
  147. /* Build for Gnu elf or Diab compiler */
  148. /* useful, assembly-language macros */
  149. #define FUNC(a) a
  150. #define VAR(name) name
  151. #define FUNC_LABEL(func)      FUNC(func)##:
  152. #define VAR_LABEL(name)               VAR(name)##:
  153. #if ARM_THUMB 
  154. #define _ARM_FUNCTION_CALLED_FROM_C(a) 
  155. .code 16 ;
  156. .balign 4 ;
  157. .thumb_func ;
  158. a: ;
  159. BX pc ;
  160. NOP ;
  161. .code 32 ;
  162. A##a:
  163. #else
  164. #define _ARM_FUNCTION_CALLED_FROM_C(a) 
  165. .code 32 ;
  166. .balign 4 ;
  167. a:
  168. #endif
  169. #define _ARM_FUNCTION(a)
  170. .code 32 ;
  171. .balign 4 ;
  172. a:
  173. #if ARM_THUMB
  174. #define _THUMB_FUNCTION(a)
  175. .code 16 ;
  176. .balign 2 ;
  177. .thumb_func ;
  178. a:
  179. #endif
  180. #endif  /* GNU elf or DIAB*/ 
  181. /** I80310 (coyanosa) specific helper macros **/
  182. #if ((CPU==XSCALE) || (CPU==ARMSA110))
  183. /*
  184.  * The following macro should be used when software needs to be assured that a
  185.  * CP15 update has taken effect. It may only used while in a privileged mode,
  186.  * because it accesses CP15. Ref. Coyanosa EAS 2.3.4 Additions to CP15
  187.  * functionality
  188.  */
  189. #define CPWAIT(a) 
  190.     mrc         p15, 0, a, c2, c0, 0  /* arbitrary read of CP15 */ ;
  191.     mov         a, a                  /* wait for it */ ;
  192.     sub         pc, pc, IMMED4            /* branch to next instruction */ ;
  193. #define IMMED4  #4    
  194. /*
  195.  * at this point, any previous CP15 writes are guaranteed
  196.  * to have taken effect
  197.  */
  198.  
  199. /*
  200.  * The following macro should be used when software needs to be assure that
  201.  * BCU has finish all outstanding operations.
  202.  */
  203.  
  204. /*
  205.  * CAUTION: This macro should be used only from the cacheable region, or it may
  206.  * keep the BCU eternally busy fetching the code.
  207.  */
  208. #define BCUWAIT(a) 
  209.     mrc p13, 0, a, c0, c1, 0; /* Read BCUCTL,updates conditon code */ 
  210.     submi       pc, pc, IMMED12 ;          /* If BCU busy (bit 31 set) try again */
  211. #define IMMED12  #12    
  212.  
  213. #endif /* if CPU=XSCALE */
  214. #endif /* _ASMLANGUAGE */
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218. #endif /* __INCarmh */