1 /* $NetBSD: bus.h,v 1.17 2000/07/31 22:40:25 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 /* 75 * Bus address and size types 76 */ 77 typedef u_long bus_addr_t; 78 typedef u_long bus_size_t; 79 80 /* 81 * Access methods for bus resources and address space. 82 */ 83 #define BSH_T struct bus_space_handle_s 84 typedef int bus_space_tag_t; 85 typedef struct bus_space_handle_s { 86 u_long base; 87 int swapped; 88 int stride; 89 90 u_int8_t (*bsr1) __P((bus_space_tag_t t, 91 BSH_T *h, bus_size_t o)); 92 u_int16_t (*bsr2) __P((bus_space_tag_t t, 93 BSH_T *h, bus_size_t o)); 94 u_int32_t (*bsr4) __P((bus_space_tag_t t, 95 BSH_T *h, bus_size_t o)); 96 u_int8_t (*bsrs1) __P((bus_space_tag_t t, 97 BSH_T *h, bus_size_t o)); 98 u_int16_t (*bsrs2) __P((bus_space_tag_t t, 99 BSH_T *h, bus_size_t o)); 100 u_int32_t (*bsrs4) __P((bus_space_tag_t t, 101 BSH_T *h, bus_size_t o)); 102 void (*bsrm1) __P((bus_space_tag_t t, BSH_T *h, 103 bus_size_t o, u_int8_t *a, size_t c)); 104 void (*bsrm2) __P((bus_space_tag_t t, BSH_T *h, 105 bus_size_t o, u_int16_t *a, size_t c)); 106 void (*bsrm4) __P((bus_space_tag_t t, BSH_T *h, 107 bus_size_t o, u_int32_t *a, size_t c)); 108 void (*bsrms1) __P((bus_space_tag_t t, BSH_T *h, 109 bus_size_t o, u_int8_t *a, size_t c)); 110 void (*bsrms2) __P((bus_space_tag_t t, BSH_T *h, 111 bus_size_t o, u_int16_t *a, size_t c)); 112 void (*bsrms4) __P((bus_space_tag_t t, BSH_T *h, 113 bus_size_t o, u_int32_t *a, size_t c)); 114 void (*bsrr1) __P((bus_space_tag_t t, BSH_T *h, 115 bus_size_t o, u_int8_t *a, size_t c)); 116 void (*bsrr2) __P((bus_space_tag_t t, BSH_T *h, 117 bus_size_t o, u_int16_t *a, size_t c)); 118 void (*bsrr4) __P((bus_space_tag_t t, BSH_T *h, 119 bus_size_t o, u_int32_t *a, size_t c)); 120 void (*bsrrs1) __P((bus_space_tag_t t, BSH_T *h, 121 bus_size_t o, u_int8_t *a, size_t c)); 122 void (*bsrrs2) __P((bus_space_tag_t t, BSH_T *h, 123 bus_size_t o, u_int16_t *a, size_t c)); 124 void (*bsrrs4) __P((bus_space_tag_t t, BSH_T *h, 125 bus_size_t o, u_int32_t *a, size_t c)); 126 void (*bsw1) __P((bus_space_tag_t t, BSH_T *h, 127 bus_size_t o, u_int8_t v)); 128 void (*bsw2) __P((bus_space_tag_t t, BSH_T *h, 129 bus_size_t o, u_int16_t v)); 130 void (*bsw4) __P((bus_space_tag_t t, BSH_T *h, 131 bus_size_t o, u_int32_t v)); 132 void (*bsws1) __P((bus_space_tag_t t, BSH_T *h, 133 bus_size_t o, u_int8_t v)); 134 void (*bsws2) __P((bus_space_tag_t t, BSH_T *h, 135 bus_size_t o, u_int16_t v)); 136 void (*bsws4) __P((bus_space_tag_t t, BSH_T *h, 137 bus_size_t o, u_int32_t v)); 138 void (*bswm1) __P((bus_space_tag_t t, BSH_T *h, 139 bus_size_t o, u_int8_t *a, size_t c)); 140 void (*bswm2) __P((bus_space_tag_t t, BSH_T *h, 141 bus_size_t o, u_int16_t *a, size_t c)); 142 void (*bswm4) __P((bus_space_tag_t t, BSH_T *h, 143 bus_size_t o, u_int32_t *a, size_t c)); 144 void (*bswms1) __P((bus_space_tag_t t, BSH_T *h, 145 bus_size_t o, u_int8_t *a, size_t c)); 146 void (*bswms2) __P((bus_space_tag_t t, BSH_T *h, 147 bus_size_t o, u_int16_t *a, size_t c)); 148 void (*bswms4) __P((bus_space_tag_t t, BSH_T *h, 149 bus_size_t o, u_int32_t *a, size_t c)); 150 void (*bswr1) __P((bus_space_tag_t t, BSH_T *h, 151 bus_size_t o, u_int8_t *a, size_t c)); 152 void (*bswr2) __P((bus_space_tag_t t, BSH_T *h, 153 bus_size_t o, u_int16_t *a, size_t c)); 154 void (*bswr4) __P((bus_space_tag_t t, BSH_T *h, 155 bus_size_t o, u_int32_t *a, size_t c)); 156 void (*bswrs1) __P((bus_space_tag_t t, BSH_T *h, 157 bus_size_t o, u_int8_t *a, size_t c)); 158 void (*bswrs2) __P((bus_space_tag_t t, BSH_T *h, 159 bus_size_t o, u_int16_t *a, size_t c)); 160 void (*bswrs4) __P((bus_space_tag_t t, BSH_T *h, 161 bus_size_t o, u_int32_t *a, size_t c)); 162 void (*bssm1) __P((bus_space_tag_t t, BSH_T *h, 163 bus_size_t o, u_int8_t v, size_t c)); 164 void (*bssm2) __P((bus_space_tag_t t, BSH_T *h, 165 bus_size_t o, u_int16_t v, size_t c)); 166 void (*bssm4) __P((bus_space_tag_t t, BSH_T *h, 167 bus_size_t o, u_int32_t v, size_t c)); 168 void (*bssr1) __P((bus_space_tag_t t, BSH_T *h, 169 bus_size_t o, u_int8_t v, size_t c)); 170 void (*bssr2) __P((bus_space_tag_t t, BSH_T *h, 171 bus_size_t o, u_int16_t v, size_t c)); 172 void (*bssr4) __P((bus_space_tag_t t, BSH_T *h, 173 bus_size_t o, u_int32_t v, size_t c)); 174 } bus_space_handle_t; 175 #undef BSH_T 176 177 void mac68k_bus_space_handle_swapped __P((bus_space_tag_t t, 178 bus_space_handle_t *h)); 179 void mac68k_bus_space_handle_set_stride __P((bus_space_tag_t t, 180 bus_space_handle_t *h, int stride)); 181 182 /* 183 * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr, 184 * bus_size_t size, int flags, bus_space_handle_t *bshp)); 185 * 186 * Map a region of bus space. 187 */ 188 189 #define BUS_SPACE_MAP_CACHEABLE 0x01 190 #define BUS_SPACE_MAP_LINEAR 0x02 191 #define BUS_SPACE_MAP_PREFETCHABLE 0x04 192 193 int bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t, 194 int, bus_space_handle_t *)); 195 196 /* 197 * void bus_space_unmap __P((bus_space_tag_t t, 198 * bus_space_handle_t bsh, bus_size_t size)); 199 * 200 * Unmap a region of bus space. 201 */ 202 203 void bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t, bus_size_t)); 204 205 /* 206 * int bus_space_subregion __P((bus_space_tag_t t, 207 * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, 208 * bus_space_handle_t *nbshp)); 209 * 210 * Get a new handle for a subregion of an already-mapped area of bus space. 211 */ 212 213 int bus_space_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh, 214 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)); 215 216 /* 217 * int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t, rstart, 218 * bus_addr_t rend, bus_size_t size, bus_size_t align, 219 * bus_size_t boundary, int flags, bus_addr_t *addrp, 220 * bus_space_handle_t *bshp)); 221 * 222 * Allocate a region of bus space. 223 */ 224 225 int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart, 226 bus_addr_t rend, bus_size_t size, bus_size_t align, 227 bus_size_t boundary, int cacheable, bus_addr_t *addrp, 228 bus_space_handle_t *bshp)); 229 230 /* 231 * int bus_space_free __P((bus_space_tag_t t, 232 * bus_space_handle_t bsh, bus_size_t size)); 233 * 234 * Free a region of bus space. 235 */ 236 237 void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, 238 bus_size_t size)); 239 240 /* 241 * int mac68k_bus_space_probe __P((bus_space_tag_t t, 242 * bus_space_handle_t bsh, bus_size_t offset, int sz)); 243 * 244 * Probe the bus at t/bsh/offset, using sz as the size of the load. 245 * 246 * This is a machine-dependent extension, and is not to be used by 247 * machine-independent code. 248 */ 249 250 int mac68k_bus_space_probe __P((bus_space_tag_t t, 251 bus_space_handle_t bsh, bus_size_t offset, int sz)); 252 253 /* 254 * u_intN_t bus_space_read_N __P((bus_space_tag_t tag, 255 * bus_space_handle_t bsh, bus_size_t offset)); 256 * 257 * Read a 1, 2, 4, or 8 byte quantity from bus space 258 * described by tag/handle/offset. 259 */ 260 261 u_int8_t mac68k_bsr1 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 262 bus_size_t offset)); 263 u_int8_t mac68k_bsr1_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 264 bus_size_t offset)); 265 u_int16_t mac68k_bsr2 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 266 bus_size_t offset)); 267 u_int16_t mac68k_bsr2_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 268 bus_size_t offset)); 269 u_int16_t mac68k_bsr2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 270 bus_size_t offset)); 271 u_int16_t mac68k_bsrs2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 272 bus_size_t offset)); 273 u_int32_t mac68k_bsr4 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 274 bus_size_t offset)); 275 u_int32_t mac68k_bsr4_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 276 bus_size_t offset)); 277 u_int32_t mac68k_bsr4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 278 bus_size_t offset)); 279 u_int32_t mac68k_bsrs4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 280 bus_size_t offset)); 281 282 #define bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o)) 283 #define bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o)) 284 #define bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o)) 285 #define bus_space_read_stream_1(t,h,o) (h).bsrs1((t), &(h), (o)) 286 #define bus_space_read_stream_2(t,h,o) (h).bsrs2((t), &(h), (o)) 287 #define bus_space_read_stream_4(t,h,o) (h).bsrs4((t), &(h), (o)) 288 289 #if 0 /* Cause a link error for bus_space_read_8 */ 290 #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! 291 #define bus_space_read_stream_8(t, h, o) \ 292 !!! bus_space_read_stream_8 unimplemented !!! 293 #endif 294 295 /* 296 * void bus_space_read_multi_N __P((bus_space_tag_t tag, 297 * bus_space_handle_t bsh, bus_size_t offset, 298 * u_intN_t *addr, size_t count)); 299 * 300 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 301 * described by tag/handle/offset and copy into buffer provided. 302 */ 303 304 void mac68k_bsrm1 __P((bus_space_tag_t t, bus_space_handle_t *h, 305 bus_size_t o, u_int8_t *a, size_t c)); 306 void mac68k_bsrm1_gen __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_bsrm2 __P((bus_space_tag_t t, bus_space_handle_t *h, 309 bus_size_t o, u_int16_t *a, size_t c)); 310 void mac68k_bsrm2_swap __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_gen __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_bsrms2_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_bsrm4 __P((bus_space_tag_t t, bus_space_handle_t *h, 317 bus_size_t o, u_int32_t *a, size_t c)); 318 void mac68k_bsrms4 __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_bsrm4_swap __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_gen __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_bsrms4_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 327 #if defined(DIAGNOSTIC) 328 #define bus_space_read_multi_1(t, h, o, a, c) do { \ 329 if (!c) panic("bus_space_read_multi_1 called with zero count."); \ 330 (h).bsrm1(t,&(h),o,a,c); } while (0) 331 #define bus_space_read_multi_2(t, h, o, a, c) do { \ 332 if (!c) panic("bus_space_read_multi_2 called with zero count."); \ 333 (h).bsrm2(t,&(h),o,a,c); } while (0) 334 #define bus_space_read_multi_4(t, h, o, a, c) do { \ 335 if (!c) panic("bus_space_read_multi_4 called with zero count."); \ 336 (h).bsrm4(t,&(h),o,a,c); } while (0) 337 #define bus_space_read_multi_stream_1(t, h, o, a, c) do { \ 338 if (!c) panic("bus_space_read_multi_stream_1 called with count=0."); \ 339 (h).bsrms1(t,&(h),o,a,c); } while (0) 340 #define bus_space_read_multi_stream_2(t, h, o, a, c) do { \ 341 if (!c) panic("bus_space_read_multi_stream_2 called with count=0."); \ 342 (h).bsrms2(t,&(h),o,a,c); } while (0) 343 #define bus_space_read_multi_stream_4(t, h, o, a, c) do { \ 344 if (!c) panic("bus_space_read_multi_stream_4 called with count=0."); \ 345 (h).bsrms4(t,&(h),o,a,c); } while (0) 346 #else 347 #define bus_space_read_multi_1(t, h, o, a, c) \ 348 do { if (c) (h).bsrm1(t, &(h), o, a, c); } while (0) 349 #define bus_space_read_multi_2(t, h, o, a, c) \ 350 do { if (c) (h).bsrm2(t, &(h), o, a, c); } while (0) 351 #define bus_space_read_multi_4(t, h, o, a, c) \ 352 do { if (c) (h).bsrm4(t, &(h), o, a, c); } while (0) 353 #define bus_space_read_multi_stream_1(t, h, o, a, c) \ 354 do { if (c) (h).bsrms1(t, &(h), o, a, c); } while (0) 355 #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 356 do { if (c) (h).bsrms2(t, &(h), o, a, c); } while (0) 357 #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 358 do { if (c) (h).bsrms4(t, &(h), o, a, c); } while (0) 359 #endif 360 361 #if 0 /* Cause a link error for bus_space_read_multi_8 */ 362 #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! 363 #define bus_space_read_multi_stream_8 \ 364 !!! bus_space_read_multi_stream_8 unimplemented !!! 365 #endif 366 367 /* 368 * void bus_space_read_region_N __P((bus_space_tag_t tag, 369 * bus_space_handle_t bsh, bus_size_t offset, 370 * u_intN_t *addr, size_t count)); 371 * 372 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 373 * described by tag/handle and starting at `offset' and copy into 374 * buffer provided. 375 */ 376 377 void mac68k_bsrr1 __P((bus_space_tag_t t, bus_space_handle_t *h, 378 bus_size_t o, u_int8_t *a, size_t c)); 379 void mac68k_bsrr1_gen __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_bsrr2 __P((bus_space_tag_t t, bus_space_handle_t *h, 382 bus_size_t o, u_int16_t *a, size_t c)); 383 void mac68k_bsrr2_swap __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_gen __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_bsrrs2_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_bsrr4 __P((bus_space_tag_t t, bus_space_handle_t *h, 390 bus_size_t o, u_int32_t *a, size_t c)); 391 void mac68k_bsrr4_swap __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_gen __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_bsrrs4_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 398 #if defined(DIAGNOSTIC) 399 #define bus_space_read_region_1(t, h, o, a, c) do { \ 400 if (!c) panic("bus_space_read_region_1 called with zero count."); \ 401 (h).bsrr1(t,&(h),o,a,c); } while (0) 402 #define bus_space_read_region_2(t, h, o, a, c) do { \ 403 if (!c) panic("bus_space_read_region_2 called with zero count."); \ 404 (h).bsrr2(t,&(h),o,a,c); } while (0) 405 #define bus_space_read_region_4(t, h, o, a, c) do { \ 406 if (!c) panic("bus_space_read_region_4 called with zero count."); \ 407 (h).bsrr4(t,&(h),o,a,c); } while (0) 408 #define bus_space_read_region_stream_1(t, h, o, a, c) do { \ 409 if (!c) panic("bus_space_read_region_stream_1 called with count=0."); \ 410 (h).bsrrs1(t,&(h),o,a,c); } while (0) 411 #define bus_space_read_region_stream_2(t, h, o, a, c) do { \ 412 if (!c) panic("bus_space_read_region_stream_2 called with count=0."); \ 413 (h).bsrrs2(t,&(h),o,a,c); } while (0) 414 #define bus_space_read_region_stream_4(t, h, o, a, c) do { \ 415 if (!c) panic("bus_space_read_region_stream_4 called with count=0."); \ 416 (h).bsrrs4(t,&(h),o,a,c); } while (0) 417 #else 418 #define bus_space_read_region_1(t, h, o, a, c) \ 419 do { if (c) (h).bsrr1(t,&(h),o,a,c); } while (0) 420 #define bus_space_read_region_2(t, h, o, a, c) \ 421 do { if (c) (h).bsrr2(t,&(h),o,a,c); } while (0) 422 #define bus_space_read_region_4(t, h, o, a, c) \ 423 do { if (c) (h).bsrr4(t,&(h),o,a,c); } while (0) 424 #define bus_space_read_region_stream_1(t, h, o, a, c) \ 425 do { if (c) (h).bsrrs1(t,&(h),o,a,c); } while (0) 426 #define bus_space_read_region_stream_2(t, h, o, a, c) \ 427 do { if (c) (h).bsrrs2(t,&(h),o,a,c); } while (0) 428 #define bus_space_read_region_stream_4(t, h, o, a, c) \ 429 do { if (c) (h).bsrrs4(t,&(h),o,a,c); } while (0) 430 #endif 431 432 #if 0 /* Cause a link error for bus_space_read_region_8 */ 433 #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! 434 #define bus_space_read_region_stream_8 \ 435 !!! bus_space_read_region_stream_8 unimplemented !!! 436 #endif 437 438 /* 439 * void bus_space_write_N __P((bus_space_tag_t tag, 440 * bus_space_handle_t bsh, bus_size_t offset, 441 * u_intN_t value)); 442 * 443 * Write the 1, 2, 4, or 8 byte value `value' to bus space 444 * described by tag/handle/offset. 445 */ 446 447 void mac68k_bsw1 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 448 bus_size_t offset, u_int8_t v)); 449 void mac68k_bsw1_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 450 bus_size_t offset, u_int8_t v)); 451 void mac68k_bsw2 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 452 bus_size_t offset, u_int16_t v)); 453 void mac68k_bsw2_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 454 bus_size_t offset, u_int16_t v)); 455 void mac68k_bsw2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 456 bus_size_t offset, u_int16_t v)); 457 void mac68k_bsws2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 458 bus_size_t offset, u_int16_t v)); 459 void mac68k_bsw4 __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 460 bus_size_t offset, u_int32_t v)); 461 void mac68k_bsw4_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 462 bus_size_t offset, u_int32_t v)); 463 void mac68k_bsw4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 464 bus_size_t offset, u_int32_t v)); 465 void mac68k_bsws4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh, 466 bus_size_t offset, u_int32_t v)); 467 468 #define bus_space_write_1(t, h, o, v) (h).bsw1(t, &(h), o, v) 469 #define bus_space_write_2(t, h, o, v) (h).bsw2(t, &(h), o, v) 470 #define bus_space_write_4(t, h, o, v) (h).bsw4(t, &(h), o, v) 471 #define bus_space_write_stream_1(t, h, o, v) (h).bsws1(t, &(h), o, v) 472 #define bus_space_write_stream_2(t, h, o, v) (h).bsws2(t, &(h), o, v) 473 #define bus_space_write_stream_4(t, h, o, v) (h).bsws4(t, &(h), o, v) 474 475 #if 0 /* Cause a link error for bus_space_write_8 */ 476 #define bus_space_write_8 !!! bus_space_write_8 not implemented !!! 477 #define bus_space_write_stream_8 \ 478 !!! bus_space_write_stream_8 not implemented !!! 479 #endif 480 481 /* 482 * void bus_space_write_multi_N __P((bus_space_tag_t tag, 483 * bus_space_handle_t bsh, bus_size_t offset, 484 * const u_intN_t *addr, size_t count)); 485 * 486 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer 487 * provided to bus space described by tag/handle/offset. 488 */ 489 490 void mac68k_bswm1 __P((bus_space_tag_t t, bus_space_handle_t *h, 491 bus_size_t o, u_int8_t *a, size_t c)); 492 void mac68k_bswm1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 493 bus_size_t o, u_int8_t *a, size_t c)); 494 void mac68k_bswm2 __P((bus_space_tag_t t, bus_space_handle_t *h, 495 bus_size_t o, u_int16_t *a, size_t c)); 496 void mac68k_bswm2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 497 bus_size_t o, u_int16_t *a, size_t c)); 498 void mac68k_bswm2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 499 bus_size_t o, u_int16_t *a, size_t c)); 500 void mac68k_bswms2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 501 bus_size_t o, u_int16_t *a, size_t c)); 502 void mac68k_bswm4 __P((bus_space_tag_t t, bus_space_handle_t *h, 503 bus_size_t o, u_int32_t *a, size_t c)); 504 void mac68k_bswm4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 505 bus_size_t o, u_int32_t *a, size_t c)); 506 void mac68k_bswm4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 507 bus_size_t o, u_int32_t *a, size_t c)); 508 void mac68k_bswms4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 509 bus_size_t o, u_int32_t *a, size_t c)); 510 511 #if defined(DIAGNOSTIC) 512 #define bus_space_write_multi_1(t, h, o, a, c) do { \ 513 if (!c) panic("bus_space_write_multi_1 called with zero count."); \ 514 (h).bswm1(t,&(h),o,a,c); } while (0) 515 #define bus_space_write_multi_2(t, h, o, a, c) do { \ 516 if (!c) panic("bus_space_write_multi_2 called with zero count."); \ 517 (h).bswm2(t,&(h),o,a,c); } while (0) 518 #define bus_space_write_multi_4(t, h, o, a, c) do { \ 519 if (!c) panic("bus_space_write_multi_4 called with zero count."); \ 520 (h).bswm4(t,&(h),o,a,c); } while (0) 521 #define bus_space_write_multi_stream_1(t, h, o, a, c) do { \ 522 if (!c) panic("bus_space_write_multi_stream_1 called with count=0."); \ 523 (h).bswms1(t,&(h),o,a,c); } while (0) 524 #define bus_space_write_multi_stream_2(t, h, o, a, c) do { \ 525 if (!c) panic("bus_space_write_multi_stream_2 called with count=0."); \ 526 (h).bswms2(t,&(h),o,a,c); } while (0) 527 #define bus_space_write_multi_stream_4(t, h, o, a, c) do { \ 528 if (!c) panic("bus_space_write_multi_stream_4 called with count=0."); \ 529 (h).bswms4(t,&(h),o,a,c); } while (0) 530 #else 531 #define bus_space_write_multi_1(t, h, o, a, c) \ 532 do { if (c) (h).bswm1(t, &(h), o, a, c); } while (0) 533 #define bus_space_write_multi_2(t, h, o, a, c) \ 534 do { if (c) (h).bswm2(t, &(h), o, a, c); } while (0) 535 #define bus_space_write_multi_4(t, h, o, a, c) \ 536 do { if (c) (h).bswm4(t, &(h), o, a, c); } while (0) 537 #define bus_space_write_multi_stream_1(t, h, o, a, c) \ 538 do { if (c) (h).bswms1(t, &(h), o, a, c); } while (0) 539 #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 540 do { if (c) (h).bswms2(t, &(h), o, a, c); } while (0) 541 #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 542 do { if (c) (h).bswms4(t, &(h), o, a, c); } while (0) 543 #endif 544 545 #if 0 /* Cause a link error for bus_space_write_8 */ 546 #define bus_space_write_multi_8(t, h, o, a, c) \ 547 !!! bus_space_write_multi_8 unimplimented !!! 548 #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 549 !!! bus_space_write_multi_stream_8 unimplimented !!! 550 #endif 551 552 /* 553 * void bus_space_write_region_N __P((bus_space_tag_t tag, 554 * bus_space_handle_t bsh, bus_size_t offset, 555 * const u_intN_t *addr, size_t count)); 556 * 557 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided 558 * to bus space described by tag/handle starting at `offset'. 559 */ 560 561 void mac68k_bswr1 __P((bus_space_tag_t t, bus_space_handle_t *h, 562 bus_size_t o, u_int8_t *a, size_t c)); 563 void mac68k_bswr1_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 564 bus_size_t o, u_int8_t *a, size_t c)); 565 void mac68k_bswr2 __P((bus_space_tag_t t, bus_space_handle_t *h, 566 bus_size_t o, u_int16_t *a, size_t c)); 567 void mac68k_bswr2_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 568 bus_size_t o, u_int16_t *a, size_t c)); 569 void mac68k_bswr2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 570 bus_size_t o, u_int16_t *a, size_t c)); 571 void mac68k_bswrs2_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 572 bus_size_t o, u_int16_t *a, size_t c)); 573 void mac68k_bswr4 __P((bus_space_tag_t t, bus_space_handle_t *h, 574 bus_size_t o, u_int32_t *a, size_t c)); 575 void mac68k_bswr4_swap __P((bus_space_tag_t t, bus_space_handle_t *h, 576 bus_size_t o, u_int32_t *a, size_t c)); 577 void mac68k_bswr4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 578 bus_size_t o, u_int32_t *a, size_t c)); 579 void mac68k_bswrs4_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 580 bus_size_t o, u_int32_t *a, size_t c)); 581 582 #if defined(DIAGNOSTIC) 583 #define bus_space_write_region_1(t, h, o, a, c) do { \ 584 if (!c) panic("bus_space_write_region_1 called with zero count."); \ 585 (h).bswr1(t,&(h),o,a,c); } while (0) 586 #define bus_space_write_region_2(t, h, o, a, c) do { \ 587 if (!c) panic("bus_space_write_region_2 called with zero count."); \ 588 (h).bswr2(t,&(h),o,a,c); } while (0) 589 #define bus_space_write_region_4(t, h, o, a, c) do { \ 590 if (!c) panic("bus_space_write_region_4 called with zero count."); \ 591 (h).bswr4(t,&(h),o,a,c); } while (0) 592 #define bus_space_write_region_stream_1(t, h, o, a, c) do { \ 593 if (!c) panic("bus_space_write_region_stream_1 called with count=0."); \ 594 (h).bswrs1(t,&(h),o,a,c); } while (0) 595 #define bus_space_write_region_stream_2(t, h, o, a, c) do { \ 596 if (!c) panic("bus_space_write_region_stream_2 called with count=0."); \ 597 (h).bswrs2(t,&(h),o,a,c); } while (0) 598 #define bus_space_write_region_stream_4(t, h, o, a, c) do { \ 599 if (!c) panic("bus_space_write_region_stream_4 called with count=0."); \ 600 (h).bswrs4(t,&(h),o,a,c); } while (0) 601 #else 602 #define bus_space_write_region_1(t, h, o, a, c) \ 603 do { if (c) (h).bswr1(t,&(h),o,a,c); } while (0) 604 #define bus_space_write_region_2(t, h, o, a, c) \ 605 do { if (c) (h).bswr2(t,&(h),o,a,c); } while (0) 606 #define bus_space_write_region_4(t, h, o, a, c) \ 607 do { if (c) (h).bswr4(t,&(h),o,a,c); } while (0) 608 #define bus_space_write_region_stream_1(t, h, o, a, c) \ 609 do { if (c) (h).bswrs1(t,&(h),o,a,c); } while (0) 610 #define bus_space_write_region_stream_2(t, h, o, a, c) \ 611 do { if (c) (h).bswrs2(t,&(h),o,a,c); } while (0) 612 #define bus_space_write_region_stream_4(t, h, o, a, c) \ 613 do { if (c) (h).bswrs4(t,&(h),o,a,c); } while (0) 614 #endif 615 616 #if 0 /* Cause a link error for bus_space_write_region_8 */ 617 #define bus_space_write_region_8 \ 618 !!! bus_space_write_region_8 unimplemented !!! 619 #define bus_space_write_region_stream_8 \ 620 !!! bus_space_write_region_stream_8 unimplemented !!! 621 #endif 622 623 /* 624 * void bus_space_set_multi_N __P((bus_space_tag_t tag, 625 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 626 * size_t count)); 627 * 628 * Write the 1, 2, 4, or 8 byte value `val' to bus space described 629 * by tag/handle/offset `count' times. 630 */ 631 632 void mac68k_bssm1 __P((bus_space_tag_t t, bus_space_handle_t *h, 633 bus_size_t o, u_int8_t v, size_t c)); 634 void mac68k_bssm1_gen __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_bssm2 __P((bus_space_tag_t t, bus_space_handle_t *h, 637 bus_size_t o, u_int16_t v, size_t c)); 638 void mac68k_bssm2_swap __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_gen __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_bssm4 __P((bus_space_tag_t t, bus_space_handle_t *h, 643 bus_size_t o, u_int32_t v, size_t c)); 644 void mac68k_bssm4_swap __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_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 647 bus_size_t o, u_int32_t v, size_t c)); 648 649 #if defined(DIAGNOSTIC) 650 #define bus_space_set_multi_1(t, h, o, val, c) do { \ 651 if (!c) panic("bus_space_set_multi_1 called with zero count."); \ 652 (h).bssm1(t,&(h),o,val,c); } while (0) 653 #define bus_space_set_multi_2(t, h, o, val, c) do { \ 654 if (!c) panic("bus_space_set_multi_2 called with zero count."); \ 655 (h).bssm2(t,&(h),o,val,c); } while (0) 656 #define bus_space_set_multi_4(t, h, o, val, c) do { \ 657 if (!c) panic("bus_space_set_multi_4 called with zero count."); \ 658 (h).bssm4(t,&(h),o,val,c); } while (0) 659 #else 660 #define bus_space_set_multi_1(t, h, o, val, c) \ 661 do { if (c) (h).bssm1(t,&(h),o,val,c); } while (0) 662 #define bus_space_set_multi_2(t, h, o, val, c) \ 663 do { if (c) (h).bssm2(t,&(h),o,val,c); } while (0) 664 #define bus_space_set_multi_4(t, h, o, val, c) \ 665 do { if (c) (h).bssm4(t,&(h),o,val,c); } while (0) 666 #endif 667 668 #if 0 /* Cause a link error for bus_space_set_multi_8 */ 669 #define bus_space_set_multi_8 \ 670 !!! bus_space_set_multi_8 unimplemented !!! 671 #endif 672 673 /* 674 * void bus_space_set_region_N __P((bus_space_tag_t tag, 675 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 676 * size_t count)); 677 * 678 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described 679 * by tag/handle starting at `offset'. 680 */ 681 682 void mac68k_bssr1 __P((bus_space_tag_t t, bus_space_handle_t *h, 683 bus_size_t o, u_int8_t v, size_t c)); 684 void mac68k_bssr1_gen __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_bssr2 __P((bus_space_tag_t t, bus_space_handle_t *h, 687 bus_size_t o, u_int16_t v, size_t c)); 688 void mac68k_bssr2_swap __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_gen __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_bssr4 __P((bus_space_tag_t t, bus_space_handle_t *h, 693 bus_size_t o, u_int32_t v, size_t c)); 694 void mac68k_bssr4_swap __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_gen __P((bus_space_tag_t t, bus_space_handle_t *h, 697 bus_size_t o, u_int32_t v, size_t c)); 698 699 #if defined(DIAGNOSTIC) 700 #define bus_space_set_region_1(t, h, o, val, c) do { \ 701 if (!c) panic("bus_space_set_region_1 called with zero count."); \ 702 (h).bssr1(t,&(h),o,val,c); } while (0) 703 #define bus_space_set_region_2(t, h, o, val, c) do { \ 704 if (!c) panic("bus_space_set_region_2 called with zero count."); \ 705 (h).bssr2(t,&(h),o,val,c); } while (0) 706 #define bus_space_set_region_4(t, h, o, val, c) do { \ 707 if (!c) panic("bus_space_set_region_4 called with zero count."); \ 708 (h).bssr4(t,&(h),o,val,c); } while (0) 709 #else 710 #define bus_space_set_region_1(t, h, o, val, c) \ 711 do { if (c) (h).bssr1(t,&(h),o,val,c); } while (0) 712 #define bus_space_set_region_2(t, h, o, val, c) \ 713 do { if (c) (h).bssr2(t,&(h),o,val,c); } while (0) 714 #define bus_space_set_region_4(t, h, o, val, c) \ 715 do { if (c) (h).bssr4(t,&(h),o,val,c); } while (0) 716 #endif 717 718 #if 0 /* Cause a link error for bus_space_set_region_8 */ 719 #define bus_space_set_region_8 \ 720 !!! bus_space_set_region_8 unimplemented !!! 721 #endif 722 723 /* 724 * void bus_space_copy_N __P((bus_space_tag_t tag, 725 * bus_space_handle_t bsh1, bus_size_t off1, 726 * bus_space_handle_t bsh2, bus_size_t off2, 727 * size_t count)); 728 * 729 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting 730 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. 731 */ 732 733 #define __MAC68K_copy_region_N(BYTES) \ 734 static __inline void __CONCAT(bus_space_copy_region_,BYTES) \ 735 __P((bus_space_tag_t, \ 736 bus_space_handle_t bsh1, bus_size_t off1, \ 737 bus_space_handle_t bsh2, bus_size_t off2, \ 738 bus_size_t count)); \ 739 \ 740 static __inline void \ 741 __CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c) \ 742 bus_space_tag_t t; \ 743 bus_space_handle_t h1, h2; \ 744 bus_size_t o1, o2, c; \ 745 { \ 746 bus_size_t o; \ 747 \ 748 if ((h1.base + o1) >= (h2.base + o2)) { \ 749 /* src after dest: copy forward */ \ 750 for (o = 0; c != 0; c--, o += BYTES) \ 751 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ 752 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ 753 } else { \ 754 /* dest after src: copy backwards */ \ 755 for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \ 756 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ 757 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ 758 } \ 759 } 760 __MAC68K_copy_region_N(1) 761 __MAC68K_copy_region_N(2) 762 __MAC68K_copy_region_N(4) 763 #if 0 /* Cause a link error for bus_space_copy_8 */ 764 #define bus_space_copy_8 \ 765 !!! bus_space_copy_8 unimplemented !!! 766 #endif 767 768 #undef __MAC68K_copy_region_N 769 770 /* 771 * Bus read/write barrier methods. 772 * 773 * void bus_space_barrier __P((bus_space_tag_t tag, 774 * bus_space_handle_t bsh, bus_size_t offset, 775 * bus_size_t len, int flags)); 776 * 777 * Note: the 680x0 does not currently require barriers, but we must 778 * provide the flags to MI code. 779 */ 780 #define bus_space_barrier(t, h, o, l, f) \ 781 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f))) 782 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 783 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 784 785 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 786 787 #endif /* _MAC68K_BUS_H_ */ 788