1 /* $NetBSD: bus.h,v 1.20 2002/04/10 04:38:49 briggs Exp $ */ 2 3 /*- 4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * NASA Ames Research Center. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 /* 41 * Copyright (C) 1997 Scott Reynolds. All rights reserved. 42 * 43 * Redistribution and use in source and binary forms, with or without 44 * modification, are permitted provided that the following conditions 45 * are met: 46 * 1. Redistributions of source code must retain the above copyright 47 * notice, this list of conditions and the following disclaimer. 48 * 2. Redistributions in binary form must reproduce the above copyright 49 * notice, this list of conditions and the following disclaimer in the 50 * documentation and/or other materials provided with the distribution. 51 * 3. The name of the author may not be used to endorse or promote products 52 * derived from this software without specific prior written permission 53 * 54 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 55 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 56 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 57 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 58 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 59 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 63 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 64 */ 65 66 #ifndef _MAC68K_BUS_H_ 67 #define _MAC68K_BUS_H_ 68 69 /* 70 * Value for the mac68k bus space tag, not to be used directly by MI code. 71 */ 72 #define MAC68K_BUS_SPACE_MEM 0 /* space is mem space */ 73 74 #define __BUS_SPACE_HAS_STREAM_METHODS 1 75 76 /* 77 * Bus address and size types 78 */ 79 typedef u_long bus_addr_t; 80 typedef u_long bus_size_t; 81 82 /* 83 * Access methods for bus resources and address space. 84 */ 85 #define BSH_T struct bus_space_handle_s 86 typedef int bus_space_tag_t; 87 typedef struct bus_space_handle_s { 88 u_long base; 89 int swapped; 90 int stride; 91 92 u_int8_t (*bsr1) __P((bus_space_tag_t t, 93 BSH_T *h, bus_size_t o)); 94 u_int16_t (*bsr2) __P((bus_space_tag_t t, 95 BSH_T *h, bus_size_t o)); 96 u_int32_t (*bsr4) __P((bus_space_tag_t t, 97 BSH_T *h, bus_size_t o)); 98 u_int8_t (*bsrs1) __P((bus_space_tag_t t, 99 BSH_T *h, bus_size_t o)); 100 u_int16_t (*bsrs2) __P((bus_space_tag_t t, 101 BSH_T *h, bus_size_t o)); 102 u_int32_t (*bsrs4) __P((bus_space_tag_t t, 103 BSH_T *h, bus_size_t o)); 104 void (*bsrm1) __P((bus_space_tag_t t, BSH_T *h, 105 bus_size_t o, u_int8_t *a, size_t c)); 106 void (*bsrm2) __P((bus_space_tag_t t, BSH_T *h, 107 bus_size_t o, u_int16_t *a, size_t c)); 108 void (*bsrm4) __P((bus_space_tag_t t, BSH_T *h, 109 bus_size_t o, u_int32_t *a, size_t c)); 110 void (*bsrms1) __P((bus_space_tag_t t, BSH_T *h, 111 bus_size_t o, u_int8_t *a, size_t c)); 112 void (*bsrms2) __P((bus_space_tag_t t, BSH_T *h, 113 bus_size_t o, u_int16_t *a, size_t c)); 114 void (*bsrms4) __P((bus_space_tag_t t, BSH_T *h, 115 bus_size_t o, u_int32_t *a, size_t c)); 116 void (*bsrr1) __P((bus_space_tag_t t, BSH_T *h, 117 bus_size_t o, u_int8_t *a, size_t c)); 118 void (*bsrr2) __P((bus_space_tag_t t, BSH_T *h, 119 bus_size_t o, u_int16_t *a, size_t c)); 120 void (*bsrr4) __P((bus_space_tag_t t, BSH_T *h, 121 bus_size_t o, u_int32_t *a, size_t c)); 122 void (*bsrrs1) __P((bus_space_tag_t t, BSH_T *h, 123 bus_size_t o, u_int8_t *a, size_t c)); 124 void (*bsrrs2) __P((bus_space_tag_t t, BSH_T *h, 125 bus_size_t o, u_int16_t *a, size_t c)); 126 void (*bsrrs4) __P((bus_space_tag_t t, BSH_T *h, 127 bus_size_t o, u_int32_t *a, size_t c)); 128 void (*bsw1) __P((bus_space_tag_t t, BSH_T *h, 129 bus_size_t o, u_int8_t v)); 130 void (*bsw2) __P((bus_space_tag_t t, BSH_T *h, 131 bus_size_t o, u_int16_t v)); 132 void (*bsw4) __P((bus_space_tag_t t, BSH_T *h, 133 bus_size_t o, u_int32_t v)); 134 void (*bsws1) __P((bus_space_tag_t t, BSH_T *h, 135 bus_size_t o, u_int8_t v)); 136 void (*bsws2) __P((bus_space_tag_t t, BSH_T *h, 137 bus_size_t o, u_int16_t v)); 138 void (*bsws4) __P((bus_space_tag_t t, BSH_T *h, 139 bus_size_t o, u_int32_t v)); 140 void (*bswm1) __P((bus_space_tag_t t, BSH_T *h, 141 bus_size_t o, const u_int8_t *a, size_t c)); 142 void (*bswm2) __P((bus_space_tag_t t, BSH_T *h, 143 bus_size_t o, const u_int16_t *a, size_t c)); 144 void (*bswm4) __P((bus_space_tag_t t, BSH_T *h, 145 bus_size_t o, const u_int32_t *a, size_t c)); 146 void (*bswms1) __P((bus_space_tag_t t, BSH_T *h, 147 bus_size_t o, const u_int8_t *a, size_t c)); 148 void (*bswms2) __P((bus_space_tag_t t, BSH_T *h, 149 bus_size_t o, const u_int16_t *a, size_t c)); 150 void (*bswms4) __P((bus_space_tag_t t, BSH_T *h, 151 bus_size_t o, const u_int32_t *a, size_t c)); 152 void (*bswr1) __P((bus_space_tag_t t, BSH_T *h, 153 bus_size_t o, const u_int8_t *a, size_t c)); 154 void (*bswr2) __P((bus_space_tag_t t, BSH_T *h, 155 bus_size_t o, const u_int16_t *a, size_t c)); 156 void (*bswr4) __P((bus_space_tag_t t, BSH_T *h, 157 bus_size_t o, const u_int32_t *a, size_t c)); 158 void (*bswrs1) __P((bus_space_tag_t t, BSH_T *h, 159 bus_size_t o, const u_int8_t *a, size_t c)); 160 void (*bswrs2) __P((bus_space_tag_t t, BSH_T *h, 161 bus_size_t o, const u_int16_t *a, size_t c)); 162 void (*bswrs4) __P((bus_space_tag_t t, BSH_T *h, 163 bus_size_t o, const u_int32_t *a, size_t c)); 164 void (*bssm1) __P((bus_space_tag_t t, BSH_T *h, 165 bus_size_t o, u_int8_t v, size_t c)); 166 void (*bssm2) __P((bus_space_tag_t t, BSH_T *h, 167 bus_size_t o, u_int16_t v, size_t c)); 168 void (*bssm4) __P((bus_space_tag_t t, BSH_T *h, 169 bus_size_t o, u_int32_t v, size_t c)); 170 void (*bssr1) __P((bus_space_tag_t t, BSH_T *h, 171 bus_size_t o, u_int8_t v, size_t c)); 172 void (*bssr2) __P((bus_space_tag_t t, BSH_T *h, 173 bus_size_t o, u_int16_t v, size_t c)); 174 void (*bssr4) __P((bus_space_tag_t t, BSH_T *h, 175 bus_size_t o, u_int32_t v, size_t c)); 176 } bus_space_handle_t; 177 #undef BSH_T 178 179 void mac68k_bus_space_handle_swapped __P((bus_space_tag_t t, 180 bus_space_handle_t *h)); 181 void mac68k_bus_space_handle_set_stride __P((bus_space_tag_t t, 182 bus_space_handle_t *h, int stride)); 183 184 /* 185 * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr, 186 * bus_size_t size, int flags, bus_space_handle_t *bshp)); 187 * 188 * Map a region of bus space. 189 */ 190 191 #define BUS_SPACE_MAP_CACHEABLE 0x01 192 #define BUS_SPACE_MAP_LINEAR 0x02 193 #define BUS_SPACE_MAP_PREFETCHABLE 0x04 194 195 int bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t, 196 int, bus_space_handle_t *)); 197 198 /* 199 * void bus_space_unmap __P((bus_space_tag_t t, 200 * bus_space_handle_t bsh, bus_size_t size)); 201 * 202 * Unmap a region of bus space. 203 */ 204 205 void bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t, bus_size_t)); 206 207 /* 208 * int bus_space_subregion __P((bus_space_tag_t t, 209 * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, 210 * bus_space_handle_t *nbshp)); 211 * 212 * Get a new handle for a subregion of an already-mapped area of bus space. 213 */ 214 215 int bus_space_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh, 216 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)); 217 218 /* 219 * int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t, rstart, 220 * bus_addr_t rend, bus_size_t size, bus_size_t align, 221 * bus_size_t boundary, int flags, bus_addr_t *addrp, 222 * bus_space_handle_t *bshp)); 223 * 224 * Allocate a region of bus space. 225 */ 226 227 int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart, 228 bus_addr_t rend, bus_size_t size, bus_size_t align, 229 bus_size_t boundary, int cacheable, bus_addr_t *addrp, 230 bus_space_handle_t *bshp)); 231 232 /* 233 * int bus_space_free __P((bus_space_tag_t t, 234 * bus_space_handle_t bsh, bus_size_t size)); 235 * 236 * Free a region of bus space. 237 */ 238 239 void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, 240 bus_size_t size)); 241 242 /* 243 * int mac68k_bus_space_probe __P((bus_space_tag_t t, 244 * bus_space_handle_t bsh, bus_size_t offset, int sz)); 245 * 246 * Probe the bus at t/bsh/offset, using sz as the size of the load. 247 * 248 * This is a machine-dependent extension, and is not to be used by 249 * machine-independent code. 250 */ 251 252 int mac68k_bus_space_probe __P((bus_space_tag_t t, 253 bus_space_handle_t bsh, bus_size_t offset, int sz)); 254 255 /* 256 * u_intN_t bus_space_read_N __P((bus_space_tag_t tag, 257 * bus_space_handle_t bsh, bus_size_t offset)); 258 * 259 * Read a 1, 2, 4, or 8 byte quantity from bus space 260 * described by tag/handle/offset. 261 */ 262 263 u_int8_t mac68k_bsr1 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 264 bus_size_t offset)); 265 u_int8_t mac68k_bsr1_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 266 bus_size_t offset)); 267 u_int16_t mac68k_bsr2 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 268 bus_size_t offset)); 269 u_int16_t mac68k_bsr2_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 270 bus_size_t offset)); 271 u_int16_t mac68k_bsr2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 272 bus_size_t offset)); 273 u_int16_t mac68k_bsrs2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 274 bus_size_t offset)); 275 u_int32_t mac68k_bsr4 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 276 bus_size_t offset)); 277 u_int32_t mac68k_bsr4_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 278 bus_size_t offset)); 279 u_int32_t mac68k_bsr4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 280 bus_size_t offset)); 281 u_int32_t mac68k_bsrs4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 282 bus_size_t offset)); 283 284 #define bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o)) 285 #define bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o)) 286 #define bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o)) 287 #define bus_space_read_stream_1(t,h,o) (h).bsrs1((t), &(h), (o)) 288 #define bus_space_read_stream_2(t,h,o) (h).bsrs2((t), &(h), (o)) 289 #define bus_space_read_stream_4(t,h,o) (h).bsrs4((t), &(h), (o)) 290 291 #if 0 /* Cause a link error for bus_space_read_8 */ 292 #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! 293 #define bus_space_read_stream_8(t, h, o) \ 294 !!! bus_space_read_stream_8 unimplemented !!! 295 #endif 296 297 /* 298 * void bus_space_read_multi_N __P((bus_space_tag_t tag, 299 * bus_space_handle_t bsh, bus_size_t offset, 300 * u_intN_t *addr, size_t count)); 301 * 302 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 303 * described by tag/handle/offset and copy into buffer provided. 304 */ 305 306 void mac68k_bsrm1 __P((bus_space_tag_t t, bus_space_handle_t *h, 307 bus_size_t o, u_int8_t *a, size_t c)); 308 void mac68k_bsrm1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 309 bus_size_t o, u_int8_t *a, size_t c)); 310 void mac68k_bsrm2 __P((bus_space_tag_t t, bus_space_handle_t *h, 311 bus_size_t o, u_int16_t *a, size_t c)); 312 void mac68k_bsrm2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 313 bus_size_t o, u_int16_t *a, size_t c)); 314 void mac68k_bsrm2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 315 bus_size_t o, u_int16_t *a, size_t c)); 316 void mac68k_bsrms2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 317 bus_size_t o, u_int16_t *a, size_t c)); 318 void mac68k_bsrm4 __P((bus_space_tag_t t, bus_space_handle_t *h, 319 bus_size_t o, u_int32_t *a, size_t c)); 320 void mac68k_bsrms4 __P((bus_space_tag_t t, bus_space_handle_t *h, 321 bus_size_t o, u_int32_t *a, size_t c)); 322 void mac68k_bsrm4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 323 bus_size_t o, u_int32_t *a, size_t c)); 324 void mac68k_bsrm4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 325 bus_size_t o, u_int32_t *a, size_t c)); 326 void mac68k_bsrms4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 327 bus_size_t o, u_int32_t *a, size_t c)); 328 329 #if defined(DIAGNOSTIC) 330 #define bus_space_read_multi_1(t, h, o, a, c) do { \ 331 if (!c) panic("bus_space_read_multi_1 called with zero count."); \ 332 (h).bsrm1(t,&(h),o,a,c); } while (0) 333 #define bus_space_read_multi_2(t, h, o, a, c) do { \ 334 if (!c) panic("bus_space_read_multi_2 called with zero count."); \ 335 (h).bsrm2(t,&(h),o,a,c); } while (0) 336 #define bus_space_read_multi_4(t, h, o, a, c) do { \ 337 if (!c) panic("bus_space_read_multi_4 called with zero count."); \ 338 (h).bsrm4(t,&(h),o,a,c); } while (0) 339 #define bus_space_read_multi_stream_1(t, h, o, a, c) do { \ 340 if (!c) panic("bus_space_read_multi_stream_1 called with count=0."); \ 341 (h).bsrms1(t,&(h),o,a,c); } while (0) 342 #define bus_space_read_multi_stream_2(t, h, o, a, c) do { \ 343 if (!c) panic("bus_space_read_multi_stream_2 called with count=0."); \ 344 (h).bsrms2(t,&(h),o,a,c); } while (0) 345 #define bus_space_read_multi_stream_4(t, h, o, a, c) do { \ 346 if (!c) panic("bus_space_read_multi_stream_4 called with count=0."); \ 347 (h).bsrms4(t,&(h),o,a,c); } while (0) 348 #else 349 #define bus_space_read_multi_1(t, h, o, a, c) \ 350 do { if (c) (h).bsrm1(t, &(h), o, a, c); } while (0) 351 #define bus_space_read_multi_2(t, h, o, a, c) \ 352 do { if (c) (h).bsrm2(t, &(h), o, a, c); } while (0) 353 #define bus_space_read_multi_4(t, h, o, a, c) \ 354 do { if (c) (h).bsrm4(t, &(h), o, a, c); } while (0) 355 #define bus_space_read_multi_stream_1(t, h, o, a, c) \ 356 do { if (c) (h).bsrms1(t, &(h), o, a, c); } while (0) 357 #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 358 do { if (c) (h).bsrms2(t, &(h), o, a, c); } while (0) 359 #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 360 do { if (c) (h).bsrms4(t, &(h), o, a, c); } while (0) 361 #endif 362 363 #if 0 /* Cause a link error for bus_space_read_multi_8 */ 364 #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! 365 #define bus_space_read_multi_stream_8 \ 366 !!! bus_space_read_multi_stream_8 unimplemented !!! 367 #endif 368 369 /* 370 * void bus_space_read_region_N __P((bus_space_tag_t tag, 371 * bus_space_handle_t bsh, bus_size_t offset, 372 * u_intN_t *addr, size_t count)); 373 * 374 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 375 * described by tag/handle and starting at `offset' and copy into 376 * buffer provided. 377 */ 378 379 void mac68k_bsrr1 __P((bus_space_tag_t t, bus_space_handle_t *h, 380 bus_size_t o, u_int8_t *a, size_t c)); 381 void mac68k_bsrr1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 382 bus_size_t o, u_int8_t *a, size_t c)); 383 void mac68k_bsrr2 __P((bus_space_tag_t t, bus_space_handle_t *h, 384 bus_size_t o, u_int16_t *a, size_t c)); 385 void mac68k_bsrr2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 386 bus_size_t o, u_int16_t *a, size_t c)); 387 void mac68k_bsrr2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 388 bus_size_t o, u_int16_t *a, size_t c)); 389 void mac68k_bsrrs2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 390 bus_size_t o, u_int16_t *a, size_t c)); 391 void mac68k_bsrr4 __P((bus_space_tag_t t, bus_space_handle_t *h, 392 bus_size_t o, u_int32_t *a, size_t c)); 393 void mac68k_bsrr4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 394 bus_size_t o, u_int32_t *a, size_t c)); 395 void mac68k_bsrr4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 396 bus_size_t o, u_int32_t *a, size_t c)); 397 void mac68k_bsrrs4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 398 bus_size_t o, u_int32_t *a, size_t c)); 399 400 #if defined(DIAGNOSTIC) 401 #define bus_space_read_region_1(t, h, o, a, c) do { \ 402 if (!c) panic("bus_space_read_region_1 called with zero count."); \ 403 (h).bsrr1(t,&(h),o,a,c); } while (0) 404 #define bus_space_read_region_2(t, h, o, a, c) do { \ 405 if (!c) panic("bus_space_read_region_2 called with zero count."); \ 406 (h).bsrr2(t,&(h),o,a,c); } while (0) 407 #define bus_space_read_region_4(t, h, o, a, c) do { \ 408 if (!c) panic("bus_space_read_region_4 called with zero count."); \ 409 (h).bsrr4(t,&(h),o,a,c); } while (0) 410 #define bus_space_read_region_stream_1(t, h, o, a, c) do { \ 411 if (!c) panic("bus_space_read_region_stream_1 called with count=0."); \ 412 (h).bsrrs1(t,&(h),o,a,c); } while (0) 413 #define bus_space_read_region_stream_2(t, h, o, a, c) do { \ 414 if (!c) panic("bus_space_read_region_stream_2 called with count=0."); \ 415 (h).bsrrs2(t,&(h),o,a,c); } while (0) 416 #define bus_space_read_region_stream_4(t, h, o, a, c) do { \ 417 if (!c) panic("bus_space_read_region_stream_4 called with count=0."); \ 418 (h).bsrrs4(t,&(h),o,a,c); } while (0) 419 #else 420 #define bus_space_read_region_1(t, h, o, a, c) \ 421 do { if (c) (h).bsrr1(t,&(h),o,a,c); } while (0) 422 #define bus_space_read_region_2(t, h, o, a, c) \ 423 do { if (c) (h).bsrr2(t,&(h),o,a,c); } while (0) 424 #define bus_space_read_region_4(t, h, o, a, c) \ 425 do { if (c) (h).bsrr4(t,&(h),o,a,c); } while (0) 426 #define bus_space_read_region_stream_1(t, h, o, a, c) \ 427 do { if (c) (h).bsrrs1(t,&(h),o,a,c); } while (0) 428 #define bus_space_read_region_stream_2(t, h, o, a, c) \ 429 do { if (c) (h).bsrrs2(t,&(h),o,a,c); } while (0) 430 #define bus_space_read_region_stream_4(t, h, o, a, c) \ 431 do { if (c) (h).bsrrs4(t,&(h),o,a,c); } while (0) 432 #endif 433 434 #if 0 /* Cause a link error for bus_space_read_region_8 */ 435 #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! 436 #define bus_space_read_region_stream_8 \ 437 !!! bus_space_read_region_stream_8 unimplemented !!! 438 #endif 439 440 /* 441 * void bus_space_write_N __P((bus_space_tag_t tag, 442 * bus_space_handle_t bsh, bus_size_t offset, 443 * u_intN_t value)); 444 * 445 * Write the 1, 2, 4, or 8 byte value `value' to bus space 446 * described by tag/handle/offset. 447 */ 448 449 void mac68k_bsw1 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 450 bus_size_t offset, u_int8_t v)); 451 void mac68k_bsw1_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 452 bus_size_t offset, u_int8_t v)); 453 void mac68k_bsw2 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 454 bus_size_t offset, u_int16_t v)); 455 void mac68k_bsw2_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 456 bus_size_t offset, u_int16_t v)); 457 void mac68k_bsw2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 458 bus_size_t offset, u_int16_t v)); 459 void mac68k_bsws2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 460 bus_size_t offset, u_int16_t v)); 461 void mac68k_bsw4 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 462 bus_size_t offset, u_int32_t v)); 463 void mac68k_bsw4_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 464 bus_size_t offset, u_int32_t v)); 465 void mac68k_bsw4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 466 bus_size_t offset, u_int32_t v)); 467 void mac68k_bsws4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 468 bus_size_t offset, u_int32_t v)); 469 470 #define bus_space_write_1(t, h, o, v) (h).bsw1(t, &(h), o, v) 471 #define bus_space_write_2(t, h, o, v) (h).bsw2(t, &(h), o, v) 472 #define bus_space_write_4(t, h, o, v) (h).bsw4(t, &(h), o, v) 473 #define bus_space_write_stream_1(t, h, o, v) (h).bsws1(t, &(h), o, v) 474 #define bus_space_write_stream_2(t, h, o, v) (h).bsws2(t, &(h), o, v) 475 #define bus_space_write_stream_4(t, h, o, v) (h).bsws4(t, &(h), o, v) 476 477 #if 0 /* Cause a link error for bus_space_write_8 */ 478 #define bus_space_write_8 !!! bus_space_write_8 not implemented !!! 479 #define bus_space_write_stream_8 \ 480 !!! bus_space_write_stream_8 not implemented !!! 481 #endif 482 483 /* 484 * void bus_space_write_multi_N __P((bus_space_tag_t tag, 485 * bus_space_handle_t bsh, bus_size_t offset, 486 * const u_intN_t *addr, size_t count)); 487 * 488 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer 489 * provided to bus space described by tag/handle/offset. 490 */ 491 492 void mac68k_bswm1 __P((bus_space_tag_t t, bus_space_handle_t *h, 493 bus_size_t o, const u_int8_t *a, size_t c)); 494 void mac68k_bswm1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 495 bus_size_t o, const u_int8_t *a, size_t c)); 496 void mac68k_bswm2 __P((bus_space_tag_t t, bus_space_handle_t *h, 497 bus_size_t o, const u_int16_t *a, size_t c)); 498 void mac68k_bswm2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 499 bus_size_t o, const u_int16_t *a, size_t c)); 500 void mac68k_bswm2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 501 bus_size_t o, const u_int16_t *a, size_t c)); 502 void mac68k_bswms2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 503 bus_size_t o, const u_int16_t *a, size_t c)); 504 void mac68k_bswm4 __P((bus_space_tag_t t, bus_space_handle_t *h, 505 bus_size_t o, const u_int32_t *a, size_t c)); 506 void mac68k_bswm4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 507 bus_size_t o, const u_int32_t *a, size_t c)); 508 void mac68k_bswm4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 509 bus_size_t o, const u_int32_t *a, size_t c)); 510 void mac68k_bswms4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 511 bus_size_t o, const u_int32_t *a, size_t c)); 512 513 #if defined(DIAGNOSTIC) 514 #define bus_space_write_multi_1(t, h, o, a, c) do { \ 515 if (!c) panic("bus_space_write_multi_1 called with zero count."); \ 516 (h).bswm1(t,&(h),o,a,c); } while (0) 517 #define bus_space_write_multi_2(t, h, o, a, c) do { \ 518 if (!c) panic("bus_space_write_multi_2 called with zero count."); \ 519 (h).bswm2(t,&(h),o,a,c); } while (0) 520 #define bus_space_write_multi_4(t, h, o, a, c) do { \ 521 if (!c) panic("bus_space_write_multi_4 called with zero count."); \ 522 (h).bswm4(t,&(h),o,a,c); } while (0) 523 #define bus_space_write_multi_stream_1(t, h, o, a, c) do { \ 524 if (!c) panic("bus_space_write_multi_stream_1 called with count=0."); \ 525 (h).bswms1(t,&(h),o,a,c); } while (0) 526 #define bus_space_write_multi_stream_2(t, h, o, a, c) do { \ 527 if (!c) panic("bus_space_write_multi_stream_2 called with count=0."); \ 528 (h).bswms2(t,&(h),o,a,c); } while (0) 529 #define bus_space_write_multi_stream_4(t, h, o, a, c) do { \ 530 if (!c) panic("bus_space_write_multi_stream_4 called with count=0."); \ 531 (h).bswms4(t,&(h),o,a,c); } while (0) 532 #else 533 #define bus_space_write_multi_1(t, h, o, a, c) \ 534 do { if (c) (h).bswm1(t, &(h), o, a, c); } while (0) 535 #define bus_space_write_multi_2(t, h, o, a, c) \ 536 do { if (c) (h).bswm2(t, &(h), o, a, c); } while (0) 537 #define bus_space_write_multi_4(t, h, o, a, c) \ 538 do { if (c) (h).bswm4(t, &(h), o, a, c); } while (0) 539 #define bus_space_write_multi_stream_1(t, h, o, a, c) \ 540 do { if (c) (h).bswms1(t, &(h), o, a, c); } while (0) 541 #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 542 do { if (c) (h).bswms2(t, &(h), o, a, c); } while (0) 543 #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 544 do { if (c) (h).bswms4(t, &(h), o, a, c); } while (0) 545 #endif 546 547 #if 0 /* Cause a link error for bus_space_write_8 */ 548 #define bus_space_write_multi_8(t, h, o, a, c) \ 549 !!! bus_space_write_multi_8 unimplimented !!! 550 #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 551 !!! bus_space_write_multi_stream_8 unimplimented !!! 552 #endif 553 554 /* 555 * void bus_space_write_region_N __P((bus_space_tag_t tag, 556 * bus_space_handle_t bsh, bus_size_t offset, 557 * const u_intN_t *addr, size_t count)); 558 * 559 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided 560 * to bus space described by tag/handle starting at `offset'. 561 */ 562 563 void mac68k_bswr1 __P((bus_space_tag_t t, bus_space_handle_t *h, 564 bus_size_t o, const u_int8_t *a, size_t c)); 565 void mac68k_bswr1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 566 bus_size_t o, const u_int8_t *a, size_t c)); 567 void mac68k_bswr2 __P((bus_space_tag_t t, bus_space_handle_t *h, 568 bus_size_t o, const u_int16_t *a, size_t c)); 569 void mac68k_bswr2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 570 bus_size_t o, const u_int16_t *a, size_t c)); 571 void mac68k_bswr2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 572 bus_size_t o, const u_int16_t *a, size_t c)); 573 void mac68k_bswrs2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 574 bus_size_t o, const u_int16_t *a, size_t c)); 575 void mac68k_bswr4 __P((bus_space_tag_t t, bus_space_handle_t *h, 576 bus_size_t o, const u_int32_t *a, size_t c)); 577 void mac68k_bswr4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 578 bus_size_t o, const u_int32_t *a, size_t c)); 579 void mac68k_bswr4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 580 bus_size_t o, const u_int32_t *a, size_t c)); 581 void mac68k_bswrs4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 582 bus_size_t o, const u_int32_t *a, size_t c)); 583 584 #if defined(DIAGNOSTIC) 585 #define bus_space_write_region_1(t, h, o, a, c) do { \ 586 if (!c) panic("bus_space_write_region_1 called with zero count."); \ 587 (h).bswr1(t,&(h),o,a,c); } while (0) 588 #define bus_space_write_region_2(t, h, o, a, c) do { \ 589 if (!c) panic("bus_space_write_region_2 called with zero count."); \ 590 (h).bswr2(t,&(h),o,a,c); } while (0) 591 #define bus_space_write_region_4(t, h, o, a, c) do { \ 592 if (!c) panic("bus_space_write_region_4 called with zero count."); \ 593 (h).bswr4(t,&(h),o,a,c); } while (0) 594 #define bus_space_write_region_stream_1(t, h, o, a, c) do { \ 595 if (!c) panic("bus_space_write_region_stream_1 called with count=0."); \ 596 (h).bswrs1(t,&(h),o,a,c); } while (0) 597 #define bus_space_write_region_stream_2(t, h, o, a, c) do { \ 598 if (!c) panic("bus_space_write_region_stream_2 called with count=0."); \ 599 (h).bswrs2(t,&(h),o,a,c); } while (0) 600 #define bus_space_write_region_stream_4(t, h, o, a, c) do { \ 601 if (!c) panic("bus_space_write_region_stream_4 called with count=0."); \ 602 (h).bswrs4(t,&(h),o,a,c); } while (0) 603 #else 604 #define bus_space_write_region_1(t, h, o, a, c) \ 605 do { if (c) (h).bswr1(t,&(h),o,a,c); } while (0) 606 #define bus_space_write_region_2(t, h, o, a, c) \ 607 do { if (c) (h).bswr2(t,&(h),o,a,c); } while (0) 608 #define bus_space_write_region_4(t, h, o, a, c) \ 609 do { if (c) (h).bswr4(t,&(h),o,a,c); } while (0) 610 #define bus_space_write_region_stream_1(t, h, o, a, c) \ 611 do { if (c) (h).bswrs1(t,&(h),o,a,c); } while (0) 612 #define bus_space_write_region_stream_2(t, h, o, a, c) \ 613 do { if (c) (h).bswrs2(t,&(h),o,a,c); } while (0) 614 #define bus_space_write_region_stream_4(t, h, o, a, c) \ 615 do { if (c) (h).bswrs4(t,&(h),o,a,c); } while (0) 616 #endif 617 618 #if 0 /* Cause a link error for bus_space_write_region_8 */ 619 #define bus_space_write_region_8 \ 620 !!! bus_space_write_region_8 unimplemented !!! 621 #define bus_space_write_region_stream_8 \ 622 !!! bus_space_write_region_stream_8 unimplemented !!! 623 #endif 624 625 /* 626 * void bus_space_set_multi_N __P((bus_space_tag_t tag, 627 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 628 * size_t count)); 629 * 630 * Write the 1, 2, 4, or 8 byte value `val' to bus space described 631 * by tag/handle/offset `count' times. 632 */ 633 634 void mac68k_bssm1 __P((bus_space_tag_t t, bus_space_handle_t *h, 635 bus_size_t o, u_int8_t v, size_t c)); 636 void mac68k_bssm1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 637 bus_size_t o, u_int8_t v, size_t c)); 638 void mac68k_bssm2 __P((bus_space_tag_t t, bus_space_handle_t *h, 639 bus_size_t o, u_int16_t v, size_t c)); 640 void mac68k_bssm2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 641 bus_size_t o, u_int16_t v, size_t c)); 642 void mac68k_bssm2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 643 bus_size_t o, u_int16_t v, size_t c)); 644 void mac68k_bssm4 __P((bus_space_tag_t t, bus_space_handle_t *h, 645 bus_size_t o, u_int32_t v, size_t c)); 646 void mac68k_bssm4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 647 bus_size_t o, u_int32_t v, size_t c)); 648 void mac68k_bssm4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 649 bus_size_t o, u_int32_t v, size_t c)); 650 651 #if defined(DIAGNOSTIC) 652 #define bus_space_set_multi_1(t, h, o, val, c) do { \ 653 if (!c) panic("bus_space_set_multi_1 called with zero count."); \ 654 (h).bssm1(t,&(h),o,val,c); } while (0) 655 #define bus_space_set_multi_2(t, h, o, val, c) do { \ 656 if (!c) panic("bus_space_set_multi_2 called with zero count."); \ 657 (h).bssm2(t,&(h),o,val,c); } while (0) 658 #define bus_space_set_multi_4(t, h, o, val, c) do { \ 659 if (!c) panic("bus_space_set_multi_4 called with zero count."); \ 660 (h).bssm4(t,&(h),o,val,c); } while (0) 661 #else 662 #define bus_space_set_multi_1(t, h, o, val, c) \ 663 do { if (c) (h).bssm1(t,&(h),o,val,c); } while (0) 664 #define bus_space_set_multi_2(t, h, o, val, c) \ 665 do { if (c) (h).bssm2(t,&(h),o,val,c); } while (0) 666 #define bus_space_set_multi_4(t, h, o, val, c) \ 667 do { if (c) (h).bssm4(t,&(h),o,val,c); } while (0) 668 #endif 669 670 #if 0 /* Cause a link error for bus_space_set_multi_8 */ 671 #define bus_space_set_multi_8 \ 672 !!! bus_space_set_multi_8 unimplemented !!! 673 #endif 674 675 /* 676 * void bus_space_set_region_N __P((bus_space_tag_t tag, 677 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 678 * size_t count)); 679 * 680 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described 681 * by tag/handle starting at `offset'. 682 */ 683 684 void mac68k_bssr1 __P((bus_space_tag_t t, bus_space_handle_t *h, 685 bus_size_t o, u_int8_t v, size_t c)); 686 void mac68k_bssr1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 687 bus_size_t o, u_int8_t v, size_t c)); 688 void mac68k_bssr2 __P((bus_space_tag_t t, bus_space_handle_t *h, 689 bus_size_t o, u_int16_t v, size_t c)); 690 void mac68k_bssr2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 691 bus_size_t o, u_int16_t v, size_t c)); 692 void mac68k_bssr2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 693 bus_size_t o, u_int16_t v, size_t c)); 694 void mac68k_bssr4 __P((bus_space_tag_t t, bus_space_handle_t *h, 695 bus_size_t o, u_int32_t v, size_t c)); 696 void mac68k_bssr4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 697 bus_size_t o, u_int32_t v, size_t c)); 698 void mac68k_bssr4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 699 bus_size_t o, u_int32_t v, size_t c)); 700 701 #if defined(DIAGNOSTIC) 702 #define bus_space_set_region_1(t, h, o, val, c) do { \ 703 if (!c) panic("bus_space_set_region_1 called with zero count."); \ 704 (h).bssr1(t,&(h),o,val,c); } while (0) 705 #define bus_space_set_region_2(t, h, o, val, c) do { \ 706 if (!c) panic("bus_space_set_region_2 called with zero count."); \ 707 (h).bssr2(t,&(h),o,val,c); } while (0) 708 #define bus_space_set_region_4(t, h, o, val, c) do { \ 709 if (!c) panic("bus_space_set_region_4 called with zero count."); \ 710 (h).bssr4(t,&(h),o,val,c); } while (0) 711 #else 712 #define bus_space_set_region_1(t, h, o, val, c) \ 713 do { if (c) (h).bssr1(t,&(h),o,val,c); } while (0) 714 #define bus_space_set_region_2(t, h, o, val, c) \ 715 do { if (c) (h).bssr2(t,&(h),o,val,c); } while (0) 716 #define bus_space_set_region_4(t, h, o, val, c) \ 717 do { if (c) (h).bssr4(t,&(h),o,val,c); } while (0) 718 #endif 719 720 #if 0 /* Cause a link error for bus_space_set_region_8 */ 721 #define bus_space_set_region_8 \ 722 !!! bus_space_set_region_8 unimplemented !!! 723 #endif 724 725 /* 726 * void bus_space_copy_N __P((bus_space_tag_t tag, 727 * bus_space_handle_t bsh1, bus_size_t off1, 728 * bus_space_handle_t bsh2, bus_size_t off2, 729 * size_t count)); 730 * 731 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting 732 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. 733 */ 734 735 #define __MAC68K_copy_region_N(BYTES) \ 736 static __inline void __CONCAT(bus_space_copy_region_,BYTES) \ 737 __P((bus_space_tag_t, \ 738 bus_space_handle_t bsh1, bus_size_t off1, \ 739 bus_space_handle_t bsh2, bus_size_t off2, \ 740 bus_size_t count)); \ 741 \ 742 static __inline void \ 743 __CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c) \ 744 bus_space_tag_t t; \ 745 bus_space_handle_t h1, h2; \ 746 bus_size_t o1, o2, c; \ 747 { \ 748 bus_size_t o; \ 749 \ 750 if ((h1.base + o1) >= (h2.base + o2)) { \ 751 /* src after dest: copy forward */ \ 752 for (o = 0; c != 0; c--, o += BYTES) \ 753 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ 754 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ 755 } else { \ 756 /* dest after src: copy backwards */ \ 757 for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \ 758 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ 759 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ 760 } \ 761 } 762 __MAC68K_copy_region_N(1) 763 __MAC68K_copy_region_N(2) 764 __MAC68K_copy_region_N(4) 765 #if 0 /* Cause a link error for bus_space_copy_8 */ 766 #define bus_space_copy_8 \ 767 !!! bus_space_copy_8 unimplemented !!! 768 #endif 769 770 #undef __MAC68K_copy_region_N 771 772 /* 773 * Bus read/write barrier methods. 774 * 775 * void bus_space_barrier __P((bus_space_tag_t tag, 776 * bus_space_handle_t bsh, bus_size_t offset, 777 * bus_size_t len, int flags)); 778 * 779 * Note: the 680x0 does not currently require barriers, but we must 780 * provide the flags to MI code. 781 */ 782 #define bus_space_barrier(t, h, o, l, f) \ 783 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) 784 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 785 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 786 787 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 788 789 #include <m68k/bus_dma.h> 790 791 #endif /* _MAC68K_BUS_H_ */ 792