cacheasm.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * include/asm-xtensa/cacheasm.h
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2006 Tensilica Inc.
  9. */
  10. #include <asm/cache.h>
  11. #include <asm/asmmacro.h>
  12. #include <linux/stringify.h>
  13. /*
  14. * Define cache functions as macros here so that they can be used
  15. * by the kernel and boot loader. We should consider moving them to a
  16. * library that can be linked by both.
  17. *
  18. * Locking
  19. *
  20. * ___unlock_dcache_all
  21. * ___unlock_icache_all
  22. *
  23. * Flush and invaldating
  24. *
  25. * ___flush_invalidate_dcache_{all|range|page}
  26. * ___flush_dcache_{all|range|page}
  27. * ___invalidate_dcache_{all|range|page}
  28. * ___invalidate_icache_{all|range|page}
  29. *
  30. */
  31. .macro __loop_cache_all ar at insn size line_width
  32. movi \ar, 0
  33. __loopi \ar, \at, \size, (4 << (\line_width))
  34. \insn \ar, 0 << (\line_width)
  35. \insn \ar, 1 << (\line_width)
  36. \insn \ar, 2 << (\line_width)
  37. \insn \ar, 3 << (\line_width)
  38. __endla \ar, \at, 4 << (\line_width)
  39. .endm
  40. .macro __loop_cache_range ar as at insn line_width
  41. extui \at, \ar, 0, \line_width
  42. add \as, \as, \at
  43. __loops \ar, \as, \at, \line_width
  44. \insn \ar, 0
  45. __endla \ar, \at, (1 << (\line_width))
  46. .endm
  47. .macro __loop_cache_page ar at insn line_width
  48. __loopi \ar, \at, PAGE_SIZE, 4 << (\line_width)
  49. \insn \ar, 0 << (\line_width)
  50. \insn \ar, 1 << (\line_width)
  51. \insn \ar, 2 << (\line_width)
  52. \insn \ar, 3 << (\line_width)
  53. __endla \ar, \at, 4 << (\line_width)
  54. .endm
  55. .macro ___unlock_dcache_all ar at
  56. #if XCHAL_DCACHE_LINE_LOCKABLE && XCHAL_DCACHE_SIZE
  57. __loop_cache_all \ar \at diu XCHAL_DCACHE_SIZE XCHAL_DCACHE_LINEWIDTH
  58. #endif
  59. .endm
  60. .macro ___unlock_icache_all ar at
  61. #if XCHAL_ICACHE_LINE_LOCKABLE && XCHAL_ICACHE_SIZE
  62. __loop_cache_all \ar \at iiu XCHAL_ICACHE_SIZE XCHAL_ICACHE_LINEWIDTH
  63. #endif
  64. .endm
  65. .macro ___flush_invalidate_dcache_all ar at
  66. #if XCHAL_DCACHE_SIZE
  67. __loop_cache_all \ar \at diwbi XCHAL_DCACHE_SIZE XCHAL_DCACHE_LINEWIDTH
  68. #endif
  69. .endm
  70. .macro ___flush_dcache_all ar at
  71. #if XCHAL_DCACHE_SIZE
  72. __loop_cache_all \ar \at diwb XCHAL_DCACHE_SIZE XCHAL_DCACHE_LINEWIDTH
  73. #endif
  74. .endm
  75. .macro ___invalidate_dcache_all ar at
  76. #if XCHAL_DCACHE_SIZE
  77. __loop_cache_all \ar \at dii __stringify(DCACHE_WAY_SIZE) \
  78. XCHAL_DCACHE_LINEWIDTH
  79. #endif
  80. .endm
  81. .macro ___invalidate_icache_all ar at
  82. #if XCHAL_ICACHE_SIZE
  83. __loop_cache_all \ar \at iii __stringify(ICACHE_WAY_SIZE) \
  84. XCHAL_ICACHE_LINEWIDTH
  85. #endif
  86. .endm
  87. .macro ___flush_invalidate_dcache_range ar as at
  88. #if XCHAL_DCACHE_SIZE
  89. __loop_cache_range \ar \as \at dhwbi XCHAL_DCACHE_LINEWIDTH
  90. #endif
  91. .endm
  92. .macro ___flush_dcache_range ar as at
  93. #if XCHAL_DCACHE_SIZE
  94. __loop_cache_range \ar \as \at dhwb XCHAL_DCACHE_LINEWIDTH
  95. #endif
  96. .endm
  97. .macro ___invalidate_dcache_range ar as at
  98. #if XCHAL_DCACHE_SIZE
  99. __loop_cache_range \ar \as \at dhi XCHAL_DCACHE_LINEWIDTH
  100. #endif
  101. .endm
  102. .macro ___invalidate_icache_range ar as at
  103. #if XCHAL_ICACHE_SIZE
  104. __loop_cache_range \ar \as \at ihi XCHAL_ICACHE_LINEWIDTH
  105. #endif
  106. .endm
  107. .macro ___flush_invalidate_dcache_page ar as
  108. #if XCHAL_DCACHE_SIZE
  109. __loop_cache_page \ar \as dhwbi XCHAL_DCACHE_LINEWIDTH
  110. #endif
  111. .endm
  112. .macro ___flush_dcache_page ar as
  113. #if XCHAL_DCACHE_SIZE
  114. __loop_cache_page \ar \as dhwb XCHAL_DCACHE_LINEWIDTH
  115. #endif
  116. .endm
  117. .macro ___invalidate_dcache_page ar as
  118. #if XCHAL_DCACHE_SIZE
  119. __loop_cache_page \ar \as dhi XCHAL_DCACHE_LINEWIDTH
  120. #endif
  121. .endm
  122. .macro ___invalidate_icache_page ar as
  123. #if XCHAL_ICACHE_SIZE
  124. __loop_cache_page \ar \as ihi XCHAL_ICACHE_LINEWIDTH
  125. #endif
  126. .endm