page.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #ifndef _PARISC_PAGE_H
  2. #define _PARISC_PAGE_H
  3. #include <linux/const.h>
  4. #if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
  5. # define PAGE_SHIFT 12
  6. #elif defined(CONFIG_PARISC_PAGE_SIZE_16KB)
  7. # define PAGE_SHIFT 14
  8. #elif defined(CONFIG_PARISC_PAGE_SIZE_64KB)
  9. # define PAGE_SHIFT 16
  10. #else
  11. # error "unknown default kernel page size"
  12. #endif
  13. #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
  14. #define PAGE_MASK (~(PAGE_SIZE-1))
  15. #ifndef __ASSEMBLY__
  16. #include <asm/types.h>
  17. #include <asm/cache.h>
  18. #define clear_page(page) clear_page_asm((void *)(page))
  19. #define copy_page(to, from) copy_page_asm((void *)(to), (void *)(from))
  20. struct page;
  21. void clear_page_asm(void *page);
  22. void copy_page_asm(void *to, void *from);
  23. #define clear_user_page(vto, vaddr, page) clear_page_asm(vto)
  24. void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
  25. struct page *pg);
  26. /*
  27. * These are used to make use of C type-checking..
  28. */
  29. #define STRICT_MM_TYPECHECKS
  30. #ifdef STRICT_MM_TYPECHECKS
  31. typedef struct { unsigned long pte; } pte_t; /* either 32 or 64bit */
  32. /* NOTE: even on 64 bits, these entries are __u32 because we allocate
  33. * the pmd and pgd in ZONE_DMA (i.e. under 4GB) */
  34. typedef struct { __u32 pmd; } pmd_t;
  35. typedef struct { __u32 pgd; } pgd_t;
  36. typedef struct { unsigned long pgprot; } pgprot_t;
  37. #define pte_val(x) ((x).pte)
  38. /* These do not work lvalues, so make sure we don't use them as such. */
  39. #define pmd_val(x) ((x).pmd + 0)
  40. #define pgd_val(x) ((x).pgd + 0)
  41. #define pgprot_val(x) ((x).pgprot)
  42. #define __pte(x) ((pte_t) { (x) } )
  43. #define __pmd(x) ((pmd_t) { (x) } )
  44. #define __pgd(x) ((pgd_t) { (x) } )
  45. #define __pgprot(x) ((pgprot_t) { (x) } )
  46. #define __pmd_val_set(x,n) (x).pmd = (n)
  47. #define __pgd_val_set(x,n) (x).pgd = (n)
  48. #else
  49. /*
  50. * .. while these make it easier on the compiler
  51. */
  52. typedef unsigned long pte_t;
  53. typedef __u32 pmd_t;
  54. typedef __u32 pgd_t;
  55. typedef unsigned long pgprot_t;
  56. #define pte_val(x) (x)
  57. #define pmd_val(x) (x)
  58. #define pgd_val(x) (x)
  59. #define pgprot_val(x) (x)
  60. #define __pte(x) (x)
  61. #define __pmd(x) (x)
  62. #define __pgd(x) (x)
  63. #define __pgprot(x) (x)
  64. #define __pmd_val_set(x,n) (x) = (n)
  65. #define __pgd_val_set(x,n) (x) = (n)
  66. #endif /* STRICT_MM_TYPECHECKS */
  67. typedef struct page *pgtable_t;
  68. typedef struct __physmem_range {
  69. unsigned long start_pfn;
  70. unsigned long pages; /* PAGE_SIZE pages */
  71. } physmem_range_t;
  72. extern physmem_range_t pmem_ranges[];
  73. extern int npmem_ranges;
  74. #endif /* !__ASSEMBLY__ */
  75. /* WARNING: The definitions below must match exactly to sizeof(pte_t)
  76. * etc
  77. */
  78. #ifdef CONFIG_64BIT
  79. #define BITS_PER_PTE_ENTRY 3
  80. #define BITS_PER_PMD_ENTRY 2
  81. #define BITS_PER_PGD_ENTRY 2
  82. #else
  83. #define BITS_PER_PTE_ENTRY 2
  84. #define BITS_PER_PMD_ENTRY 2
  85. #define BITS_PER_PGD_ENTRY BITS_PER_PMD_ENTRY
  86. #endif
  87. #define PGD_ENTRY_SIZE (1UL << BITS_PER_PGD_ENTRY)
  88. #define PMD_ENTRY_SIZE (1UL << BITS_PER_PMD_ENTRY)
  89. #define PTE_ENTRY_SIZE (1UL << BITS_PER_PTE_ENTRY)
  90. #define LINUX_GATEWAY_SPACE 0
  91. /* This governs the relationship between virtual and physical addresses.
  92. * If you alter it, make sure to take care of our various fixed mapping
  93. * segments in fixmap.h */
  94. #ifdef CONFIG_64BIT
  95. #define __PAGE_OFFSET (0x40000000) /* 1GB */
  96. #else
  97. #define __PAGE_OFFSET (0x10000000) /* 256MB */
  98. #endif
  99. #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
  100. /* The size of the gateway page (we leave lots of room for expansion) */
  101. #define GATEWAY_PAGE_SIZE 0x4000
  102. /* The start of the actual kernel binary---used in vmlinux.lds.S
  103. * Leave some space after __PAGE_OFFSET for detecting kernel null
  104. * ptr derefs */
  105. #define KERNEL_BINARY_TEXT_START (__PAGE_OFFSET + 0x100000)
  106. /* These macros don't work for 64-bit C code -- don't allow in C at all */
  107. #ifdef __ASSEMBLY__
  108. # define PA(x) ((x)-__PAGE_OFFSET)
  109. # define VA(x) ((x)+__PAGE_OFFSET)
  110. #endif
  111. #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
  112. #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
  113. #ifndef CONFIG_DISCONTIGMEM
  114. #define pfn_valid(pfn) ((pfn) < max_mapnr)
  115. #endif /* CONFIG_DISCONTIGMEM */
  116. #ifdef CONFIG_HUGETLB_PAGE
  117. #define HPAGE_SHIFT 22 /* 4MB (is this fixed?) */
  118. #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
  119. #define HPAGE_MASK (~(HPAGE_SIZE - 1))
  120. #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
  121. #endif
  122. #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
  123. #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
  124. #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
  125. #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
  126. VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  127. #include <asm-generic/memory_model.h>
  128. #include <asm-generic/getorder.h>
  129. #include <asm/pdc.h>
  130. #define PAGE0 ((struct zeropage *)__PAGE_OFFSET)
  131. /* DEFINITION OF THE ZERO-PAGE (PAG0) */
  132. /* based on work by Jason Eckhardt (jason@equator.com) */
  133. #endif /* _PARISC_PAGE_H */