Home | History | Annotate | Line # | Download | only in include
      1  1.5  riastrad /*	$NetBSD: bus_defs.h,v 1.5 2022/03/10 00:14:16 riastradh Exp $	*/
      2  1.1    dyoung /*	$OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $	*/
      3  1.1    dyoung 
      4  1.1    dyoung /*-
      5  1.1    dyoung  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
      6  1.1    dyoung  * All rights reserved.
      7  1.1    dyoung  *
      8  1.1    dyoung  * This code is derived from software contributed to The NetBSD Foundation
      9  1.1    dyoung  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
     10  1.1    dyoung  * NASA Ames Research Center.
     11  1.1    dyoung  *
     12  1.1    dyoung  * Redistribution and use in source and binary forms, with or without
     13  1.1    dyoung  * modification, are permitted provided that the following conditions
     14  1.1    dyoung  * are met:
     15  1.1    dyoung  * 1. Redistributions of source code must retain the above copyright
     16  1.1    dyoung  *    notice, this list of conditions and the following disclaimer.
     17  1.1    dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.1    dyoung  *    notice, this list of conditions and the following disclaimer in the
     19  1.1    dyoung  *    documentation and/or other materials provided with the distribution.
     20  1.1    dyoung  *
     21  1.1    dyoung  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     22  1.1    dyoung  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23  1.1    dyoung  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24  1.1    dyoung  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     25  1.1    dyoung  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  1.1    dyoung  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  1.1    dyoung  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  1.1    dyoung  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  1.1    dyoung  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  1.1    dyoung  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31  1.1    dyoung  * POSSIBILITY OF SUCH DAMAGE.
     32  1.1    dyoung  */
     33  1.1    dyoung 
     34  1.1    dyoung /*
     35  1.1    dyoung  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
     36  1.1    dyoung  * Copyright (c) 1996 Jason R. Thorpe.  All rights reserved.
     37  1.1    dyoung  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     38  1.1    dyoung  *
     39  1.1    dyoung  * Redistribution and use in source and binary forms, with or without
     40  1.1    dyoung  * modification, are permitted provided that the following conditions
     41  1.1    dyoung  * are met:
     42  1.1    dyoung  * 1. Redistributions of source code must retain the above copyright
     43  1.1    dyoung  *    notice, this list of conditions and the following disclaimer.
     44  1.1    dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     45  1.1    dyoung  *    notice, this list of conditions and the following disclaimer in the
     46  1.1    dyoung  *    documentation and/or other materials provided with the distribution.
     47  1.1    dyoung  * 3. All advertising materials mentioning features or use of this software
     48  1.1    dyoung  *    must display the following acknowledgement:
     49  1.1    dyoung  *      This product includes software developed by Christopher G. Demetriou
     50  1.1    dyoung  *	for the NetBSD Project.
     51  1.1    dyoung  * 4. The name of the author may not be used to endorse or promote products
     52  1.1    dyoung  *    derived from this software without specific prior written permission
     53  1.1    dyoung  *
     54  1.1    dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     55  1.1    dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     56  1.1    dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     57  1.1    dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     58  1.1    dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     59  1.1    dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     60  1.1    dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     61  1.1    dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     62  1.1    dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     63  1.1    dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     64  1.1    dyoung  */
     65  1.1    dyoung 
     66  1.1    dyoung /*
     67  1.1    dyoung  * Copyright (c) 1997 Per Fogelstrom.  All rights reserved.
     68  1.1    dyoung  * Copyright (c) 1996 Niklas Hallqvist.  All rights reserved.
     69  1.1    dyoung  *
     70  1.1    dyoung  * Redistribution and use in source and binary forms, with or without
     71  1.1    dyoung  * modification, are permitted provided that the following conditions
     72  1.1    dyoung  * are met:
     73  1.1    dyoung  * 1. Redistributions of source code must retain the above copyright
     74  1.1    dyoung  *    notice, this list of conditions and the following disclaimer.
     75  1.1    dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     76  1.1    dyoung  *    notice, this list of conditions and the following disclaimer in the
     77  1.1    dyoung  *    documentation and/or other materials provided with the distribution.
     78  1.1    dyoung  * 3. All advertising materials mentioning features or use of this software
     79  1.1    dyoung  *    must display the following acknowledgement:
     80  1.1    dyoung  *      This product includes software developed by Christopher G. Demetriou
     81  1.1    dyoung  *	for the NetBSD Project.
     82  1.1    dyoung  * 4. The name of the author may not be used to endorse or promote products
     83  1.1    dyoung  *    derived from this software without specific prior written permission
     84  1.1    dyoung  *
     85  1.1    dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     86  1.1    dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     87  1.1    dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     88  1.1    dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     89  1.1    dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     90  1.1    dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     91  1.1    dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     92  1.1    dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     93  1.1    dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     94  1.1    dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     95  1.1    dyoung  */
     96  1.1    dyoung 
     97  1.1    dyoung #ifndef _POWERPC_BUS_DEFS_H_
     98  1.1    dyoung #define _POWERPC_BUS_DEFS_H_
     99  1.1    dyoung 
    100  1.4       rin #ifdef _KERNEL_OPT
    101  1.1    dyoung #include "opt_ppcarch.h"
    102  1.4       rin #endif
    103  1.4       rin 
    104  1.4       rin #ifndef BUS_DMA_DONTCACHE
    105  1.1    dyoung #if defined(PPC_IBM4XX) || defined(PPC_BOOKE)
    106  1.1    dyoung #define BUS_DMA_DONTCACHE (BUS_DMA_COHERENT|BUS_DMA_NOCACHE)
    107  1.4       rin #endif
    108  1.4       rin #endif
    109  1.1    dyoung 
    110  1.1    dyoung /*
    111  1.1    dyoung  * Bus access types.
    112  1.1    dyoung  */
    113  1.2      matt typedef uintptr_t bus_addr_t;
    114  1.2      matt typedef uintptr_t bus_size_t;
    115  1.1    dyoung 
    116  1.3     skrll #define PRIxBUSADDR	PRIxPTR
    117  1.3     skrll #define PRIxBUSSIZE	PRIxPTR
    118  1.3     skrll #define PRIuBUSSIZE	PRIuPTR
    119  1.3     skrll 
    120  1.1    dyoung #ifndef __HAVE_LOCAL_BUS_SPACE
    121  1.2      matt typedef	uintptr_t bus_space_handle_t;
    122  1.3     skrll 
    123  1.3     skrll #define PRIxBSH		PRIxPTR
    124  1.3     skrll 
    125  1.1    dyoung typedef	const struct powerpc_bus_space *bus_space_tag_t;
    126  1.1    dyoung 
    127  1.1    dyoung struct extent;
    128  1.1    dyoung 
    129  1.1    dyoung struct powerpc_bus_space_scalar {
    130  1.1    dyoung 	uint8_t (*pbss_read_1)(bus_space_tag_t, bus_space_handle_t,
    131  1.1    dyoung 	    bus_size_t);
    132  1.1    dyoung 	uint16_t (*pbss_read_2)(bus_space_tag_t, bus_space_handle_t,
    133  1.1    dyoung 	    bus_size_t);
    134  1.1    dyoung 	uint32_t (*pbss_read_4)(bus_space_tag_t, bus_space_handle_t,
    135  1.1    dyoung 	    bus_size_t);
    136  1.1    dyoung 	uint64_t (*pbss_read_8)(bus_space_tag_t, bus_space_handle_t,
    137  1.1    dyoung 	    bus_size_t);
    138  1.1    dyoung 
    139  1.1    dyoung 	void (*pbss_write_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    140  1.1    dyoung 	    uint8_t);
    141  1.1    dyoung 	void (*pbss_write_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    142  1.1    dyoung 	    uint16_t);
    143  1.1    dyoung 	void (*pbss_write_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    144  1.1    dyoung 	    uint32_t);
    145  1.1    dyoung 	void (*pbss_write_8)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    146  1.1    dyoung 	    uint64_t);
    147  1.1    dyoung };
    148  1.1    dyoung 
    149  1.1    dyoung struct powerpc_bus_space_group {
    150  1.1    dyoung 	void (*pbsg_read_1)(bus_space_tag_t, bus_space_handle_t,
    151  1.1    dyoung 	    bus_size_t, uint8_t *, size_t);
    152  1.1    dyoung 	void (*pbsg_read_2)(bus_space_tag_t, bus_space_handle_t,
    153  1.1    dyoung 	    bus_size_t, uint16_t *, size_t);
    154  1.1    dyoung 	void (*pbsg_read_4)(bus_space_tag_t, bus_space_handle_t,
    155  1.1    dyoung 	    bus_size_t, uint32_t *, size_t);
    156  1.1    dyoung 	void (*pbsg_read_8)(bus_space_tag_t, bus_space_handle_t,
    157  1.1    dyoung 	    bus_size_t, uint64_t *, size_t);
    158  1.1    dyoung 
    159  1.1    dyoung 	void (*pbsg_write_1)(bus_space_tag_t, bus_space_handle_t,
    160  1.1    dyoung 	    bus_size_t, const uint8_t *, size_t);
    161  1.1    dyoung 	void (*pbsg_write_2)(bus_space_tag_t, bus_space_handle_t,
    162  1.1    dyoung 	    bus_size_t, const uint16_t *, size_t);
    163  1.1    dyoung 	void (*pbsg_write_4)(bus_space_tag_t, bus_space_handle_t,
    164  1.1    dyoung 	    bus_size_t, const uint32_t *, size_t);
    165  1.1    dyoung 	void (*pbsg_write_8)(bus_space_tag_t, bus_space_handle_t,
    166  1.1    dyoung 	    bus_size_t, const uint64_t *, size_t);
    167  1.1    dyoung };
    168  1.1    dyoung 
    169  1.1    dyoung struct powerpc_bus_space_set {
    170  1.1    dyoung 	void (*pbss_set_1)(bus_space_tag_t, bus_space_handle_t,
    171  1.1    dyoung 	    bus_size_t, uint8_t, size_t);
    172  1.1    dyoung 	void (*pbss_set_2)(bus_space_tag_t, bus_space_handle_t,
    173  1.1    dyoung 	    bus_size_t, uint16_t, size_t);
    174  1.1    dyoung 	void (*pbss_set_4)(bus_space_tag_t, bus_space_handle_t,
    175  1.1    dyoung 	    bus_size_t, uint32_t, size_t);
    176  1.1    dyoung 	void (*pbss_set_8)(bus_space_tag_t, bus_space_handle_t,
    177  1.1    dyoung 	    bus_size_t, uint64_t, size_t);
    178  1.1    dyoung };
    179  1.1    dyoung 
    180  1.1    dyoung struct powerpc_bus_space_copy {
    181  1.1    dyoung 	void (*pbsc_copy_1)(bus_space_tag_t, bus_space_handle_t,
    182  1.1    dyoung 	    bus_size_t, bus_space_handle_t, bus_size_t, size_t);
    183  1.1    dyoung 	void (*pbsc_copy_2)(bus_space_tag_t, bus_space_handle_t,
    184  1.1    dyoung 	    bus_size_t, bus_space_handle_t, bus_size_t, size_t);
    185  1.1    dyoung 	void (*pbsc_copy_4)(bus_space_tag_t, bus_space_handle_t,
    186  1.1    dyoung 	    bus_size_t, bus_space_handle_t, bus_size_t, size_t);
    187  1.1    dyoung 	void (*pbsc_copy_8)(bus_space_tag_t, bus_space_handle_t,
    188  1.1    dyoung 	    bus_size_t, bus_space_handle_t, bus_size_t, size_t);
    189  1.1    dyoung };
    190  1.1    dyoung 
    191  1.1    dyoung struct powerpc_bus_space {
    192  1.1    dyoung 	int pbs_flags;
    193  1.1    dyoung #define	_BUS_SPACE_BIG_ENDIAN		0x00000100
    194  1.1    dyoung #define	_BUS_SPACE_LITTLE_ENDIAN	0x00000000
    195  1.1    dyoung #define	_BUS_SPACE_IO_TYPE		0x00000200
    196  1.1    dyoung #define	_BUS_SPACE_MEM_TYPE		0x00000000
    197  1.1    dyoung #define _BUS_SPACE_STRIDE_MASK		0x0000001f
    198  1.1    dyoung 	bus_addr_t pbs_offset;		/* offset to real start */
    199  1.1    dyoung 	bus_addr_t pbs_base;		/* extent base */
    200  1.1    dyoung 	bus_addr_t pbs_limit;		/* extent limit */
    201  1.1    dyoung 	struct extent *pbs_extent;
    202  1.1    dyoung 
    203  1.1    dyoung 	paddr_t (*pbs_mmap)(bus_space_tag_t, bus_addr_t, off_t, int, int);
    204  1.1    dyoung 	int (*pbs_map)(bus_space_tag_t, bus_addr_t, bus_size_t, int,
    205  1.1    dyoung 	    bus_space_handle_t *);
    206  1.1    dyoung 	void (*pbs_unmap)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
    207  1.1    dyoung 	int (*pbs_alloc)(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
    208  1.1    dyoung 	    bus_size_t align, bus_size_t, int, bus_addr_t *,
    209  1.1    dyoung 	    bus_space_handle_t *);
    210  1.1    dyoung 	void (*pbs_free)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
    211  1.1    dyoung 	int (*pbs_subregion)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    212  1.1    dyoung 	    bus_size_t, bus_space_handle_t *);
    213  1.1    dyoung 
    214  1.1    dyoung 	struct powerpc_bus_space_scalar pbs_scalar;
    215  1.1    dyoung 	struct powerpc_bus_space_scalar pbs_scalar_stream;
    216  1.1    dyoung 	const struct powerpc_bus_space_group *pbs_multi;
    217  1.1    dyoung 	const struct powerpc_bus_space_group *pbs_multi_stream;
    218  1.1    dyoung 	const struct powerpc_bus_space_group *pbs_region;
    219  1.1    dyoung 	const struct powerpc_bus_space_group *pbs_region_stream;
    220  1.1    dyoung 	const struct powerpc_bus_space_set *pbs_set;
    221  1.1    dyoung 	const struct powerpc_bus_space_set *pbs_set_stream;
    222  1.1    dyoung 	const struct powerpc_bus_space_copy *pbs_copy;
    223  1.5  riastrad 
    224  1.5  riastrad 	void (*pbs_barrier)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    225  1.5  riastrad 	    bus_size_t, int);
    226  1.1    dyoung };
    227  1.1    dyoung 
    228  1.1    dyoung #define _BUS_SPACE_STRIDE(t, o) \
    229  1.1    dyoung 	((o) << ((t)->pbs_flags & _BUS_SPACE_STRIDE_MASK))
    230  1.1    dyoung #define _BUS_SPACE_UNSTRIDE(t, o) \
    231  1.1    dyoung 	((o) >> ((t)->pbs_flags & _BUS_SPACE_STRIDE_MASK))
    232  1.1    dyoung 
    233  1.1    dyoung #define BUS_SPACE_MAP_CACHEABLE         0x01
    234  1.1    dyoung #define BUS_SPACE_MAP_LINEAR            0x02
    235  1.1    dyoung #define	BUS_SPACE_MAP_PREFETCHABLE	0x04
    236  1.1    dyoung 
    237  1.1    dyoung int bus_space_init(struct powerpc_bus_space *, const char *, void *, size_t);
    238  1.1    dyoung void bus_space_mallocok(void);
    239  1.1    dyoung 
    240  1.1    dyoung /*
    241  1.1    dyoung  * Access methods for bus resources
    242  1.1    dyoung  */
    243  1.1    dyoung 
    244  1.1    dyoung #define	__BUS_SPACE_HAS_STREAM_METHODS
    245  1.1    dyoung 
    246  1.1    dyoung #define	BUS_SPACE_BARRIER_READ	0x01		/* force read barrier */
    247  1.1    dyoung #define	BUS_SPACE_BARRIER_WRITE	0x02		/* force write barrier */
    248  1.1    dyoung 
    249  1.1    dyoung #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
    250  1.1    dyoung 
    251  1.1    dyoung #endif	/* !__HAVE_LOCAL_BUS_SPACE */
    252  1.1    dyoung 
    253  1.1    dyoung /*
    254  1.1    dyoung  * Bus DMA methods.
    255  1.1    dyoung  */
    256  1.1    dyoung 
    257  1.1    dyoung /*
    258  1.1    dyoung  * Flags used in various bus DMA methods.
    259  1.1    dyoung  */
    260  1.1    dyoung #define	BUS_DMA_WAITOK		0x000	/* safe to sleep (pseudo-flag) */
    261  1.1    dyoung #define	BUS_DMA_NOWAIT		0x001	/* not safe to sleep */
    262  1.1    dyoung #define	BUS_DMA_ALLOCNOW	0x002	/* perform resource allocation now */
    263  1.1    dyoung #define	BUS_DMA_COHERENT	0x004	/* hint: map memory DMA coherent */
    264  1.1    dyoung #define	BUS_DMA_STREAMING	0x008	/* hint: sequential, unidirectional */
    265  1.1    dyoung #define	BUS_DMA_BUS1		0x010	/* placeholders for bus functions... */
    266  1.1    dyoung #define	BUS_DMA_BUS2		0x020
    267  1.1    dyoung #define	BUS_DMA_BUS3		0x040
    268  1.1    dyoung #define	BUS_DMA_BUS4		0x080
    269  1.1    dyoung #define	BUS_DMA_READ		0x100	/* mapping is device -> memory only */
    270  1.1    dyoung #define	BUS_DMA_WRITE		0x200	/* mapping is memory -> device only */
    271  1.1    dyoung #define	BUS_DMA_NOCACHE		0x400	/* hint: map non-cached memory */
    272  1.1    dyoung 
    273  1.1    dyoung #ifndef BUS_DMA_DONTCACHE
    274  1.1    dyoung #define	BUS_DMA_DONTCACHE	BUS_DMA_NOCACHE
    275  1.1    dyoung #endif
    276  1.1    dyoung 
    277  1.1    dyoung /* Forwards needed by prototypes below. */
    278  1.1    dyoung struct proc;
    279  1.1    dyoung struct mbuf;
    280  1.1    dyoung struct uio;
    281  1.1    dyoung 
    282  1.1    dyoung /*
    283  1.1    dyoung  * Operations performed by bus_dmamap_sync().
    284  1.1    dyoung  */
    285  1.1    dyoung #define	BUS_DMASYNC_PREREAD	0x01	/* pre-read synchronization */
    286  1.1    dyoung #define	BUS_DMASYNC_POSTREAD	0x02	/* post-read synchronization */
    287  1.1    dyoung #define	BUS_DMASYNC_PREWRITE	0x04	/* pre-write synchronization */
    288  1.1    dyoung #define	BUS_DMASYNC_POSTWRITE	0x08	/* post-write synchronization */
    289  1.1    dyoung 
    290  1.1    dyoung typedef struct powerpc_bus_dma_tag		*bus_dma_tag_t;
    291  1.1    dyoung typedef struct powerpc_bus_dmamap		*bus_dmamap_t;
    292  1.1    dyoung 
    293  1.1    dyoung #define BUS_DMA_TAG_VALID(t)    ((t) != (bus_dma_tag_t)0)
    294  1.1    dyoung 
    295  1.1    dyoung /*
    296  1.1    dyoung  *	bus_dma_segment_t
    297  1.1    dyoung  *
    298  1.1    dyoung  *	Describes a single contiguous DMA transaction.  Values
    299  1.1    dyoung  *	are suitable for programming into DMA registers.
    300  1.1    dyoung  */
    301  1.1    dyoung struct powerpc_bus_dma_segment {
    302  1.1    dyoung 	bus_addr_t	ds_addr;	/* DMA address */
    303  1.1    dyoung 	bus_size_t	ds_len;		/* length of transfer */
    304  1.1    dyoung };
    305  1.1    dyoung typedef struct powerpc_bus_dma_segment	bus_dma_segment_t;
    306  1.1    dyoung 
    307  1.1    dyoung /*
    308  1.1    dyoung  *	bus_dma_tag_t
    309  1.1    dyoung  *
    310  1.1    dyoung  *	A machine-dependent opaque type describing the implementation of
    311  1.1    dyoung  *	DMA for a given bus.
    312  1.1    dyoung  */
    313  1.1    dyoung 
    314  1.1    dyoung struct powerpc_bus_dma_tag {
    315  1.1    dyoung 	/*
    316  1.1    dyoung 	 * The `bounce threshold' is checked while we are loading
    317  1.1    dyoung 	 * the DMA map.  If the physical address of the segment
    318  1.1    dyoung 	 * exceeds the threshold, an error will be returned.  The
    319  1.1    dyoung 	 * caller can then take whatever action is necessary to
    320  1.1    dyoung 	 * bounce the transfer.  If this value is 0, it will be
    321  1.1    dyoung 	 * ignored.
    322  1.1    dyoung 	 */
    323  1.1    dyoung 	bus_addr_t _bounce_thresh;
    324  1.1    dyoung 
    325  1.1    dyoung 	/*
    326  1.1    dyoung 	 * DMA mapping methods.
    327  1.1    dyoung 	 */
    328  1.1    dyoung 	int	(*_dmamap_create) (bus_dma_tag_t, bus_size_t, int,
    329  1.1    dyoung 		    bus_size_t, bus_size_t, int, bus_dmamap_t *);
    330  1.1    dyoung 	void	(*_dmamap_destroy) (bus_dma_tag_t, bus_dmamap_t);
    331  1.1    dyoung 	int	(*_dmamap_load) (bus_dma_tag_t, bus_dmamap_t, void *,
    332  1.1    dyoung 		    bus_size_t, struct proc *, int);
    333  1.1    dyoung 	int	(*_dmamap_load_mbuf) (bus_dma_tag_t, bus_dmamap_t,
    334  1.1    dyoung 		    struct mbuf *, int);
    335  1.1    dyoung 	int	(*_dmamap_load_uio) (bus_dma_tag_t, bus_dmamap_t,
    336  1.1    dyoung 		    struct uio *, int);
    337  1.1    dyoung 	int	(*_dmamap_load_raw) (bus_dma_tag_t, bus_dmamap_t,
    338  1.1    dyoung 		    bus_dma_segment_t *, int, bus_size_t, int);
    339  1.1    dyoung 	void	(*_dmamap_unload) (bus_dma_tag_t, bus_dmamap_t);
    340  1.1    dyoung 	void	(*_dmamap_sync) (bus_dma_tag_t, bus_dmamap_t,
    341  1.1    dyoung 		    bus_addr_t, bus_size_t, int);
    342  1.1    dyoung 
    343  1.1    dyoung 	/*
    344  1.1    dyoung 	 * DMA memory utility functions.
    345  1.1    dyoung 	 */
    346  1.1    dyoung 	int	(*_dmamem_alloc) (bus_dma_tag_t, bus_size_t, bus_size_t,
    347  1.1    dyoung 		    bus_size_t, bus_dma_segment_t *, int, int *, int);
    348  1.1    dyoung 	void	(*_dmamem_free) (bus_dma_tag_t,
    349  1.1    dyoung 		    bus_dma_segment_t *, int);
    350  1.1    dyoung 	int	(*_dmamem_map) (bus_dma_tag_t, bus_dma_segment_t *,
    351  1.1    dyoung 		    int, size_t, void **, int);
    352  1.1    dyoung 	void	(*_dmamem_unmap) (bus_dma_tag_t, void *, size_t);
    353  1.1    dyoung 	paddr_t	(*_dmamem_mmap) (bus_dma_tag_t, bus_dma_segment_t *,
    354  1.1    dyoung 		    int, off_t, int, int);
    355  1.1    dyoung 
    356  1.1    dyoung #ifndef PHYS_TO_BUS_MEM
    357  1.1    dyoung 	bus_addr_t (*_dma_phys_to_bus_mem)(bus_dma_tag_t, bus_addr_t);
    358  1.1    dyoung #define	PHYS_TO_BUS_MEM(t, addr) (*(t)->_dma_phys_to_bus_mem)((t), (addr))
    359  1.1    dyoung #endif
    360  1.1    dyoung #ifndef BUS_MEM_TO_PHYS
    361  1.1    dyoung 	bus_addr_t (*_dma_bus_mem_to_phys)(bus_dma_tag_t, bus_addr_t);
    362  1.1    dyoung #define	BUS_MEM_TO_PHYS(t, addr) (*(t)->_dma_bus_mem_to_phys)((t), (addr))
    363  1.1    dyoung #endif
    364  1.1    dyoung };
    365  1.1    dyoung 
    366  1.1    dyoung /*
    367  1.1    dyoung  *	bus_dmamap_t
    368  1.1    dyoung  *
    369  1.1    dyoung  *	Describes a DMA mapping.
    370  1.1    dyoung  */
    371  1.1    dyoung struct powerpc_bus_dmamap {
    372  1.1    dyoung 	/*
    373  1.1    dyoung 	 * PRIVATE MEMBERS: not for use my machine-independent code.
    374  1.1    dyoung 	 */
    375  1.1    dyoung 	bus_size_t	_dm_size;	/* largest DMA transfer mappable */
    376  1.1    dyoung 	int		_dm_segcnt;	/* number of segs this map can map */
    377  1.1    dyoung 	bus_size_t	_dm_maxmaxsegsz; /* fixed largest possible segment */
    378  1.1    dyoung 	bus_size_t	_dm_boundary;	/* don't cross this */
    379  1.1    dyoung 	bus_addr_t	_dm_bounce_thresh; /* bounce threshold; see tag */
    380  1.1    dyoung 	int		_dm_flags;	/* misc. flags */
    381  1.1    dyoung 
    382  1.1    dyoung 	void		*_dm_cookie;	/* cookie for bus-specific functions */
    383  1.1    dyoung 
    384  1.1    dyoung 	/*
    385  1.1    dyoung 	 * PUBLIC MEMBERS: these are used by machine-independent code.
    386  1.1    dyoung 	 */
    387  1.1    dyoung 	bus_size_t	dm_maxsegsz;	/* largest possible segment */
    388  1.1    dyoung 	bus_size_t	dm_mapsize;	/* size of the mapping */
    389  1.1    dyoung 	int		dm_nsegs;	/* # valid segments in mapping */
    390  1.1    dyoung 	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
    391  1.1    dyoung };
    392  1.1    dyoung 
    393  1.1    dyoung #endif /* _POWERPC_BUS_DEFS_H_ */
    394