]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/arm64/arm64/bus_space_asm.S
Merge from head
[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
30 __FBSDID("$FreeBSD$");
31
32 ENTRY(generic_bs_r_1)
33         ldrb    w0, [x1, x2]
34         ret
35 END(generic_bs_r_1)
36
37 ENTRY(generic_bs_r_2)
38         ldrh    w0, [x1, x2]
39         ret
40 END(generic_bs_r_2)
41
42 ENTRY(generic_bs_r_4)
43         ldr     w0, [x1, x2]
44         ret
45 END(generic_bs_r_4)
46
47 ENTRY(generic_bs_r_8)
48         ldr     x0, [x1, x2]
49         ret
50 END(generic_bs_r_8)
51
52 ENTRY(generic_bs_rm_1)
53         /* If there is anything to read. */
54         cbz     x4, 2f
55
56         /* Calculate the device address. */
57         add     x0, x1, x2
58         /*
59          * x0 = The device address.
60          * x3 = The kernel address.
61          * x4 = Count
62          */
63
64         /* Read the data. */
65 1:      ldrb    w1, [x0]
66         strb    w1, [x3], #1
67         subs    x4, x4, #1
68         b.ne    1b
69
70 2:      ret
71 END(generic_bs_rm_1)
72
73 ENTRY(generic_bs_rm_2)
74         /* If there is anything to read. */
75         cbz     x4, 2f
76
77         /* Calculate the device address. */
78         add     x0, x1, x2
79         /*
80          * x0 = The device address.
81          * x3 = The kernel address.
82          * x4 = Count
83          */
84
85         /* Read the data. */
86 1:      ldrh    w1, [x0]
87         strh    w1, [x3], #2
88         subs    x4, x4, #1
89         b.ne    1b
90
91 2:      ret
92 END(generic_bs_rm_2)
93
94 ENTRY(generic_bs_rm_4)
95         /* If there is anything to read. */
96         cbz     x4, 2f
97
98         /* Calculate the device address. */
99         add     x0, x1, x2
100         /*
101          * x0 = The device address.
102          * x3 = The kernel address.
103          * x4 = Count
104          */
105
106         /* Read the data. */
107 1:      ldr     w1, [x0]
108         str     w1, [x3], #4
109         subs    x4, x4, #1
110         b.ne    1b
111
112 2:      ret
113 END(generic_bs_rm_4)
114
115 ENTRY(generic_bs_rm_8)
116         /* If there is anything to read. */
117         cbz     x4, 2f
118
119         /* Calculate the device address. */
120         add     x0, x1, x2
121         /*
122          * x0 = The device address.
123          * x3 = The kernel address.
124          * x4 = Count
125          */
126
127         /* Read the data. */
128 1:      ldr     x1, [x0]
129         str     x1, [x3], #8
130         subs    x4, x4, #1
131         b.ne    1b
132
133 2:      ret
134 END(generic_bs_rm_8)
135
136
137 ENTRY(generic_bs_w_1)
138         strb    w3, [x1, x2]
139         ret
140 END(generic_bs_w_1)
141
142 ENTRY(generic_bs_w_2)
143         strh    w3, [x1, x2]
144         ret
145 END(generic_bs_w_2)
146
147 ENTRY(generic_bs_w_4)
148         str     w3, [x1, x2]
149         ret
150 END(generic_bs_w_4)
151
152 ENTRY(generic_bs_w_8)
153         str     x3, [x1, x2]
154         ret
155 END(generic_bs_w_8)
156
157 ENTRY(generic_bs_wm_1)
158         /* If there is anything to write. */
159         cbz     x4, 2f
160
161         add     x0, x1, x2
162         /*
163          * x0 = The device address.
164          * x3 = The kernel address.
165          * x4 = Count
166          */
167
168         /* Write the data */
169 1:      ldrb    w1, [x3], #1
170         strb    w1, [x0]
171         subs    x4, x4, #1
172         b.ne    1b
173
174 2:      ret
175 END(generic_bs_wm_1)
176
177 ENTRY(generic_bs_wm_2)
178         /* If there is anything to write. */
179         cbz     x4, 2f
180
181         add     x0, x1, x2
182         /*
183          * x0 = The device address.
184          * x3 = The kernel address.
185          * x4 = Count
186          */
187
188         /* Write the data */
189 1:      ldrh    w1, [x3], #2
190         strh    w1, [x0]
191         subs    x4, x4, #1
192         b.ne    1b
193
194 2:      ret
195 END(generic_bs_wm_2)
196
197 ENTRY(generic_bs_wm_4)
198         /* If there is anything to write. */
199         cbz     x4, 2f
200
201         add     x0, x1, x2
202         /*
203          * x0 = The device address.
204          * x3 = The kernel address.
205          * x4 = Count
206          */
207
208         /* Write the data */
209 1:      ldr     w1, [x3], #4
210         str     w1, [x0]
211         subs    x4, x4, #1
212         b.ne    1b
213
214 2:      ret
215 END(generic_bs_wm_4)
216
217 ENTRY(generic_bs_wm_8)
218         /* If there is anything to write. */
219         cbz     x4, 2f
220
221         add     x0, x1, x2
222         /*
223          * x0 = The device address.
224          * x3 = The kernel address.
225          * x4 = Count
226          */
227
228         /* Write the data */
229 1:      ldr     x1, [x3], #8
230         str     x1, [x0]
231         subs    x4, x4, #1
232         b.ne    1b
233
234 2:      ret
235 END(generic_bs_wm_8)