system.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __ASM_ARM_SYSTEM_H
  2. #define __ASM_ARM_SYSTEM_H
  3. #ifdef __KERNEL__
  4. #define CPU_ARCH_UNKNOWN 0
  5. #define CPU_ARCH_ARMv3 1
  6. #define CPU_ARCH_ARMv4 2
  7. #define CPU_ARCH_ARMv4T 3
  8. #define CPU_ARCH_ARMv5 4
  9. #define CPU_ARCH_ARMv5T 5
  10. #define CPU_ARCH_ARMv5TE 6
  11. #define CPU_ARCH_ARMv5TEJ 7
  12. #define CPU_ARCH_ARMv6 8
  13. #define CPU_ARCH_ARMv7 9
  14. /*
  15. * CR1 bits (CP#15 CR1)
  16. */
  17. #define CR_M (1 << 0) /* MMU enable */
  18. #define CR_A (1 << 1) /* Alignment abort enable */
  19. #define CR_C (1 << 2) /* Dcache enable */
  20. #define CR_W (1 << 3) /* Write buffer enable */
  21. #define CR_P (1 << 4) /* 32-bit exception handler */
  22. #define CR_D (1 << 5) /* 32-bit data address range */
  23. #define CR_L (1 << 6) /* Implementation defined */
  24. #define CR_B (1 << 7) /* Big endian */
  25. #define CR_S (1 << 8) /* System MMU protection */
  26. #define CR_R (1 << 9) /* ROM MMU protection */
  27. #define CR_F (1 << 10) /* Implementation defined */
  28. #define CR_Z (1 << 11) /* Implementation defined */
  29. #define CR_I (1 << 12) /* Icache enable */
  30. #define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */
  31. #define CR_RR (1 << 14) /* Round Robin cache replacement */
  32. #define CR_L4 (1 << 15) /* LDR pc can set T bit */
  33. #define CR_DT (1 << 16)
  34. #define CR_IT (1 << 18)
  35. #define CR_ST (1 << 19)
  36. #define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */
  37. #define CR_U (1 << 22) /* Unaligned access operation */
  38. #define CR_XP (1 << 23) /* Extended page tables */
  39. #define CR_VE (1 << 24) /* Vectored interrupts */
  40. #define CR_EE (1 << 25) /* Exception (Big) Endian */
  41. #define CR_TRE (1 << 28) /* TEX remap enable */
  42. #define CR_AFE (1 << 29) /* Access flag enable */
  43. #define CR_TE (1 << 30) /* Thumb exception enable */
  44. /*
  45. * This is used to ensure the compiler did actually allocate the register we
  46. * asked it for some inline assembly sequences. Apparently we can't trust
  47. * the compiler from one version to another so a bit of paranoia won't hurt.
  48. * This string is meant to be concatenated with the inline asm string and
  49. * will cause compilation to stop on mismatch.
  50. * (for details, see gcc PR 15089)
  51. */
  52. #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
  53. #ifndef __ASSEMBLY__
  54. #define isb() __asm__ __volatile__ ("" : : : "memory")
  55. #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
  56. #ifdef __ARM_ARCH_7A__
  57. #define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
  58. #else
  59. #define wfi()
  60. #endif
  61. static inline unsigned int get_cr(void)
  62. {
  63. unsigned int val;
  64. asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc");
  65. return val;
  66. }
  67. static inline void set_cr(unsigned int val)
  68. {
  69. asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR"
  70. : : "r" (val) : "cc");
  71. isb();
  72. }
  73. /* options available for data cache on each page */
  74. enum dcache_option {
  75. DCACHE_OFF = 0x12,
  76. DCACHE_WRITETHROUGH = 0x1a,
  77. DCACHE_WRITEBACK = 0x1e,
  78. };
  79. /* Size of an MMU section */
  80. enum {
  81. MMU_SECTION_SHIFT = 20,
  82. MMU_SECTION_SIZE = 1 << MMU_SECTION_SHIFT,
  83. };
  84. /**
  85. * Change the cache settings for a region.
  86. *
  87. * \param start start address of memory region to change
  88. * \param size size of memory region to change
  89. * \param option dcache option to select
  90. */
  91. void mmu_set_region_dcache_behaviour(u32 start, int size,
  92. enum dcache_option option);
  93. /**
  94. * Register an update to the page tables, and flush the TLB
  95. *
  96. * \param start start address of update in page table
  97. * \param stop stop address of update in page table
  98. */
  99. void mmu_page_table_flush(unsigned long start, unsigned long stop);
  100. #endif /* __ASSEMBLY__ */
  101. #define arch_align_stack(x) (x)
  102. #endif /* __KERNEL__ */
  103. #endif