Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1 | /* |
| 2 | * This file contains the routines setting up the linux page tables. |
| 3 | * -- paulus |
| 4 | * |
| 5 | * Derived from arch/ppc/mm/init.c: |
| 6 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
| 7 | * |
| 8 | * Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au) |
| 9 | * and Cort Dougan (PReP) (cort@cs.nmt.edu) |
| 10 | * Copyright (C) 1996 Paul Mackerras |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 11 | * |
| 12 | * Derived from "arch/i386/mm/init.c" |
| 13 | * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License |
| 17 | * as published by the Free Software Foundation; either version |
| 18 | * 2 of the License, or (at your option) any later version. |
| 19 | * |
| 20 | */ |
| 21 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 22 | #include <linux/kernel.h> |
| 23 | #include <linux/module.h> |
| 24 | #include <linux/types.h> |
| 25 | #include <linux/mm.h> |
| 26 | #include <linux/vmalloc.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/highmem.h> |
| 29 | |
| 30 | #include <asm/pgtable.h> |
| 31 | #include <asm/pgalloc.h> |
Kumar Gala | 2c419bd | 2008-04-23 23:05:20 +1000 | [diff] [blame] | 32 | #include <asm/fixmap.h> |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 33 | #include <asm/io.h> |
| 34 | |
| 35 | #include "mmu_decl.h" |
| 36 | |
| 37 | unsigned long ioremap_base; |
| 38 | unsigned long ioremap_bot; |
Olaf Hering | 920573b | 2006-03-14 21:21:11 +0100 | [diff] [blame] | 39 | EXPORT_SYMBOL(ioremap_bot); /* aka VMALLOC_END */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 40 | |
| 41 | #if defined(CONFIG_6xx) || defined(CONFIG_POWER3) |
| 42 | #define HAVE_BATS 1 |
| 43 | #endif |
| 44 | |
| 45 | #if defined(CONFIG_FSL_BOOKE) |
| 46 | #define HAVE_TLBCAM 1 |
| 47 | #endif |
| 48 | |
| 49 | extern char etext[], _stext[]; |
| 50 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 51 | #ifdef HAVE_BATS |
Becky Bruce | 7c5c432 | 2008-06-14 09:41:42 +1000 | [diff] [blame] | 52 | extern phys_addr_t v_mapped_by_bats(unsigned long va); |
| 53 | extern unsigned long p_mapped_by_bats(phys_addr_t pa); |
| 54 | void setbat(int index, unsigned long virt, phys_addr_t phys, |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 55 | unsigned int size, int flags); |
| 56 | |
| 57 | #else /* !HAVE_BATS */ |
| 58 | #define v_mapped_by_bats(x) (0UL) |
| 59 | #define p_mapped_by_bats(x) (0UL) |
| 60 | #endif /* HAVE_BATS */ |
| 61 | |
| 62 | #ifdef HAVE_TLBCAM |
| 63 | extern unsigned int tlbcam_index; |
| 64 | extern unsigned long v_mapped_by_tlbcam(unsigned long va); |
| 65 | extern unsigned long p_mapped_by_tlbcam(unsigned long pa); |
| 66 | #else /* !HAVE_TLBCAM */ |
| 67 | #define v_mapped_by_tlbcam(x) (0UL) |
| 68 | #define p_mapped_by_tlbcam(x) (0UL) |
| 69 | #endif /* HAVE_TLBCAM */ |
| 70 | |
| 71 | #ifdef CONFIG_PTE_64BIT |
Becky Bruce | 4ee7084 | 2008-09-24 11:01:24 -0500 | [diff] [blame] | 72 | /* Some processors use an 8kB pgdir because they have 8-byte Linux PTEs. */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 73 | #define PGDIR_ORDER 1 |
| 74 | #else |
| 75 | #define PGDIR_ORDER 0 |
| 76 | #endif |
| 77 | |
| 78 | pgd_t *pgd_alloc(struct mm_struct *mm) |
| 79 | { |
| 80 | pgd_t *ret; |
| 81 | |
| 82 | ret = (pgd_t *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, PGDIR_ORDER); |
| 83 | return ret; |
| 84 | } |
| 85 | |
Benjamin Herrenschmidt | 5e54197 | 2008-02-04 22:29:14 -0800 | [diff] [blame] | 86 | void pgd_free(struct mm_struct *mm, pgd_t *pgd) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 87 | { |
| 88 | free_pages((unsigned long)pgd, PGDIR_ORDER); |
| 89 | } |
| 90 | |
Kumar Gala | f1aed92 | 2007-05-23 07:49:37 -0500 | [diff] [blame] | 91 | __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 92 | { |
| 93 | pte_t *pte; |
| 94 | extern int mem_init_done; |
| 95 | extern void *early_get_page(void); |
| 96 | |
| 97 | if (mem_init_done) { |
| 98 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); |
| 99 | } else { |
| 100 | pte = (pte_t *)early_get_page(); |
| 101 | if (pte) |
| 102 | clear_page(pte); |
| 103 | } |
| 104 | return pte; |
| 105 | } |
| 106 | |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 107 | pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 108 | { |
| 109 | struct page *ptepage; |
| 110 | |
| 111 | #ifdef CONFIG_HIGHPTE |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 112 | gfp_t flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT | __GFP_ZERO; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 113 | #else |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 114 | gfp_t flags = GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 115 | #endif |
| 116 | |
| 117 | ptepage = alloc_pages(flags, 0); |
Martin Schwidefsky | 2f569af | 2008-02-08 04:22:04 -0800 | [diff] [blame] | 118 | if (!ptepage) |
| 119 | return NULL; |
| 120 | pgtable_page_ctor(ptepage); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 121 | return ptepage; |
| 122 | } |
| 123 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 124 | void __iomem * |
| 125 | ioremap(phys_addr_t addr, unsigned long size) |
| 126 | { |
Benjamin Herrenschmidt | a1f242f | 2008-07-23 21:27:08 -0700 | [diff] [blame] | 127 | return __ioremap(addr, size, _PAGE_NO_CACHE | _PAGE_GUARDED); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 128 | } |
Olaf Hering | 920573b | 2006-03-14 21:21:11 +0100 | [diff] [blame] | 129 | EXPORT_SYMBOL(ioremap); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 130 | |
| 131 | void __iomem * |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 132 | ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags) |
| 133 | { |
Benjamin Herrenschmidt | a1f242f | 2008-07-23 21:27:08 -0700 | [diff] [blame] | 134 | /* writeable implies dirty for kernel addresses */ |
| 135 | if (flags & _PAGE_RW) |
| 136 | flags |= _PAGE_DIRTY | _PAGE_HWWRITE; |
| 137 | |
| 138 | /* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */ |
| 139 | flags &= ~(_PAGE_USER | _PAGE_EXEC | _PAGE_HWEXEC); |
| 140 | |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 141 | return __ioremap(addr, size, flags); |
| 142 | } |
| 143 | EXPORT_SYMBOL(ioremap_flags); |
| 144 | |
| 145 | void __iomem * |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 146 | __ioremap(phys_addr_t addr, unsigned long size, unsigned long flags) |
| 147 | { |
| 148 | unsigned long v, i; |
| 149 | phys_addr_t p; |
| 150 | int err; |
| 151 | |
Benjamin Herrenschmidt | a1f242f | 2008-07-23 21:27:08 -0700 | [diff] [blame] | 152 | /* Make sure we have the base flags */ |
| 153 | if ((flags & _PAGE_PRESENT) == 0) |
| 154 | flags |= _PAGE_KERNEL; |
| 155 | |
| 156 | /* Non-cacheable page cannot be coherent */ |
| 157 | if (flags & _PAGE_NO_CACHE) |
| 158 | flags &= ~_PAGE_COHERENT; |
| 159 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 160 | /* |
| 161 | * Choose an address to map it to. |
| 162 | * Once the vmalloc system is running, we use it. |
| 163 | * Before then, we use space going down from ioremap_base |
| 164 | * (ioremap_bot records where we're up to). |
| 165 | */ |
| 166 | p = addr & PAGE_MASK; |
| 167 | size = PAGE_ALIGN(addr + size) - p; |
| 168 | |
| 169 | /* |
| 170 | * If the address lies within the first 16 MB, assume it's in ISA |
| 171 | * memory space |
| 172 | */ |
| 173 | if (p < 16*1024*1024) |
| 174 | p += _ISA_MEM_BASE; |
| 175 | |
Anton Vorontsov | 01695a9 | 2008-12-17 10:09:10 +0000 | [diff] [blame^] | 176 | #ifndef CONFIG_CRASH_DUMP |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 177 | /* |
| 178 | * Don't allow anybody to remap normal RAM that we're using. |
| 179 | * mem_init() sets high_memory so only do the check after that. |
| 180 | */ |
Paul Mackerras | 7c8c6b9 | 2005-10-06 12:23:33 +1000 | [diff] [blame] | 181 | if (mem_init_done && (p < virt_to_phys(high_memory))) { |
David Gibson | 37f01d6 | 2007-04-24 15:05:18 +1000 | [diff] [blame] | 182 | printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n", |
| 183 | (unsigned long long)p, __builtin_return_address(0)); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 184 | return NULL; |
| 185 | } |
Anton Vorontsov | 01695a9 | 2008-12-17 10:09:10 +0000 | [diff] [blame^] | 186 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 187 | |
| 188 | if (size == 0) |
| 189 | return NULL; |
| 190 | |
| 191 | /* |
| 192 | * Is it already mapped? Perhaps overlapped by a previous |
| 193 | * BAT mapping. If the whole area is mapped then we're done, |
| 194 | * otherwise remap it since we want to keep the virt addrs for |
| 195 | * each request contiguous. |
| 196 | * |
| 197 | * We make the assumption here that if the bottom and top |
| 198 | * of the range we want are mapped then it's mapped to the |
| 199 | * same virt address (and this is contiguous). |
| 200 | * -- Cort |
| 201 | */ |
| 202 | if ((v = p_mapped_by_bats(p)) /*&& p_mapped_by_bats(p+size-1)*/ ) |
| 203 | goto out; |
| 204 | |
| 205 | if ((v = p_mapped_by_tlbcam(p))) |
| 206 | goto out; |
| 207 | |
| 208 | if (mem_init_done) { |
| 209 | struct vm_struct *area; |
| 210 | area = get_vm_area(size, VM_IOREMAP); |
| 211 | if (area == 0) |
| 212 | return NULL; |
| 213 | v = (unsigned long) area->addr; |
| 214 | } else { |
| 215 | v = (ioremap_bot -= size); |
| 216 | } |
| 217 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 218 | /* |
| 219 | * Should check if it is a candidate for a BAT mapping |
| 220 | */ |
| 221 | |
| 222 | err = 0; |
| 223 | for (i = 0; i < size && err == 0; i += PAGE_SIZE) |
| 224 | err = map_page(v+i, p+i, flags); |
| 225 | if (err) { |
| 226 | if (mem_init_done) |
| 227 | vunmap((void *)v); |
| 228 | return NULL; |
| 229 | } |
| 230 | |
| 231 | out: |
| 232 | return (void __iomem *) (v + ((unsigned long)addr & ~PAGE_MASK)); |
| 233 | } |
Olaf Hering | 920573b | 2006-03-14 21:21:11 +0100 | [diff] [blame] | 234 | EXPORT_SYMBOL(__ioremap); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 235 | |
| 236 | void iounmap(volatile void __iomem *addr) |
| 237 | { |
| 238 | /* |
| 239 | * If mapped by BATs then there is nothing to do. |
| 240 | * Calling vfree() generates a benign warning. |
| 241 | */ |
| 242 | if (v_mapped_by_bats((unsigned long)addr)) return; |
| 243 | |
| 244 | if (addr > high_memory && (unsigned long) addr < ioremap_bot) |
| 245 | vunmap((void *) (PAGE_MASK & (unsigned long)addr)); |
| 246 | } |
Olaf Hering | 920573b | 2006-03-14 21:21:11 +0100 | [diff] [blame] | 247 | EXPORT_SYMBOL(iounmap); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 248 | |
Benjamin Herrenschmidt | 68a6435 | 2006-11-13 09:27:39 +1100 | [diff] [blame] | 249 | int map_page(unsigned long va, phys_addr_t pa, int flags) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 250 | { |
| 251 | pmd_t *pd; |
| 252 | pte_t *pg; |
| 253 | int err = -ENOMEM; |
| 254 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 255 | /* Use upper 10 bits of VA to index the first level map */ |
David Gibson | d1953c8 | 2007-05-08 12:46:49 +1000 | [diff] [blame] | 256 | pd = pmd_offset(pud_offset(pgd_offset_k(va), va), va); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 257 | /* Use middle 10 bits of VA to index the second-level map */ |
Paul Mackerras | e2f2e58 | 2005-10-31 14:40:03 +1100 | [diff] [blame] | 258 | pg = pte_alloc_kernel(pd, va); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 259 | if (pg != 0) { |
| 260 | err = 0; |
Benjamin Herrenschmidt | 3be4e69 | 2007-04-12 15:30:21 +1000 | [diff] [blame] | 261 | /* The PTE should never be already set nor present in the |
| 262 | * hash table |
| 263 | */ |
| 264 | BUG_ON(pte_val(*pg) & (_PAGE_PRESENT | _PAGE_HASHPTE)); |
| 265 | set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT, |
| 266 | __pgprot(flags))); |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 267 | } |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 268 | return err; |
| 269 | } |
| 270 | |
| 271 | /* |
Becky Bruce | 4ee7084 | 2008-09-24 11:01:24 -0500 | [diff] [blame] | 272 | * Map in a big chunk of physical memory starting at KERNELBASE. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 273 | */ |
| 274 | void __init mapin_ram(void) |
| 275 | { |
Kumar Gala | 99c62dd7 | 2008-04-16 05:52:21 +1000 | [diff] [blame] | 276 | unsigned long v, s, f; |
| 277 | phys_addr_t p; |
Benjamin Herrenschmidt | ee4f2ea | 2007-04-12 15:30:22 +1000 | [diff] [blame] | 278 | int ktext; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 279 | |
| 280 | s = mmu_mapin_ram(); |
| 281 | v = KERNELBASE + s; |
Kumar Gala | 99c62dd7 | 2008-04-16 05:52:21 +1000 | [diff] [blame] | 282 | p = memstart_addr + s; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 283 | for (; s < total_lowmem; s += PAGE_SIZE) { |
Benjamin Herrenschmidt | ee4f2ea | 2007-04-12 15:30:22 +1000 | [diff] [blame] | 284 | ktext = ((char *) v >= _stext && (char *) v < etext); |
| 285 | f = ktext ?_PAGE_RAM_TEXT : _PAGE_RAM; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 286 | map_page(v, p, f); |
Benjamin Herrenschmidt | ee4f2ea | 2007-04-12 15:30:22 +1000 | [diff] [blame] | 287 | #ifdef CONFIG_PPC_STD_MMU_32 |
| 288 | if (ktext) |
| 289 | hash_preload(&init_mm, v, 0, 0x300); |
| 290 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 291 | v += PAGE_SIZE; |
| 292 | p += PAGE_SIZE; |
| 293 | } |
| 294 | } |
| 295 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 296 | /* Scan the real Linux page tables and return a PTE pointer for |
| 297 | * a virtual address in a context. |
| 298 | * Returns true (1) if PTE was found, zero otherwise. The pointer to |
| 299 | * the PTE pointer is unmodified if PTE is not found. |
| 300 | */ |
| 301 | int |
Eugene Surovegin | bab70a4 | 2006-03-28 10:13:12 -0800 | [diff] [blame] | 302 | get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep, pmd_t **pmdp) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 303 | { |
| 304 | pgd_t *pgd; |
David Gibson | d1953c8 | 2007-05-08 12:46:49 +1000 | [diff] [blame] | 305 | pud_t *pud; |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 306 | pmd_t *pmd; |
| 307 | pte_t *pte; |
| 308 | int retval = 0; |
| 309 | |
| 310 | pgd = pgd_offset(mm, addr & PAGE_MASK); |
| 311 | if (pgd) { |
David Gibson | d1953c8 | 2007-05-08 12:46:49 +1000 | [diff] [blame] | 312 | pud = pud_offset(pgd, addr & PAGE_MASK); |
| 313 | if (pud && pud_present(*pud)) { |
| 314 | pmd = pmd_offset(pud, addr & PAGE_MASK); |
| 315 | if (pmd_present(*pmd)) { |
| 316 | pte = pte_offset_map(pmd, addr & PAGE_MASK); |
| 317 | if (pte) { |
| 318 | retval = 1; |
| 319 | *ptep = pte; |
| 320 | if (pmdp) |
| 321 | *pmdp = pmd; |
| 322 | /* XXX caller needs to do pte_unmap, yuck */ |
| 323 | } |
| 324 | } |
| 325 | } |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 326 | } |
| 327 | return(retval); |
| 328 | } |
| 329 | |
Benjamin Herrenschmidt | 88df6e9 | 2007-04-12 15:30:22 +1000 | [diff] [blame] | 330 | #ifdef CONFIG_DEBUG_PAGEALLOC |
| 331 | |
| 332 | static int __change_page_attr(struct page *page, pgprot_t prot) |
| 333 | { |
| 334 | pte_t *kpte; |
| 335 | pmd_t *kpmd; |
| 336 | unsigned long address; |
| 337 | |
| 338 | BUG_ON(PageHighMem(page)); |
| 339 | address = (unsigned long)page_address(page); |
| 340 | |
| 341 | if (v_mapped_by_bats(address) || v_mapped_by_tlbcam(address)) |
| 342 | return 0; |
| 343 | if (!get_pteptr(&init_mm, address, &kpte, &kpmd)) |
| 344 | return -EINVAL; |
| 345 | set_pte_at(&init_mm, address, kpte, mk_pte(page, prot)); |
| 346 | wmb(); |
Benjamin Herrenschmidt | f63837f | 2008-12-14 19:44:51 +0000 | [diff] [blame] | 347 | #ifdef CONFIG_PPC_STD_MMU |
| 348 | flush_hash_pages(0, address, pmd_val(*kpmd), 1); |
| 349 | #else |
| 350 | flush_tlb_page(NULL, address); |
| 351 | #endif |
Benjamin Herrenschmidt | 88df6e9 | 2007-04-12 15:30:22 +1000 | [diff] [blame] | 352 | pte_unmap(kpte); |
| 353 | |
| 354 | return 0; |
| 355 | } |
| 356 | |
| 357 | /* |
| 358 | * Change the page attributes of an page in the linear mapping. |
| 359 | * |
| 360 | * THIS CONFLICTS WITH BAT MAPPINGS, DEBUG USE ONLY |
| 361 | */ |
| 362 | static int change_page_attr(struct page *page, int numpages, pgprot_t prot) |
| 363 | { |
| 364 | int i, err = 0; |
| 365 | unsigned long flags; |
| 366 | |
| 367 | local_irq_save(flags); |
| 368 | for (i = 0; i < numpages; i++, page++) { |
| 369 | err = __change_page_attr(page, prot); |
| 370 | if (err) |
| 371 | break; |
| 372 | } |
| 373 | local_irq_restore(flags); |
| 374 | return err; |
| 375 | } |
| 376 | |
| 377 | |
| 378 | void kernel_map_pages(struct page *page, int numpages, int enable) |
| 379 | { |
| 380 | if (PageHighMem(page)) |
| 381 | return; |
| 382 | |
| 383 | change_page_attr(page, numpages, enable ? PAGE_KERNEL : __pgprot(0)); |
| 384 | } |
| 385 | #endif /* CONFIG_DEBUG_PAGEALLOC */ |
Kumar Gala | 2c419bd | 2008-04-23 23:05:20 +1000 | [diff] [blame] | 386 | |
| 387 | static int fixmaps; |
| 388 | unsigned long FIXADDR_TOP = 0xfffff000; |
| 389 | EXPORT_SYMBOL(FIXADDR_TOP); |
| 390 | |
| 391 | void __set_fixmap (enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags) |
| 392 | { |
| 393 | unsigned long address = __fix_to_virt(idx); |
| 394 | |
| 395 | if (idx >= __end_of_fixed_addresses) { |
| 396 | BUG(); |
| 397 | return; |
| 398 | } |
| 399 | |
David Gibson | 46a7417 | 2008-05-19 16:16:00 +1000 | [diff] [blame] | 400 | map_page(address, phys, pgprot_val(flags)); |
Kumar Gala | 2c419bd | 2008-04-23 23:05:20 +1000 | [diff] [blame] | 401 | fixmaps++; |
| 402 | } |
| 403 | |
| 404 | void __this_fixmap_does_not_exist(void) |
| 405 | { |
| 406 | WARN_ON(1); |
| 407 | } |