ppccache.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
  3. * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
  4. * Copyright (C) 2000, 2001,2002 Wolfgang Denk <wd@denx.de>
  5. * Copyright Freescale Semiconductor, Inc. 2004, 2006.
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <config.h>
  10. #include <ppc_asm.tmpl>
  11. #include <ppc_defs.h>
  12. #include <asm/cache.h>
  13. /*------------------------------------------------------------------------------- */
  14. /* Function: ppcDcbf */
  15. /* Description: Data Cache block flush */
  16. /* Input: r3 = effective address */
  17. /* Output: none. */
  18. /*------------------------------------------------------------------------------- */
  19. .globl ppcDcbf
  20. ppcDcbf:
  21. dcbf r0,r3
  22. blr
  23. /*------------------------------------------------------------------------------- */
  24. /* Function: ppcDcbi */
  25. /* Description: Data Cache block Invalidate */
  26. /* Input: r3 = effective address */
  27. /* Output: none. */
  28. /*------------------------------------------------------------------------------- */
  29. .globl ppcDcbi
  30. ppcDcbi:
  31. dcbi r0,r3
  32. blr
  33. /*--------------------------------------------------------------------------
  34. * Function: ppcDcbz
  35. * Description: Data Cache block zero.
  36. * Input: r3 = effective address
  37. * Output: none.
  38. *-------------------------------------------------------------------------- */
  39. .globl ppcDcbz
  40. ppcDcbz:
  41. dcbz r0,r3
  42. blr
  43. /*------------------------------------------------------------------------------- */
  44. /* Function: ppcSync */
  45. /* Description: Processor Synchronize */
  46. /* Input: none. */
  47. /* Output: none. */
  48. /*------------------------------------------------------------------------------- */
  49. .globl ppcSync
  50. ppcSync:
  51. sync
  52. blr
  53. /*
  54. * Write any modified data cache blocks out to memory and invalidate them.
  55. * Does not invalidate the corresponding instruction cache blocks.
  56. *
  57. * flush_dcache_range(unsigned long start, unsigned long stop)
  58. */
  59. _GLOBAL(flush_dcache_range)
  60. #if defined(CONFIG_4xx) || defined(CONFIG_MPC86xx)
  61. li r5,L1_CACHE_BYTES-1
  62. andc r3,r3,r5
  63. subf r4,r3,r4
  64. add r4,r4,r5
  65. srwi. r4,r4,L1_CACHE_SHIFT
  66. beqlr
  67. mtctr r4
  68. 1: dcbf 0,r3
  69. addi r3,r3,L1_CACHE_BYTES
  70. bdnz 1b
  71. sync /* wait for dcbst's to get to ram */
  72. #endif
  73. blr
  74. /*
  75. * Like above, but invalidate the D-cache. This is used by the 8xx
  76. * to invalidate the cache so the PPC core doesn't get stale data
  77. * from the CPM (no cache snooping here :-).
  78. *
  79. * invalidate_dcache_range(unsigned long start, unsigned long stop)
  80. */
  81. _GLOBAL(invalidate_dcache_range)
  82. #if defined(CONFIG_4xx) || defined(CONFIG_MPC86xx)
  83. li r5,L1_CACHE_BYTES-1
  84. andc r3,r3,r5
  85. subf r4,r3,r4
  86. add r4,r4,r5
  87. srwi. r4,r4,L1_CACHE_SHIFT
  88. beqlr
  89. mtctr r4
  90. sync
  91. 1: dcbi 0,r3
  92. addi r3,r3,L1_CACHE_BYTES
  93. bdnz 1b
  94. sync /* wait for dcbi's to get to ram */
  95. #endif
  96. blr