1 /* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1996, 1997, 1998, 2001 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 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /*- 34 * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 35 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 36 * 37 * Redistribution and use in source and binary forms, with or without 38 * modification, are permitted provided that the following conditions 39 * are met: 40 * 1. Redistributions of source code must retain the above copyright 41 * notice, this list of conditions and the following disclaimer. 42 * 2. Redistributions in binary form must reproduce the above copyright 43 * notice, this list of conditions and the following disclaimer in the 44 * documentation and/or other materials provided with the distribution. 45 * 3. All advertising materials mentioning features or use of this software 46 * must display the following acknowledgement: 47 * This product includes software developed by Christopher G. Demetriou 48 * for the NetBSD Project. 49 * 4. The name of the author may not be used to endorse or promote products 50 * derived from this software without specific prior written permission 51 * 52 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 62 * 63 * $FreeBSD$ 64 */ 65 66 #ifndef _MACHINE_BUS_H_ 67 #define _MACHINE_BUS_H_ 68 69 #include <machine/_bus.h> 70 71 /* 72 * int bus_space_map (bus_space_tag_t t, bus_addr_t addr, 73 * bus_size_t size, int flags, bus_space_handle_t *bshp); 74 * 75 * Map a region of bus space. 76 */ 77 78 #define BUS_SPACE_MAP_CACHEABLE 0x01 79 #define BUS_SPACE_MAP_LINEAR 0x02 80 #define BUS_SPACE_MAP_PREFETCHABLE 0x04 81 82 struct bus_space { 83 /* cookie */ 84 void *bs_cookie; 85 86 /* mapping/unmapping */ 87 int (*bs_map) (void *, bus_addr_t, bus_size_t, 88 int, bus_space_handle_t *); 89 void (*bs_unmap) (void *, bus_space_handle_t, bus_size_t); 90 int (*bs_subregion) (void *, bus_space_handle_t, 91 bus_size_t, bus_size_t, bus_space_handle_t *); 92 93 /* allocation/deallocation */ 94 int (*bs_alloc) (void *, bus_addr_t, bus_addr_t, 95 bus_size_t, bus_size_t, bus_size_t, int, 96 bus_addr_t *, bus_space_handle_t *); 97 void (*bs_free) (void *, bus_space_handle_t, 98 bus_size_t); 99 100 /* get kernel virtual address */ 101 /* barrier */ 102 void (*bs_barrier) (void *, bus_space_handle_t, 103 bus_size_t, bus_size_t, int); 104 105 /* read (single) */ 106 u_int8_t (*bs_r_1) (void *, bus_space_handle_t, bus_size_t); 107 u_int16_t (*bs_r_2) (void *, bus_space_handle_t, bus_size_t); 108 u_int32_t (*bs_r_4) (void *, bus_space_handle_t, bus_size_t); 109 u_int64_t (*bs_r_8) (void *, bus_space_handle_t, bus_size_t); 110 111 /* read multiple */ 112 void (*bs_rm_1) (void *, bus_space_handle_t, bus_size_t, 113 u_int8_t *, bus_size_t); 114 void (*bs_rm_2) (void *, bus_space_handle_t, bus_size_t, 115 u_int16_t *, bus_size_t); 116 void (*bs_rm_4) (void *, bus_space_handle_t, 117 bus_size_t, u_int32_t *, bus_size_t); 118 void (*bs_rm_8) (void *, bus_space_handle_t, 119 bus_size_t, u_int64_t *, bus_size_t); 120 121 /* read region */ 122 void (*bs_rr_1) (void *, bus_space_handle_t, 123 bus_size_t, u_int8_t *, bus_size_t); 124 void (*bs_rr_2) (void *, bus_space_handle_t, 125 bus_size_t, u_int16_t *, bus_size_t); 126 void (*bs_rr_4) (void *, bus_space_handle_t, 127 bus_size_t, u_int32_t *, bus_size_t); 128 void (*bs_rr_8) (void *, bus_space_handle_t, 129 bus_size_t, u_int64_t *, bus_size_t); 130 131 /* write (single) */ 132 void (*bs_w_1) (void *, bus_space_handle_t, 133 bus_size_t, u_int8_t); 134 void (*bs_w_2) (void *, bus_space_handle_t, 135 bus_size_t, u_int16_t); 136 void (*bs_w_4) (void *, bus_space_handle_t, 137 bus_size_t, u_int32_t); 138 void (*bs_w_8) (void *, bus_space_handle_t, 139 bus_size_t, u_int64_t); 140 141 /* write multiple */ 142 void (*bs_wm_1) (void *, bus_space_handle_t, 143 bus_size_t, const u_int8_t *, bus_size_t); 144 void (*bs_wm_2) (void *, bus_space_handle_t, 145 bus_size_t, const u_int16_t *, bus_size_t); 146 void (*bs_wm_4) (void *, bus_space_handle_t, 147 bus_size_t, const u_int32_t *, bus_size_t); 148 void (*bs_wm_8) (void *, bus_space_handle_t, 149 bus_size_t, const u_int64_t *, bus_size_t); 150 151 /* write region */ 152 void (*bs_wr_1) (void *, bus_space_handle_t, 153 bus_size_t, const u_int8_t *, bus_size_t); 154 void (*bs_wr_2) (void *, bus_space_handle_t, 155 bus_size_t, const u_int16_t *, bus_size_t); 156 void (*bs_wr_4) (void *, bus_space_handle_t, 157 bus_size_t, const u_int32_t *, bus_size_t); 158 void (*bs_wr_8) (void *, bus_space_handle_t, 159 bus_size_t, const u_int64_t *, bus_size_t); 160 161 /* set multiple */ 162 void (*bs_sm_1) (void *, bus_space_handle_t, 163 bus_size_t, u_int8_t, bus_size_t); 164 void (*bs_sm_2) (void *, bus_space_handle_t, 165 bus_size_t, u_int16_t, bus_size_t); 166 void (*bs_sm_4) (void *, bus_space_handle_t, 167 bus_size_t, u_int32_t, bus_size_t); 168 void (*bs_sm_8) (void *, bus_space_handle_t, 169 bus_size_t, u_int64_t, bus_size_t); 170 171 /* set region */ 172 void (*bs_sr_1) (void *, bus_space_handle_t, 173 bus_size_t, u_int8_t, bus_size_t); 174 void (*bs_sr_2) (void *, bus_space_handle_t, 175 bus_size_t, u_int16_t, bus_size_t); 176 void (*bs_sr_4) (void *, bus_space_handle_t, 177 bus_size_t, u_int32_t, bus_size_t); 178 void (*bs_sr_8) (void *, bus_space_handle_t, 179 bus_size_t, u_int64_t, bus_size_t); 180 181 /* copy */ 182 void (*bs_c_1) (void *, bus_space_handle_t, bus_size_t, 183 bus_space_handle_t, bus_size_t, bus_size_t); 184 void (*bs_c_2) (void *, bus_space_handle_t, bus_size_t, 185 bus_space_handle_t, bus_size_t, bus_size_t); 186 void (*bs_c_4) (void *, bus_space_handle_t, bus_size_t, 187 bus_space_handle_t, bus_size_t, bus_size_t); 188 void (*bs_c_8) (void *, bus_space_handle_t, bus_size_t, 189 bus_space_handle_t, bus_size_t, bus_size_t); 190 191 /* read stream (single) */ 192 u_int8_t (*bs_r_1_s) (void *, bus_space_handle_t, bus_size_t); 193 u_int16_t (*bs_r_2_s) (void *, bus_space_handle_t, bus_size_t); 194 u_int32_t (*bs_r_4_s) (void *, bus_space_handle_t, bus_size_t); 195 u_int64_t (*bs_r_8_s) (void *, bus_space_handle_t, bus_size_t); 196 197 /* read multiple stream */ 198 void (*bs_rm_1_s) (void *, bus_space_handle_t, bus_size_t, 199 u_int8_t *, bus_size_t); 200 void (*bs_rm_2_s) (void *, bus_space_handle_t, bus_size_t, 201 u_int16_t *, bus_size_t); 202 void (*bs_rm_4_s) (void *, bus_space_handle_t, 203 bus_size_t, u_int32_t *, bus_size_t); 204 void (*bs_rm_8_s) (void *, bus_space_handle_t, 205 bus_size_t, u_int64_t *, bus_size_t); 206 207 /* read region stream */ 208 void (*bs_rr_1_s) (void *, bus_space_handle_t, 209 bus_size_t, u_int8_t *, bus_size_t); 210 void (*bs_rr_2_s) (void *, bus_space_handle_t, 211 bus_size_t, u_int16_t *, bus_size_t); 212 void (*bs_rr_4_s) (void *, bus_space_handle_t, 213 bus_size_t, u_int32_t *, bus_size_t); 214 void (*bs_rr_8_s) (void *, bus_space_handle_t, 215 bus_size_t, u_int64_t *, bus_size_t); 216 217 /* write stream (single) */ 218 void (*bs_w_1_s) (void *, bus_space_handle_t, 219 bus_size_t, u_int8_t); 220 void (*bs_w_2_s) (void *, bus_space_handle_t, 221 bus_size_t, u_int16_t); 222 void (*bs_w_4_s) (void *, bus_space_handle_t, 223 bus_size_t, u_int32_t); 224 void (*bs_w_8_s) (void *, bus_space_handle_t, 225 bus_size_t, u_int64_t); 226 227 /* write multiple stream */ 228 void (*bs_wm_1_s) (void *, bus_space_handle_t, 229 bus_size_t, const u_int8_t *, bus_size_t); 230 void (*bs_wm_2_s) (void *, bus_space_handle_t, 231 bus_size_t, const u_int16_t *, bus_size_t); 232 void (*bs_wm_4_s) (void *, bus_space_handle_t, 233 bus_size_t, const u_int32_t *, bus_size_t); 234 void (*bs_wm_8_s) (void *, bus_space_handle_t, 235 bus_size_t, const u_int64_t *, bus_size_t); 236 237 /* write region stream */ 238 void (*bs_wr_1_s) (void *, bus_space_handle_t, 239 bus_size_t, const u_int8_t *, bus_size_t); 240 void (*bs_wr_2_s) (void *, bus_space_handle_t, 241 bus_size_t, const u_int16_t *, bus_size_t); 242 void (*bs_wr_4_s) (void *, bus_space_handle_t, 243 bus_size_t, const u_int32_t *, bus_size_t); 244 void (*bs_wr_8_s) (void *, bus_space_handle_t, 245 bus_size_t, const u_int64_t *, bus_size_t); 246 }; 247 248 249 /* 250 * Utility macros; INTERNAL USE ONLY. 251 */ 252 #define __bs_c(a,b) __CONCAT(a,b) 253 #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size) 254 255 #define __bs_rs(sz, t, h, o) \ 256 (*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o) 257 #define __bs_ws(sz, t, h, o, v) \ 258 (*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v) 259 #define __bs_nonsingle(type, sz, t, h, o, a, c) \ 260 (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c) 261 #define __bs_set(type, sz, t, h, o, v, c) \ 262 (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, v, c) 263 #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \ 264 (*(t)->__bs_opname(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt) 265 266 #define __bs_opname_s(op,size) __bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s) 267 #define __bs_rs_s(sz, t, h, o) \ 268 (*(t)->__bs_opname_s(r,sz))((t)->bs_cookie, h, o) 269 #define __bs_ws_s(sz, t, h, o, v) \ 270 (*(t)->__bs_opname_s(w,sz))((t)->bs_cookie, h, o, v) 271 #define __bs_nonsingle_s(type, sz, t, h, o, a, c) \ 272 (*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c) 273 274 275 /* 276 * Mapping and unmapping operations. 277 */ 278 #define bus_space_map(t, a, s, c, hp) \ 279 (*(t)->bs_map)((t)->bs_cookie, (a), (s), (c), (hp)) 280 #define bus_space_unmap(t, h, s) \ 281 (*(t)->bs_unmap)((t)->bs_cookie, (h), (s)) 282 #define bus_space_subregion(t, h, o, s, hp) \ 283 (*(t)->bs_subregion)((t)->bs_cookie, (h), (o), (s), (hp)) 284 285 286 /* 287 * Allocation and deallocation operations. 288 */ 289 #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \ 290 (*(t)->bs_alloc)((t)->bs_cookie, (rs), (re), (s), (a), (b), \ 291 (c), (ap), (hp)) 292 #define bus_space_free(t, h, s) \ 293 (*(t)->bs_free)((t)->bs_cookie, (h), (s)) 294 295 /* 296 * Bus barrier operations. 297 */ 298 #define bus_space_barrier(t, h, o, l, f) \ 299 (*(t)->bs_barrier)((t)->bs_cookie, (h), (o), (l), (f)) 300 301 #define BUS_SPACE_BARRIER_READ 0x01 302 #define BUS_SPACE_BARRIER_WRITE 0x02 303 304 /* 305 * Bus read (single) operations. 306 */ 307 #define bus_space_read_1(t, h, o) __bs_rs(1,(t),(h),(o)) 308 #define bus_space_read_2(t, h, o) __bs_rs(2,(t),(h),(o)) 309 #define bus_space_read_4(t, h, o) __bs_rs(4,(t),(h),(o)) 310 #define bus_space_read_8(t, h, o) __bs_rs(8,(t),(h),(o)) 311 312 #define bus_space_read_stream_1(t, h, o) __bs_rs_s(1,(t), (h), (o)) 313 #define bus_space_read_stream_2(t, h, o) __bs_rs_s(2,(t), (h), (o)) 314 #define bus_space_read_stream_4(t, h, o) __bs_rs_s(4,(t), (h), (o)) 315 #define bus_space_read_stream_8(t, h, o) __bs_rs_s(8,8,(t),(h),(o)) 316 317 /* 318 * Bus read multiple operations. 319 */ 320 #define bus_space_read_multi_1(t, h, o, a, c) \ 321 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c)) 322 #define bus_space_read_multi_2(t, h, o, a, c) \ 323 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c)) 324 #define bus_space_read_multi_4(t, h, o, a, c) \ 325 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c)) 326 #define bus_space_read_multi_8(t, h, o, a, c) \ 327 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c)) 328 329 #define bus_space_read_multi_stream_1(t, h, o, a, c) \ 330 __bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c)) 331 #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 332 __bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c)) 333 #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 334 __bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c)) 335 #define bus_space_read_multi_stream_8(t, h, o, a, c) \ 336 __bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c)) 337 338 339 /* 340 * Bus read region operations. 341 */ 342 #define bus_space_read_region_1(t, h, o, a, c) \ 343 __bs_nonsingle(rr,1,(t),(h),(o),(a),(c)) 344 #define bus_space_read_region_2(t, h, o, a, c) \ 345 __bs_nonsingle(rr,2,(t),(h),(o),(a),(c)) 346 #define bus_space_read_region_4(t, h, o, a, c) \ 347 __bs_nonsingle(rr,4,(t),(h),(o),(a),(c)) 348 #define bus_space_read_region_8(t, h, o, a, c) \ 349 __bs_nonsingle(rr,8,(t),(h),(o),(a),(c)) 350 351 #define bus_space_read_region_stream_1(t, h, o, a, c) \ 352 __bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c)) 353 #define bus_space_read_region_stream_2(t, h, o, a, c) \ 354 __bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c)) 355 #define bus_space_read_region_stream_4(t, h, o, a, c) \ 356 __bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c)) 357 #define bus_space_read_region_stream_8(t, h, o, a, c) \ 358 __bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c)) 359 360 361 /* 362 * Bus write (single) operations. 363 */ 364 #define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v)) 365 #define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v)) 366 #define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v)) 367 #define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v)) 368 369 #define bus_space_write_stream_1(t, h, o, v) __bs_ws_s(1,(t),(h),(o),(v)) 370 #define bus_space_write_stream_2(t, h, o, v) __bs_ws_s(2,(t),(h),(o),(v)) 371 #define bus_space_write_stream_4(t, h, o, v) __bs_ws_s(4,(t),(h),(o),(v)) 372 #define bus_space_write_stream_8(t, h, o, v) __bs_ws_s(8,(t),(h),(o),(v)) 373 374 375 /* 376 * Bus write multiple operations. 377 */ 378 #define bus_space_write_multi_1(t, h, o, a, c) \ 379 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c)) 380 #define bus_space_write_multi_2(t, h, o, a, c) \ 381 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c)) 382 #define bus_space_write_multi_4(t, h, o, a, c) \ 383 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c)) 384 #define bus_space_write_multi_8(t, h, o, a, c) \ 385 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c)) 386 387 #define bus_space_write_multi_stream_1(t, h, o, a, c) \ 388 __bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c)) 389 #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 390 __bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c)) 391 #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 392 __bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c)) 393 #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 394 __bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c)) 395 396 397 /* 398 * Bus write region operations. 399 */ 400 #define bus_space_write_region_1(t, h, o, a, c) \ 401 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c)) 402 #define bus_space_write_region_2(t, h, o, a, c) \ 403 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c)) 404 #define bus_space_write_region_4(t, h, o, a, c) \ 405 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c)) 406 #define bus_space_write_region_8(t, h, o, a, c) \ 407 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c)) 408 409 #define bus_space_write_region_stream_1(t, h, o, a, c) \ 410 __bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c)) 411 #define bus_space_write_region_stream_2(t, h, o, a, c) \ 412 __bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c)) 413 #define bus_space_write_region_stream_4(t, h, o, a, c) \ 414 __bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c)) 415 #define bus_space_write_region_stream_8(t, h, o, a, c) \ 416 __bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c)) 417 418 419 /* 420 * Set multiple operations. 421 */ 422 #define bus_space_set_multi_1(t, h, o, v, c) \ 423 __bs_set(sm,1,(t),(h),(o),(v),(c)) 424 #define bus_space_set_multi_2(t, h, o, v, c) \ 425 __bs_set(sm,2,(t),(h),(o),(v),(c)) 426 #define bus_space_set_multi_4(t, h, o, v, c) \ 427 __bs_set(sm,4,(t),(h),(o),(v),(c)) 428 #define bus_space_set_multi_8(t, h, o, v, c) \ 429 __bs_set(sm,8,(t),(h),(o),(v),(c)) 430 431 432 /* 433 * Set region operations. 434 */ 435 #define bus_space_set_region_1(t, h, o, v, c) \ 436 __bs_set(sr,1,(t),(h),(o),(v),(c)) 437 #define bus_space_set_region_2(t, h, o, v, c) \ 438 __bs_set(sr,2,(t),(h),(o),(v),(c)) 439 #define bus_space_set_region_4(t, h, o, v, c) \ 440 __bs_set(sr,4,(t),(h),(o),(v),(c)) 441 #define bus_space_set_region_8(t, h, o, v, c) \ 442 __bs_set(sr,8,(t),(h),(o),(v),(c)) 443 444 445 /* 446 * Copy operations. 447 */ 448 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ 449 __bs_copy(1, t, h1, o1, h2, o2, c) 450 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ 451 __bs_copy(2, t, h1, o1, h2, o2, c) 452 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ 453 __bs_copy(4, t, h1, o1, h2, o2, c) 454 #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ 455 __bs_copy(8, t, h1, o1, h2, o2, c) 456 457 /* 458 * Macros to provide prototypes for all the functions used in the 459 * bus_space structure 460 */ 461 462 #define bs_map_proto(f) \ 463 int __bs_c(f,_bs_map) (void *t, bus_addr_t addr, \ 464 bus_size_t size, int cacheable, bus_space_handle_t *bshp); 465 466 #define bs_unmap_proto(f) \ 467 void __bs_c(f,_bs_unmap) (void *t, bus_space_handle_t bsh, \ 468 bus_size_t size); 469 470 #define bs_subregion_proto(f) \ 471 int __bs_c(f,_bs_subregion) (void *t, bus_space_handle_t bsh, \ 472 bus_size_t offset, bus_size_t size, \ 473 bus_space_handle_t *nbshp); 474 475 #define bs_alloc_proto(f) \ 476 int __bs_c(f,_bs_alloc) (void *t, bus_addr_t rstart, \ 477 bus_addr_t rend, bus_size_t size, bus_size_t align, \ 478 bus_size_t boundary, int cacheable, bus_addr_t *addrp, \ 479 bus_space_handle_t *bshp); 480 481 #define bs_free_proto(f) \ 482 void __bs_c(f,_bs_free) (void *t, bus_space_handle_t bsh, \ 483 bus_size_t size); 484 485 #define bs_mmap_proto(f) \ 486 int __bs_c(f,_bs_mmap) (struct cdev *, vm_offset_t, vm_paddr_t *, int); 487 488 #define bs_barrier_proto(f) \ 489 void __bs_c(f,_bs_barrier) (void *t, bus_space_handle_t bsh, \ 490 bus_size_t offset, bus_size_t len, int flags); 491 492 #define bs_r_1_proto(f) \ 493 u_int8_t __bs_c(f,_bs_r_1) (void *t, bus_space_handle_t bsh, \ 494 bus_size_t offset); 495 496 #define bs_r_2_proto(f) \ 497 u_int16_t __bs_c(f,_bs_r_2) (void *t, bus_space_handle_t bsh, \ 498 bus_size_t offset); 499 500 #define bs_r_4_proto(f) \ 501 u_int32_t __bs_c(f,_bs_r_4) (void *t, bus_space_handle_t bsh, \ 502 bus_size_t offset); 503 504 #define bs_r_8_proto(f) \ 505 u_int64_t __bs_c(f,_bs_r_8) (void *t, bus_space_handle_t bsh, \ 506 bus_size_t offset); 507 508 #define bs_r_1_s_proto(f) \ 509 u_int8_t __bs_c(f,_bs_r_1_s) (void *t, bus_space_handle_t bsh, \ 510 bus_size_t offset); 511 512 #define bs_r_2_s_proto(f) \ 513 u_int16_t __bs_c(f,_bs_r_2_s) (void *t, bus_space_handle_t bsh, \ 514 bus_size_t offset); 515 516 #define bs_r_4_s_proto(f) \ 517 u_int32_t __bs_c(f,_bs_r_4_s) (void *t, bus_space_handle_t bsh, \ 518 bus_size_t offset); 519 520 #define bs_w_1_proto(f) \ 521 void __bs_c(f,_bs_w_1) (void *t, bus_space_handle_t bsh, \ 522 bus_size_t offset, u_int8_t value); 523 524 #define bs_w_2_proto(f) \ 525 void __bs_c(f,_bs_w_2) (void *t, bus_space_handle_t bsh, \ 526 bus_size_t offset, u_int16_t value); 527 528 #define bs_w_4_proto(f) \ 529 void __bs_c(f,_bs_w_4) (void *t, bus_space_handle_t bsh, \ 530 bus_size_t offset, u_int32_t value); 531 532 #define bs_w_8_proto(f) \ 533 void __bs_c(f,_bs_w_8) (void *t, bus_space_handle_t bsh, \ 534 bus_size_t offset, u_int64_t value); 535 536 #define bs_w_1_s_proto(f) \ 537 void __bs_c(f,_bs_w_1_s) (void *t, bus_space_handle_t bsh, \ 538 bus_size_t offset, u_int8_t value); 539 540 #define bs_w_2_s_proto(f) \ 541 void __bs_c(f,_bs_w_2_s) (void *t, bus_space_handle_t bsh, \ 542 bus_size_t offset, u_int16_t value); 543 544 #define bs_w_4_s_proto(f) \ 545 void __bs_c(f,_bs_w_4_s) (void *t, bus_space_handle_t bsh, \ 546 bus_size_t offset, u_int32_t value); 547 548 #define bs_rm_1_proto(f) \ 549 void __bs_c(f,_bs_rm_1) (void *t, bus_space_handle_t bsh, \ 550 bus_size_t offset, u_int8_t *addr, bus_size_t count); 551 552 #define bs_rm_2_proto(f) \ 553 void __bs_c(f,_bs_rm_2) (void *t, bus_space_handle_t bsh, \ 554 bus_size_t offset, u_int16_t *addr, bus_size_t count); 555 556 #define bs_rm_4_proto(f) \ 557 void __bs_c(f,_bs_rm_4) (void *t, bus_space_handle_t bsh, \ 558 bus_size_t offset, u_int32_t *addr, bus_size_t count); 559 560 #define bs_rm_8_proto(f) \ 561 void __bs_c(f,_bs_rm_8) (void *t, bus_space_handle_t bsh, \ 562 bus_size_t offset, u_int64_t *addr, bus_size_t count); 563 564 #define bs_wm_1_proto(f) \ 565 void __bs_c(f,_bs_wm_1) (void *t, bus_space_handle_t bsh, \ 566 bus_size_t offset, const u_int8_t *addr, bus_size_t count); 567 568 #define bs_wm_2_proto(f) \ 569 void __bs_c(f,_bs_wm_2) (void *t, bus_space_handle_t bsh, \ 570 bus_size_t offset, const u_int16_t *addr, bus_size_t count); 571 572 #define bs_wm_4_proto(f) \ 573 void __bs_c(f,_bs_wm_4) (void *t, bus_space_handle_t bsh, \ 574 bus_size_t offset, const u_int32_t *addr, bus_size_t count); 575 576 #define bs_wm_8_proto(f) \ 577 void __bs_c(f,_bs_wm_8) (void *t, bus_space_handle_t bsh, \ 578 bus_size_t offset, const u_int64_t *addr, bus_size_t count); 579 580 #define bs_rr_1_proto(f) \ 581 void __bs_c(f, _bs_rr_1) (void *t, bus_space_handle_t bsh, \ 582 bus_size_t offset, u_int8_t *addr, bus_size_t count); 583 584 #define bs_rr_2_proto(f) \ 585 void __bs_c(f, _bs_rr_2) (void *t, bus_space_handle_t bsh, \ 586 bus_size_t offset, u_int16_t *addr, bus_size_t count); 587 588 #define bs_rr_4_proto(f) \ 589 void __bs_c(f, _bs_rr_4) (void *t, bus_space_handle_t bsh, \ 590 bus_size_t offset, u_int32_t *addr, bus_size_t count); 591 592 #define bs_rr_8_proto(f) \ 593 void __bs_c(f, _bs_rr_8) (void *t, bus_space_handle_t bsh, \ 594 bus_size_t offset, u_int64_t *addr, bus_size_t count); 595 596 #define bs_wr_1_proto(f) \ 597 void __bs_c(f, _bs_wr_1) (void *t, bus_space_handle_t bsh, \ 598 bus_size_t offset, const u_int8_t *addr, bus_size_t count); 599 600 #define bs_wr_2_proto(f) \ 601 void __bs_c(f, _bs_wr_2) (void *t, bus_space_handle_t bsh, \ 602 bus_size_t offset, const u_int16_t *addr, bus_size_t count); 603 604 #define bs_wr_4_proto(f) \ 605 void __bs_c(f, _bs_wr_4) (void *t, bus_space_handle_t bsh, \ 606 bus_size_t offset, const u_int32_t *addr, bus_size_t count); 607 608 #define bs_wr_8_proto(f) \ 609 void __bs_c(f, _bs_wr_8) (void *t, bus_space_handle_t bsh, \ 610 bus_size_t offset, const u_int64_t *addr, bus_size_t count); 611 612 #define bs_sm_1_proto(f) \ 613 void __bs_c(f,_bs_sm_1) (void *t, bus_space_handle_t bsh, \ 614 bus_size_t offset, u_int8_t value, bus_size_t count); 615 616 #define bs_sm_2_proto(f) \ 617 void __bs_c(f,_bs_sm_2) (void *t, bus_space_handle_t bsh, \ 618 bus_size_t offset, u_int16_t value, bus_size_t count); 619 620 #define bs_sm_4_proto(f) \ 621 void __bs_c(f,_bs_sm_4) (void *t, bus_space_handle_t bsh, \ 622 bus_size_t offset, u_int32_t value, bus_size_t count); 623 624 #define bs_sm_8_proto(f) \ 625 void __bs_c(f,_bs_sm_8) (void *t, bus_space_handle_t bsh, \ 626 bus_size_t offset, u_int64_t value, bus_size_t count); 627 628 #define bs_sr_1_proto(f) \ 629 void __bs_c(f,_bs_sr_1) (void *t, bus_space_handle_t bsh, \ 630 bus_size_t offset, u_int8_t value, bus_size_t count); 631 632 #define bs_sr_2_proto(f) \ 633 void __bs_c(f,_bs_sr_2) (void *t, bus_space_handle_t bsh, \ 634 bus_size_t offset, u_int16_t value, bus_size_t count); 635 636 #define bs_sr_4_proto(f) \ 637 void __bs_c(f,_bs_sr_4) (void *t, bus_space_handle_t bsh, \ 638 bus_size_t offset, u_int32_t value, bus_size_t count); 639 640 #define bs_sr_8_proto(f) \ 641 void __bs_c(f,_bs_sr_8) (void *t, bus_space_handle_t bsh, \ 642 bus_size_t offset, u_int64_t value, bus_size_t count); 643 644 #define bs_c_1_proto(f) \ 645 void __bs_c(f,_bs_c_1) (void *t, bus_space_handle_t bsh1, \ 646 bus_size_t offset1, bus_space_handle_t bsh2, \ 647 bus_size_t offset2, bus_size_t count); 648 649 #define bs_c_2_proto(f) \ 650 void __bs_c(f,_bs_c_2) (void *t, bus_space_handle_t bsh1, \ 651 bus_size_t offset1, bus_space_handle_t bsh2, \ 652 bus_size_t offset2, bus_size_t count); 653 654 #define bs_c_4_proto(f) \ 655 void __bs_c(f,_bs_c_4) (void *t, bus_space_handle_t bsh1, \ 656 bus_size_t offset1, bus_space_handle_t bsh2, \ 657 bus_size_t offset2, bus_size_t count); 658 659 #define bs_c_8_proto(f) \ 660 void __bs_c(f,_bs_c_8) (void *t, bus_space_handle_t bsh1, \ 661 bus_size_t offset1, bus_space_handle_t bsh2, \ 662 bus_size_t offset2, bus_size_t count); 663 664 #define bs_protos(f) \ 665 bs_map_proto(f); \ 666 bs_unmap_proto(f); \ 667 bs_subregion_proto(f); \ 668 bs_alloc_proto(f); \ 669 bs_free_proto(f); \ 670 bs_mmap_proto(f); \ 671 bs_barrier_proto(f); \ 672 bs_r_1_proto(f); \ 673 bs_r_2_proto(f); \ 674 bs_r_4_proto(f); \ 675 bs_r_8_proto(f); \ 676 bs_r_1_s_proto(f); \ 677 bs_r_2_s_proto(f); \ 678 bs_r_4_s_proto(f); \ 679 bs_w_1_proto(f); \ 680 bs_w_2_proto(f); \ 681 bs_w_4_proto(f); \ 682 bs_w_8_proto(f); \ 683 bs_w_1_s_proto(f); \ 684 bs_w_2_s_proto(f); \ 685 bs_w_4_s_proto(f); \ 686 bs_rm_1_proto(f); \ 687 bs_rm_2_proto(f); \ 688 bs_rm_4_proto(f); \ 689 bs_rm_8_proto(f); \ 690 bs_wm_1_proto(f); \ 691 bs_wm_2_proto(f); \ 692 bs_wm_4_proto(f); \ 693 bs_wm_8_proto(f); \ 694 bs_rr_1_proto(f); \ 695 bs_rr_2_proto(f); \ 696 bs_rr_4_proto(f); \ 697 bs_rr_8_proto(f); \ 698 bs_wr_1_proto(f); \ 699 bs_wr_2_proto(f); \ 700 bs_wr_4_proto(f); \ 701 bs_wr_8_proto(f); \ 702 bs_sm_1_proto(f); \ 703 bs_sm_2_proto(f); \ 704 bs_sm_4_proto(f); \ 705 bs_sm_8_proto(f); \ 706 bs_sr_1_proto(f); \ 707 bs_sr_2_proto(f); \ 708 bs_sr_4_proto(f); \ 709 bs_sr_8_proto(f); \ 710 bs_c_1_proto(f); \ 711 bs_c_2_proto(f); \ 712 bs_c_4_proto(f); \ 713 bs_c_8_proto(f); 714 715 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 716 717 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF 718 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF 719 #define BUS_SPACE_MAXADDR 0xFFFFFFFF 720 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF 721 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF 722 #define BUS_SPACE_MAXSIZE 0xFFFFFFFF 723 724 #define BUS_SPACE_UNRESTRICTED (~0) 725 726 #include <machine/bus_dma.h> 727 728 /* 729 * Get the physical address of a bus space memory-mapped resource. 730 * Doing this as a macro is a temporary solution until a more robust fix is 731 * designed. It also serves to mark the locations needing that fix. 732 */ 733 #define BUS_SPACE_PHYSADDR(res, offs) \ 734 ((u_int)(rman_get_start(res)+(offs))) 735 736 #endif /* _MACHINE_BUS_H_ */ 737