be_bus.c revision 1.4
1/*	$NetBSD: be_bus.c,v 1.4 2000/01/19 13:12:54 leo Exp $	*/
2
3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Leo Weppelman.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 *    must display the following acknowledgement:
20 *        This product includes software developed by the NetBSD
21 *        Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 *    contributors may be used to endorse or promote products derived
24 *    from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38#include <sys/types.h>
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/malloc.h>
42#include <machine/cpu.h>
43#include <machine/bus.h>
44
45/*
46 * This file contains the common functions for using a big endian (linear)
47 * bus on a big endian atari.
48 */
49
50	/* Autoconf detection stuff */
51static int		beb_bus_space_peek_1 __P((bus_space_tag_t,
52				bus_space_handle_t, bus_size_t));
53static int		beb_bus_space_peek_2 __P((bus_space_tag_t,
54				bus_space_handle_t, bus_size_t));
55static int		beb_bus_space_peek_4 __P((bus_space_tag_t,
56				bus_space_handle_t, bus_size_t));
57static int		beb_bus_space_peek_8 __P((bus_space_tag_t,
58				bus_space_handle_t, bus_size_t));
59
60	/* read (single) */
61static u_int8_t		beb_bus_space_read_1 __P((bus_space_tag_t,
62				bus_space_handle_t, bus_size_t));
63static u_int16_t	beb_bus_space_read_2 __P((bus_space_tag_t,
64				bus_space_handle_t, bus_size_t));
65static u_int32_t	beb_bus_space_read_4 __P((bus_space_tag_t,
66				bus_space_handle_t, bus_size_t));
67static u_int64_t	beb_bus_space_read_8 __P((bus_space_tag_t,
68				bus_space_handle_t, bus_size_t));
69
70	/* write (single) */
71static void		beb_bus_space_write_1 __P((bus_space_tag_t,
72				bus_space_handle_t, bus_size_t, u_int8_t));
73static void		beb_bus_space_write_2 __P((bus_space_tag_t,
74				bus_space_handle_t, bus_size_t, u_int16_t));
75static void		beb_bus_space_write_4 __P((bus_space_tag_t,
76				bus_space_handle_t, bus_size_t, u_int32_t));
77static void		beb_bus_space_write_8 __P((bus_space_tag_t,
78				bus_space_handle_t, bus_size_t, u_int64_t));
79
80	/* read multiple */
81static void		beb_bus_space_read_multi_1 __P((bus_space_tag_t,
82				bus_space_handle_t, bus_size_t, u_int8_t *,
83				bus_size_t));
84static void		beb_bus_space_read_multi_2 __P((bus_space_tag_t,
85				bus_space_handle_t, bus_size_t, u_int16_t *,
86				bus_size_t));
87static void		beb_bus_space_read_multi_4 __P((bus_space_tag_t,
88				bus_space_handle_t, bus_size_t, u_int32_t *,
89				bus_size_t));
90static void		beb_bus_space_read_multi_8 __P((bus_space_tag_t,
91				bus_space_handle_t, bus_size_t, u_int64_t *,
92				bus_size_t));
93
94	/* write multiple */
95static void		beb_bus_space_write_multi_1 __P((bus_space_tag_t,
96				bus_space_handle_t, bus_size_t,
97				const u_int8_t *, bus_size_t));
98static void		beb_bus_space_write_multi_2 __P((bus_space_tag_t,
99				bus_space_handle_t, bus_size_t,
100				const u_int16_t *, bus_size_t));
101static void		beb_bus_space_write_multi_4 __P((bus_space_tag_t,
102				bus_space_handle_t, bus_size_t,
103				const u_int32_t *, bus_size_t));
104static void		beb_bus_space_write_multi_8 __P((bus_space_tag_t,
105				bus_space_handle_t, bus_size_t,
106				const u_int64_t *, bus_size_t));
107
108	/* read region */
109static void		beb_bus_space_read_region_1 __P((bus_space_tag_t,
110				bus_space_handle_t, bus_size_t, u_int8_t *,
111				bus_size_t));
112static void		beb_bus_space_read_region_2 __P((bus_space_tag_t,
113				bus_space_handle_t, bus_size_t, u_int16_t *,
114				bus_size_t));
115static void		beb_bus_space_read_region_4 __P((bus_space_tag_t,
116				bus_space_handle_t, bus_size_t, u_int32_t *,
117				bus_size_t));
118static void		beb_bus_space_read_region_8 __P((bus_space_tag_t,
119				bus_space_handle_t, bus_size_t, u_int64_t *,
120				bus_size_t));
121
122	/* read region */
123static void		beb_bus_space_write_region_1 __P((bus_space_tag_t,
124				bus_space_handle_t, bus_size_t,
125				const u_int8_t *, bus_size_t));
126static void		beb_bus_space_write_region_2 __P((bus_space_tag_t,
127				bus_space_handle_t, bus_size_t,
128				const u_int16_t *, bus_size_t));
129static void		beb_bus_space_write_region_4 __P((bus_space_tag_t,
130				bus_space_handle_t, bus_size_t,
131				const u_int32_t *, bus_size_t));
132static void		beb_bus_space_write_region_8 __P((bus_space_tag_t,
133				bus_space_handle_t, bus_size_t,
134				const u_int64_t *, bus_size_t));
135
136	/* set multi */
137static void		beb_bus_space_set_multi_1 __P((bus_space_tag_t,
138				bus_space_handle_t, bus_size_t, u_int8_t,
139				bus_size_t));
140static void		beb_bus_space_set_multi_2 __P((bus_space_tag_t,
141				bus_space_handle_t, bus_size_t, u_int16_t,
142				bus_size_t));
143static void		beb_bus_space_set_multi_4 __P((bus_space_tag_t,
144				bus_space_handle_t, bus_size_t, u_int32_t,
145				bus_size_t));
146static void		beb_bus_space_set_multi_8 __P((bus_space_tag_t,
147				bus_space_handle_t, bus_size_t, u_int64_t,
148				bus_size_t));
149
150	/* set region */
151static void		beb_bus_space_set_region_1 __P((bus_space_tag_t,
152				bus_space_handle_t, bus_size_t, u_int8_t,
153				bus_size_t));
154static void		beb_bus_space_set_region_2 __P((bus_space_tag_t,
155				bus_space_handle_t, bus_size_t, u_int16_t,
156				bus_size_t));
157static void		beb_bus_space_set_region_4 __P((bus_space_tag_t,
158				bus_space_handle_t, bus_size_t, u_int32_t,
159				bus_size_t));
160static void		beb_bus_space_set_region_8 __P((bus_space_tag_t,
161				bus_space_handle_t, bus_size_t, u_int64_t,
162				bus_size_t));
163
164/*
165 * Don't force a function call overhead on these primitives...
166 */
167#define __read_1(h, o)		*((u_int8_t  *)((h) + (o)))
168#define __read_2(h, o)		*((u_int16_t *)((h) + (o)))
169#define __read_4(h, o)		*((u_int32_t *)((h) + (o)))
170#define __read_8(h, o)		*((u_int64_t *)((h) + (o)))
171
172#define __write_1(h, o, v)	*((u_int8_t  *)((h) + (o))) = (v)
173#define __write_2(h, o, v)	*((u_int16_t *)((h) + (o))) = (v)
174#define __write_4(h, o, v)	*((u_int32_t *)((h) + (o))) = (v)
175#define __write_8(h, o, v)	*((u_int64_t *)((h) + (o))) = (v)
176
177bus_space_tag_t
178beb_alloc_bus_space_tag(storage)
179bus_space_tag_t	storage;
180{
181	bus_space_tag_t	beb_t;
182
183	/*
184	 * Allow the caller to specify storage space for the tag. This
185	 * is used during console config (when malloc() can't be used).
186	 */
187	if (storage != NULL)
188		beb_t = storage;
189	else {
190	    if ((beb_t = malloc(sizeof(*beb_t), M_TEMP, M_NOWAIT)) == NULL)
191		return(NULL);
192	}
193	bzero(beb_t, sizeof(*beb_t));
194
195	beb_t->abs_p_1   = beb_bus_space_peek_1;
196	beb_t->abs_p_2   = beb_bus_space_peek_2;
197	beb_t->abs_p_4   = beb_bus_space_peek_4;
198	beb_t->abs_p_8   = beb_bus_space_peek_8;
199	beb_t->abs_r_1   = beb_bus_space_read_1;
200	beb_t->abs_r_2   = beb_bus_space_read_2;
201	beb_t->abs_r_4   = beb_bus_space_read_4;
202	beb_t->abs_r_8   = beb_bus_space_read_8;
203	beb_t->abs_rs_1  = beb_bus_space_read_1;
204	beb_t->abs_rs_2  = beb_bus_space_read_2;
205	beb_t->abs_rs_4  = beb_bus_space_read_4;
206	beb_t->abs_rs_8  = beb_bus_space_read_8;
207	beb_t->abs_rm_1  = beb_bus_space_read_multi_1;
208	beb_t->abs_rm_2  = beb_bus_space_read_multi_2;
209	beb_t->abs_rm_4  = beb_bus_space_read_multi_4;
210	beb_t->abs_rm_8  = beb_bus_space_read_multi_8;
211	beb_t->abs_rms_1 = beb_bus_space_read_multi_1;
212	beb_t->abs_rms_2 = beb_bus_space_read_multi_2;
213	beb_t->abs_rms_4 = beb_bus_space_read_multi_4;
214	beb_t->abs_rms_8 = beb_bus_space_read_multi_8;
215	beb_t->abs_rr_1  = beb_bus_space_read_region_1;
216	beb_t->abs_rr_2  = beb_bus_space_read_region_2;
217	beb_t->abs_rr_4  = beb_bus_space_read_region_4;
218	beb_t->abs_rr_8  = beb_bus_space_read_region_8;
219	beb_t->abs_rrs_1 = beb_bus_space_read_region_1;
220	beb_t->abs_rrs_2 = beb_bus_space_read_region_2;
221	beb_t->abs_rrs_4 = beb_bus_space_read_region_4;
222	beb_t->abs_rrs_8 = beb_bus_space_read_region_8;
223	beb_t->abs_w_1   = beb_bus_space_write_1;
224	beb_t->abs_w_2   = beb_bus_space_write_2;
225	beb_t->abs_w_4   = beb_bus_space_write_4;
226	beb_t->abs_w_8   = beb_bus_space_write_8;
227	beb_t->abs_ws_1  = beb_bus_space_write_1;
228	beb_t->abs_ws_2  = beb_bus_space_write_2;
229	beb_t->abs_ws_4  = beb_bus_space_write_4;
230	beb_t->abs_ws_8  = beb_bus_space_write_8;
231	beb_t->abs_wm_1  = beb_bus_space_write_multi_1;
232	beb_t->abs_wm_2  = beb_bus_space_write_multi_2;
233	beb_t->abs_wm_4  = beb_bus_space_write_multi_4;
234	beb_t->abs_wm_8  = beb_bus_space_write_multi_8;
235	beb_t->abs_wms_1 = beb_bus_space_write_multi_1;
236	beb_t->abs_wms_2 = beb_bus_space_write_multi_2;
237	beb_t->abs_wms_4 = beb_bus_space_write_multi_4;
238	beb_t->abs_wms_8 = beb_bus_space_write_multi_8;
239	beb_t->abs_wr_1  = beb_bus_space_write_region_1;
240	beb_t->abs_wr_2  = beb_bus_space_write_region_2;
241	beb_t->abs_wr_4  = beb_bus_space_write_region_4;
242	beb_t->abs_wr_8  = beb_bus_space_write_region_8;
243	beb_t->abs_wrs_1 = beb_bus_space_write_region_1;
244	beb_t->abs_wrs_2 = beb_bus_space_write_region_2;
245	beb_t->abs_wrs_4 = beb_bus_space_write_region_4;
246	beb_t->abs_wrs_8 = beb_bus_space_write_region_8;
247	beb_t->abs_sm_1  = beb_bus_space_set_multi_1;
248	beb_t->abs_sm_2  = beb_bus_space_set_multi_2;
249	beb_t->abs_sm_4  = beb_bus_space_set_multi_4;
250	beb_t->abs_sm_8  = beb_bus_space_set_multi_8;
251	beb_t->abs_sr_1  = beb_bus_space_set_region_1;
252	beb_t->abs_sr_2  = beb_bus_space_set_region_2;
253	beb_t->abs_sr_4  = beb_bus_space_set_region_4;
254	beb_t->abs_sr_8  = beb_bus_space_set_region_8;
255
256	return(beb_t);
257}
258
259
260/*
261 * The various access functions
262 */
263
264/*
265 *	int bus_space_peek_N __P((bus_space_tag_t tag,
266 *		bus_space_handle_t sh, bus_size_t offset));
267 *
268 * Check if the address is suitable for reading N-byte quantities.
269 */
270static int
271beb_bus_space_peek_1(t, h, o)
272    bus_space_tag_t	t;
273    bus_space_handle_t	h;
274    bus_size_t		o;
275{
276    return(!badbaddr((caddr_t)(h + o), 1));
277}
278
279static int
280beb_bus_space_peek_2(t, h, o)
281    bus_space_tag_t	t;
282    bus_space_handle_t	h;
283    bus_size_t		o;
284{
285    return(!badbaddr((caddr_t)(h + o), 2));
286}
287
288static int
289beb_bus_space_peek_4(t, h, o)
290    bus_space_tag_t	t;
291    bus_space_handle_t	h;
292    bus_size_t		o;
293{
294    return(!badbaddr((caddr_t)(h + o), 4));
295}
296
297static int
298beb_bus_space_peek_8(t, h, o)
299    bus_space_tag_t	t;
300    bus_space_handle_t	h;
301    bus_size_t		o;
302{
303    return(!badbaddr((caddr_t)(h + o), 8));
304}
305
306/*
307 *	u_intX_t bus_space_read_N __P((bus_space_tag_t tag,
308 *		bus_space_handle_t bsh, bus_size_t offset));
309 *
310 * Return an 1, 2, 4, or 8 byte value read from the bus_space described
311 * by tag/handle at `offset'. The value is converted to host-endian.
312 */
313static u_int8_t
314beb_bus_space_read_1(t, h, o)
315    bus_space_tag_t	t;
316    bus_space_handle_t	h;
317    bus_size_t		o;
318{
319    return(__read_1(h, o));
320}
321
322static u_int16_t
323beb_bus_space_read_2(t, h, o)
324    bus_space_tag_t	t;
325    bus_space_handle_t	h;
326    bus_size_t		o;
327{
328    return(__read_2(h, o));
329}
330
331static u_int32_t
332beb_bus_space_read_4(t, h, o)
333    bus_space_tag_t	t;
334    bus_space_handle_t	h;
335    bus_size_t		o;
336{
337    return(__read_4(h, o));
338}
339
340static u_int64_t
341beb_bus_space_read_8(t, h, o)
342    bus_space_tag_t	t;
343    bus_space_handle_t	h;
344    bus_size_t		o;
345{
346    return(__read_8(h, o));
347}
348
349/*
350 *	u_intX_t bus_space_write_N __P((bus_space_tag_t tag,
351 *		bus_space_handle_t bsh, bus_size_t offset, u_intX_t val));
352 *
353 * Write an 1, 2, 4, or 8 byte value to the bus_space described by tag/handle
354 * at `offset'. The value `val' is converted from host to bus endianness
355 * before being written.
356 */
357static void
358beb_bus_space_write_1(t, h, o, v)
359    bus_space_tag_t	t;
360    bus_space_handle_t	h;
361    bus_size_t		o;
362    u_int8_t		v;
363{
364    __write_1(h, o, v);
365}
366
367static void
368beb_bus_space_write_2(t, h, o, v)
369    bus_space_tag_t	t;
370    bus_space_handle_t	h;
371    bus_size_t		o;
372    u_int16_t		v;
373{
374    __write_2(h, o, v);
375}
376
377static void
378beb_bus_space_write_4(t, h, o, v)
379    bus_space_tag_t	t;
380    bus_space_handle_t	h;
381    bus_size_t		o;
382    u_int32_t		v;
383{
384    __write_4(h, o, v);
385}
386
387static void
388beb_bus_space_write_8(t, h, o, v)
389    bus_space_tag_t	t;
390    bus_space_handle_t	h;
391    bus_size_t		o;
392    u_int64_t		v;
393{
394    __write_8(h, o, v);
395}
396
397/*
398 *	void bus_space_read_multi_N __P((bus_space_tag_t tag,
399 *		bus_space_handle_t bsh, bus_size_t offset, u_intX_t *address,
400 *	 	bus_size_t count));
401 *
402 * Read 'count' 1, 2, 4, or 8 byte values from the bus_space described by
403 * tag/handle at `offset' and store them in the address range starting at
404 * 'address'. The values are converted to cpu endian order before being
405 * being stored.
406 */
407static void
408beb_bus_space_read_multi_1(t, h, o, a, c)
409	bus_space_tag_t		t;
410	bus_space_handle_t	h;
411	bus_size_t		o, c;
412	u_int8_t		*a;
413{
414	for (; c; a++, c--)
415		*a = __read_1(h, o);
416}
417static void
418beb_bus_space_read_multi_2(t, h, o, a, c)
419	bus_space_tag_t		t;
420	bus_space_handle_t	h;
421	bus_size_t		o, c;
422	u_int16_t		*a;
423{
424	for (; c; a++, c--)
425		*a = __read_2(h, o);
426}
427
428static void
429beb_bus_space_read_multi_4(t, h, o, a, c)
430	bus_space_tag_t		t;
431	bus_space_handle_t	h;
432	bus_size_t		o, c;
433	u_int32_t		*a;
434{
435	for (; c; a++, c--)
436		*a = __read_4(h, o);
437}
438
439static void
440beb_bus_space_read_multi_8(t, h, o, a, c)
441	bus_space_tag_t		t;
442	bus_space_handle_t	h;
443	bus_size_t		o, c;
444	u_int64_t		*a;
445{
446	for (; c; a++, c--)
447		*a = __read_8(h, o);
448}
449
450/*
451 *	void bus_space_write_multi_N __P((bus_space_tag_t tag,
452 *		bus_space_handle_t bsh, bus_size_t offset,
453 *		const u_intX_t *address, bus_size_t count));
454 *
455 * Write 'count' 1, 2, 4, or 8 byte values from the address range starting
456 * at 'address' to the bus_space described by tag/handle at `offset'.
457 * The values are converted to bus endian order before being written to
458 * the bus.
459 */
460static void
461beb_bus_space_write_multi_1(t, h, o, a, c)
462	bus_space_tag_t		t;
463	bus_space_handle_t	h;
464	bus_size_t		o, c;
465	const u_int8_t		*a;
466{
467	for (; c; a++, c--)
468		__write_1(h, o, *a);
469}
470
471static void
472beb_bus_space_write_multi_2(t, h, o, a, c)
473	bus_space_tag_t		t;
474	bus_space_handle_t	h;
475	bus_size_t		o, c;
476	const u_int16_t		*a;
477{
478	for (; c; a++, c--)
479		__write_2(h, o, *a);
480}
481
482static void
483beb_bus_space_write_multi_4(t, h, o, a, c)
484	bus_space_tag_t		t;
485	bus_space_handle_t	h;
486	bus_size_t		o, c;
487	const u_int32_t		*a;
488{
489	for (; c; a++, c--)
490		__write_4(h, o, *a);
491}
492
493static void
494beb_bus_space_write_multi_8(t, h, o, a, c)
495	bus_space_tag_t		t;
496	bus_space_handle_t	h;
497	bus_size_t		o, c;
498	const u_int64_t		*a;
499{
500	for (; c; a++, c--)
501		__write_8(h, o, *a);
502}
503
504/*
505 *	void bus_space_read_region_N __P((bus_space_tag_t tag,
506 *		bus_space_handle_t bsh, bus_size_t offset,
507 *		u_intN_t *addr, bus_size_t count));
508 *
509 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
510 * described by tag/handle and starting at `offset' and copy into
511 * buffer provided.
512 */
513static void
514beb_bus_space_read_region_1(t, h, o, a, c)
515	bus_space_tag_t		t;
516	bus_space_handle_t	h;
517	bus_size_t		o, c;
518	u_int8_t		*a;
519{
520	for (; c; a++, o++, c--)
521		*a = __read_1(h, o);
522}
523
524static void
525beb_bus_space_read_region_2(t, h, o, a, c)
526	bus_space_tag_t		t;
527	bus_space_handle_t	h;
528	bus_size_t		o, c;
529	u_int16_t		*a;
530{
531	for (; c; a++, o += 2, c--)
532		*a = __read_2(h, o);
533}
534
535static void
536beb_bus_space_read_region_4(t, h, o, a, c)
537	bus_space_tag_t		t;
538	bus_space_handle_t	h;
539	bus_size_t		o, c;
540	u_int32_t		*a;
541{
542	for (; c; a++, o += 4, c--)
543		*a = __read_4(h, o);
544}
545
546static void
547beb_bus_space_read_region_8(t, h, o, a, c)
548	bus_space_tag_t		t;
549	bus_space_handle_t	h;
550	bus_size_t		o, c;
551	u_int64_t		*a;
552{
553	for (; c; a++, o += 8, c--)
554		*a = __read_8(h, o);
555}
556
557/*
558 *	void bus_space_write_region_N __P((bus_space_tag_t tag,
559 *		bus_space_handle_t bsh, bus_size_t offset,
560 *		u_intN_t *addr, bus_size_t count));
561 *
562 * Copy `count' 1, 2, 4, or 8 byte quantities from the buffer provided
563 * into the bus space described by tag/handle and starting at `offset'.
564 */
565static void
566beb_bus_space_write_region_1(t, h, o, a, c)
567	bus_space_tag_t		t;
568	bus_space_handle_t	h;
569	bus_size_t		o, c;
570	const u_int8_t		*a;
571{
572	for (; c; a++, o++, c--)
573		__write_1(h, o, *a);
574}
575
576static void
577beb_bus_space_write_region_2(t, h, o, a, c)
578	bus_space_tag_t		t;
579	bus_space_handle_t	h;
580	bus_size_t		o, c;
581	const u_int16_t		*a;
582{
583	for (; c; a++, o += 2, c--)
584		__write_2(h, o, *a);
585}
586
587static void
588beb_bus_space_write_region_4(t, h, o, a, c)
589	bus_space_tag_t		t;
590	bus_space_handle_t	h;
591	bus_size_t		o, c;
592	const u_int32_t		*a;
593{
594	for (; c; a++, o += 4, c--)
595		__write_4(h, o, *a);
596}
597
598static void
599beb_bus_space_write_region_8(t, h, o, a, c)
600	bus_space_tag_t		t;
601	bus_space_handle_t	h;
602	bus_size_t		o, c;
603	const u_int64_t		*a;
604{
605	for (; c; a++, o += 8, c--)
606		__write_8(h, o, *a);
607}
608
609/*
610 *	void bus_space_set_multi_N __P((bus_space_tag_t tag,
611 *		bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
612 *		bus_size_t count));
613 *
614 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
615 * by tag/handle/offset `count' times.
616 */
617
618static void
619beb_bus_space_set_multi_1(t, h, o, v, c)
620	bus_space_tag_t		t;
621	bus_space_handle_t	h;
622	bus_size_t		o, c;
623	u_int8_t		v;
624{
625	for (; c; c--)
626		__write_1(h, o, v);
627}
628
629static void
630beb_bus_space_set_multi_2(t, h, o, v, c)
631	bus_space_tag_t		t;
632	bus_space_handle_t	h;
633	bus_size_t		o, c;
634	u_int16_t		v;
635{
636	for (; c; c--)
637		__write_2(h, o, v);
638}
639
640static void
641beb_bus_space_set_multi_4(t, h, o, v, c)
642	bus_space_tag_t		t;
643	bus_space_handle_t	h;
644	bus_size_t		o, c;
645	u_int32_t		v;
646{
647	for (; c; c--)
648		__write_4(h, o, v);
649}
650
651static void
652beb_bus_space_set_multi_8(t, h, o, v, c)
653	bus_space_tag_t		t;
654	bus_space_handle_t	h;
655	bus_size_t		o, c;
656	u_int64_t		v;
657{
658	for (; c; c--)
659		__write_8(h, o, v);
660}
661
662/*
663 *	void bus_space_set_region_N __P((bus_space_tag_t tag,
664 *		bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
665 *		bus_size_t count));
666 *
667 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
668 * by tag/handle starting at `offset'.
669 */
670static void
671beb_bus_space_set_region_1(t, h, o, v, c)
672	bus_space_tag_t		t;
673	bus_space_handle_t	h;
674	bus_size_t		o, c;
675	u_int8_t		v;
676{
677	for (; c; o++, c--)
678		__write_1(h, o, v);
679}
680
681static void
682beb_bus_space_set_region_2(t, h, o, v, c)
683	bus_space_tag_t		t;
684	bus_space_handle_t	h;
685	bus_size_t		o, c;
686	u_int16_t		v;
687{
688	for (; c; o += 2, c--)
689		__write_2(h, o, v);
690}
691
692static void
693beb_bus_space_set_region_4(t, h, o, v, c)
694	bus_space_tag_t		t;
695	bus_space_handle_t	h;
696	bus_size_t		o, c;
697	u_int32_t		v;
698{
699	for (; c; o += 4, c--)
700		__write_4(h, o, v);
701}
702
703static void
704beb_bus_space_set_region_8(t, h, o, v, c)
705	bus_space_tag_t		t;
706	bus_space_handle_t	h;
707	bus_size_t		o, c;
708	u_int64_t		v;
709{
710	for (; c; o += 8, c--)
711		__write_8(h, o, v);
712}
713