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; |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 18 | unsigned long entry; |
| 19 | |
| 20 | #ifdef __PAGETABLE_PMD_FOLDED |
| 21 | entry = (unsigned long)invalid_pte_table; |
| 22 | #else |
| 23 | entry = (unsigned long)invalid_pmd_table; |
| 24 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | p = (unsigned long *) page; |
| 27 | end = p + PTRS_PER_PGD; |
| 28 | |
| 29 | while (p < end) { |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 30 | p[0] = entry; |
| 31 | p[1] = entry; |
| 32 | p[2] = entry; |
| 33 | p[3] = entry; |
| 34 | p[4] = entry; |
| 35 | p[5] = entry; |
| 36 | p[6] = entry; |
| 37 | p[7] = entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | p += 8; |
| 39 | } |
| 40 | } |
| 41 | |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 42 | #ifndef __PAGETABLE_PMD_FOLDED |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | void pmd_init(unsigned long addr, unsigned long pagetable) |
| 44 | { |
| 45 | unsigned long *p, *end; |
| 46 | |
| 47 | p = (unsigned long *) addr; |
| 48 | end = p + PTRS_PER_PMD; |
| 49 | |
| 50 | while (p < end) { |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 51 | p[0] = pagetable; |
| 52 | p[1] = pagetable; |
| 53 | p[2] = pagetable; |
| 54 | p[3] = pagetable; |
| 55 | p[4] = pagetable; |
| 56 | p[5] = pagetable; |
| 57 | p[6] = pagetable; |
| 58 | p[7] = pagetable; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | p += 8; |
| 60 | } |
| 61 | } |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 62 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | void __init pagetable_init(void) |
| 65 | { |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 66 | unsigned long vaddr; |
| 67 | pgd_t *pgd_base; |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | /* Initialize the entire pgd. */ |
| 70 | pgd_init((unsigned long)swapper_pg_dir); |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 71 | #ifndef __PAGETABLE_PMD_FOLDED |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table); |
David Daney | 325f8a0 | 2009-12-04 13:52:36 -0800 | [diff] [blame] | 73 | #endif |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 74 | pgd_base = swapper_pg_dir; |
| 75 | /* |
| 76 | * Fixed mappings: |
| 77 | */ |
| 78 | vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; |
Kevin Cernekee | 464fd83 | 2011-01-05 23:31:30 -0800 | [diff] [blame] | 79 | fixrange_init(vaddr, vaddr + FIXADDR_SIZE, pgd_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | } |