gdb-cache.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ###############################################################################
  2. #
  3. # MN10300 Low-level cache purging routines for gdbstub
  4. #
  5. # Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  6. # Written by David Howells (dhowells@redhat.com)
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public Licence
  10. # as published by the Free Software Foundation; either version
  11. # 2 of the Licence, or (at your option) any later version.
  12. #
  13. ###############################################################################
  14. #include <linux/sys.h>
  15. #include <linux/linkage.h>
  16. #include <asm/smp.h>
  17. #include <asm/cache.h>
  18. #include <asm/cpu-regs.h>
  19. #include <asm/exceptions.h>
  20. #include <asm/frame.inc>
  21. #include <asm/serial-regs.h>
  22. .text
  23. ###############################################################################
  24. #
  25. # GDB stub cache purge
  26. #
  27. ###############################################################################
  28. .type gdbstub_purge_cache,@function
  29. ENTRY(gdbstub_purge_cache)
  30. #######################################################################
  31. # read the addresses tagged in the cache's tag RAM and attempt to flush
  32. # those addresses specifically
  33. # - we rely on the hardware to filter out invalid tag entry addresses
  34. mov DCACHE_TAG(0,0),a0 # dcache tag RAM access address
  35. mov DCACHE_PURGE(0,0),a1 # dcache purge request address
  36. mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,d1 # total number of entries
  37. mn10300_dcache_flush_loop:
  38. mov (a0),d0
  39. and L1_CACHE_TAG_ADDRESS|L1_CACHE_TAG_ENTRY,d0
  40. or L1_CACHE_TAG_VALID,d0 # retain valid entries in the
  41. # cache
  42. mov d0,(a1) # conditional purge
  43. mn10300_dcache_flush_skip:
  44. add L1_CACHE_BYTES,a0
  45. add L1_CACHE_BYTES,a1
  46. add -1,d1
  47. bne mn10300_dcache_flush_loop
  48. ;; # unconditionally flush and invalidate the dcache
  49. ;; mov DCACHE_PURGE(0,0),a1 # dcache purge request address
  50. ;; mov L1_CACHE_NWAYS*L1_CACHE_NENTRIES,d1 # total number of
  51. ;; # entries
  52. ;;
  53. ;; gdbstub_purge_cache__dcache_loop:
  54. ;; mov (a1),d0 # unconditional purge
  55. ;;
  56. ;; add L1_CACHE_BYTES,a1
  57. ;; add -1,d1
  58. ;; bne gdbstub_purge_cache__dcache_loop
  59. #######################################################################
  60. # now invalidate the icache
  61. mov CHCTR,a0
  62. movhu (a0),a1
  63. mov epsw,d1
  64. and ~EPSW_IE,epsw
  65. nop
  66. nop
  67. # disable the icache
  68. and ~CHCTR_ICEN,d0
  69. movhu d0,(a0)
  70. # and wait for it to calm down
  71. setlb
  72. movhu (a0),d0
  73. btst CHCTR_ICBUSY,d0
  74. lne
  75. # invalidate
  76. or CHCTR_ICINV,d0
  77. movhu d0,(a0)
  78. # wait for the cache to finish
  79. mov CHCTR,a0
  80. setlb
  81. movhu (a0),d0
  82. btst CHCTR_ICBUSY,d0
  83. lne
  84. # and reenable it
  85. movhu a1,(a0)
  86. movhu (a0),d0 # read back to flush
  87. # (SIGILLs all over without this)
  88. mov d1,epsw
  89. ret [],0
  90. .size gdbstub_purge_cache,.-gdbstub_purge_cache