1 /* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */ 2 3 /*- 4 * SPDX-License-Identifier: BSD-2-Clause-NetBSD 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 struct bus_space { 74 /* cookie */ 75 void *bs_cookie; 76 77 /* mapping/unmapping */ 78 int (*bs_map) (void *, bus_addr_t, bus_size_t, 79 int, bus_space_handle_t *); 80 void (*bs_unmap) (void *, bus_space_handle_t, bus_size_t); 81 int (*bs_subregion) (void *, bus_space_handle_t, 82 bus_size_t, bus_size_t, bus_space_handle_t *); 83 84 /* allocation/deallocation */ 85 int (*bs_alloc) (void *, bus_addr_t, bus_addr_t, 86 bus_size_t, bus_size_t, bus_size_t, int, 87 bus_addr_t *, bus_space_handle_t *); 88 void (*bs_free) (void *, bus_space_handle_t, 89 bus_size_t); 90 91 /* get kernel virtual address */ 92 /* barrier */ 93 void (*bs_barrier) (void *, bus_space_handle_t, 94 bus_size_t, bus_size_t, int); 95 96 /* read (single) */ 97 u_int8_t (*bs_r_1) (void *, bus_space_handle_t, bus_size_t); 98 u_int16_t (*bs_r_2) (void *, bus_space_handle_t, bus_size_t); 99 u_int32_t (*bs_r_4) (void *, bus_space_handle_t, bus_size_t); 100 u_int64_t (*bs_r_8) (void *, bus_space_handle_t, bus_size_t); 101 102 /* read multiple */ 103 void (*bs_rm_1) (void *, bus_space_handle_t, bus_size_t, 104 u_int8_t *, bus_size_t); 105 void (*bs_rm_2) (void *, bus_space_handle_t, bus_size_t, 106 u_int16_t *, bus_size_t); 107 void (*bs_rm_4) (void *, bus_space_handle_t, 108 bus_size_t, u_int32_t *, bus_size_t); 109 void (*bs_rm_8) (void *, bus_space_handle_t, 110 bus_size_t, u_int64_t *, bus_size_t); 111 112 /* read region */ 113 void (*bs_rr_1) (void *, bus_space_handle_t, 114 bus_size_t, u_int8_t *, bus_size_t); 115 void (*bs_rr_2) (void *, bus_space_handle_t, 116 bus_size_t, u_int16_t *, bus_size_t); 117 void (*bs_rr_4) (void *, bus_space_handle_t, 118 bus_size_t, u_int32_t *, bus_size_t); 119 void (*bs_rr_8) (void *, bus_space_handle_t, 120 bus_size_t, u_int64_t *, bus_size_t); 121 122 /* write (single) */ 123 void (*bs_w_1) (void *, bus_space_handle_t, 124 bus_size_t, u_int8_t); 125 void (*bs_w_2) (void *, bus_space_handle_t, 126 bus_size_t, u_int16_t); 127 void (*bs_w_4) (void *, bus_space_handle_t, 128 bus_size_t, u_int32_t); 129 void (*bs_w_8) (void *, bus_space_handle_t, 130 bus_size_t, u_int64_t); 131 132 /* write multiple */ 133 void (*bs_wm_1) (void *, bus_space_handle_t, 134 bus_size_t, const u_int8_t *, bus_size_t); 135 void (*bs_wm_2) (void *, bus_space_handle_t, 136 bus_size_t, const u_int16_t *, bus_size_t); 137 void (*bs_wm_4) (void *, bus_space_handle_t, 138 bus_size_t, const u_int32_t *, bus_size_t); 139 void (*bs_wm_8) (void *, bus_space_handle_t, 140 bus_size_t, const u_int64_t *, bus_size_t); 141 142 /* write region */ 143 void (*bs_wr_1) (void *, bus_space_handle_t, 144 bus_size_t, const u_int8_t *, bus_size_t); 145 void (*bs_wr_2) (void *, bus_space_handle_t, 146 bus_size_t, const u_int16_t *, bus_size_t); 147 void (*bs_wr_4) (void *, bus_space_handle_t, 148 bus_size_t, const u_int32_t *, bus_size_t); 149 void (*bs_wr_8) (void *, bus_space_handle_t, 150 bus_size_t, const u_int64_t *, bus_size_t); 151 152 /* set multiple */ 153 void (*bs_sm_1) (void *, bus_space_handle_t, 154 bus_size_t, u_int8_t, bus_size_t); 155 void (*bs_sm_2) (void *, bus_space_handle_t, 156 bus_size_t, u_int16_t, bus_size_t); 157 void (*bs_sm_4) (void *, bus_space_handle_t, 158 bus_size_t, u_int32_t, bus_size_t); 159 void (*bs_sm_8) (void *, bus_space_handle_t, 160 bus_size_t, u_int64_t, bus_size_t); 161 162 /* set region */ 163 void (*bs_sr_1) (void *, bus_space_handle_t, 164 bus_size_t, u_int8_t, bus_size_t); 165 void (*bs_sr_2) (void *, bus_space_handle_t, 166 bus_size_t, u_int16_t, bus_size_t); 167 void (*bs_sr_4) (void *, bus_space_handle_t, 168 bus_size_t, u_int32_t, bus_size_t); 169 void (*bs_sr_8) (void *, bus_space_handle_t, 170 bus_size_t, u_int64_t, bus_size_t); 171 172 /* copy */ 173 void (*bs_c_1) (void *, bus_space_handle_t, bus_size_t, 174 bus_space_handle_t, bus_size_t, bus_size_t); 175 void (*bs_c_2) (void *, bus_space_handle_t, bus_size_t, 176 bus_space_handle_t, bus_size_t, bus_size_t); 177 void (*bs_c_4) (void *, bus_space_handle_t, bus_size_t, 178 bus_space_handle_t, bus_size_t, bus_size_t); 179 void (*bs_c_8) (void *, bus_space_handle_t, bus_size_t, 180 bus_space_handle_t, bus_size_t, bus_size_t); 181 182 /* read stream (single) */ 183 u_int8_t (*bs_r_1_s) (void *, bus_space_handle_t, bus_size_t); 184 u_int16_t (*bs_r_2_s) (void *, bus_space_handle_t, bus_size_t); 185 u_int32_t (*bs_r_4_s) (void *, bus_space_handle_t, bus_size_t); 186 u_int64_t (*bs_r_8_s) (void *, bus_space_handle_t, bus_size_t); 187 188 /* read multiple stream */ 189 void (*bs_rm_1_s) (void *, bus_space_handle_t, bus_size_t, 190 u_int8_t *, bus_size_t); 191 void (*bs_rm_2_s) (void *, bus_space_handle_t, bus_size_t, 192 u_int16_t *, bus_size_t); 193 void (*bs_rm_4_s) (void *, bus_space_handle_t, 194 bus_size_t, u_int32_t *, bus_size_t); 195 void (*bs_rm_8_s) (void *, bus_space_handle_t, 196 bus_size_t, u_int64_t *, bus_size_t); 197 198 /* read region stream */ 199 void (*bs_rr_1_s) (void *, bus_space_handle_t, 200 bus_size_t, u_int8_t *, bus_size_t); 201 void (*bs_rr_2_s) (void *, bus_space_handle_t, 202 bus_size_t, u_int16_t *, bus_size_t); 203 void (*bs_rr_4_s) (void *, bus_space_handle_t, 204 bus_size_t, u_int32_t *, bus_size_t); 205 void (*bs_rr_8_s) (void *, bus_space_handle_t, 206 bus_size_t, u_int64_t *, bus_size_t); 207 208 /* write stream (single) */ 209 void (*bs_w_1_s) (void *, bus_space_handle_t, 210 bus_size_t, u_int8_t); 211 void (*bs_w_2_s) (void *, bus_space_handle_t, 212 bus_size_t, u_int16_t); 213 void (*bs_w_4_s) (void *, bus_space_handle_t, 214 bus_size_t, u_int32_t); 215 void (*bs_w_8_s) (void *, bus_space_handle_t, 216 bus_size_t, u_int64_t); 217 218 /* write multiple stream */ 219 void (*bs_wm_1_s) (void *, bus_space_handle_t, 220 bus_size_t, const u_int8_t *, bus_size_t); 221 void (*bs_wm_2_s) (void *, bus_space_handle_t, 222 bus_size_t, const u_int16_t *, bus_size_t); 223 void (*bs_wm_4_s) (void *, bus_space_handle_t, 224 bus_size_t, const u_int32_t *, bus_size_t); 225 void (*bs_wm_8_s) (void *, bus_space_handle_t, 226 bus_size_t, const u_int64_t *, bus_size_t); 227 228 /* write region stream */ 229 void (*bs_wr_1_s) (void *, bus_space_handle_t, 230 bus_size_t, const u_int8_t *, bus_size_t); 231 void (*bs_wr_2_s) (void *, bus_space_handle_t, 232 bus_size_t, const u_int16_t *, bus_size_t); 233 void (*bs_wr_4_s) (void *, bus_space_handle_t, 234 bus_size_t, const u_int32_t *, bus_size_t); 235 void (*bs_wr_8_s) (void *, bus_space_handle_t, 236 bus_size_t, const u_int64_t *, bus_size_t); 237 }; 238 239 240 /* 241 * Utility macros; INTERNAL USE ONLY. 242 */ 243 #define __bs_c(a,b) __CONCAT(a,b) 244 #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) 245 246 #define __bs_rs(sz, t, h, o) \ 247 (*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o) 248 #define __bs_ws(sz, t, h, o, v) \ 249 (*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v) 250 #define __bs_nonsingle(type, sz, t, h, o, a, c) \ 251 (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c) 252 #define __bs_set(type, sz, t, h, o, v, c) \ 253 (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, v, c) 254 #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ 255 (*(t)->__bs_opname(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt) 256 257 #define __bs_opname_s(op,size) __bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s) 258 #define __bs_rs_s(sz, t, h, o) \ 259 (*(t)->__bs_opname_s(r,sz))((t)->bs_cookie, h, o) 260 #define __bs_ws_s(sz, t, h, o, v) \ 261 (*(t)->__bs_opname_s(w,sz))((t)->bs_cookie, h, o, v) 262 #define __bs_nonsingle_s(type, sz, t, h, o, a, c) \ 263 (*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c) 264 265 266 /* 267 * Mapping and unmapping operations. 268 */ 269 #define bus_space_map(t, a, s, c, hp) \ 270 (*(t)->bs_map)((t)->bs_cookie, (a), (s), (c), (hp)) 271 #define bus_space_unmap(t, h, s) \ 272 (*(t)->bs_unmap)((t)->bs_cookie, (h), (s)) 273 #define bus_space_subregion(t, h, o, s, hp) \ 274 (*(t)->bs_subregion)((t)->bs_cookie, (h), (o), (s), (hp)) 275 276 277 /* 278 * Allocation and deallocation operations. 279 */ 280 #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ 281 (*(t)->bs_alloc)((t)->bs_cookie, (rs), (re), (s), (a), (b), \ 282 (c), (ap), (hp)) 283 #define bus_space_free(t, h, s) \ 284 (*(t)->bs_free)((t)->bs_cookie, (h), (s)) 285 286 /* 287 * Bus barrier operations. 288 */ 289 #define bus_space_barrier(t, h, o, l, f) \ 290 (*(t)->bs_barrier)((t)->bs_cookie, (h), (o), (l), (f)) 291 292 #define BUS_SPACE_BARRIER_READ 0x01 293 #define BUS_SPACE_BARRIER_WRITE 0x02 294 295 /* 296 * Bus read (single) operations. 297 */ 298 #define bus_space_read_1(t, h, o) __bs_rs(1,(t),(h),(o)) 299 #define bus_space_read_2(t, h, o) __bs_rs(2,(t),(h),(o)) 300 #define bus_space_read_4(t, h, o) __bs_rs(4,(t),(h),(o)) 301 #define bus_space_read_8(t, h, o) __bs_rs(8,(t),(h),(o)) 302 303 #define bus_space_read_stream_1(t, h, o) __bs_rs_s(1,(t), (h), (o)) 304 #define bus_space_read_stream_2(t, h, o) __bs_rs_s(2,(t), (h), (o)) 305 #define bus_space_read_stream_4(t, h, o) __bs_rs_s(4,(t), (h), (o)) 306 #define bus_space_read_stream_8(t, h, o) __bs_rs_s(8,8,(t),(h),(o)) 307 308 /* 309 * Bus read multiple operations. 310 */ 311 #define bus_space_read_multi_1(t, h, o, a, c) \ 312 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) 313 #define bus_space_read_multi_2(t, h, o, a, c) \ 314 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) 315 #define bus_space_read_multi_4(t, h, o, a, c) \ 316 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) 317 #define bus_space_read_multi_8(t, h, o, a, c) \ 318 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) 319 320 #define bus_space_read_multi_stream_1(t, h, o, a, c) \ 321 __bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c)) 322 #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 323 __bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c)) 324 #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 325 __bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c)) 326 #define bus_space_read_multi_stream_8(t, h, o, a, c) \ 327 __bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c)) 328 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(t, h, o, a, c) \ 343 __bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c)) 344 #define bus_space_read_region_stream_2(t, h, o, a, c) \ 345 __bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c)) 346 #define bus_space_read_region_stream_4(t, h, o, a, c) \ 347 __bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c)) 348 #define bus_space_read_region_stream_8(t, h, o, a, c) \ 349 __bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c)) 350 351 352 /* 353 * Bus write (single) operations. 354 */ 355 #define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v)) 356 #define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v)) 357 #define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v)) 358 #define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v)) 359 360 #define bus_space_write_stream_1(t, h, o, v) __bs_ws_s(1,(t),(h),(o),(v)) 361 #define bus_space_write_stream_2(t, h, o, v) __bs_ws_s(2,(t),(h),(o),(v)) 362 #define bus_space_write_stream_4(t, h, o, v) __bs_ws_s(4,(t),(h),(o),(v)) 363 #define bus_space_write_stream_8(t, h, o, v) __bs_ws_s(8,(t),(h),(o),(v)) 364 365 366 /* 367 * Bus write multiple operations. 368 */ 369 #define bus_space_write_multi_1(t, h, o, a, c) \ 370 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) 371 #define bus_space_write_multi_2(t, h, o, a, c) \ 372 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) 373 #define bus_space_write_multi_4(t, h, o, a, c) \ 374 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) 375 #define bus_space_write_multi_8(t, h, o, a, c) \ 376 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) 377 378 #define bus_space_write_multi_stream_1(t, h, o, a, c) \ 379 __bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c)) 380 #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 381 __bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c)) 382 #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 383 __bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c)) 384 #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 385 __bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c)) 386 387 388 /* 389 * Bus write region operations. 390 */ 391 #define bus_space_write_region_1(t, h, o, a, c) \ 392 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c)) 393 #define bus_space_write_region_2(t, h, o, a, c) \ 394 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c)) 395 #define bus_space_write_region_4(t, h, o, a, c) \ 396 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c)) 397 #define bus_space_write_region_8(t, h, o, a, c) \ 398 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c)) 399 400 #define bus_space_write_region_stream_1(t, h, o, a, c) \ 401 __bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c)) 402 #define bus_space_write_region_stream_2(t, h, o, a, c) \ 403 __bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c)) 404 #define bus_space_write_region_stream_4(t, h, o, a, c) \ 405 __bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c)) 406 #define bus_space_write_region_stream_8(t, h, o, a, c) \ 407 __bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c)) 408 409 410 /* 411 * Set multiple operations. 412 */ 413 #define bus_space_set_multi_1(t, h, o, v, c) \ 414 __bs_set(sm,1,(t),(h),(o),(v),(c)) 415 #define bus_space_set_multi_2(t, h, o, v, c) \ 416 __bs_set(sm,2,(t),(h),(o),(v),(c)) 417 #define bus_space_set_multi_4(t, h, o, v, c) \ 418 __bs_set(sm,4,(t),(h),(o),(v),(c)) 419 #define bus_space_set_multi_8(t, h, o, v, c) \ 420 __bs_set(sm,8,(t),(h),(o),(v),(c)) 421 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 436 /* 437 * Copy operations. 438 */ 439 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ 440 __bs_copy(1, t, h1, o1, h2, o2, c) 441 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ 442 __bs_copy(2, t, h1, o1, h2, o2, c) 443 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ 444 __bs_copy(4, t, h1, o1, h2, o2, c) 445 #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ 446 __bs_copy(8, t, h1, o1, h2, o2, c) 447 448 /* 449 * Macros to provide prototypes for all the functions used in the 450 * bus_space structure 451 */ 452 453 #define bs_map_proto(f) \ 454 int __bs_c(f,_bs_map) (void *t, bus_addr_t addr, \ 455 bus_size_t size, int cacheable, bus_space_handle_t *bshp); 456 457 #define bs_unmap_proto(f) \ 458 void __bs_c(f,_bs_unmap) (void *t, bus_space_handle_t bsh, \ 459 bus_size_t size); 460 461 #define bs_subregion_proto(f) \ 462 int __bs_c(f,_bs_subregion) (void *t, bus_space_handle_t bsh, \ 463 bus_size_t offset, bus_size_t size, \ 464 bus_space_handle_t *nbshp); 465 466 #define bs_alloc_proto(f) \ 467 int __bs_c(f,_bs_alloc) (void *t, bus_addr_t rstart, \ 468 bus_addr_t rend, bus_size_t size, bus_size_t align, \ 469 bus_size_t boundary, int cacheable, bus_addr_t *addrp, \ 470 bus_space_handle_t *bshp); 471 472 #define bs_free_proto(f) \ 473 void __bs_c(f,_bs_free) (void *t, bus_space_handle_t bsh, \ 474 bus_size_t size); 475 476 #define bs_barrier_proto(f) \ 477 void __bs_c(f,_bs_barrier) (void *t, bus_space_handle_t bsh, \ 478 bus_size_t offset, bus_size_t len, int flags); 479 480 #define bs_r_1_proto(f) \ 481 u_int8_t __bs_c(f,_bs_r_1) (void *t, bus_space_handle_t bsh, \ 482 bus_size_t offset); 483 484 #define bs_r_2_proto(f) \ 485 u_int16_t __bs_c(f,_bs_r_2) (void *t, bus_space_handle_t bsh, \ 486 bus_size_t offset); 487 488 #define bs_r_4_proto(f) \ 489 u_int32_t __bs_c(f,_bs_r_4) (void *t, bus_space_handle_t bsh, \ 490 bus_size_t offset); 491 492 #define bs_r_8_proto(f) \ 493 u_int64_t __bs_c(f,_bs_r_8) (void *t, bus_space_handle_t bsh, \ 494 bus_size_t offset); 495 496 #define bs_r_1_s_proto(f) \ 497 u_int8_t __bs_c(f,_bs_r_1_s) (void *t, bus_space_handle_t bsh, \ 498 bus_size_t offset); 499 500 #define bs_r_2_s_proto(f) \ 501 u_int16_t __bs_c(f,_bs_r_2_s) (void *t, bus_space_handle_t bsh, \ 502 bus_size_t offset); 503 504 #define bs_r_4_s_proto(f) \ 505 u_int32_t __bs_c(f,_bs_r_4_s) (void *t, bus_space_handle_t bsh, \ 506 bus_size_t offset); 507 508 #define bs_w_1_proto(f) \ 509 void __bs_c(f,_bs_w_1) (void *t, bus_space_handle_t bsh, \ 510 bus_size_t offset, u_int8_t value); 511 512 #define bs_w_2_proto(f) \ 513 void __bs_c(f,_bs_w_2) (void *t, bus_space_handle_t bsh, \ 514 bus_size_t offset, u_int16_t value); 515 516 #define bs_w_4_proto(f) \ 517 void __bs_c(f,_bs_w_4) (void *t, bus_space_handle_t bsh, \ 518 bus_size_t offset, u_int32_t value); 519 520 #define bs_w_8_proto(f) \ 521 void __bs_c(f,_bs_w_8) (void *t, bus_space_handle_t bsh, \ 522 bus_size_t offset, u_int64_t value); 523 524 #define bs_w_1_s_proto(f) \ 525 void __bs_c(f,_bs_w_1_s) (void *t, bus_space_handle_t bsh, \ 526 bus_size_t offset, u_int8_t value); 527 528 #define bs_w_2_s_proto(f) \ 529 void __bs_c(f,_bs_w_2_s) (void *t, bus_space_handle_t bsh, \ 530 bus_size_t offset, u_int16_t value); 531 532 #define bs_w_4_s_proto(f) \ 533 void __bs_c(f,_bs_w_4_s) (void *t, bus_space_handle_t bsh, \ 534 bus_size_t offset, u_int32_t value); 535 536 #define bs_rm_1_proto(f) \ 537 void __bs_c(f,_bs_rm_1) (void *t, bus_space_handle_t bsh, \ 538 bus_size_t offset, u_int8_t *addr, bus_size_t count); 539 540 #define bs_rm_2_proto(f) \ 541 void __bs_c(f,_bs_rm_2) (void *t, bus_space_handle_t bsh, \ 542 bus_size_t offset, u_int16_t *addr, bus_size_t count); 543 544 #define bs_rm_4_proto(f) \ 545 void __bs_c(f,_bs_rm_4) (void *t, bus_space_handle_t bsh, \ 546 bus_size_t offset, u_int32_t *addr, bus_size_t count); 547 548 #define bs_rm_8_proto(f) \ 549 void __bs_c(f,_bs_rm_8) (void *t, bus_space_handle_t bsh, \ 550 bus_size_t offset, u_int64_t *addr, bus_size_t count); 551 552 #define bs_wm_1_proto(f) \ 553 void __bs_c(f,_bs_wm_1) (void *t, bus_space_handle_t bsh, \ 554 bus_size_t offset, const u_int8_t *addr, bus_size_t count); 555 556 #define bs_wm_2_proto(f) \ 557 void __bs_c(f,_bs_wm_2) (void *t, bus_space_handle_t bsh, \ 558 bus_size_t offset, const u_int16_t *addr, bus_size_t count); 559 560 #define bs_wm_4_proto(f) \ 561 void __bs_c(f,_bs_wm_4) (void *t, bus_space_handle_t bsh, \ 562 bus_size_t offset, const u_int32_t *addr, bus_size_t count); 563 564 #define bs_wm_8_proto(f) \ 565 void __bs_c(f,_bs_wm_8) (void *t, bus_space_handle_t bsh, \ 566 bus_size_t offset, const u_int64_t *addr, bus_size_t count); 567 568 #define bs_rr_1_proto(f) \ 569 void __bs_c(f, _bs_rr_1) (void *t, bus_space_handle_t bsh, \ 570 bus_size_t offset, u_int8_t *addr, bus_size_t count); 571 572 #define bs_rr_2_proto(f) \ 573 void __bs_c(f, _bs_rr_2) (void *t, bus_space_handle_t bsh, \ 574 bus_size_t offset, u_int16_t *addr, bus_size_t count); 575 576 #define bs_rr_4_proto(f) \ 577 void __bs_c(f, _bs_rr_4) (void *t, bus_space_handle_t bsh, \ 578 bus_size_t offset, u_int32_t *addr, bus_size_t count); 579 580 #define bs_rr_8_proto(f) \ 581 void __bs_c(f, _bs_rr_8) (void *t, bus_space_handle_t bsh, \ 582 bus_size_t offset, u_int64_t *addr, bus_size_t count); 583 584 #define bs_wr_1_proto(f) \ 585 void __bs_c(f, _bs_wr_1) (void *t, bus_space_handle_t bsh, \ 586 bus_size_t offset, const u_int8_t *addr, bus_size_t count); 587 588 #define bs_wr_2_proto(f) \ 589 void __bs_c(f, _bs_wr_2) (void *t, bus_space_handle_t bsh, \ 590 bus_size_t offset, const u_int16_t *addr, bus_size_t count); 591 592 #define bs_wr_4_proto(f) \ 593 void __bs_c(f, _bs_wr_4) (void *t, bus_space_handle_t bsh, \ 594 bus_size_t offset, const u_int32_t *addr, bus_size_t count); 595 596 #define bs_wr_8_proto(f) \ 597 void __bs_c(f, _bs_wr_8) (void *t, bus_space_handle_t bsh, \ 598 bus_size_t offset, const u_int64_t *addr, bus_size_t count); 599 600 #define bs_sm_1_proto(f) \ 601 void __bs_c(f,_bs_sm_1) (void *t, bus_space_handle_t bsh, \ 602 bus_size_t offset, u_int8_t value, bus_size_t count); 603 604 #define bs_sm_2_proto(f) \ 605 void __bs_c(f,_bs_sm_2) (void *t, bus_space_handle_t bsh, \ 606 bus_size_t offset, u_int16_t value, bus_size_t count); 607 608 #define bs_sm_4_proto(f) \ 609 void __bs_c(f,_bs_sm_4) (void *t, bus_space_handle_t bsh, \ 610 bus_size_t offset, u_int32_t value, bus_size_t count); 611 612 #define bs_sm_8_proto(f) \ 613 void __bs_c(f,_bs_sm_8) (void *t, bus_space_handle_t bsh, \ 614 bus_size_t offset, u_int64_t value, bus_size_t count); 615 616 #define bs_sr_1_proto(f) \ 617 void __bs_c(f,_bs_sr_1) (void *t, bus_space_handle_t bsh, \ 618 bus_size_t offset, u_int8_t value, bus_size_t count); 619 620 #define bs_sr_2_proto(f) \ 621 void __bs_c(f,_bs_sr_2) (void *t, bus_space_handle_t bsh, \ 622 bus_size_t offset, u_int16_t value, bus_size_t count); 623 624 #define bs_sr_4_proto(f) \ 625 void __bs_c(f,_bs_sr_4) (void *t, bus_space_handle_t bsh, \ 626 bus_size_t offset, u_int32_t value, bus_size_t count); 627 628 #define bs_sr_8_proto(f) \ 629 void __bs_c(f,_bs_sr_8) (void *t, bus_space_handle_t bsh, \ 630 bus_size_t offset, u_int64_t value, bus_size_t count); 631 632 #define bs_c_1_proto(f) \ 633 void __bs_c(f,_bs_c_1) (void *t, bus_space_handle_t bsh1, \ 634 bus_size_t offset1, bus_space_handle_t bsh2, \ 635 bus_size_t offset2, bus_size_t count); 636 637 #define bs_c_2_proto(f) \ 638 void __bs_c(f,_bs_c_2) (void *t, bus_space_handle_t bsh1, \ 639 bus_size_t offset1, bus_space_handle_t bsh2, \ 640 bus_size_t offset2, bus_size_t count); 641 642 #define bs_c_4_proto(f) \ 643 void __bs_c(f,_bs_c_4) (void *t, bus_space_handle_t bsh1, \ 644 bus_size_t offset1, bus_space_handle_t bsh2, \ 645 bus_size_t offset2, bus_size_t count); 646 647 #define bs_c_8_proto(f) \ 648 void __bs_c(f,_bs_c_8) (void *t, bus_space_handle_t bsh1, \ 649 bus_size_t offset1, bus_space_handle_t bsh2, \ 650 bus_size_t offset2, bus_size_t count); 651 652 #define DECLARE_BUS_SPACE_PROTOTYPES(f) \ 653 bs_map_proto(f); \ 654 bs_unmap_proto(f); \ 655 bs_subregion_proto(f); \ 656 bs_alloc_proto(f); \ 657 bs_free_proto(f); \ 658 bs_barrier_proto(f); \ 659 bs_r_1_proto(f); \ 660 bs_r_2_proto(f); \ 661 bs_r_4_proto(f); \ 662 bs_r_8_proto(f); \ 663 bs_r_1_s_proto(f); \ 664 bs_r_2_s_proto(f); \ 665 bs_r_4_s_proto(f); \ 666 bs_w_1_proto(f); \ 667 bs_w_2_proto(f); \ 668 bs_w_4_proto(f); \ 669 bs_w_8_proto(f); \ 670 bs_w_1_s_proto(f); \ 671 bs_w_2_s_proto(f); \ 672 bs_w_4_s_proto(f); \ 673 bs_rm_1_proto(f); \ 674 bs_rm_2_proto(f); \ 675 bs_rm_4_proto(f); \ 676 bs_rm_8_proto(f); \ 677 bs_wm_1_proto(f); \ 678 bs_wm_2_proto(f); \ 679 bs_wm_4_proto(f); \ 680 bs_wm_8_proto(f); \ 681 bs_rr_1_proto(f); \ 682 bs_rr_2_proto(f); \ 683 bs_rr_4_proto(f); \ 684 bs_rr_8_proto(f); \ 685 bs_wr_1_proto(f); \ 686 bs_wr_2_proto(f); \ 687 bs_wr_4_proto(f); \ 688 bs_wr_8_proto(f); \ 689 bs_sm_1_proto(f); \ 690 bs_sm_2_proto(f); \ 691 bs_sm_4_proto(f); \ 692 bs_sm_8_proto(f); \ 693 bs_sr_1_proto(f); \ 694 bs_sr_2_proto(f); \ 695 bs_sr_4_proto(f); \ 696 bs_sr_8_proto(f); \ 697 bs_c_1_proto(f); \ 698 bs_c_2_proto(f); \ 699 bs_c_4_proto(f); \ 700 bs_c_8_proto(f); 701 702 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 703 704 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF 705 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF 706 707 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF 708 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF 709 710 #if defined(__mips_n64) 711 #define BUS_SPACE_MAXADDR 0xFFFFFFFFFFFFFFFFUL 712 #define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFFUL 713 #else 714 #define BUS_SPACE_MAXADDR 0xFFFFFFFFUL 715 #define BUS_SPACE_MAXSIZE 0xFFFFFFFFUL 716 #endif 717 718 719 #define BUS_SPACE_UNRESTRICTED (~0) 720 721 /* 722 * declare generic bus space, it suits all needs in 723 */ 724 DECLARE_BUS_SPACE_PROTOTYPES(generic); 725 extern bus_space_tag_t mips_bus_space_generic; 726 727 /* Special bus space for RMI processors */ 728 #if defined(CPU_RMI) || defined (CPU_NLM) 729 extern bus_space_tag_t rmi_bus_space; 730 extern bus_space_tag_t rmi_pci_bus_space; 731 extern bus_space_tag_t rmi_uart_bus_space; 732 #endif 733 734 #include <machine/bus_dma.h> 735 736 #endif /* _MACHINE_BUS_H_ */ 737