aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/lib/memcpy.S
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@analog.com>2007-05-06 17:50:22 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:58 -0400
commit1394f03221790a988afc3e4b3cb79f2e477246a9 (patch)
tree2c1963c9a4f2d84a5e021307fde240c5d567cf70 /arch/blackfin/lib/memcpy.S
parent73243284463a761e04d69d22c7516b2be7de096c (diff)
blackfin architecture
This adds support for the Analog Devices Blackfin processor architecture, and currently supports the BF533, BF532, BF531, BF537, BF536, BF534, and BF561 (Dual Core) devices, with a variety of development platforms including those avaliable from Analog Devices (BF533-EZKit, BF533-STAMP, BF537-STAMP, BF561-EZKIT), and Bluetechnix! Tinyboards. The Blackfin architecture was jointly developed by Intel and Analog Devices Inc. (ADI) as the Micro Signal Architecture (MSA) core and introduced it in December of 2000. Since then ADI has put this core into its Blackfin processor family of devices. The Blackfin core has the advantages of a clean, orthogonal,RISC-like microprocessor instruction set. It combines a dual-MAC (Multiply/Accumulate), state-of-the-art signal processing engine and single-instruction, multiple-data (SIMD) multimedia capabilities into a single instruction-set architecture. The Blackfin architecture, including the instruction set, is described by the ADSP-BF53x/BF56x Blackfin Processor Programming Reference http://blackfin.uclinux.org/gf/download/frsrelease/29/2549/Blackfin_PRM.pdf The Blackfin processor is already supported by major releases of gcc, and there are binary and source rpms/tarballs for many architectures at: http://blackfin.uclinux.org/gf/project/toolchain/frs There is complete documentation, including "getting started" guides available at: http://docs.blackfin.uclinux.org/ which provides links to the sources and patches you will need in order to set up a cross-compiling environment for bfin-linux-uclibc This patch, as well as the other patches (toolchain, distribution, uClibc) are actively supported by Analog Devices Inc, at: http://blackfin.uclinux.org/ We have tested this on LTP, and our test plan (including pass/fails) can be found at: http://docs.blackfin.uclinux.org/doku.php?id=testing_the_linux_kernel [m.kozlowski@tuxland.pl: balance parenthesis in blackfin header files] Signed-off-by: Bryan Wu <bryan.wu@analog.com> Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl> Signed-off-by: Aubrey Li <aubrey.li@analog.com> Signed-off-by: Jie Zhang <jie.zhang@analog.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/blackfin/lib/memcpy.S')
-rw-r--r--arch/blackfin/lib/memcpy.S142
1 files changed, 142 insertions, 0 deletions
diff --git a/arch/blackfin/lib/memcpy.S b/arch/blackfin/lib/memcpy.S
new file mode 100644
index 000000000000..c1e00eff541c
--- /dev/null
+++ b/arch/blackfin/lib/memcpy.S
@@ -0,0 +1,142 @@
1/*
2 * File: arch/blackfin/lib/memcpy.S
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description: internal version of memcpy(), issued by the compiler
8 * to copy blocks of data around.
9 * This is really memmove() - it has to be able to deal with
10 * possible overlaps, because that ambiguity is when the compiler
11 * gives up and calls a function. We have our own, internal version
12 * so that we get something we trust, even if the user has redefined
13 * the normal symbol.
14 *
15 * Modified:
16 * Copyright 2004-2006 Analog Devices Inc.
17 *
18 * Bugs: Enter bugs at http://blackfin.uclinux.org/
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, see the file COPYING, or write
32 * to the Free Software Foundation, Inc.,
33 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 */
35
36#include <linux/linkage.h>
37
38/* void *memcpy(void *dest, const void *src, size_t n);
39 * R0 = To Address (dest) (leave unchanged to form result)
40 * R1 = From Address (src)
41 * R2 = count
42 *
43 * Note: Favours word alignment
44 */
45
46#ifdef CONFIG_MEMCPY_L1
47.section .l1.text
48#else
49.text
50#endif
51
52.align 2
53
54ENTRY(_memcpy)
55 CC = R2 <= 0; /* length not positive? */
56 IF CC JUMP .L_P1L2147483647; /* Nothing to do */
57
58 P0 = R0 ; /* dst*/
59 P1 = R1 ; /* src*/
60 P2 = R2 ; /* length */
61
62 /* check for overlapping data */
63 CC = R1 < R0; /* src < dst */
64 IF !CC JUMP .Lno_overlap;
65 R3 = R1 + R2;
66 CC = R0 < R3; /* and dst < src+len */
67 IF CC JUMP .Lhas_overlap;
68
69.Lno_overlap:
70 /* Check for aligned data.*/
71
72 R3 = R1 | R0;
73 R0 = 0x3;
74 R3 = R3 & R0;
75 CC = R3; /* low bits set on either address? */
76 IF CC JUMP .Lnot_aligned;
77
78 /* Both addresses are word-aligned, so we can copy
79 at least part of the data using word copies.*/
80 P2 = P2 >> 2;
81 CC = P2 <= 2;
82 IF !CC JUMP .Lmore_than_seven;
83 /* less than eight bytes... */
84 P2 = R2;
85 LSETUP(.Lthree_start, .Lthree_end) LC0=P2;
86 R0 = R1; /* setup src address for return */
87.Lthree_start:
88 R3 = B[P1++] (X);
89.Lthree_end:
90 B[P0++] = R3;
91
92 RTS;
93
94.Lmore_than_seven:
95 /* There's at least eight bytes to copy. */
96 P2 += -1; /* because we unroll one iteration */
97 LSETUP(.Lword_loop, .Lword_loop) LC0=P2;
98 R0 = R1;
99 I1 = P1;
100 R3 = [I1++];
101.Lword_loop:
102 MNOP || [P0++] = R3 || R3 = [I1++];
103
104 [P0++] = R3;
105 /* Any remaining bytes to copy? */
106 R3 = 0x3;
107 R3 = R2 & R3;
108 CC = R3 == 0;
109 P1 = I1; /* in case there's something left, */
110 IF !CC JUMP .Lbytes_left;
111 RTS;
112.Lbytes_left: P2 = R3;
113.Lnot_aligned:
114 /* From here, we're copying byte-by-byte. */
115 LSETUP (.Lbyte_start, .Lbyte_end) LC0=P2;
116 R0 = R1; /* Save src address for return */
117.Lbyte_start:
118 R1 = B[P1++] (X);
119.Lbyte_end:
120 B[P0++] = R1;
121
122.L_P1L2147483647:
123 RTS;
124
125.Lhas_overlap:
126 /* Need to reverse the copying, because the
127 * dst would clobber the src.
128 * Don't bother to work out alignment for
129 * the reverse case.
130 */
131 R0 = R1; /* save src for later. */
132 P0 = P0 + P2;
133 P0 += -1;
134 P1 = P1 + P2;
135 P1 += -1;
136 LSETUP(.Lover_start, .Lover_end) LC0=P2;
137.Lover_start:
138 R1 = B[P1--] (X);
139.Lover_end:
140 B[P0--] = R1;
141
142 RTS;