]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm64/arm64/bus_space_asm.S
arm64: Mask non-debug exceptions when single stepping
[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 ENTRY(generic_bs_r_1)
30         ldrb    w0, [x1, x2]
31         ret
32 END(generic_bs_r_1)
33
34 ENTRY(generic_bs_r_2)
35         ldrh    w0, [x1, x2]
36         ret
37 END(generic_bs_r_2)
38
39 ENTRY(generic_bs_r_4)
40         ldr     w0, [x1, x2]
41         ret
42 END(generic_bs_r_4)
43
44 ENTRY(generic_bs_r_8)
45         ldr     x0, [x1, x2]
46         ret
47 END(generic_bs_r_8)
48
49 ENTRY(generic_bs_rm_1)
50         /* If there is anything to read. */
51         cbz     x4, 2f
52
53         /* Calculate the device address. */
54         add     x0, x1, x2
55         /*
56          * x0 = The device address.
57          * x3 = The kernel address.
58          * x4 = Count
59          */
60
61         /* Read the data. */
62 1:      ldrb    w1, [x0]
63         strb    w1, [x3], #1
64         subs    x4, x4, #1
65         b.ne    1b
66
67 2:      ret
68 END(generic_bs_rm_1)
69
70 ENTRY(generic_bs_rm_2)
71         /* If there is anything to read. */
72         cbz     x4, 2f
73
74         /* Calculate the device address. */
75         add     x0, x1, x2
76         /*
77          * x0 = The device address.
78          * x3 = The kernel address.
79          * x4 = Count
80          */
81
82         /* Read the data. */
83 1:      ldrh    w1, [x0]
84         strh    w1, [x3], #2
85         subs    x4, x4, #1
86         b.ne    1b
87
88 2:      ret
89 END(generic_bs_rm_2)
90
91 ENTRY(generic_bs_rm_4)
92         /* If there is anything to read. */
93         cbz     x4, 2f
94
95         /* Calculate the device address. */
96         add     x0, x1, x2
97         /*
98          * x0 = The device address.
99          * x3 = The kernel address.
100          * x4 = Count
101          */
102
103         /* Read the data. */
104 1:      ldr     w1, [x0]
105         str     w1, [x3], #4
106         subs    x4, x4, #1
107         b.ne    1b
108
109 2:      ret
110 END(generic_bs_rm_4)
111
112 ENTRY(generic_bs_rm_8)
113         /* If there is anything to read. */
114         cbz     x4, 2f
115
116         /* Calculate the device address. */
117         add     x0, x1, x2
118         /*
119          * x0 = The device address.
120          * x3 = The kernel address.
121          * x4 = Count
122          */
123
124         /* Read the data. */
125 1:      ldr     x1, [x0]
126         str     x1, [x3], #8
127         subs    x4, x4, #1
128         b.ne    1b
129
130 2:      ret
131 END(generic_bs_rm_8)
132
133 ENTRY(generic_bs_rr_1)
134         /* Is there is anything to read. */
135         cbz     x4, 2f
136
137         /* Calculate the device address. */
138         add     x0, x1, x2
139         /*
140          * x0 = The device address.
141          * x3 = The kernel address.
142          * x4 = Count
143          */
144
145         /* Read the data. */
146 1:      ldrb    w1, [x0], #1
147         strb    w1, [x3], #1
148         subs    x4, x4, #1
149         b.ne    1b
150
151 2:      ret
152 END(generic_bs_rr_1)
153
154 ENTRY(generic_bs_rr_2)
155         /* Is there is anything to read. */
156         cbz     x4, 2f
157
158         /* Calculate the device address. */
159         add     x0, x1, x2
160         /*
161          * x0 = The device address.
162          * x3 = The kernel address.
163          * x4 = Count
164          */
165
166         /* Read the data. */
167 1:      ldrh    w1, [x0], #2
168         strh    w1, [x3], #2
169         subs    x4, x4, #1
170         b.ne    1b
171
172 2:      ret
173 END(generic_bs_rr_2)
174
175 ENTRY(generic_bs_rr_4)
176         /* Is there is anything to read. */
177         cbz     x4, 2f
178
179         /* Calculate the device address. */
180         add     x0, x1, x2
181         /*
182          * x0 = The device address.
183          * x3 = The kernel address.
184          * x4 = Count
185          */
186
187         /* Read the data. */
188 1:      ldr     w1, [x0], #4
189         str     w1, [x3], #4
190         subs    x4, x4, #1
191         b.ne    1b
192
193 2:      ret
194 END(generic_bs_rr_4)
195
196 ENTRY(generic_bs_rr_8)
197         /* Is there is anything to read. */
198         cbz     x4, 2f
199
200         /* Calculate the device address. */
201         add     x0, x1, x2
202         /*
203          * x0 = The device address.
204          * x3 = The kernel address.
205          * x4 = Count
206          */
207
208         /* Read the data. */
209 1:      ldr     x1, [x0], #8
210         str     x1, [x3], #8
211         subs    x4, x4, #1
212         b.ne    1b
213
214 2:      ret
215 END(generic_bs_rr_8)
216
217
218 ENTRY(generic_bs_w_1)
219         strb    w3, [x1, x2]
220         ret
221 END(generic_bs_w_1)
222
223 ENTRY(generic_bs_w_2)
224         strh    w3, [x1, x2]
225         ret
226 END(generic_bs_w_2)
227
228 ENTRY(generic_bs_w_4)
229         str     w3, [x1, x2]
230         ret
231 END(generic_bs_w_4)
232
233 ENTRY(generic_bs_w_8)
234         str     x3, [x1, x2]
235         ret
236 END(generic_bs_w_8)
237
238 ENTRY(generic_bs_wm_1)
239         /* If there is anything to write. */
240         cbz     x4, 2f
241
242         add     x0, x1, x2
243         /*
244          * x0 = The device address.
245          * x3 = The kernel address.
246          * x4 = Count
247          */
248
249         /* Write the data */
250 1:      ldrb    w1, [x3], #1
251         strb    w1, [x0]
252         subs    x4, x4, #1
253         b.ne    1b
254
255 2:      ret
256 END(generic_bs_wm_1)
257
258 ENTRY(generic_bs_wm_2)
259         /* If there is anything to write. */
260         cbz     x4, 2f
261
262         add     x0, x1, x2
263         /*
264          * x0 = The device address.
265          * x3 = The kernel address.
266          * x4 = Count
267          */
268
269         /* Write the data */
270 1:      ldrh    w1, [x3], #2
271         strh    w1, [x0]
272         subs    x4, x4, #1
273         b.ne    1b
274
275 2:      ret
276 END(generic_bs_wm_2)
277
278 ENTRY(generic_bs_wm_4)
279         /* If there is anything to write. */
280         cbz     x4, 2f
281
282         add     x0, x1, x2
283         /*
284          * x0 = The device address.
285          * x3 = The kernel address.
286          * x4 = Count
287          */
288
289         /* Write the data */
290 1:      ldr     w1, [x3], #4
291         str     w1, [x0]
292         subs    x4, x4, #1
293         b.ne    1b
294
295 2:      ret
296 END(generic_bs_wm_4)
297
298 ENTRY(generic_bs_wm_8)
299         /* If there is anything to write. */
300         cbz     x4, 2f
301
302         add     x0, x1, x2
303         /*
304          * x0 = The device address.
305          * x3 = The kernel address.
306          * x4 = Count
307          */
308
309         /* Write the data */
310 1:      ldr     x1, [x3], #8
311         str     x1, [x0]
312         subs    x4, x4, #1
313         b.ne    1b
314
315 2:      ret
316 END(generic_bs_wm_8)
317
318 ENTRY(generic_bs_wr_1)
319         /* Is there is anything to write. */
320         cbz     x4, 2f
321         
322         add     x0, x1, x2
323         /*
324          * x0 = The device address.
325          * x3 = The kernel address.
326          * x4 = Count
327          */
328
329         /* Write the data */
330 1:      ldrb    w1, [x3], #1
331         strb    w1, [x0], #1
332         subs    x4, x4, #1
333         b.ne    1b
334
335 2:      ret
336 END(generic_bs_wr_1)
337
338 ENTRY(generic_bs_wr_2)
339         /* Is there is anything to write. */
340         cbz     x4, 2f
341         
342         add     x0, x1, x2
343         /*
344          * x0 = The device address.
345          * x3 = The kernel address.
346          * x4 = Count
347          */
348
349         /* Write the data */
350 1:      ldrh    w1, [x3], #2
351         strh    w1, [x0], #2
352         subs    x4, x4, #1
353         b.ne    1b
354
355 2:      ret
356 END(generic_bs_wr_2)
357
358 ENTRY(generic_bs_wr_4)
359         /* Is there is anything to write. */
360         cbz     x4, 2f
361         
362         add     x0, x1, x2
363         /*
364          * x0 = The device address.
365          * x3 = The kernel address.
366          * x4 = Count
367          */
368
369         /* Write the data */
370 1:      ldr     w1, [x3], #4
371         str     w1, [x0], #4
372         subs    x4, x4, #1
373         b.ne    1b
374
375 2:      ret
376 END(generic_bs_wr_4)
377
378 ENTRY(generic_bs_wr_8)
379         /* Is there is anything to write. */
380         cbz     x4, 2f
381         
382         add     x0, x1, x2
383         /*
384          * x0 = The device address.
385          * x3 = The kernel address.
386          * x4 = Count
387          */
388
389         /* Write the data */
390 1:      ldr     x1, [x3], #8
391         str     x1, [x0], #8
392         subs    x4, x4, #1
393         b.ne    1b
394
395 2:      ret
396 END(generic_bs_wr_8)
397
398 ENTRY(generic_bs_fault)
399         mov     x0, #-1
400         ret
401 END(generic_bs_fault)
402
403 ENTRY(generic_bs_peek_1)
404         .globl  generic_bs_peek_1f
405 generic_bs_peek_1f:
406         ldrb    w0, [x1, x2]    /* Checked instruction */
407         dsb     sy
408         strb    w0,[x3]
409         mov     x0, #0
410         ret
411 END(generic_bs_peek_1)
412
413 ENTRY(generic_bs_peek_2)
414         .globl  generic_bs_peek_2f
415 generic_bs_peek_2f:
416         ldrh    w0, [x1, x2]    /* Checked instruction */
417         dsb     sy
418         strh    w0,[x3]
419         mov     x0, #0
420         ret
421 END(generic_bs_peek_2)
422
423 ENTRY(generic_bs_peek_4)
424         .globl  generic_bs_peek_4f
425 generic_bs_peek_4f:
426         ldr     w0, [x1, x2]    /* Checked instruction */
427         dsb     sy
428         str     w0,[x3]
429         mov     x0, #0
430         ret
431 END(generic_bs_peek_4)
432
433 ENTRY(generic_bs_peek_8)
434         .globl  generic_bs_peek_8f
435 generic_bs_peek_8f:
436         ldr     x0, [x1, x2]    /* Checked instruction */
437         dsb     sy
438         str     x0,[x3]
439         mov     x0, #0
440         ret
441 END(generic_bs_peek_8)
442
443 ENTRY(generic_bs_poke_1)
444         .globl  generic_bs_poke_1f
445 generic_bs_poke_1f:
446         strb    w3, [x1, x2]    /* Checked instruction */
447         dsb     sy
448         mov     x0, #0
449         ret
450 END(generic_bs_poke_1)
451
452 ENTRY(generic_bs_poke_2)
453         .globl  generic_bs_poke_2f
454 generic_bs_poke_2f:
455         strh    w3, [x1, x2]    /* Checked instruction */
456         dsb     sy
457         mov     x0, #0
458         ret
459 END(generic_bs_poke_2)
460
461 ENTRY(generic_bs_poke_4)
462         .globl  generic_bs_poke_4f
463 generic_bs_poke_4f:
464         str     w3, [x1, x2]    /* Checked instruction */
465         dsb     sy
466         mov     x0, #0
467         ret
468 END(generic_bs_poke_4)
469
470 ENTRY(generic_bs_poke_8)
471         .globl  generic_bs_poke_8f
472 generic_bs_poke_8f:
473         str     x3, [x1, x2]    /* Checked instruction */
474         dsb     sy
475         mov     x0, #0
476         ret
477 END(generic_bs_poke_8)