pgtable-32.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. */
  8. #include <linux/init.h>
  9. #include <linux/mm.h>
  10. #include <linux/bootmem.h>
  11. #include <linux/highmem.h>
  12. #include <asm/fixmap.h>
  13. #include <asm/pgtable.h>
  14. #include <asm/pgalloc.h>
  15. void pgd_init(unsigned long page)
  16. {
  17. unsigned long *p = (unsigned long *) page;
  18. int i;
  19. for (i = 0; i < USER_PTRS_PER_PGD; i+=8) {
  20. p[i + 0] = (unsigned long) invalid_pte_table;
  21. p[i + 1] = (unsigned long) invalid_pte_table;
  22. p[i + 2] = (unsigned long) invalid_pte_table;
  23. p[i + 3] = (unsigned long) invalid_pte_table;
  24. p[i + 4] = (unsigned long) invalid_pte_table;
  25. p[i + 5] = (unsigned long) invalid_pte_table;
  26. p[i + 6] = (unsigned long) invalid_pte_table;
  27. p[i + 7] = (unsigned long) invalid_pte_table;
  28. }
  29. }
  30. void __init pagetable_init(void)
  31. {
  32. unsigned long vaddr;
  33. pgd_t *pgd_base;
  34. #ifdef CONFIG_HIGHMEM
  35. pgd_t *pgd;
  36. pud_t *pud;
  37. pmd_t *pmd;
  38. pte_t *pte;
  39. #endif
  40. /* Initialize the entire pgd. */
  41. pgd_init((unsigned long)swapper_pg_dir);
  42. pgd_init((unsigned long)swapper_pg_dir
  43. + sizeof(pgd_t) * USER_PTRS_PER_PGD);
  44. pgd_base = swapper_pg_dir;
  45. /*
  46. * Fixed mappings:
  47. */
  48. vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
  49. fixrange_init(vaddr, vaddr + FIXADDR_SIZE, pgd_base);
  50. #ifdef CONFIG_HIGHMEM
  51. /*
  52. * Permanent kmaps:
  53. */
  54. vaddr = PKMAP_BASE;
  55. fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
  56. pgd = swapper_pg_dir + __pgd_offset(vaddr);
  57. pud = pud_offset(pgd, vaddr);
  58. pmd = pmd_offset(pud, vaddr);
  59. pte = pte_offset_kernel(pmd, vaddr);
  60. pkmap_page_table = pte;
  61. #endif
  62. }