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