1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// memcpy.c
|
4 |
|
|
//
|
5 |
|
|
// memcpy() routine for coldfire
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//==========================================================================
|
41 |
|
|
|
42 |
|
|
/* INCLUDES */
|
43 |
|
|
|
44 |
|
|
#include <cyg/infra/cyg_type.h> /* Common type definitions */
|
45 |
|
|
#include <stddef.h> /* Compiler defns such as size_t, NULL etc. */
|
46 |
|
|
|
47 |
|
|
/* EXPORTED SYMBOLS */
|
48 |
|
|
|
49 |
|
|
externC void *
|
50 |
|
|
memcpy( void * s1, const void * s2, size_t n ) __attribute__((alias("_memcpy")));
|
51 |
|
|
|
52 |
|
|
/* FUNCTIONS */
|
53 |
|
|
|
54 |
|
|
void *
|
55 |
|
|
_memcpy( void * s1, const void * s2, size_t n )
|
56 |
|
|
{
|
57 |
|
|
char * dst = (char *) s1;
|
58 |
|
|
const char * src = (const char *) s2;
|
59 |
|
|
long longwords;
|
60 |
|
|
int_t rem_bytes;
|
61 |
|
|
int_t loops;
|
62 |
|
|
int_t loop_index;
|
63 |
|
|
|
64 |
|
|
/* Don't worry about alignment on the coldfire. Most large */
|
65 |
|
|
/* structures should be aligned anyway. */
|
66 |
|
|
|
67 |
|
|
longwords = (long)(n / 4);
|
68 |
|
|
rem_bytes = n % 4;
|
69 |
|
|
loops = (int_t)(longwords / 32);
|
70 |
|
|
loop_index = (int_t)(longwords % 32);
|
71 |
|
|
|
72 |
|
|
switch (loop_index)
|
73 |
|
|
{
|
74 |
|
|
do
|
75 |
|
|
{
|
76 |
|
|
*((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
77 |
|
|
case 31: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
78 |
|
|
case 30: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
79 |
|
|
case 29: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
80 |
|
|
case 28: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
81 |
|
|
case 27: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
82 |
|
|
case 26: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
83 |
|
|
case 25: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
84 |
|
|
case 24: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
85 |
|
|
case 23: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
86 |
|
|
case 22: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
87 |
|
|
case 21: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
88 |
|
|
case 20: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
89 |
|
|
case 19: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
90 |
|
|
case 18: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
91 |
|
|
case 17: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
92 |
|
|
case 16: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
93 |
|
|
case 15: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
94 |
|
|
case 14: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
95 |
|
|
case 13: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
96 |
|
|
case 12: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
97 |
|
|
case 11: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
98 |
|
|
case 10: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
99 |
|
|
case 9: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
100 |
|
|
case 8: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
101 |
|
|
case 7: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
102 |
|
|
case 6: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
103 |
|
|
case 5: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
104 |
|
|
case 4: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
105 |
|
|
case 3: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
106 |
|
|
case 2: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
107 |
|
|
case 1: *((cyg_uint32*)dst)++ = *((cyg_uint32*)src)++;
|
108 |
|
|
case 0: ; /* Keep compiler from complaining. */
|
109 |
|
|
} while (--loops >= 0);
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
/* Clean up the remaining bytes. */
|
113 |
|
|
|
114 |
|
|
while (--rem_bytes >= 0)
|
115 |
|
|
{
|
116 |
|
|
*dst++ = *src++;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
return s1;
|
120 |
|
|
|
121 |
|
|
} /* _memcpy() */
|
122 |
|
|
|
123 |
|
|
/* EOF memcpy.c */
|