1 /*
2  *  include/asm-s390/page.h
3  *
4  *  S390 version
5  *    Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6  *    Author(s): Hartmut Penner (hp@de.ibm.com)
7  */
8 
9 #ifndef _S390_PAGE_H
10 #define _S390_PAGE_H
11 
12 #include <asm/setup.h>
13 #include <asm/types.h>
14 
15 /* PAGE_SHIFT determines the page size */
16 #define PAGE_SHIFT      12
17 #define PAGE_SIZE       (1UL << PAGE_SHIFT)
18 #define PAGE_MASK       (~(PAGE_SIZE-1))
19 
20 #ifdef __KERNEL__
21 #ifndef __ASSEMBLY__
22 
clear_page(void * page)23 static inline void clear_page(void *page)
24 {
25 	register_pair rp;
26 
27 	rp.subreg.even = (unsigned long) page;
28 	rp.subreg.odd = (unsigned long) 4096;
29         asm volatile ("   slr  1,1\n"
30 		      "   mvcl %0,0"
31 		      : "+&a" (rp) : : "memory", "cc", "1" );
32 }
33 
copy_page(void * to,void * from)34 static inline void copy_page(void *to, void *from)
35 {
36         if (MACHINE_HAS_MVPG)
37 		asm volatile ("   sr   0,0\n"
38 			      "   mvpg %0,%1"
39 			      : : "a" ((void *)(to)), "a" ((void *)(from))
40 			      : "memory", "cc", "0" );
41 	else
42 		asm volatile ("   mvc  0(256,%0),0(%1)\n"
43 			      "   mvc  256(256,%0),256(%1)\n"
44 			      "   mvc  512(256,%0),512(%1)\n"
45 			      "   mvc  768(256,%0),768(%1)\n"
46 			      "   mvc  1024(256,%0),1024(%1)\n"
47 			      "   mvc  1280(256,%0),1280(%1)\n"
48 			      "   mvc  1536(256,%0),1536(%1)\n"
49 			      "   mvc  1792(256,%0),1792(%1)\n"
50 			      "   mvc  2048(256,%0),2048(%1)\n"
51 			      "   mvc  2304(256,%0),2304(%1)\n"
52 			      "   mvc  2560(256,%0),2560(%1)\n"
53 			      "   mvc  2816(256,%0),2816(%1)\n"
54 			      "   mvc  3072(256,%0),3072(%1)\n"
55 			      "   mvc  3328(256,%0),3328(%1)\n"
56 			      "   mvc  3584(256,%0),3584(%1)\n"
57 			      "   mvc  3840(256,%0),3840(%1)\n"
58 			      : : "a"((void *)(to)),"a"((void *)(from))
59 			      : "memory" );
60 }
61 
62 #define clear_user_page(page, vaddr)	clear_page(page)
63 #define copy_user_page(to, from, vaddr)	copy_page(to, from)
64 
65 #define BUG() do { \
66         printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
67         __asm__ __volatile__(".long 0"); \
68 } while (0)
69 
70 #define PAGE_BUG(page) do { \
71         BUG(); \
72 } while (0)
73 
74 /* Pure 2^n version of get_order */
get_order(unsigned long size)75 extern __inline__ int get_order(unsigned long size)
76 {
77         int order;
78 
79         size = (size-1) >> (PAGE_SHIFT-1);
80         order = -1;
81         do {
82                 size >>= 1;
83                 order++;
84         } while (size);
85         return order;
86 }
87 
88 /*
89  * These are used to make use of C type-checking..
90  */
91 typedef struct { unsigned long pte; } pte_t;
92 typedef struct { unsigned long pmd; } pmd_t;
93 typedef struct {
94         unsigned long pgd0;
95         unsigned long pgd1;
96         unsigned long pgd2;
97         unsigned long pgd3;
98         } pgd_t;
99 typedef struct { unsigned long pgprot; } pgprot_t;
100 
101 #define pte_val(x)      ((x).pte)
102 #define pmd_val(x)      ((x).pmd)
103 #define pgd_val(x)      ((x).pgd0)
104 #define pgprot_val(x)   ((x).pgprot)
105 
106 #define __pte(x)        ((pte_t) { (x) } )
107 #define __pmd(x)        ((pmd_t) { (x) } )
108 #define __pgd(x)        ((pgd_t) { (x) } )
109 #define __pgprot(x)     ((pgprot_t) { (x) } )
110 
111 #endif /* !__ASSEMBLY__ */
112 
113 /* to align the pointer to the (next) page boundary */
114 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
115 
116 #define __PAGE_OFFSET           0x0UL
117 #define PAGE_OFFSET             0x0UL
118 #define __pa(x)                 (unsigned long)(x)
119 #define __va(x)                 (void *)(x)
120 #define virt_to_page(kaddr)	(mem_map + (__pa(kaddr) >> PAGE_SHIFT))
121 #define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
122 
123 #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
124 				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
125 
126 unsigned int get_storage_key(void);
127 unsigned long pfix_get_page_addr(void *);
128 unsigned long pfix_get_addr(void *);
129 
130 #endif /* __KERNEL__ */
131 
132 #endif /* _S390_PAGE_H */
133