6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
#include <linux/export.h>
#include <linux/types.h>
#include <linux/stddef.h>
#include <linux/compiler.h>
#include <linux/string.h>
#ifdef __HAVE_ARCH_MEMCPY
#ifndef CONFIG_OPT_LIB_FUNCTION
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
{
const char *src = v_src;
char *dst = v_dst;
while (c--)
*dst++ = *src++;
return v_dst;
}
#else /* CONFIG_OPT_LIB_FUNCTION */
void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
{
const char *src = v_src;
char *dst = v_dst;
const uint32_t *i_src;
uint32_t *i_dst;
if (likely(c >= 4)) {
unsigned value, buf_hold;
switch ((unsigned long)dst & 3) {
case 1:
*dst++ = *src++;
--c;
case 2:
*dst++ = *src++;
--c;
case 3:
*dst++ = *src++;
--c;
}
i_dst = (void *)dst;
switch ((unsigned long)src & 3) {
case 0x0:
i_src = (const void *)src;
for (; c >= 4; c -= 4)
*i_dst++ = *i_src++;
src = (const void *)i_src;
break;
case 0x1:
i_src = (const void *) ((unsigned)src & ~3);
#ifndef __MICROBLAZEEL__
buf_hold = *i_src++ << 8;
for (; c >= 4; c -= 4) {
value = *i_src++;
*i_dst++ = buf_hold | value >> 24;
buf_hold = value << 8;
}
#else
buf_hold = (*i_src++ & 0xFFFFFF00) >> 8;
for (; c >= 4; c -= 4) {
value = *i_src++;
*i_dst++ = buf_hold | ((value & 0xFF) << 24);
buf_hold = (value & 0xFFFFFF00) >> 8;
}
#endif
src = (const void *)i_src;
src -= 3;
break;
case 0x2:
i_src = (const void *) ((unsigned)src & ~3);
#ifndef __MICROBLAZEEL__
buf_hold = *i_src++ << 16;
for (; c >= 4; c -= 4) {
value = *i_src++;
*i_dst++ = buf_hold | value >> 16;
buf_hold = value << 16;
}
#else
buf_hold = (*i_src++ & 0xFFFF0000) >> 16;
for (; c >= 4; c -= 4) {
value = *i_src++;
*i_dst++ = buf_hold | ((value & 0xFFFF) << 16);
buf_hold = (value & 0xFFFF0000) >> 16;
}
#endif
src = (const void *)i_src;
src -= 2;
break;
case 0x3:
i_src = (const void *) ((unsigned)src & ~3);
#ifndef __MICROBLAZEEL__
buf_hold = *i_src++ << 24;
for (; c >= 4; c -= 4) {
value = *i_src++;
*i_dst++ = buf_hold | value >> 8;
buf_hold = value << 24;
}
#else
buf_hold = (*i_src++ & 0xFF000000) >> 24;
for (; c >= 4; c -= 4) {
value = *i_src++;
*i_dst++ = buf_hold | ((value & 0xFFFFFF) << 8);
buf_hold = (value & 0xFF000000) >> 24;
}
#endif
src = (const void *)i_src;
src -= 1;
break;
}
dst = (void *)i_dst;
}
switch (c) {
case 3:
*dst++ = *src++;
case 2:
*dst++ = *src++;
case 1:
*dst++ = *src++;
}
return v_dst;
}
#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memcpy);
#endif /* __HAVE_ARCH_MEMCPY */
|