bus.h revision 1.23 1 1.23 phx /* $NetBSD: bus.h,v 1.23 2010/02/03 13:56:53 phx Exp $ */
2 1.1 is
3 1.1 is /*
4 1.1 is * Copyright (c) 1996 Leo Weppelman. All rights reserved.
5 1.1 is *
6 1.1 is * Redistribution and use in source and binary forms, with or without
7 1.1 is * modification, are permitted provided that the following conditions
8 1.1 is * are met:
9 1.1 is * 1. Redistributions of source code must retain the above copyright
10 1.1 is * notice, this list of conditions and the following disclaimer.
11 1.1 is * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 is * notice, this list of conditions and the following disclaimer in the
13 1.1 is * documentation and/or other materials provided with the distribution.
14 1.1 is *
15 1.1 is * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 1.1 is * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 1.1 is * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 1.1 is * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 1.1 is * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 1.1 is * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 1.1 is * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 1.1 is * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 1.1 is * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 1.1 is * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 1.1 is */
26 1.1 is
27 1.1 is #ifndef _AMIGA_BUS_H_
28 1.1 is #define _AMIGA_BUS_H_
29 1.1 is
30 1.4 is #include <sys/types.h>
31 1.5 is
32 1.12 is /* for public use: */
33 1.12 is
34 1.1 is /*
35 1.1 is * Memory addresses (in bus space)
36 1.1 is */
37 1.5 is
38 1.4 is typedef u_int32_t bus_addr_t;
39 1.4 is typedef u_int32_t bus_size_t;
40 1.1 is
41 1.1 is /*
42 1.1 is * Access methods for bus resources and address space.
43 1.1 is */
44 1.4 is typedef struct bus_space_tag *bus_space_tag_t;
45 1.4 is typedef u_long bus_space_handle_t;
46 1.4 is
47 1.12 is /* unpublic, but needed by method implementors */
48 1.12 is
49 1.5 is /*
50 1.5 is * Lazyness macros for function declarations.
51 1.5 is */
52 1.5 is
53 1.4 is #define bsr(what, typ) \
54 1.12 is typ (what)(bus_space_handle_t, bus_addr_t)
55 1.4 is
56 1.4 is #define bsw(what, typ) \
57 1.12 is void (what)(bus_space_handle_t, bus_addr_t, unsigned)
58 1.4 is
59 1.4 is #define bsrm(what, typ) \
60 1.12 is void (what)(bus_space_handle_t, bus_size_t, typ *, bus_size_t)
61 1.4 is
62 1.4 is #define bswm(what, typ) \
63 1.12 is void (what)(bus_space_handle_t, bus_size_t, const typ *, bus_size_t)
64 1.4 is
65 1.5 is #define bssr(what, typ) \
66 1.12 is void (what)(bus_space_handle_t, bus_size_t, unsigned, bus_size_t)
67 1.5 is
68 1.5 is #define bscr(what, typ) \
69 1.12 is void (what)(bus_space_handle_t, bus_size_t, \
70 1.12 is bus_space_handle_t, bus_size_t, bus_size_t)
71 1.5 is
72 1.5 is /*
73 1.5 is * Implementation specific structures.
74 1.5 is * XXX Don't use outside of bus_space definitions!
75 1.5 is * XXX maybe this should be encapsuled in a non-global .h file?
76 1.5 is */
77 1.5 is
78 1.5 is struct bus_space_tag {
79 1.5 is bus_addr_t base;
80 1.9 is const struct amiga_bus_space_methods *absm;
81 1.5 is };
82 1.5 is
83 1.4 is struct amiga_bus_space_methods {
84 1.5 is
85 1.12 is /* map, unmap, etc */
86 1.12 is
87 1.12 is int (*bsm)(bus_space_tag_t,
88 1.12 is bus_addr_t, bus_size_t, int, bus_space_handle_t *);
89 1.12 is
90 1.12 is int (*bsms)(bus_space_handle_t,
91 1.12 is bus_size_t, bus_size_t, bus_space_handle_t *);
92 1.12 is
93 1.12 is void (*bsu)(bus_space_handle_t, bus_size_t);
94 1.12 is
95 1.12 is /* placeholders for currently not implemented alloc and free */
96 1.12 is
97 1.12 is void *bsa;
98 1.12 is void *bsf;
99 1.12 is
100 1.12 is /* 8 bit methods */
101 1.12 is
102 1.12 is bsr(*bsr1, u_int8_t);
103 1.12 is bsw(*bsw1, u_int8_t);
104 1.12 is bsrm(*bsrm1, u_int8_t);
105 1.12 is bswm(*bswm1, u_int8_t);
106 1.12 is bsrm(*bsrr1, u_int8_t);
107 1.12 is bswm(*bswr1, u_int8_t);
108 1.12 is bssr(*bssr1, u_int8_t);
109 1.12 is bscr(*bscr1, u_int8_t);
110 1.12 is
111 1.4 is /* 16bit methods */
112 1.5 is
113 1.4 is bsr(*bsr2, u_int16_t);
114 1.4 is bsw(*bsw2, u_int16_t);
115 1.12 is bsr(*bsrs2, u_int16_t);
116 1.12 is bsw(*bsws2, u_int16_t);
117 1.4 is bsrm(*bsrm2, u_int16_t);
118 1.4 is bswm(*bswm2, u_int16_t);
119 1.12 is bsrm(*bsrms2, u_int16_t);
120 1.12 is bswm(*bswms2, u_int16_t);
121 1.4 is bsrm(*bsrr2, u_int16_t);
122 1.4 is bswm(*bswr2, u_int16_t);
123 1.7 is bsrm(*bsrrs2, u_int16_t);
124 1.7 is bswm(*bswrs2, u_int16_t);
125 1.5 is bssr(*bssr2, u_int16_t);
126 1.5 is bscr(*bscr2, u_int16_t);
127 1.4 is
128 1.5 is /* add 32bit methods here */
129 1.4 is };
130 1.9 is
131 1.5 is /*
132 1.5 is * Macro definition of map, unmap, etc.
133 1.5 is */
134 1.1 is
135 1.12 is #define bus_space_map(t, o, s, f, hp) \
136 1.12 is ((t)->absm->bsm)((t), (o), (s), (f), (hp))
137 1.2 is
138 1.12 is #define bus_space_subregion(t, h, o, s, hp) \
139 1.12 is ((t)->absm->bsms)((h), (o), (s), (hp))
140 1.1 is
141 1.12 is #define bus_space_unmap(t, h, s) \
142 1.12 is ((t)->absm->bsu)((h), (s))
143 1.1 is
144 1.5 is /*
145 1.12 is * Macro definition of _2 functions as indirect method array calls
146 1.5 is */
147 1.5 is
148 1.12 is /* 0: Helper macros */
149 1.12 is
150 1.12 is #define dbsdr(n, t, h, o) ((t)->absm->n)((h), (o))
151 1.12 is #define dbsdw(n, t, h, o, v) ((t)->absm->n)((h), (o), (v))
152 1.12 is #define dbsm(n, t, h, o, p, c) ((t)->absm->n)((h), (o), (p), (c))
153 1.12 is #define dbss(n, t, h, o, v, c) ((t)->absm->n)((h), (o), (v), (c))
154 1.12 is #define dbsc(n, t, h, o, v, c) ((t)->absm->n)((h), (o), (v), (c))
155 1.1 is
156 1.12 is /* 1: byte-wide "functions" */
157 1.1 is
158 1.12 is #define bus_space_read_1(t, h, o) dbsdr(bsr1, t, h, o)
159 1.12 is #define bus_space_write_1(t, h, o, v) dbsdw(bsw1, t, h, o, v)
160 1.12 is
161 1.12 is #define bus_space_read_multi_1(t, h, o, p, c) dbsm(bsrm1, t, h, o, p, c)
162 1.12 is #define bus_space_write_multi_1(t, h, o, p, c) dbsm(bswm1, t, h, o, p, c)
163 1.12 is
164 1.12 is #define bus_space_read_region_1(t, h, o, p, c) dbsm(bsrr1, t, h, o, p, c)
165 1.12 is #define bus_space_write_region_1(t, h, o, p, c) dbsm(bswr1, t, h, o, p, c)
166 1.12 is
167 1.12 is #define bus_space_set_region_1(t, h, o, v, c) dbss(bssr1, t, h, o, v, c)
168 1.12 is #define bus_space_copy_region_1(t, h, o, g, q, c) dbss(bscr1, t, h, o, g, q, c)
169 1.5 is
170 1.5 is
171 1.12 is /* 2: word-wide "functions" */
172 1.5 is
173 1.12 is #define bus_space_read_2(t, h, o) dbsdr(bsr2, t, h, o)
174 1.12 is #define bus_space_write_2(t, h, o, v) dbsdw(bsw2, t, h, o, v)
175 1.12 is #define bus_space_read_stream_2(t, h, o) dbsdr(bsrs2, t, h, o)
176 1.12 is #define bus_space_write_stream_2(t, h, o, v) dbsdw(bsws2, t, h, o, v)
177 1.5 is
178 1.12 is #define bus_space_read_multi_2(t, h, o, p, c) dbsm(bsrm2, t, h, o, p, c)
179 1.12 is #define bus_space_write_multi_2(t, h, o, p, c) dbsm(bswm2, t, h, o, p, c)
180 1.5 is
181 1.12 is #define bus_space_read_multi_stream_2(t, h, o, p, c) \
182 1.12 is dbsm(bsrms2, t, h, o, p, c)
183 1.5 is
184 1.12 is #define bus_space_write_multi_stream_2(t, h, o, p, c) \
185 1.12 is dbsm(bswms2, t, h, o, p, c)
186 1.5 is
187 1.12 is #define bus_space_read_region_2(t, h, o, p, c) dbsm(bsrr2, t, h, o, p, c)
188 1.12 is #define bus_space_write_region_2(t, h, o, p, c) dbsm(bswr2, t, h, o, p, c)
189 1.5 is
190 1.7 is #define bus_space_read_region_stream_2(t, h, o, p, c) \
191 1.12 is dbsm(bsrrs2, t, h, o, p, c)
192 1.5 is
193 1.7 is #define bus_space_write_region_stream_2(t, h, o, p, c) \
194 1.12 is dbsm(bswrs2, t, h, o, p, c)
195 1.5 is
196 1.12 is #define bus_space_set_region_2(t, h, o, v, c) dbss(bssr2, t, h, o, v, c)
197 1.12 is #define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c)
198 1.10 drochner
199 1.13 aymeric /* 4: Fake 32-bit macros */
200 1.13 aymeric
201 1.13 aymeric #define bus_space_read_4(t, h, o) \
202 1.15 aymeric (panic("bus_space_read_4 not implemented"), 0)
203 1.13 aymeric
204 1.13 aymeric #define bus_space_write_4(t, h, o, v) \
205 1.14 mhitch panic("bus_space_write_4 not implemented")
206 1.18 jdolecek
207 1.18 jdolecek #define bus_space_read_stream_4(t, h, o) \
208 1.18 jdolecek (panic("bus_space_read_stream_4 not implemented"), 0)
209 1.18 jdolecek
210 1.18 jdolecek #define bus_space_write_stream_4(t, h, o, v) \
211 1.18 jdolecek panic("bus_space_read_stream_4 not implemented")
212 1.13 aymeric
213 1.13 aymeric #define bus_space_read_multi_4(t, h, o, p, c) \
214 1.14 mhitch panic("bus_space_read_multi_4 not implemented")
215 1.13 aymeric
216 1.13 aymeric #define bus_space_write_multi_4(t, h, o, p, c) \
217 1.14 mhitch panic("bus_space_write_multi_4 not implemented")
218 1.13 aymeric
219 1.13 aymeric #define bus_space_read_multi_stream_4(t, h, o, p, c) \
220 1.14 mhitch panic("bus_space_read_multi_stream_4 not implemented")
221 1.13 aymeric
222 1.13 aymeric #define bus_space_write_multi_stream_4(t, h, o, p, c) \
223 1.14 mhitch panic("bus_space_write_multi_stream_4 not implemented")
224 1.13 aymeric
225 1.19 aymeric #define bus_space_read_region_stream_4(t, h, o, p, c) \
226 1.19 aymeric panic("bus_space_read_region_stream_4 not implemented")
227 1.19 aymeric
228 1.19 aymeric #define bus_space_write_region_stream_4(t, h, o, p, c) \
229 1.19 aymeric panic("bus_space_write_region_stream_4 not implemented")
230 1.19 aymeric
231 1.11 is /*
232 1.11 is * Bus read/write barrier methods.
233 1.11 is *
234 1.21 dsl * void bus_space_barrier(bus_space_tag_t tag,
235 1.11 is * bus_space_handle_t bsh, bus_size_t offset,
236 1.21 dsl * bus_size_t len, int flags);
237 1.11 is *
238 1.11 is * Note: the 680x0 does not currently require barriers, but we must
239 1.11 is * provide the flags to MI code.
240 1.11 is */
241 1.11 is #define bus_space_barrier(t, h, o, l, f) \
242 1.11 is ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
243 1.11 is #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
244 1.11 is #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
245 1.11 is
246 1.10 drochner #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
247 1.12 is
248 1.12 is #define __BUS_SPACE_HAS_STREAM_METHODS
249 1.12 is
250 1.23 phx /* Instruction for enforcing reorder protection. Nothing for 68k. */
251 1.23 phx #define amiga_bus_reorder_protect()
252 1.23 phx
253 1.17 aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_1;
254 1.17 aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_2;
255 1.17 aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_4;
256 1.17 aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_4swap;
257 1.17 aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_16;
258 1.12 is
259 1.1 is #endif /* _AMIGA_BUS_H_ */
260