xref: /netbsd-src/sys/arch/amigappc/include/bus_funcs.h (revision cde8f271ec30c028c5652673e0e3c4a6298637d1)
1 /*	$NetBSD: bus_funcs.h,v 1.2 2022/02/16 23:49:26 riastradh Exp $	*/
2 
3 /*
4  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef _AMIGAPPC_BUS_FUNCS_H_
28 #define _AMIGAPPC_BUS_FUNCS_H_
29 
30 /*
31  * Macro definition of map, unmap, etc.
32  */
33 
34 #define bus_space_map(t, o, s, f, hp) \
35 	((t)->absm->bsm)((t), (o), (s), (f), (hp))
36 
37 #define bus_space_subregion(t, h, o, s, hp) \
38 	((t)->absm->bsms)((h), (o), (s), (hp))
39 
40 #define bus_space_unmap(t, h, s) \
41 	((t)->absm->bsu)((h), (s))
42 
43 /*
44  * Macro definition of _2 functions as indirect method array calls
45  */
46 
47 /* 0: Helper macros */
48 
49 #define dbsdr(n, t, h, o)	((t)->absm->n)((h), (o))
50 #define dbsdw(n, t, h, o, v)	((t)->absm->n)((h), (o), (v))
51 #define dbsm(n, t, h, o, p, c)	((t)->absm->n)((h), (o), (p), (c))
52 #define dbss(n, t, h, o, v, c)	((t)->absm->n)((h), (o), (v), (c))
53 #define dbsc(n, t, h, o, v, c)	((t)->absm->n)((h), (o), (v), (c))
54 
55 /* 1: byte-wide "functions" */
56 
57 #define bus_space_read_1(t, h, o)		  dbsdr(bsr1, t, h, o)
58 #define bus_space_write_1(t, h, o, v)		  dbsdw(bsw1, t, h, o, v)
59 
60 #define bus_space_read_multi_1(t, h, o, p, c)	  dbsm(bsrm1, t, h, o, p, c)
61 #define bus_space_write_multi_1(t, h, o, p, c)	  dbsm(bswm1, t, h, o, p, c)
62 
63 #define bus_space_read_region_1(t, h, o, p, c)	  dbsm(bsrr1, t, h, o, p, c)
64 #define bus_space_write_region_1(t, h, o, p, c)	  dbsm(bswr1, t, h, o, p, c)
65 
66 #define bus_space_set_region_1(t, h, o, v, c)	  dbss(bssr1, t, h, o, v, c)
67 #define bus_space_copy_region_1(t, h, o, g, q, c) dbss(bscr1, t, h, o, g, q, c)
68 
69 
70 /* 2: word-wide "functions" */
71 
72 #define bus_space_read_2(t, h, o)		  dbsdr(bsr2, t, h, o)
73 #define bus_space_write_2(t, h, o, v)		  dbsdw(bsw2, t, h, o, v)
74 #define bus_space_read_stream_2(t, h, o)	  dbsdr(bsrs2, t, h, o)
75 #define bus_space_write_stream_2(t, h, o, v)	  dbsdw(bsws2, t, h, o, v)
76 
77 #define bus_space_read_multi_2(t, h, o, p, c)	  dbsm(bsrm2, t, h, o, p, c)
78 #define bus_space_write_multi_2(t, h, o, p, c)	  dbsm(bswm2, t, h, o, p, c)
79 
80 #define bus_space_read_multi_stream_2(t, h, o, p, c) \
81 						  dbsm(bsrms2, t, h, o, p, c)
82 
83 #define bus_space_write_multi_stream_2(t, h, o, p, c) \
84 						  dbsm(bswms2, t, h, o, p, c)
85 
86 #define bus_space_read_region_2(t, h, o, p, c)	  dbsm(bsrr2, t, h, o, p, c)
87 #define bus_space_write_region_2(t, h, o, p, c)	  dbsm(bswr2, t, h, o, p, c)
88 
89 #define bus_space_read_region_stream_2(t, h, o, p, c) \
90 						  dbsm(bsrrs2, t, h, o, p, c)
91 
92 #define bus_space_write_region_stream_2(t, h, o, p, c) \
93 						  dbsm(bswrs2, t, h, o, p, c)
94 
95 #define bus_space_set_region_2(t, h, o, v, c)	  dbss(bssr2, t, h, o, v, c)
96 #define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c)
97 
98 /* 4: Fake 32-bit macros */
99 
100 #define bus_space_read_4(t, h, o) \
101 	(panic("bus_space_read_4 not implemented"), 0)
102 
103 #define bus_space_write_4(t, h, o, v) \
104 	panic("bus_space_write_4 not implemented")
105 
106 #define bus_space_read_stream_4(t, h, o) \
107 	(panic("bus_space_read_stream_4 not implemented"), 0)
108 
109 #define bus_space_write_stream_4(t, h, o, v) \
110 	panic("bus_space_read_stream_4 not implemented")
111 
112 #define bus_space_read_multi_4(t, h, o, p, c) \
113 	panic("bus_space_read_multi_4 not implemented")
114 
115 #define bus_space_write_multi_4(t, h, o, p, c) \
116 	panic("bus_space_write_multi_4 not implemented")
117 
118 #define bus_space_read_multi_stream_4(t, h, o, p, c) \
119 	panic("bus_space_read_multi_stream_4 not implemented")
120 
121 #define bus_space_write_multi_stream_4(t, h, o, p, c) \
122 	panic("bus_space_write_multi_stream_4 not implemented")
123 
124 #define bus_space_read_region_stream_4(t, h, o, p, c) \
125 	panic("bus_space_read_region_stream_4 not implemented")
126 
127 #define bus_space_write_region_stream_4(t, h, o, p, c) \
128 	panic("bus_space_write_region_stream_4 not implemented")
129 
130 /*
131  * Bus read/write barrier methods.
132  *
133  *      void bus_space_barrier __P((bus_space_tag_t tag,
134  *          bus_space_handle_t bsh, bus_size_t offset,
135  *          bus_size_t len, int flags));
136  *
137  * Note: the 680x0 does not currently require barriers, but we must
138  * provide the flags to MI code.
139  */
140 #define bus_space_barrier(t, h, o, l, f)        \
141         ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
142 
143 /* Instruction for enforcing reorder protection. */
144 #define amiga_bus_reorder_protect() __asm volatile("eieio" ::: "memory")
145 
146 #endif /* _AMIGAPPC_BUS_FUNCS_H_ */
147