NGpage.S 2.6 KB

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