cache-dbg-flush-by-reg.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* MN10300 CPU cache invalidation routines, using automatic purge registers
  2. *
  3. * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/sys.h>
  12. #include <linux/linkage.h>
  13. #include <asm/smp.h>
  14. #include <asm/page.h>
  15. #include <asm/cache.h>
  16. #include <asm/irqflags.h>
  17. #include <asm/cacheflush.h>
  18. #include "cache.inc"
  19. .am33_2
  20. ###############################################################################
  21. #
  22. # void debugger_local_cache_flushinv(void)
  23. # Flush the entire data cache back to RAM and invalidate the icache
  24. #
  25. ###############################################################################
  26. ALIGN
  27. .globl debugger_local_cache_flushinv
  28. .type debugger_local_cache_flushinv,@function
  29. debugger_local_cache_flushinv:
  30. #
  31. # firstly flush the dcache
  32. #
  33. movhu (CHCTR),d0
  34. btst CHCTR_DCEN|CHCTR_ICEN,d0
  35. beq debugger_local_cache_flushinv_end
  36. mov DCPGCR,a0
  37. mov epsw,d1
  38. and ~EPSW_IE,epsw
  39. or EPSW_NMID,epsw
  40. nop
  41. btst CHCTR_DCEN,d0
  42. beq debugger_local_cache_flushinv_no_dcache
  43. # wait for busy bit of area purge
  44. setlb
  45. mov (a0),d0
  46. btst DCPGCR_DCPGBSY,d0
  47. lne
  48. # set mask
  49. clr d0
  50. mov d0,(DCPGMR)
  51. # area purge
  52. #
  53. # DCPGCR = DCPGCR_DCP
  54. #
  55. mov DCPGCR_DCP,d0
  56. mov d0,(a0)
  57. # wait for busy bit of area purge
  58. setlb
  59. mov (a0),d0
  60. btst DCPGCR_DCPGBSY,d0
  61. lne
  62. debugger_local_cache_flushinv_no_dcache:
  63. #
  64. # secondly, invalidate the icache if it is enabled
  65. #
  66. mov CHCTR,a0
  67. movhu (a0),d0
  68. btst CHCTR_ICEN,d0
  69. beq debugger_local_cache_flushinv_done
  70. invalidate_icache 0
  71. debugger_local_cache_flushinv_done:
  72. mov d1,epsw
  73. debugger_local_cache_flushinv_end:
  74. ret [],0
  75. .size debugger_local_cache_flushinv,.-debugger_local_cache_flushinv
  76. ###############################################################################
  77. #
  78. # void debugger_local_cache_flushinv_one(u8 *addr)
  79. #
  80. # Invalidate one particular cacheline if it's in the icache
  81. #
  82. ###############################################################################
  83. ALIGN
  84. .globl debugger_local_cache_flushinv_one
  85. .type debugger_local_cache_flushinv_one,@function
  86. debugger_local_cache_flushinv_one:
  87. movhu (CHCTR),d1
  88. btst CHCTR_DCEN|CHCTR_ICEN,d1
  89. beq debugger_local_cache_flushinv_one_end
  90. btst CHCTR_DCEN,d1
  91. beq debugger_local_cache_flushinv_one_no_dcache
  92. # round cacheline addr down
  93. and L1_CACHE_TAG_MASK,d0
  94. mov d0,a1
  95. mov d0,d1
  96. # determine the dcache purge control reg address
  97. mov DCACHE_PURGE(0,0),a0
  98. and L1_CACHE_TAG_ENTRY,d0
  99. add d0,a0
  100. # retain valid entries in the cache
  101. or L1_CACHE_TAG_VALID,d1
  102. # conditionally purge this line in all ways
  103. mov d1,(L1_CACHE_WAYDISP*0,a0)
  104. debugger_local_cache_flushinv_one_no_dcache:
  105. #
  106. # now try to flush the icache
  107. #
  108. mov CHCTR,a0
  109. movhu (a0),d0
  110. btst CHCTR_ICEN,d0
  111. beq debugger_local_cache_flushinv_one_end
  112. LOCAL_CLI_SAVE(d1)
  113. mov ICIVCR,a0
  114. # wait for the invalidator to quiesce
  115. setlb
  116. mov (a0),d0
  117. btst ICIVCR_ICIVBSY,d0
  118. lne
  119. # set the mask
  120. mov L1_CACHE_TAG_MASK,d0
  121. mov d0,(ICIVMR)
  122. # invalidate the cache line at the given address
  123. or ICIVCR_ICI,a1
  124. mov a1,(a0)
  125. # wait for the invalidator to quiesce again
  126. setlb
  127. mov (a0),d0
  128. btst ICIVCR_ICIVBSY,d0
  129. lne
  130. LOCAL_IRQ_RESTORE(d1)
  131. debugger_local_cache_flushinv_one_end:
  132. ret [],0
  133. .size debugger_local_cache_flushinv_one,.-debugger_local_cache_flushinv_one