cache-dbg-flush-by-tag.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* MN10300 CPU cache invalidation routines, using direct tag flushing
  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. #
  24. # Flush the entire data cache back to RAM and invalidate the icache
  25. #
  26. ###############################################################################
  27. ALIGN
  28. .globl debugger_local_cache_flushinv
  29. .type debugger_local_cache_flushinv,@function
  30. debugger_local_cache_flushinv:
  31. #
  32. # firstly flush the dcache
  33. #
  34. movhu (CHCTR),d0
  35. btst CHCTR_DCEN|CHCTR_ICEN,d0
  36. beq debugger_local_cache_flushinv_end
  37. btst CHCTR_DCEN,d0
  38. beq debugger_local_cache_flushinv_no_dcache
  39. # read the addresses tagged in the cache's tag RAM and attempt to flush
  40. # those addresses specifically
  41. # - we rely on the hardware to filter out invalid tag entry addresses
  42. mov DCACHE_TAG(0,0),a0 # dcache tag RAM access address
  43. mov DCACHE_PURGE(0,0),a1 # dcache purge request address
  44. mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,e0 # total number of entries
  45. mn10300_local_dcache_flush_loop:
  46. mov (a0),d0
  47. and L1_CACHE_TAG_MASK,d0
  48. or L1_CACHE_TAG_VALID,d0 # retain valid entries in the
  49. # cache
  50. mov d0,(a1) # conditional purge
  51. add L1_CACHE_BYTES,a0
  52. add L1_CACHE_BYTES,a1
  53. add -1,e0
  54. bne mn10300_local_dcache_flush_loop
  55. debugger_local_cache_flushinv_no_dcache:
  56. #
  57. # secondly, invalidate the icache if it is enabled
  58. #
  59. mov CHCTR,a0
  60. movhu (a0),d0
  61. btst CHCTR_ICEN,d0
  62. beq debugger_local_cache_flushinv_end
  63. invalidate_icache 1
  64. debugger_local_cache_flushinv_end:
  65. ret [],0
  66. .size debugger_local_cache_flushinv,.-debugger_local_cache_flushinv
  67. ###############################################################################
  68. #
  69. # void debugger_local_cache_flushinv_one(u8 *addr)
  70. #
  71. # Invalidate one particular cacheline if it's in the icache
  72. #
  73. ###############################################################################
  74. ALIGN
  75. .globl debugger_local_cache_flushinv_one
  76. .type debugger_local_cache_flushinv_one,@function
  77. debugger_local_cache_flushinv_one:
  78. movhu (CHCTR),d1
  79. btst CHCTR_DCEN|CHCTR_ICEN,d1
  80. beq debugger_local_cache_flushinv_one_end
  81. btst CHCTR_DCEN,d1
  82. beq debugger_local_cache_flushinv_one_icache
  83. # round cacheline addr down
  84. and L1_CACHE_TAG_MASK,d0
  85. mov d0,a1
  86. # determine the dcache purge control reg address
  87. mov DCACHE_PURGE(0,0),a0
  88. and L1_CACHE_TAG_ENTRY,d0
  89. add d0,a0
  90. # retain valid entries in the cache
  91. or L1_CACHE_TAG_VALID,a1
  92. # conditionally purge this line in all ways
  93. mov a1,(L1_CACHE_WAYDISP*0,a0)
  94. # now go and do the icache
  95. bra debugger_local_cache_flushinv_one_icache
  96. debugger_local_cache_flushinv_one_end:
  97. ret [],0
  98. .size debugger_local_cache_flushinv_one,.-debugger_local_cache_flushinv_one