cache.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <config.h>
  24. .text
  25. .global flush_dcache
  26. flush_dcache:
  27. add r5, r5, r4
  28. movhi r8, %hi(CONFIG_SYS_DCACHELINE_SIZE)
  29. ori r8, r8, %lo(CONFIG_SYS_DCACHELINE_SIZE)
  30. 0: flushd 0(r4)
  31. add r4, r4, r8
  32. bltu r4, r5, 0b
  33. ret
  34. .global flush_icache
  35. flush_icache:
  36. add r5, r5, r4
  37. movhi r8, %hi(CONFIG_SYS_ICACHELINE_SIZE)
  38. ori r8, r8, %lo(CONFIG_SYS_ICACHELINE_SIZE)
  39. 1: flushi r4
  40. add r4, r4, r8
  41. bltu r4, r5, 1b
  42. ret
  43. .global flush_dcache_range
  44. flush_dcache_range:
  45. movhi r8, %hi(CONFIG_SYS_DCACHELINE_SIZE)
  46. ori r8, r8, %lo(CONFIG_SYS_DCACHELINE_SIZE)
  47. 0: flushd 0(r4)
  48. add r4, r4, r8
  49. bltu r4, r5, 0b
  50. ret
  51. .global flush_cache
  52. flush_cache:
  53. add r5, r5, r4
  54. mov r9, r4
  55. mov r10, r5
  56. movhi r8, %hi(CONFIG_SYS_DCACHELINE_SIZE)
  57. ori r8, r8, %lo(CONFIG_SYS_DCACHELINE_SIZE)
  58. 0: flushd 0(r4)
  59. add r4, r4, r8
  60. bltu r4, r5, 0b
  61. mov r4, r9
  62. mov r5, r10
  63. movhi r8, %hi(CONFIG_SYS_ICACHELINE_SIZE)
  64. ori r8, r8, %lo(CONFIG_SYS_ICACHELINE_SIZE)
  65. 1: flushi r4
  66. add r4, r4, r8
  67. bltu r4, r5, 1b
  68. sync
  69. flushp
  70. ret