copy_page.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. *
  4. * Optimized version of the standard copy_page() function
  5. *
  6. * Inputs:
  7. * in0: address of target page
  8. * in1: address of source page
  9. * Output:
  10. * no return value
  11. *
  12. * Copyright (C) 1999, 2001 Hewlett-Packard Co
  13. * Stephane Eranian <eranian@hpl.hp.com>
  14. * David Mosberger <davidm@hpl.hp.com>
  15. *
  16. * 4/06/01 davidm Tuned to make it perform well both for cached and uncached copies.
  17. */
  18. #include <asm/asmmacro.h>
  19. #include <asm/page.h>
  20. #include <asm/export.h>
  21. #define PIPE_DEPTH 3
  22. #define EPI p[PIPE_DEPTH-1]
  23. #define lcount r16
  24. #define saved_pr r17
  25. #define saved_lc r18
  26. #define saved_pfs r19
  27. #define src1 r20
  28. #define src2 r21
  29. #define tgt1 r22
  30. #define tgt2 r23
  31. #define srcf r24
  32. #define tgtf r25
  33. #define tgt_last r26
  34. #define Nrot ((8*PIPE_DEPTH+7)&~7)
  35. GLOBAL_ENTRY(copy_page)
  36. .prologue
  37. .save ar.pfs, saved_pfs
  38. alloc saved_pfs=ar.pfs,3,Nrot-3,0,Nrot
  39. .rotr t1[PIPE_DEPTH], t2[PIPE_DEPTH], t3[PIPE_DEPTH], t4[PIPE_DEPTH], \
  40. t5[PIPE_DEPTH], t6[PIPE_DEPTH], t7[PIPE_DEPTH], t8[PIPE_DEPTH]
  41. .rotp p[PIPE_DEPTH]
  42. .save ar.lc, saved_lc
  43. mov saved_lc=ar.lc
  44. mov ar.ec=PIPE_DEPTH
  45. mov lcount=PAGE_SIZE/64-1
  46. .save pr, saved_pr
  47. mov saved_pr=pr
  48. mov pr.rot=1<<16
  49. .body
  50. mov src1=in1
  51. adds src2=8,in1
  52. mov tgt_last = PAGE_SIZE
  53. ;;
  54. adds tgt2=8,in0
  55. add srcf=512,in1
  56. mov ar.lc=lcount
  57. mov tgt1=in0
  58. add tgtf=512,in0
  59. add tgt_last = tgt_last, in0
  60. ;;
  61. 1:
  62. (p[0]) ld8 t1[0]=[src1],16
  63. (EPI) st8 [tgt1]=t1[PIPE_DEPTH-1],16
  64. (p[0]) ld8 t2[0]=[src2],16
  65. (EPI) st8 [tgt2]=t2[PIPE_DEPTH-1],16
  66. cmp.ltu p6,p0 = tgtf, tgt_last
  67. ;;
  68. (p[0]) ld8 t3[0]=[src1],16
  69. (EPI) st8 [tgt1]=t3[PIPE_DEPTH-1],16
  70. (p[0]) ld8 t4[0]=[src2],16
  71. (EPI) st8 [tgt2]=t4[PIPE_DEPTH-1],16
  72. ;;
  73. (p[0]) ld8 t5[0]=[src1],16
  74. (EPI) st8 [tgt1]=t5[PIPE_DEPTH-1],16
  75. (p[0]) ld8 t6[0]=[src2],16
  76. (EPI) st8 [tgt2]=t6[PIPE_DEPTH-1],16
  77. ;;
  78. (p[0]) ld8 t7[0]=[src1],16
  79. (EPI) st8 [tgt1]=t7[PIPE_DEPTH-1],16
  80. (p[0]) ld8 t8[0]=[src2],16
  81. (EPI) st8 [tgt2]=t8[PIPE_DEPTH-1],16
  82. (p6) lfetch [srcf], 64
  83. (p6) lfetch [tgtf], 64
  84. br.ctop.sptk.few 1b
  85. ;;
  86. mov pr=saved_pr,0xffffffffffff0000 // restore predicates
  87. mov ar.pfs=saved_pfs
  88. mov ar.lc=saved_lc
  89. br.ret.sptk.many rp
  90. END(copy_page)
  91. EXPORT_SYMBOL(copy_page)