~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/mm/ioremap.c

Version: ~ [ linux-6.0-rc1 ] ~ [ linux-5.19.1 ] ~ [ linux-5.18.17 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.60 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.136 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.210 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.255 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.290 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.325 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Re-map IO memory to kernel address space so that we can access it.
  4  * This is needed for high PCI addresses that aren't mapped in the
  5  * 640k-1MB IO memory area on PC's
  6  *
  7  * (C) Copyright 1995 1996 Linus Torvalds
  8  */
  9 #include <linux/vmalloc.h>
 10 #include <linux/mm.h>
 11 #include <linux/sched.h>
 12 #include <linux/io.h>
 13 #include <linux/export.h>
 14 #include <asm/cacheflush.h>
 15 
 16 #include "pgalloc-track.h"
 17 
 18 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
 19 static unsigned int __ro_after_init iomap_max_page_shift = BITS_PER_LONG - 1;
 20 
 21 static int __init set_nohugeiomap(char *str)
 22 {
 23         iomap_max_page_shift = PAGE_SHIFT;
 24         return 0;
 25 }
 26 early_param("nohugeiomap", set_nohugeiomap);
 27 #else /* CONFIG_HAVE_ARCH_HUGE_VMAP */
 28 static const unsigned int iomap_max_page_shift = PAGE_SHIFT;
 29 #endif  /* CONFIG_HAVE_ARCH_HUGE_VMAP */
 30 
 31 int ioremap_page_range(unsigned long addr,
 32                        unsigned long end, phys_addr_t phys_addr, pgprot_t prot)
 33 {
 34         return vmap_range(addr, end, phys_addr, prot, iomap_max_page_shift);
 35 }
 36 
 37 #ifdef CONFIG_GENERIC_IOREMAP
 38 void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
 39 {
 40         unsigned long offset, vaddr;
 41         phys_addr_t last_addr;
 42         struct vm_struct *area;
 43 
 44         /* Disallow wrap-around or zero size */
 45         last_addr = addr + size - 1;
 46         if (!size || last_addr < addr)
 47                 return NULL;
 48 
 49         /* Page-align mappings */
 50         offset = addr & (~PAGE_MASK);
 51         addr -= offset;
 52         size = PAGE_ALIGN(size + offset);
 53 
 54         area = get_vm_area_caller(size, VM_IOREMAP,
 55                         __builtin_return_address(0));
 56         if (!area)
 57                 return NULL;
 58         vaddr = (unsigned long)area->addr;
 59 
 60         if (ioremap_page_range(vaddr, vaddr + size, addr, __pgprot(prot))) {
 61                 free_vm_area(area);
 62                 return NULL;
 63         }
 64 
 65         return (void __iomem *)(vaddr + offset);
 66 }
 67 EXPORT_SYMBOL(ioremap_prot);
 68 
 69 void iounmap(volatile void __iomem *addr)
 70 {
 71         vunmap((void *)((unsigned long)addr & PAGE_MASK));
 72 }
 73 EXPORT_SYMBOL(iounmap);
 74 #endif /* CONFIG_GENERIC_IOREMAP */
 75 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp