3 * Copyright IBM Corp. 1999, 2000
4 * Author(s): Hartmut Penner (hp@de.ibm.com)
10 #include <linux/const.h>
11 #include <asm/types.h>
13 /* PAGE_SHIFT determines the page size */
15 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
16 #define PAGE_MASK (~(PAGE_SIZE-1))
17 #define PAGE_DEFAULT_ACC 0
18 #define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
20 #define HPAGE_SHIFT 20
21 #define HPAGE_SIZE (1UL << HPAGE_SHIFT)
22 #define HPAGE_MASK (~(HPAGE_SIZE - 1))
23 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
25 #define ARCH_HAS_SETCLEAR_HUGE_PTE
26 #define ARCH_HAS_HUGE_PTE_TYPE
27 #define ARCH_HAS_PREPARE_HUGEPAGE
28 #define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH
30 #include <asm/setup.h>
33 static inline void storage_key_init_range(unsigned long start
, unsigned long end
)
36 __storage_key_init_range(start
, end
);
40 static inline void clear_page(void *page
)
42 register unsigned long reg1
asm ("1") = 0;
43 register void *reg2
asm ("2") = page
;
44 register unsigned long reg3
asm ("3") = 4096;
47 : "+d" (reg2
), "+d" (reg3
) : "d" (reg1
)
52 * copy_page uses the mvcl instruction with 0xb0 padding byte in order to
53 * bypass caches when copying a page. Especially when copying huge pages
54 * this keeps L1 and L2 data caches alive.
56 static inline void copy_page(void *to
, void *from
)
58 register void *reg2
asm ("2") = to
;
59 register unsigned long reg3
asm ("3") = 0x1000;
60 register void *reg4
asm ("4") = from
;
61 register unsigned long reg5
asm ("5") = 0xb0001000;
64 : "+d" (reg2
), "+d" (reg3
), "+d" (reg4
), "+d" (reg5
)
68 #define clear_user_page(page, vaddr, pg) clear_page(page)
69 #define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
71 #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
72 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
73 #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
76 * These are used to make use of C type-checking..
79 typedef struct { unsigned long pgprot
; } pgprot_t
;
80 typedef struct { unsigned long pgste
; } pgste_t
;
81 typedef struct { unsigned long pte
; } pte_t
;
82 typedef struct { unsigned long pmd
; } pmd_t
;
83 typedef struct { unsigned long pud
; } pud_t
;
84 typedef struct { unsigned long pgd
; } pgd_t
;
85 typedef pte_t
*pgtable_t
;
87 #define pgprot_val(x) ((x).pgprot)
88 #define pgste_val(x) ((x).pgste)
89 #define pte_val(x) ((x).pte)
90 #define pmd_val(x) ((x).pmd)
91 #define pud_val(x) ((x).pud)
92 #define pgd_val(x) ((x).pgd)
94 #define __pgste(x) ((pgste_t) { (x) } )
95 #define __pte(x) ((pte_t) { (x) } )
96 #define __pmd(x) ((pmd_t) { (x) } )
97 #define __pud(x) ((pud_t) { (x) } )
98 #define __pgd(x) ((pgd_t) { (x) } )
99 #define __pgprot(x) ((pgprot_t) { (x) } )
101 static inline void page_set_storage_key(unsigned long addr
,
102 unsigned char skey
, int mapped
)
105 asm volatile(".insn rrf,0xb22b0000,%0,%1,8,0"
106 : : "d" (skey
), "a" (addr
));
108 asm volatile("sske %0,%1" : : "d" (skey
), "a" (addr
));
111 static inline unsigned char page_get_storage_key(unsigned long addr
)
115 asm volatile("iske %0,%1" : "=d" (skey
) : "a" (addr
));
119 static inline int page_reset_referenced(unsigned long addr
)
126 : "=d" (ipm
) : "a" (addr
) : "cc");
127 return !!(ipm
& 0x20000000);
130 /* Bits int the storage key */
131 #define _PAGE_CHANGED 0x02 /* HW changed bit */
132 #define _PAGE_REFERENCED 0x04 /* HW referenced bit */
133 #define _PAGE_FP_BIT 0x08 /* HW fetch protection bit */
134 #define _PAGE_ACC_BITS 0xf0 /* HW access control bits */
137 void arch_free_page(struct page
*page
, int order
);
138 void arch_alloc_page(struct page
*page
, int order
);
139 void arch_set_page_states(int make_stable
);
141 static inline int devmem_is_allowed(unsigned long pfn
)
146 #define HAVE_ARCH_FREE_PAGE
147 #define HAVE_ARCH_ALLOC_PAGE
149 #endif /* !__ASSEMBLY__ */
151 #define __PAGE_OFFSET 0x0UL
152 #define PAGE_OFFSET 0x0UL
153 #define __pa(x) (unsigned long)(x)
154 #define __va(x) (void *)(unsigned long)(x)
155 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
156 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
157 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
159 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
160 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
162 #include <asm-generic/memory_model.h>
163 #include <asm-generic/getorder.h>
165 #endif /* _S390_PAGE_H */