copypage_power7.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. *
  16. * Copyright (C) IBM Corporation, 2012
  17. *
  18. * Author: Anton Blanchard <anton@au.ibm.com>
  19. */
  20. #include <asm/page.h>
  21. #include <asm/ppc_asm.h>
  22. _GLOBAL(copypage_power7)
  23. /*
  24. * We prefetch both the source and destination using enhanced touch
  25. * instructions. We use a stream ID of 0 for the load side and
  26. * 1 for the store side. Since source and destination are page
  27. * aligned we don't need to clear the bottom 7 bits of either
  28. * address.
  29. */
  30. ori r9,r3,1 /* stream=1 => to */
  31. #ifdef CONFIG_PPC_64K_PAGES
  32. lis r7,0x0E01 /* depth=7
  33. * units/cachelines=512 */
  34. #else
  35. lis r7,0x0E00 /* depth=7 */
  36. ori r7,r7,0x1000 /* units/cachelines=32 */
  37. #endif
  38. ori r10,r7,1 /* stream=1 */
  39. lis r8,0x8000 /* GO=1 */
  40. clrldi r8,r8,32
  41. /* setup read stream 0 */
  42. dcbt 0,r4,0b01000 /* addr from */
  43. dcbt 0,r7,0b01010 /* length and depth from */
  44. /* setup write stream 1 */
  45. dcbtst 0,r9,0b01000 /* addr to */
  46. dcbtst 0,r10,0b01010 /* length and depth to */
  47. eieio
  48. dcbt 0,r8,0b01010 /* all streams GO */
  49. #ifdef CONFIG_ALTIVEC
  50. mflr r0
  51. std r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
  52. std r4,-STACKFRAMESIZE+STK_REG(R30)(r1)
  53. std r0,16(r1)
  54. stdu r1,-STACKFRAMESIZE(r1)
  55. bl enter_vmx_ops
  56. cmpwi r3,0
  57. ld r0,STACKFRAMESIZE+16(r1)
  58. ld r3,STK_REG(R31)(r1)
  59. ld r4,STK_REG(R30)(r1)
  60. mtlr r0
  61. li r0,(PAGE_SIZE/128)
  62. mtctr r0
  63. beq .Lnonvmx_copy
  64. addi r1,r1,STACKFRAMESIZE
  65. li r6,16
  66. li r7,32
  67. li r8,48
  68. li r9,64
  69. li r10,80
  70. li r11,96
  71. li r12,112
  72. .align 5
  73. 1: lvx v7,0,r4
  74. lvx v6,r4,r6
  75. lvx v5,r4,r7
  76. lvx v4,r4,r8
  77. lvx v3,r4,r9
  78. lvx v2,r4,r10
  79. lvx v1,r4,r11
  80. lvx v0,r4,r12
  81. addi r4,r4,128
  82. stvx v7,0,r3
  83. stvx v6,r3,r6
  84. stvx v5,r3,r7
  85. stvx v4,r3,r8
  86. stvx v3,r3,r9
  87. stvx v2,r3,r10
  88. stvx v1,r3,r11
  89. stvx v0,r3,r12
  90. addi r3,r3,128
  91. bdnz 1b
  92. b exit_vmx_ops /* tail call optimise */
  93. #else
  94. li r0,(PAGE_SIZE/128)
  95. mtctr r0
  96. stdu r1,-STACKFRAMESIZE(r1)
  97. #endif
  98. .Lnonvmx_copy:
  99. std r14,STK_REG(R14)(r1)
  100. std r15,STK_REG(R15)(r1)
  101. std r16,STK_REG(R16)(r1)
  102. std r17,STK_REG(R17)(r1)
  103. std r18,STK_REG(R18)(r1)
  104. std r19,STK_REG(R19)(r1)
  105. std r20,STK_REG(R20)(r1)
  106. 1: ld r0,0(r4)
  107. ld r5,8(r4)
  108. ld r6,16(r4)
  109. ld r7,24(r4)
  110. ld r8,32(r4)
  111. ld r9,40(r4)
  112. ld r10,48(r4)
  113. ld r11,56(r4)
  114. ld r12,64(r4)
  115. ld r14,72(r4)
  116. ld r15,80(r4)
  117. ld r16,88(r4)
  118. ld r17,96(r4)
  119. ld r18,104(r4)
  120. ld r19,112(r4)
  121. ld r20,120(r4)
  122. addi r4,r4,128
  123. std r0,0(r3)
  124. std r5,8(r3)
  125. std r6,16(r3)
  126. std r7,24(r3)
  127. std r8,32(r3)
  128. std r9,40(r3)
  129. std r10,48(r3)
  130. std r11,56(r3)
  131. std r12,64(r3)
  132. std r14,72(r3)
  133. std r15,80(r3)
  134. std r16,88(r3)
  135. std r17,96(r3)
  136. std r18,104(r3)
  137. std r19,112(r3)
  138. std r20,120(r3)
  139. addi r3,r3,128
  140. bdnz 1b
  141. ld r14,STK_REG(R14)(r1)
  142. ld r15,STK_REG(R15)(r1)
  143. ld r16,STK_REG(R16)(r1)
  144. ld r17,STK_REG(R17)(r1)
  145. ld r18,STK_REG(R18)(r1)
  146. ld r19,STK_REG(R19)(r1)
  147. ld r20,STK_REG(R20)(r1)
  148. addi r1,r1,STACKFRAMESIZE
  149. blr