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