]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm64/arm64/bus_space_asm.S
zfs: merge openzfs/zfs@8e8acabdc
[FreeBSD/FreeBSD.git] / sys / arm64 / arm64 / bus_space_asm.S
1 /*-
2  * Copyright (c) 2014 Andrew Turner
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  */
27
28 #include <machine/asm.h>
29 __FBSDID("$FreeBSD$");
30
31 ENTRY(generic_bs_r_1)
32         ldrb    w0, [x1, x2]
33         ret
34 END(generic_bs_r_1)
35
36 ENTRY(generic_bs_r_2)
37         ldrh    w0, [x1, x2]
38         ret
39 END(generic_bs_r_2)
40
41 ENTRY(generic_bs_r_4)
42         ldr     w0, [x1, x2]
43         ret
44 END(generic_bs_r_4)
45
46 ENTRY(generic_bs_r_8)
47         ldr     x0, [x1, x2]
48         ret
49 END(generic_bs_r_8)
50
51 ENTRY(generic_bs_rm_1)
52         /* If there is anything to read. */
53         cbz     x4, 2f
54
55         /* Calculate the device address. */
56         add     x0, x1, x2
57         /*
58          * x0 = The device address.
59          * x3 = The kernel address.
60          * x4 = Count
61          */
62
63         /* Read the data. */
64 1:      ldrb    w1, [x0]
65         strb    w1, [x3], #1
66         subs    x4, x4, #1
67         b.ne    1b
68
69 2:      ret
70 END(generic_bs_rm_1)
71
72 ENTRY(generic_bs_rm_2)
73         /* If there is anything to read. */
74         cbz     x4, 2f
75
76         /* Calculate the device address. */
77         add     x0, x1, x2
78         /*
79          * x0 = The device address.
80          * x3 = The kernel address.
81          * x4 = Count
82          */
83
84         /* Read the data. */
85 1:      ldrh    w1, [x0]
86         strh    w1, [x3], #2
87         subs    x4, x4, #1
88         b.ne    1b
89
90 2:      ret
91 END(generic_bs_rm_2)
92
93 ENTRY(generic_bs_rm_4)
94         /* If there is anything to read. */
95         cbz     x4, 2f
96
97         /* Calculate the device address. */
98         add     x0, x1, x2
99         /*
100          * x0 = The device address.
101          * x3 = The kernel address.
102          * x4 = Count
103          */
104
105         /* Read the data. */
106 1:      ldr     w1, [x0]
107         str     w1, [x3], #4
108         subs    x4, x4, #1
109         b.ne    1b
110
111 2:      ret
112 END(generic_bs_rm_4)
113
114 ENTRY(generic_bs_rm_8)
115         /* If there is anything to read. */
116         cbz     x4, 2f
117
118         /* Calculate the device address. */
119         add     x0, x1, x2
120         /*
121          * x0 = The device address.
122          * x3 = The kernel address.
123          * x4 = Count
124          */
125
126         /* Read the data. */
127 1:      ldr     x1, [x0]
128         str     x1, [x3], #8
129         subs    x4, x4, #1
130         b.ne    1b
131
132 2:      ret
133 END(generic_bs_rm_8)
134
135 ENTRY(generic_bs_rr_1)
136         /* Is there is anything to read. */
137         cbz     x4, 2f
138
139         /* Calculate the device address. */
140         add     x0, x1, x2
141         /*
142          * x0 = The device address.
143          * x3 = The kernel address.
144          * x4 = Count
145          */
146
147         /* Read the data. */
148 1:      ldrb    w1, [x0], #1
149         strb    w1, [x3], #1
150         subs    x4, x4, #1
151         b.ne    1b
152
153 2:      ret
154 END(generic_bs_rr_1)
155
156 ENTRY(generic_bs_rr_2)
157         /* Is there is anything to read. */
158         cbz     x4, 2f
159
160         /* Calculate the device address. */
161         add     x0, x1, x2
162         /*
163          * x0 = The device address.
164          * x3 = The kernel address.
165          * x4 = Count
166          */
167
168         /* Read the data. */
169 1:      ldrh    w1, [x0], #2
170         strh    w1, [x3], #2
171         subs    x4, x4, #1
172         b.ne    1b
173
174 2:      ret
175 END(generic_bs_rr_2)
176
177 ENTRY(generic_bs_rr_4)
178         /* Is there is anything to read. */
179         cbz     x4, 2f
180
181         /* Calculate the device address. */
182         add     x0, x1, x2
183         /*
184          * x0 = The device address.
185          * x3 = The kernel address.
186          * x4 = Count
187          */
188
189         /* Read the data. */
190 1:      ldr     w1, [x0], #4
191         str     w1, [x3], #4
192         subs    x4, x4, #1
193         b.ne    1b
194
195 2:      ret
196 END(generic_bs_rr_4)
197
198 ENTRY(generic_bs_rr_8)
199         /* Is there is anything to read. */
200         cbz     x4, 2f
201
202         /* Calculate the device address. */
203         add     x0, x1, x2
204         /*
205          * x0 = The device address.
206          * x3 = The kernel address.
207          * x4 = Count
208          */
209
210         /* Read the data. */
211 1:      ldr     x1, [x0], #8
212         str     x1, [x3], #8
213         subs    x4, x4, #1
214         b.ne    1b
215
216 2:      ret
217 END(generic_bs_rr_8)
218
219
220 ENTRY(generic_bs_w_1)
221         strb    w3, [x1, x2]
222         ret
223 END(generic_bs_w_1)
224
225 ENTRY(generic_bs_w_2)
226         strh    w3, [x1, x2]
227         ret
228 END(generic_bs_w_2)
229
230 ENTRY(generic_bs_w_4)
231         str     w3, [x1, x2]
232         ret
233 END(generic_bs_w_4)
234
235 ENTRY(generic_bs_w_8)
236         str     x3, [x1, x2]
237         ret
238 END(generic_bs_w_8)
239
240 ENTRY(generic_bs_wm_1)
241         /* If there is anything to write. */
242         cbz     x4, 2f
243
244         add     x0, x1, x2
245         /*
246          * x0 = The device address.
247          * x3 = The kernel address.
248          * x4 = Count
249          */
250
251         /* Write the data */
252 1:      ldrb    w1, [x3], #1
253         strb    w1, [x0]
254         subs    x4, x4, #1
255         b.ne    1b
256
257 2:      ret
258 END(generic_bs_wm_1)
259
260 ENTRY(generic_bs_wm_2)
261         /* If there is anything to write. */
262         cbz     x4, 2f
263
264         add     x0, x1, x2
265         /*
266          * x0 = The device address.
267          * x3 = The kernel address.
268          * x4 = Count
269          */
270
271         /* Write the data */
272 1:      ldrh    w1, [x3], #2
273         strh    w1, [x0]
274         subs    x4, x4, #1
275         b.ne    1b
276
277 2:      ret
278 END(generic_bs_wm_2)
279
280 ENTRY(generic_bs_wm_4)
281         /* If there is anything to write. */
282         cbz     x4, 2f
283
284         add     x0, x1, x2
285         /*
286          * x0 = The device address.
287          * x3 = The kernel address.
288          * x4 = Count
289          */
290
291         /* Write the data */
292 1:      ldr     w1, [x3], #4
293         str     w1, [x0]
294         subs    x4, x4, #1
295         b.ne    1b
296
297 2:      ret
298 END(generic_bs_wm_4)
299
300 ENTRY(generic_bs_wm_8)
301         /* If there is anything to write. */
302         cbz     x4, 2f
303
304         add     x0, x1, x2
305         /*
306          * x0 = The device address.
307          * x3 = The kernel address.
308          * x4 = Count
309          */
310
311         /* Write the data */
312 1:      ldr     x1, [x3], #8
313         str     x1, [x0]
314         subs    x4, x4, #1
315         b.ne    1b
316
317 2:      ret
318 END(generic_bs_wm_8)
319
320 ENTRY(generic_bs_wr_1)
321         /* Is there is anything to write. */
322         cbz     x4, 2f
323         
324         add     x0, x1, x2
325         /*
326          * x0 = The device address.
327          * x3 = The kernel address.
328          * x4 = Count
329          */
330
331         /* Write the data */
332 1:      ldrb    w1, [x3], #1
333         strb    w1, [x0], #1
334         subs    x4, x4, #1
335         b.ne    1b
336
337 2:      ret
338 END(generic_bs_wr_1)
339
340 ENTRY(generic_bs_wr_2)
341         /* Is there is anything to write. */
342         cbz     x4, 2f
343         
344         add     x0, x1, x2
345         /*
346          * x0 = The device address.
347          * x3 = The kernel address.
348          * x4 = Count
349          */
350
351         /* Write the data */
352 1:      ldrh    w1, [x3], #2
353         strh    w1, [x0], #2
354         subs    x4, x4, #1
355         b.ne    1b
356
357 2:      ret
358 END(generic_bs_wr_2)
359
360 ENTRY(generic_bs_wr_4)
361         /* Is there is anything to write. */
362         cbz     x4, 2f
363         
364         add     x0, x1, x2
365         /*
366          * x0 = The device address.
367          * x3 = The kernel address.
368          * x4 = Count
369          */
370
371         /* Write the data */
372 1:      ldr     w1, [x3], #4
373         str     w1, [x0], #4
374         subs    x4, x4, #1
375         b.ne    1b
376
377 2:      ret
378 END(generic_bs_wr_4)
379
380 ENTRY(generic_bs_wr_8)
381         /* Is there is anything to write. */
382         cbz     x4, 2f
383         
384         add     x0, x1, x2
385         /*
386          * x0 = The device address.
387          * x3 = The kernel address.
388          * x4 = Count
389          */
390
391         /* Write the data */
392 1:      ldr     x1, [x3], #8
393         str     x1, [x0], #8
394         subs    x4, x4, #1
395         b.ne    1b
396
397 2:      ret
398 END(generic_bs_wr_8)
399
400 ENTRY(generic_bs_fault)
401         mov     x0, #-1
402         ret
403 END(generic_bs_fault)
404
405 ENTRY(generic_bs_peek_1)
406         .globl  generic_bs_peek_1f
407 generic_bs_peek_1f:
408         ldrb    w0, [x1, x2]    /* Checked instruction */
409         dsb     sy
410         strb    w0,[x3]
411         mov     x0, #0
412         ret
413 END(generic_bs_peek_1)
414
415 ENTRY(generic_bs_peek_2)
416         .globl  generic_bs_peek_2f
417 generic_bs_peek_2f:
418         ldrh    w0, [x1, x2]    /* Checked instruction */
419         dsb     sy
420         strh    w0,[x3]
421         mov     x0, #0
422         ret
423 END(generic_bs_peek_2)
424
425 ENTRY(generic_bs_peek_4)
426         .globl  generic_bs_peek_4f
427 generic_bs_peek_4f:
428         ldr     w0, [x1, x2]    /* Checked instruction */
429         dsb     sy
430         str     w0,[x3]
431         mov     x0, #0
432         ret
433 END(generic_bs_peek_4)
434
435 ENTRY(generic_bs_peek_8)
436         .globl  generic_bs_peek_8f
437 generic_bs_peek_8f:
438         ldr     x0, [x1, x2]    /* Checked instruction */
439         dsb     sy
440         str     x0,[x3]
441         mov     x0, #0
442         ret
443 END(generic_bs_peek_8)
444
445 ENTRY(generic_bs_poke_1)
446         .globl  generic_bs_poke_1f
447 generic_bs_poke_1f:
448         strb    w3, [x1, x2]    /* Checked instruction */
449         dsb     sy
450         mov     x0, #0
451         ret
452 END(generic_bs_poke_1)
453
454 ENTRY(generic_bs_poke_2)
455         .globl  generic_bs_poke_2f
456 generic_bs_poke_2f:
457         strh    w3, [x1, x2]    /* Checked instruction */
458         dsb     sy
459         mov     x0, #0
460         ret
461 END(generic_bs_poke_2)
462
463 ENTRY(generic_bs_poke_4)
464         .globl  generic_bs_poke_4f
465 generic_bs_poke_4f:
466         str     w3, [x1, x2]    /* Checked instruction */
467         dsb     sy
468         mov     x0, #0
469         ret
470 END(generic_bs_poke_4)
471
472 ENTRY(generic_bs_poke_8)
473         .globl  generic_bs_poke_8f
474 generic_bs_poke_8f:
475         str     x3, [x1, x2]    /* Checked instruction */
476         dsb     sy
477         mov     x0, #0
478         ret
479 END(generic_bs_poke_8)