1*34376d66Sriastradh /* $NetBSD: bus_funcs.h,v 1.2 2022/03/10 00:14:16 riastradh Exp $ */ 2e57d534eSdyoung /* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */ 3e57d534eSdyoung 4e57d534eSdyoung /*- 5e57d534eSdyoung * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 6e57d534eSdyoung * All rights reserved. 7e57d534eSdyoung * 8e57d534eSdyoung * This code is derived from software contributed to The NetBSD Foundation 9e57d534eSdyoung * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 10e57d534eSdyoung * NASA Ames Research Center. 11e57d534eSdyoung * 12e57d534eSdyoung * Redistribution and use in source and binary forms, with or without 13e57d534eSdyoung * modification, are permitted provided that the following conditions 14e57d534eSdyoung * are met: 15e57d534eSdyoung * 1. Redistributions of source code must retain the above copyright 16e57d534eSdyoung * notice, this list of conditions and the following disclaimer. 17e57d534eSdyoung * 2. Redistributions in binary form must reproduce the above copyright 18e57d534eSdyoung * notice, this list of conditions and the following disclaimer in the 19e57d534eSdyoung * documentation and/or other materials provided with the distribution. 20e57d534eSdyoung * 21e57d534eSdyoung * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22e57d534eSdyoung * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23e57d534eSdyoung * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24e57d534eSdyoung * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25e57d534eSdyoung * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26e57d534eSdyoung * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27e57d534eSdyoung * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28e57d534eSdyoung * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29e57d534eSdyoung * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30e57d534eSdyoung * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31e57d534eSdyoung * POSSIBILITY OF SUCH DAMAGE. 32e57d534eSdyoung */ 33e57d534eSdyoung 34e57d534eSdyoung /* 35e57d534eSdyoung * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 36e57d534eSdyoung * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. 37e57d534eSdyoung * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 38e57d534eSdyoung * 39e57d534eSdyoung * Redistribution and use in source and binary forms, with or without 40e57d534eSdyoung * modification, are permitted provided that the following conditions 41e57d534eSdyoung * are met: 42e57d534eSdyoung * 1. Redistributions of source code must retain the above copyright 43e57d534eSdyoung * notice, this list of conditions and the following disclaimer. 44e57d534eSdyoung * 2. Redistributions in binary form must reproduce the above copyright 45e57d534eSdyoung * notice, this list of conditions and the following disclaimer in the 46e57d534eSdyoung * documentation and/or other materials provided with the distribution. 47e57d534eSdyoung * 3. All advertising materials mentioning features or use of this software 48e57d534eSdyoung * must display the following acknowledgement: 49e57d534eSdyoung * This product includes software developed by Christopher G. Demetriou 50e57d534eSdyoung * for the NetBSD Project. 51e57d534eSdyoung * 4. The name of the author may not be used to endorse or promote products 52e57d534eSdyoung * derived from this software without specific prior written permission 53e57d534eSdyoung * 54e57d534eSdyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 55e57d534eSdyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 56e57d534eSdyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 57e57d534eSdyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 58e57d534eSdyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 59e57d534eSdyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 60e57d534eSdyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 61e57d534eSdyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 62e57d534eSdyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 63e57d534eSdyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 64e57d534eSdyoung */ 65e57d534eSdyoung 66e57d534eSdyoung /* 67e57d534eSdyoung * Copyright (c) 1997 Per Fogelstrom. All rights reserved. 68e57d534eSdyoung * Copyright (c) 1996 Niklas Hallqvist. All rights reserved. 69e57d534eSdyoung * 70e57d534eSdyoung * Redistribution and use in source and binary forms, with or without 71e57d534eSdyoung * modification, are permitted provided that the following conditions 72e57d534eSdyoung * are met: 73e57d534eSdyoung * 1. Redistributions of source code must retain the above copyright 74e57d534eSdyoung * notice, this list of conditions and the following disclaimer. 75e57d534eSdyoung * 2. Redistributions in binary form must reproduce the above copyright 76e57d534eSdyoung * notice, this list of conditions and the following disclaimer in the 77e57d534eSdyoung * documentation and/or other materials provided with the distribution. 78e57d534eSdyoung * 3. All advertising materials mentioning features or use of this software 79e57d534eSdyoung * must display the following acknowledgement: 80e57d534eSdyoung * This product includes software developed by Christopher G. Demetriou 81e57d534eSdyoung * for the NetBSD Project. 82e57d534eSdyoung * 4. The name of the author may not be used to endorse or promote products 83e57d534eSdyoung * derived from this software without specific prior written permission 84e57d534eSdyoung * 85e57d534eSdyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 86e57d534eSdyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 87e57d534eSdyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 88e57d534eSdyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 89e57d534eSdyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 90e57d534eSdyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 91e57d534eSdyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 92e57d534eSdyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 93e57d534eSdyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 94e57d534eSdyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 95e57d534eSdyoung */ 96e57d534eSdyoung 97e57d534eSdyoung #ifndef _POWERPC_BUS_FUNCS_H_ 98e57d534eSdyoung #define _POWERPC_BUS_FUNCS_H_ 99e57d534eSdyoung 100e57d534eSdyoung #ifndef __HAVE_LOCAL_BUS_SPACE 101e57d534eSdyoung 102e57d534eSdyoung #ifdef __STDC__ 103e57d534eSdyoung #define CAT(a,b) a##b 104e57d534eSdyoung #define CAT3(a,b,c) a##b##c 105e57d534eSdyoung #else 106e57d534eSdyoung #define CAT(a,b) a/**/b 107e57d534eSdyoung #define CAT3(a,b,c) a/**/b/**/c 108e57d534eSdyoung #endif 109e57d534eSdyoung 110e57d534eSdyoung int bus_space_init(struct powerpc_bus_space *, const char *, void *, size_t); 111e57d534eSdyoung void bus_space_mallocok(void); 112e57d534eSdyoung 113e57d534eSdyoung /* 114e57d534eSdyoung * Access methods for bus resources 115e57d534eSdyoung */ 116e57d534eSdyoung 117e57d534eSdyoung /* 118e57d534eSdyoung * void *bus_space_vaddr (bus_space_tag_t, bus_space_handle_t); 119e57d534eSdyoung * 120e57d534eSdyoung * Get the kernel virtual address for the mapped bus space. 121e57d534eSdyoung * Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR. 122e57d534eSdyoung * (XXX not enforced) 123e57d534eSdyoung */ 124e57d534eSdyoung #define bus_space_vaddr(t, h) ((void *)(h)) 125e57d534eSdyoung 126e57d534eSdyoung /* 127e57d534eSdyoung * paddr_t bus_space_mmap (bus_space_tag_t t, bus_addr_t addr, 128e57d534eSdyoung * off_t offset, int prot, int flags); 129e57d534eSdyoung * 130e57d534eSdyoung * Mmap a region of bus space. 131e57d534eSdyoung */ 132e57d534eSdyoung 133e57d534eSdyoung #define bus_space_mmap(t, b, o, p, f) \ 134e57d534eSdyoung ((*(t)->pbs_mmap)((t), (b), (o), (p), (f))) 135e57d534eSdyoung 136e57d534eSdyoung /* 137e57d534eSdyoung * int bus_space_map (bus_space_tag_t t, bus_addr_t addr, 138e57d534eSdyoung * bus_size_t size, int flags, bus_space_handle_t *bshp); 139e57d534eSdyoung * 140e57d534eSdyoung * Map a region of bus space. 141e57d534eSdyoung */ 142e57d534eSdyoung 143e57d534eSdyoung #define bus_space_map(t, a, s, f, hp) \ 144e57d534eSdyoung ((*(t)->pbs_map)((t), (a), (s), (f), (hp))) 145e57d534eSdyoung 146e57d534eSdyoung /* 147e57d534eSdyoung * int bus_space_unmap (bus_space_tag_t t, 148e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t size); 149e57d534eSdyoung * 150e57d534eSdyoung * Unmap a region of bus space. 151e57d534eSdyoung */ 152e57d534eSdyoung 153e57d534eSdyoung #define bus_space_unmap(t, h, s) \ 154e57d534eSdyoung ((void)(*(t)->pbs_unmap)((t), (h), (s))) 155e57d534eSdyoung 156e57d534eSdyoung /* 157e57d534eSdyoung * int bus_space_subregion (bus_space_tag_t t, 158e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, 159e57d534eSdyoung * bus_space_handle_t *nbshp); 160e57d534eSdyoung * 161e57d534eSdyoung * Get a new handle for a subregion of an already-mapped area of bus space. 162e57d534eSdyoung */ 163e57d534eSdyoung 164e57d534eSdyoung #define bus_space_subregion(t, h, o, s, hp) \ 165e57d534eSdyoung ((*(t)->pbs_subregion)((t), (h), (o), (s), (hp))) 166e57d534eSdyoung 167e57d534eSdyoung /* 168e57d534eSdyoung * int bus_space_alloc (bus_space_tag_t t, bus_addr_t rstart, 169e57d534eSdyoung * bus_addr_t rend, bus_size_t size, bus_size_t align, 170e57d534eSdyoung * bus_size_t boundary, int flags, bus_addr_t *bpap, 171e57d534eSdyoung * bus_space_handle_t *bshp); 172e57d534eSdyoung * 173e57d534eSdyoung * Allocate a region of bus space. 174e57d534eSdyoung */ 175e57d534eSdyoung 176e57d534eSdyoung #define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \ 177e57d534eSdyoung ((*(t)->pbs_alloc)((t), (rs), (re), (s), (a), (b), (f), (ap), (hp))) 178e57d534eSdyoung 179e57d534eSdyoung /* 180e57d534eSdyoung * int bus_space_free (bus_space_tag_t t, 181e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t size); 182e57d534eSdyoung * 183e57d534eSdyoung * Free a region of bus space. 184e57d534eSdyoung */ 185e57d534eSdyoung 186e57d534eSdyoung #define bus_space_free(t, h, s) \ 187e57d534eSdyoung ((void)(*(t)->pbs_free)((t), (h), (s))) 188e57d534eSdyoung 189e57d534eSdyoung /* 190e57d534eSdyoung * uintN_t bus_space_read_N (bus_space_tag_t tag, 191e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset); 192e57d534eSdyoung * 193e57d534eSdyoung * Read a 1, 2, 4, or 8 byte quantity from bus space 194e57d534eSdyoung * described by tag/handle/offset. 195e57d534eSdyoung */ 196e57d534eSdyoung 197e57d534eSdyoung #define bus_space_read_1(t, h, o) \ 198e57d534eSdyoung ((*(t)->pbs_scalar.pbss_read_1)((t), (h), (o))) 199e57d534eSdyoung #define bus_space_read_2(t, h, o) \ 200e57d534eSdyoung ((*(t)->pbs_scalar.pbss_read_2)((t), (h), (o))) 201e57d534eSdyoung #define bus_space_read_4(t, h, o) \ 202e57d534eSdyoung ((*(t)->pbs_scalar.pbss_read_4)((t), (h), (o))) 203e57d534eSdyoung #define bus_space_read_8(t, h, o) \ 204e57d534eSdyoung ((*(t)->pbs_scalar.pbss_read_8)((t), (h), (o))) 205e57d534eSdyoung 206e57d534eSdyoung /* 207e57d534eSdyoung * uintN_t bus_space_read_stream_N (bus_space_tag_t tag, 208e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset); 209e57d534eSdyoung * 210e57d534eSdyoung * Read a 2, 4, or 8 byte quantity from bus space 211e57d534eSdyoung * described by tag/handle/offset ignoring endianness. 212e57d534eSdyoung */ 213e57d534eSdyoung 214e57d534eSdyoung #define bus_space_read_stream_2(t, h, o) \ 215e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_read_2)((t), (h), (o))) 216e57d534eSdyoung #define bus_space_read_stream_4(t, h, o) \ 217e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_read_4)((t), (h), (o))) 218e57d534eSdyoung #define bus_space_read_stream_8(t, h, o) \ 219e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_read_8)((t), (h), (o))) 220e57d534eSdyoung 221e57d534eSdyoung /* 222e57d534eSdyoung * void bus_space_read_multi_N _P((bus_space_tag_t tag, 223e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 224e57d534eSdyoung * uintN_t *addr, size_t count); 225e57d534eSdyoung * 226e57d534eSdyoung * Read `count' 1, 2, 4, or 8 byte quantities from bus space 227e57d534eSdyoung * described by tag/handle/offset and copy into buffer provided. 228e57d534eSdyoung */ 229e57d534eSdyoung 230e57d534eSdyoung #define bus_space_read_multi_1(t, h, o, a, c) \ 231e57d534eSdyoung ((*(t)->pbs_multi->pbsg_read_1)((t), (h), (o), (a), (c))) 232e57d534eSdyoung #define bus_space_read_multi_2(t, h, o, a, c) \ 233e57d534eSdyoung ((*(t)->pbs_multi->pbsg_read_2)((t), (h), (o), (a), (c))) 234e57d534eSdyoung #define bus_space_read_multi_4(t, h, o, a, c) \ 235e57d534eSdyoung ((*(t)->pbs_multi->pbsg_read_4)((t), (h), (o), (a), (c))) 236e57d534eSdyoung #define bus_space_read_multi_8(t, h, o, a, c) \ 237e57d534eSdyoung ((*(t)->pbs_multi->pbsg_read_8)((t), (h), (o), (a), (c))) 238e57d534eSdyoung 239e57d534eSdyoung /* 240e57d534eSdyoung * void bus_space_read_multi_stream_N (bus_space_tag_t tag, 241e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 242e57d534eSdyoung * uintN_t *addr, size_t count); 243e57d534eSdyoung * 244e57d534eSdyoung * Read `count' 2, 4, or 8 byte stream quantities from bus space 245e57d534eSdyoung * described by tag/handle/offset and copy into buffer provided. 246e57d534eSdyoung */ 247e57d534eSdyoung 248e57d534eSdyoung #define bus_space_read_multi_stream_2(t, h, o, a, c) \ 249e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_read_2)((t), (h), (o), (a), (c))) 250e57d534eSdyoung #define bus_space_read_multi_stream_4(t, h, o, a, c) \ 251e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_read_4)((t), (h), (o), (a), (c))) 252e57d534eSdyoung #define bus_space_read_multi_stream_8(t, h, o, a, c) \ 253e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_read_8)((t), (h), (o), (a), (c))) 254e57d534eSdyoung 255e57d534eSdyoung /* 256e57d534eSdyoung * void bus_space_write_N (bus_space_tag_t tag, 257e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 258e57d534eSdyoung * uintN_t value); 259e57d534eSdyoung * 260e57d534eSdyoung * Write the 1, 2, 4, or 8 byte value `value' to bus space 261e57d534eSdyoung * described by tag/handle/offset. 262e57d534eSdyoung */ 263e57d534eSdyoung 264e57d534eSdyoung #define bus_space_write_1(t, h, o, v) \ 265e57d534eSdyoung ((*(t)->pbs_scalar.pbss_write_1)((t), (h), (o), (v))) 266e57d534eSdyoung #define bus_space_write_2(t, h, o, v) \ 267e57d534eSdyoung ((*(t)->pbs_scalar.pbss_write_2)((t), (h), (o), (v))) 268e57d534eSdyoung #define bus_space_write_4(t, h, o, v) \ 269e57d534eSdyoung ((*(t)->pbs_scalar.pbss_write_4)((t), (h), (o), (v))) 270e57d534eSdyoung #define bus_space_write_8(t, h, o, v) \ 271e57d534eSdyoung ((*(t)->pbs_scalar.pbss_write_8)((t), (h), (o), (v))) 272e57d534eSdyoung 273e57d534eSdyoung /* 274e57d534eSdyoung * void bus_space_write_stream_N (bus_space_tag_t tag, 275e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 276e57d534eSdyoung * uintN_t value); 277e57d534eSdyoung * 278e57d534eSdyoung * Write the 2, 4, or 8 byte stream value `value' to bus space 279e57d534eSdyoung * described by tag/handle/offset. 280e57d534eSdyoung */ 281e57d534eSdyoung 282e57d534eSdyoung #define bus_space_write_stream_1(t, h, o, v) \ 283e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_write_1)((t), (h), (o), (v))) 284e57d534eSdyoung #define bus_space_write_stream_2(t, h, o, v) \ 285e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_write_2)((t), (h), (o), (v))) 286e57d534eSdyoung #define bus_space_write_stream_4(t, h, o, v) \ 287e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_write_4)((t), (h), (o), (v))) 288e57d534eSdyoung #define bus_space_write_stream_8(t, h, o, v) \ 289e57d534eSdyoung ((*(t)->pbs_scalar_stream.pbss_write_8)((t), (h), (o), (v))) 290e57d534eSdyoung 291e57d534eSdyoung /* 292e57d534eSdyoung * void bus_space_write_multi_N (bus_space_tag_t tag, 293e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 294e57d534eSdyoung * const uintN_t *addr, size_t count); 295e57d534eSdyoung * 296e57d534eSdyoung * Write `count' 1, 2, 4, or 8 byte quantities from the buffer 297e57d534eSdyoung * provided to bus space described by tag/handle/offset. 298e57d534eSdyoung */ 299e57d534eSdyoung 300e57d534eSdyoung #define bus_space_write_multi_1(t, h, o, a, c) \ 301e57d534eSdyoung ((*(t)->pbs_multi->pbsg_write_1)((t), (h), (o), (a), (c))) 302e57d534eSdyoung #define bus_space_write_multi_2(t, h, o, a, c) \ 303e57d534eSdyoung ((*(t)->pbs_multi->pbsg_write_2)((t), (h), (o), (a), (c))) 304e57d534eSdyoung #define bus_space_write_multi_4(t, h, o, a, c) \ 305e57d534eSdyoung ((*(t)->pbs_multi->pbsg_write_4)((t), (h), (o), (a), (c))) 306e57d534eSdyoung #define bus_space_write_multi_8(t, h, o, a, c) \ 307e57d534eSdyoung ((*(t)->pbs_multi->pbsg_write_8)((t), (h), (o), (a), (c))) 308e57d534eSdyoung 309e57d534eSdyoung /* 310e57d534eSdyoung * void bus_space_write_multi_stream_N (bus_space_tag_t tag, 311e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 312e57d534eSdyoung * const uintN_t *addr, size_t count); 313e57d534eSdyoung * 314e57d534eSdyoung * Write `count' 2, 4, or 8 byte stream quantities from the buffer 315e57d534eSdyoung * provided to bus space described by tag/handle/offset. 316e57d534eSdyoung */ 317e57d534eSdyoung 318e57d534eSdyoung #define bus_space_write_multi_stream_1(t, h, o, a, c) \ 319e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_write_1)((t), (h), (o), (a), (c))) 320e57d534eSdyoung #define bus_space_write_multi_stream_2(t, h, o, a, c) \ 321e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_write_2)((t), (h), (o), (a), (c))) 322e57d534eSdyoung #define bus_space_write_multi_stream_4(t, h, o, a, c) \ 323e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_write_4)((t), (h), (o), (a), (c))) 324e57d534eSdyoung #define bus_space_write_multi_stream_8(t, h, o, a, c) \ 325e57d534eSdyoung ((*(t)->pbs_multi_stream->pbsg_write_8)((t), (h), (o), (a), (c))) 326e57d534eSdyoung 327e57d534eSdyoung /* 328e57d534eSdyoung * void bus_space_read_region_N (bus_space_tag_t tag, 329e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 330e57d534eSdyoung * uintN_t *addr, size_t count); 331e57d534eSdyoung * 332e57d534eSdyoung * Read `count' 1, 2, 4, or 8 byte quantities from bus space 333e57d534eSdyoung * described by tag/handle and starting at `offset' and copy into 334e57d534eSdyoung * buffer provided. 335e57d534eSdyoung */ 336e57d534eSdyoung #define bus_space_read_region_1(t, h, o, a, c) \ 337e57d534eSdyoung ((*(t)->pbs_region->pbsg_read_1)((t), (h), (o), (a), (c))) 338e57d534eSdyoung #define bus_space_read_region_2(t, h, o, a, c) \ 339e57d534eSdyoung ((*(t)->pbs_region->pbsg_read_2)((t), (h), (o), (a), (c))) 340e57d534eSdyoung #define bus_space_read_region_4(t, h, o, a, c) \ 341e57d534eSdyoung ((*(t)->pbs_region->pbsg_read_4)((t), (h), (o), (a), (c))) 342e57d534eSdyoung #define bus_space_read_region_8(t, h, o, a, c) \ 343e57d534eSdyoung ((*(t)->pbs_region->pbsg_read_8)((t), (h), (o), (a), (c))) 344e57d534eSdyoung 345e57d534eSdyoung /* 346e57d534eSdyoung * void bus_space_read_region_stream_N (bus_space_tag_t tag, 347e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 348e57d534eSdyoung * uintN_t *addr, size_t count); 349e57d534eSdyoung * 350e57d534eSdyoung * Read `count' 2, 4, or 8 byte stream quantities from bus space 351e57d534eSdyoung * described by tag/handle and starting at `offset' and copy into 352e57d534eSdyoung * buffer provided. 353e57d534eSdyoung */ 354e57d534eSdyoung #define bus_space_read_region_stream_2(t, h, o, a, c) \ 355e57d534eSdyoung ((*(t)->pbs_region_stream->pbsg_read_2)((t), (h), (o), (a), (c))) 356e57d534eSdyoung #define bus_space_read_region_stream_4(t, h, o, a, c) \ 357e57d534eSdyoung ((*(t)->pbs_region_stream->pbsg_read_4)((t), (h), (o), (a), (c))) 358e57d534eSdyoung #define bus_space_read_region_stream_8(t, h, o, a, c) \ 359e57d534eSdyoung ((*(t)->pbs_region_stream->pbsg_read_8)((t), (h), (o), (a), (c))) 360e57d534eSdyoung 361e57d534eSdyoung /* 362e57d534eSdyoung * void bus_space_write_region_N (bus_space_tag_t tag, 363e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 364e57d534eSdyoung * const uintN_t *addr, size_t count); 365e57d534eSdyoung * 366e57d534eSdyoung * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided 367e57d534eSdyoung * to bus space described by tag/handle starting at `offset'. 368e57d534eSdyoung */ 369e57d534eSdyoung #define bus_space_write_region_1(t, h, o, a, c) \ 370e57d534eSdyoung ((*(t)->pbs_region->pbsg_write_1)((t), (h), (o), (a), (c))) 371e57d534eSdyoung #define bus_space_write_region_2(t, h, o, a, c) \ 372e57d534eSdyoung ((*(t)->pbs_region->pbsg_write_2)((t), (h), (o), (a), (c))) 373e57d534eSdyoung #define bus_space_write_region_4(t, h, o, a, c) \ 374e57d534eSdyoung ((*(t)->pbs_region->pbsg_write_4)((t), (h), (o), (a), (c))) 375e57d534eSdyoung #define bus_space_write_region_8(t, h, o, a, c) \ 376e57d534eSdyoung ((*(t)->pbs_region->pbsg_write_8)((t), (h), (o), (a), (c))) 377e57d534eSdyoung 378e57d534eSdyoung /* 379e57d534eSdyoung * void bus_space_write_region_stream_N (bus_space_tag_t tag, 380e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 381e57d534eSdyoung * const uintN_t *addr, size_t count); 382e57d534eSdyoung * 383e57d534eSdyoung * Write `count' 2, 4, or 8 byte stream quantities from the buffer provided 384e57d534eSdyoung * to bus space described by tag/handle starting at `offset'. 385e57d534eSdyoung */ 386e57d534eSdyoung #define bus_space_write_region_stream_2(t, h, o, a, c) \ 387e57d534eSdyoung ((*(t)->pbs_region_stream->pbsg_write_2)((t), (h), (o), (a), (c))) 388e57d534eSdyoung #define bus_space_write_region_stream_4(t, h, o, a, c) \ 389e57d534eSdyoung ((*(t)->pbs_region_stream->pbsg_write_4)((t), (h), (o), (a), (c))) 390e57d534eSdyoung #define bus_space_write_region_stream_8(t, h, o, a, c) \ 391e57d534eSdyoung ((*(t)->pbs_region_stream->pbsg_write_8)((t), (h), (o), (a), (c))) 392e57d534eSdyoung 393e57d534eSdyoung #if 0 394e57d534eSdyoung /* 395e57d534eSdyoung * void bus_space_set_multi_N (bus_space_tag_t tag, 396e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, uintN_t val, 397e57d534eSdyoung * size_t count); 398e57d534eSdyoung * 399e57d534eSdyoung * Write the 1, 2, 4, or 8 byte value `val' to bus space described 400e57d534eSdyoung * by tag/handle/offset `count' times. 401e57d534eSdyoung */ 402e57d534eSdyoung #define bus_space_set_multi_1(t, h, o, v, c) 403e57d534eSdyoung ((*(t)->pbs_set_multi_1)((t), (h), (o), (v), (c))) 404e57d534eSdyoung #define bus_space_set_multi_2(t, h, o, v, c) 405e57d534eSdyoung ((*(t)->pbs_set_multi_2)((t), (h), (o), (v), (c))) 406e57d534eSdyoung #define bus_space_set_multi_4(t, h, o, v, c) 407e57d534eSdyoung ((*(t)->pbs_set_multi_4)((t), (h), (o), (v), (c))) 408e57d534eSdyoung #define bus_space_set_multi_8(t, h, o, v, c) 409e57d534eSdyoung ((*(t)->pbs_set_multi_8)((t), (h), (o), (v), (c))) 410e57d534eSdyoung 411e57d534eSdyoung /* 412e57d534eSdyoung * void bus_space_set_multi_stream_N (bus_space_tag_t tag, 413e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, uintN_t val, 414e57d534eSdyoung * size_t count); 415e57d534eSdyoung * 416e57d534eSdyoung * Write the 2, 4, or 8 byte stream value `val' to bus space described 417e57d534eSdyoung * by tag/handle/offset `count' times. 418e57d534eSdyoung */ 419e57d534eSdyoung #define bus_space_set_multi_stream_2(t, h, o, v, c) 420e57d534eSdyoung ((*(t)->pbs_set_multi_stream_2)((t), (h), (o), (v), (c))) 421e57d534eSdyoung #define bus_space_set_multi_stream_4(t, h, o, v, c) 422e57d534eSdyoung ((*(t)->pbs_set_multi_stream_4)((t), (h), (o), (v), (c))) 423e57d534eSdyoung #define bus_space_set_multi_stream_8(t, h, o, v, c) 424e57d534eSdyoung ((*(t)->pbs_set_multi_stream_8)((t), (h), (o), (v), (c))) 425e57d534eSdyoung 426e57d534eSdyoung #endif 427e57d534eSdyoung 428e57d534eSdyoung /* 429e57d534eSdyoung * void bus_space_set_region_N (bus_space_tag_t tag, 430e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, uintN_t val, 431e57d534eSdyoung * size_t count); 432e57d534eSdyoung * 433e57d534eSdyoung * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described 434e57d534eSdyoung * by tag/handle starting at `offset'. 435e57d534eSdyoung */ 436e57d534eSdyoung #define bus_space_set_region_1(t, h, o, v, c) \ 437e57d534eSdyoung ((*(t)->pbs_set->pbss_set_1)((t), (h), (o), (v), (c))) 438e57d534eSdyoung #define bus_space_set_region_2(t, h, o, v, c) \ 439e57d534eSdyoung ((*(t)->pbs_set->pbss_set_2)((t), (h), (o), (v), (c))) 440e57d534eSdyoung #define bus_space_set_region_4(t, h, o, v, c) \ 441e57d534eSdyoung ((*(t)->pbs_set->pbss_set_4)((t), (h), (o), (v), (c))) 442e57d534eSdyoung #define bus_space_set_region_8(t, h, o, v, c) \ 443e57d534eSdyoung ((*(t)->pbs_set->pbss_set_8)((t), (h), (o), (v), (c))) 444e57d534eSdyoung 445e57d534eSdyoung /* 446e57d534eSdyoung * void bus_space_set_region_stream_N (bus_space_tag_t tag, 447e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, uintN_t val, 448e57d534eSdyoung * size_t count); 449e57d534eSdyoung * 450e57d534eSdyoung * Write `count' 2, 4, or 8 byte stream value `val' to bus space described 451e57d534eSdyoung * by tag/handle starting at `offset'. 452e57d534eSdyoung */ 453e57d534eSdyoung #define bus_space_set_region_stream_2(t, h, o, v, c) \ 454e57d534eSdyoung ((*(t)->pbs_set_stream->pbss_set_2)((t), (h), (o), (v), (c))) 455e57d534eSdyoung #define bus_space_set_region_stream_4(t, h, o, v, c) \ 456e57d534eSdyoung ((*(t)->pbs_set_stream->pbss_set_4)((t), (h), (o), (v), (c))) 457e57d534eSdyoung #define bus_space_set_region_stream_8(t, h, o, v, c) \ 458e57d534eSdyoung ((*(t)->pbs_set_stream->pbss_set_8)((t), (h), (o), (v), (c))) 459e57d534eSdyoung 460e57d534eSdyoung 461e57d534eSdyoung /* 462e57d534eSdyoung * void bus_space_copy_region_N (bus_space_tag_t tag, 463e57d534eSdyoung * bus_space_handle_t bsh1, bus_size_t off1, 464e57d534eSdyoung * bus_space_handle_t bsh2, bus_size_t off2, 465e57d534eSdyoung * size_t count); 466e57d534eSdyoung * 467e57d534eSdyoung * Copy `count' 1, 2, 4, or 8 byte values from bus space starting 468e57d534eSdyoung * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. 469e57d534eSdyoung */ 470e57d534eSdyoung #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \ 471e57d534eSdyoung ((*(t)->pbs_copy->pbsc_copy_1)((t), (h1), (o1), (h2), (o2), (c))) 472e57d534eSdyoung #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \ 473e57d534eSdyoung ((*(t)->pbs_copy->pbsc_copy_2)((t), (h1), (o1), (h2), (o2), (c))) 474e57d534eSdyoung #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \ 475e57d534eSdyoung ((*(t)->pbs_copy->pbsc_copy_4)((t), (h1), (o1), (h2), (o2), (c))) 476e57d534eSdyoung #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \ 477e57d534eSdyoung ((*(t)->pbs_copy->pbsc_copy_8)((t), (h1), (o1), (h2), (o2), (c))) 478e57d534eSdyoung 479e57d534eSdyoung /* 480e57d534eSdyoung * Bus read/write barrier methods. 481e57d534eSdyoung * 482e57d534eSdyoung * void bus_space_barrier (bus_space_tag_t tag, 483e57d534eSdyoung * bus_space_handle_t bsh, bus_size_t offset, 484e57d534eSdyoung * bus_size_t len, int flags); 485e57d534eSdyoung * 486e57d534eSdyoung */ 487e57d534eSdyoung #define bus_space_barrier(t, h, o, l, f) \ 488*34376d66Sriastradh ((*(t)->pbs_barrier)((t), (h), (o), (l), (f))) 489e57d534eSdyoung 490e57d534eSdyoung #endif /* !__HAVE_LOCAL_BUS_SPACE */ 491e57d534eSdyoung 492e57d534eSdyoung /* 493e57d534eSdyoung * Bus DMA methods. 494e57d534eSdyoung */ 495e57d534eSdyoung 496e57d534eSdyoung /* Forwards needed by prototypes below. */ 497e57d534eSdyoung struct proc; 498e57d534eSdyoung struct mbuf; 499e57d534eSdyoung struct uio; 500e57d534eSdyoung 501e57d534eSdyoung #define bus_dmamap_create(t, s, n, m, b, f, p) \ 502e57d534eSdyoung (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p)) 503e57d534eSdyoung #define bus_dmamap_destroy(t, p) \ 504e57d534eSdyoung (*(t)->_dmamap_destroy)((t), (p)) 505e57d534eSdyoung #define bus_dmamap_load(t, m, b, s, p, f) \ 506e57d534eSdyoung (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f)) 507e57d534eSdyoung #define bus_dmamap_load_mbuf(t, m, b, f) \ 508e57d534eSdyoung (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f)) 509e57d534eSdyoung #define bus_dmamap_load_uio(t, m, u, f) \ 510e57d534eSdyoung (*(t)->_dmamap_load_uio)((t), (m), (u), (f)) 511e57d534eSdyoung #define bus_dmamap_load_raw(t, m, sg, n, s, f) \ 512e57d534eSdyoung (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f)) 513e57d534eSdyoung #define bus_dmamap_unload(t, p) \ 514e57d534eSdyoung (*(t)->_dmamap_unload)((t), (p)) 515e57d534eSdyoung #define bus_dmamap_sync(t, p, o, l, ops) \ 516e57d534eSdyoung (void)((t)->_dmamap_sync ? \ 517e57d534eSdyoung (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0) 518e57d534eSdyoung 519e57d534eSdyoung #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ 520e57d534eSdyoung (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) 521e57d534eSdyoung #define bus_dmamem_free(t, sg, n) \ 522e57d534eSdyoung (*(t)->_dmamem_free)((t), (sg), (n)) 523e57d534eSdyoung #define bus_dmamem_map(t, sg, n, s, k, f) \ 524e57d534eSdyoung (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f)) 525e57d534eSdyoung #define bus_dmamem_unmap(t, k, s) \ 526e57d534eSdyoung (*(t)->_dmamem_unmap)((t), (k), (s)) 527e57d534eSdyoung #define bus_dmamem_mmap(t, sg, n, o, p, f) \ 528e57d534eSdyoung (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f)) 529e57d534eSdyoung 530e57d534eSdyoung #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP 531e57d534eSdyoung #define bus_dmatag_destroy(t) 532e57d534eSdyoung 533e57d534eSdyoung #ifdef _POWERPC_BUS_DMA_PRIVATE 534e57d534eSdyoung int _bus_dmamap_create (bus_dma_tag_t, bus_size_t, int, bus_size_t, 535e57d534eSdyoung bus_size_t, int, bus_dmamap_t *); 536e57d534eSdyoung void _bus_dmamap_destroy (bus_dma_tag_t, bus_dmamap_t); 537e57d534eSdyoung int _bus_dmamap_load (bus_dma_tag_t, bus_dmamap_t, void *, 538e57d534eSdyoung bus_size_t, struct proc *, int); 539e57d534eSdyoung int _bus_dmamap_load_mbuf (bus_dma_tag_t, bus_dmamap_t, 540e57d534eSdyoung struct mbuf *, int); 541e57d534eSdyoung int _bus_dmamap_load_uio (bus_dma_tag_t, bus_dmamap_t, 542e57d534eSdyoung struct uio *, int); 543e57d534eSdyoung int _bus_dmamap_load_raw (bus_dma_tag_t, bus_dmamap_t, 544e57d534eSdyoung bus_dma_segment_t *, int, bus_size_t, int); 545e57d534eSdyoung void _bus_dmamap_unload (bus_dma_tag_t, bus_dmamap_t); 546e57d534eSdyoung void _bus_dmamap_sync (bus_dma_tag_t, bus_dmamap_t, bus_addr_t, 547e57d534eSdyoung bus_size_t, int); 548e57d534eSdyoung 549e57d534eSdyoung int _bus_dmamem_alloc (bus_dma_tag_t tag, bus_size_t size, 550e57d534eSdyoung bus_size_t alignment, bus_size_t boundary, 551e57d534eSdyoung bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags); 552e57d534eSdyoung void _bus_dmamem_free (bus_dma_tag_t tag, bus_dma_segment_t *segs, 553e57d534eSdyoung int nsegs); 554e57d534eSdyoung int _bus_dmamem_map (bus_dma_tag_t tag, bus_dma_segment_t *segs, 555e57d534eSdyoung int nsegs, size_t size, void **kvap, int flags); 556e57d534eSdyoung void _bus_dmamem_unmap (bus_dma_tag_t tag, void *kva, 557e57d534eSdyoung size_t size); 558e57d534eSdyoung paddr_t _bus_dmamem_mmap (bus_dma_tag_t tag, bus_dma_segment_t *segs, 559e57d534eSdyoung int nsegs, off_t off, int prot, int flags); 560e57d534eSdyoung 561e57d534eSdyoung int _bus_dmamem_alloc_range (bus_dma_tag_t tag, bus_size_t size, 562e57d534eSdyoung bus_size_t alignment, bus_size_t boundary, 563e57d534eSdyoung bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags, 564e57d534eSdyoung paddr_t low, paddr_t high); 565e57d534eSdyoung bus_addr_t _bus_dma_phys_to_bus_mem_generic(bus_dma_tag_t, bus_addr_t); 566e57d534eSdyoung bus_addr_t _bus_dma_bus_mem_to_phys_generic(bus_dma_tag_t, bus_addr_t); 567e57d534eSdyoung #endif /* _POWERPC_BUS_DMA_PRIVATE */ 568e57d534eSdyoung #endif /* _POWERPC_BUS_FUNCS_H_ */ 569