memset.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * File: arch/blackfin/lib/memset.S
  3. * Based on:
  4. * Author:
  5. *
  6. * Created:
  7. * Description:
  8. *
  9. * Modified:
  10. * Copyright 2004-2006 Analog Devices Inc.
  11. *
  12. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, see the file COPYING, or write
  26. * to the Free Software Foundation, Inc.,
  27. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  28. */
  29. #include <linux/linkage.h>
  30. .align 2
  31. #ifdef CONFIG_MEMSET_L1
  32. .section .l1.text
  33. #else
  34. .text
  35. #endif
  36. /*
  37. * C Library function MEMSET
  38. * R0 = address (leave unchanged to form result)
  39. * R1 = filler byte
  40. * R2 = count
  41. * Favours word aligned data.
  42. */
  43. ENTRY(_memset)
  44. P0 = R0 ; /* P0 = address */
  45. P2 = R2 ; /* P2 = count */
  46. R3 = R0 + R2; /* end */
  47. CC = R2 <= 7(IU);
  48. IF CC JUMP .Ltoo_small;
  49. R1 = R1.B (Z); /* R1 = fill char */
  50. R2 = 3;
  51. R2 = R0 & R2; /* addr bottom two bits */
  52. CC = R2 == 0; /* AZ set if zero. */
  53. IF !CC JUMP .Lforce_align ; /* Jump if addr not aligned. */
  54. .Laligned:
  55. P1 = P2 >> 2; /* count = n/4 */
  56. R2 = R1 << 8; /* create quad filler */
  57. R2.L = R2.L + R1.L(NS);
  58. R2.H = R2.L + R1.H(NS);
  59. P2 = R3;
  60. LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
  61. .Lquad_loop:
  62. [P0++] = R2;
  63. CC = P0 == P2;
  64. IF !CC JUMP .Lbytes_left;
  65. RTS;
  66. .Lbytes_left:
  67. R2 = R3; /* end point */
  68. R3 = P0; /* current position */
  69. R2 = R2 - R3; /* bytes left */
  70. P2 = R2;
  71. .Ltoo_small:
  72. CC = P2 == 0; /* Check zero count */
  73. IF CC JUMP .Lfinished; /* Unusual */
  74. .Lbytes:
  75. LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
  76. .Lbyte_loop:
  77. B[P0++] = R1;
  78. .Lfinished:
  79. RTS;
  80. .Lforce_align:
  81. CC = BITTST (R0, 0); /* odd byte */
  82. R0 = 4;
  83. R0 = R0 - R2;
  84. P1 = R0;
  85. R0 = P0; /* Recover return address */
  86. IF !CC JUMP .Lskip1;
  87. B[P0++] = R1;
  88. .Lskip1:
  89. CC = R2 <= 2; /* 2 bytes */
  90. P2 -= P1; /* reduce count */
  91. IF !CC JUMP .Laligned;
  92. B[P0++] = R1;
  93. B[P0++] = R1;
  94. JUMP .Laligned;
  95. ENDPROC(_memset)