aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/lib/memmove.S
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-05-07 23:37:51 -0400
committerPaul Mackerras <paulus@samba.org>2007-05-07 23:37:51 -0400
commit02bbc0f09c90cefdb2837605c96a66c5ce4ba2e1 (patch)
tree04ef573cd4de095c500c9fc3477f4278c0b36300 /arch/blackfin/lib/memmove.S
parent7487a2245b8841c77ba9db406cf99a483b9334e9 (diff)
parent5b94f675f57e4ff16c8fda09088d7480a84dcd91 (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'arch/blackfin/lib/memmove.S')
-rw-r--r--arch/blackfin/lib/memmove.S103
1 files changed, 103 insertions, 0 deletions
diff --git a/arch/blackfin/lib/memmove.S b/arch/blackfin/lib/memmove.S
new file mode 100644
index 000000000000..2e5fb7f8df13
--- /dev/null
+++ b/arch/blackfin/lib/memmove.S
@@ -0,0 +1,103 @@
1/*
2 * File: arch/blackfin/lib/memmove.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
30#include <linux/linkage.h>
31
32.align 2
33
34/*
35 * C Library function MEMMOVE
36 * R0 = To Address (leave unchanged to form result)
37 * R1 = From Address
38 * R2 = count
39 * Data may overlap
40 */
41
42ENTRY(_memmove)
43 I1 = P3;
44 P0 = R0; /* P0 = To address */
45 P3 = R1; /* P3 = From Address */
46 P2 = R2; /* P2 = count */
47 CC = P2 == 0; /* Check zero count*/
48 IF CC JUMP .Lfinished; /* very unlikely */
49
50 CC = R1 < R0 (IU); /* From < To */
51 IF !CC JUMP .Lno_overlap;
52 R3 = R1 + R2;
53 CC = R0 <= R3 (IU); /* (From+len) >= To */
54 IF CC JUMP .Loverlap;
55.Lno_overlap:
56 R3 = 11;
57 CC = R2 <= R3;
58 IF CC JUMP .Lbytes;
59 R3 = R1 | R0; /* OR addresses together */
60 R3 <<= 30; /* check bottom two bits */
61 CC = AZ; /* AZ set if zero.*/
62 IF !CC JUMP .Lbytes; /* Jump if addrs not aligned.*/
63
64 I0 = P3;
65 P1 = P2 >> 2; /* count = n/4 */
66 P1 += -1;
67 R3 = 3;
68 R2 = R2 & R3; /* remainder */
69 P2 = R2; /* set remainder */
70 R1 = [I0++];
71
72 LSETUP (.Lquad_loop, .Lquad_loop) LC0=P1;
73.Lquad_loop: MNOP || [P0++] = R1 || R1 = [I0++];
74 [P0++] = R1;
75
76 CC = P2 == 0; /* any remaining bytes? */
77 P3 = I0; /* Ammend P3 to updated ptr. */
78 IF !CC JUMP .Lbytes;
79 P3 = I1;
80 RTS;
81
82.Lbytes: LSETUP (.Lbyte2_s, .Lbyte2_e) LC0=P2;
83.Lbyte2_s: R1 = B[P3++](Z);
84.Lbyte2_e: B[P0++] = R1;
85
86.Lfinished: P3 = I1;
87 RTS;
88
89.Loverlap:
90 P2 += -1;
91 P0 = P0 + P2;
92 P3 = P3 + P2;
93 R1 = B[P3--] (Z);
94 CC = P2 == 0;
95 IF CC JUMP .Lno_loop;
96 LSETUP (.Lol_s, .Lol_e) LC0 = P2;
97.Lol_s: B[P0--] = R1;
98.Lol_e: R1 = B[P3--] (Z);
99.Lno_loop: B[P0] = R1;
100 P3 = I1;
101 RTS;
102
103.size _memmove,.-_memmove