cregit-Linux how code gets into the kernel

Release 4.12 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
 */


struct io_mapping {
	
resource_size_t base;
	
unsigned long size;
	
pgprot_t prot;
	
void __iomem *iomem;
};

#ifdef CONFIG_HAVE_ATOMIC_IOMAP

#include <asm/iomap.h>
/*
 * 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_init_wc(struct io_mapping *iomap, resource_size_t base, unsigned long size) { pgprot_t prot; if (iomap_create_wc(base, size, &prot)) return NULL; iomap->base = base; iomap->size = size; iomap->prot = prot; return iomap; }

Contributors

PersonTokensPropCommitsCommitProp
Venkatesh Pallipadi3660.00%250.00%
Keith Packard1525.00%125.00%
Chris Wilson915.00%125.00%
Total60100.00%4100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Venkatesh Pallipadi1356.52%250.00%
Keith Packard939.13%125.00%
Chris Wilson14.35%125.00%
Total23100.00%4100.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 Pallipadi3656.25%125.00%
Keith Packard2742.19%250.00%
Francisco Jerez11.56%125.00%
Total64100.00%4100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard1694.12%266.67%
Francisco Jerez15.88%133.33%
Total17100.00%3100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard2652.00%233.33%
Venkatesh Pallipadi1836.00%233.33%
Chris Wilson510.00%116.67%
Francisco Jerez12.00%116.67%
Total50100.00%6100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard1694.12%266.67%
Francisco Jerez15.88%133.33%
Total17100.00%3100.00%

#else #include <linux/uaccess.h> #include <asm/pgtable.h> /* Create the io_mapping object*/
static inline struct io_mapping * io_mapping_init_wc(struct io_mapping *iomap, resource_size_t base, unsigned long size) { iomap->base = base; iomap->size = size; iomap->iomem = ioremap_wc(base, size); #if defined(pgprot_noncached_wc) /* archs can't agree on a name ... */ iomap->prot = pgprot_noncached_wc(PAGE_KERNEL); #elif defined(pgprot_writecombine) iomap->prot = pgprot_writecombine(PAGE_KERNEL); #else iomap->prot = pgprot_noncached(PAGE_KERNEL); #endif return iomap; }

Contributors

PersonTokensPropCommitsCommitProp
Daniel Vetter3538.46%116.67%
Chris Wilson3437.36%233.33%
Keith Packard2123.08%233.33%
Venkatesh Pallipadi11.10%116.67%
Total91100.00%6100.00%


static inline void io_mapping_fini(struct io_mapping *mapping) { iounmap(mapping->iomem); }

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard1684.21%266.67%
Chris Wilson315.79%133.33%
Total19100.00%3100.00%

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

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard2172.41%250.00%
Chris Wilson724.14%125.00%
Francisco Jerez13.45%125.00%
Total29100.00%4100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard872.73%133.33%
Chris Wilson218.18%133.33%
Francisco Jerez19.09%133.33%
Total11100.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 io_mapping_map_wc(mapping, offset, PAGE_SIZE); }

Contributors

PersonTokensPropCommitsCommitProp
Keith Packard2058.82%250.00%
Chris Wilson1338.24%125.00%
Francisco Jerez12.94%125.00%
Total34100.00%4100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Chris Wilson1460.87%133.33%
Keith Packard834.78%133.33%
Francisco Jerez14.35%133.33%
Total23100.00%3100.00%

#endif /* HAVE_ATOMIC_IOMAP */
static inline struct io_mapping * io_mapping_create_wc(resource_size_t base, unsigned long size) { struct io_mapping *iomap; iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); if (!iomap) return NULL; if (!io_mapping_init_wc(iomap, base, size)) { kfree(iomap); return NULL; } return iomap; }

Contributors

PersonTokensPropCommitsCommitProp
Chris Wilson67100.00%1100.00%
Total67100.00%1100.00%


static inline void io_mapping_free(struct io_mapping *iomap) { io_mapping_fini(iomap); kfree(iomap); }

Contributors

PersonTokensPropCommitsCommitProp
Chris Wilson22100.00%1100.00%
Total22100.00%1100.00%

#endif /* _LINUX_IO_MAPPING_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
Keith Packard22938.49%213.33%
Chris Wilson19332.44%320.00%
Venkatesh Pallipadi11920.00%320.00%
Daniel Vetter386.39%213.33%
Francisco Jerez81.34%16.67%
Tejun Heo30.50%16.67%
Paul Gortmaker30.50%16.67%
Dan J Williams10.17%16.67%
Paul Bolle10.17%16.67%
Total595100.00%15100.00%
Directory: include/linux
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.