NG4patch.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* NG4patch.S: Patch Ultra-I routines with Niagara-4 variant.
  3. *
  4. * Copyright (C) 2012 David S. Miller <davem@davemloft.net>
  5. */
  6. #include <linux/linkage.h>
  7. #define BRANCH_ALWAYS 0x10680000
  8. #define NOP 0x01000000
  9. #define NG_DO_PATCH(OLD, NEW) \
  10. sethi %hi(NEW), %g1; \
  11. or %g1, %lo(NEW), %g1; \
  12. sethi %hi(OLD), %g2; \
  13. or %g2, %lo(OLD), %g2; \
  14. sub %g1, %g2, %g1; \
  15. sethi %hi(BRANCH_ALWAYS), %g3; \
  16. sll %g1, 11, %g1; \
  17. srl %g1, 11 + 2, %g1; \
  18. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  19. or %g3, %g1, %g3; \
  20. stw %g3, [%g2]; \
  21. sethi %hi(NOP), %g3; \
  22. or %g3, %lo(NOP), %g3; \
  23. stw %g3, [%g2 + 0x4]; \
  24. flush %g2;
  25. .globl niagara4_patch_copyops
  26. .type niagara4_patch_copyops,#function
  27. niagara4_patch_copyops:
  28. NG_DO_PATCH(memcpy, NG4memcpy)
  29. NG_DO_PATCH(raw_copy_from_user, NG4copy_from_user)
  30. NG_DO_PATCH(raw_copy_to_user, NG4copy_to_user)
  31. retl
  32. nop
  33. .size niagara4_patch_copyops,.-niagara4_patch_copyops
  34. .globl niagara4_patch_bzero
  35. .type niagara4_patch_bzero,#function
  36. niagara4_patch_bzero:
  37. NG_DO_PATCH(memset, NG4memset)
  38. NG_DO_PATCH(__bzero, NG4bzero)
  39. NG_DO_PATCH(__clear_user, NGclear_user)
  40. NG_DO_PATCH(tsb_init, NGtsb_init)
  41. retl
  42. nop
  43. .size niagara4_patch_bzero,.-niagara4_patch_bzero
  44. .globl niagara4_patch_pageops
  45. .type niagara4_patch_pageops,#function
  46. niagara4_patch_pageops:
  47. NG_DO_PATCH(copy_user_page, NG4copy_user_page)
  48. NG_DO_PATCH(_clear_page, NG4clear_page)
  49. NG_DO_PATCH(clear_user_page, NG4clear_user_page)
  50. retl
  51. nop
  52. .size niagara4_patch_pageops,.-niagara4_patch_pageops
  53. ENTRY(niagara4_patch_fls)
  54. NG_DO_PATCH(fls, NG4fls)
  55. NG_DO_PATCH(__fls, __NG4fls)
  56. retl
  57. nop
  58. ENDPROC(niagara4_patch_fls)