1
/*********************************************************
2
* Copyright (C) 2008 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation version 2 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*********************************************************/
19
#ifndef __COMPAT_PCI_MAPPING_H__
20
#define __COMPAT_PCI_MAPPING_H__
22
#include <asm/types.h>
24
#include <linux/pci.h>
26
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,41)
27
typedef u32 dma_addr_t;
30
get_order(unsigned long size)
34
size = (size - 1) >> (PAGE_SHIFT - 1);
44
compat_pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
46
void *ptr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
49
*dma_handle = virt_to_phys(ptr);
55
compat_pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr,
56
dma_addr_t dma_handle)
58
free_pages((unsigned long)vaddr, get_order(size));
61
static inline dma_addr_t
62
compat_pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
64
return virt_to_phys(ptr);
68
compat_pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
69
size_t size, int direction)
74
#define compat_pci_alloc_consistent(hwdev, size, dma_handle) \
75
pci_alloc_consistent(hwdev, size, dma_handle)
76
#define compat_pci_free_consistent(hwdev, size, vaddr, dma_handle) \
77
pci_free_consistent(hwdev, size, vaddr, dma_handle)
78
#define compat_pci_map_single(hwdev, ptr, size, direction) \
79
pci_map_single(hwdev, ptr, size, direction)
80
#define compat_pci_unmap_single(hwdev, dma_addr, size, direction) \
81
pci_unmap_single(hwdev, dma_addr, size, direction)