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