2 * Copyright (C) 2002 Mark Debbage (Mark.Debbage@superh.com)
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
9 #include <linux/config.h>
10 #include <linux/types.h>
11 #include <asm/string.h>
13 // This is a simplistic optimization of memcpy to increase the
14 // granularity of access beyond one byte using aligned
15 // loads and stores. This is not an optimal implementation
16 // for SH-5 (especially with regard to prefetching and the cache),
17 // and a better version should be provided later ...
19 void *memcpy(void *dest, const void *src, size_t count)
21 char *d = (char *) dest, *s = (char *) src;
24 int i = 8 - (((unsigned long) d) & 0x7);
27 while (i-- && count--) {
31 if (((((unsigned long) d) & 0x7) == 0) &&
32 ((((unsigned long) s) & 0x7) == 0)) {
34 unsigned long long t1, t2, t3, t4;
35 t1 = *(unsigned long long *) (s);
36 t2 = *(unsigned long long *) (s + 8);
37 t3 = *(unsigned long long *) (s + 16);
38 t4 = *(unsigned long long *) (s + 24);
39 *(unsigned long long *) (d) = t1;
40 *(unsigned long long *) (d + 8) = t2;
41 *(unsigned long long *) (d + 16) = t3;
42 *(unsigned long long *) (d + 24) = t4;
48 *(unsigned long long *) d =
49 *(unsigned long long *) s;
56 if (((((unsigned long) d) & 0x3) == 0) &&
57 ((((unsigned long) s) & 0x3) == 0)) {
59 *(unsigned long *) d = *(unsigned long *) s;
66 if (((((unsigned long) d) & 0x1) == 0) &&
67 ((((unsigned long) s) & 0x1) == 0)) {
69 *(unsigned short *) d = *(unsigned short *) s;