Home | History | Annotate | Line # | Download | only in include
bus_funcs.h revision 1.1.2.3
      1  1.1.2.3    yamt /*	$NetBSD: bus_funcs.h,v 1.1.2.3 2014/05/22 11:39:32 yamt Exp $	*/
      2      1.1  dyoung 
      3      1.1  dyoung /*-
      4      1.1  dyoung  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
      5      1.1  dyoung  * All rights reserved.
      6      1.1  dyoung  *
      7      1.1  dyoung  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1  dyoung  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9      1.1  dyoung  * NASA Ames Research Center.
     10      1.1  dyoung  *
     11      1.1  dyoung  * Redistribution and use in source and binary forms, with or without
     12      1.1  dyoung  * modification, are permitted provided that the following conditions
     13      1.1  dyoung  * are met:
     14      1.1  dyoung  * 1. Redistributions of source code must retain the above copyright
     15      1.1  dyoung  *    notice, this list of conditions and the following disclaimer.
     16      1.1  dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     17      1.1  dyoung  *    notice, this list of conditions and the following disclaimer in the
     18      1.1  dyoung  *    documentation and/or other materials provided with the distribution.
     19      1.1  dyoung  *
     20      1.1  dyoung  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21      1.1  dyoung  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22      1.1  dyoung  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23      1.1  dyoung  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24      1.1  dyoung  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25      1.1  dyoung  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26      1.1  dyoung  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27      1.1  dyoung  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28      1.1  dyoung  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29      1.1  dyoung  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30      1.1  dyoung  * POSSIBILITY OF SUCH DAMAGE.
     31      1.1  dyoung  */
     32      1.1  dyoung 
     33      1.1  dyoung /*
     34      1.1  dyoung  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
     35      1.1  dyoung  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     36      1.1  dyoung  *
     37      1.1  dyoung  * Redistribution and use in source and binary forms, with or without
     38      1.1  dyoung  * modification, are permitted provided that the following conditions
     39      1.1  dyoung  * are met:
     40      1.1  dyoung  * 1. Redistributions of source code must retain the above copyright
     41      1.1  dyoung  *    notice, this list of conditions and the following disclaimer.
     42      1.1  dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     43      1.1  dyoung  *    notice, this list of conditions and the following disclaimer in the
     44      1.1  dyoung  *    documentation and/or other materials provided with the distribution.
     45      1.1  dyoung  * 3. All advertising materials mentioning features or use of this software
     46      1.1  dyoung  *    must display the following acknowledgement:
     47      1.1  dyoung  *      This product includes software developed by Christopher G. Demetriou
     48      1.1  dyoung  *	for the NetBSD Project.
     49      1.1  dyoung  * 4. The name of the author may not be used to endorse or promote products
     50      1.1  dyoung  *    derived from this software without specific prior written permission
     51      1.1  dyoung  *
     52      1.1  dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     53      1.1  dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     54      1.1  dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     55      1.1  dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     56      1.1  dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     57      1.1  dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     58      1.1  dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     59      1.1  dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     60      1.1  dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     61      1.1  dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     62      1.1  dyoung  */
     63      1.1  dyoung 
     64  1.1.2.3    yamt #ifndef _ARM_BUS_FUNCS_H_
     65  1.1.2.3    yamt #define _ARM_BUS_FUNCS_H_
     66      1.1  dyoung 
     67  1.1.2.2    yamt #ifdef _KERNEL_OPT
     68  1.1.2.2    yamt #include "opt_cputypes.h"
     69  1.1.2.2    yamt #endif
     70  1.1.2.2    yamt 
     71      1.1  dyoung /*
     72      1.1  dyoung  * Utility macros; INTERNAL USE ONLY.
     73      1.1  dyoung  */
     74      1.1  dyoung #define	__bs_c(a,b)		__CONCAT(a,b)
     75      1.1  dyoung #define	__bs_opname(op,size)	__bs_c(__bs_c(__bs_c(bs_,op),_),size)
     76      1.1  dyoung 
     77      1.1  dyoung #define	__bs_rs(sz, t, h, o)						\
     78      1.1  dyoung 	(*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o)
     79      1.1  dyoung #define	__bs_ws(sz, t, h, o, v)						\
     80      1.1  dyoung 	(*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v)
     81      1.1  dyoung #define	__bs_nonsingle(type, sz, t, h, o, a, c)				\
     82      1.1  dyoung 	(*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c)
     83      1.1  dyoung #define	__bs_set(type, sz, t, h, o, v, c)				\
     84      1.1  dyoung 	(*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, v, c)
     85      1.1  dyoung #define	__bs_copy(sz, t, h1, o1, h2, o2, cnt)				\
     86      1.1  dyoung 	(*(t)->__bs_opname(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt)
     87      1.1  dyoung 
     88      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
     89      1.1  dyoung #define	__bs_opname_s(op,size)	__bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s)
     90      1.1  dyoung #define	__bs_rs_s(sz, t, h, o)						\
     91      1.1  dyoung 	(*(t)->__bs_opname_s(r,sz))((t)->bs_cookie, h, o)
     92      1.1  dyoung #define	__bs_ws_s(sz, t, h, o, v)					\
     93      1.1  dyoung 	(*(t)->__bs_opname_s(w,sz))((t)->bs_cookie, h, o, v)
     94      1.1  dyoung #define	__bs_nonsingle_s(type, sz, t, h, o, a, c)			\
     95      1.1  dyoung 	(*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c)
     96      1.1  dyoung #define	__bs_set_s(type, sz, t, h, o, v, c)				\
     97      1.1  dyoung 	(*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, v, c)
     98      1.1  dyoung #define	__bs_copy_s(sz, t, h1, o1, h2, o2, cnt)				\
     99      1.1  dyoung 	(*(t)->__bs_opname_s(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt)
    100      1.1  dyoung #endif
    101      1.1  dyoung 
    102      1.1  dyoung /*
    103      1.1  dyoung  * Mapping and unmapping operations.
    104      1.1  dyoung  */
    105      1.1  dyoung #define	bus_space_map(t, a, s, c, hp)					\
    106      1.1  dyoung 	(*(t)->bs_map)((t)->bs_cookie, (a), (s), (c), (hp))
    107      1.1  dyoung #define	bus_space_unmap(t, h, s)					\
    108      1.1  dyoung 	(*(t)->bs_unmap)((t)->bs_cookie, (h), (s))
    109      1.1  dyoung #define	bus_space_subregion(t, h, o, s, hp)				\
    110      1.1  dyoung 	(*(t)->bs_subregion)((t)->bs_cookie, (h), (o), (s), (hp))
    111      1.1  dyoung 
    112      1.1  dyoung 
    113      1.1  dyoung /*
    114      1.1  dyoung  * Allocation and deallocation operations.
    115      1.1  dyoung  */
    116      1.1  dyoung #define	bus_space_alloc(t, rs, re, s, a, b, c, ap, hp)			\
    117      1.1  dyoung 	(*(t)->bs_alloc)((t)->bs_cookie, (rs), (re), (s), (a), (b),	\
    118      1.1  dyoung 	    (c), (ap), (hp))
    119      1.1  dyoung #define	bus_space_free(t, h, s)						\
    120      1.1  dyoung 	(*(t)->bs_free)((t)->bs_cookie, (h), (s))
    121      1.1  dyoung 
    122      1.1  dyoung /*
    123      1.1  dyoung  * Get kernel virtual address for ranges mapped BUS_SPACE_MAP_LINEAR.
    124      1.1  dyoung  */
    125      1.1  dyoung #define	bus_space_vaddr(t, h)						\
    126      1.1  dyoung 	(*(t)->bs_vaddr)((t)->bs_cookie, (h))
    127      1.1  dyoung 
    128      1.1  dyoung /*
    129      1.1  dyoung  * MMap bus space for a user application.
    130      1.1  dyoung  */
    131      1.1  dyoung #define bus_space_mmap(t, a, o, p, f)					\
    132      1.1  dyoung 	(*(t)->bs_mmap)((t)->bs_cookie, (a), (o), (p), (f))
    133      1.1  dyoung 
    134      1.1  dyoung /*
    135      1.1  dyoung  * Bus barrier operations.
    136      1.1  dyoung  */
    137      1.1  dyoung #define	bus_space_barrier(t, h, o, l, f)				\
    138      1.1  dyoung 	(*(t)->bs_barrier)((t)->bs_cookie, (h), (o), (l), (f))
    139      1.1  dyoung 
    140      1.1  dyoung /*
    141      1.1  dyoung  * Bus read (single) operations.
    142      1.1  dyoung  */
    143      1.1  dyoung #define	bus_space_read_1(t, h, o)	__bs_rs(1,(t),(h),(o))
    144      1.1  dyoung #define	bus_space_read_2(t, h, o)	__bs_rs(2,(t),(h),(o))
    145      1.1  dyoung #define	bus_space_read_4(t, h, o)	__bs_rs(4,(t),(h),(o))
    146      1.1  dyoung #define	bus_space_read_8(t, h, o)	__bs_rs(8,(t),(h),(o))
    147      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
    148      1.1  dyoung #define	bus_space_read_stream_1(t, h, o)	__bs_rs_s(1,(t),(h),(o))
    149      1.1  dyoung #define	bus_space_read_stream_2(t, h, o)	__bs_rs_s(2,(t),(h),(o))
    150      1.1  dyoung #define	bus_space_read_stream_4(t, h, o)	__bs_rs_s(4,(t),(h),(o))
    151      1.1  dyoung #define	bus_space_read_stream_8(t, h, o)	__bs_rs_s(8,(t),(h),(o))
    152      1.1  dyoung #endif
    153      1.1  dyoung 
    154      1.1  dyoung 
    155      1.1  dyoung /*
    156      1.1  dyoung  * Bus read multiple operations.
    157      1.1  dyoung  */
    158      1.1  dyoung #define	bus_space_read_multi_1(t, h, o, a, c)				\
    159      1.1  dyoung 	__bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
    160      1.1  dyoung #define	bus_space_read_multi_2(t, h, o, a, c)				\
    161      1.1  dyoung 	__bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
    162      1.1  dyoung #define	bus_space_read_multi_4(t, h, o, a, c)				\
    163      1.1  dyoung 	__bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
    164      1.1  dyoung #define	bus_space_read_multi_8(t, h, o, a, c)				\
    165      1.1  dyoung 	__bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
    166      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
    167      1.1  dyoung #define	bus_space_read_multi_stream_1(t, h, o, a, c)			\
    168      1.1  dyoung 	__bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c))
    169      1.1  dyoung #define	bus_space_read_multi_stream_2(t, h, o, a, c)			\
    170      1.1  dyoung 	__bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c))
    171      1.1  dyoung #define	bus_space_read_multi_stream_4(t, h, o, a, c)			\
    172      1.1  dyoung 	__bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c))
    173      1.1  dyoung #define	bus_space_read_multi_stream_8(t, h, o, a, c)			\
    174      1.1  dyoung 	__bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c))
    175      1.1  dyoung #endif
    176      1.1  dyoung 
    177      1.1  dyoung 
    178      1.1  dyoung /*
    179      1.1  dyoung  * Bus read region operations.
    180      1.1  dyoung  */
    181      1.1  dyoung #define	bus_space_read_region_1(t, h, o, a, c)				\
    182      1.1  dyoung 	__bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
    183      1.1  dyoung #define	bus_space_read_region_2(t, h, o, a, c)				\
    184      1.1  dyoung 	__bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
    185      1.1  dyoung #define	bus_space_read_region_4(t, h, o, a, c)				\
    186      1.1  dyoung 	__bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
    187      1.1  dyoung #define	bus_space_read_region_8(t, h, o, a, c)				\
    188      1.1  dyoung 	__bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
    189      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
    190      1.1  dyoung #define	bus_space_read_region_stream_1(t, h, o, a, c)			\
    191      1.1  dyoung 	__bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c))
    192      1.1  dyoung #define	bus_space_read_region_stream_2(t, h, o, a, c)			\
    193      1.1  dyoung 	__bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c))
    194      1.1  dyoung #define	bus_space_read_region_stream_4(t, h, o, a, c)			\
    195      1.1  dyoung 	__bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c))
    196      1.1  dyoung #define	bus_space_read_region_stream_8(t, h, o, a, c)			\
    197      1.1  dyoung 	__bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c))
    198      1.1  dyoung #endif
    199      1.1  dyoung 
    200      1.1  dyoung 
    201      1.1  dyoung /*
    202      1.1  dyoung  * Bus write (single) operations.
    203      1.1  dyoung  */
    204      1.1  dyoung #define	bus_space_write_1(t, h, o, v)	__bs_ws(1,(t),(h),(o),(v))
    205      1.1  dyoung #define	bus_space_write_2(t, h, o, v)	__bs_ws(2,(t),(h),(o),(v))
    206      1.1  dyoung #define	bus_space_write_4(t, h, o, v)	__bs_ws(4,(t),(h),(o),(v))
    207      1.1  dyoung #define	bus_space_write_8(t, h, o, v)	__bs_ws(8,(t),(h),(o),(v))
    208      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
    209      1.1  dyoung #define	bus_space_write_stream_1(t, h, o, v)	__bs_ws_s(1,(t),(h),(o),(v))
    210      1.1  dyoung #define	bus_space_write_stream_2(t, h, o, v)	__bs_ws_s(2,(t),(h),(o),(v))
    211      1.1  dyoung #define	bus_space_write_stream_4(t, h, o, v)	__bs_ws_s(4,(t),(h),(o),(v))
    212      1.1  dyoung #define	bus_space_write_stream_8(t, h, o, v)	__bs_ws_s(8,(t),(h),(o),(v))
    213      1.1  dyoung #endif
    214      1.1  dyoung 
    215      1.1  dyoung 
    216      1.1  dyoung /*
    217      1.1  dyoung  * Bus write multiple operations.
    218      1.1  dyoung  */
    219      1.1  dyoung #define	bus_space_write_multi_1(t, h, o, a, c)				\
    220      1.1  dyoung 	__bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
    221      1.1  dyoung #define	bus_space_write_multi_2(t, h, o, a, c)				\
    222      1.1  dyoung 	__bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
    223      1.1  dyoung #define	bus_space_write_multi_4(t, h, o, a, c)				\
    224      1.1  dyoung 	__bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
    225      1.1  dyoung #define	bus_space_write_multi_8(t, h, o, a, c)				\
    226      1.1  dyoung 	__bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
    227      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
    228      1.1  dyoung #define	bus_space_write_multi_stream_1(t, h, o, a, c)			\
    229      1.1  dyoung 	__bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c))
    230      1.1  dyoung #define	bus_space_write_multi_stream_2(t, h, o, a, c)			\
    231      1.1  dyoung 	__bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c))
    232      1.1  dyoung #define	bus_space_write_multi_stream_4(t, h, o, a, c)			\
    233      1.1  dyoung 	__bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c))
    234      1.1  dyoung #define	bus_space_write_multi_stream_8(t, h, o, a, c)			\
    235      1.1  dyoung 	__bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c))
    236      1.1  dyoung #endif
    237      1.1  dyoung 
    238      1.1  dyoung 
    239      1.1  dyoung /*
    240      1.1  dyoung  * Bus write region operations.
    241      1.1  dyoung  */
    242      1.1  dyoung #define	bus_space_write_region_1(t, h, o, a, c)				\
    243      1.1  dyoung 	__bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
    244      1.1  dyoung #define	bus_space_write_region_2(t, h, o, a, c)				\
    245      1.1  dyoung 	__bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
    246      1.1  dyoung #define	bus_space_write_region_4(t, h, o, a, c)				\
    247      1.1  dyoung 	__bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
    248      1.1  dyoung #define	bus_space_write_region_8(t, h, o, a, c)				\
    249      1.1  dyoung 	__bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
    250      1.1  dyoung #ifdef __BUS_SPACE_HAS_STREAM_METHODS
    251      1.1  dyoung #define	bus_space_write_region_stream_1(t, h, o, a, c)			\
    252      1.1  dyoung 	__bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c))
    253      1.1  dyoung #define	bus_space_write_region_stream_2(t, h, o, a, c)			\
    254      1.1  dyoung 	__bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c))
    255      1.1  dyoung #define	bus_space_write_region_stream_4(t, h, o, a, c)			\
    256      1.1  dyoung 	__bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c))
    257      1.1  dyoung #define	bus_space_write_region_stream_8(t, h, o, a, c)			\
    258      1.1  dyoung 	__bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c))
    259      1.1  dyoung #endif
    260      1.1  dyoung 
    261      1.1  dyoung 
    262      1.1  dyoung /*
    263      1.1  dyoung  * Set multiple operations.
    264      1.1  dyoung  */
    265      1.1  dyoung #define	bus_space_set_multi_1(t, h, o, v, c)				\
    266      1.1  dyoung 	__bs_set(sm,1,(t),(h),(o),(v),(c))
    267      1.1  dyoung #define	bus_space_set_multi_2(t, h, o, v, c)				\
    268      1.1  dyoung 	__bs_set(sm,2,(t),(h),(o),(v),(c))
    269      1.1  dyoung #define	bus_space_set_multi_4(t, h, o, v, c)				\
    270      1.1  dyoung 	__bs_set(sm,4,(t),(h),(o),(v),(c))
    271      1.1  dyoung #define	bus_space_set_multi_8(t, h, o, v, c)				\
    272      1.1  dyoung 	__bs_set(sm,8,(t),(h),(o),(v),(c))
    273      1.1  dyoung 
    274      1.1  dyoung /*
    275      1.1  dyoung  * Set region operations.
    276      1.1  dyoung  */
    277      1.1  dyoung #define	bus_space_set_region_1(t, h, o, v, c)				\
    278      1.1  dyoung 	__bs_set(sr,1,(t),(h),(o),(v),(c))
    279      1.1  dyoung #define	bus_space_set_region_2(t, h, o, v, c)				\
    280      1.1  dyoung 	__bs_set(sr,2,(t),(h),(o),(v),(c))
    281      1.1  dyoung #define	bus_space_set_region_4(t, h, o, v, c)				\
    282      1.1  dyoung 	__bs_set(sr,4,(t),(h),(o),(v),(c))
    283      1.1  dyoung #define	bus_space_set_region_8(t, h, o, v, c)				\
    284      1.1  dyoung 	__bs_set(sr,8,(t),(h),(o),(v),(c))
    285      1.1  dyoung 
    286      1.1  dyoung /*
    287      1.1  dyoung  * Copy operations.
    288      1.1  dyoung  */
    289      1.1  dyoung #define	bus_space_copy_region_1(t, h1, o1, h2, o2, c)				\
    290      1.1  dyoung 	__bs_copy(1, t, h1, o1, h2, o2, c)
    291      1.1  dyoung #define	bus_space_copy_region_2(t, h1, o1, h2, o2, c)				\
    292      1.1  dyoung 	__bs_copy(2, t, h1, o1, h2, o2, c)
    293      1.1  dyoung #define	bus_space_copy_region_4(t, h1, o1, h2, o2, c)				\
    294      1.1  dyoung 	__bs_copy(4, t, h1, o1, h2, o2, c)
    295      1.1  dyoung #define	bus_space_copy_region_8(t, h1, o1, h2, o2, c)				\
    296      1.1  dyoung 	__bs_copy(8, t, h1, o1, h2, o2, c)
    297      1.1  dyoung 
    298      1.1  dyoung /*
    299      1.1  dyoung  * Macros to provide prototypes for all the functions used in the
    300      1.1  dyoung  * bus_space structure
    301      1.1  dyoung  */
    302      1.1  dyoung 
    303      1.1  dyoung #define bs_map_proto(f)							\
    304      1.1  dyoung int	__bs_c(f,_bs_map)(void *t, bus_addr_t addr,		\
    305      1.1  dyoung 	    bus_size_t size, int cacheable, bus_space_handle_t *bshp);
    306      1.1  dyoung 
    307      1.1  dyoung #define bs_unmap_proto(f)						\
    308      1.1  dyoung void	__bs_c(f,_bs_unmap)(void *t, bus_space_handle_t bsh,	\
    309      1.1  dyoung 	    bus_size_t size);
    310      1.1  dyoung 
    311      1.1  dyoung #define bs_subregion_proto(f)						\
    312      1.1  dyoung int	__bs_c(f,_bs_subregion)(void *t, bus_space_handle_t bsh,	\
    313      1.1  dyoung 	    bus_size_t offset, bus_size_t size, 			\
    314      1.1  dyoung 	    bus_space_handle_t *nbshp);
    315      1.1  dyoung 
    316      1.1  dyoung #define bs_alloc_proto(f)						\
    317      1.1  dyoung int	__bs_c(f,_bs_alloc)(void *t, bus_addr_t rstart,		\
    318      1.1  dyoung 	    bus_addr_t rend, bus_size_t size, bus_size_t align,		\
    319      1.1  dyoung 	    bus_size_t boundary, int cacheable, bus_addr_t *addrp,	\
    320      1.1  dyoung 	    bus_space_handle_t *bshp);
    321      1.1  dyoung 
    322      1.1  dyoung #define bs_free_proto(f)						\
    323      1.1  dyoung void	__bs_c(f,_bs_free)(void *t, bus_space_handle_t bsh,	\
    324      1.1  dyoung 	    bus_size_t size);
    325      1.1  dyoung 
    326      1.1  dyoung #define bs_vaddr_proto(f)						\
    327      1.1  dyoung void *	__bs_c(f,_bs_vaddr)(void *t, bus_space_handle_t bsh);
    328      1.1  dyoung 
    329      1.1  dyoung #define bs_mmap_proto(f)						\
    330      1.1  dyoung paddr_t	__bs_c(f,_bs_mmap)(void *, bus_addr_t, off_t, int, int);
    331      1.1  dyoung 
    332      1.1  dyoung #define bs_barrier_proto(f)						\
    333      1.1  dyoung void	__bs_c(f,_bs_barrier)(void *t, bus_space_handle_t bsh,	\
    334      1.1  dyoung 	    bus_size_t offset, bus_size_t len, int flags);
    335      1.1  dyoung 
    336      1.1  dyoung #define	bs_r_1_proto(f)							\
    337  1.1.2.1    yamt uint8_t	__bs_c(f,_bs_r_1)(void *t, bus_space_handle_t bsh,	\
    338      1.1  dyoung 		    bus_size_t offset);
    339      1.1  dyoung 
    340      1.1  dyoung #define	bs_r_2_proto(f)							\
    341  1.1.2.1    yamt uint16_t	__bs_c(f,_bs_r_2)(void *t, bus_space_handle_t bsh,	\
    342  1.1.2.1    yamt 		    bus_size_t offset);					\
    343  1.1.2.1    yamt uint16_t	__bs_c(f,_bs_r_2_swap)(void *t, bus_space_handle_t bsh,	\
    344      1.1  dyoung 		    bus_size_t offset);
    345      1.1  dyoung 
    346      1.1  dyoung #define	bs_r_4_proto(f)							\
    347  1.1.2.1    yamt uint32_t	__bs_c(f,_bs_r_4)(void *t, bus_space_handle_t bsh,	\
    348  1.1.2.1    yamt 		    bus_size_t offset);					\
    349  1.1.2.1    yamt uint32_t	__bs_c(f,_bs_r_4_swap)(void *t, bus_space_handle_t bsh,	\
    350      1.1  dyoung 		    bus_size_t offset);
    351      1.1  dyoung 
    352      1.1  dyoung #define	bs_r_8_proto(f)							\
    353  1.1.2.1    yamt uint64_t	__bs_c(f,_bs_r_8)(void *t, bus_space_handle_t bsh,	\
    354  1.1.2.1    yamt 		    bus_size_t offset);					\
    355  1.1.2.1    yamt uint64_t	__bs_c(f,_bs_r_8_swap)(void *t, bus_space_handle_t bsh,	\
    356      1.1  dyoung 		    bus_size_t offset);
    357      1.1  dyoung 
    358      1.1  dyoung #define	bs_w_1_proto(f)							\
    359      1.1  dyoung void	__bs_c(f,_bs_w_1)(void *t, bus_space_handle_t bsh,		\
    360  1.1.2.1    yamt 	    bus_size_t offset, uint8_t value);
    361      1.1  dyoung 
    362      1.1  dyoung #define	bs_w_2_proto(f)							\
    363      1.1  dyoung void	__bs_c(f,_bs_w_2)(void *t, bus_space_handle_t bsh,		\
    364  1.1.2.1    yamt 	    bus_size_t offset, uint16_t value);				\
    365  1.1.2.1    yamt void	__bs_c(f,_bs_w_2_swap)(void *t, bus_space_handle_t bsh,		\
    366  1.1.2.1    yamt 	    bus_size_t offset, uint16_t value);
    367      1.1  dyoung 
    368      1.1  dyoung #define	bs_w_4_proto(f)							\
    369      1.1  dyoung void	__bs_c(f,_bs_w_4)(void *t, bus_space_handle_t bsh,		\
    370  1.1.2.1    yamt 	    bus_size_t offset, uint32_t value);				\
    371  1.1.2.1    yamt void	__bs_c(f,_bs_w_4_swap)(void *t, bus_space_handle_t bsh,		\
    372  1.1.2.1    yamt 	    bus_size_t offset, uint32_t value);
    373      1.1  dyoung 
    374      1.1  dyoung #define	bs_w_8_proto(f)							\
    375      1.1  dyoung void	__bs_c(f,_bs_w_8)(void *t, bus_space_handle_t bsh,		\
    376  1.1.2.1    yamt 	    bus_size_t offset, uint64_t value);				\
    377  1.1.2.1    yamt void	__bs_c(f,_bs_w_8_swap)(void *t, bus_space_handle_t bsh,		\
    378  1.1.2.1    yamt 	    bus_size_t offset, uint64_t value);
    379      1.1  dyoung 
    380      1.1  dyoung #define	bs_rm_1_proto(f)						\
    381  1.1.2.1    yamt void	__bs_c(f,_bs_rm_1)(void *t, bus_space_handle_t bsh,		\
    382  1.1.2.1    yamt 	    bus_size_t offset, uint8_t *addr, bus_size_t count);
    383      1.1  dyoung 
    384      1.1  dyoung #define	bs_rm_2_proto(f)						\
    385  1.1.2.1    yamt void	__bs_c(f,_bs_rm_2)(void *t, bus_space_handle_t bsh,		\
    386  1.1.2.1    yamt 	    bus_size_t offset, uint16_t *addr, bus_size_t count);	\
    387  1.1.2.1    yamt void	__bs_c(f,_bs_rm_2_swap)(void *t, bus_space_handle_t bsh,	\
    388  1.1.2.1    yamt 	    bus_size_t offset, uint16_t *addr, bus_size_t count);
    389      1.1  dyoung 
    390      1.1  dyoung #define	bs_rm_4_proto(f)						\
    391  1.1.2.1    yamt void	__bs_c(f,_bs_rm_4)(void *t, bus_space_handle_t bsh,		\
    392  1.1.2.1    yamt 	    bus_size_t offset, uint32_t *addr, bus_size_t count);	\
    393  1.1.2.1    yamt void	__bs_c(f,_bs_rm_4_swap)(void *t, bus_space_handle_t bsh,	\
    394  1.1.2.1    yamt 	    bus_size_t offset, uint32_t *addr, bus_size_t count);
    395      1.1  dyoung 
    396      1.1  dyoung #define	bs_rm_8_proto(f)						\
    397  1.1.2.1    yamt void	__bs_c(f,_bs_rm_8)(void *t, bus_space_handle_t bsh,		\
    398  1.1.2.1    yamt 	    bus_size_t offset, uint64_t *addr, bus_size_t count);	\
    399  1.1.2.1    yamt void	__bs_c(f,_bs_rm_8_swap)(void *t, bus_space_handle_t bsh,	\
    400  1.1.2.1    yamt 	    bus_size_t offset, uint64_t *addr, bus_size_t count);
    401      1.1  dyoung 
    402      1.1  dyoung #define	bs_wm_1_proto(f)						\
    403  1.1.2.1    yamt void	__bs_c(f,_bs_wm_1)(void *t, bus_space_handle_t bsh,		\
    404  1.1.2.1    yamt 	    bus_size_t offset, const uint8_t *addr, bus_size_t count);	\
    405      1.1  dyoung 
    406      1.1  dyoung #define	bs_wm_2_proto(f)						\
    407  1.1.2.1    yamt void	__bs_c(f,_bs_wm_2)(void *t, bus_space_handle_t bsh,		\
    408  1.1.2.1    yamt 	    bus_size_t offset, const uint16_t *addr, bus_size_t count);	\
    409  1.1.2.1    yamt void	__bs_c(f,_bs_wm_2_swap)(void *t, bus_space_handle_t bsh,	\
    410  1.1.2.1    yamt 	    bus_size_t offset, const uint16_t *addr, bus_size_t count);
    411      1.1  dyoung 
    412      1.1  dyoung #define	bs_wm_4_proto(f)						\
    413  1.1.2.1    yamt void	__bs_c(f,_bs_wm_4)(void *t, bus_space_handle_t bsh,		\
    414  1.1.2.1    yamt 	    bus_size_t offset, const uint32_t *addr, bus_size_t count);	\
    415  1.1.2.1    yamt void	__bs_c(f,_bs_wm_4_swap)(void *t, bus_space_handle_t bsh,	\
    416  1.1.2.1    yamt 	    bus_size_t offset, const uint32_t *addr, bus_size_t count);
    417      1.1  dyoung 
    418      1.1  dyoung #define	bs_wm_8_proto(f)						\
    419  1.1.2.1    yamt void	__bs_c(f,_bs_wm_8)(void *t, bus_space_handle_t bsh,		\
    420  1.1.2.1    yamt 	    bus_size_t offset, const uint64_t *addr, bus_size_t count);	\
    421  1.1.2.1    yamt void	__bs_c(f,_bs_wm_8_swap)(void *t, bus_space_handle_t bsh,	\
    422  1.1.2.1    yamt 	    bus_size_t offset, const uint64_t *addr, bus_size_t count);
    423      1.1  dyoung 
    424      1.1  dyoung #define	bs_rr_1_proto(f)						\
    425  1.1.2.1    yamt void	__bs_c(f, _bs_rr_1)(void *t, bus_space_handle_t bsh,		\
    426  1.1.2.1    yamt 	    bus_size_t offset, uint8_t *addr, bus_size_t count);
    427      1.1  dyoung 
    428      1.1  dyoung #define	bs_rr_2_proto(f)						\
    429  1.1.2.1    yamt void	__bs_c(f, _bs_rr_2)(void *t, bus_space_handle_t bsh,		\
    430  1.1.2.1    yamt 	    bus_size_t offset, uint16_t *addr, bus_size_t count);	\
    431  1.1.2.1    yamt void	__bs_c(f, _bs_rr_2_swap)(void *t, bus_space_handle_t bsh,	\
    432  1.1.2.1    yamt 	    bus_size_t offset, uint16_t *addr, bus_size_t count);
    433      1.1  dyoung 
    434      1.1  dyoung #define	bs_rr_4_proto(f)						\
    435  1.1.2.1    yamt void	__bs_c(f, _bs_rr_4)(void *t, bus_space_handle_t bsh,		\
    436  1.1.2.1    yamt 	    bus_size_t offset, uint32_t *addr, bus_size_t count);	\
    437  1.1.2.1    yamt void	__bs_c(f, _bs_rr_4_swap)(void *t, bus_space_handle_t bsh,	\
    438  1.1.2.1    yamt 	    bus_size_t offset, uint32_t *addr, bus_size_t count);
    439      1.1  dyoung 
    440      1.1  dyoung #define	bs_rr_8_proto(f)						\
    441  1.1.2.1    yamt void	__bs_c(f, _bs_rr_8)(void *t, bus_space_handle_t bsh,		\
    442  1.1.2.1    yamt 	    bus_size_t offset, uint64_t *addr, bus_size_t count);	\
    443  1.1.2.1    yamt void	__bs_c(f, _bs_rr_8_swap)(void *t, bus_space_handle_t bsh,	\
    444  1.1.2.1    yamt 	    bus_size_t offset, uint64_t *addr, bus_size_t count);
    445      1.1  dyoung 
    446      1.1  dyoung #define	bs_wr_1_proto(f)						\
    447  1.1.2.1    yamt void	__bs_c(f, _bs_wr_1)(void *t, bus_space_handle_t bsh,		\
    448  1.1.2.1    yamt 	    bus_size_t offset, const uint8_t *addr, bus_size_t count);
    449      1.1  dyoung 
    450      1.1  dyoung #define	bs_wr_2_proto(f)						\
    451  1.1.2.1    yamt void	__bs_c(f, _bs_wr_2)(void *t, bus_space_handle_t bsh,		\
    452  1.1.2.1    yamt 	    bus_size_t offset, const uint16_t *addr, bus_size_t count);	\
    453  1.1.2.1    yamt void	__bs_c(f, _bs_wr_2_swap)(void *t, bus_space_handle_t bsh,	\
    454  1.1.2.1    yamt 	    bus_size_t offset, const uint16_t *addr, bus_size_t count);
    455      1.1  dyoung 
    456      1.1  dyoung #define	bs_wr_4_proto(f)						\
    457  1.1.2.1    yamt void	__bs_c(f, _bs_wr_4)(void *t, bus_space_handle_t bsh,		\
    458  1.1.2.1    yamt 	    bus_size_t offset, const uint32_t *addr, bus_size_t count);	\
    459  1.1.2.1    yamt void	__bs_c(f, _bs_wr_4_swap)(void *t, bus_space_handle_t bsh,	\
    460  1.1.2.1    yamt 	    bus_size_t offset, const uint32_t *addr, bus_size_t count);
    461      1.1  dyoung 
    462      1.1  dyoung #define	bs_wr_8_proto(f)						\
    463  1.1.2.1    yamt void	__bs_c(f, _bs_wr_8)(void *t, bus_space_handle_t bsh,		\
    464  1.1.2.1    yamt 	    bus_size_t offset, const uint64_t *addr, bus_size_t count);	\
    465  1.1.2.1    yamt void	__bs_c(f, _bs_wr_8_swap)(void *t, bus_space_handle_t bsh,	\
    466  1.1.2.1    yamt 	    bus_size_t offset, const uint64_t *addr, bus_size_t count);
    467      1.1  dyoung 
    468      1.1  dyoung #define	bs_sm_1_proto(f)						\
    469  1.1.2.1    yamt void	__bs_c(f,_bs_sm_1)(void *t, bus_space_handle_t bsh,		\
    470  1.1.2.1    yamt 	    bus_size_t offset, uint8_t value, bus_size_t count);
    471      1.1  dyoung 
    472      1.1  dyoung #define	bs_sm_2_proto(f)						\
    473  1.1.2.1    yamt void	__bs_c(f,_bs_sm_2)(void *t, bus_space_handle_t bsh,		\
    474  1.1.2.1    yamt 	    bus_size_t offset, uint16_t value, bus_size_t count);
    475      1.1  dyoung 
    476      1.1  dyoung #define	bs_sm_4_proto(f)						\
    477  1.1.2.1    yamt void	__bs_c(f,_bs_sm_4)(void *t, bus_space_handle_t bsh,		\
    478  1.1.2.1    yamt 	    bus_size_t offset, uint32_t value, bus_size_t count);
    479      1.1  dyoung 
    480      1.1  dyoung #define	bs_sm_8_proto(f)						\
    481  1.1.2.1    yamt void	__bs_c(f,_bs_sm_8)(void *t, bus_space_handle_t bsh,		\
    482  1.1.2.1    yamt 	    bus_size_t offset, uint64_t value, bus_size_t count);
    483      1.1  dyoung 
    484      1.1  dyoung #define	bs_sr_1_proto(f)						\
    485  1.1.2.1    yamt void	__bs_c(f,_bs_sr_1)(void *t, bus_space_handle_t bsh,		\
    486  1.1.2.1    yamt 	    bus_size_t offset, uint8_t value, bus_size_t count);
    487      1.1  dyoung 
    488      1.1  dyoung #define	bs_sr_2_proto(f)						\
    489  1.1.2.1    yamt void	__bs_c(f,_bs_sr_2)(void *t, bus_space_handle_t bsh,		\
    490  1.1.2.1    yamt 	    bus_size_t offset, uint16_t value, bus_size_t count);	\
    491  1.1.2.1    yamt void	__bs_c(f,_bs_sr_2_swap)(void *t, bus_space_handle_t bsh,	\
    492  1.1.2.1    yamt 	    bus_size_t offset, uint16_t value, bus_size_t count);
    493      1.1  dyoung 
    494      1.1  dyoung #define	bs_sr_4_proto(f)						\
    495  1.1.2.1    yamt void	__bs_c(f,_bs_sr_4)(void *t, bus_space_handle_t bsh,		\
    496  1.1.2.1    yamt 	    bus_size_t offset, uint32_t value, bus_size_t count);	\
    497  1.1.2.1    yamt void	__bs_c(f,_bs_sr_4_swap)(void *t, bus_space_handle_t bsh,	\
    498  1.1.2.1    yamt 	    bus_size_t offset, uint32_t value, bus_size_t count);
    499      1.1  dyoung 
    500      1.1  dyoung #define	bs_sr_8_proto(f)						\
    501  1.1.2.1    yamt void	__bs_c(f,_bs_sr_8)(void *t, bus_space_handle_t bsh,		\
    502  1.1.2.1    yamt 	    bus_size_t offset, uint64_t value, bus_size_t count);	\
    503  1.1.2.1    yamt void	__bs_c(f,_bs_sr_8_swap)(void *t, bus_space_handle_t bsh,	\
    504  1.1.2.1    yamt 	    bus_size_t offset, uint64_t value, bus_size_t count);
    505      1.1  dyoung 
    506      1.1  dyoung #define	bs_c_1_proto(f)							\
    507  1.1.2.1    yamt void	__bs_c(f,_bs_c_1)(void *t, bus_space_handle_t bsh1,		\
    508      1.1  dyoung 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
    509      1.1  dyoung 	    bus_size_t offset2, bus_size_t count);
    510      1.1  dyoung 
    511      1.1  dyoung #define	bs_c_2_proto(f)							\
    512  1.1.2.1    yamt void	__bs_c(f,_bs_c_2)(void *t, bus_space_handle_t bsh1,		\
    513      1.1  dyoung 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
    514      1.1  dyoung 	    bus_size_t offset2, bus_size_t count);
    515      1.1  dyoung 
    516      1.1  dyoung #define	bs_c_4_proto(f)							\
    517  1.1.2.1    yamt void	__bs_c(f,_bs_c_4)(void *t, bus_space_handle_t bsh1,		\
    518      1.1  dyoung 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
    519      1.1  dyoung 	    bus_size_t offset2, bus_size_t count);
    520      1.1  dyoung 
    521      1.1  dyoung #define	bs_c_8_proto(f)							\
    522  1.1.2.1    yamt void	__bs_c(f,_bs_c_8)(void *t, bus_space_handle_t bsh1,		\
    523      1.1  dyoung 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
    524      1.1  dyoung 	    bus_size_t offset2, bus_size_t count);
    525      1.1  dyoung 
    526      1.1  dyoung #define bs_protos(f)		\
    527      1.1  dyoung bs_map_proto(f);		\
    528      1.1  dyoung bs_unmap_proto(f);		\
    529      1.1  dyoung bs_subregion_proto(f);		\
    530      1.1  dyoung bs_alloc_proto(f);		\
    531      1.1  dyoung bs_free_proto(f);		\
    532      1.1  dyoung bs_vaddr_proto(f);		\
    533      1.1  dyoung bs_mmap_proto(f);		\
    534      1.1  dyoung bs_barrier_proto(f);		\
    535      1.1  dyoung bs_r_1_proto(f);		\
    536      1.1  dyoung bs_r_2_proto(f);		\
    537      1.1  dyoung bs_r_4_proto(f);		\
    538      1.1  dyoung bs_r_8_proto(f);		\
    539      1.1  dyoung bs_w_1_proto(f);		\
    540      1.1  dyoung bs_w_2_proto(f);		\
    541      1.1  dyoung bs_w_4_proto(f);		\
    542      1.1  dyoung bs_w_8_proto(f);		\
    543      1.1  dyoung bs_rm_1_proto(f);		\
    544      1.1  dyoung bs_rm_2_proto(f);		\
    545      1.1  dyoung bs_rm_4_proto(f);		\
    546      1.1  dyoung bs_rm_8_proto(f);		\
    547      1.1  dyoung bs_wm_1_proto(f);		\
    548      1.1  dyoung bs_wm_2_proto(f);		\
    549      1.1  dyoung bs_wm_4_proto(f);		\
    550      1.1  dyoung bs_wm_8_proto(f);		\
    551      1.1  dyoung bs_rr_1_proto(f);		\
    552      1.1  dyoung bs_rr_2_proto(f);		\
    553      1.1  dyoung bs_rr_4_proto(f);		\
    554      1.1  dyoung bs_rr_8_proto(f);		\
    555      1.1  dyoung bs_wr_1_proto(f);		\
    556      1.1  dyoung bs_wr_2_proto(f);		\
    557      1.1  dyoung bs_wr_4_proto(f);		\
    558      1.1  dyoung bs_wr_8_proto(f);		\
    559      1.1  dyoung bs_sm_1_proto(f);		\
    560      1.1  dyoung bs_sm_2_proto(f);		\
    561      1.1  dyoung bs_sm_4_proto(f);		\
    562      1.1  dyoung bs_sm_8_proto(f);		\
    563      1.1  dyoung bs_sr_1_proto(f);		\
    564      1.1  dyoung bs_sr_2_proto(f);		\
    565      1.1  dyoung bs_sr_4_proto(f);		\
    566      1.1  dyoung bs_sr_8_proto(f);		\
    567      1.1  dyoung bs_c_1_proto(f);		\
    568      1.1  dyoung bs_c_2_proto(f);		\
    569      1.1  dyoung bs_c_4_proto(f);		\
    570      1.1  dyoung bs_c_8_proto(f);
    571      1.1  dyoung 
    572      1.1  dyoung /* Bus Space DMA macros */
    573      1.1  dyoung 
    574      1.1  dyoung /* Forwards needed by prototypes below. */
    575      1.1  dyoung struct mbuf;
    576      1.1  dyoung struct uio;
    577      1.1  dyoung 
    578      1.1  dyoung #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
    579      1.1  dyoung 	(*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
    580      1.1  dyoung #define	bus_dmamap_destroy(t, p)				\
    581      1.1  dyoung 	(*(t)->_dmamap_destroy)((t), (p))
    582      1.1  dyoung #define	bus_dmamap_load(t, m, b, s, p, f)			\
    583      1.1  dyoung 	(*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
    584      1.1  dyoung #define	bus_dmamap_load_mbuf(t, m, b, f)			\
    585      1.1  dyoung 	(*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
    586      1.1  dyoung #define	bus_dmamap_load_uio(t, m, u, f)				\
    587      1.1  dyoung 	(*(t)->_dmamap_load_uio)((t), (m), (u), (f))
    588      1.1  dyoung #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
    589      1.1  dyoung 	(*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
    590      1.1  dyoung #define	bus_dmamap_unload(t, p)					\
    591      1.1  dyoung 	(*(t)->_dmamap_unload)((t), (p))
    592      1.1  dyoung #define	bus_dmamap_sync(t, p, o, l, ops)			\
    593      1.1  dyoung do {									\
    594  1.1.2.1    yamt 	if (((p)->_dm_flags & (_BUS_DMAMAP_COHERENT|_BUS_DMAMAP_IS_BOUNCING)) == _BUS_DMAMAP_COHERENT) \
    595  1.1.2.1    yamt 		break;							\
    596      1.1  dyoung 	if (((ops) & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0	\
    597      1.1  dyoung 	    && (t)->_dmamap_sync_pre != NULL)				\
    598      1.1  dyoung 		(*(t)->_dmamap_sync_pre)((t), (p), (o), (l), (ops));	\
    599      1.1  dyoung 	else if (((ops) & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0 \
    600      1.1  dyoung 		 && (t)->_dmamap_sync_post != NULL)			     \
    601      1.1  dyoung 		(*(t)->_dmamap_sync_post)((t), (p), (o), (l), (ops));	     \
    602      1.1  dyoung } while (/*CONSTCOND*/0)
    603      1.1  dyoung 
    604      1.1  dyoung #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
    605      1.1  dyoung 	(*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
    606      1.1  dyoung #define	bus_dmamem_free(t, sg, n)				\
    607      1.1  dyoung 	(*(t)->_dmamem_free)((t), (sg), (n))
    608      1.1  dyoung #define	bus_dmamem_map(t, sg, n, s, k, f)			\
    609      1.1  dyoung 	(*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
    610      1.1  dyoung #define	bus_dmamem_unmap(t, k, s)				\
    611      1.1  dyoung 	(*(t)->_dmamem_unmap)((t), (k), (s))
    612      1.1  dyoung #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
    613      1.1  dyoung 	(*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
    614      1.1  dyoung 
    615  1.1.2.1    yamt #define	bus_dmatag_subregion(t, mna, mxa, nt, f)		\
    616  1.1.2.1    yamt 	(*(t)->_dmatag_subregion)((t), (mna), (mxa), (nt), (f))
    617  1.1.2.1    yamt #define	bus_dmatag_destroy(t)					\
    618  1.1.2.1    yamt 	(*(t)->_dmatag_destroy)(t)
    619      1.1  dyoung 
    620      1.1  dyoung #ifdef _ARM32_BUS_DMA_PRIVATE
    621      1.1  dyoung 
    622  1.1.2.1    yamt extern paddr_t physical_start, physical_end;
    623  1.1.2.1    yamt 
    624      1.1  dyoung int	arm32_dma_range_intersect(struct arm32_dma_range *, int,
    625      1.1  dyoung 	    paddr_t pa, psize_t size, paddr_t *pap, psize_t *sizep);
    626      1.1  dyoung 
    627      1.1  dyoung int	_bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
    628      1.1  dyoung 	    bus_size_t, int, bus_dmamap_t *);
    629      1.1  dyoung void	_bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
    630      1.1  dyoung int	_bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
    631      1.1  dyoung 	    bus_size_t, struct proc *, int);
    632      1.1  dyoung int	_bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
    633      1.1  dyoung 	    struct mbuf *, int);
    634      1.1  dyoung int	_bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
    635      1.1  dyoung 	    struct uio *, int);
    636      1.1  dyoung int	_bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
    637      1.1  dyoung 	    bus_dma_segment_t *, int, bus_size_t, int);
    638      1.1  dyoung void	_bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
    639      1.1  dyoung void	_bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
    640      1.1  dyoung 	    bus_size_t, int);
    641      1.1  dyoung 
    642  1.1.2.2    yamt #if defined(_ARM32_NEED_BUS_DMA_BOUNCE) || defined(CPU_CORTEX)
    643  1.1.2.1    yamt #define	_BUS_DMAMAP_SYNC_FUNCS \
    644  1.1.2.1    yamt 	._dmamap_sync_pre = _bus_dmamap_sync,	\
    645  1.1.2.1    yamt 	._dmamap_sync_post = _bus_dmamap_sync
    646  1.1.2.1    yamt #else
    647  1.1.2.1    yamt #define	_BUS_DMAMAP_SYNC_FUNCS \
    648  1.1.2.1    yamt 	._dmamap_sync_pre = _bus_dmamap_sync
    649  1.1.2.1    yamt #endif
    650  1.1.2.1    yamt 
    651  1.1.2.1    yamt #define	_BUS_DMAMAP_FUNCS \
    652  1.1.2.1    yamt 	._dmamap_create = _bus_dmamap_create,		\
    653  1.1.2.1    yamt 	._dmamap_destroy = _bus_dmamap_destroy,		\
    654  1.1.2.1    yamt 	._dmamap_load = _bus_dmamap_load,		\
    655  1.1.2.1    yamt 	._dmamap_load_mbuf = _bus_dmamap_load_mbuf,	\
    656  1.1.2.1    yamt 	._dmamap_load_raw = _bus_dmamap_load_raw,	\
    657  1.1.2.1    yamt 	._dmamap_load_uio = _bus_dmamap_load_uio,	\
    658  1.1.2.1    yamt 	._dmamap_unload = _bus_dmamap_unload,		\
    659  1.1.2.1    yamt 	_BUS_DMAMAP_SYNC_FUNCS
    660  1.1.2.1    yamt 
    661      1.1  dyoung int	_bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size,
    662      1.1  dyoung 	    bus_size_t alignment, bus_size_t boundary,
    663      1.1  dyoung 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
    664      1.1  dyoung void	_bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs,
    665      1.1  dyoung 	    int nsegs);
    666      1.1  dyoung int	_bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs,
    667      1.1  dyoung 	    int nsegs, size_t size, void **kvap, int flags);
    668      1.1  dyoung void	_bus_dmamem_unmap(bus_dma_tag_t tag, void *kva,
    669      1.1  dyoung 	    size_t size);
    670      1.1  dyoung paddr_t	_bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs,
    671      1.1  dyoung 	    int nsegs, off_t off, int prot, int flags);
    672      1.1  dyoung 
    673  1.1.2.1    yamt #define	_BUS_DMAMEM_FUNCS \
    674  1.1.2.1    yamt 	._dmamem_alloc = _bus_dmamem_alloc,	\
    675  1.1.2.1    yamt 	._dmamem_free = _bus_dmamem_free,	\
    676  1.1.2.1    yamt 	._dmamem_map = _bus_dmamem_map,		\
    677  1.1.2.1    yamt 	._dmamem_unmap = _bus_dmamem_unmap,	\
    678  1.1.2.1    yamt 	._dmamem_mmap = _bus_dmamem_mmap
    679  1.1.2.1    yamt 
    680      1.1  dyoung int	_bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
    681      1.1  dyoung 	    bus_size_t alignment, bus_size_t boundary,
    682      1.1  dyoung 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
    683      1.1  dyoung 	    vaddr_t low, vaddr_t high);
    684  1.1.2.1    yamt 
    685  1.1.2.1    yamt int	_bus_dmatag_subregion(bus_dma_tag_t, bus_addr_t, bus_addr_t,
    686  1.1.2.1    yamt 	    bus_dma_tag_t *, int);
    687  1.1.2.1    yamt void 	_bus_dmatag_destroy(bus_dma_tag_t);
    688  1.1.2.1    yamt 
    689  1.1.2.1    yamt #define	_BUS_DMATAG_FUNCS \
    690  1.1.2.1    yamt 	._dmatag_subregion = _bus_dmatag_subregion,	\
    691  1.1.2.1    yamt 	._dmatag_destroy = _bus_dmatag_destroy
    692  1.1.2.1    yamt 
    693      1.1  dyoung #endif /* _ARM32_BUS_DMA_PRIVATE */
    694      1.1  dyoung 
    695  1.1.2.3    yamt #endif /* _ARM_BUS_FUNCS_H_ */
    696