xref: /linux/arch/alpha/include/asm/page.h (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ALPHA_PAGE_H
3 #define _ALPHA_PAGE_H
4 
5 #include <linux/const.h>
6 #include <asm/pal.h>
7 #include <vdso/page.h>
8 
9 #ifndef __ASSEMBLY__
10 
11 #define STRICT_MM_TYPECHECKS
12 
13 extern void clear_page(void *page);
14 #define clear_user_page(page, vaddr, pg)	clear_page(page)
15 
16 #define vma_alloc_zeroed_movable_folio(vma, vaddr) \
17 	vma_alloc_folio(GFP_HIGHUSER_MOVABLE | __GFP_ZERO, 0, vma, vaddr)
18 
19 extern void copy_page(void * _to, void * _from);
20 #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
21 
22 #ifdef STRICT_MM_TYPECHECKS
23 /*
24  * These are used to make use of C type-checking..
25  */
26 typedef struct { unsigned long pte; } pte_t;
27 typedef struct { unsigned long pmd; } pmd_t;
28 typedef struct { unsigned long pgd; } pgd_t;
29 typedef struct { unsigned long pgprot; } pgprot_t;
30 
31 #define pte_val(x)	((x).pte)
32 #define pmd_val(x)	((x).pmd)
33 #define pgd_val(x)	((x).pgd)
34 #define pgprot_val(x)	((x).pgprot)
35 
36 #define __pte(x)	((pte_t) { (x) } )
37 #define __pmd(x)	((pmd_t) { (x) } )
38 #define __pgd(x)	((pgd_t) { (x) } )
39 #define __pgprot(x)	((pgprot_t) { (x) } )
40 
41 #else
42 /*
43  * .. while these make it easier on the compiler
44  */
45 typedef unsigned long pte_t;
46 typedef unsigned long pmd_t;
47 typedef unsigned long pgd_t;
48 typedef unsigned long pgprot_t;
49 
50 #define pte_val(x)	(x)
51 #define pmd_val(x)	(x)
52 #define pgd_val(x)	(x)
53 #define pgprot_val(x)	(x)
54 
55 #define __pte(x)	(x)
56 #define __pgd(x)	(x)
57 #define __pgprot(x)	(x)
58 
59 #endif /* STRICT_MM_TYPECHECKS */
60 
61 typedef struct page *pgtable_t;
62 
63 #ifdef USE_48_BIT_KSEG
64 #define PAGE_OFFSET		0xffff800000000000UL
65 #else
66 #define PAGE_OFFSET		0xfffffc0000000000UL
67 #endif
68 
69 #else
70 
71 #ifdef USE_48_BIT_KSEG
72 #define PAGE_OFFSET		0xffff800000000000
73 #else
74 #define PAGE_OFFSET		0xfffffc0000000000
75 #endif
76 
77 #endif /* !__ASSEMBLY__ */
78 
79 #define __pa(x)			((unsigned long) (x) - PAGE_OFFSET)
80 #define __va(x)			((void *)((unsigned long) (x) + PAGE_OFFSET))
81 
82 #define virt_to_page(kaddr)	pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
83 #define virt_addr_valid(kaddr)	pfn_valid((__pa(kaddr) >> PAGE_SHIFT))
84 
85 #include <asm-generic/memory_model.h>
86 #include <asm-generic/getorder.h>
87 
88 #endif /* _ALPHA_PAGE_H */
89