1 /* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */ 2 3 /*- 4 * SPDX-License-Identifier: BSD-2-Clause AND BSD-4-Clause 5 * 6 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to The NetBSD Foundation 10 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 11 * NASA Ames Research Center. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 /*- 36 * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 37 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 38 * 39 * Redistribution and use in source and binary forms, with or without 40 * modification, are permitted provided that the following conditions 41 * are met: 42 * 1. Redistributions of source code must retain the above copyright 43 * notice, this list of conditions and the following disclaimer. 44 * 2. Redistributions in binary form must reproduce the above copyright 45 * notice, this list of conditions and the following disclaimer in the 46 * documentation and/or other materials provided with the distribution. 47 * 3. All advertising materials mentioning features or use of this software 48 * must display the following acknowledgement: 49 * This product includes software developed by Christopher G. Demetriou 50 * for the NetBSD Project. 51 * 4. 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 * $FreeBSD$ 66 */ 67 68 #ifndef _MACHINE_BUS_H_ 69 #define _MACHINE_BUS_H_ 70 71 #include <machine/_bus.h> 72 73 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 74 75 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFFUL 76 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFFUL 77 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFFUL 78 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFFUL 79 80 #ifdef __powerpc64__ 81 #define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL 82 #define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL 83 #else 84 #ifdef BOOKE 85 #define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL 86 #define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL 87 #else 88 #define BUS_SPACE_MAXADDR 0xFFFFFFFFUL 89 #define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL 90 #endif 91 #endif 92 93 #define BUS_SPACE_MAP_CACHEABLE 0x01 94 #define BUS_SPACE_MAP_LINEAR 0x02 95 #define BUS_SPACE_MAP_PREFETCHABLE 0x04 96 97 #define BUS_SPACE_UNRESTRICTED (~0) 98 99 #define BUS_SPACE_BARRIER_READ 0x01 100 #define BUS_SPACE_BARRIER_WRITE 0x02 101 102 struct bus_space_access; 103 104 struct bus_space { 105 /* mapping/unmapping */ 106 int (*bs_map)(bus_addr_t, bus_size_t, int, 107 bus_space_handle_t *); 108 void (*bs_unmap)(bus_size_t); 109 int (*bs_subregion)(bus_space_handle_t, bus_size_t, 110 bus_size_t, bus_space_handle_t *); 111 112 /* allocation/deallocation */ 113 int (*bs_alloc)(bus_addr_t, bus_addr_t, bus_size_t, 114 bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *); 115 void (*bs_free)(bus_space_handle_t, bus_size_t); 116 117 void (*bs_barrier)(bus_space_handle_t, bus_size_t, 118 bus_size_t, int); 119 120 /* Read single. */ 121 uint8_t (*bs_r_1)(bus_space_handle_t, bus_size_t); 122 uint16_t (*bs_r_2)(bus_space_handle_t, bus_size_t); 123 uint32_t (*bs_r_4)(bus_space_handle_t, bus_size_t); 124 uint64_t (*bs_r_8)(bus_space_handle_t, bus_size_t); 125 126 uint16_t (*bs_r_s_2)(bus_space_handle_t, bus_size_t); 127 uint32_t (*bs_r_s_4)(bus_space_handle_t, bus_size_t); 128 uint64_t (*bs_r_s_8)(bus_space_handle_t, bus_size_t); 129 130 /* read multiple */ 131 void (*bs_rm_1)(bus_space_handle_t, bus_size_t, uint8_t *, 132 bus_size_t); 133 void (*bs_rm_2)(bus_space_handle_t, bus_size_t, uint16_t *, 134 bus_size_t); 135 void (*bs_rm_4)(bus_space_handle_t, bus_size_t, uint32_t *, 136 bus_size_t); 137 void (*bs_rm_8)(bus_space_handle_t, bus_size_t, uint64_t *, 138 bus_size_t); 139 140 void (*bs_rm_s_2)(bus_space_handle_t, bus_size_t, uint16_t *, 141 bus_size_t); 142 void (*bs_rm_s_4)(bus_space_handle_t, bus_size_t, uint32_t *, 143 bus_size_t); 144 void (*bs_rm_s_8)(bus_space_handle_t, bus_size_t, uint64_t *, 145 bus_size_t); 146 147 /* read region */ 148 void (*bs_rr_1)(bus_space_handle_t, bus_size_t, uint8_t *, 149 bus_size_t); 150 void (*bs_rr_2)(bus_space_handle_t, bus_size_t, uint16_t *, 151 bus_size_t); 152 void (*bs_rr_4)(bus_space_handle_t, bus_size_t, uint32_t *, 153 bus_size_t); 154 void (*bs_rr_8)(bus_space_handle_t, bus_size_t, uint64_t *, 155 bus_size_t); 156 157 void (*bs_rr_s_2)(bus_space_handle_t, bus_size_t, uint16_t *, 158 bus_size_t); 159 void (*bs_rr_s_4)(bus_space_handle_t, bus_size_t, uint32_t *, 160 bus_size_t); 161 void (*bs_rr_s_8)(bus_space_handle_t, bus_size_t, uint64_t *, 162 bus_size_t); 163 164 /* write */ 165 void (*bs_w_1)(bus_space_handle_t, bus_size_t, uint8_t); 166 void (*bs_w_2)(bus_space_handle_t, bus_size_t, uint16_t); 167 void (*bs_w_4)(bus_space_handle_t, bus_size_t, uint32_t); 168 void (*bs_w_8)(bus_space_handle_t, bus_size_t, uint64_t); 169 170 void (*bs_w_s_2)(bus_space_handle_t, bus_size_t, uint16_t); 171 void (*bs_w_s_4)(bus_space_handle_t, bus_size_t, uint32_t); 172 void (*bs_w_s_8)(bus_space_handle_t, bus_size_t, uint64_t); 173 174 /* write multiple */ 175 void (*bs_wm_1)(bus_space_handle_t, bus_size_t, 176 const uint8_t *, bus_size_t); 177 void (*bs_wm_2)(bus_space_handle_t, bus_size_t, 178 const uint16_t *, bus_size_t); 179 void (*bs_wm_4)(bus_space_handle_t, bus_size_t, 180 const uint32_t *, bus_size_t); 181 void (*bs_wm_8)(bus_space_handle_t, bus_size_t, 182 const uint64_t *, bus_size_t); 183 184 void (*bs_wm_s_2)(bus_space_handle_t, bus_size_t, 185 const uint16_t *, bus_size_t); 186 void (*bs_wm_s_4)(bus_space_handle_t, bus_size_t, 187 const uint32_t *, bus_size_t); 188 void (*bs_wm_s_8)(bus_space_handle_t, bus_size_t, 189 const uint64_t *, bus_size_t); 190 191 /* write region */ 192 void (*bs_wr_1)(bus_space_handle_t, bus_size_t, 193 const uint8_t *, bus_size_t); 194 void (*bs_wr_2)(bus_space_handle_t, bus_size_t, 195 const uint16_t *, bus_size_t); 196 void (*bs_wr_4)(bus_space_handle_t, bus_size_t, 197 const uint32_t *, bus_size_t); 198 void (*bs_wr_8)(bus_space_handle_t, bus_size_t, 199 const uint64_t *, bus_size_t); 200 201 void (*bs_wr_s_2)(bus_space_handle_t, bus_size_t, 202 const uint16_t *, bus_size_t); 203 void (*bs_wr_s_4)(bus_space_handle_t, bus_size_t, 204 const uint32_t *, bus_size_t); 205 void (*bs_wr_s_8)(bus_space_handle_t, bus_size_t, 206 const uint64_t *, bus_size_t); 207 208 /* set multiple */ 209 void (*bs_sm_1)(bus_space_handle_t, bus_size_t, uint8_t, 210 bus_size_t); 211 void (*bs_sm_2)(bus_space_handle_t, bus_size_t, uint16_t, 212 bus_size_t); 213 void (*bs_sm_4)(bus_space_handle_t, bus_size_t, uint32_t, 214 bus_size_t); 215 void (*bs_sm_8)(bus_space_handle_t, bus_size_t, uint64_t, 216 bus_size_t); 217 218 void (*bs_sm_s_2)(bus_space_handle_t, bus_size_t, uint16_t, 219 bus_size_t); 220 void (*bs_sm_s_4)(bus_space_handle_t, bus_size_t, uint32_t, 221 bus_size_t); 222 void (*bs_sm_s_8)(bus_space_handle_t, bus_size_t, uint64_t, 223 bus_size_t); 224 225 /* set region */ 226 void (*bs_sr_1)(bus_space_handle_t, bus_size_t, uint8_t, 227 bus_size_t); 228 void (*bs_sr_2)(bus_space_handle_t, bus_size_t, uint16_t, 229 bus_size_t); 230 void (*bs_sr_4)(bus_space_handle_t, bus_size_t, uint32_t, 231 bus_size_t); 232 void (*bs_sr_8)(bus_space_handle_t, bus_size_t, uint64_t, 233 bus_size_t); 234 235 void (*bs_sr_s_2)(bus_space_handle_t, bus_size_t, uint16_t, 236 bus_size_t); 237 void (*bs_sr_s_4)(bus_space_handle_t, bus_size_t, uint32_t, 238 bus_size_t); 239 void (*bs_sr_s_8)(bus_space_handle_t, bus_size_t, uint64_t, 240 bus_size_t); 241 242 /* copy region */ 243 void (*bs_cr_1)(bus_space_handle_t, bus_size_t, 244 bus_space_handle_t, bus_size_t, bus_size_t); 245 void (*bs_cr_2)(bus_space_handle_t, bus_size_t, 246 bus_space_handle_t, bus_size_t, bus_size_t); 247 void (*bs_cr_4)(bus_space_handle_t, bus_size_t, 248 bus_space_handle_t, bus_size_t, bus_size_t); 249 void (*bs_cr_8)(bus_space_handle_t, bus_size_t, 250 bus_space_handle_t, bus_size_t, bus_size_t); 251 252 void (*bs_cr_s_2)(bus_space_handle_t, bus_size_t, 253 bus_space_handle_t, bus_size_t, bus_size_t); 254 void (*bs_cr_s_4)(bus_space_handle_t, bus_size_t, 255 bus_space_handle_t, bus_size_t, bus_size_t); 256 void (*bs_cr_s_8)(bus_space_handle_t, bus_size_t, 257 bus_space_handle_t, bus_size_t, bus_size_t); 258 }; 259 260 extern struct bus_space bs_be_tag; 261 extern struct bus_space bs_le_tag; 262 263 #define __bs_c(a,b) __CONCAT(a,b) 264 #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) 265 266 #define __bs_rs(sz, t, h, o) \ 267 (*(t)->__bs_opname(r,sz))(h, o) 268 #define __bs_ws(sz, t, h, o, v) \ 269 (*(t)->__bs_opname(w,sz))(h, o, v) 270 #define __bs_nonsingle(type, sz, t, h, o, a, c) \ 271 (*(t)->__bs_opname(type,sz))(h, o, a, c) 272 #define __bs_set(type, sz, t, h, o, v, c) \ 273 (*(t)->__bs_opname(type,sz))(h, o, v, c) 274 #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ 275 (*(t)->__bs_opname(c,sz))(h1, o1, h2, o2, cnt) 276 277 /* 278 * Mapping and unmapping operations. 279 */ 280 #define bus_space_map(t, a, s, c, hp) (*(t)->bs_map)(a, s, c, hp) 281 #define bus_space_unmap(t, h, s) (*(t)->bs_unmap)(h, s) 282 #define bus_space_subregion(t, h, o, s, hp) (*(t)->bs_subregion)(h, o, s, hp) 283 284 /* 285 * Allocation and deallocation operations. 286 */ 287 #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ 288 (*(t)->bs_alloc)(rs, re, s, a, b, c, ap, hp) 289 #define bus_space_free(t, h, s) \ 290 (*(t)->bs_free)(h, s) 291 292 /* 293 * Bus barrier operations. 294 */ 295 #define bus_space_barrier(t, h, o, l, f) (*(t)->bs_barrier)(h, o, l, f) 296 297 /* 298 * Bus read (single) operations. 299 */ 300 #define bus_space_read_1(t, h, o) __bs_rs(1,t,h,o) 301 #define bus_space_read_2(t, h, o) __bs_rs(2,t,h,o) 302 #define bus_space_read_4(t, h, o) __bs_rs(4,t,h,o) 303 #define bus_space_read_8(t, h, o) __bs_rs(8,t,h,o) 304 305 #define bus_space_read_stream_1 bus_space_read_1 306 #define bus_space_read_stream_2(t, h, o) __bs_rs(s_2,t,h,o) 307 #define bus_space_read_stream_4(t, h, o) __bs_rs(s_4,t,h,o) 308 #define bus_space_read_stream_8(t, h, o) __bs_rs(s_8,t,h,o) 309 310 /* 311 * Bus read multiple operations. 312 */ 313 #define bus_space_read_multi_1(t, h, o, a, c) \ 314 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) 315 #define bus_space_read_multi_2(t, h, o, a, c) \ 316 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) 317 #define bus_space_read_multi_4(t, h, o, a, c) \ 318 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) 319 #define bus_space_read_multi_8(t, h, o, a, c) \ 320 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) 321 322 #define bus_space_read_multi_stream_1 bus_space_read_multi_1 323 #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 324 __bs_nonsingle(rm,s_2,(t),(h),(o),(a),(c)) 325 #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 326 __bs_nonsingle(rm,s_4,(t),(h),(o),(a),(c)) 327 #define bus_space_read_multi_stream_8(t, h, o, a, c) \ 328 __bs_nonsingle(rm,s_8,(t),(h),(o),(a),(c)) 329 330 /* 331 * Bus read region operations. 332 */ 333 #define bus_space_read_region_1(t, h, o, a, c) \ 334 __bs_nonsingle(rr,1,(t),(h),(o),(a),(c)) 335 #define bus_space_read_region_2(t, h, o, a, c) \ 336 __bs_nonsingle(rr,2,(t),(h),(o),(a),(c)) 337 #define bus_space_read_region_4(t, h, o, a, c) \ 338 __bs_nonsingle(rr,4,(t),(h),(o),(a),(c)) 339 #define bus_space_read_region_8(t, h, o, a, c) \ 340 __bs_nonsingle(rr,8,(t),(h),(o),(a),(c)) 341 342 #define bus_space_read_region_stream_1 bus_space_read_region_1 343 #define bus_space_read_region_stream_2(t, h, o, a, c) \ 344 __bs_nonsingle(rr,s_2,(t),(h),(o),(a),(c)) 345 #define bus_space_read_region_stream_4(t, h, o, a, c) \ 346 __bs_nonsingle(rr,s_4,(t),(h),(o),(a),(c)) 347 #define bus_space_read_region_stream_8(t, h, o, a, c) \ 348 __bs_nonsingle(rr,s_8,(t),(h),(o),(a),(c)) 349 350 /* 351 * Bus write (single) operations. 352 */ 353 #define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v)) 354 #define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v)) 355 #define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v)) 356 #define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v)) 357 358 #define bus_space_write_stream_1 bus_space_write_1 359 #define bus_space_write_stream_2(t, h, o, v) __bs_ws(s_2,(t),(h),(o),(v)) 360 #define bus_space_write_stream_4(t, h, o, v) __bs_ws(s_4,(t),(h),(o),(v)) 361 #define bus_space_write_stream_8(t, h, o, v) __bs_ws(s_8,(t),(h),(o),(v)) 362 363 /* 364 * Bus write multiple operations. 365 */ 366 #define bus_space_write_multi_1(t, h, o, a, c) \ 367 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) 368 #define bus_space_write_multi_2(t, h, o, a, c) \ 369 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) 370 #define bus_space_write_multi_4(t, h, o, a, c) \ 371 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) 372 #define bus_space_write_multi_8(t, h, o, a, c) \ 373 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) 374 375 #define bus_space_write_multi_stream_1 bus_space_write_multi_1 376 #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 377 __bs_nonsingle(wm,s_2,(t),(h),(o),(a),(c)) 378 #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 379 __bs_nonsingle(wm,s_4,(t),(h),(o),(a),(c)) 380 #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 381 __bs_nonsingle(wm,s_8,(t),(h),(o),(a),(c)) 382 383 /* 384 * Bus write region operations. 385 */ 386 #define bus_space_write_region_1(t, h, o, a, c) \ 387 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c)) 388 #define bus_space_write_region_2(t, h, o, a, c) \ 389 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c)) 390 #define bus_space_write_region_4(t, h, o, a, c) \ 391 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c)) 392 #define bus_space_write_region_8(t, h, o, a, c) \ 393 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c)) 394 395 #define bus_space_write_region_stream_1 bus_space_write_region_1 396 #define bus_space_write_region_stream_2(t, h, o, a, c) \ 397 __bs_nonsingle(wr,s_2,(t),(h),(o),(a),(c)) 398 #define bus_space_write_region_stream_4(t, h, o, a, c) \ 399 __bs_nonsingle(wr,s_4,(t),(h),(o),(a),(c)) 400 #define bus_space_write_region_stream_8(t, h, o, a, c) \ 401 __bs_nonsingle(wr,s_8,(t),(h),(o),(a),(c)) 402 403 /* 404 * Set multiple operations. 405 */ 406 #define bus_space_set_multi_1(t, h, o, v, c) \ 407 __bs_set(sm,1,(t),(h),(o),(v),(c)) 408 #define bus_space_set_multi_2(t, h, o, v, c) \ 409 __bs_set(sm,2,(t),(h),(o),(v),(c)) 410 #define bus_space_set_multi_4(t, h, o, v, c) \ 411 __bs_set(sm,4,(t),(h),(o),(v),(c)) 412 #define bus_space_set_multi_8(t, h, o, v, c) \ 413 __bs_set(sm,8,(t),(h),(o),(v),(c)) 414 415 #define bus_space_set_multi_stream_1 bus_space_set_multi_1 416 #define bus_space_set_multi_stream_2(t, h, o, v, c) \ 417 __bs_set(sm,s_2,(t),(h),(o),(v),(c)) 418 #define bus_space_set_multi_stream_4(t, h, o, v, c) \ 419 __bs_set(sm,s_4,(t),(h),(o),(v),(c)) 420 #define bus_space_set_multi_stream_8(t, h, o, v, c) \ 421 __bs_set(sm,s_8,(t),(h),(o),(v),(c)) 422 423 /* 424 * Set region operations. 425 */ 426 #define bus_space_set_region_1(t, h, o, v, c) \ 427 __bs_set(sr,1,(t),(h),(o),(v),(c)) 428 #define bus_space_set_region_2(t, h, o, v, c) \ 429 __bs_set(sr,2,(t),(h),(o),(v),(c)) 430 #define bus_space_set_region_4(t, h, o, v, c) \ 431 __bs_set(sr,4,(t),(h),(o),(v),(c)) 432 #define bus_space_set_region_8(t, h, o, v, c) \ 433 __bs_set(sr,8,(t),(h),(o),(v),(c)) 434 435 #define bus_space_set_region_stream_1 bus_space_set_region_1 436 #define bus_space_set_region_stream_2(t, h, o, v, c) \ 437 __bs_set(sr,s_2,(t),(h),(o),(v),(c)) 438 #define bus_space_set_region_stream_4(t, h, o, v, c) \ 439 __bs_set(sr,s_4,(t),(h),(o),(v),(c)) 440 #define bus_space_set_region_stream_8(t, h, o, v, c) \ 441 __bs_set(sr,s_8,(t),(h),(o),(v),(c)) 442 443 #if 0 444 /* 445 * Copy operations. 446 */ 447 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ 448 __bs_copy(1, t, h1, o1, h2, o2, c) 449 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ 450 __bs_copy(2, t, h1, o1, h2, o2, c) 451 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ 452 __bs_copy(4, t, h1, o1, h2, o2, c) 453 #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ 454 __bs_copy(8, t, h1, o1, h2, o2, c) 455 456 #define bus_space_copy_region_stream_1 bus_space_copy_region_1 457 #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \ 458 __bs_copy(s_2, t, h1, o1, h2, o2, c) 459 #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \ 460 __bs_copy(s_4, t, h1, o1, h2, o2, c) 461 #define bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c) \ 462 __bs_copy(s_8, t, h1, o1, h2, o2, c) 463 #endif 464 465 #define BUS_PEEK_FUNC(width, type) \ 466 static inline int \ 467 bus_space_peek_##width(bus_space_tag_t tag, \ 468 bus_space_handle_t hnd, bus_size_t offset, type *value) \ 469 { \ 470 type tmp; \ 471 tmp = bus_space_read_##width(tag, hnd, offset); \ 472 *value = (type)tmp; \ 473 return (0); \ 474 } 475 BUS_PEEK_FUNC(1, uint8_t) 476 BUS_PEEK_FUNC(2, uint16_t) 477 BUS_PEEK_FUNC(4, uint32_t) 478 BUS_PEEK_FUNC(8, uint64_t) 479 480 #define BUS_POKE_FUNC(width, type) \ 481 static inline int \ 482 bus_space_poke_##width(bus_space_tag_t tag, \ 483 bus_space_handle_t hnd, bus_size_t offset, type value) \ 484 { \ 485 bus_space_write_##width(tag, hnd, offset, value); \ 486 return (0); \ 487 } 488 BUS_POKE_FUNC(1, uint8_t) 489 BUS_POKE_FUNC(2, uint16_t) 490 BUS_POKE_FUNC(4, uint32_t) 491 BUS_POKE_FUNC(8, uint64_t) 492 493 #include <machine/bus_dma.h> 494 495 #endif /* _MACHINE_BUS_H_ */ 496