1*cc01a7f7Sriastradh /* $NetBSD: bus_defs.h,v 1.5 2022/03/10 00:14:16 riastradh Exp $ */ 259adf08eSdyoung /* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */ 359adf08eSdyoung 459adf08eSdyoung /*- 559adf08eSdyoung * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 659adf08eSdyoung * All rights reserved. 759adf08eSdyoung * 859adf08eSdyoung * This code is derived from software contributed to The NetBSD Foundation 959adf08eSdyoung * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 1059adf08eSdyoung * NASA Ames Research Center. 1159adf08eSdyoung * 1259adf08eSdyoung * Redistribution and use in source and binary forms, with or without 1359adf08eSdyoung * modification, are permitted provided that the following conditions 1459adf08eSdyoung * are met: 1559adf08eSdyoung * 1. Redistributions of source code must retain the above copyright 1659adf08eSdyoung * notice, this list of conditions and the following disclaimer. 1759adf08eSdyoung * 2. Redistributions in binary form must reproduce the above copyright 1859adf08eSdyoung * notice, this list of conditions and the following disclaimer in the 1959adf08eSdyoung * documentation and/or other materials provided with the distribution. 2059adf08eSdyoung * 2159adf08eSdyoung * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 2259adf08eSdyoung * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2359adf08eSdyoung * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2459adf08eSdyoung * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2559adf08eSdyoung * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2659adf08eSdyoung * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2759adf08eSdyoung * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2859adf08eSdyoung * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2959adf08eSdyoung * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3059adf08eSdyoung * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3159adf08eSdyoung * POSSIBILITY OF SUCH DAMAGE. 3259adf08eSdyoung */ 3359adf08eSdyoung 3459adf08eSdyoung /* 3559adf08eSdyoung * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 3659adf08eSdyoung * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. 3759adf08eSdyoung * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 3859adf08eSdyoung * 3959adf08eSdyoung * Redistribution and use in source and binary forms, with or without 4059adf08eSdyoung * modification, are permitted provided that the following conditions 4159adf08eSdyoung * are met: 4259adf08eSdyoung * 1. Redistributions of source code must retain the above copyright 4359adf08eSdyoung * notice, this list of conditions and the following disclaimer. 4459adf08eSdyoung * 2. Redistributions in binary form must reproduce the above copyright 4559adf08eSdyoung * notice, this list of conditions and the following disclaimer in the 4659adf08eSdyoung * documentation and/or other materials provided with the distribution. 4759adf08eSdyoung * 3. All advertising materials mentioning features or use of this software 4859adf08eSdyoung * must display the following acknowledgement: 4959adf08eSdyoung * This product includes software developed by Christopher G. Demetriou 5059adf08eSdyoung * for the NetBSD Project. 5159adf08eSdyoung * 4. The name of the author may not be used to endorse or promote products 5259adf08eSdyoung * derived from this software without specific prior written permission 5359adf08eSdyoung * 5459adf08eSdyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 5559adf08eSdyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 5659adf08eSdyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 5759adf08eSdyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 5859adf08eSdyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 5959adf08eSdyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 6059adf08eSdyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 6159adf08eSdyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 6259adf08eSdyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 6359adf08eSdyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6459adf08eSdyoung */ 6559adf08eSdyoung 6659adf08eSdyoung /* 6759adf08eSdyoung * Copyright (c) 1997 Per Fogelstrom. All rights reserved. 6859adf08eSdyoung * Copyright (c) 1996 Niklas Hallqvist. All rights reserved. 6959adf08eSdyoung * 7059adf08eSdyoung * Redistribution and use in source and binary forms, with or without 7159adf08eSdyoung * modification, are permitted provided that the following conditions 7259adf08eSdyoung * are met: 7359adf08eSdyoung * 1. Redistributions of source code must retain the above copyright 7459adf08eSdyoung * notice, this list of conditions and the following disclaimer. 7559adf08eSdyoung * 2. Redistributions in binary form must reproduce the above copyright 7659adf08eSdyoung * notice, this list of conditions and the following disclaimer in the 7759adf08eSdyoung * documentation and/or other materials provided with the distribution. 7859adf08eSdyoung * 3. All advertising materials mentioning features or use of this software 7959adf08eSdyoung * must display the following acknowledgement: 8059adf08eSdyoung * This product includes software developed by Christopher G. Demetriou 8159adf08eSdyoung * for the NetBSD Project. 8259adf08eSdyoung * 4. The name of the author may not be used to endorse or promote products 8359adf08eSdyoung * derived from this software without specific prior written permission 8459adf08eSdyoung * 8559adf08eSdyoung * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 8659adf08eSdyoung * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 8759adf08eSdyoung * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 8859adf08eSdyoung * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 8959adf08eSdyoung * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 9059adf08eSdyoung * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 9159adf08eSdyoung * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 9259adf08eSdyoung * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 9359adf08eSdyoung * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 9459adf08eSdyoung * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 9559adf08eSdyoung */ 9659adf08eSdyoung 9759adf08eSdyoung #ifndef _POWERPC_BUS_DEFS_H_ 9859adf08eSdyoung #define _POWERPC_BUS_DEFS_H_ 9959adf08eSdyoung 10016031f7dSrin #ifdef _KERNEL_OPT 10159adf08eSdyoung #include "opt_ppcarch.h" 10216031f7dSrin #endif 10316031f7dSrin 10416031f7dSrin #ifndef BUS_DMA_DONTCACHE 10559adf08eSdyoung #if defined(PPC_IBM4XX) || defined(PPC_BOOKE) 10659adf08eSdyoung #define BUS_DMA_DONTCACHE (BUS_DMA_COHERENT|BUS_DMA_NOCACHE) 10716031f7dSrin #endif 10816031f7dSrin #endif 10959adf08eSdyoung 11059adf08eSdyoung /* 11159adf08eSdyoung * Bus access types. 11259adf08eSdyoung */ 1137f94f535Smatt typedef uintptr_t bus_addr_t; 1147f94f535Smatt typedef uintptr_t bus_size_t; 11559adf08eSdyoung 116bf158e33Sskrll #define PRIxBUSADDR PRIxPTR 117bf158e33Sskrll #define PRIxBUSSIZE PRIxPTR 118bf158e33Sskrll #define PRIuBUSSIZE PRIuPTR 119bf158e33Sskrll 12059adf08eSdyoung #ifndef __HAVE_LOCAL_BUS_SPACE 1217f94f535Smatt typedef uintptr_t bus_space_handle_t; 122bf158e33Sskrll 123bf158e33Sskrll #define PRIxBSH PRIxPTR 124bf158e33Sskrll 12559adf08eSdyoung typedef const struct powerpc_bus_space *bus_space_tag_t; 12659adf08eSdyoung 12759adf08eSdyoung struct extent; 12859adf08eSdyoung 12959adf08eSdyoung struct powerpc_bus_space_scalar { 13059adf08eSdyoung uint8_t (*pbss_read_1)(bus_space_tag_t, bus_space_handle_t, 13159adf08eSdyoung bus_size_t); 13259adf08eSdyoung uint16_t (*pbss_read_2)(bus_space_tag_t, bus_space_handle_t, 13359adf08eSdyoung bus_size_t); 13459adf08eSdyoung uint32_t (*pbss_read_4)(bus_space_tag_t, bus_space_handle_t, 13559adf08eSdyoung bus_size_t); 13659adf08eSdyoung uint64_t (*pbss_read_8)(bus_space_tag_t, bus_space_handle_t, 13759adf08eSdyoung bus_size_t); 13859adf08eSdyoung 13959adf08eSdyoung void (*pbss_write_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t, 14059adf08eSdyoung uint8_t); 14159adf08eSdyoung void (*pbss_write_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t, 14259adf08eSdyoung uint16_t); 14359adf08eSdyoung void (*pbss_write_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t, 14459adf08eSdyoung uint32_t); 14559adf08eSdyoung void (*pbss_write_8)(bus_space_tag_t, bus_space_handle_t, bus_size_t, 14659adf08eSdyoung uint64_t); 14759adf08eSdyoung }; 14859adf08eSdyoung 14959adf08eSdyoung struct powerpc_bus_space_group { 15059adf08eSdyoung void (*pbsg_read_1)(bus_space_tag_t, bus_space_handle_t, 15159adf08eSdyoung bus_size_t, uint8_t *, size_t); 15259adf08eSdyoung void (*pbsg_read_2)(bus_space_tag_t, bus_space_handle_t, 15359adf08eSdyoung bus_size_t, uint16_t *, size_t); 15459adf08eSdyoung void (*pbsg_read_4)(bus_space_tag_t, bus_space_handle_t, 15559adf08eSdyoung bus_size_t, uint32_t *, size_t); 15659adf08eSdyoung void (*pbsg_read_8)(bus_space_tag_t, bus_space_handle_t, 15759adf08eSdyoung bus_size_t, uint64_t *, size_t); 15859adf08eSdyoung 15959adf08eSdyoung void (*pbsg_write_1)(bus_space_tag_t, bus_space_handle_t, 16059adf08eSdyoung bus_size_t, const uint8_t *, size_t); 16159adf08eSdyoung void (*pbsg_write_2)(bus_space_tag_t, bus_space_handle_t, 16259adf08eSdyoung bus_size_t, const uint16_t *, size_t); 16359adf08eSdyoung void (*pbsg_write_4)(bus_space_tag_t, bus_space_handle_t, 16459adf08eSdyoung bus_size_t, const uint32_t *, size_t); 16559adf08eSdyoung void (*pbsg_write_8)(bus_space_tag_t, bus_space_handle_t, 16659adf08eSdyoung bus_size_t, const uint64_t *, size_t); 16759adf08eSdyoung }; 16859adf08eSdyoung 16959adf08eSdyoung struct powerpc_bus_space_set { 17059adf08eSdyoung void (*pbss_set_1)(bus_space_tag_t, bus_space_handle_t, 17159adf08eSdyoung bus_size_t, uint8_t, size_t); 17259adf08eSdyoung void (*pbss_set_2)(bus_space_tag_t, bus_space_handle_t, 17359adf08eSdyoung bus_size_t, uint16_t, size_t); 17459adf08eSdyoung void (*pbss_set_4)(bus_space_tag_t, bus_space_handle_t, 17559adf08eSdyoung bus_size_t, uint32_t, size_t); 17659adf08eSdyoung void (*pbss_set_8)(bus_space_tag_t, bus_space_handle_t, 17759adf08eSdyoung bus_size_t, uint64_t, size_t); 17859adf08eSdyoung }; 17959adf08eSdyoung 18059adf08eSdyoung struct powerpc_bus_space_copy { 18159adf08eSdyoung void (*pbsc_copy_1)(bus_space_tag_t, bus_space_handle_t, 18259adf08eSdyoung bus_size_t, bus_space_handle_t, bus_size_t, size_t); 18359adf08eSdyoung void (*pbsc_copy_2)(bus_space_tag_t, bus_space_handle_t, 18459adf08eSdyoung bus_size_t, bus_space_handle_t, bus_size_t, size_t); 18559adf08eSdyoung void (*pbsc_copy_4)(bus_space_tag_t, bus_space_handle_t, 18659adf08eSdyoung bus_size_t, bus_space_handle_t, bus_size_t, size_t); 18759adf08eSdyoung void (*pbsc_copy_8)(bus_space_tag_t, bus_space_handle_t, 18859adf08eSdyoung bus_size_t, bus_space_handle_t, bus_size_t, size_t); 18959adf08eSdyoung }; 19059adf08eSdyoung 19159adf08eSdyoung struct powerpc_bus_space { 19259adf08eSdyoung int pbs_flags; 19359adf08eSdyoung #define _BUS_SPACE_BIG_ENDIAN 0x00000100 19459adf08eSdyoung #define _BUS_SPACE_LITTLE_ENDIAN 0x00000000 19559adf08eSdyoung #define _BUS_SPACE_IO_TYPE 0x00000200 19659adf08eSdyoung #define _BUS_SPACE_MEM_TYPE 0x00000000 19759adf08eSdyoung #define _BUS_SPACE_STRIDE_MASK 0x0000001f 19859adf08eSdyoung bus_addr_t pbs_offset; /* offset to real start */ 19959adf08eSdyoung bus_addr_t pbs_base; /* extent base */ 20059adf08eSdyoung bus_addr_t pbs_limit; /* extent limit */ 20159adf08eSdyoung struct extent *pbs_extent; 20259adf08eSdyoung 20359adf08eSdyoung paddr_t (*pbs_mmap)(bus_space_tag_t, bus_addr_t, off_t, int, int); 20459adf08eSdyoung int (*pbs_map)(bus_space_tag_t, bus_addr_t, bus_size_t, int, 20559adf08eSdyoung bus_space_handle_t *); 20659adf08eSdyoung void (*pbs_unmap)(bus_space_tag_t, bus_space_handle_t, bus_size_t); 20759adf08eSdyoung int (*pbs_alloc)(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t, 20859adf08eSdyoung bus_size_t align, bus_size_t, int, bus_addr_t *, 20959adf08eSdyoung bus_space_handle_t *); 21059adf08eSdyoung void (*pbs_free)(bus_space_tag_t, bus_space_handle_t, bus_size_t); 21159adf08eSdyoung int (*pbs_subregion)(bus_space_tag_t, bus_space_handle_t, bus_size_t, 21259adf08eSdyoung bus_size_t, bus_space_handle_t *); 21359adf08eSdyoung 21459adf08eSdyoung struct powerpc_bus_space_scalar pbs_scalar; 21559adf08eSdyoung struct powerpc_bus_space_scalar pbs_scalar_stream; 21659adf08eSdyoung const struct powerpc_bus_space_group *pbs_multi; 21759adf08eSdyoung const struct powerpc_bus_space_group *pbs_multi_stream; 21859adf08eSdyoung const struct powerpc_bus_space_group *pbs_region; 21959adf08eSdyoung const struct powerpc_bus_space_group *pbs_region_stream; 22059adf08eSdyoung const struct powerpc_bus_space_set *pbs_set; 22159adf08eSdyoung const struct powerpc_bus_space_set *pbs_set_stream; 22259adf08eSdyoung const struct powerpc_bus_space_copy *pbs_copy; 223*cc01a7f7Sriastradh 224*cc01a7f7Sriastradh void (*pbs_barrier)(bus_space_tag_t, bus_space_handle_t, bus_size_t, 225*cc01a7f7Sriastradh bus_size_t, int); 22659adf08eSdyoung }; 22759adf08eSdyoung 22859adf08eSdyoung #define _BUS_SPACE_STRIDE(t, o) \ 22959adf08eSdyoung ((o) << ((t)->pbs_flags & _BUS_SPACE_STRIDE_MASK)) 23059adf08eSdyoung #define _BUS_SPACE_UNSTRIDE(t, o) \ 23159adf08eSdyoung ((o) >> ((t)->pbs_flags & _BUS_SPACE_STRIDE_MASK)) 23259adf08eSdyoung 23359adf08eSdyoung #define BUS_SPACE_MAP_CACHEABLE 0x01 23459adf08eSdyoung #define BUS_SPACE_MAP_LINEAR 0x02 23559adf08eSdyoung #define BUS_SPACE_MAP_PREFETCHABLE 0x04 23659adf08eSdyoung 23759adf08eSdyoung int bus_space_init(struct powerpc_bus_space *, const char *, void *, size_t); 23859adf08eSdyoung void bus_space_mallocok(void); 23959adf08eSdyoung 24059adf08eSdyoung /* 24159adf08eSdyoung * Access methods for bus resources 24259adf08eSdyoung */ 24359adf08eSdyoung 24459adf08eSdyoung #define __BUS_SPACE_HAS_STREAM_METHODS 24559adf08eSdyoung 24659adf08eSdyoung #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 24759adf08eSdyoung #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 24859adf08eSdyoung 24959adf08eSdyoung #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 25059adf08eSdyoung 25159adf08eSdyoung #endif /* !__HAVE_LOCAL_BUS_SPACE */ 25259adf08eSdyoung 25359adf08eSdyoung /* 25459adf08eSdyoung * Bus DMA methods. 25559adf08eSdyoung */ 25659adf08eSdyoung 25759adf08eSdyoung /* 25859adf08eSdyoung * Flags used in various bus DMA methods. 25959adf08eSdyoung */ 26059adf08eSdyoung #define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */ 26159adf08eSdyoung #define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */ 26259adf08eSdyoung #define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */ 26359adf08eSdyoung #define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */ 26459adf08eSdyoung #define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */ 26559adf08eSdyoung #define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */ 26659adf08eSdyoung #define BUS_DMA_BUS2 0x020 26759adf08eSdyoung #define BUS_DMA_BUS3 0x040 26859adf08eSdyoung #define BUS_DMA_BUS4 0x080 26959adf08eSdyoung #define BUS_DMA_READ 0x100 /* mapping is device -> memory only */ 27059adf08eSdyoung #define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */ 27159adf08eSdyoung #define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */ 27259adf08eSdyoung 27359adf08eSdyoung #ifndef BUS_DMA_DONTCACHE 27459adf08eSdyoung #define BUS_DMA_DONTCACHE BUS_DMA_NOCACHE 27559adf08eSdyoung #endif 27659adf08eSdyoung 27759adf08eSdyoung /* Forwards needed by prototypes below. */ 27859adf08eSdyoung struct proc; 27959adf08eSdyoung struct mbuf; 28059adf08eSdyoung struct uio; 28159adf08eSdyoung 28259adf08eSdyoung /* 28359adf08eSdyoung * Operations performed by bus_dmamap_sync(). 28459adf08eSdyoung */ 28559adf08eSdyoung #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */ 28659adf08eSdyoung #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */ 28759adf08eSdyoung #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */ 28859adf08eSdyoung #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */ 28959adf08eSdyoung 29059adf08eSdyoung typedef struct powerpc_bus_dma_tag *bus_dma_tag_t; 29159adf08eSdyoung typedef struct powerpc_bus_dmamap *bus_dmamap_t; 29259adf08eSdyoung 29359adf08eSdyoung #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0) 29459adf08eSdyoung 29559adf08eSdyoung /* 29659adf08eSdyoung * bus_dma_segment_t 29759adf08eSdyoung * 29859adf08eSdyoung * Describes a single contiguous DMA transaction. Values 29959adf08eSdyoung * are suitable for programming into DMA registers. 30059adf08eSdyoung */ 30159adf08eSdyoung struct powerpc_bus_dma_segment { 30259adf08eSdyoung bus_addr_t ds_addr; /* DMA address */ 30359adf08eSdyoung bus_size_t ds_len; /* length of transfer */ 30459adf08eSdyoung }; 30559adf08eSdyoung typedef struct powerpc_bus_dma_segment bus_dma_segment_t; 30659adf08eSdyoung 30759adf08eSdyoung /* 30859adf08eSdyoung * bus_dma_tag_t 30959adf08eSdyoung * 31059adf08eSdyoung * A machine-dependent opaque type describing the implementation of 31159adf08eSdyoung * DMA for a given bus. 31259adf08eSdyoung */ 31359adf08eSdyoung 31459adf08eSdyoung struct powerpc_bus_dma_tag { 31559adf08eSdyoung /* 31659adf08eSdyoung * The `bounce threshold' is checked while we are loading 31759adf08eSdyoung * the DMA map. If the physical address of the segment 31859adf08eSdyoung * exceeds the threshold, an error will be returned. The 31959adf08eSdyoung * caller can then take whatever action is necessary to 32059adf08eSdyoung * bounce the transfer. If this value is 0, it will be 32159adf08eSdyoung * ignored. 32259adf08eSdyoung */ 32359adf08eSdyoung bus_addr_t _bounce_thresh; 32459adf08eSdyoung 32559adf08eSdyoung /* 32659adf08eSdyoung * DMA mapping methods. 32759adf08eSdyoung */ 32859adf08eSdyoung int (*_dmamap_create) (bus_dma_tag_t, bus_size_t, int, 32959adf08eSdyoung bus_size_t, bus_size_t, int, bus_dmamap_t *); 33059adf08eSdyoung void (*_dmamap_destroy) (bus_dma_tag_t, bus_dmamap_t); 33159adf08eSdyoung int (*_dmamap_load) (bus_dma_tag_t, bus_dmamap_t, void *, 33259adf08eSdyoung bus_size_t, struct proc *, int); 33359adf08eSdyoung int (*_dmamap_load_mbuf) (bus_dma_tag_t, bus_dmamap_t, 33459adf08eSdyoung struct mbuf *, int); 33559adf08eSdyoung int (*_dmamap_load_uio) (bus_dma_tag_t, bus_dmamap_t, 33659adf08eSdyoung struct uio *, int); 33759adf08eSdyoung int (*_dmamap_load_raw) (bus_dma_tag_t, bus_dmamap_t, 33859adf08eSdyoung bus_dma_segment_t *, int, bus_size_t, int); 33959adf08eSdyoung void (*_dmamap_unload) (bus_dma_tag_t, bus_dmamap_t); 34059adf08eSdyoung void (*_dmamap_sync) (bus_dma_tag_t, bus_dmamap_t, 34159adf08eSdyoung bus_addr_t, bus_size_t, int); 34259adf08eSdyoung 34359adf08eSdyoung /* 34459adf08eSdyoung * DMA memory utility functions. 34559adf08eSdyoung */ 34659adf08eSdyoung int (*_dmamem_alloc) (bus_dma_tag_t, bus_size_t, bus_size_t, 34759adf08eSdyoung bus_size_t, bus_dma_segment_t *, int, int *, int); 34859adf08eSdyoung void (*_dmamem_free) (bus_dma_tag_t, 34959adf08eSdyoung bus_dma_segment_t *, int); 35059adf08eSdyoung int (*_dmamem_map) (bus_dma_tag_t, bus_dma_segment_t *, 35159adf08eSdyoung int, size_t, void **, int); 35259adf08eSdyoung void (*_dmamem_unmap) (bus_dma_tag_t, void *, size_t); 35359adf08eSdyoung paddr_t (*_dmamem_mmap) (bus_dma_tag_t, bus_dma_segment_t *, 35459adf08eSdyoung int, off_t, int, int); 35559adf08eSdyoung 35659adf08eSdyoung #ifndef PHYS_TO_BUS_MEM 35759adf08eSdyoung bus_addr_t (*_dma_phys_to_bus_mem)(bus_dma_tag_t, bus_addr_t); 35859adf08eSdyoung #define PHYS_TO_BUS_MEM(t, addr) (*(t)->_dma_phys_to_bus_mem)((t), (addr)) 35959adf08eSdyoung #endif 36059adf08eSdyoung #ifndef BUS_MEM_TO_PHYS 36159adf08eSdyoung bus_addr_t (*_dma_bus_mem_to_phys)(bus_dma_tag_t, bus_addr_t); 36259adf08eSdyoung #define BUS_MEM_TO_PHYS(t, addr) (*(t)->_dma_bus_mem_to_phys)((t), (addr)) 36359adf08eSdyoung #endif 36459adf08eSdyoung }; 36559adf08eSdyoung 36659adf08eSdyoung /* 36759adf08eSdyoung * bus_dmamap_t 36859adf08eSdyoung * 36959adf08eSdyoung * Describes a DMA mapping. 37059adf08eSdyoung */ 37159adf08eSdyoung struct powerpc_bus_dmamap { 37259adf08eSdyoung /* 37359adf08eSdyoung * PRIVATE MEMBERS: not for use my machine-independent code. 37459adf08eSdyoung */ 37559adf08eSdyoung bus_size_t _dm_size; /* largest DMA transfer mappable */ 37659adf08eSdyoung int _dm_segcnt; /* number of segs this map can map */ 37759adf08eSdyoung bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */ 37859adf08eSdyoung bus_size_t _dm_boundary; /* don't cross this */ 37959adf08eSdyoung bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */ 38059adf08eSdyoung int _dm_flags; /* misc. flags */ 38159adf08eSdyoung 38259adf08eSdyoung void *_dm_cookie; /* cookie for bus-specific functions */ 38359adf08eSdyoung 38459adf08eSdyoung /* 38559adf08eSdyoung * PUBLIC MEMBERS: these are used by machine-independent code. 38659adf08eSdyoung */ 38759adf08eSdyoung bus_size_t dm_maxsegsz; /* largest possible segment */ 38859adf08eSdyoung bus_size_t dm_mapsize; /* size of the mapping */ 38959adf08eSdyoung int dm_nsegs; /* # valid segments in mapping */ 39059adf08eSdyoung bus_dma_segment_t dm_segs[1]; /* segments; variable length */ 39159adf08eSdyoung }; 39259adf08eSdyoung 39359adf08eSdyoung #endif /* _POWERPC_BUS_DEFS_H_ */ 394