1 /* $NetBSD: amiga_bus_simple_4.c,v 1.4 2002/01/28 09:56:44 aymeric Exp $ */
2 
3 /*-
4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Ignatios Souvatzis.
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(1, "$NetBSD: amiga_bus_simple_4.c,v 1.4 2002/01/28 09:56:44 aymeric Exp $");
41 
42 #define AMIGA_SIMPLE_BUS_STRIDE 4		/* 1 byte per long */
43 #define AMIGA_SIMPLE_BUS_WORD_METHODS
44 
45 #include "simple_busfuncs.c"
46 
47 /*
48  * Little-endian word methods.
49  * Stream access does not swap, used for 16-bit wide transfers of byte streams.
50  * Non-stream access swaps bytes.
51  * XXX Only *_multi_2 transfers currently swap bytes XXX
52  */
53 
54 bsrm(oabs(bsrm2_swap_), u_int16_t);
55 bswm(oabs(bswm2_swap_), u_int16_t);
56 
57 void
58 oabs(bsrm2_swap_)(bus_space_handle_t handle, bus_size_t offset,
59 	 	  u_int16_t *pointer, bus_size_t count)
60 {
61 	volatile u_int16_t *p;
62 
63 	p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
64 
65 	while (count > 0) {
66 		*pointer++ = bswap16(*p);
67 		--count;
68 	}
69 }
70 
71 void
72 oabs(bswm2_swap_)(bus_space_handle_t handle, bus_size_t offset,
73 		  const u_int16_t *pointer, bus_size_t count)
74 {
75 	volatile u_int16_t *p;
76 
77 	p = (volatile u_int16_t *)(handle + offset * AMIGA_SIMPLE_BUS_STRIDE);
78 
79 	while (count > 0) {
80 		*p = bswap16(*pointer);
81 		++pointer;
82 		--count;
83 	}
84 }
85 
86 const struct amiga_bus_space_methods amiga_bus_stride_4swap = {
87 
88         oabs(bsm_),
89         oabs(bsms_),
90         oabs(bsu_),
91         0,
92         0,
93 
94         oabs(bsr1_),
95         oabs(bsw1_),
96         oabs(bsrm1_),
97         oabs(bswm1_),
98         oabs(bsrr1_),
99         oabs(bswr1_),
100         oabs(bssr1_),
101         oabs(bscr1_),
102 
103         oabs(bsr2_),		/* XXX swap? */
104         oabs(bsw2_),		/* XXX swap? */
105         oabs(bsr2_),
106         oabs(bsw2_),
107         oabs(bsrm2_swap_),
108         oabs(bswm2_swap_),
109         oabs(bsrm2_),
110         oabs(bswm2_),
111         oabs(bsrr2_),		/* XXX swap? */
112         oabs(bswr2_),		/* XXX swap? */
113         oabs(bsrr2_),
114         oabs(bswr2_),
115         oabs(bssr2_),		/* XXX swap? */
116         oabs(bscr2_)		/* XXX swap? */
117 };
118