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