memset.S 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  4. */
  5. #include <linux/linkage.h>
  6. #define SMALL 7 /* Must be at least 6 to deal with alignment/loop issues. */
  7. ENTRY_CFI(memset)
  8. mov_s r4,r0
  9. or r12,r0,r2
  10. bmsk.f r12,r12,1
  11. extb_s r1,r1
  12. asl r3,r1,8
  13. beq.d .Laligned
  14. or_s r1,r1,r3
  15. brls r2,SMALL,.Ltiny
  16. add r3,r2,r0
  17. stb r1,[r3,-1]
  18. bclr_s r3,r3,0
  19. stw r1,[r3,-2]
  20. bmsk.f r12,r0,1
  21. add_s r2,r2,r12
  22. sub.ne r2,r2,4
  23. stb.ab r1,[r4,1]
  24. and r4,r4,-2
  25. stw.ab r1,[r4,2]
  26. and r4,r4,-4
  27. .Laligned: ; This code address should be aligned for speed.
  28. asl r3,r1,16
  29. lsr.f lp_count,r2,2
  30. or_s r1,r1,r3
  31. lpne .Loop_end
  32. st.ab r1,[r4,4]
  33. .Loop_end:
  34. j_s [blink]
  35. .balign 4
  36. .Ltiny:
  37. mov.f lp_count,r2
  38. lpne .Ltiny_end
  39. stb.ab r1,[r4,1]
  40. .Ltiny_end:
  41. j_s [blink]
  42. END_CFI(memset)
  43. ; memzero: @r0 = mem, @r1 = size_t
  44. ; memset: @r0 = mem, @r1 = char, @r2 = size_t
  45. ENTRY_CFI(memzero)
  46. ; adjust bzero args to memset args
  47. mov r2, r1
  48. mov r1, 0
  49. b memset ;tail call so need to tinker with blink
  50. END_CFI(memzero)