Annotation of sys/arch/arm/include/bus.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: bus.h,v 1.8 2007/04/10 18:22:08 miod Exp $ */
! 2: /* $NetBSD: bus.h,v 1.12 2003/10/23 15:03:24 scw Exp $ */
! 3:
! 4: /*-
! 5: * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
! 6: * All rights reserved.
! 7: *
! 8: * This code is derived from software contributed to The NetBSD Foundation
! 9: * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
! 10: * NASA Ames Research Center.
! 11: *
! 12: * Redistribution and use in source and binary forms, with or without
! 13: * modification, are permitted provided that the following conditions
! 14: * are met:
! 15: * 1. Redistributions of source code must retain the above copyright
! 16: * notice, this list of conditions and the following disclaimer.
! 17: * 2. Redistributions in binary form must reproduce the above copyright
! 18: * notice, this list of conditions and the following disclaimer in the
! 19: * documentation and/or other materials provided with the distribution.
! 20: * 3. All advertising materials mentioning features or use of this software
! 21: * must display the following acknowledgement:
! 22: * This product includes software developed by the NetBSD
! 23: * Foundation, Inc. and its contributors.
! 24: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 25: * contributors may be used to endorse or promote products derived
! 26: * from this software without specific prior written permission.
! 27: *
! 28: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 29: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 30: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 31: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 32: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 33: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 34: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 35: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 36: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 37: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 38: * POSSIBILITY OF SUCH DAMAGE.
! 39: */
! 40:
! 41: /*
! 42: * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
! 43: * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
! 44: *
! 45: * Redistribution and use in source and binary forms, with or without
! 46: * modification, are permitted provided that the following conditions
! 47: * are met:
! 48: * 1. Redistributions of source code must retain the above copyright
! 49: * notice, this list of conditions and the following disclaimer.
! 50: * 2. Redistributions in binary form must reproduce the above copyright
! 51: * notice, this list of conditions and the following disclaimer in the
! 52: * documentation and/or other materials provided with the distribution.
! 53: * 3. All advertising materials mentioning features or use of this software
! 54: * must display the following acknowledgement:
! 55: * This product includes software developed by Christopher G. Demetriou
! 56: * for the NetBSD Project.
! 57: * 4. The name of the author may not be used to endorse or promote products
! 58: * derived from this software without specific prior written permission
! 59: *
! 60: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 61: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 62: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 63: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 64: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 65: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 66: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 67: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 68: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 69: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 70: */
! 71:
! 72: #ifndef _ARM32_BUS_H_
! 73: #define _ARM32_BUS_H_
! 74:
! 75: /*
! 76: * Addresses (in bus space).
! 77: */
! 78: typedef u_long bus_addr_t;
! 79: typedef u_long bus_size_t;
! 80:
! 81: /*
! 82: * Access methods for bus space.
! 83: */
! 84: typedef struct bus_space *bus_space_tag_t;
! 85: typedef u_long bus_space_handle_t;
! 86:
! 87: /*
! 88: * int bus_space_map (bus_space_tag_t t, bus_addr_t addr,
! 89: * bus_size_t size, int flags, bus_space_handle_t *bshp);
! 90: *
! 91: * Map a region of bus space.
! 92: */
! 93:
! 94: #define BUS_SPACE_MAP_CACHEABLE 0x01
! 95: #define BUS_SPACE_MAP_LINEAR 0x02
! 96: #define BUS_SPACE_MAP_PREFETCHABLE 0x04
! 97:
! 98: struct bus_space {
! 99: /* cookie */
! 100: void *bs_cookie;
! 101:
! 102: /* mapping/unmapping */
! 103: int (*bs_map) (void *, bus_addr_t, bus_size_t,
! 104: int, bus_space_handle_t *);
! 105: void (*bs_unmap) (void *, bus_space_handle_t,
! 106: bus_size_t);
! 107: int (*bs_subregion) (void *, bus_space_handle_t,
! 108: bus_size_t, bus_size_t, bus_space_handle_t *);
! 109:
! 110: /* allocation/deallocation */
! 111: int (*bs_alloc) (void *, bus_addr_t, bus_addr_t,
! 112: bus_size_t, bus_size_t, bus_size_t, int,
! 113: bus_addr_t *, bus_space_handle_t *);
! 114: void (*bs_free) (void *, bus_space_handle_t,
! 115: bus_size_t);
! 116:
! 117: /* get kernel virtual address */
! 118: void * (*bs_vaddr) (void *, bus_space_handle_t);
! 119:
! 120: /* mmap bus space for user */
! 121: paddr_t (*bs_mmap) (void *, bus_addr_t, off_t, int, int);
! 122:
! 123: /* barrier */
! 124: void (*bs_barrier) (void *, bus_space_handle_t,
! 125: bus_size_t, bus_size_t, int);
! 126:
! 127: /* read (single) */
! 128: u_int8_t (*bs_r_1) (void *, bus_space_handle_t,
! 129: bus_size_t);
! 130: u_int16_t (*bs_r_2) (void *, bus_space_handle_t,
! 131: bus_size_t);
! 132: u_int32_t (*bs_r_4) (void *, bus_space_handle_t,
! 133: bus_size_t);
! 134: u_int64_t (*bs_r_8) (void *, bus_space_handle_t,
! 135: bus_size_t);
! 136:
! 137: /* read multiple */
! 138: void (*bs_rm_1) (void *, bus_space_handle_t,
! 139: bus_size_t, u_int8_t *, bus_size_t);
! 140: void (*bs_rm_2) (void *, bus_space_handle_t,
! 141: bus_size_t, u_int16_t *, bus_size_t);
! 142: void (*bs_rm_4) (void *, bus_space_handle_t,
! 143: bus_size_t, u_int32_t *, bus_size_t);
! 144: void (*bs_rm_8) (void *, bus_space_handle_t,
! 145: bus_size_t, u_int64_t *, bus_size_t);
! 146:
! 147: /* read region */
! 148: void (*bs_rr_1) (void *, bus_space_handle_t,
! 149: bus_size_t, u_int8_t *, bus_size_t);
! 150: void (*bs_rr_2) (void *, bus_space_handle_t,
! 151: bus_size_t, u_int16_t *, bus_size_t);
! 152: void (*bs_rr_4) (void *, bus_space_handle_t,
! 153: bus_size_t, u_int32_t *, bus_size_t);
! 154: void (*bs_rr_8) (void *, bus_space_handle_t,
! 155: bus_size_t, u_int64_t *, bus_size_t);
! 156:
! 157: /* write (single) */
! 158: void (*bs_w_1) (void *, bus_space_handle_t,
! 159: bus_size_t, u_int8_t);
! 160: void (*bs_w_2) (void *, bus_space_handle_t,
! 161: bus_size_t, u_int16_t);
! 162: void (*bs_w_4) (void *, bus_space_handle_t,
! 163: bus_size_t, u_int32_t);
! 164: void (*bs_w_8) (void *, bus_space_handle_t,
! 165: bus_size_t, u_int64_t);
! 166:
! 167: /* write multiple */
! 168: void (*bs_wm_1) (void *, bus_space_handle_t,
! 169: bus_size_t, const u_int8_t *, bus_size_t);
! 170: void (*bs_wm_2) (void *, bus_space_handle_t,
! 171: bus_size_t, const u_int16_t *, bus_size_t);
! 172: void (*bs_wm_4) (void *, bus_space_handle_t,
! 173: bus_size_t, const u_int32_t *, bus_size_t);
! 174: void (*bs_wm_8) (void *, bus_space_handle_t,
! 175: bus_size_t, const u_int64_t *, bus_size_t);
! 176:
! 177: /* write region */
! 178: void (*bs_wr_1) (void *, bus_space_handle_t,
! 179: bus_size_t, const u_int8_t *, bus_size_t);
! 180: void (*bs_wr_2) (void *, bus_space_handle_t,
! 181: bus_size_t, const u_int16_t *, bus_size_t);
! 182: void (*bs_wr_4) (void *, bus_space_handle_t,
! 183: bus_size_t, const u_int32_t *, bus_size_t);
! 184: void (*bs_wr_8) (void *, bus_space_handle_t,
! 185: bus_size_t, const u_int64_t *, bus_size_t);
! 186:
! 187: /* set multiple */
! 188: void (*bs_sm_1) (void *, bus_space_handle_t,
! 189: bus_size_t, u_int8_t, bus_size_t);
! 190: void (*bs_sm_2) (void *, bus_space_handle_t,
! 191: bus_size_t, u_int16_t, bus_size_t);
! 192: void (*bs_sm_4) (void *, bus_space_handle_t,
! 193: bus_size_t, u_int32_t, bus_size_t);
! 194: void (*bs_sm_8) (void *, bus_space_handle_t,
! 195: bus_size_t, u_int64_t, bus_size_t);
! 196:
! 197: /* set region */
! 198: void (*bs_sr_1) (void *, bus_space_handle_t,
! 199: bus_size_t, u_int8_t, bus_size_t);
! 200: void (*bs_sr_2) (void *, bus_space_handle_t,
! 201: bus_size_t, u_int16_t, bus_size_t);
! 202: void (*bs_sr_4) (void *, bus_space_handle_t,
! 203: bus_size_t, u_int32_t, bus_size_t);
! 204: void (*bs_sr_8) (void *, bus_space_handle_t,
! 205: bus_size_t, u_int64_t, bus_size_t);
! 206:
! 207: /* copy */
! 208: void (*bs_c_1) (void *, bus_space_handle_t, bus_size_t,
! 209: bus_space_handle_t, bus_size_t, bus_size_t);
! 210: void (*bs_c_2) (void *, bus_space_handle_t, bus_size_t,
! 211: bus_space_handle_t, bus_size_t, bus_size_t);
! 212: void (*bs_c_4) (void *, bus_space_handle_t, bus_size_t,
! 213: bus_space_handle_t, bus_size_t, bus_size_t);
! 214: void (*bs_c_8) (void *, bus_space_handle_t, bus_size_t,
! 215: bus_space_handle_t, bus_size_t, bus_size_t);
! 216:
! 217: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 218: /* read stream (single) */
! 219: u_int8_t (*bs_r_1_s) (void *, bus_space_handle_t,
! 220: bus_size_t);
! 221: u_int16_t (*bs_r_2_s) (void *, bus_space_handle_t,
! 222: bus_size_t);
! 223: u_int32_t (*bs_r_4_s) (void *, bus_space_handle_t,
! 224: bus_size_t);
! 225: u_int64_t (*bs_r_8_s) (void *, bus_space_handle_t,
! 226: bus_size_t);
! 227:
! 228: /* read multiple stream */
! 229: void (*bs_rm_1_s) (void *, bus_space_handle_t,
! 230: bus_size_t, u_int8_t *, bus_size_t);
! 231: void (*bs_rm_2_s) (void *, bus_space_handle_t,
! 232: bus_size_t, u_int16_t *, bus_size_t);
! 233: void (*bs_rm_4_s) (void *, bus_space_handle_t,
! 234: bus_size_t, u_int32_t *, bus_size_t);
! 235: void (*bs_rm_8_s) (void *, bus_space_handle_t,
! 236: bus_size_t, u_int64_t *, bus_size_t);
! 237:
! 238: /* read region stream */
! 239: void (*bs_rr_1_s) (void *, bus_space_handle_t,
! 240: bus_size_t, u_int8_t *, bus_size_t);
! 241: void (*bs_rr_2_s) (void *, bus_space_handle_t,
! 242: bus_size_t, u_int16_t *, bus_size_t);
! 243: void (*bs_rr_4_s) (void *, bus_space_handle_t,
! 244: bus_size_t, u_int32_t *, bus_size_t);
! 245: void (*bs_rr_8_s) (void *, bus_space_handle_t,
! 246: bus_size_t, u_int64_t *, bus_size_t);
! 247:
! 248: /* write stream (single) */
! 249: void (*bs_w_1_s) (void *, bus_space_handle_t,
! 250: bus_size_t, u_int8_t);
! 251: void (*bs_w_2_s) (void *, bus_space_handle_t,
! 252: bus_size_t, u_int16_t);
! 253: void (*bs_w_4_s) (void *, bus_space_handle_t,
! 254: bus_size_t, u_int32_t);
! 255: void (*bs_w_8_s) (void *, bus_space_handle_t,
! 256: bus_size_t, u_int64_t);
! 257:
! 258: /* write multiple stream */
! 259: void (*bs_wm_1_s) (void *, bus_space_handle_t,
! 260: bus_size_t, const u_int8_t *, bus_size_t);
! 261: void (*bs_wm_2_s) (void *, bus_space_handle_t,
! 262: bus_size_t, const u_int16_t *, bus_size_t);
! 263: void (*bs_wm_4_s) (void *, bus_space_handle_t,
! 264: bus_size_t, const u_int32_t *, bus_size_t);
! 265: void (*bs_wm_8_s) (void *, bus_space_handle_t,
! 266: bus_size_t, const u_int64_t *, bus_size_t);
! 267:
! 268: /* write region stream */
! 269: void (*bs_wr_1_s) (void *, bus_space_handle_t,
! 270: bus_size_t, const u_int8_t *, bus_size_t);
! 271: void (*bs_wr_2_s) (void *, bus_space_handle_t,
! 272: bus_size_t, const u_int16_t *, bus_size_t);
! 273: void (*bs_wr_4_s) (void *, bus_space_handle_t,
! 274: bus_size_t, const u_int32_t *, bus_size_t);
! 275: void (*bs_wr_8_s) (void *, bus_space_handle_t,
! 276: bus_size_t, const u_int64_t *, bus_size_t);
! 277: #endif /* __BUS_SPACE_HAS_STREAM_METHODS */
! 278: };
! 279:
! 280:
! 281: /*
! 282: * Utility macros; INTERNAL USE ONLY.
! 283: */
! 284: #define __bs_c(a,b) __CONCAT(a,b)
! 285: #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size)
! 286:
! 287: #define __bs_rs(sz, t, h, o) \
! 288: (*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o)
! 289: #define __bs_ws(sz, t, h, o, v) \
! 290: (*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v)
! 291: #define __bs_nonsingle(type, sz, t, h, o, a, c) \
! 292: (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c)
! 293: #define __bs_set(type, sz, t, h, o, v, c) \
! 294: (*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, v, c)
! 295: #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \
! 296: (*(t)->__bs_opname(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt)
! 297:
! 298: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 299: #define __bs_opname_s(op,size) __bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s)
! 300: #define __bs_rs_s(sz, t, h, o) \
! 301: (*(t)->__bs_opname_s(r,sz))((t)->bs_cookie, h, o)
! 302: #define __bs_ws_s(sz, t, h, o, v) \
! 303: (*(t)->__bs_opname_s(w,sz))((t)->bs_cookie, h, o, v)
! 304: #define __bs_nonsingle_s(type, sz, t, h, o, a, c) \
! 305: (*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c)
! 306: #define __bs_set_s(type, sz, t, h, o, v, c) \
! 307: (*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, v, c)
! 308: #define __bs_copy_s(sz, t, h1, o1, h2, o2, cnt) \
! 309: (*(t)->__bs_opname_s(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt)
! 310: #endif
! 311:
! 312: /*
! 313: * Mapping and unmapping operations.
! 314: */
! 315: #define bus_space_map(t, a, s, c, hp) \
! 316: (*(t)->bs_map)((t)->bs_cookie, (a), (s), (c), (hp))
! 317: #define bus_space_unmap(t, h, s) \
! 318: (*(t)->bs_unmap)((t)->bs_cookie, (h), (s))
! 319: #define bus_space_subregion(t, h, o, s, hp) \
! 320: (*(t)->bs_subregion)((t)->bs_cookie, (h), (o), (s), (hp))
! 321:
! 322:
! 323: /*
! 324: * Allocation and deallocation operations.
! 325: */
! 326: #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \
! 327: (*(t)->bs_alloc)((t)->bs_cookie, (rs), (re), (s), (a), (b), \
! 328: (c), (ap), (hp))
! 329: #define bus_space_free(t, h, s) \
! 330: (*(t)->bs_free)((t)->bs_cookie, (h), (s))
! 331:
! 332: /*
! 333: * Get kernel virtual address for ranges mapped BUS_SPACE_MAP_LINEAR.
! 334: */
! 335: #define bus_space_vaddr(t, h) \
! 336: (*(t)->bs_vaddr)((t)->bs_cookie, (h))
! 337:
! 338: /*
! 339: * MMap bus space for a user application.
! 340: */
! 341: #define bus_space_mmap(t, a, o, p, f) \
! 342: (*(t)->bs_mmap)((t)->bs_cookie, (a), (o), (p), (f))
! 343:
! 344: /*
! 345: * Bus barrier operations.
! 346: */
! 347: #define bus_space_barrier(t, h, o, l, f) \
! 348: (*(t)->bs_barrier)((t)->bs_cookie, (h), (o), (l), (f))
! 349:
! 350: #define BUS_SPACE_BARRIER_READ 0x01
! 351: #define BUS_SPACE_BARRIER_WRITE 0x02
! 352:
! 353: /*
! 354: * Bus read (single) operations.
! 355: */
! 356: #define bus_space_read_1(t, h, o) __bs_rs(1,(t),(h),(o))
! 357: #define bus_space_read_2(t, h, o) __bs_rs(2,(t),(h),(o))
! 358: #define bus_space_read_4(t, h, o) __bs_rs(4,(t),(h),(o))
! 359: #define bus_space_read_8(t, h, o) __bs_rs(8,(t),(h),(o))
! 360: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 361: #define bus_space_read_stream_1(t, h, o) __bs_rs_s(1,(t),(h),(o))
! 362: #define bus_space_read_stream_2(t, h, o) __bs_rs_s(2,(t),(h),(o))
! 363: #define bus_space_read_stream_4(t, h, o) __bs_rs_s(4,(t),(h),(o))
! 364: #define bus_space_read_stream_8(t, h, o) __bs_rs_s(8,(t),(h),(o))
! 365: #endif
! 366:
! 367:
! 368: /*
! 369: * Bus read multiple operations.
! 370: */
! 371: #define bus_space_read_multi_1(t, h, o, a, c) \
! 372: __bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
! 373: #define bus_space_read_multi_2(t, h, o, a, c) \
! 374: __bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
! 375: #define bus_space_read_multi_4(t, h, o, a, c) \
! 376: __bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
! 377: #define bus_space_read_multi_8(t, h, o, a, c) \
! 378: __bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
! 379: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 380: #define bus_space_read_multi_stream_1(t, h, o, a, c) \
! 381: __bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c))
! 382: #define bus_space_read_multi_stream_2(t, h, o, a, c) \
! 383: __bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c))
! 384: #define bus_space_read_multi_stream_4(t, h, o, a, c) \
! 385: __bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c))
! 386: #define bus_space_read_multi_stream_8(t, h, o, a, c) \
! 387: __bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c))
! 388: #endif
! 389:
! 390:
! 391: /*
! 392: * Bus read region operations.
! 393: */
! 394: #define bus_space_read_region_1(t, h, o, a, c) \
! 395: __bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
! 396: #define bus_space_read_region_2(t, h, o, a, c) \
! 397: __bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
! 398: #define bus_space_read_region_4(t, h, o, a, c) \
! 399: __bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
! 400: #define bus_space_read_region_8(t, h, o, a, c) \
! 401: __bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
! 402: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 403: #define bus_space_read_region_stream_1(t, h, o, a, c) \
! 404: __bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c))
! 405: #define bus_space_read_region_stream_2(t, h, o, a, c) \
! 406: __bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c))
! 407: #define bus_space_read_region_stream_4(t, h, o, a, c) \
! 408: __bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c))
! 409: #define bus_space_read_region_stream_8(t, h, o, a, c) \
! 410: __bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c))
! 411: #endif
! 412:
! 413:
! 414: /*
! 415: * Bus write (single) operations.
! 416: */
! 417: #define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v))
! 418: #define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v))
! 419: #define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v))
! 420: #define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v))
! 421: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 422: #define bus_space_write_stream_1(t, h, o, v) __bs_ws_s(1,(t),(h),(o),(v))
! 423: #define bus_space_write_stream_2(t, h, o, v) __bs_ws_s(2,(t),(h),(o),(v))
! 424: #define bus_space_write_stream_4(t, h, o, v) __bs_ws_s(4,(t),(h),(o),(v))
! 425: #define bus_space_write_stream_8(t, h, o, v) __bs_ws_s(8,(t),(h),(o),(v))
! 426: #endif
! 427:
! 428:
! 429: /*
! 430: * Bus write multiple operations.
! 431: */
! 432: #define bus_space_write_multi_1(t, h, o, a, c) \
! 433: __bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
! 434: #define bus_space_write_multi_2(t, h, o, a, c) \
! 435: __bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
! 436: #define bus_space_write_multi_4(t, h, o, a, c) \
! 437: __bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
! 438: #define bus_space_write_multi_8(t, h, o, a, c) \
! 439: __bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
! 440: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 441: #define bus_space_write_multi_stream_1(t, h, o, a, c) \
! 442: __bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c))
! 443: #define bus_space_write_multi_stream_2(t, h, o, a, c) \
! 444: __bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c))
! 445: #define bus_space_write_multi_stream_4(t, h, o, a, c) \
! 446: __bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c))
! 447: #define bus_space_write_multi_stream_8(t, h, o, a, c) \
! 448: __bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c))
! 449: #endif
! 450:
! 451:
! 452: /*
! 453: * Bus write region operations.
! 454: */
! 455: #define bus_space_write_region_1(t, h, o, a, c) \
! 456: __bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
! 457: #define bus_space_write_region_2(t, h, o, a, c) \
! 458: __bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
! 459: #define bus_space_write_region_4(t, h, o, a, c) \
! 460: __bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
! 461: #define bus_space_write_region_8(t, h, o, a, c) \
! 462: __bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
! 463: #ifdef __BUS_SPACE_HAS_STREAM_METHODS
! 464: #define bus_space_write_region_stream_1(t, h, o, a, c) \
! 465: __bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c))
! 466: #define bus_space_write_region_stream_2(t, h, o, a, c) \
! 467: __bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c))
! 468: #define bus_space_write_region_stream_4(t, h, o, a, c) \
! 469: __bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c))
! 470: #define bus_space_write_region_stream_8(t, h, o, a, c) \
! 471: __bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c))
! 472: #endif
! 473:
! 474:
! 475: /*
! 476: * Set multiple operations.
! 477: */
! 478: #define bus_space_set_multi_1(t, h, o, v, c) \
! 479: __bs_set(sm,1,(t),(h),(o),(v),(c))
! 480: #define bus_space_set_multi_2(t, h, o, v, c) \
! 481: __bs_set(sm,2,(t),(h),(o),(v),(c))
! 482: #define bus_space_set_multi_4(t, h, o, v, c) \
! 483: __bs_set(sm,4,(t),(h),(o),(v),(c))
! 484: #define bus_space_set_multi_8(t, h, o, v, c) \
! 485: __bs_set(sm,8,(t),(h),(o),(v),(c))
! 486:
! 487: /*
! 488: * Set region operations.
! 489: */
! 490: #define bus_space_set_region_1(t, h, o, v, c) \
! 491: __bs_set(sr,1,(t),(h),(o),(v),(c))
! 492: #define bus_space_set_region_2(t, h, o, v, c) \
! 493: __bs_set(sr,2,(t),(h),(o),(v),(c))
! 494: #define bus_space_set_region_4(t, h, o, v, c) \
! 495: __bs_set(sr,4,(t),(h),(o),(v),(c))
! 496: #define bus_space_set_region_8(t, h, o, v, c) \
! 497: __bs_set(sr,8,(t),(h),(o),(v),(c))
! 498:
! 499: /*
! 500: * Copy operations.
! 501: */
! 502: #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
! 503: __bs_copy(1, t, h1, o1, h2, o2, c)
! 504: #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
! 505: __bs_copy(2, t, h1, o1, h2, o2, c)
! 506: #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
! 507: __bs_copy(4, t, h1, o1, h2, o2, c)
! 508: #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
! 509: __bs_copy(8, t, h1, o1, h2, o2, c)
! 510:
! 511: void
! 512: bus_space_copy_1(bus_space_tag_t bst, bus_space_handle_t h1,
! 513: bus_space_handle_t h2, bus_size_t o1, bus_size_t o2, bus_size_t c);
! 514: void
! 515: bus_space_copy_2(bus_space_tag_t bst, bus_space_handle_t h1,
! 516: bus_space_handle_t h2, bus_size_t o1, bus_size_t o2, bus_size_t c);
! 517: void
! 518: bus_space_copy_4(bus_space_tag_t bst, bus_space_handle_t h1,
! 519: bus_space_handle_t h2, bus_size_t o1, bus_size_t o2, bus_size_t c);
! 520: #define bus_space_copy_8 \
! 521: !!! bus_space_write_raw_multi_8 not implemented !!!
! 522:
! 523: /*
! 524: * Macros to provide prototypes for all the functions used in the
! 525: * bus_space structure
! 526: */
! 527:
! 528: #define bs_map_proto(f) \
! 529: int __bs_c(f,_bs_map) (void *t, bus_addr_t addr, \
! 530: bus_size_t size, int cacheable, bus_space_handle_t *bshp);
! 531:
! 532: #define bs_unmap_proto(f) \
! 533: void __bs_c(f,_bs_unmap) (void *t, bus_space_handle_t bsh, \
! 534: bus_size_t size);
! 535:
! 536: #define bs_subregion_proto(f) \
! 537: int __bs_c(f,_bs_subregion) (void *t, bus_space_handle_t bsh, \
! 538: bus_size_t offset, bus_size_t size, \
! 539: bus_space_handle_t *nbshp);
! 540:
! 541: #define bs_alloc_proto(f) \
! 542: int __bs_c(f,_bs_alloc) (void *t, bus_addr_t rstart, \
! 543: bus_addr_t rend, bus_size_t size, bus_size_t align, \
! 544: bus_size_t boundary, int cacheable, bus_addr_t *addrp, \
! 545: bus_space_handle_t *bshp);
! 546:
! 547: #define bs_free_proto(f) \
! 548: void __bs_c(f,_bs_free) (void *t, bus_space_handle_t bsh, \
! 549: bus_size_t size);
! 550:
! 551: #define bs_vaddr_proto(f) \
! 552: void * __bs_c(f,_bs_vaddr) (void *t, bus_space_handle_t bsh);
! 553:
! 554: #define bs_mmap_proto(f) \
! 555: paddr_t __bs_c(f,_bs_mmap) (void *, bus_addr_t, off_t, int, int);
! 556:
! 557: #define bs_barrier_proto(f) \
! 558: void __bs_c(f,_bs_barrier) (void *t, bus_space_handle_t bsh, \
! 559: bus_size_t offset, bus_size_t len, int flags);
! 560:
! 561: #define bs_r_1_proto(f) \
! 562: u_int8_t __bs_c(f,_bs_r_1) (void *t, bus_space_handle_t bsh, \
! 563: bus_size_t offset);
! 564:
! 565: #define bs_r_2_proto(f) \
! 566: u_int16_t __bs_c(f,_bs_r_2) (void *t, bus_space_handle_t bsh, \
! 567: bus_size_t offset);
! 568:
! 569: #define bs_r_4_proto(f) \
! 570: u_int32_t __bs_c(f,_bs_r_4) (void *t, bus_space_handle_t bsh, \
! 571: bus_size_t offset);
! 572:
! 573: #define bs_r_8_proto(f) \
! 574: u_int64_t __bs_c(f,_bs_r_8) (void *t, bus_space_handle_t bsh, \
! 575: bus_size_t offset);
! 576:
! 577: #define bs_w_1_proto(f) \
! 578: void __bs_c(f,_bs_w_1) (void *t, bus_space_handle_t bsh, \
! 579: bus_size_t offset, u_int8_t value);
! 580:
! 581: #define bs_w_2_proto(f) \
! 582: void __bs_c(f,_bs_w_2) (void *t, bus_space_handle_t bsh, \
! 583: bus_size_t offset, u_int16_t value);
! 584:
! 585: #define bs_w_4_proto(f) \
! 586: void __bs_c(f,_bs_w_4) (void *t, bus_space_handle_t bsh, \
! 587: bus_size_t offset, u_int32_t value);
! 588:
! 589: #define bs_w_8_proto(f) \
! 590: void __bs_c(f,_bs_w_8) (void *t, bus_space_handle_t bsh, \
! 591: bus_size_t offset, u_int64_t value);
! 592:
! 593: #define bs_rm_1_proto(f) \
! 594: void __bs_c(f,_bs_rm_1) (void *t, bus_space_handle_t bsh, \
! 595: bus_size_t offset, u_int8_t *addr, bus_size_t count);
! 596:
! 597: #define bs_rm_2_proto(f) \
! 598: void __bs_c(f,_bs_rm_2) (void *t, bus_space_handle_t bsh, \
! 599: bus_size_t offset, u_int16_t *addr, bus_size_t count);
! 600:
! 601: #define bs_rm_4_proto(f) \
! 602: void __bs_c(f,_bs_rm_4) (void *t, bus_space_handle_t bsh, \
! 603: bus_size_t offset, u_int32_t *addr, bus_size_t count);
! 604:
! 605: #define bs_rm_8_proto(f) \
! 606: void __bs_c(f,_bs_rm_8) (void *t, bus_space_handle_t bsh, \
! 607: bus_size_t offset, u_int64_t *addr, bus_size_t count);
! 608:
! 609: #define bs_wm_1_proto(f) \
! 610: void __bs_c(f,_bs_wm_1) (void *t, bus_space_handle_t bsh, \
! 611: bus_size_t offset, const u_int8_t *addr, bus_size_t count);
! 612:
! 613: #define bs_wm_2_proto(f) \
! 614: void __bs_c(f,_bs_wm_2) (void *t, bus_space_handle_t bsh, \
! 615: bus_size_t offset, const u_int16_t *addr, bus_size_t count);
! 616:
! 617: #define bs_wm_4_proto(f) \
! 618: void __bs_c(f,_bs_wm_4) (void *t, bus_space_handle_t bsh, \
! 619: bus_size_t offset, const u_int32_t *addr, bus_size_t count);
! 620:
! 621: #define bs_wm_8_proto(f) \
! 622: void __bs_c(f,_bs_wm_8) (void *t, bus_space_handle_t bsh, \
! 623: bus_size_t offset, const u_int64_t *addr, bus_size_t count);
! 624:
! 625: #define bs_rr_1_proto(f) \
! 626: void __bs_c(f, _bs_rr_1) (void *t, bus_space_handle_t bsh, \
! 627: bus_size_t offset, u_int8_t *addr, bus_size_t count);
! 628:
! 629: #define bs_rr_2_proto(f) \
! 630: void __bs_c(f, _bs_rr_2) (void *t, bus_space_handle_t bsh, \
! 631: bus_size_t offset, u_int16_t *addr, bus_size_t count);
! 632:
! 633: #define bs_rr_4_proto(f) \
! 634: void __bs_c(f, _bs_rr_4) (void *t, bus_space_handle_t bsh, \
! 635: bus_size_t offset, u_int32_t *addr, bus_size_t count);
! 636:
! 637: #define bs_rr_8_proto(f) \
! 638: void __bs_c(f, _bs_rr_8) (void *t, bus_space_handle_t bsh, \
! 639: bus_size_t offset, u_int64_t *addr, bus_size_t count);
! 640:
! 641: #define bs_wr_1_proto(f) \
! 642: void __bs_c(f, _bs_wr_1) (void *t, bus_space_handle_t bsh, \
! 643: bus_size_t offset, const u_int8_t *addr, bus_size_t count);
! 644:
! 645: #define bs_wr_2_proto(f) \
! 646: void __bs_c(f, _bs_wr_2) (void *t, bus_space_handle_t bsh, \
! 647: bus_size_t offset, const u_int16_t *addr, bus_size_t count);
! 648:
! 649: #define bs_wr_4_proto(f) \
! 650: void __bs_c(f, _bs_wr_4) (void *t, bus_space_handle_t bsh, \
! 651: bus_size_t offset, const u_int32_t *addr, bus_size_t count);
! 652:
! 653: #define bs_wr_8_proto(f) \
! 654: void __bs_c(f, _bs_wr_8) (void *t, bus_space_handle_t bsh, \
! 655: bus_size_t offset, const u_int64_t *addr, bus_size_t count);
! 656:
! 657: #define bs_sm_1_proto(f) \
! 658: void __bs_c(f,_bs_sm_1) (void *t, bus_space_handle_t bsh, \
! 659: bus_size_t offset, u_int8_t value, bus_size_t count);
! 660:
! 661: #define bs_sm_2_proto(f) \
! 662: void __bs_c(f,_bs_sm_2) (void *t, bus_space_handle_t bsh, \
! 663: bus_size_t offset, u_int16_t value, bus_size_t count);
! 664:
! 665: #define bs_sm_4_proto(f) \
! 666: void __bs_c(f,_bs_sm_4) (void *t, bus_space_handle_t bsh, \
! 667: bus_size_t offset, u_int32_t value, bus_size_t count);
! 668:
! 669: #define bs_sm_8_proto(f) \
! 670: void __bs_c(f,_bs_sm_8) (void *t, bus_space_handle_t bsh, \
! 671: bus_size_t offset, u_int64_t value, bus_size_t count);
! 672:
! 673: #define bs_sr_1_proto(f) \
! 674: void __bs_c(f,_bs_sr_1) (void *t, bus_space_handle_t bsh, \
! 675: bus_size_t offset, u_int8_t value, bus_size_t count);
! 676:
! 677: #define bs_sr_2_proto(f) \
! 678: void __bs_c(f,_bs_sr_2) (void *t, bus_space_handle_t bsh, \
! 679: bus_size_t offset, u_int16_t value, bus_size_t count);
! 680:
! 681: #define bs_sr_4_proto(f) \
! 682: void __bs_c(f,_bs_sr_4) (void *t, bus_space_handle_t bsh, \
! 683: bus_size_t offset, u_int32_t value, bus_size_t count);
! 684:
! 685: #define bs_sr_8_proto(f) \
! 686: void __bs_c(f,_bs_sr_8) (void *t, bus_space_handle_t bsh, \
! 687: bus_size_t offset, u_int64_t value, bus_size_t count);
! 688:
! 689: #define bs_c_1_proto(f) \
! 690: void __bs_c(f,_bs_c_1) (void *t, bus_space_handle_t bsh1, \
! 691: bus_size_t offset1, bus_space_handle_t bsh2, \
! 692: bus_size_t offset2, bus_size_t count);
! 693:
! 694: #define bs_c_2_proto(f) \
! 695: void __bs_c(f,_bs_c_2) (void *t, bus_space_handle_t bsh1, \
! 696: bus_size_t offset1, bus_space_handle_t bsh2, \
! 697: bus_size_t offset2, bus_size_t count);
! 698:
! 699: #define bs_c_4_proto(f) \
! 700: void __bs_c(f,_bs_c_4) (void *t, bus_space_handle_t bsh1, \
! 701: bus_size_t offset1, bus_space_handle_t bsh2, \
! 702: bus_size_t offset2, bus_size_t count);
! 703:
! 704: #define bs_c_8_proto(f) \
! 705: void __bs_c(f,_bs_c_8) (void *t, bus_space_handle_t bsh1, \
! 706: bus_size_t offset1, bus_space_handle_t bsh2, \
! 707: bus_size_t offset2, bus_size_t count);
! 708:
! 709: #define bs_protos(f) \
! 710: bs_map_proto(f); \
! 711: bs_unmap_proto(f); \
! 712: bs_subregion_proto(f); \
! 713: bs_alloc_proto(f); \
! 714: bs_free_proto(f); \
! 715: bs_vaddr_proto(f); \
! 716: bs_mmap_proto(f); \
! 717: bs_barrier_proto(f); \
! 718: bs_r_1_proto(f); \
! 719: bs_r_2_proto(f); \
! 720: bs_r_4_proto(f); \
! 721: bs_r_8_proto(f); \
! 722: bs_w_1_proto(f); \
! 723: bs_w_2_proto(f); \
! 724: bs_w_4_proto(f); \
! 725: bs_w_8_proto(f); \
! 726: bs_rm_1_proto(f); \
! 727: bs_rm_2_proto(f); \
! 728: bs_rm_4_proto(f); \
! 729: bs_rm_8_proto(f); \
! 730: bs_wm_1_proto(f); \
! 731: bs_wm_2_proto(f); \
! 732: bs_wm_4_proto(f); \
! 733: bs_wm_8_proto(f); \
! 734: bs_rr_1_proto(f); \
! 735: bs_rr_2_proto(f); \
! 736: bs_rr_4_proto(f); \
! 737: bs_rr_8_proto(f); \
! 738: bs_wr_1_proto(f); \
! 739: bs_wr_2_proto(f); \
! 740: bs_wr_4_proto(f); \
! 741: bs_wr_8_proto(f); \
! 742: bs_sm_1_proto(f); \
! 743: bs_sm_2_proto(f); \
! 744: bs_sm_4_proto(f); \
! 745: bs_sm_8_proto(f); \
! 746: bs_sr_1_proto(f); \
! 747: bs_sr_2_proto(f); \
! 748: bs_sr_4_proto(f); \
! 749: bs_sr_8_proto(f); \
! 750: bs_c_1_proto(f); \
! 751: bs_c_2_proto(f); \
! 752: bs_c_4_proto(f); \
! 753: bs_c_8_proto(f);
! 754:
! 755: /* Bus Space DMA macros */
! 756:
! 757: /*
! 758: * Flags used in various bus DMA methods.
! 759: */
! 760: #define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
! 761: #define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
! 762: #define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
! 763: #define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
! 764: #define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
! 765: #define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
! 766: #define BUS_DMA_BUS2 0x020
! 767: #define BUS_DMA_BUS3 0x040
! 768: #define BUS_DMA_BUS4 0x080
! 769: #define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
! 770: #define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
! 771: #define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
! 772:
! 773: /*
! 774: * Private flags stored in the DMA map.
! 775: */
! 776: #define ARM32_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
! 777:
! 778: /* Forwards needed by prototypes below. */
! 779: struct mbuf;
! 780: struct uio;
! 781:
! 782: /*
! 783: * Operations performed by bus_dmamap_sync().
! 784: */
! 785: #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
! 786: #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
! 787: #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
! 788: #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
! 789:
! 790: typedef struct arm32_bus_dma_tag *bus_dma_tag_t;
! 791: typedef struct arm32_bus_dmamap *bus_dmamap_t;
! 792:
! 793: #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0)
! 794:
! 795: /*
! 796: * bus_dma_segment_t
! 797: *
! 798: * Describes a single contiguous DMA transaction. Values
! 799: * are suitable for programming into DMA registers.
! 800: */
! 801: struct arm32_bus_dma_segment {
! 802: /*
! 803: * PUBLIC MEMBERS: these are used by machine-independent code.
! 804: */
! 805: bus_addr_t ds_addr; /* DMA address */
! 806: bus_size_t ds_len; /* length of transfer */
! 807: /*
! 808: * PRIVATE MEMBERS: not for use by machine-independent code.
! 809: */
! 810: bus_addr_t _ds_vaddr; /* Virtual mapped address
! 811: * Used by bus_dmamem_sync() */
! 812: };
! 813: typedef struct arm32_bus_dma_segment bus_dma_segment_t;
! 814:
! 815: /*
! 816: * arm32_dma_range
! 817: *
! 818: * This structure describes a valid DMA range.
! 819: */
! 820: struct arm32_dma_range {
! 821: bus_addr_t dr_sysbase; /* system base address */
! 822: bus_addr_t dr_busbase; /* appears here on bus */
! 823: bus_size_t dr_len; /* length of range */
! 824: };
! 825:
! 826: /*
! 827: * bus_dma_tag_t
! 828: *
! 829: * A machine-dependent opaque type describing the implementation of
! 830: * DMA for a given bus.
! 831: */
! 832:
! 833: struct arm32_bus_dma_tag {
! 834: /*
! 835: * DMA range for this tag. If the page doesn't fall within
! 836: * one of these ranges, an error is returned. The caller
! 837: * may then decide what to do with the transfer. If the
! 838: * range pointer is NULL, it is ignored.
! 839: */
! 840: struct arm32_dma_range *_ranges;
! 841: int _nranges;
! 842:
! 843: /*
! 844: * Opaque cookie for use by back-end.
! 845: */
! 846: void *_cookie;
! 847:
! 848: /*
! 849: * DMA mapping methods.
! 850: */
! 851: int (*_dmamap_create) (bus_dma_tag_t, bus_size_t, int,
! 852: bus_size_t, bus_size_t, int, bus_dmamap_t *);
! 853: void (*_dmamap_destroy) (bus_dma_tag_t, bus_dmamap_t);
! 854: int (*_dmamap_load) (bus_dma_tag_t, bus_dmamap_t, void *,
! 855: bus_size_t, struct proc *, int);
! 856: int (*_dmamap_load_mbuf) (bus_dma_tag_t, bus_dmamap_t,
! 857: struct mbuf *, int);
! 858: int (*_dmamap_load_uio) (bus_dma_tag_t, bus_dmamap_t,
! 859: struct uio *, int);
! 860: int (*_dmamap_load_raw) (bus_dma_tag_t, bus_dmamap_t,
! 861: bus_dma_segment_t *, int, bus_size_t, int);
! 862: void (*_dmamap_unload) (bus_dma_tag_t, bus_dmamap_t);
! 863: void (*_dmamap_sync) (bus_dma_tag_t, bus_dmamap_t,
! 864: bus_addr_t, bus_size_t, int);
! 865:
! 866: /*
! 867: * DMA memory utility functions.
! 868: */
! 869: int (*_dmamem_alloc) (bus_dma_tag_t, bus_size_t, bus_size_t,
! 870: bus_size_t, bus_dma_segment_t *, int, int *, int);
! 871: void (*_dmamem_free) (bus_dma_tag_t,
! 872: bus_dma_segment_t *, int);
! 873: int (*_dmamem_map) (bus_dma_tag_t, bus_dma_segment_t *,
! 874: int, size_t, caddr_t *, int);
! 875: void (*_dmamem_unmap) (bus_dma_tag_t, caddr_t, size_t);
! 876: paddr_t (*_dmamem_mmap) (bus_dma_tag_t, bus_dma_segment_t *,
! 877: int, off_t, int, int);
! 878: };
! 879:
! 880: #define bus_dmamap_create(t, s, n, m, b, f, p) \
! 881: (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
! 882: #define bus_dmamap_destroy(t, p) \
! 883: (*(t)->_dmamap_destroy)((t), (p))
! 884: #define bus_dmamap_load(t, m, b, s, p, f) \
! 885: (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
! 886: #define bus_dmamap_load_mbuf(t, m, b, f) \
! 887: (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
! 888: #define bus_dmamap_load_uio(t, m, u, f) \
! 889: (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
! 890: #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
! 891: (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
! 892: #define bus_dmamap_unload(t, p) \
! 893: (*(t)->_dmamap_unload)((t), (p))
! 894: #define bus_dmamap_sync(t, p, o, l, ops) \
! 895: (void)((t)->_dmamap_sync ? \
! 896: (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
! 897:
! 898: #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
! 899: (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
! 900: #define bus_dmamem_free(t, sg, n) \
! 901: (*(t)->_dmamem_free)((t), (sg), (n))
! 902: #define bus_dmamem_map(t, sg, n, s, k, f) \
! 903: (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
! 904: #define bus_dmamem_unmap(t, k, s) \
! 905: (*(t)->_dmamem_unmap)((t), (k), (s))
! 906: #define bus_dmamem_mmap(t, sg, n, o, p, f) \
! 907: (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
! 908:
! 909: /*
! 910: * bus_dmamap_t
! 911: *
! 912: * Describes a DMA mapping.
! 913: */
! 914: struct arm32_bus_dmamap {
! 915: /*
! 916: * PRIVATE MEMBERS: not for use by machine-independent code.
! 917: */
! 918: bus_size_t _dm_size; /* largest DMA transfer mappable */
! 919: int _dm_segcnt; /* number of segs this map can map */
! 920: bus_size_t _dm_maxsegsz; /* largest possible segment */
! 921: bus_size_t _dm_boundary; /* don't cross this */
! 922: int _dm_flags; /* misc. flags */
! 923:
! 924: void *_dm_origbuf; /* pointer to original buffer */
! 925: int _dm_buftype; /* type of buffer */
! 926: struct proc *_dm_proc; /* proc that owns the mapping */
! 927:
! 928: void *_dm_cookie; /* cookie for bus-specific functions */
! 929:
! 930: /*
! 931: * PUBLIC MEMBERS: these are used by machine-independent code.
! 932: */
! 933: bus_size_t dm_mapsize; /* size of the mapping */
! 934: int dm_nsegs; /* # valid segments in mapping */
! 935: bus_dma_segment_t dm_segs[1]; /* segments; variable length */
! 936: };
! 937:
! 938: //#ifdef _ARM32_BUS_DMA_PRIVATE
! 939:
! 940: /* _dm_buftype */
! 941: #define ARM32_BUFTYPE_INVALID 0
! 942: #define ARM32_BUFTYPE_LINEAR 1
! 943: #define ARM32_BUFTYPE_MBUF 2
! 944: #define ARM32_BUFTYPE_UIO 3
! 945:
! 946: int arm32_dma_range_intersect(struct arm32_dma_range *, int,
! 947: paddr_t pa, psize_t size, paddr_t *pap, psize_t *sizep);
! 948:
! 949: int _bus_dmamap_create (bus_dma_tag_t, bus_size_t, int, bus_size_t,
! 950: bus_size_t, int, bus_dmamap_t *);
! 951: void _bus_dmamap_destroy (bus_dma_tag_t, bus_dmamap_t);
! 952: int _bus_dmamap_load (bus_dma_tag_t, bus_dmamap_t, void *,
! 953: bus_size_t, struct proc *, int);
! 954: int _bus_dmamap_load_mbuf (bus_dma_tag_t, bus_dmamap_t,
! 955: struct mbuf *, int);
! 956: int _bus_dmamap_load_uio (bus_dma_tag_t, bus_dmamap_t,
! 957: struct uio *, int);
! 958: int _bus_dmamap_load_raw (bus_dma_tag_t, bus_dmamap_t,
! 959: bus_dma_segment_t *, int, bus_size_t, int);
! 960: void _bus_dmamap_unload (bus_dma_tag_t, bus_dmamap_t);
! 961: void _bus_dmamap_sync (bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
! 962: bus_size_t, int);
! 963:
! 964: int _bus_dmamem_alloc (bus_dma_tag_t tag, bus_size_t size,
! 965: bus_size_t alignment, bus_size_t boundary,
! 966: bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
! 967: void _bus_dmamem_free (bus_dma_tag_t tag, bus_dma_segment_t *segs,
! 968: int nsegs);
! 969: int _bus_dmamem_map (bus_dma_tag_t tag, bus_dma_segment_t *segs,
! 970: int nsegs, size_t size, caddr_t *kvap, int flags);
! 971: void _bus_dmamem_unmap (bus_dma_tag_t tag, caddr_t kva,
! 972: size_t size);
! 973: paddr_t _bus_dmamem_mmap (bus_dma_tag_t tag, bus_dma_segment_t *segs,
! 974: int nsegs, off_t off, int prot, int flags);
! 975:
! 976: int _bus_dmamem_alloc_range (bus_dma_tag_t tag, bus_size_t size,
! 977: bus_size_t alignment, bus_size_t boundary,
! 978: bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
! 979: vaddr_t low, vaddr_t high);
! 980: //#endif /* _ARM32_BUS_DMA_PRIVATE */
! 981: /* These are OpenBSD extensions to the general NetBSD bus interface. */
! 982: void
! 983: bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
! 984: bus_addr_t ba, u_int8_t *dst, bus_size_t size);
! 985: void
! 986: bus_space_read_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
! 987: bus_addr_t ba, u_int8_t *dst, bus_size_t size);
! 988: #define bus_space_read_raw_multi_8 \
! 989: !!! bus_space_read_raw_multi_8 not implemented !!!
! 990:
! 991: void
! 992: bus_space_write_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
! 993: bus_addr_t ba, const u_int8_t *src, bus_size_t size);
! 994: void
! 995: bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
! 996: bus_addr_t ba, const u_int8_t *src, bus_size_t size);
! 997: #define bus_space_write_raw_multi_8 \
! 998: !!! bus_space_write_raw_multi_8 not implemented !!!
! 999:
! 1000: /*
! 1001: * void bus_space_read_raw_region_N(bus_space_tag_t tag,
! 1002: * bus_space_handle_t bsh, bus_size_t offset,
! 1003: * u_int8_t *addr, size_t count);
! 1004: *
! 1005: * Read `count' bytes in 2, 4 or 8 byte wide quantities from bus space
! 1006: * described by tag/handle and starting at `offset' and copy into
! 1007: * buffer provided. The buffer must have proper alignment for the N byte
! 1008: * wide entities. Furthermore possible byte-swapping should be done by
! 1009: * these functions.
! 1010: */
! 1011:
! 1012: #define bus_space_read_raw_region_2(t, h, o, a, c) \
! 1013: bus_space_read_region_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
! 1014: #define bus_space_read_raw_region_4(t, h, o, a, c) \
! 1015: bus_space_read_region_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
! 1016:
! 1017: #if 0 /* Cause a link error for bus_space_read_raw_region_8 */
! 1018: #define bus_space_read_raw_region_8 \
! 1019: !!! bus_space_read_raw_region_8 unimplemented !!!
! 1020: #endif
! 1021:
! 1022: /*
! 1023: * void bus_space_write_raw_region_N(bus_space_tag_t tag,
! 1024: * bus_space_handle_t bsh, bus_size_t offset,
! 1025: * const u_int8_t *addr, size_t count);
! 1026: *
! 1027: * Write `count' bytes in 2, 4 or 8 byte wide quantities to bus space
! 1028: * described by tag/handle and starting at `offset' from the
! 1029: * buffer provided. The buffer must have proper alignment for the N byte
! 1030: * wide entities. Furthermore possible byte-swapping should be done by
! 1031: * these functions.
! 1032: */
! 1033:
! 1034: #define bus_space_write_raw_region_2(t, h, o, a, c) \
! 1035: bus_space_write_region_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
! 1036: #define bus_space_write_raw_region_4(t, h, o, a, c) \
! 1037: bus_space_write_region_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
! 1038:
! 1039: #if 0 /* Cause a link error for bus_space_write_raw_region_8 */
! 1040: #define bus_space_write_raw_region_8 \
! 1041: !!! bus_space_write_raw_region_8 unimplemented !!!
! 1042: #endif
! 1043:
! 1044: #endif /* _ARM32_BUS_H_ */
CVSweb