NGpage.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* NGpage.S: Niagara optimize clear and copy page.
  2. *
  3. * Copyright (C) 2006 (davem@davemloft.net)
  4. */
  5. #include <asm/asi.h>
  6. #include <asm/page.h>
  7. .text
  8. .align 32
  9. /* This is heavily simplified from the sun4u variants
  10. * because Niagara does not have any D-cache aliasing issues
  11. * and also we don't need to use the FPU in order to implement
  12. * an optimal page copy/clear.
  13. */
  14. NGcopy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
  15. save %sp, -192, %sp
  16. rd %asi, %g3
  17. wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
  18. set PAGE_SIZE, %g7
  19. prefetch [%i1 + 0x00], #one_read
  20. prefetch [%i1 + 0x40], #one_read
  21. 1: prefetch [%i1 + 0x80], #one_read
  22. prefetch [%i1 + 0xc0], #one_read
  23. ldda [%i1 + 0x00] %asi, %o2
  24. ldda [%i1 + 0x10] %asi, %o4
  25. ldda [%i1 + 0x20] %asi, %l2
  26. ldda [%i1 + 0x30] %asi, %l4
  27. stxa %o2, [%i0 + 0x00] %asi
  28. stxa %o3, [%i0 + 0x08] %asi
  29. stxa %o4, [%i0 + 0x10] %asi
  30. stxa %o5, [%i0 + 0x18] %asi
  31. stxa %l2, [%i0 + 0x20] %asi
  32. stxa %l3, [%i0 + 0x28] %asi
  33. stxa %l4, [%i0 + 0x30] %asi
  34. stxa %l5, [%i0 + 0x38] %asi
  35. ldda [%i1 + 0x40] %asi, %o2
  36. ldda [%i1 + 0x50] %asi, %o4
  37. ldda [%i1 + 0x60] %asi, %l2
  38. ldda [%i1 + 0x70] %asi, %l4
  39. stxa %o2, [%i0 + 0x40] %asi
  40. stxa %o3, [%i0 + 0x48] %asi
  41. stxa %o4, [%i0 + 0x50] %asi
  42. stxa %o5, [%i0 + 0x58] %asi
  43. stxa %l2, [%i0 + 0x60] %asi
  44. stxa %l3, [%i0 + 0x68] %asi
  45. stxa %l4, [%i0 + 0x70] %asi
  46. stxa %l5, [%i0 + 0x78] %asi
  47. add %i1, 128, %i1
  48. subcc %g7, 128, %g7
  49. bne,pt %xcc, 1b
  50. add %i0, 128, %i0
  51. wr %g3, 0x0, %asi
  52. membar #Sync
  53. ret
  54. restore
  55. .align 32
  56. .globl NGclear_page
  57. .globl NGclear_user_page
  58. NGclear_page: /* %o0=dest */
  59. NGclear_user_page: /* %o0=dest, %o1=vaddr */
  60. rd %asi, %g3
  61. wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
  62. set PAGE_SIZE, %g7
  63. 1: stxa %g0, [%o0 + 0x00] %asi
  64. stxa %g0, [%o0 + 0x08] %asi
  65. stxa %g0, [%o0 + 0x10] %asi
  66. stxa %g0, [%o0 + 0x18] %asi
  67. stxa %g0, [%o0 + 0x20] %asi
  68. stxa %g0, [%o0 + 0x28] %asi
  69. stxa %g0, [%o0 + 0x30] %asi
  70. stxa %g0, [%o0 + 0x38] %asi
  71. stxa %g0, [%o0 + 0x40] %asi
  72. stxa %g0, [%o0 + 0x48] %asi
  73. stxa %g0, [%o0 + 0x50] %asi
  74. stxa %g0, [%o0 + 0x58] %asi
  75. stxa %g0, [%o0 + 0x60] %asi
  76. stxa %g0, [%o0 + 0x68] %asi
  77. stxa %g0, [%o0 + 0x70] %asi
  78. stxa %g0, [%o0 + 0x78] %asi
  79. stxa %g0, [%o0 + 0x80] %asi
  80. stxa %g0, [%o0 + 0x88] %asi
  81. stxa %g0, [%o0 + 0x90] %asi
  82. stxa %g0, [%o0 + 0x98] %asi
  83. stxa %g0, [%o0 + 0xa0] %asi
  84. stxa %g0, [%o0 + 0xa8] %asi
  85. stxa %g0, [%o0 + 0xb0] %asi
  86. stxa %g0, [%o0 + 0xb8] %asi
  87. stxa %g0, [%o0 + 0xc0] %asi
  88. stxa %g0, [%o0 + 0xc8] %asi
  89. stxa %g0, [%o0 + 0xd0] %asi
  90. stxa %g0, [%o0 + 0xd8] %asi
  91. stxa %g0, [%o0 + 0xe0] %asi
  92. stxa %g0, [%o0 + 0xe8] %asi
  93. stxa %g0, [%o0 + 0xf0] %asi
  94. stxa %g0, [%o0 + 0xf8] %asi
  95. subcc %g7, 256, %g7
  96. bne,pt %xcc, 1b
  97. add %o0, 256, %o0
  98. wr %g3, 0x0, %asi
  99. membar #Sync
  100. retl
  101. nop
  102. #define BRANCH_ALWAYS 0x10680000
  103. #define NOP 0x01000000
  104. #define NG_DO_PATCH(OLD, NEW) \
  105. sethi %hi(NEW), %g1; \
  106. or %g1, %lo(NEW), %g1; \
  107. sethi %hi(OLD), %g2; \
  108. or %g2, %lo(OLD), %g2; \
  109. sub %g1, %g2, %g1; \
  110. sethi %hi(BRANCH_ALWAYS), %g3; \
  111. sll %g1, 11, %g1; \
  112. srl %g1, 11 + 2, %g1; \
  113. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  114. or %g3, %g1, %g3; \
  115. stw %g3, [%g2]; \
  116. sethi %hi(NOP), %g3; \
  117. or %g3, %lo(NOP), %g3; \
  118. stw %g3, [%g2 + 0x4]; \
  119. flush %g2;
  120. .globl niagara_patch_pageops
  121. .type niagara_patch_pageops,#function
  122. niagara_patch_pageops:
  123. NG_DO_PATCH(copy_user_page, NGcopy_user_page)
  124. NG_DO_PATCH(_clear_page, NGclear_page)
  125. NG_DO_PATCH(clear_user_page, NGclear_user_page)
  126. retl
  127. nop
  128. .size niagara_patch_pageops,.-niagara_patch_pageops