cache.inc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* MN10300 CPU core caching macros -*- asm -*-
  2. *
  3. * Copyright (C) 2007 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. ###############################################################################
  12. #
  13. # Invalidate the instruction cache.
  14. # A0: Should hold CHCTR
  15. # D0: Should have been read from CHCTR
  16. # D1: Will be clobbered
  17. #
  18. # On some cores it is necessary to disable the icache whilst we do this.
  19. #
  20. ###############################################################################
  21. .macro invalidate_icache,disable_irq
  22. #if defined(CONFIG_AM33_2) || defined(CONFIG_AM33_3)
  23. .if \disable_irq
  24. # don't want an interrupt routine seeing a disabled cache
  25. mov epsw,d1
  26. and ~EPSW_IE,epsw
  27. or EPSW_NMID,epsw
  28. nop
  29. nop
  30. .endif
  31. # disable the icache
  32. and ~CHCTR_ICEN,d0
  33. movhu d0,(a0)
  34. # and wait for it to calm down
  35. setlb
  36. movhu (a0),d0
  37. btst CHCTR_ICBUSY,d0
  38. lne
  39. # invalidate
  40. or CHCTR_ICINV,d0
  41. movhu d0,(a0)
  42. # wait for the cache to finish
  43. setlb
  44. movhu (a0),d0
  45. btst CHCTR_ICBUSY,d0
  46. lne
  47. # and reenable it
  48. or CHCTR_ICEN,d0
  49. movhu d0,(a0)
  50. movhu (a0),d0
  51. .if \disable_irq
  52. LOCAL_IRQ_RESTORE(d1)
  53. .endif
  54. #else /* CONFIG_AM33_2 || CONFIG_AM33_3 */
  55. # invalidate
  56. or CHCTR_ICINV,d0
  57. movhu d0,(a0)
  58. movhu (a0),d0
  59. #endif /* CONFIG_AM33_2 || CONFIG_AM33_3 */
  60. .endm
  61. ###############################################################################
  62. #
  63. # Invalidate the data cache.
  64. # A0: Should hold CHCTR
  65. # D0: Should have been read from CHCTR
  66. # D1: Will be clobbered
  67. #
  68. # On some cores it is necessary to disable the dcache whilst we do this.
  69. #
  70. ###############################################################################
  71. .macro invalidate_dcache,disable_irq
  72. #if defined(CONFIG_AM33_2) || defined(CONFIG_AM33_3)
  73. .if \disable_irq
  74. # don't want an interrupt routine seeing a disabled cache
  75. mov epsw,d1
  76. and ~EPSW_IE,epsw
  77. or EPSW_NMID,epsw
  78. nop
  79. nop
  80. .endif
  81. # disable the dcache
  82. and ~CHCTR_DCEN,d0
  83. movhu d0,(a0)
  84. # and wait for it to calm down
  85. setlb
  86. movhu (a0),d0
  87. btst CHCTR_DCBUSY,d0
  88. lne
  89. # invalidate
  90. or CHCTR_DCINV,d0
  91. movhu d0,(a0)
  92. # wait for the cache to finish
  93. setlb
  94. movhu (a0),d0
  95. btst CHCTR_DCBUSY,d0
  96. lne
  97. # and reenable it
  98. or CHCTR_DCEN,d0
  99. movhu d0,(a0)
  100. movhu (a0),d0
  101. .if \disable_irq
  102. LOCAL_IRQ_RESTORE(d1)
  103. .endif
  104. #else /* CONFIG_AM33_2 || CONFIG_AM33_3 */
  105. # invalidate
  106. or CHCTR_DCINV,d0
  107. movhu d0,(a0)
  108. movhu (a0),d0
  109. #endif /* CONFIG_AM33_2 || CONFIG_AM33_3 */
  110. .endm