]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm/arm/bus_space_asm_generic.S
Add 'contrib/unifdef/' from commit '0da44885831dc0a43c4ca6ff04a2430993cc0a80'
[FreeBSD/FreeBSD.git] / sys / arm / arm / bus_space_asm_generic.S
1 /*      $NetBSD: bus_space_asm_generic.S,v 1.3 2003/03/27 19:46:14 mycroft Exp $        */
2
3 /*-
4  * Copyright (c) 1997 Causality Limited.
5  * Copyright (c) 1997 Mark Brinicombe.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Mark Brinicombe
19  *      for the NetBSD Project.
20  * 4. The name of the company nor the name of the author may be used to
21  *    endorse or promote products derived from this software without specific
22  *    prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  */
37
38 #include <machine/asm.h>
39 /*
40  * Generic bus_space functions.
41  */
42
43 /*
44  * read single
45  */
46
47 ENTRY(generic_bs_r_1)
48         ldrb    r0, [r1, r2]
49         RET
50 END(generic_bs_r_1)
51
52 ENTRY(generic_bs_r_2)
53         ldrh    r0, [r1, r2]
54         RET
55 END(generic_bs_r_2)
56
57 ENTRY(generic_bs_r_4)
58         ldr     r0, [r1, r2]
59         RET
60 END(generic_bs_r_4)
61
62 /*
63  * write single
64  */
65
66 ENTRY(generic_bs_w_1)
67         strb    r3, [r1, r2]
68         RET
69 END(generic_bs_w_1)
70
71 ENTRY(generic_bs_w_2)
72         strh    r3, [r1, r2]
73         RET
74 END(generic_bs_w_2)
75
76 ENTRY(generic_bs_w_4)
77         str     r3, [r1, r2]
78         RET
79 END(generic_bs_w_4)
80
81 /*
82  * read multiple
83  */
84
85 ENTRY(generic_bs_rm_1)
86         add     r0, r1, r2
87         mov     r1, r3
88         ldr     r2, [sp, #0]
89         teq     r2, #0
90         RETeq
91
92 1:      ldrb    r3, [r0]
93         strb    r3, [r1], #1
94         subs    r2, r2, #1
95         bne     1b
96
97         RET
98 END(generic_bs_rm_1)
99
100 ENTRY(generic_bs_rm_2)
101         add     r0, r1, r2
102         mov     r1, r3
103         ldr     r2, [sp, #0]
104         teq     r2, #0
105         RETeq
106
107 1:      ldrh    r3, [r0]
108         strh    r3, [r1], #2
109         subs    r2, r2, #1
110         bne     1b
111
112         RET
113 END(generic_bs_rm_2)
114
115 ENTRY(generic_bs_rm_4)
116         add     r0, r1, r2
117         mov     r1, r3
118         ldr     r2, [sp, #0]
119         teq     r2, #0
120         RETeq
121
122 1:      ldr     r3, [r0]
123         str     r3, [r1], #4
124         subs    r2, r2, #1
125         bne     1b
126
127         RET
128 END(generic_bs_rm_4)
129
130 /*
131  * write multiple
132  */
133
134 ENTRY(generic_bs_wm_1)
135         add     r0, r1, r2
136         mov     r1, r3
137         ldr     r2, [sp, #0]
138         teq     r2, #0
139         RETeq
140
141 1:      ldrb    r3, [r1], #1
142         strb    r3, [r0]
143         subs    r2, r2, #1
144         bne     1b
145
146         RET
147 END(generic_bs_wm_1)
148
149 ENTRY(generic_bs_wm_2)
150         add     r0, r1, r2
151         mov     r1, r3
152         ldr     r2, [sp, #0]
153         teq     r2, #0
154         RETeq
155
156 1:      ldrh    r3, [r1], #2
157         strh    r3, [r0]
158         subs    r2, r2, #1
159         bne     1b
160
161         RET
162 END(generic_bs_wm_2)
163
164 ENTRY(generic_bs_wm_4)
165         add     r0, r1, r2
166         mov     r1, r3
167         ldr     r2, [sp, #0]
168         teq     r2, #0
169         RETeq
170
171 1:      ldr     r3, [r1], #4
172         str     r3, [r0]
173         subs    r2, r2, #1
174         bne     1b
175
176         RET
177 END(generic_bs_wm_4)
178
179 /*
180  * read region
181  */
182
183 ENTRY(generic_bs_rr_1)
184         add     r0, r1, r2
185         mov     r1, r3
186         ldr     r2, [sp, #0]
187         teq     r2, #0
188         RETeq
189
190 1:      ldrb    r3, [r0], #1
191         strb    r3, [r1], #1
192         subs    r2, r2, #1
193         bne     1b
194
195         RET
196 END(generic_bs_rr_1)
197
198 ENTRY(generic_bs_rr_2)
199         add     r0, r1, r2
200         mov     r1, r3
201         ldr     r2, [sp, #0]
202         teq     r2, #0
203         RETeq
204
205 1:      ldrh    r3, [r0], #2
206         strh    r3, [r1], #2
207         subs    r2, r2, #1
208         bne     1b
209
210         RET
211 END(generic_bs_rr_2)
212
213 ENTRY(generic_bs_rr_4)
214         add     r0, r1, r2
215         mov     r1, r3
216         ldr     r2, [sp, #0]
217         teq     r2, #0
218         RETeq
219
220 1:      ldr     r3, [r0], #4
221         str     r3, [r1], #4
222         subs    r2, r2, #1
223         bne     1b
224
225         RET
226 END(generic_bs_rr_4)
227
228 /*
229  * write region.
230  */
231
232 ENTRY(generic_bs_wr_1)
233         add     r0, r1, r2
234         mov     r1, r3
235         ldr     r2, [sp, #0]
236         teq     r2, #0
237         RETeq
238
239 1:      ldrb    r3, [r1], #1
240         strb    r3, [r0], #1
241         subs    r2, r2, #1
242         bne     1b
243
244         RET
245 END(generic_bs_wr_1)
246
247 ENTRY(generic_bs_wr_2)
248         add     r0, r1, r2
249         mov     r1, r3
250         ldr     r2, [sp, #0]
251         teq     r2, #0
252         RETeq
253
254 1:      ldrh    r3, [r1], #2
255         strh    r3, [r0], #2
256         subs    r2, r2, #1
257         bne     1b
258
259         RET
260 END(generic_bs_wr_2)
261
262 ENTRY(generic_bs_wr_4)
263         add     r0, r1, r2
264         mov     r1, r3
265         ldr     r2, [sp, #0]
266         teq     r2, #0
267         RETeq
268
269 1:      ldr     r3, [r1], #4
270         str     r3, [r0], #4
271         subs    r2, r2, #1
272         bne     1b
273
274         RET
275 END(generic_bs_wr_4)
276
277 /*
278  * set region
279  */
280
281 ENTRY(generic_bs_sr_1)
282         add     r0, r1, r2
283         mov     r1, r3
284         ldr     r2, [sp, #0]
285         teq     r2, #0
286         RETeq
287
288 1:      strb    r1, [r0], #1
289         subs    r2, r2, #1
290         bne     1b
291
292         RET
293 END(generic_bs_sr_1)
294
295 ENTRY(generic_bs_sr_2)
296         add     r0, r1, r2
297         mov     r1, r3
298         ldr     r2, [sp, #0]
299         teq     r2, #0
300         RETeq
301
302 1:      strh    r1, [r0], #2
303         subs    r2, r2, #1
304         bne     1b
305
306         RET
307 END(generic_bs_sr_2)
308
309 ENTRY(generic_bs_sr_4)
310         add     r0, r1, r2
311         mov     r1, r3
312         ldr     r2, [sp, #0]
313         teq     r2, #0
314         RETeq
315
316 1:      str     r1, [r0], #4
317         subs    r2, r2, #1
318         bne     1b
319
320         RET
321 END(generic_bs_sr_4)
322
323 /*
324  * copy region
325  */
326
327 ENTRY(generic_bs_c_2)
328         add     r0, r1, r2
329         ldr     r2, [sp, #0]
330         add     r1, r2, r3
331         ldr     r2, [sp, #4]
332         teq     r2, #0
333         RETeq
334
335         cmp     r0, r1
336         blt     2f
337
338 1:      ldrh    r3, [r0], #2
339         strh    r3, [r1], #2
340         subs    r2, r2, #1
341         bne     1b
342
343         RET
344
345 2:      add     r0, r0, r2, lsl #1
346         add     r1, r1, r2, lsl #1
347         sub     r0, r0, #2
348         sub     r1, r1, #2
349
350 3:      ldrh    r3, [r0], #-2
351         strh    r3, [r1], #-2
352         subs    r2, r2, #1
353         bne     3b
354
355         RET
356 END(generic_bs_c_2)
357