2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2003 by Ralf Baechle
8 #include <linux/config.h>
9 #include <linux/init.h>
11 #include <linux/bootmem.h>
12 #include <linux/highmem.h>
13 #include <asm/pgtable.h>
15 void pgd_init(unsigned long page
)
17 unsigned long *p
= (unsigned long *) page
;
20 for (i
= 0; i
< USER_PTRS_PER_PGD
; i
+=8) {
21 p
[i
+ 0] = (unsigned long) invalid_pte_table
;
22 p
[i
+ 1] = (unsigned long) invalid_pte_table
;
23 p
[i
+ 2] = (unsigned long) invalid_pte_table
;
24 p
[i
+ 3] = (unsigned long) invalid_pte_table
;
25 p
[i
+ 4] = (unsigned long) invalid_pte_table
;
26 p
[i
+ 5] = (unsigned long) invalid_pte_table
;
27 p
[i
+ 6] = (unsigned long) invalid_pte_table
;
28 p
[i
+ 7] = (unsigned long) invalid_pte_table
;
33 static void __init
fixrange_init (unsigned long start
, unsigned long end
,
43 i
= __pgd_offset(vaddr
);
44 j
= __pmd_offset(vaddr
);
47 for ( ; (i
< PTRS_PER_PGD
) && (vaddr
!= end
); pgd
++, i
++) {
49 for (; (j
< PTRS_PER_PMD
) && (vaddr
!= end
); pmd
++, j
++) {
51 pte
= (pte_t
*) alloc_bootmem_low_pages(PAGE_SIZE
);
52 set_pmd(pmd
, __pmd((unsigned long)pte
));
53 if (pte
!= pte_offset_kernel(pmd
, 0))
63 void __init
pagetable_init(void)
67 pgd_t
*pgd
, *pgd_base
;
72 /* Initialize the entire pgd. */
73 pgd_init((unsigned long)swapper_pg_dir
);
74 pgd_init((unsigned long)swapper_pg_dir
75 + sizeof(pgd_t
) * USER_PTRS_PER_PGD
);
78 pgd_base
= swapper_pg_dir
;
83 vaddr
= __fix_to_virt(__end_of_fixed_addresses
- 1) & PMD_MASK
;
84 fixrange_init(vaddr
, 0, pgd_base
);
90 fixrange_init(vaddr
, vaddr
+ PAGE_SIZE
*LAST_PKMAP
, pgd_base
);
92 pgd
= swapper_pg_dir
+ __pgd_offset(vaddr
);
93 pmd
= pmd_offset(pgd
, vaddr
);
94 pte
= pte_offset_kernel(pmd
, vaddr
);
95 pkmap_page_table
= pte
;