blob: 4a61e624b0ecfcd921a560d426e92e1df2df1de2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <linux/init.h>
9#include <linux/mm.h>
10#include <linux/bootmem.h>
11#include <linux/highmem.h>
Ralf Baechle84fd0892005-02-07 16:13:07 +000012#include <asm/fixmap.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/pgtable.h>
14
15void pgd_init(unsigned long page)
16{
17 unsigned long *p = (unsigned long *) page;
18 int i;
19
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;
29 }
30}
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032void __init pagetable_init(void)
33{
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 unsigned long vaddr;
Ralf Baechlef8829ca2006-10-21 23:17:35 +010035 pgd_t *pgd_base;
36#ifdef CONFIG_HIGHMEM
37 pgd_t *pgd;
Ralf Baechlec6e8b582005-02-10 12:19:59 +000038 pud_t *pud;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 pmd_t *pmd;
40 pte_t *pte;
41#endif
42
43 /* Initialize the entire pgd. */
44 pgd_init((unsigned long)swapper_pg_dir);
45 pgd_init((unsigned long)swapper_pg_dir
46 + sizeof(pgd_t) * USER_PTRS_PER_PGD);
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 pgd_base = swapper_pg_dir;
49
50 /*
51 * Fixed mappings:
52 */
53 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
54 fixrange_init(vaddr, 0, pgd_base);
55
Ralf Baechlef8829ca2006-10-21 23:17:35 +010056#ifdef CONFIG_HIGHMEM
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 /*
58 * Permanent kmaps:
59 */
60 vaddr = PKMAP_BASE;
61 fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
62
63 pgd = swapper_pg_dir + __pgd_offset(vaddr);
Ralf Baechlec6e8b582005-02-10 12:19:59 +000064 pud = pud_offset(pgd, vaddr);
65 pmd = pmd_offset(pud, vaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 pte = pte_offset_kernel(pmd, vaddr);
67 pkmap_page_table = pte;
68#endif
69}