1 #ifndef _SPARC64_PAGE_H
2 #define _SPARC64_PAGE_H
4 #include <linux/const.h>
6 #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
8 #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
11 #error No page size specified in kernel configuration
14 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
15 #define PAGE_MASK (~(PAGE_SIZE-1))
17 /* Flushing for D-cache alias handling is only needed if
18 * the page size is smaller than 16K.
21 #define DCACHE_ALIASING_POSSIBLE
24 #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
25 #define HPAGE_SHIFT 22
26 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
27 #define HPAGE_SHIFT 19
28 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
29 #define HPAGE_SHIFT 16
32 #ifdef CONFIG_HUGETLB_PAGE
33 #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
34 #define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
35 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
36 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
41 extern void _clear_page(void *page);
42 #define clear_page(X) _clear_page((void *)(X))
44 extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
45 #define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
46 extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
48 /* Unlike sparc32, sparc64's parameter passing API is more
49 * sane in that structures which as small enough are passed
50 * in registers instead of on the stack. Thus, setting
51 * STRICT_MM_TYPECHECKS does not generate worse code so
52 * let's enable it to get the type checking.
55 #define STRICT_MM_TYPECHECKS
57 #ifdef STRICT_MM_TYPECHECKS
58 /* These are used to make use of C type-checking.. */
59 typedef struct { unsigned long pte; } pte_t;
60 typedef struct { unsigned long iopte; } iopte_t;
61 typedef struct { unsigned int pmd; } pmd_t;
62 typedef struct { unsigned int pgd; } pgd_t;
63 typedef struct { unsigned long pgprot; } pgprot_t;
65 #define pte_val(x) ((x).pte)
66 #define iopte_val(x) ((x).iopte)
67 #define pmd_val(x) ((x).pmd)
68 #define pgd_val(x) ((x).pgd)
69 #define pgprot_val(x) ((x).pgprot)
71 #define __pte(x) ((pte_t) { (x) } )
72 #define __iopte(x) ((iopte_t) { (x) } )
73 #define __pmd(x) ((pmd_t) { (x) } )
74 #define __pgd(x) ((pgd_t) { (x) } )
75 #define __pgprot(x) ((pgprot_t) { (x) } )
78 /* .. while these make it easier on the compiler */
79 typedef unsigned long pte_t;
80 typedef unsigned long iopte_t;
81 typedef unsigned int pmd_t;
82 typedef unsigned int pgd_t;
83 typedef unsigned long pgprot_t;
85 #define pte_val(x) (x)
86 #define iopte_val(x) (x)
87 #define pmd_val(x) (x)
88 #define pgd_val(x) (x)
89 #define pgprot_val(x) (x)
92 #define __iopte(x) (x)
95 #define __pgprot(x) (x)
97 #endif /* (STRICT_MM_TYPECHECKS) */
99 typedef struct page *pgtable_t;
101 #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
102 (_AC(0x0000000070000000,UL)) : \
103 (_AC(0xfffff80000000000,UL) + (1UL << 32UL)))
105 #include <asm-generic/memory_model.h>
107 #endif /* !(__ASSEMBLY__) */
109 /* to align the pointer to the (next) page boundary */
110 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
112 /* We used to stick this into a hard-coded global register (%g4)
113 * but that does not make sense anymore.
115 #define PAGE_OFFSET _AC(0xFFFFF80000000000,UL)
119 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
120 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
122 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
124 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
126 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
128 #define virt_to_phys __pa
129 #define phys_to_virt __va
131 #endif /* !(__ASSEMBLY__) */
133 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
134 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
136 #include <asm-generic/page.h>
138 #endif /* _SPARC64_PAGE_H */