NGpage.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. retl
  40. nop
  41. NGclear_page: /* %o0=dest */
  42. NGclear_user_page: /* %o0=dest, %o1=vaddr */
  43. mov 8, %g1
  44. mov 16, %g2
  45. mov 24, %g3
  46. set PAGE_SIZE, %g7
  47. 1: stxa %g0, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
  48. stxa %g0, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
  49. stxa %g0, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
  50. stxa %g0, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
  51. add %o0, 32, %o0
  52. stxa %g0, [%o0 + %g0] ASI_BLK_INIT_QUAD_LDD_P
  53. stxa %g0, [%o0 + %g1] ASI_BLK_INIT_QUAD_LDD_P
  54. stxa %g0, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P
  55. stxa %g0, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P
  56. subcc %g7, 64, %g7
  57. bne,pt %xcc, 1b
  58. add %o0, 32, %o0
  59. retl
  60. nop
  61. #define BRANCH_ALWAYS 0x10680000
  62. #define NOP 0x01000000
  63. #define NG_DO_PATCH(OLD, NEW) \
  64. sethi %hi(NEW), %g1; \
  65. or %g1, %lo(NEW), %g1; \
  66. sethi %hi(OLD), %g2; \
  67. or %g2, %lo(OLD), %g2; \
  68. sub %g1, %g2, %g1; \
  69. sethi %hi(BRANCH_ALWAYS), %g3; \
  70. sll %g1, 11, %g1; \
  71. srl %g1, 11 + 2, %g1; \
  72. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  73. or %g3, %g1, %g3; \
  74. stw %g3, [%g2]; \
  75. sethi %hi(NOP), %g3; \
  76. or %g3, %lo(NOP), %g3; \
  77. stw %g3, [%g2 + 0x4]; \
  78. flush %g2;
  79. .globl niagara_patch_pageops
  80. .type niagara_patch_pageops,#function
  81. niagara_patch_pageops:
  82. NG_DO_PATCH(copy_user_page, NGcopy_user_page)
  83. NG_DO_PATCH(_clear_page, NGclear_page)
  84. NG_DO_PATCH(clear_user_page, NGclear_user_page)
  85. retl
  86. nop
  87. .size niagara_patch_pageops,.-niagara_patch_pageops