NGpage.S 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. srl %g1, 2, %g1; \
  71. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  72. or %g3, %g1, %g3; \
  73. stw %g3, [%g2]; \
  74. sethi %hi(NOP), %g3; \
  75. or %g3, %lo(NOP), %g3; \
  76. stw %g3, [%g2 + 0x4]; \
  77. flush %g2;
  78. .globl niagara_patch_pageops
  79. .type niagara_patch_pageops,#function
  80. niagara_patch_pageops:
  81. NG_DO_PATCH(copy_user_page, NGcopy_user_page)
  82. NG_DO_PATCH(_clear_page, NGclear_page)
  83. NG_DO_PATCH(clear_user_page, NGclear_user_page)
  84. retl
  85. nop
  86. .size niagara_patch_pageops,.-niagara_patch_pageops