The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/lib/pci_iomap.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Implement the default iomap interfaces
    3  *
    4  * (C) Copyright 2004 Linus Torvalds
    5  */
    6 #include <linux/pci.h>
    7 #include <linux/io.h>
    8 
    9 #include <linux/export.h>
   10 
   11 #ifdef CONFIG_PCI
   12 /**
   13  * pci_iomap - create a virtual mapping cookie for a PCI BAR
   14  * @dev: PCI device that owns the BAR
   15  * @bar: BAR number
   16  * @maxlen: length of the memory to map
   17  *
   18  * Using this function you will get a __iomem address to your device BAR.
   19  * You can access it using ioread*() and iowrite*(). These functions hide
   20  * the details if this is a MMIO or PIO address space and will just do what
   21  * you expect from them in the correct way.
   22  *
   23  * @maxlen specifies the maximum length to map. If you want to get access to
   24  * the complete BAR without checking for its length first, pass %0 here.
   25  * */
   26 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
   27 {
   28         resource_size_t start = pci_resource_start(dev, bar);
   29         resource_size_t len = pci_resource_len(dev, bar);
   30         unsigned long flags = pci_resource_flags(dev, bar);
   31 
   32         if (!len || !start)
   33                 return NULL;
   34         if (maxlen && len > maxlen)
   35                 len = maxlen;
   36         if (flags & IORESOURCE_IO)
   37                 return __pci_ioport_map(dev, start, len);
   38         if (flags & IORESOURCE_MEM) {
   39                 if (flags & IORESOURCE_CACHEABLE)
   40                         return ioremap(start, len);
   41                 return ioremap_nocache(start, len);
   42         }
   43         /* What? */
   44         return NULL;
   45 }
   46 
   47 EXPORT_SYMBOL(pci_iomap);
   48 #endif /* CONFIG_PCI */

Cache object: 263ce6d76bb6d1caf3b5fd1e82029168


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.