cacheflush.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * vDSO provided cache flush routines
  3. *
  4. * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
  5. * IBM Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #include <asm/processor.h>
  13. #include <asm/ppc_asm.h>
  14. #include <asm/vdso.h>
  15. #include <asm/asm-offsets.h>
  16. .text
  17. /*
  18. * Default "generic" version of __kernel_sync_dicache.
  19. *
  20. * void __kernel_sync_dicache(unsigned long start, unsigned long end)
  21. *
  22. * Flushes the data cache & invalidate the instruction cache for the
  23. * provided range [start, end[
  24. */
  25. V_FUNCTION_BEGIN(__kernel_sync_dicache)
  26. .cfi_startproc
  27. mflr r12
  28. .cfi_register lr,r12
  29. mr r11,r3
  30. bl V_LOCAL_FUNC(__get_datapage)
  31. mtlr r12
  32. mr r10,r3
  33. lwz r7,CFG_DCACHE_BLOCKSZ(r10)
  34. addi r5,r7,-1
  35. andc r6,r11,r5 /* round low to line bdy */
  36. subf r8,r6,r4 /* compute length */
  37. add r8,r8,r5 /* ensure we get enough */
  38. lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
  39. srw. r8,r8,r9 /* compute line count */
  40. crclr cr0*4+so
  41. beqlr /* nothing to do? */
  42. mtctr r8
  43. 1: dcbst 0,r6
  44. add r6,r6,r7
  45. bdnz 1b
  46. sync
  47. /* Now invalidate the instruction cache */
  48. lwz r7,CFG_ICACHE_BLOCKSZ(r10)
  49. addi r5,r7,-1
  50. andc r6,r11,r5 /* round low to line bdy */
  51. subf r8,r6,r4 /* compute length */
  52. add r8,r8,r5
  53. lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
  54. srw. r8,r8,r9 /* compute line count */
  55. crclr cr0*4+so
  56. beqlr /* nothing to do? */
  57. mtctr r8
  58. 2: icbi 0,r6
  59. add r6,r6,r7
  60. bdnz 2b
  61. isync
  62. li r3,0
  63. blr
  64. .cfi_endproc
  65. V_FUNCTION_END(__kernel_sync_dicache)
  66. /*
  67. * POWER5 version of __kernel_sync_dicache
  68. */
  69. V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
  70. .cfi_startproc
  71. crclr cr0*4+so
  72. sync
  73. isync
  74. li r3,0
  75. blr
  76. .cfi_endproc
  77. V_FUNCTION_END(__kernel_sync_dicache_p5)