cache-dbg-inv-by-tag.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. .globl debugger_local_cache_flushinv_one_icache
  21. ###############################################################################
  22. #
  23. # void debugger_local_cache_flushinv_one(u8 *addr)
  24. #
  25. # Invalidate one particular cacheline if it's in the icache
  26. #
  27. ###############################################################################
  28. ALIGN
  29. .globl debugger_local_cache_flushinv_one_icache
  30. .type debugger_local_cache_flushinv_one_icache,@function
  31. debugger_local_cache_flushinv_one_icache:
  32. movm [d3,a2],(sp)
  33. mov CHCTR,a2
  34. movhu (a2),d0
  35. btst CHCTR_ICEN,d0
  36. beq debugger_local_cache_flushinv_one_icache_end
  37. mov d0,a1
  38. and L1_CACHE_TAG_MASK,a1
  39. # read the tags from the tag RAM, and if they indicate a matching valid
  40. # cache line then we invalidate that line
  41. mov ICACHE_TAG(0,0),a0
  42. mov a1,d0
  43. and L1_CACHE_TAG_ENTRY,d0
  44. add d0,a0 # starting icache tag RAM
  45. # access address
  46. and ~(L1_CACHE_DISPARITY-1),a1 # determine comparator base
  47. or L1_CACHE_TAG_VALID,a1
  48. mov L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_VALID,d1
  49. LOCAL_CLI_SAVE(d3)
  50. # disable the icache
  51. movhu (a2),d0
  52. and ~CHCTR_ICEN,d0
  53. movhu d0,(a2)
  54. # and wait for it to calm down
  55. setlb
  56. movhu (a2),d0
  57. btst CHCTR_ICBUSY,d0
  58. lne
  59. # check all the way tags for this cache entry
  60. mov (a0),d0 # read the tag in the way 0 slot
  61. xor a1,d0
  62. and d1,d0
  63. beq debugger_local_icache_kill # jump if matched
  64. add L1_CACHE_WAYDISP,a0
  65. mov (a0),d0 # read the tag in the way 1 slot
  66. xor a1,d0
  67. and d1,d0
  68. beq debugger_local_icache_kill # jump if matched
  69. add L1_CACHE_WAYDISP,a0
  70. mov (a0),d0 # read the tag in the way 2 slot
  71. xor a1,d0
  72. and d1,d0
  73. beq debugger_local_icache_kill # jump if matched
  74. add L1_CACHE_WAYDISP,a0
  75. mov (a0),d0 # read the tag in the way 3 slot
  76. xor a1,d0
  77. and d1,d0
  78. bne debugger_local_icache_finish # jump if not matched
  79. debugger_local_icache_kill:
  80. mov d0,(a0) # kill the tag (D0 is 0 at this point)
  81. debugger_local_icache_finish:
  82. # wait for the cache to finish what it's doing
  83. setlb
  84. movhu (a2),d0
  85. btst CHCTR_ICBUSY,d0
  86. lne
  87. # and reenable it
  88. or CHCTR_ICEN,d0
  89. movhu d0,(a2)
  90. movhu (a2),d0
  91. # re-enable interrupts
  92. LOCAL_IRQ_RESTORE(d3)
  93. debugger_local_cache_flushinv_one_icache_end:
  94. ret [d3,a2],8
  95. .size debugger_local_cache_flushinv_one_icache,.-debugger_local_cache_flushinv_one_icache
  96. #ifdef CONFIG_MN10300_DEBUGGER_CACHE_INV_BY_TAG
  97. .globl debugger_local_cache_flushinv_one
  98. .type debugger_local_cache_flushinv_one,@function
  99. debugger_local_cache_flushinv_one = debugger_local_cache_flushinv_one_icache
  100. #endif