Blame view

kernel/linux-imx6_3.14.28/arch/m68k/lib/uaccess.c 2.87 KB
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
  /*
   * This file is subject to the terms and conditions of the GNU General Public
   * License.  See the file COPYING in the main directory of this archive
   * for more details.
   */
  
  #include <linux/module.h>
  #include <asm/uaccess.h>
  
  unsigned long __generic_copy_from_user(void *to, const void __user *from,
  				       unsigned long n)
  {
  	unsigned long tmp, res;
  
  	asm volatile ("
  "
  		"	tst.l	%0
  "
  		"	jeq	2f
  "
  		"1:	"MOVES".l	(%1)+,%3
  "
  		"	move.l	%3,(%2)+
  "
  		"	subq.l	#1,%0
  "
  		"	jne	1b
  "
  		"2:	btst	#1,%5
  "
  		"	jeq	4f
  "
  		"3:	"MOVES".w	(%1)+,%3
  "
  		"	move.w	%3,(%2)+
  "
  		"4:	btst	#0,%5
  "
  		"	jeq	6f
  "
  		"5:	"MOVES".b	(%1)+,%3
  "
  		"	move.b  %3,(%2)+
  "
  		"6:
  "
  		"	.section .fixup,\"ax\"
  "
  		"	.even
  "
  		"10:	move.l	%0,%3
  "
  		"7:	clr.l	(%2)+
  "
  		"	subq.l	#1,%3
  "
  		"	jne	7b
  "
  		"	lsl.l	#2,%0
  "
  		"	btst	#1,%5
  "
  		"	jeq	8f
  "
  		"30:	clr.w	(%2)+
  "
  		"	addq.l	#2,%0
  "
  		"8:	btst	#0,%5
  "
  		"	jeq	6b
  "
  		"50:	clr.b	(%2)+
  "
  		"	addq.l	#1,%0
  "
  		"	jra	6b
  "
  		"	.previous
  "
  		"
  "
  		"	.section __ex_table,\"a\"
  "
  		"	.align	4
  "
  		"	.long	1b,10b
  "
  		"	.long	3b,30b
  "
  		"	.long	5b,50b
  "
  		"	.previous"
  		: "=d" (res), "+a" (from), "+a" (to), "=&d" (tmp)
  		: "0" (n / 4), "d" (n & 3));
  
  	return res;
  }
  EXPORT_SYMBOL(__generic_copy_from_user);
  
  unsigned long __generic_copy_to_user(void __user *to, const void *from,
  				     unsigned long n)
  {
  	unsigned long tmp, res;
  
  	asm volatile ("
  "
  		"	tst.l	%0
  "
  		"	jeq	4f
  "
  		"1:	move.l	(%1)+,%3
  "
  		"2:	"MOVES".l	%3,(%2)+
  "
  		"3:	subq.l	#1,%0
  "
  		"	jne	1b
  "
  		"4:	btst	#1,%5
  "
  		"	jeq	6f
  "
  		"	move.w	(%1)+,%3
  "
  		"5:	"MOVES".w	%3,(%2)+
  "
  		"6:	btst	#0,%5
  "
  		"	jeq	8f
  "
  		"	move.b	(%1)+,%3
  "
  		"7:	"MOVES".b  %3,(%2)+
  "
  		"8:
  "
  		"	.section .fixup,\"ax\"
  "
  		"	.even
  "
  		"20:	lsl.l	#2,%0
  "
  		"50:	add.l	%5,%0
  "
  		"	jra	8b
  "
  		"	.previous
  "
  		"
  "
  		"	.section __ex_table,\"a\"
  "
  		"	.align	4
  "
  		"	.long	2b,20b
  "
  		"	.long	3b,20b
  "
  		"	.long	5b,50b
  "
  		"	.long	6b,50b
  "
  		"	.long	7b,50b
  "
  		"	.long	8b,50b
  "
  		"	.previous"
  		: "=d" (res), "+a" (from), "+a" (to), "=&d" (tmp)
  		: "0" (n / 4), "d" (n & 3));
  
  	return res;
  }
  EXPORT_SYMBOL(__generic_copy_to_user);
  
  /*
   * Zero Userspace
   */
  
  unsigned long __clear_user(void __user *to, unsigned long n)
  {
  	unsigned long res;
  
  	asm volatile ("
  "
  		"	tst.l	%0
  "
  		"	jeq	3f
  "
  		"1:	"MOVES".l	%2,(%1)+
  "
  		"2:	subq.l	#1,%0
  "
  		"	jne	1b
  "
  		"3:	btst	#1,%4
  "
  		"	jeq	5f
  "
  		"4:	"MOVES".w	%2,(%1)+
  "
  		"5:	btst	#0,%4
  "
  		"	jeq	7f
  "
  		"6:	"MOVES".b	%2,(%1)
  "
  		"7:
  "
  		"	.section .fixup,\"ax\"
  "
  		"	.even
  "
  		"10:	lsl.l	#2,%0
  "
  		"40:	add.l	%4,%0
  "
  		"	jra	7b
  "
  		"	.previous
  "
  		"
  "
  		"	.section __ex_table,\"a\"
  "
  		"	.align	4
  "
  		"	.long	1b,10b
  "
  		"	.long	2b,10b
  "
  		"	.long	4b,40b
  "
  		"	.long	5b,40b
  "
  		"	.long	6b,40b
  "
  		"	.long	7b,40b
  "
  		"	.previous"
  		: "=d" (res), "+a" (to)
  		: "d" (0), "0" (n / 4), "d" (n & 3));
  
      return res;
  }
  EXPORT_SYMBOL(__clear_user);