blob: 32e8f6aa4384245892a6523943d7819f0c808cb6 [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
Sam Ravnborg52480ee2007-10-12 16:11:50 +020012#include <linux/const.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/types.h>
14
15/* PAGE_SHIFT determines the page size */
16#define PAGE_SHIFT 12
Sam Ravnborg52480ee2007-10-12 16:11:50 +020017#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#define PAGE_MASK (~(PAGE_SIZE-1))
Peter Oberparleiter0b642ed2005-05-01 08:58:58 -070019#define PAGE_DEFAULT_ACC 0
20#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Gerald Schaefer53492b12008-04-30 13:38:46 +020022#define HPAGE_SHIFT 20
23#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
24#define HPAGE_MASK (~(HPAGE_SIZE - 1))
25#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
26
27#define ARCH_HAS_SETCLEAR_HUGE_PTE
28#define ARCH_HAS_HUGE_PTE_TYPE
29#define ARCH_HAS_PREPARE_HUGEPAGE
30#define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH
31
David Woodhouse274f5942006-04-27 04:47:10 +010032#include <asm/setup.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#ifndef __ASSEMBLY__
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035static inline void clear_page(void *page)
36{
Gerald Schaefer53492b12008-04-30 13:38:46 +020037 if (MACHINE_HAS_PFMF) {
38 asm volatile(
39 " .insn rre,0xb9af0000,%0,%1"
40 : : "d" (0x10000), "a" (page) : "memory", "cc");
41 } else {
42 register unsigned long reg1 asm ("1") = 0;
43 register void *reg2 asm ("2") = page;
44 register unsigned long reg3 asm ("3") = 4096;
45 asm volatile(
46 " mvcl 2,0"
47 : "+d" (reg2), "+d" (reg3) : "d" (reg1)
48 : "memory", "cc");
49 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
52static inline void copy_page(void *to, void *from)
53{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020054 if (MACHINE_HAS_MVPG) {
55 register unsigned long reg0 asm ("0") = 0;
56 asm volatile(
57 " mvpg %0,%1"
58 : : "a" (to), "a" (from), "d" (reg0)
59 : "memory", "cc");
60 } else
61 asm volatile(
62 " mvc 0(256,%0),0(%1)\n"
63 " mvc 256(256,%0),256(%1)\n"
64 " mvc 512(256,%0),512(%1)\n"
65 " mvc 768(256,%0),768(%1)\n"
66 " mvc 1024(256,%0),1024(%1)\n"
67 " mvc 1280(256,%0),1280(%1)\n"
68 " mvc 1536(256,%0),1536(%1)\n"
69 " mvc 1792(256,%0),1792(%1)\n"
70 " mvc 2048(256,%0),2048(%1)\n"
71 " mvc 2304(256,%0),2304(%1)\n"
72 " mvc 2560(256,%0),2560(%1)\n"
73 " mvc 2816(256,%0),2816(%1)\n"
74 " mvc 3072(256,%0),3072(%1)\n"
75 " mvc 3328(256,%0),3328(%1)\n"
76 " mvc 3584(256,%0),3584(%1)\n"
77 " mvc 3840(256,%0),3840(%1)\n"
78 : : "a" (to), "a" (from) : "memory");
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#define clear_user_page(page, vaddr, pg) clear_page(page)
82#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
83
Mel Gorman769848c2007-07-17 04:03:05 -070084#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
85 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088/*
89 * These are used to make use of C type-checking..
90 */
91
92typedef struct { unsigned long pgprot; } pgprot_t;
93typedef struct { unsigned long pte; } pte_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094typedef struct { unsigned long pmd; } pmd_t;
Martin Schwidefsky190a1d72007-10-22 12:52:48 +020095typedef struct { unsigned long pud; } pud_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096typedef struct { unsigned long pgd; } pgd_t;
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010097typedef pte_t *pgtable_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Martin Schwidefsky146e4b32008-02-09 18:24:35 +010099#define pgprot_val(x) ((x).pgprot)
100#define pte_val(x) ((x).pte)
101#define pmd_val(x) ((x).pmd)
Martin Schwidefsky190a1d72007-10-22 12:52:48 +0200102#define pud_val(x) ((x).pud)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define pgd_val(x) ((x).pgd)
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#define __pte(x) ((pte_t) { (x) } )
106#define __pmd(x) ((pmd_t) { (x) } )
107#define __pgd(x) ((pgd_t) { (x) } )
108#define __pgprot(x) ((pgprot_t) { (x) } )
109
110/* default storage key used for all pages */
111extern unsigned int default_storage_key;
112
113static inline void
114page_set_storage_key(unsigned long addr, unsigned int skey)
115{
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200116 asm volatile("sske %0,%1" : : "d" (skey), "a" (addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117}
118
119static inline unsigned int
120page_get_storage_key(unsigned long addr)
121{
122 unsigned int skey;
123
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +0200124 asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr), "0" (0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 return skey;
126}
127
Martin Schwidefsky45e576b2008-05-07 09:22:59 +0200128#ifdef CONFIG_PAGE_STATES
129
130struct page;
131void arch_free_page(struct page *page, int order);
132void arch_alloc_page(struct page *page, int order);
133
134#define HAVE_ARCH_FREE_PAGE
135#define HAVE_ARCH_ALLOC_PAGE
136
137#endif
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#endif /* !__ASSEMBLY__ */
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#define __PAGE_OFFSET 0x0UL
142#define PAGE_OFFSET 0x0UL
143#define __pa(x) (unsigned long)(x)
144#define __va(x) (void *)(unsigned long)(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
Heiko Carstens0b2b6e12006-10-04 20:02:23 +0200146#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
148
Martin Schwidefsky146e4b32008-02-09 18:24:35 +0100149#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
151
KAMEZAWA Hiroyukiaed63042006-03-27 01:15:45 -0800152#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700153#include <asm-generic/page.h>
154
Martin Schwidefskyb0206322008-12-25 13:38:36 +0100155#define __HAVE_ARCH_GATE_AREA 1
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#endif /* _S390_PAGE_H */