Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / arm / mm / pgd.c
bloba672c6a4aab9e0edb3ffc369965f236f2cdea7ec
1 /*
2 * linux/arch/arm/mm/pgd.c
4 * Copyright (C) 1998-2005 Russell King
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #include <linux/mm.h>
11 #include <linux/highmem.h>
13 #include <asm/pgalloc.h>
14 #include <asm/page.h>
15 #include <asm/tlbflush.h>
17 #include "mm.h"
19 #define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD)
22 * need to get a 16k page for level 1
24 pgd_t *get_pgd_slow(struct mm_struct *mm)
26 pgd_t *new_pgd, *init_pgd;
27 pmd_t *new_pmd, *init_pmd;
28 pte_t *new_pte, *init_pte;
30 new_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL, 2);
31 if (!new_pgd)
32 goto no_pgd;
34 memzero(new_pgd, FIRST_KERNEL_PGD_NR * sizeof(pgd_t));
37 * Copy over the kernel and IO PGD entries
39 init_pgd = pgd_offset_k(0);
40 memcpy(new_pgd + FIRST_KERNEL_PGD_NR, init_pgd + FIRST_KERNEL_PGD_NR,
41 (PTRS_PER_PGD - FIRST_KERNEL_PGD_NR) * sizeof(pgd_t));
43 clean_dcache_area(new_pgd, PTRS_PER_PGD * sizeof(pgd_t));
45 if (!vectors_high()) {
47 * On ARM, first page must always be allocated since it
48 * contains the machine vectors.
50 new_pmd = pmd_alloc(mm, new_pgd, 0);
51 if (!new_pmd)
52 goto no_pmd;
54 new_pte = pte_alloc_map(mm, new_pmd, 0);
55 if (!new_pte)
56 goto no_pte;
58 init_pmd = pmd_offset(init_pgd, 0);
59 init_pte = pte_offset_map_nested(init_pmd, 0);
60 set_pte_ext(new_pte, *init_pte, 0);
61 pte_unmap_nested(init_pte);
62 pte_unmap(new_pte);
65 return new_pgd;
67 no_pte:
68 pmd_free(mm, new_pmd);
69 no_pmd:
70 free_pages((unsigned long)new_pgd, 2);
71 no_pgd:
72 return NULL;
75 void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
77 pmd_t *pmd;
78 <<<<<<< HEAD:arch/arm/mm/pgd.c
79 struct page *pte;
80 =======
81 pgtable_t pte;
82 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mm/pgd.c
84 if (!pgd)
85 return;
87 /* pgd is always present and good */
88 pmd = pmd_off(pgd, 0);
89 if (pmd_none(*pmd))
90 goto free;
91 if (pmd_bad(*pmd)) {
92 pmd_ERROR(*pmd);
93 pmd_clear(pmd);
94 goto free;
97 <<<<<<< HEAD:arch/arm/mm/pgd.c
98 pte = pmd_page(*pmd);
99 =======
100 pte = pmd_pgtable(*pmd);
101 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mm/pgd.c
102 pmd_clear(pmd);
103 <<<<<<< HEAD:arch/arm/mm/pgd.c
104 dec_zone_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
105 pte_lock_deinit(pte);
106 =======
107 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mm/pgd.c
108 pte_free(mm, pte);
109 pmd_free(mm, pmd);
110 free:
111 free_pages((unsigned long) pgd, 2);