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) 2003 by Ralf Baechle |
| 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/init.h> |
| 9 | #include <linux/mm.h> |
| 10 | #include <linux/bootmem.h> |
| 11 | #include <linux/highmem.h> |
Ralf Baechle | 84fd089 | 2005-02-07 16:13:07 +0000 | [diff] [blame] | 12 | #include <asm/fixmap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/pgtable.h> |
Atsushi Nemoto | 6a1e552 | 2007-02-19 01:27:34 +0900 | [diff] [blame] | 14 | #include <asm/pgalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | void pgd_init(unsigned long page) |
| 17 | { |
| 18 | unsigned long *p = (unsigned long *) page; |
| 19 | int i; |
| 20 | |
| 21 | for (i = 0; i < USER_PTRS_PER_PGD; i+=8) { |
| 22 | p[i + 0] = (unsigned long) invalid_pte_table; |
| 23 | p[i + 1] = (unsigned long) invalid_pte_table; |
| 24 | p[i + 2] = (unsigned long) invalid_pte_table; |
| 25 | p[i + 3] = (unsigned long) invalid_pte_table; |
| 26 | p[i + 4] = (unsigned long) invalid_pte_table; |
| 27 | p[i + 5] = (unsigned long) invalid_pte_table; |
| 28 | p[i + 6] = (unsigned long) invalid_pte_table; |
| 29 | p[i + 7] = (unsigned long) invalid_pte_table; |
| 30 | } |
| 31 | } |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | void __init pagetable_init(void) |
| 34 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | unsigned long vaddr; |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 36 | pgd_t *pgd_base; |
| 37 | #ifdef CONFIG_HIGHMEM |
| 38 | pgd_t *pgd; |
Ralf Baechle | c6e8b58 | 2005-02-10 12:19:59 +0000 | [diff] [blame] | 39 | pud_t *pud; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | pmd_t *pmd; |
| 41 | pte_t *pte; |
| 42 | #endif |
| 43 | |
| 44 | /* Initialize the entire pgd. */ |
| 45 | pgd_init((unsigned long)swapper_pg_dir); |
| 46 | pgd_init((unsigned long)swapper_pg_dir |
| 47 | + sizeof(pgd_t) * USER_PTRS_PER_PGD); |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | pgd_base = swapper_pg_dir; |
| 50 | |
| 51 | /* |
| 52 | * Fixed mappings: |
| 53 | */ |
| 54 | vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK; |
Kevin Cernekee | 464fd83 | 2011-01-05 23:31:30 -0800 | [diff] [blame] | 55 | fixrange_init(vaddr, vaddr + FIXADDR_SIZE, pgd_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Ralf Baechle | f8829ca | 2006-10-21 23:17:35 +0100 | [diff] [blame] | 57 | #ifdef CONFIG_HIGHMEM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /* |
| 59 | * Permanent kmaps: |
| 60 | */ |
| 61 | vaddr = PKMAP_BASE; |
| 62 | fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base); |
| 63 | |
| 64 | pgd = swapper_pg_dir + __pgd_offset(vaddr); |
Ralf Baechle | c6e8b58 | 2005-02-10 12:19:59 +0000 | [diff] [blame] | 65 | pud = pud_offset(pgd, vaddr); |
| 66 | pmd = pmd_offset(pud, vaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | pte = pte_offset_kernel(pmd, vaddr); |
| 68 | pkmap_page_table = pte; |
| 69 | #endif |
| 70 | } |