pgtable.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _M68K_PGTABLE_H
  2. #define _M68K_PGTABLE_H
  3. #include <linux/config.h>
  4. #include <asm/setup.h>
  5. #ifndef __ASSEMBLY__
  6. #include <asm/processor.h>
  7. #include <linux/threads.h>
  8. /*
  9.  * This file contains the functions and defines necessary to modify and use
  10.  * the m68k page table tree.
  11.  */
  12. #include <asm/virtconvert.h>
  13. /* Certain architectures need to do special things when pte's
  14.  * within a page table are directly modified.  Thus, the following
  15.  * hook is made available.
  16.  */
  17. #define set_pte(pteptr, pteval)
  18. do{
  19. *(pteptr) = (pteval);
  20. } while(0)
  21. /* PMD_SHIFT determines the size of the area a second-level page table can map */
  22. #ifdef CONFIG_SUN3
  23. #define PMD_SHIFT       17
  24. #else
  25. #define PMD_SHIFT 22
  26. #endif
  27. #define PMD_SIZE (1UL << PMD_SHIFT)
  28. #define PMD_MASK (~(PMD_SIZE-1))
  29. /* PGDIR_SHIFT determines what a third-level page table entry can map */
  30. #ifdef CONFIG_SUN3
  31. #define PGDIR_SHIFT     17
  32. #else
  33. #define PGDIR_SHIFT 25
  34. #endif
  35. #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
  36. #define PGDIR_MASK (~(PGDIR_SIZE-1))
  37. /*
  38.  * entries per page directory level: the m68k is configured as three-level,
  39.  * so we do have PMD level physically.
  40.  */
  41. #ifdef CONFIG_SUN3
  42. #define PTRS_PER_PTE   16
  43. #define PTRS_PER_PMD   1
  44. #define PTRS_PER_PGD   2048
  45. #else
  46. #define PTRS_PER_PTE 1024
  47. #define PTRS_PER_PMD 8
  48. #define PTRS_PER_PGD 128
  49. #endif
  50. #define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
  51. #define FIRST_USER_PGD_NR 0
  52. /* Virtual address region for use by kernel_map() */
  53. #ifdef CONFIG_SUN3
  54. #define KMAP_START     0x0DC00000
  55. #define KMAP_END       0x0E000000
  56. #else
  57. #define KMAP_START 0xd0000000
  58. #define KMAP_END 0xf0000000
  59. #endif
  60. #ifndef CONFIG_SUN3
  61. /* Just any arbitrary offset to the start of the vmalloc VM area: the
  62.  * current 8MB value just means that there will be a 8MB "hole" after the
  63.  * physical memory until the kernel virtual memory starts.  That means that
  64.  * any out-of-bounds memory accesses will hopefully be caught.
  65.  * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  66.  * area for the same reason. ;)
  67.  */
  68. #define VMALLOC_OFFSET (8*1024*1024)
  69. #define VMALLOC_START (((unsigned long) high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
  70. #define VMALLOC_VMADDR(x) ((unsigned long)(x))
  71. #define VMALLOC_END KMAP_START
  72. #else
  73. extern unsigned long vmalloc_end;
  74. #define VMALLOC_START 0x0f800000
  75. #define VMALLOC_VMADDR(x) ((unsigned long)(x))
  76. #define VMALLOC_END vmalloc_end
  77. #endif /* CONFIG_SUN3 */
  78. /* zero page used for uninitialized stuff */
  79. extern unsigned long empty_zero_page;
  80. /*
  81.  * BAD_PAGETABLE is used when we need a bogus page-table, while
  82.  * BAD_PAGE is used for a bogus page.
  83.  *
  84.  * ZERO_PAGE is a global shared page that is always zero: used
  85.  * for zero-mapped memory areas etc..
  86.  */
  87. extern pte_t __bad_page(void);
  88. extern pte_t * __bad_pagetable(void);
  89. #define BAD_PAGETABLE __bad_pagetable()
  90. #define BAD_PAGE __bad_page()
  91. #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
  92. /* number of bits that fit into a memory pointer */
  93. #define BITS_PER_PTR (8*sizeof(unsigned long))
  94. /* to align the pointer to a pointer address */
  95. #define PTR_MASK (~(sizeof(void*)-1))
  96. /* sizeof(void*)==1<<SIZEOF_PTR_LOG2 */
  97. /* 64-bit machines, beware!  SRB. */
  98. #define SIZEOF_PTR_LOG2        2
  99. /*
  100.  * Check if the addr/len goes up to the end of a physical
  101.  * memory chunk.  Used for DMA functions.
  102.  */
  103. #ifdef CONFIG_SINGLE_MEMORY_CHUNK
  104. /*
  105.  * It makes no sense to consider whether we cross a memory boundary if
  106.  * we support just one physical chunk of memory.
  107.  */
  108. extern inline int mm_end_of_chunk (unsigned long addr, int len)
  109. {
  110. return 0;
  111. }
  112. #else
  113. int mm_end_of_chunk (unsigned long addr, int len);
  114. #endif
  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. extern inline void update_mmu_cache(struct vm_area_struct * vma,
  122. unsigned long address, pte_t pte)
  123. {
  124. }
  125. #ifdef CONFIG_SUN3
  126. /* Macros to (de)construct the fake PTEs representing swap pages. */
  127. #define SWP_TYPE(x)                ((x).val & 0x7F)
  128. #define SWP_OFFSET(x)      (((x).val) >> 7)
  129. #define SWP_ENTRY(type,offset) ((swp_entry_t) { ((type) | ((offset) << 7)) })
  130. #define pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
  131. #define swp_entry_to_pte(x) ((pte_t) { (x).val })
  132. #else
  133. /* Encode and de-code a swap entry (must be !pte_none(e) && !pte_present(e)) */
  134. #define SWP_TYPE(x) (((x).val >> 1) & 0xff)
  135. #define SWP_OFFSET(x) ((x).val >> 10)
  136. #define SWP_ENTRY(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 10) })
  137. #define pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
  138. #define swp_entry_to_pte(x) ((pte_t) { (x).val })
  139. #endif /* CONFIG_SUN3 */
  140. #endif /* !__ASSEMBLY__ */
  141. /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
  142. #define PageSkip(page) (0)
  143. #define kern_addr_valid(addr) (1)
  144. #define io_remap_page_range remap_page_range
  145. /* MMU-specific headers */
  146. #ifdef CONFIG_SUN3
  147. #include <asm/sun3_pgtable.h>
  148. #else
  149. #include <asm/motorola_pgtable.h>
  150. #endif
  151. #ifndef __ASSEMBLY__
  152. #include <asm-generic/pgtable.h>
  153. #endif /* !__ASSEMBLY__ */
  154. /*
  155.  * No page table caches to initialise
  156.  */
  157. #define pgtable_cache_init() do { } while (0)
  158. #endif /* _M68K_PGTABLE_H */