1 #ifndef _PARISC_PAGE_H
2 #define _PARISC_PAGE_H
3 
4 /* PAGE_SHIFT determines the page size */
5 #define PAGE_SHIFT	12
6 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
7 #define PAGE_MASK	(~(PAGE_SIZE-1))
8 
9 #ifdef __KERNEL__
10 #ifndef __ASSEMBLY__
11 
12 #include <asm/cache.h>
13 
14 #define clear_page(page)	memset((void *)(page), 0, PAGE_SIZE)
15 #define copy_page(to,from)      copy_user_page_asm((void *)(to), (void *)(from))
16 
17 extern void purge_kernel_dcache_page(unsigned long);
18 extern void copy_user_page_asm(void *to, void *from);
19 extern void clear_user_page_asm(void *page, unsigned long vaddr);
20 
21 static inline void
copy_user_page(void * to,void * from,unsigned long vaddr)22 copy_user_page(void *to, void *from, unsigned long vaddr)
23 {
24 	copy_user_page_asm(to, from);
25 	flush_kernel_dcache_page(to);
26 }
27 
28 static inline void
clear_user_page(void * page,unsigned long vaddr)29 clear_user_page(void *page, unsigned long vaddr)
30 {
31 	purge_kernel_dcache_page((unsigned long)page);
32 	clear_user_page_asm(page, vaddr);
33 }
34 
35 /*
36  * These are used to make use of C type-checking..
37  */
38 typedef struct { unsigned long pte; } pte_t;
39 typedef struct { unsigned long pmd; } pmd_t;
40 typedef struct { unsigned long pgd; } pgd_t;
41 typedef struct { unsigned long pgprot; } pgprot_t;
42 
43 #define pte_val(x)	((x).pte)
44 #define pmd_val(x)	((x).pmd)
45 #define pgd_val(x)	((x).pgd)
46 #define pgprot_val(x)	((x).pgprot)
47 
48 #define __pte(x)	((pte_t) { (x) } )
49 #define __pmd(x)	((pmd_t) { (x) } )
50 #define __pgd(x)	((pgd_t) { (x) } )
51 #define __pgprot(x)	((pgprot_t) { (x) } )
52 
53 /* Pure 2^n version of get_order */
get_order(unsigned long size)54 extern __inline__ int get_order(unsigned long size)
55 {
56 	int order;
57 
58 	size = (size-1) >> (PAGE_SHIFT-1);
59 	order = -1;
60 	do {
61 		size >>= 1;
62 		order++;
63 	} while (size);
64 	return order;
65 }
66 
67 #ifdef __LP64__
68 #define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
69 #else
70 #define MAX_PHYSMEM_RANGES 1 /* First range is only range that fits in 32 bits */
71 #endif
72 
73 typedef struct __physmem_range {
74 	unsigned long start_pfn;
75 	unsigned long pages;       /* PAGE_SIZE pages */
76 } physmem_range_t;
77 
78 extern physmem_range_t pmem_ranges[];
79 extern int npmem_ranges;
80 
81 #endif /* !__ASSEMBLY__ */
82 
83 /* to align the pointer to the (next) page boundary */
84 #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
85 
86 /*
87  * Tell the user there is some problem. Beep too, so we can
88  * see^H^H^Hhear bugs in early bootup as well!
89  *
90  * We don't beep yet.  prumpf
91  */
92 #define BUG() do { \
93 	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
94 } while (0)
95 
96 #define PAGE_BUG(page) do { \
97 	BUG(); \
98 } while (0)
99 
100 
101 #define LINUX_GATEWAY_SPACE     0
102 #define __PAGE_OFFSET           (0x10000000)
103 
104 #define PAGE_OFFSET		((unsigned long)__PAGE_OFFSET)
105 /* These macros don't work for 64-bit C code -- don't allow in C at all */
106 #ifdef __ASSEMBLY__
107 #   define PA(x)	((x)-__PAGE_OFFSET)
108 #   define VA(x)	((x)+__PAGE_OFFSET)
109 #endif
110 #define __pa(x)			((unsigned long)(x)-PAGE_OFFSET)
111 #define __va(x)			((void *)((unsigned long)(x)+PAGE_OFFSET))
112 #ifndef CONFIG_DISCONTIGMEM
113 #define virt_to_page(kaddr)     (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
114 #define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
115 #endif  /* !CONFIG_DISCONTIGMEM */
116 
117 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
118 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
119 
120 #endif /* __KERNEL__ */
121 
122 #endif /* _PARISC_PAGE_H */
123