pgtable_32.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef _ASM_X86_PGTABLE_32_H
  2. #define _ASM_X86_PGTABLE_32_H
  3. #include <asm/pgtable_32_types.h>
  4. /*
  5. * The Linux memory management assumes a three-level page table setup. On
  6. * the i386, we use that, but "fold" the mid level into the top-level page
  7. * table, so that we physically have the same two-level page table as the
  8. * i386 mmu expects.
  9. *
  10. * This file contains the functions and defines necessary to modify and use
  11. * the i386 page table tree.
  12. */
  13. #ifndef __ASSEMBLY__
  14. #include <asm/processor.h>
  15. #include <asm/fixmap.h>
  16. #include <linux/threads.h>
  17. #include <asm/paravirt.h>
  18. #include <linux/bitops.h>
  19. #include <linux/list.h>
  20. #include <linux/spinlock.h>
  21. struct mm_struct;
  22. struct vm_area_struct;
  23. extern pgd_t swapper_pg_dir[1024];
  24. static inline void pgtable_cache_init(void) { }
  25. static inline void check_pgt_cache(void) { }
  26. void paging_init(void);
  27. extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
  28. /*
  29. * Define this if things work differently on an i386 and an i486:
  30. * it will (on an i486) warn about kernel memory accesses that are
  31. * done without a 'access_ok(VERIFY_WRITE,..)'
  32. */
  33. #undef TEST_ACCESS_OK
  34. #ifdef CONFIG_X86_PAE
  35. # include <asm/pgtable-3level.h>
  36. #else
  37. # include <asm/pgtable-2level.h>
  38. #endif
  39. #if defined(CONFIG_HIGHPTE)
  40. #define __KM_PTE \
  41. (in_nmi() ? KM_NMI_PTE : \
  42. in_irq() ? KM_IRQ_PTE : \
  43. KM_PTE0)
  44. #define pte_offset_map(dir, address) \
  45. ((pte_t *)kmap_atomic(pmd_page(*(dir)), __KM_PTE) + \
  46. pte_index((address)))
  47. #define pte_offset_map_nested(dir, address) \
  48. ((pte_t *)kmap_atomic(pmd_page(*(dir)), KM_PTE1) + \
  49. pte_index((address)))
  50. #define pte_unmap(pte) kunmap_atomic((pte), __KM_PTE)
  51. #define pte_unmap_nested(pte) kunmap_atomic((pte), KM_PTE1)
  52. #else
  53. #define pte_offset_map(dir, address) \
  54. ((pte_t *)page_address(pmd_page(*(dir))) + pte_index((address)))
  55. #define pte_offset_map_nested(dir, address) pte_offset_map((dir), (address))
  56. #define pte_unmap(pte) do { } while (0)
  57. #define pte_unmap_nested(pte) do { } while (0)
  58. #endif
  59. /* Clear a kernel PTE and flush it from the TLB */
  60. #define kpte_clear_flush(ptep, vaddr) \
  61. do { \
  62. pte_clear(&init_mm, (vaddr), (ptep)); \
  63. __flush_tlb_one((vaddr)); \
  64. } while (0)
  65. /*
  66. * The i386 doesn't have any external MMU info: the kernel page
  67. * tables contain all the necessary information.
  68. */
  69. #define update_mmu_cache(vma, address, ptep) do { } while (0)
  70. #endif /* !__ASSEMBLY__ */
  71. /*
  72. * kern_addr_valid() is (1) for FLATMEM and (0) for
  73. * SPARSEMEM and DISCONTIGMEM
  74. */
  75. #ifdef CONFIG_FLATMEM
  76. #define kern_addr_valid(addr) (1)
  77. #else
  78. #define kern_addr_valid(kaddr) (0)
  79. #endif
  80. #endif /* _ASM_X86_PGTABLE_32_H */