cacheasm.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. #if XCHAL_DCACHE_LINE_LOCKABLE
  56. .macro ___unlock_dcache_all ar at
  57. __loop_cache_all \ar \at diu XCHAL_DCACHE_SIZE XCHAL_DCACHE_LINEWIDTH
  58. .endm
  59. #endif
  60. #if XCHAL_ICACHE_LINE_LOCKABLE
  61. .macro ___unlock_icache_all ar at
  62. __loop_cache_all \ar \at iiu XCHAL_ICACHE_SIZE XCHAL_ICACHE_LINEWIDTH
  63. .endm
  64. #endif
  65. .macro ___flush_invalidate_dcache_all ar at
  66. __loop_cache_all \ar \at diwbi XCHAL_DCACHE_SIZE XCHAL_DCACHE_LINEWIDTH
  67. .endm
  68. .macro ___flush_dcache_all ar at
  69. __loop_cache_all \ar \at diwb XCHAL_DCACHE_SIZE XCHAL_DCACHE_LINEWIDTH
  70. .endm
  71. .macro ___invalidate_dcache_all ar at
  72. __loop_cache_all \ar \at dii __stringify(DCACHE_WAY_SIZE) \
  73. XCHAL_DCACHE_LINEWIDTH
  74. .endm
  75. .macro ___invalidate_icache_all ar at
  76. __loop_cache_all \ar \at iii __stringify(ICACHE_WAY_SIZE) \
  77. XCHAL_ICACHE_LINEWIDTH
  78. .endm
  79. .macro ___flush_invalidate_dcache_range ar as at
  80. __loop_cache_range \ar \as \at dhwbi XCHAL_DCACHE_LINEWIDTH
  81. .endm
  82. .macro ___flush_dcache_range ar as at
  83. __loop_cache_range \ar \as \at dhwb XCHAL_DCACHE_LINEWIDTH
  84. .endm
  85. .macro ___invalidate_dcache_range ar as at
  86. __loop_cache_range \ar \as \at dhi XCHAL_DCACHE_LINEWIDTH
  87. .endm
  88. .macro ___invalidate_icache_range ar as at
  89. __loop_cache_range \ar \as \at ihi XCHAL_ICACHE_LINEWIDTH
  90. .endm
  91. .macro ___flush_invalidate_dcache_page ar as
  92. __loop_cache_page \ar \as dhwbi XCHAL_DCACHE_LINEWIDTH
  93. .endm
  94. .macro ___flush_dcache_page ar as
  95. __loop_cache_page \ar \as dhwb XCHAL_DCACHE_LINEWIDTH
  96. .endm
  97. .macro ___invalidate_dcache_page ar as
  98. __loop_cache_page \ar \as dhi XCHAL_DCACHE_LINEWIDTH
  99. .endm
  100. .macro ___invalidate_icache_page ar as
  101. __loop_cache_page \ar \as ihi XCHAL_ICACHE_LINEWIDTH
  102. .endm