proc-v7-2level.S 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * arch/arm/mm/proc-v7-2level.S
  3. *
  4. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #define TTB_S (1 << 1)
  11. #define TTB_RGN_NC (0 << 3)
  12. #define TTB_RGN_OC_WBWA (1 << 3)
  13. #define TTB_RGN_OC_WT (2 << 3)
  14. #define TTB_RGN_OC_WB (3 << 3)
  15. #define TTB_NOS (1 << 5)
  16. #define TTB_IRGN_NC ((0 << 0) | (0 << 6))
  17. #define TTB_IRGN_WBWA ((0 << 0) | (1 << 6))
  18. #define TTB_IRGN_WT ((1 << 0) | (0 << 6))
  19. #define TTB_IRGN_WB ((1 << 0) | (1 << 6))
  20. /* PTWs cacheable, inner WB not shareable, outer WB not shareable */
  21. #define TTB_FLAGS_UP TTB_IRGN_WB|TTB_RGN_OC_WB
  22. #define PMD_FLAGS_UP PMD_SECT_WB
  23. /* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */
  24. #define TTB_FLAGS_SMP TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA
  25. #define PMD_FLAGS_SMP PMD_SECT_WBWA|PMD_SECT_S
  26. /*
  27. * cpu_v7_switch_mm(pgd_phys, tsk)
  28. *
  29. * Set the translation table base pointer to be pgd_phys
  30. *
  31. * - pgd_phys - physical address of new TTB
  32. *
  33. * It is assumed that:
  34. * - we are not using split page tables
  35. *
  36. * Note that we always need to flush BTAC/BTB if IBE is set
  37. * even on Cortex-A8 revisions not affected by 430973.
  38. * If IBE is not set, the flush BTAC/BTB won't do anything.
  39. */
  40. ENTRY(cpu_ca8_switch_mm)
  41. #ifdef CONFIG_MMU
  42. mov r2, #0
  43. mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
  44. #endif
  45. ENTRY(cpu_v7_switch_mm)
  46. #ifdef CONFIG_MMU
  47. mmid r1, r1 @ get mm->context.id
  48. ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP)
  49. ALT_UP(orr r0, r0, #TTB_FLAGS_UP)
  50. #ifdef CONFIG_PID_IN_CONTEXTIDR
  51. mrc p15, 0, r2, c13, c0, 1 @ read current context ID
  52. lsr r2, r2, #8 @ extract the PID
  53. bfi r1, r2, #8, #24 @ insert into new context ID
  54. #endif
  55. #ifdef CONFIG_ARM_ERRATA_754322
  56. dsb
  57. #endif
  58. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  59. isb
  60. mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  61. isb
  62. #endif
  63. bx lr
  64. ENDPROC(cpu_v7_switch_mm)
  65. ENDPROC(cpu_ca8_switch_mm)
  66. /*
  67. * cpu_v7_set_pte_ext(ptep, pte)
  68. *
  69. * Set a level 2 translation table entry.
  70. *
  71. * - ptep - pointer to level 2 translation table entry
  72. * (hardware version is stored at +2048 bytes)
  73. * - pte - PTE value to store
  74. * - ext - value for extended PTE bits
  75. */
  76. ENTRY(cpu_v7_set_pte_ext)
  77. #ifdef CONFIG_MMU
  78. str r1, [r0] @ linux version
  79. bic r3, r1, #0x000003f0
  80. bic r3, r3, #PTE_TYPE_MASK
  81. orr r3, r3, r2
  82. orr r3, r3, #PTE_EXT_AP0 | 2
  83. tst r1, #1 << 4
  84. orrne r3, r3, #PTE_EXT_TEX(1)
  85. eor r1, r1, #L_PTE_DIRTY
  86. tst r1, #L_PTE_RDONLY | L_PTE_DIRTY
  87. orrne r3, r3, #PTE_EXT_APX
  88. tst r1, #L_PTE_USER
  89. orrne r3, r3, #PTE_EXT_AP1
  90. tst r1, #L_PTE_XN
  91. orrne r3, r3, #PTE_EXT_XN
  92. tst r1, #L_PTE_YOUNG
  93. tstne r1, #L_PTE_VALID
  94. eorne r1, r1, #L_PTE_NONE
  95. tstne r1, #L_PTE_NONE
  96. moveq r3, #0
  97. ARM( str r3, [r0, #2048]! )
  98. THUMB( add r0, r0, #2048 )
  99. THUMB( str r3, [r0] )
  100. ALT_SMP(W(nop))
  101. ALT_UP (mcr p15, 0, r0, c7, c10, 1) @ flush_pte
  102. #endif
  103. bx lr
  104. ENDPROC(cpu_v7_set_pte_ext)
  105. /*
  106. * Memory region attributes with SCTLR.TRE=1
  107. *
  108. * n = TEX[0],C,B
  109. * TR = PRRR[2n+1:2n] - memory type
  110. * IR = NMRR[2n+1:2n] - inner cacheable property
  111. * OR = NMRR[2n+17:2n+16] - outer cacheable property
  112. *
  113. * n TR IR OR
  114. * UNCACHED 000 00
  115. * BUFFERABLE 001 10 00 00
  116. * WRITETHROUGH 010 10 10 10
  117. * WRITEBACK 011 10 11 11
  118. * reserved 110
  119. * WRITEALLOC 111 10 01 01
  120. * DEV_SHARED 100 01
  121. * DEV_NONSHARED 100 01
  122. * DEV_WC 001 10
  123. * DEV_CACHED 011 10
  124. *
  125. * Other attributes:
  126. *
  127. * DS0 = PRRR[16] = 0 - device shareable property
  128. * DS1 = PRRR[17] = 1 - device shareable property
  129. * NS0 = PRRR[18] = 0 - normal shareable property
  130. * NS1 = PRRR[19] = 1 - normal shareable property
  131. * NOS = PRRR[24+n] = 1 - not outer shareable
  132. */
  133. .equ PRRR, 0xff0a81a8
  134. .equ NMRR, 0x40e040e0
  135. /*
  136. * Macro for setting up the TTBRx and TTBCR registers.
  137. * - \ttb0 and \ttb1 updated with the corresponding flags.
  138. */
  139. .macro v7_ttb_setup, zero, ttbr0l, ttbr0h, ttbr1, tmp
  140. mcr p15, 0, \zero, c2, c0, 2 @ TTB control register
  141. ALT_SMP(orr \ttbr0l, \ttbr0l, #TTB_FLAGS_SMP)
  142. ALT_UP(orr \ttbr0l, \ttbr0l, #TTB_FLAGS_UP)
  143. ALT_SMP(orr \ttbr1, \ttbr1, #TTB_FLAGS_SMP)
  144. ALT_UP(orr \ttbr1, \ttbr1, #TTB_FLAGS_UP)
  145. mcr p15, 0, \ttbr1, c2, c0, 1 @ load TTB1
  146. .endm
  147. /* AT
  148. * TFR EV X F I D LR S
  149. * .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM
  150. * rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced
  151. * 01 0 110 0011 1100 .111 1101 < we want
  152. */
  153. .align 2
  154. .type v7_crval, #object
  155. v7_crval:
  156. crval clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c