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