copypage_power7.S 3.3 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 */
  31. #ifdef CONFIG_PPC_64K_PAGES
  32. lis r7,0x0E01 /* depth=7, units=512 */
  33. #else
  34. lis r7,0x0E00 /* depth=7 */
  35. ori r7,r7,0x1000 /* units=32 */
  36. #endif
  37. ori r10,r7,1 /* stream=1 */
  38. lis r8,0x8000 /* GO=1 */
  39. clrldi r8,r8,32
  40. .machine push
  41. .machine "power4"
  42. dcbt r0,r4,0b01000
  43. dcbt r0,r7,0b01010
  44. dcbtst r0,r9,0b01000
  45. dcbtst r0,r10,0b01010
  46. eieio
  47. dcbt r0,r8,0b01010 /* GO */
  48. .machine pop
  49. #ifdef CONFIG_ALTIVEC
  50. mflr r0
  51. std r3,48(r1)
  52. std r4,56(r1)
  53. std r0,16(r1)
  54. stdu r1,-STACKFRAMESIZE(r1)
  55. bl .enter_vmx_copy
  56. cmpwi r3,0
  57. ld r0,STACKFRAMESIZE+16(r1)
  58. ld r3,STACKFRAMESIZE+48(r1)
  59. ld r4,STACKFRAMESIZE+56(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 vr7,r0,r4
  74. lvx vr6,r4,r6
  75. lvx vr5,r4,r7
  76. lvx vr4,r4,r8
  77. lvx vr3,r4,r9
  78. lvx vr2,r4,r10
  79. lvx vr1,r4,r11
  80. lvx vr0,r4,r12
  81. addi r4,r4,128
  82. stvx vr7,r0,r3
  83. stvx vr6,r3,r6
  84. stvx vr5,r3,r7
  85. stvx vr4,r3,r8
  86. stvx vr3,r3,r9
  87. stvx vr2,r3,r10
  88. stvx vr1,r3,r11
  89. stvx vr0,r3,r12
  90. addi r3,r3,128
  91. bdnz 1b
  92. b .exit_vmx_copy /* 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