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

TOMOYO Linux Cross Reference
Linux/arch/cris/mm/ioremap.c

Version: ~ [ linux-5.7-rc7 ] ~ [ linux-5.6.14 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.42 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.124 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.181 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.224 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.224 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.84 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * arch/cris/mm/ioremap.c
  3  *
  4  * Re-map IO memory to kernel address space so that we can access it.
  5  * Needed for memory-mapped I/O devices mapped outside our normal DRAM
  6  * window (that is, all memory-mapped I/O devices).
  7  *
  8  * (C) Copyright 1995 1996 Linus Torvalds
  9  * CRIS-port by Axis Communications AB
 10  */
 11 
 12 #include <linux/vmalloc.h>
 13 #include <linux/io.h>
 14 #include <asm/pgalloc.h>
 15 #include <arch/memmap.h>
 16 
 17 /*
 18  * Generic mapping function (not visible outside):
 19  */
 20 
 21 /*
 22  * Remap an arbitrary physical address space into the kernel virtual
 23  * address space. Needed when the kernel wants to access high addresses
 24  * directly.
 25  *
 26  * NOTE! We need to allow non-page-aligned mappings too: we will obviously
 27  * have to convert them into an offset in a page-aligned mapping, but the
 28  * caller shouldn't need to know that small detail.
 29  */
 30 void __iomem * __ioremap_prot(unsigned long phys_addr, unsigned long size, pgprot_t prot)
 31 {
 32         void __iomem * addr;
 33         struct vm_struct * area;
 34         unsigned long offset, last_addr;
 35 
 36         /* Don't allow wraparound or zero size */
 37         last_addr = phys_addr + size - 1;
 38         if (!size || last_addr < phys_addr)
 39                 return NULL;
 40 
 41         /*
 42          * Mappings have to be page-aligned
 43          */
 44         offset = phys_addr & ~PAGE_MASK;
 45         phys_addr &= PAGE_MASK;
 46         size = PAGE_ALIGN(last_addr+1) - phys_addr;
 47 
 48         /*
 49          * Ok, go for it..
 50          */
 51         area = get_vm_area(size, VM_IOREMAP);
 52         if (!area)
 53                 return NULL;
 54         addr = (void __iomem *)area->addr;
 55         if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
 56                                phys_addr, prot)) {
 57                 vfree((void __force *)addr);
 58                 return NULL;
 59         }
 60         return (void __iomem *) (offset + (char __iomem *)addr);
 61 }
 62 
 63 void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
 64 {
 65         return __ioremap_prot(phys_addr, size,
 66                               __pgprot(_PAGE_PRESENT | __READABLE |
 67                                        __WRITEABLE | _PAGE_GLOBAL |
 68                                        _PAGE_KERNEL | flags));
 69 }
 70 
 71 /**
 72  * ioremap_nocache     -   map bus memory into CPU space
 73  * @offset:    bus address of the memory
 74  * @size:      size of the resource to map
 75  *
 76  * Must be freed with iounmap.
 77  */
 78 
 79 void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
 80 {
 81         return __ioremap(phys_addr | MEM_NON_CACHEABLE, size, 0);
 82 }
 83 
 84 void iounmap(volatile void __iomem *addr)
 85 {
 86         if (addr > high_memory)
 87                 return vfree((void *) (PAGE_MASK & (unsigned long) addr));
 88 }
 89 

~ [ 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