Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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) 1999, 2000 by Silicon Graphics |
| 7 | * Copyright (C) 2003 by Ralf Baechle |
| 8 | */ |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/mm.h> |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 11 | #include <asm/fixmap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/pgtable.h> |
Atsushi Nemoto | 6a1e552 | 2007-02-19 01:27:34 +0900 | [diff] [blame] | 13 | #include <asm/pgalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | void pgd_init(unsigned long page) |
| 16 | { |
| 17 | unsigned long *p, *end; |
| 18 | |
| 19 | p = (unsigned long *) page; |
| 20 | end = p + PTRS_PER_PGD; |
| 21 | |
| 22 | while (p < end) { |
| 23 | p[0] = (unsigned long) invalid_pmd_table; |
| 24 | p[1] = (unsigned long) invalid_pmd_table; |
| 25 | p[2] = (unsigned long) invalid_pmd_table; |
| 26 | p[3] = (unsigned long) invalid_pmd_table; |
| 27 | p[4] = (unsigned long) invalid_pmd_table; |
| 28 | p[5] = (unsigned long) invalid_pmd_table; |
| 29 | p[6] = (unsigned long) invalid_pmd_table; |
| 30 | p[7] = (unsigned long) invalid_pmd_table; |
| 31 | p += 8; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | void pmd_init(unsigned long addr, unsigned long pagetable) |
| 36 | { |
| 37 | unsigned long *p, *end; |
| 38 | |
| 39 | p = (unsigned long *) addr; |
| 40 | end = p + PTRS_PER_PMD; |
| 41 | |
| 42 | while (p < end) { |
| 43 | p[0] = (unsigned long)pagetable; |
| 44 | p[1] = (unsigned long)pagetable; |
| 45 | p[2] = (unsigned long)pagetable; |
| 46 | p[3] = (unsigned long)pagetable; |
| 47 | p[4] = (unsigned long)pagetable; |
| 48 | p[5] = (unsigned long)pagetable; |
| 49 | p[6] = (unsigned long)pagetable; |
| 50 | p[7] = (unsigned long)pagetable; |
| 51 | p += 8; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void __init pagetable_init(void) |
| 56 | { |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 57 | unsigned long vaddr; |
| 58 | pgd_t *pgd_base; |
| 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | /* Initialize the entire pgd. */ |
| 61 | pgd_init((unsigned long)swapper_pg_dir); |
Atsushi Nemoto | 656be92 | 2006-10-26 00:08:31 +0900 | [diff] [blame] | 62 | #ifdef MODULE_START |
| 63 | pgd_init((unsigned long)module_pg_dir); |
| 64 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table); |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 66 | |
| 67 | pgd_base = swapper_pg_dir; |
| 68 | /* |
| 69 | * Fixed mappings: |
| 70 | */ |
| 71 | vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; |
| 72 | fixrange_init(vaddr, 0, pgd_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |