This source file includes following definitions.
- __ioremap
- iounmap
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 #include <linux/vmalloc.h>
  11 #include <linux/errno.h>
  12 #include <linux/module.h>
  13 #include <linux/io.h>
  14 #include <asm/pgalloc.h>
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 
  28 void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
  29 {
  30         void __iomem *addr;
  31         struct vm_struct *area;
  32         unsigned long offset, last_addr;
  33         pgprot_t pgprot;
  34 
  35 #ifdef CONFIG_EISA
  36         unsigned long end = phys_addr + size - 1;
  37         
  38         if ((phys_addr >= 0x00080000 && end < 0x000fffff) ||
  39             (phys_addr >= 0x00500000 && end < 0x03bfffff)) {
  40                 phys_addr |= F_EXTEND(0xfc000000);
  41                 flags |= _PAGE_NO_CACHE;
  42         }
  43 #endif
  44 
  45         
  46         last_addr = phys_addr + size - 1;
  47         if (!size || last_addr < phys_addr)
  48                 return NULL;
  49 
  50         
  51 
  52 
  53         if (phys_addr < virt_to_phys(high_memory)) {
  54                 char *t_addr, *t_end;
  55                 struct page *page;
  56 
  57                 t_addr = __va(phys_addr);
  58                 t_end = t_addr + (size - 1);
  59            
  60                 for (page = virt_to_page(t_addr); 
  61                      page <= virt_to_page(t_end); page++) {
  62                         if(!PageReserved(page))
  63                                 return NULL;
  64                 }
  65         }
  66 
  67         pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY |
  68                           _PAGE_ACCESSED | flags);
  69 
  70         
  71 
  72 
  73         offset = phys_addr & ~PAGE_MASK;
  74         phys_addr &= PAGE_MASK;
  75         size = PAGE_ALIGN(last_addr + 1) - phys_addr;
  76 
  77         
  78 
  79 
  80         area = get_vm_area(size, VM_IOREMAP);
  81         if (!area)
  82                 return NULL;
  83 
  84         addr = (void __iomem *) area->addr;
  85         if (ioremap_page_range((unsigned long)addr, (unsigned long)addr + size,
  86                                phys_addr, pgprot)) {
  87                 vunmap(addr);
  88                 return NULL;
  89         }
  90 
  91         return (void __iomem *) (offset + (char __iomem *)addr);
  92 }
  93 EXPORT_SYMBOL(__ioremap);
  94 
  95 void iounmap(const volatile void __iomem *io_addr)
  96 {
  97         unsigned long addr = (unsigned long)io_addr & PAGE_MASK;
  98 
  99         if (is_vmalloc_addr((void *)addr))
 100                 vunmap((void *)addr);
 101 }
 102 EXPORT_SYMBOL(iounmap);