blob: 796c400f2b79963c5f63f2bf7a5640d3a4e6880f [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070025static inline void clear_page(void *page)
26{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020027 register unsigned long reg1 asm ("1") = 0;
28 register void *reg2 asm ("2") = page;
29 register unsigned long reg3 asm ("3") = 4096;
30 asm volatile(
31 " mvcl 2,0"
32 : "+d" (reg2), "+d" (reg3) : "d" (reg1) : "memory", "cc");
Linus Torvalds1da177e2005-04-16 15:20:36 -070033}
34
35static inline void copy_page(void *to, void *from)
36{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020037 if (MACHINE_HAS_MVPG) {
38 register unsigned long reg0 asm ("0") = 0;
39 asm volatile(
40 " mvpg %0,%1"
41 : : "a" (to), "a" (from), "d" (reg0)
42 : "memory", "cc");
43 } else
44 asm volatile(
45 " mvc 0(256,%0),0(%1)\n"
46 " mvc 256(256,%0),256(%1)\n"
47 " mvc 512(256,%0),512(%1)\n"
48 " mvc 768(256,%0),768(%1)\n"
49 " mvc 1024(256,%0),1024(%1)\n"
50 " mvc 1280(256,%0),1280(%1)\n"
51 " mvc 1536(256,%0),1536(%1)\n"
52 " mvc 1792(256,%0),1792(%1)\n"
53 " mvc 2048(256,%0),2048(%1)\n"
54 " mvc 2304(256,%0),2304(%1)\n"
55 " mvc 2560(256,%0),2560(%1)\n"
56 " mvc 2816(256,%0),2816(%1)\n"
57 " mvc 3072(256,%0),3072(%1)\n"
58 " mvc 3328(256,%0),3328(%1)\n"
59 " mvc 3584(256,%0),3584(%1)\n"
60 " mvc 3840(256,%0),3840(%1)\n"
61 : : "a" (to), "a" (from) : "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define clear_user_page(page, vaddr, pg) clear_page(page)
65#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
66
67#define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr)
68#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070/*
71 * These are used to make use of C type-checking..
72 */
73
74typedef struct { unsigned long pgprot; } pgprot_t;
75typedef struct { unsigned long pte; } pte_t;
76
77#define pte_val(x) ((x).pte)
78#define pgprot_val(x) ((x).pgprot)
79
80#ifndef __s390x__
81
82typedef struct { unsigned long pmd; } pmd_t;
83typedef struct {
84 unsigned long pgd0;
85 unsigned long pgd1;
86 unsigned long pgd2;
87 unsigned long pgd3;
88 } pgd_t;
89
90#define pmd_val(x) ((x).pmd)
91#define pgd_val(x) ((x).pgd0)
92
93#else /* __s390x__ */
94
95typedef struct {
96 unsigned long pmd0;
97 unsigned long pmd1;
98 } pmd_t;
99typedef struct { unsigned long pgd; } pgd_t;
100
101#define pmd_val(x) ((x).pmd0)
102#define pmd_val1(x) ((x).pmd1)
103#define pgd_val(x) ((x).pgd)
104
105#endif /* __s390x__ */
106
107#define __pte(x) ((pte_t) { (x) } )
108#define __pmd(x) ((pmd_t) { (x) } )
109#define __pgd(x) ((pgd_t) { (x) } )
110#define __pgprot(x) ((pgprot_t) { (x) } )
111
112/* default storage key used for all pages */
113extern unsigned int default_storage_key;
114
115static inline void
116page_set_storage_key(unsigned long addr, unsigned int skey)
117{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200118 asm volatile("sske %0,%1" : : "d" (skey), "a" (addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119}
120
121static inline unsigned int
122page_get_storage_key(unsigned long addr)
123{
124 unsigned int skey;
125
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200126 asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr), "0" (0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 return skey;
128}
129
130#endif /* !__ASSEMBLY__ */
131
132/* to align the pointer to the (next) page boundary */
133#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
134
135#define __PAGE_OFFSET 0x0UL
136#define PAGE_OFFSET 0x0UL
137#define __pa(x) (unsigned long)(x)
138#define __va(x) (void *)(unsigned long)(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
140
141#define pfn_valid(pfn) ((pfn) < max_mapnr)
142#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
143
144#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
145 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
146
KAMEZAWA Hiroyukiaed63042006-03-27 01:15:45 -0800147#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700148#include <asm-generic/page.h>
149
David Woodhouse274f5942006-04-27 04:47:10 +0100150#endif /* __KERNEL__ */
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif /* _S390_PAGE_H */