be_bus.c revision 1.3
1/*	$NetBSD: be_bus.c,v 1.3 1998/05/25 09:08:08 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
164bus_space_tag_t		beb_alloc_bus_space_tag __P((void));
165
166/*
167 * Don't force a function call overhead on these primitives...
168 */
169#define __read_1(h, o)		*((u_int8_t  *)((h) + (o)))
170#define __read_2(h, o)		*((u_int16_t *)((h) + (o)))
171#define __read_4(h, o)		*((u_int32_t *)((h) + (o)))
172#define __read_8(h, o)		*((u_int64_t *)((h) + (o)))
173
174#define __write_1(h, o, v)	*((u_int8_t  *)((h) + (o))) = (v)
175#define __write_2(h, o, v)	*((u_int16_t *)((h) + (o))) = (v)
176#define __write_4(h, o, v)	*((u_int32_t *)((h) + (o))) = (v)
177#define __write_8(h, o, v)	*((u_int64_t *)((h) + (o))) = (v)
178
179bus_space_tag_t
180beb_alloc_bus_space_tag()
181{
182	bus_space_tag_t	beb_t;
183
184	if ((beb_t = malloc(sizeof(*beb_t), M_TEMP, M_NOWAIT)) == NULL)
185		return(NULL);
186	bzero(beb_t, sizeof(*beb_t));
187
188	beb_t->abs_p_1   = beb_bus_space_peek_1;
189	beb_t->abs_p_2   = beb_bus_space_peek_2;
190	beb_t->abs_p_4   = beb_bus_space_peek_4;
191	beb_t->abs_p_8   = beb_bus_space_peek_8;
192	beb_t->abs_r_1   = beb_bus_space_read_1;
193	beb_t->abs_r_2   = beb_bus_space_read_2;
194	beb_t->abs_r_4   = beb_bus_space_read_4;
195	beb_t->abs_r_8   = beb_bus_space_read_8;
196	beb_t->abs_rs_1  = beb_bus_space_read_1;
197	beb_t->abs_rs_2  = beb_bus_space_read_2;
198	beb_t->abs_rs_4  = beb_bus_space_read_4;
199	beb_t->abs_rs_8  = beb_bus_space_read_8;
200	beb_t->abs_rm_1  = beb_bus_space_read_multi_1;
201	beb_t->abs_rm_2  = beb_bus_space_read_multi_2;
202	beb_t->abs_rm_4  = beb_bus_space_read_multi_4;
203	beb_t->abs_rm_8  = beb_bus_space_read_multi_8;
204	beb_t->abs_rms_1 = beb_bus_space_read_multi_1;
205	beb_t->abs_rms_2 = beb_bus_space_read_multi_2;
206	beb_t->abs_rms_4 = beb_bus_space_read_multi_4;
207	beb_t->abs_rms_8 = beb_bus_space_read_multi_8;
208	beb_t->abs_rr_1  = beb_bus_space_read_region_1;
209	beb_t->abs_rr_2  = beb_bus_space_read_region_2;
210	beb_t->abs_rr_4  = beb_bus_space_read_region_4;
211	beb_t->abs_rr_8  = beb_bus_space_read_region_8;
212	beb_t->abs_rrs_1 = beb_bus_space_read_region_1;
213	beb_t->abs_rrs_2 = beb_bus_space_read_region_2;
214	beb_t->abs_rrs_4 = beb_bus_space_read_region_4;
215	beb_t->abs_rrs_8 = beb_bus_space_read_region_8;
216	beb_t->abs_w_1   = beb_bus_space_write_1;
217	beb_t->abs_w_2   = beb_bus_space_write_2;
218	beb_t->abs_w_4   = beb_bus_space_write_4;
219	beb_t->abs_w_8   = beb_bus_space_write_8;
220	beb_t->abs_ws_1  = beb_bus_space_write_1;
221	beb_t->abs_ws_2  = beb_bus_space_write_2;
222	beb_t->abs_ws_4  = beb_bus_space_write_4;
223	beb_t->abs_ws_8  = beb_bus_space_write_8;
224	beb_t->abs_wm_1  = beb_bus_space_write_multi_1;
225	beb_t->abs_wm_2  = beb_bus_space_write_multi_2;
226	beb_t->abs_wm_4  = beb_bus_space_write_multi_4;
227	beb_t->abs_wm_8  = beb_bus_space_write_multi_8;
228	beb_t->abs_wms_1 = beb_bus_space_write_multi_1;
229	beb_t->abs_wms_2 = beb_bus_space_write_multi_2;
230	beb_t->abs_wms_4 = beb_bus_space_write_multi_4;
231	beb_t->abs_wms_8 = beb_bus_space_write_multi_8;
232	beb_t->abs_wr_1  = beb_bus_space_write_region_1;
233	beb_t->abs_wr_2  = beb_bus_space_write_region_2;
234	beb_t->abs_wr_4  = beb_bus_space_write_region_4;
235	beb_t->abs_wr_8  = beb_bus_space_write_region_8;
236	beb_t->abs_wrs_1 = beb_bus_space_write_region_1;
237	beb_t->abs_wrs_2 = beb_bus_space_write_region_2;
238	beb_t->abs_wrs_4 = beb_bus_space_write_region_4;
239	beb_t->abs_wrs_8 = beb_bus_space_write_region_8;
240	beb_t->abs_sm_1  = beb_bus_space_set_multi_1;
241	beb_t->abs_sm_2  = beb_bus_space_set_multi_2;
242	beb_t->abs_sm_4  = beb_bus_space_set_multi_4;
243	beb_t->abs_sm_8  = beb_bus_space_set_multi_8;
244	beb_t->abs_sr_1  = beb_bus_space_set_region_1;
245	beb_t->abs_sr_2  = beb_bus_space_set_region_2;
246	beb_t->abs_sr_4  = beb_bus_space_set_region_4;
247	beb_t->abs_sr_8  = beb_bus_space_set_region_8;
248
249	return(beb_t);
250}
251
252
253/*
254 * The various access functions
255 */
256
257/*
258 *	int bus_space_peek_N __P((bus_space_tag_t tag,
259 *		bus_space_handle_t sh, bus_size_t offset));
260 *
261 * Check if the address is suitable for reading N-byte quantities.
262 */
263static int
264beb_bus_space_peek_1(t, h, o)
265    bus_space_tag_t	t;
266    bus_space_handle_t	h;
267    bus_size_t		o;
268{
269    return(!badbaddr((caddr_t)(h + o), 1));
270}
271
272static int
273beb_bus_space_peek_2(t, h, o)
274    bus_space_tag_t	t;
275    bus_space_handle_t	h;
276    bus_size_t		o;
277{
278    return(!badbaddr((caddr_t)(h + o), 2));
279}
280
281static int
282beb_bus_space_peek_4(t, h, o)
283    bus_space_tag_t	t;
284    bus_space_handle_t	h;
285    bus_size_t		o;
286{
287    return(!badbaddr((caddr_t)(h + o), 4));
288}
289
290static int
291beb_bus_space_peek_8(t, h, o)
292    bus_space_tag_t	t;
293    bus_space_handle_t	h;
294    bus_size_t		o;
295{
296    return(!badbaddr((caddr_t)(h + o), 8));
297}
298
299/*
300 *	u_intX_t bus_space_read_N __P((bus_space_tag_t tag,
301 *		bus_space_handle_t bsh, bus_size_t offset));
302 *
303 * Return an 1, 2, 4, or 8 byte value read from the bus_space described
304 * by tag/handle at `offset'. The value is converted to host-endian.
305 */
306static u_int8_t
307beb_bus_space_read_1(t, h, o)
308    bus_space_tag_t	t;
309    bus_space_handle_t	h;
310    bus_size_t		o;
311{
312    return(__read_1(h, o));
313}
314
315static u_int16_t
316beb_bus_space_read_2(t, h, o)
317    bus_space_tag_t	t;
318    bus_space_handle_t	h;
319    bus_size_t		o;
320{
321    return(__read_2(h, o));
322}
323
324static u_int32_t
325beb_bus_space_read_4(t, h, o)
326    bus_space_tag_t	t;
327    bus_space_handle_t	h;
328    bus_size_t		o;
329{
330    return(__read_4(h, o));
331}
332
333static u_int64_t
334beb_bus_space_read_8(t, h, o)
335    bus_space_tag_t	t;
336    bus_space_handle_t	h;
337    bus_size_t		o;
338{
339    return(__read_8(h, o));
340}
341
342/*
343 *	u_intX_t bus_space_write_N __P((bus_space_tag_t tag,
344 *		bus_space_handle_t bsh, bus_size_t offset, u_intX_t val));
345 *
346 * Write an 1, 2, 4, or 8 byte value to the bus_space described by tag/handle
347 * at `offset'. The value `val' is converted from host to bus endianness
348 * before being written.
349 */
350static void
351beb_bus_space_write_1(t, h, o, v)
352    bus_space_tag_t	t;
353    bus_space_handle_t	h;
354    bus_size_t		o;
355    u_int8_t		v;
356{
357    __write_1(h, o, v);
358}
359
360static void
361beb_bus_space_write_2(t, h, o, v)
362    bus_space_tag_t	t;
363    bus_space_handle_t	h;
364    bus_size_t		o;
365    u_int16_t		v;
366{
367    __write_2(h, o, v);
368}
369
370static void
371beb_bus_space_write_4(t, h, o, v)
372    bus_space_tag_t	t;
373    bus_space_handle_t	h;
374    bus_size_t		o;
375    u_int32_t		v;
376{
377    __write_4(h, o, v);
378}
379
380static void
381beb_bus_space_write_8(t, h, o, v)
382    bus_space_tag_t	t;
383    bus_space_handle_t	h;
384    bus_size_t		o;
385    u_int64_t		v;
386{
387    __write_8(h, o, v);
388}
389
390/*
391 *	void bus_space_read_multi_N __P((bus_space_tag_t tag,
392 *		bus_space_handle_t bsh, bus_size_t offset, u_intX_t *address,
393 *	 	bus_size_t count));
394 *
395 * Read 'count' 1, 2, 4, or 8 byte values from the bus_space described by
396 * tag/handle at `offset' and store them in the address range starting at
397 * 'address'. The values are converted to cpu endian order before being
398 * being stored.
399 */
400static void
401beb_bus_space_read_multi_1(t, h, o, a, c)
402	bus_space_tag_t		t;
403	bus_space_handle_t	h;
404	bus_size_t		o, c;
405	u_int8_t		*a;
406{
407	for (; c; a++, c--)
408		*a = __read_1(h, o);
409}
410static void
411beb_bus_space_read_multi_2(t, h, o, a, c)
412	bus_space_tag_t		t;
413	bus_space_handle_t	h;
414	bus_size_t		o, c;
415	u_int16_t		*a;
416{
417	for (; c; a++, c--)
418		*a = __read_2(h, o);
419}
420
421static void
422beb_bus_space_read_multi_4(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_int32_t		*a;
427{
428	for (; c; a++, c--)
429		*a = __read_4(h, o);
430}
431
432static void
433beb_bus_space_read_multi_8(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_int64_t		*a;
438{
439	for (; c; a++, c--)
440		*a = __read_8(h, o);
441}
442
443/*
444 *	void bus_space_write_multi_N __P((bus_space_tag_t tag,
445 *		bus_space_handle_t bsh, bus_size_t offset,
446 *		const u_intX_t *address, bus_size_t count));
447 *
448 * Write 'count' 1, 2, 4, or 8 byte values from the address range starting
449 * at 'address' to the bus_space described by tag/handle at `offset'.
450 * The values are converted to bus endian order before being written to
451 * the bus.
452 */
453static void
454beb_bus_space_write_multi_1(t, h, o, a, c)
455	bus_space_tag_t		t;
456	bus_space_handle_t	h;
457	bus_size_t		o, c;
458	const u_int8_t		*a;
459{
460	for (; c; a++, c--)
461		__write_1(h, o, *a);
462}
463
464static void
465beb_bus_space_write_multi_2(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_int16_t		*a;
470{
471	for (; c; a++, c--)
472		__write_2(h, o, *a);
473}
474
475static void
476beb_bus_space_write_multi_4(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_int32_t		*a;
481{
482	for (; c; a++, c--)
483		__write_4(h, o, *a);
484}
485
486static void
487beb_bus_space_write_multi_8(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_int64_t		*a;
492{
493	for (; c; a++, c--)
494		__write_8(h, o, *a);
495}
496
497/*
498 *	void bus_space_read_region_N __P((bus_space_tag_t tag,
499 *		bus_space_handle_t bsh, bus_size_t offset,
500 *		u_intN_t *addr, bus_size_t count));
501 *
502 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
503 * described by tag/handle and starting at `offset' and copy into
504 * buffer provided.
505 */
506static void
507beb_bus_space_read_region_1(t, h, o, a, c)
508	bus_space_tag_t		t;
509	bus_space_handle_t	h;
510	bus_size_t		o, c;
511	u_int8_t		*a;
512{
513	for (; c; a++, o++, c--)
514		*a = __read_1(h, o);
515}
516
517static void
518beb_bus_space_read_region_2(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_int16_t		*a;
523{
524	for (; c; a++, o += 2, c--)
525		*a = __read_2(h, o);
526}
527
528static void
529beb_bus_space_read_region_4(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_int32_t		*a;
534{
535	for (; c; a++, o += 4, c--)
536		*a = __read_4(h, o);
537}
538
539static void
540beb_bus_space_read_region_8(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_int64_t		*a;
545{
546	for (; c; a++, o += 8, c--)
547		*a = __read_8(h, o);
548}
549
550/*
551 *	void bus_space_write_region_N __P((bus_space_tag_t tag,
552 *		bus_space_handle_t bsh, bus_size_t offset,
553 *		u_intN_t *addr, bus_size_t count));
554 *
555 * Copy `count' 1, 2, 4, or 8 byte quantities from the buffer provided
556 * into the bus space described by tag/handle and starting at `offset'.
557 */
558static void
559beb_bus_space_write_region_1(t, h, o, a, c)
560	bus_space_tag_t		t;
561	bus_space_handle_t	h;
562	bus_size_t		o, c;
563	const u_int8_t		*a;
564{
565	for (; c; a++, o++, c--)
566		__write_1(h, o, *a);
567}
568
569static void
570beb_bus_space_write_region_2(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_int16_t		*a;
575{
576	for (; c; a++, o += 2, c--)
577		__write_2(h, o, *a);
578}
579
580static void
581beb_bus_space_write_region_4(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_int32_t		*a;
586{
587	for (; c; a++, o += 4, c--)
588		__write_4(h, o, *a);
589}
590
591static void
592beb_bus_space_write_region_8(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_int64_t		*a;
597{
598	for (; c; a++, o += 8, c--)
599		__write_8(h, o, *a);
600}
601
602/*
603 *	void bus_space_set_multi_N __P((bus_space_tag_t tag,
604 *		bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
605 *		bus_size_t count));
606 *
607 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
608 * by tag/handle/offset `count' times.
609 */
610
611static void
612beb_bus_space_set_multi_1(t, h, o, v, c)
613	bus_space_tag_t		t;
614	bus_space_handle_t	h;
615	bus_size_t		o, c;
616	u_int8_t		v;
617{
618	for (; c; c--)
619		__write_1(h, o, v);
620}
621
622static void
623beb_bus_space_set_multi_2(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_int16_t		v;
628{
629	for (; c; c--)
630		__write_2(h, o, v);
631}
632
633static void
634beb_bus_space_set_multi_4(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_int32_t		v;
639{
640	for (; c; c--)
641		__write_4(h, o, v);
642}
643
644static void
645beb_bus_space_set_multi_8(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_int64_t		v;
650{
651	for (; c; c--)
652		__write_8(h, o, v);
653}
654
655/*
656 *	void bus_space_set_region_N __P((bus_space_tag_t tag,
657 *		bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
658 *		bus_size_t count));
659 *
660 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
661 * by tag/handle starting at `offset'.
662 */
663static void
664beb_bus_space_set_region_1(t, h, o, v, c)
665	bus_space_tag_t		t;
666	bus_space_handle_t	h;
667	bus_size_t		o, c;
668	u_int8_t		v;
669{
670	for (; c; o++, c--)
671		__write_1(h, o, v);
672}
673
674static void
675beb_bus_space_set_region_2(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_int16_t		v;
680{
681	for (; c; o += 2, c--)
682		__write_2(h, o, v);
683}
684
685static void
686beb_bus_space_set_region_4(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_int32_t		v;
691{
692	for (; c; o += 4, c--)
693		__write_4(h, o, v);
694}
695
696static void
697beb_bus_space_set_region_8(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_int64_t		v;
702{
703	for (; c; o += 8, c--)
704		__write_8(h, o, v);
705}
706