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