xref: /freebsd/sys/arm64/arm64/bus_space_asm.S (revision 0957b409)
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
32ENTRY(generic_bs_r_1)
33	ldrb	w0, [x1, x2]
34	ret
35END(generic_bs_r_1)
36
37ENTRY(generic_bs_r_2)
38	ldrh	w0, [x1, x2]
39	ret
40END(generic_bs_r_2)
41
42ENTRY(generic_bs_r_4)
43	ldr	w0, [x1, x2]
44	ret
45END(generic_bs_r_4)
46
47ENTRY(generic_bs_r_8)
48	ldr	x0, [x1, x2]
49	ret
50END(generic_bs_r_8)
51
52ENTRY(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. */
651:	ldrb	w1, [x0]
66	strb	w1, [x3], #1
67	subs	x4, x4, #1
68	b.ne	1b
69
702:	ret
71END(generic_bs_rm_1)
72
73ENTRY(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. */
861:	ldrh	w1, [x0]
87	strh	w1, [x3], #2
88	subs	x4, x4, #1
89	b.ne	1b
90
912:	ret
92END(generic_bs_rm_2)
93
94ENTRY(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. */
1071:	ldr	w1, [x0]
108	str	w1, [x3], #4
109	subs	x4, x4, #1
110	b.ne	1b
111
1122:	ret
113END(generic_bs_rm_4)
114
115ENTRY(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. */
1281:	ldr	x1, [x0]
129	str	x1, [x3], #8
130	subs	x4, x4, #1
131	b.ne	1b
132
1332:	ret
134END(generic_bs_rm_8)
135
136ENTRY(generic_bs_rr_1)
137	/* Is there is anything to read. */
138	cbz	x4, 2f
139
140	/* Calculate the device address. */
141	add	x0, x1, x2
142	/*
143	 * x0 = The device address.
144	 * x3 = The kernel address.
145	 * x4 = Count
146	 */
147
148	/* Read the data. */
1491:	ldrb	w1, [x0], #1
150	strb	w1, [x3], #1
151	subs	x4, x4, #1
152	b.ne	1b
153
1542:	ret
155END(generic_bs_rr_1)
156
157ENTRY(generic_bs_rr_2)
158	/* Is there is anything to read. */
159	cbz	x4, 2f
160
161	/* Calculate the device address. */
162	add	x0, x1, x2
163	/*
164	 * x0 = The device address.
165	 * x3 = The kernel address.
166	 * x4 = Count
167	 */
168
169	/* Read the data. */
1701:	ldrh	w1, [x0], #2
171	strh	w1, [x3], #2
172	subs	x4, x4, #1
173	b.ne	1b
174
1752:	ret
176END(generic_bs_rr_2)
177
178ENTRY(generic_bs_rr_4)
179	/* Is there is anything to read. */
180	cbz	x4, 2f
181
182	/* Calculate the device address. */
183	add	x0, x1, x2
184	/*
185	 * x0 = The device address.
186	 * x3 = The kernel address.
187	 * x4 = Count
188	 */
189
190	/* Read the data. */
1911:	ldr	w1, [x0], #4
192	str	w1, [x3], #4
193	subs	x4, x4, #1
194	b.ne	1b
195
1962:	ret
197END(generic_bs_rr_4)
198
199ENTRY(generic_bs_rr_8)
200	/* Is there is anything to read. */
201	cbz	x4, 2f
202
203	/* Calculate the device address. */
204	add	x0, x1, x2
205	/*
206	 * x0 = The device address.
207	 * x3 = The kernel address.
208	 * x4 = Count
209	 */
210
211	/* Read the data. */
2121:	ldr	x1, [x0], #8
213	str	x1, [x3], #8
214	subs	x4, x4, #1
215	b.ne	1b
216
2172:	ret
218END(generic_bs_rr_8)
219
220
221ENTRY(generic_bs_w_1)
222	strb	w3, [x1, x2]
223	ret
224END(generic_bs_w_1)
225
226ENTRY(generic_bs_w_2)
227	strh	w3, [x1, x2]
228	ret
229END(generic_bs_w_2)
230
231ENTRY(generic_bs_w_4)
232	str	w3, [x1, x2]
233	ret
234END(generic_bs_w_4)
235
236ENTRY(generic_bs_w_8)
237	str	x3, [x1, x2]
238	ret
239END(generic_bs_w_8)
240
241ENTRY(generic_bs_wm_1)
242	/* If there is anything to write. */
243	cbz	x4, 2f
244
245	add	x0, x1, x2
246	/*
247	 * x0 = The device address.
248	 * x3 = The kernel address.
249	 * x4 = Count
250	 */
251
252	/* Write the data */
2531:	ldrb	w1, [x3], #1
254	strb	w1, [x0]
255	subs	x4, x4, #1
256	b.ne	1b
257
2582:	ret
259END(generic_bs_wm_1)
260
261ENTRY(generic_bs_wm_2)
262	/* If there is anything to write. */
263	cbz	x4, 2f
264
265	add	x0, x1, x2
266	/*
267	 * x0 = The device address.
268	 * x3 = The kernel address.
269	 * x4 = Count
270	 */
271
272	/* Write the data */
2731:	ldrh	w1, [x3], #2
274	strh	w1, [x0]
275	subs	x4, x4, #1
276	b.ne	1b
277
2782:	ret
279END(generic_bs_wm_2)
280
281ENTRY(generic_bs_wm_4)
282	/* If there is anything to write. */
283	cbz	x4, 2f
284
285	add	x0, x1, x2
286	/*
287	 * x0 = The device address.
288	 * x3 = The kernel address.
289	 * x4 = Count
290	 */
291
292	/* Write the data */
2931:	ldr	w1, [x3], #4
294	str	w1, [x0]
295	subs	x4, x4, #1
296	b.ne	1b
297
2982:	ret
299END(generic_bs_wm_4)
300
301ENTRY(generic_bs_wm_8)
302	/* If there is anything to write. */
303	cbz	x4, 2f
304
305	add	x0, x1, x2
306	/*
307	 * x0 = The device address.
308	 * x3 = The kernel address.
309	 * x4 = Count
310	 */
311
312	/* Write the data */
3131:	ldr	x1, [x3], #8
314	str	x1, [x0]
315	subs	x4, x4, #1
316	b.ne	1b
317
3182:	ret
319END(generic_bs_wm_8)
320
321ENTRY(generic_bs_wr_1)
322	/* Is there is anything to write. */
323	cbz	x4, 2f
324
325	add	x0, x1, x2
326	/*
327	 * x0 = The device address.
328	 * x3 = The kernel address.
329	 * x4 = Count
330	 */
331
332	/* Write the data */
3331:	ldrb	w1, [x3], #1
334	strb	w1, [x0], #1
335	subs	x4, x4, #1
336	b.ne	1b
337
3382:	ret
339END(generic_bs_wr_1)
340
341ENTRY(generic_bs_wr_2)
342	/* Is there is anything to write. */
343	cbz	x4, 2f
344
345	add	x0, x1, x2
346	/*
347	 * x0 = The device address.
348	 * x3 = The kernel address.
349	 * x4 = Count
350	 */
351
352	/* Write the data */
3531:	ldrh	w1, [x3], #2
354	strh	w1, [x0], #2
355	subs	x4, x4, #1
356	b.ne	1b
357
3582:	ret
359END(generic_bs_wr_2)
360
361ENTRY(generic_bs_wr_4)
362	/* Is there is anything to write. */
363	cbz	x4, 2f
364
365	add	x0, x1, x2
366	/*
367	 * x0 = The device address.
368	 * x3 = The kernel address.
369	 * x4 = Count
370	 */
371
372	/* Write the data */
3731:	ldr	w1, [x3], #4
374	str	w1, [x0], #4
375	subs	x4, x4, #1
376	b.ne	1b
377
3782:	ret
379END(generic_bs_wr_4)
380
381ENTRY(generic_bs_wr_8)
382	/* Is there is anything to write. */
383	cbz	x4, 2f
384
385	add	x0, x1, x2
386	/*
387	 * x0 = The device address.
388	 * x3 = The kernel address.
389	 * x4 = Count
390	 */
391
392	/* Write the data */
3931:	ldr	x1, [x3], #8
394	str	x1, [x0], #8
395	subs	x4, x4, #1
396	b.ne	1b
397
3982:	ret
399END(generic_bs_wr_8)
400