pgtable.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * This file contains the functions and defines necessary to modify and
  3. * use the SuperH page table tree.
  4. *
  5. * Copyright (C) 1999 Niibe Yutaka
  6. * Copyright (C) 2002 - 2007 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General
  9. * Public License. See the file "COPYING" in the main directory of this
  10. * archive for more details.
  11. */
  12. #ifndef __ASM_SH_PGTABLE_H
  13. #define __ASM_SH_PGTABLE_H
  14. #include <asm-generic/pgtable-nopmd.h>
  15. #include <asm/page.h>
  16. #ifndef __ASSEMBLY__
  17. #include <asm/addrspace.h>
  18. #include <asm/fixmap.h>
  19. /*
  20. * ZERO_PAGE is a global shared page that is always zero: used
  21. * for zero-mapped memory areas etc..
  22. */
  23. extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
  24. #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  25. #endif /* !__ASSEMBLY__ */
  26. /*
  27. * Effective and physical address definitions, to aid with sign
  28. * extension.
  29. */
  30. #define NEFF 32
  31. #define NEFF_SIGN (1LL << (NEFF - 1))
  32. #define NEFF_MASK (-1LL << NEFF)
  33. #ifdef CONFIG_29BIT
  34. #define NPHYS 29
  35. #else
  36. #define NPHYS 32
  37. #endif
  38. #define NPHYS_SIGN (1LL << (NPHYS - 1))
  39. #define NPHYS_MASK (-1LL << NPHYS)
  40. /*
  41. * traditional two-level paging structure
  42. */
  43. /* PTE bits */
  44. #if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
  45. # define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
  46. #else
  47. # define PTE_MAGNITUDE 2 /* 32-bit PTEs */
  48. #endif
  49. #define PTE_SHIFT PAGE_SHIFT
  50. #define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
  51. /* PGD bits */
  52. #define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
  53. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  54. #define PGDIR_MASK (~(PGDIR_SIZE-1))
  55. /* Entries per level */
  56. #define PTRS_PER_PTE (PAGE_SIZE / (1 << PTE_MAGNITUDE))
  57. #define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t))
  58. #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
  59. #define FIRST_USER_ADDRESS 0
  60. #ifdef CONFIG_32BIT
  61. #define PHYS_ADDR_MASK 0xffffffff
  62. #else
  63. #define PHYS_ADDR_MASK 0x1fffffff
  64. #endif
  65. #define PTE_PHYS_MASK (PHYS_ADDR_MASK & PAGE_MASK)
  66. #ifdef CONFIG_SUPERH32
  67. #define VMALLOC_START (P3SEG)
  68. #else
  69. #define VMALLOC_START (0xf0000000)
  70. #endif
  71. #define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
  72. #if defined(CONFIG_SUPERH32)
  73. #include <asm/pgtable_32.h>
  74. #else
  75. #include <asm/pgtable_64.h>
  76. #endif
  77. /*
  78. * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
  79. * protection for execute, and considers it the same as a read. Also, write
  80. * permission implies read permission. This is the closest we can get..
  81. *
  82. * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme,
  83. * not only supporting separate execute, read, and write bits, but having
  84. * completely separate permission bits for user and kernel space.
  85. */
  86. /*xwr*/
  87. #define __P000 PAGE_NONE
  88. #define __P001 PAGE_READONLY
  89. #define __P010 PAGE_COPY
  90. #define __P011 PAGE_COPY
  91. #define __P100 PAGE_EXECREAD
  92. #define __P101 PAGE_EXECREAD
  93. #define __P110 PAGE_COPY
  94. #define __P111 PAGE_COPY
  95. #define __S000 PAGE_NONE
  96. #define __S001 PAGE_READONLY
  97. #define __S010 PAGE_WRITEONLY
  98. #define __S011 PAGE_SHARED
  99. #define __S100 PAGE_EXECREAD
  100. #define __S101 PAGE_EXECREAD
  101. #define __S110 PAGE_RWX
  102. #define __S111 PAGE_RWX
  103. typedef pte_t *pte_addr_t;
  104. #define kern_addr_valid(addr) (1)
  105. #define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
  106. remap_pfn_range(vma, vaddr, pfn, size, prot)
  107. #define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
  108. /*
  109. * No page table caches to initialise
  110. */
  111. #define pgtable_cache_init() do { } while (0)
  112. #if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \
  113. defined(CONFIG_SH7705_CACHE_32KB))
  114. struct mm_struct;
  115. #define __HAVE_ARCH_PTEP_GET_AND_CLEAR
  116. pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
  117. #endif
  118. struct vm_area_struct;
  119. extern void update_mmu_cache(struct vm_area_struct * vma,
  120. unsigned long address, pte_t pte);
  121. extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
  122. extern void paging_init(void);
  123. extern void page_table_range_init(unsigned long start, unsigned long end,
  124. pgd_t *pgd);
  125. #include <asm-generic/pgtable.h>
  126. #endif /* __ASM_SH_PGTABLE_H */