xref: /dflybsd-src/sys/dev/drm/include/asm/pci-dma-compat.h (revision 00f65b9160da5bcc696004563d3e1ddb17905ad4)
134b686b2SFrançois Tigeot /*
234b686b2SFrançois Tigeot  * Copyright (c) 2015 François Tigeot
3dd05fcb0SMatthew Dillon  * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
434b686b2SFrançois Tigeot  * All rights reserved.
534b686b2SFrançois Tigeot  *
634b686b2SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
734b686b2SFrançois Tigeot  * modification, are permitted provided that the following conditions
834b686b2SFrançois Tigeot  * are met:
934b686b2SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
1034b686b2SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
1134b686b2SFrançois Tigeot  *    disclaimer.
1234b686b2SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
1334b686b2SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
1434b686b2SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
1534b686b2SFrançois Tigeot  *
1634b686b2SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1734b686b2SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1834b686b2SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1934b686b2SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2034b686b2SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2134b686b2SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2234b686b2SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2334b686b2SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2434b686b2SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2534b686b2SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2634b686b2SFrançois Tigeot  */
2734b686b2SFrançois Tigeot 
2834b686b2SFrançois Tigeot #ifndef _ASM_PCI_DMA_COMPAT_H_
2934b686b2SFrançois Tigeot #define _ASM_PCI_DMA_COMPAT_H_
3034b686b2SFrançois Tigeot 
3134b686b2SFrançois Tigeot #include <vm/vm_page.h>
3234b686b2SFrançois Tigeot 
3334b686b2SFrançois Tigeot static inline dma_addr_t
pci_map_page(struct pci_dev * hwdev,struct page * page,unsigned long offset,size_t size,int direction)34*00f65b91SFrançois Tigeot pci_map_page(struct pci_dev *hwdev, struct page *page,
3534b686b2SFrançois Tigeot 	     unsigned long offset, size_t size, int direction)
3634b686b2SFrançois Tigeot {
37*00f65b91SFrançois Tigeot 	return VM_PAGE_TO_PHYS((struct vm_page *)page) + offset;
3834b686b2SFrançois Tigeot }
3934b686b2SFrançois Tigeot 
4034b686b2SFrançois Tigeot static inline void
pci_unmap_page(struct pci_dev * hwdev,dma_addr_t dma_address,size_t size,int direction)4134b686b2SFrançois Tigeot pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
4234b686b2SFrançois Tigeot 	       size_t size, int direction)
4334b686b2SFrançois Tigeot {
4434b686b2SFrançois Tigeot }
4534b686b2SFrançois Tigeot 
46dd05fcb0SMatthew Dillon static inline int
pci_dma_mapping_error(struct pci_dev * hwdev,dma_addr_t dma_address)47dd05fcb0SMatthew Dillon pci_dma_mapping_error(struct pci_dev *hwdev, dma_addr_t dma_address)
48dd05fcb0SMatthew Dillon {
49dd05fcb0SMatthew Dillon 	return (dma_address == 0);
50dd05fcb0SMatthew Dillon }
51dd05fcb0SMatthew Dillon 
5234b686b2SFrançois Tigeot #endif	/* _ASM_PCI_DMA_COMPAT_H_ */
53