cregit-Linux how code gets into the kernel

Release 4.7 include/linux/io-mapping.h

Directory: include/linux
/*
 * Copyright © 2008 Keith Packard <keithp@keithp.com>
 *
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef _LINUX_IO_MAPPING_H

#define _LINUX_IO_MAPPING_H

#include <linux/types.h>
#include <linux/slab.h>
#include <linux/bug.h>
#include <linux/io.h>
#include <asm/page.h>

/*
 * The io_mapping mechanism provides an abstraction for mapping
 * individual pages from an io device to the CPU in an efficient fashion.
 *
 * See Documentation/io-mapping.txt
 */

#ifdef CONFIG_HAVE_ATOMIC_IOMAP

#include <asm/iomap.h>


struct io_mapping {
	
resource_size_t base;
	
unsigned long size;
	
pgprot_t prot;
};

/*
 * For small address space machines, mapping large objects
 * into the kernel virtual space isn't practical. Where
 * available, use fixmap support to dynamically map pages
 * of the object at run time.
 */


static inline struct io_mapping * io_mapping_create_wc(resource_size_t base, unsigned long size) { struct io_mapping *iomap; pgprot_t prot; iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); if (!iomap) goto out_err; if (iomap_create_wc(base, size, &prot)) goto out_free; iomap->base = base; iomap->size = size; iomap->prot = prot; return iomap; out_free: kfree(iomap); out_err: return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
venkatesh pallipadivenkatesh pallipadi7479.57%266.67%
keith packardkeith packard1920.43%133.33%
Total93100.00%3100.00%


static inline void io_mapping_free(struct io_mapping *mapping) { iomap_free(mapping->base, mapping->size); kfree(mapping); }

Contributors

PersonTokensPropCommitsCommitProp
venkatesh pallipadivenkatesh pallipadi1864.29%266.67%
keith packardkeith packard1035.71%133.33%
Total28100.00%3100.00%

/* Atomic map/unmap */
static inline void __iomem * io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) { resource_size_t phys_addr; unsigned long pfn; BUG_ON(offset >= mapping->size); phys_addr = mapping->base + offset; pfn = (unsigned long) (phys_addr >> PAGE_SHIFT); return iomap_atomic_prot_pfn(pfn, mapping->prot); }

Contributors

PersonTokensPropCommitsCommitProp
venkatesh pallipadivenkatesh pallipadi3656.25%125.00%
keith packardkeith packard2742.19%250.00%
francisco jerezfrancisco jerez11.56%125.00%
Total64100.00%4100.00%


static inline void io_mapping_unmap_atomic(void __iomem *vaddr) { iounmap_atomic(vaddr); }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard1694.12%266.67%
francisco jerezfrancisco jerez15.88%133.33%
Total17100.00%3100.00%


static inline void __iomem * io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) { resource_size_t phys_addr; BUG_ON(offset >= mapping->size); phys_addr = mapping->base + offset; return ioremap_wc(phys_addr, PAGE_SIZE); }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard2758.70%240.00%
venkatesh pallipadivenkatesh pallipadi1839.13%240.00%
francisco jerezfrancisco jerez12.17%120.00%
Total46100.00%5100.00%


static inline void io_mapping_unmap(void __iomem *vaddr) { iounmap(vaddr); }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard1694.12%266.67%
francisco jerezfrancisco jerez15.88%133.33%
Total17100.00%3100.00%

#else #include <linux/uaccess.h> /* this struct isn't actually defined anywhere */ struct io_mapping; /* Create the io_mapping object*/
static inline struct io_mapping * io_mapping_create_wc(resource_size_t base, unsigned long size) { return (struct io_mapping __force *) ioremap_wc(base, size); }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard2893.33%250.00%
venkatesh pallipadivenkatesh pallipadi13.33%125.00%
francisco jerezfrancisco jerez13.33%125.00%
Total30100.00%4100.00%


static inline void io_mapping_free(struct io_mapping *mapping) { iounmap((void __force __iomem *) mapping); }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard1773.91%266.67%
francisco jerezfrancisco jerez626.09%133.33%
Total23100.00%3100.00%

/* Atomic map/unmap */
static inline void __iomem * io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) { preempt_disable(); pagefault_disable(); return ((char __force __iomem *) mapping) + offset; }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard2875.68%240.00%
david hildenbranddavid hildenbrand38.11%120.00%
francisco jerezfrancisco jerez38.11%120.00%
daniel vetterdaniel vetter38.11%120.00%
Total37100.00%5100.00%


static inline void io_mapping_unmap_atomic(void __iomem *vaddr) { pagefault_enable(); preempt_enable(); }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard950.00%125.00%
daniel vetterdaniel vetter527.78%125.00%
david hildenbranddavid hildenbrand316.67%125.00%
francisco jerezfrancisco jerez15.56%125.00%
Total18100.00%4100.00%

/* Non-atomic map/unmap */
static inline void __iomem * io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) { return ((char __force __iomem *) mapping) + offset; }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard2890.32%266.67%
francisco jerezfrancisco jerez39.68%133.33%
Total31100.00%3100.00%


static inline void io_mapping_unmap(void __iomem *vaddr) { }

Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard1090.91%266.67%
francisco jerezfrancisco jerez19.09%133.33%
Total11100.00%3100.00%

#endif /* HAVE_ATOMIC_IOMAP */ #endif /* _LINUX_IO_MAPPING_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
keith packardkeith packard26655.53%215.38%
venkatesh pallipadivenkatesh pallipadi16634.66%323.08%
francisco jerezfrancisco jerez193.97%17.69%
daniel vetterdaniel vetter112.30%17.69%
david hildenbranddavid hildenbrand61.25%17.69%
dave airliedave airlie30.63%17.69%
tejun heotejun heo30.63%17.69%
paul gortmakerpaul gortmaker30.63%17.69%
paul bollepaul bolle10.21%17.69%
dan williamsdan williams10.21%17.69%
Total479100.00%13100.00%
Directory: include/linux
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}