pgtable_mm.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _M68K_PGTABLE_H
  3. #define _M68K_PGTABLE_H
  4. #if defined(CONFIG_SUN3) || defined(CONFIG_COLDFIRE)
  5. #include <asm-generic/pgtable-nopmd.h>
  6. #else
  7. #include <asm-generic/pgtable-nopud.h>
  8. #endif
  9. #include <asm/setup.h>
  10. #ifndef __ASSEMBLY__
  11. #include <asm/processor.h>
  12. #include <linux/sched.h>
  13. #include <linux/threads.h>
  14. /*
  15. * This file contains the functions and defines necessary to modify and use
  16. * the m68k page table tree.
  17. */
  18. #include <asm/virtconvert.h>
  19. /* Certain architectures need to do special things when pte's
  20. * within a page table are directly modified. Thus, the following
  21. * hook is made available.
  22. */
  23. #define set_pte(pteptr, pteval) \
  24. do{ \
  25. *(pteptr) = (pteval); \
  26. } while(0)
  27. #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
  28. /* PMD_SHIFT determines the size of the area a second-level page table can map */
  29. #if CONFIG_PGTABLE_LEVELS == 3
  30. #define PMD_SHIFT 18
  31. #endif
  32. #define PMD_SIZE (1UL << PMD_SHIFT)
  33. #define PMD_MASK (~(PMD_SIZE-1))
  34. /* PGDIR_SHIFT determines what a third-level page table entry can map */
  35. #ifdef CONFIG_SUN3
  36. #define PGDIR_SHIFT 17
  37. #elif defined(CONFIG_COLDFIRE)
  38. #define PGDIR_SHIFT 22
  39. #else
  40. #define PGDIR_SHIFT 25
  41. #endif
  42. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  43. #define PGDIR_MASK (~(PGDIR_SIZE-1))
  44. /*
  45. * entries per page directory level: the m68k is configured as three-level,
  46. * so we do have PMD level physically.
  47. */
  48. #ifdef CONFIG_SUN3
  49. #define PTRS_PER_PTE 16
  50. #define __PAGETABLE_PMD_FOLDED 1
  51. #define PTRS_PER_PMD 1
  52. #define PTRS_PER_PGD 2048
  53. #elif defined(CONFIG_COLDFIRE)
  54. #define PTRS_PER_PTE 512
  55. #define __PAGETABLE_PMD_FOLDED 1
  56. #define PTRS_PER_PMD 1
  57. #define PTRS_PER_PGD 1024
  58. #else
  59. #define PTRS_PER_PTE 64
  60. #define PTRS_PER_PMD 128
  61. #define PTRS_PER_PGD 128
  62. #endif
  63. #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
  64. /* Virtual address region for use by kernel_map() */
  65. #ifdef CONFIG_SUN3
  66. #define KMAP_START 0x0dc00000
  67. #define KMAP_END 0x0e000000
  68. #elif defined(CONFIG_COLDFIRE)
  69. #define KMAP_START 0xe0000000
  70. #define KMAP_END 0xf0000000
  71. #elif defined(CONFIG_VIRT)
  72. #define KMAP_START 0xdf000000
  73. #define KMAP_END 0xff000000
  74. #else
  75. #define KMAP_START 0xd0000000
  76. #define KMAP_END 0xf0000000
  77. #endif
  78. #ifdef CONFIG_SUN3
  79. extern unsigned long m68k_vmalloc_end;
  80. #define VMALLOC_START 0x0f800000
  81. #define VMALLOC_END m68k_vmalloc_end
  82. #elif defined(CONFIG_COLDFIRE)
  83. #define VMALLOC_START 0xd0000000
  84. #define VMALLOC_END 0xe0000000
  85. #elif defined(CONFIG_VIRT)
  86. #define VMALLOC_OFFSET PAGE_SIZE
  87. #define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
  88. #define VMALLOC_END KMAP_START
  89. #else
  90. /* Just any arbitrary offset to the start of the vmalloc VM area: the
  91. * current 8MB value just means that there will be a 8MB "hole" after the
  92. * physical memory until the kernel virtual memory starts. That means that
  93. * any out-of-bounds memory accesses will hopefully be caught.
  94. * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  95. * area for the same reason. ;)
  96. */
  97. #define VMALLOC_OFFSET (8*1024*1024)
  98. #define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
  99. #define VMALLOC_END KMAP_START
  100. #endif
  101. /* zero page used for uninitialized stuff */
  102. extern void *empty_zero_page;
  103. /*
  104. * ZERO_PAGE is a global shared page that is always zero: used
  105. * for zero-mapped memory areas etc..
  106. */
  107. #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  108. /* number of bits that fit into a memory pointer */
  109. #define BITS_PER_PTR (8*sizeof(unsigned long))
  110. /* to align the pointer to a pointer address */
  111. #define PTR_MASK (~(sizeof(void*)-1))
  112. /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
  113. /* 64-bit machines, beware! SRB. */
  114. #define SIZEOF_PTR_LOG2 2
  115. extern void kernel_set_cachemode(void *addr, unsigned long size, int cmode);
  116. /*
  117. * The m68k doesn't have any external MMU info: the kernel page
  118. * tables contain all the necessary information. The Sun3 does, but
  119. * they are updated on demand.
  120. */
  121. static inline void update_mmu_cache(struct vm_area_struct *vma,
  122. unsigned long address, pte_t *ptep)
  123. {
  124. }
  125. #endif /* !__ASSEMBLY__ */
  126. #define kern_addr_valid(addr) (1)
  127. /* MMU-specific headers */
  128. #ifdef CONFIG_SUN3
  129. #include <asm/sun3_pgtable.h>
  130. #elif defined(CONFIG_COLDFIRE)
  131. #include <asm/mcf_pgtable.h>
  132. #else
  133. #include <asm/motorola_pgtable.h>
  134. #endif
  135. #ifndef __ASSEMBLY__
  136. /*
  137. * Macro to mark a page protection value as "uncacheable".
  138. */
  139. #ifdef CONFIG_COLDFIRE
  140. # define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | CF_PAGE_NOCACHE))
  141. #else
  142. #ifdef SUN3_PAGE_NOCACHE
  143. # define __SUN3_PAGE_NOCACHE SUN3_PAGE_NOCACHE
  144. #else
  145. # define __SUN3_PAGE_NOCACHE 0
  146. #endif
  147. #define pgprot_noncached(prot) \
  148. (MMU_IS_SUN3 \
  149. ? (__pgprot(pgprot_val(prot) | __SUN3_PAGE_NOCACHE)) \
  150. : ((MMU_IS_851 || MMU_IS_030) \
  151. ? (__pgprot(pgprot_val(prot) | _PAGE_NOCACHE030)) \
  152. : (MMU_IS_040 || MMU_IS_060) \
  153. ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \
  154. : (prot)))
  155. pgprot_t pgprot_dmacoherent(pgprot_t prot);
  156. #define pgprot_dmacoherent(prot) pgprot_dmacoherent(prot)
  157. #endif /* CONFIG_COLDFIRE */
  158. #endif /* !__ASSEMBLY__ */
  159. #endif /* _M68K_PGTABLE_H */