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