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