copypage_power7.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. .machine push
  42. .machine "power4"
  43. /* setup read stream 0 */
  44. dcbt r0,r4,0b01000 /* addr from */
  45. dcbt r0,r7,0b01010 /* length and depth from */
  46. /* setup write stream 1 */
  47. dcbtst r0,r9,0b01000 /* addr to */
  48. dcbtst r0,r10,0b01010 /* length and depth to */
  49. eieio
  50. dcbt r0,r8,0b01010 /* all streams GO */
  51. .machine pop
  52. #ifdef CONFIG_ALTIVEC
  53. mflr r0
  54. std r3,-STACKFRAMESIZE+STK_REG(R31)(r1)
  55. std r4,-STACKFRAMESIZE+STK_REG(R30)(r1)
  56. std r0,16(r1)
  57. stdu r1,-STACKFRAMESIZE(r1)
  58. bl enter_vmx_copy
  59. cmpwi r3,0
  60. ld r0,STACKFRAMESIZE+16(r1)
  61. ld r3,STK_REG(R31)(r1)
  62. ld r4,STK_REG(R30)(r1)
  63. mtlr r0
  64. li r0,(PAGE_SIZE/128)
  65. mtctr r0
  66. beq .Lnonvmx_copy
  67. addi r1,r1,STACKFRAMESIZE
  68. li r6,16
  69. li r7,32
  70. li r8,48
  71. li r9,64
  72. li r10,80
  73. li r11,96
  74. li r12,112
  75. .align 5
  76. 1: lvx v7,r0,r4
  77. lvx v6,r4,r6
  78. lvx v5,r4,r7
  79. lvx v4,r4,r8
  80. lvx v3,r4,r9
  81. lvx v2,r4,r10
  82. lvx v1,r4,r11
  83. lvx v0,r4,r12
  84. addi r4,r4,128
  85. stvx v7,r0,r3
  86. stvx v6,r3,r6
  87. stvx v5,r3,r7
  88. stvx v4,r3,r8
  89. stvx v3,r3,r9
  90. stvx v2,r3,r10
  91. stvx v1,r3,r11
  92. stvx v0,r3,r12
  93. addi r3,r3,128
  94. bdnz 1b
  95. b exit_vmx_copy /* tail call optimise */
  96. #else
  97. li r0,(PAGE_SIZE/128)
  98. mtctr r0
  99. stdu r1,-STACKFRAMESIZE(r1)
  100. #endif
  101. .Lnonvmx_copy:
  102. std r14,STK_REG(R14)(r1)
  103. std r15,STK_REG(R15)(r1)
  104. std r16,STK_REG(R16)(r1)
  105. std r17,STK_REG(R17)(r1)
  106. std r18,STK_REG(R18)(r1)
  107. std r19,STK_REG(R19)(r1)
  108. std r20,STK_REG(R20)(r1)
  109. 1: ld r0,0(r4)
  110. ld r5,8(r4)
  111. ld r6,16(r4)
  112. ld r7,24(r4)
  113. ld r8,32(r4)
  114. ld r9,40(r4)
  115. ld r10,48(r4)
  116. ld r11,56(r4)
  117. ld r12,64(r4)
  118. ld r14,72(r4)
  119. ld r15,80(r4)
  120. ld r16,88(r4)
  121. ld r17,96(r4)
  122. ld r18,104(r4)
  123. ld r19,112(r4)
  124. ld r20,120(r4)
  125. addi r4,r4,128
  126. std r0,0(r3)
  127. std r5,8(r3)
  128. std r6,16(r3)
  129. std r7,24(r3)
  130. std r8,32(r3)
  131. std r9,40(r3)
  132. std r10,48(r3)
  133. std r11,56(r3)
  134. std r12,64(r3)
  135. std r14,72(r3)
  136. std r15,80(r3)
  137. std r16,88(r3)
  138. std r17,96(r3)
  139. std r18,104(r3)
  140. std r19,112(r3)
  141. std r20,120(r3)
  142. addi r3,r3,128
  143. bdnz 1b
  144. ld r14,STK_REG(R14)(r1)
  145. ld r15,STK_REG(R15)(r1)
  146. ld r16,STK_REG(R16)(r1)
  147. ld r17,STK_REG(R17)(r1)
  148. ld r18,STK_REG(R18)(r1)
  149. ld r19,STK_REG(R19)(r1)
  150. ld r20,STK_REG(R20)(r1)
  151. addi r1,r1,STACKFRAMESIZE
  152. blr