blob: b2628dc5c49075d0841c9b440c2b8a8288f4cd6e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <asm/types.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))
Peter Oberparleiter0b642ed2005-05-01 08:58:58 -070018#define PAGE_DEFAULT_ACC 0
19#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#ifdef __KERNEL__
David Woodhouse274f5942006-04-27 04:47:10 +010022#include <asm/setup.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#ifndef __ASSEMBLY__
24
25#ifndef __s390x__
26
27static inline void clear_page(void *page)
28{
29 register_pair rp;
30
31 rp.subreg.even = (unsigned long) page;
32 rp.subreg.odd = (unsigned long) 4096;
33 asm volatile (" slr 1,1\n"
34 " mvcl %0,0"
35 : "+&a" (rp) : : "memory", "cc", "1" );
36}
37
38static inline void copy_page(void *to, void *from)
39{
40 if (MACHINE_HAS_MVPG)
41 asm volatile (" sr 0,0\n"
42 " mvpg %0,%1"
43 : : "a" ((void *)(to)), "a" ((void *)(from))
44 : "memory", "cc", "0" );
45 else
46 asm volatile (" mvc 0(256,%0),0(%1)\n"
47 " mvc 256(256,%0),256(%1)\n"
48 " mvc 512(256,%0),512(%1)\n"
49 " mvc 768(256,%0),768(%1)\n"
50 " mvc 1024(256,%0),1024(%1)\n"
51 " mvc 1280(256,%0),1280(%1)\n"
52 " mvc 1536(256,%0),1536(%1)\n"
53 " mvc 1792(256,%0),1792(%1)\n"
54 " mvc 2048(256,%0),2048(%1)\n"
55 " mvc 2304(256,%0),2304(%1)\n"
56 " mvc 2560(256,%0),2560(%1)\n"
57 " mvc 2816(256,%0),2816(%1)\n"
58 " mvc 3072(256,%0),3072(%1)\n"
59 " mvc 3328(256,%0),3328(%1)\n"
60 " mvc 3584(256,%0),3584(%1)\n"
61 " mvc 3840(256,%0),3840(%1)\n"
62 : : "a"((void *)(to)),"a"((void *)(from))
63 : "memory" );
64}
65
66#else /* __s390x__ */
67
68static inline void clear_page(void *page)
69{
70 asm volatile (" lgr 2,%0\n"
71 " lghi 3,4096\n"
72 " slgr 1,1\n"
73 " mvcl 2,0"
74 : : "a" ((void *) (page))
75 : "memory", "cc", "1", "2", "3" );
76}
77
78static inline void copy_page(void *to, void *from)
79{
80 if (MACHINE_HAS_MVPG)
81 asm volatile (" sgr 0,0\n"
82 " mvpg %0,%1"
83 : : "a" ((void *)(to)), "a" ((void *)(from))
84 : "memory", "cc", "0" );
85 else
86 asm volatile (" mvc 0(256,%0),0(%1)\n"
87 " mvc 256(256,%0),256(%1)\n"
88 " mvc 512(256,%0),512(%1)\n"
89 " mvc 768(256,%0),768(%1)\n"
90 " mvc 1024(256,%0),1024(%1)\n"
91 " mvc 1280(256,%0),1280(%1)\n"
92 " mvc 1536(256,%0),1536(%1)\n"
93 " mvc 1792(256,%0),1792(%1)\n"
94 " mvc 2048(256,%0),2048(%1)\n"
95 " mvc 2304(256,%0),2304(%1)\n"
96 " mvc 2560(256,%0),2560(%1)\n"
97 " mvc 2816(256,%0),2816(%1)\n"
98 " mvc 3072(256,%0),3072(%1)\n"
99 " mvc 3328(256,%0),3328(%1)\n"
100 " mvc 3584(256,%0),3584(%1)\n"
101 " mvc 3840(256,%0),3840(%1)\n"
102 : : "a"((void *)(to)),"a"((void *)(from))
103 : "memory" );
104}
105
106#endif /* __s390x__ */
107
108#define clear_user_page(page, vaddr, pg) clear_page(page)
109#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
110
111#define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
112#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114/*
115 * These are used to make use of C type-checking..
116 */
117
118typedef struct { unsigned long pgprot; } pgprot_t;
119typedef struct { unsigned long pte; } pte_t;
120
121#define pte_val(x) ((x).pte)
122#define pgprot_val(x) ((x).pgprot)
123
124#ifndef __s390x__
125
126typedef struct { unsigned long pmd; } pmd_t;
127typedef struct {
128 unsigned long pgd0;
129 unsigned long pgd1;
130 unsigned long pgd2;
131 unsigned long pgd3;
132 } pgd_t;
133
134#define pmd_val(x) ((x).pmd)
135#define pgd_val(x) ((x).pgd0)
136
137#else /* __s390x__ */
138
139typedef struct {
140 unsigned long pmd0;
141 unsigned long pmd1;
142 } pmd_t;
143typedef struct { unsigned long pgd; } pgd_t;
144
145#define pmd_val(x) ((x).pmd0)
146#define pmd_val1(x) ((x).pmd1)
147#define pgd_val(x) ((x).pgd)
148
149#endif /* __s390x__ */
150
151#define __pte(x) ((pte_t) { (x) } )
152#define __pmd(x) ((pmd_t) { (x) } )
153#define __pgd(x) ((pgd_t) { (x) } )
154#define __pgprot(x) ((pgprot_t) { (x) } )
155
156/* default storage key used for all pages */
157extern unsigned int default_storage_key;
158
159static inline void
160page_set_storage_key(unsigned long addr, unsigned int skey)
161{
162 asm volatile ( "sske %0,%1" : : "d" (skey), "a" (addr) );
163}
164
165static inline unsigned int
166page_get_storage_key(unsigned long addr)
167{
168 unsigned int skey;
169
170 asm volatile ( "iske %0,%1" : "=d" (skey) : "a" (addr), "0" (0) );
171
172 return skey;
173}
174
175#endif /* !__ASSEMBLY__ */
176
177/* to align the pointer to the (next) page boundary */
178#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
179
180#define __PAGE_OFFSET 0x0UL
181#define PAGE_OFFSET 0x0UL
182#define __pa(x) (unsigned long)(x)
183#define __va(x) (void *)(unsigned long)(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
185
186#define pfn_valid(pfn) ((pfn) < max_mapnr)
187#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
188
189#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
190 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
191
KAMEZAWA Hiroyukiaed63042006-03-27 01:15:45 -0800192#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700193#include <asm-generic/page.h>
194
David Woodhouse274f5942006-04-27 04:47:10 +0100195#endif /* __KERNEL__ */
196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197#endif /* _S390_PAGE_H */