NGpage.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. prefetch [%o1 + 0x00], #one_read
  16. mov 8, %g1
  17. mov 16, %g2
  18. mov 24, %g3
  19. set PAGE_SIZE, %g7
  20. 1: ldda [%o1 + %g0] ASI_BLK_INIT_QUAD_LDD_P, %o2
  21. ldda [%o1 + %g2] ASI_BLK_INIT_QUAD_LDD_P, %o4
  22. prefetch [%o1 + 0x40], #one_read
  23. add %o1, 32, %o1
  24. stxa %o2, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
  25. stxa %o3, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
  26. ldda [%o1 + %g0] ASI_BLK_INIT_QUAD_LDD_P, %o2
  27. stxa %o4, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
  28. stxa %o5, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
  29. ldda [%o1 + %g2] ASI_BLK_INIT_QUAD_LDD_P, %o4
  30. add %o1, 32, %o1
  31. add %o0, 32, %o0
  32. stxa %o2, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
  33. stxa %o3, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
  34. stxa %o4, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
  35. stxa %o5, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
  36. subcc %g7, 64, %g7
  37. bne,pt %xcc, 1b
  38. add %o0, 32, %o0
  39. membar #Sync
  40. retl
  41. nop
  42. .globl NGclear_page, NGclear_user_page
  43. NGclear_page: /* %o0=dest */
  44. NGclear_user_page: /* %o0=dest, %o1=vaddr */
  45. mov 8, %g1
  46. mov 16, %g2
  47. mov 24, %g3
  48. set PAGE_SIZE, %g7
  49. 1: stxa %g0, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
  50. stxa %g0, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
  51. stxa %g0, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
  52. stxa %g0, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
  53. add %o0, 32, %o0
  54. stxa %g0, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
  55. stxa %g0, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
  56. stxa %g0, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
  57. stxa %g0, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
  58. subcc %g7, 64, %g7
  59. bne,pt %xcc, 1b
  60. add %o0, 32, %o0
  61. membar #Sync
  62. retl
  63. nop
  64. #define BRANCH_ALWAYS 0x10680000
  65. #define NOP 0x01000000
  66. #define NG_DO_PATCH(OLD, NEW) \
  67. sethi %hi(NEW), %g1; \
  68. or %g1, %lo(NEW), %g1; \
  69. sethi %hi(OLD), %g2; \
  70. or %g2, %lo(OLD), %g2; \
  71. sub %g1, %g2, %g1; \
  72. sethi %hi(BRANCH_ALWAYS), %g3; \
  73. sll %g1, 11, %g1; \
  74. srl %g1, 11 + 2, %g1; \
  75. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  76. or %g3, %g1, %g3; \
  77. stw %g3, [%g2]; \
  78. sethi %hi(NOP), %g3; \
  79. or %g3, %lo(NOP), %g3; \
  80. stw %g3, [%g2 + 0x4]; \
  81. flush %g2;
  82. .globl niagara_patch_pageops
  83. .type niagara_patch_pageops,#function
  84. niagara_patch_pageops:
  85. NG_DO_PATCH(copy_user_page, NGcopy_user_page)
  86. NG_DO_PATCH(_clear_page, NGclear_page)
  87. NG_DO_PATCH(clear_user_page, NGclear_user_page)
  88. retl
  89. nop
  90. .size niagara_patch_pageops,.-niagara_patch_pageops