1 /* $Id: page.h,v 1.39 2002/02/09 19:49:31 davem Exp $ */
3 #ifndef _SPARC64_PAGE_H
4 #define _SPARC64_PAGE_H
6 #include <linux/const.h>
8 #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
10 #elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
12 #elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
14 #elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
17 #error No page size specified in kernel configuration
20 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
21 #define PAGE_MASK (~(PAGE_SIZE-1))
23 /* Flushing for D-cache alias handling is only needed if
24 * the page size is smaller than 16K.
27 #define DCACHE_ALIASING_POSSIBLE
30 #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
31 #define HPAGE_SHIFT 22
32 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
33 #define HPAGE_SHIFT 19
34 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
35 #define HPAGE_SHIFT 16
38 #ifdef CONFIG_HUGETLB_PAGE
39 #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
40 #define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
41 #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
42 #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
47 extern void _clear_page(void *page);
48 #define clear_page(X) _clear_page((void *)(X))
50 extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
51 #define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
52 extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
54 /* Unlike sparc32, sparc64's parameter passing API is more
55 * sane in that structures which as small enough are passed
56 * in registers instead of on the stack. Thus, setting
57 * STRICT_MM_TYPECHECKS does not generate worse code so
58 * let's enable it to get the type checking.
61 #define STRICT_MM_TYPECHECKS
63 #ifdef STRICT_MM_TYPECHECKS
64 /* These are used to make use of C type-checking.. */
65 typedef struct { unsigned long pte; } pte_t;
66 typedef struct { unsigned long iopte; } iopte_t;
67 typedef struct { unsigned int pmd; } pmd_t;
68 typedef struct { unsigned int pgd; } pgd_t;
69 typedef struct { unsigned long pgprot; } pgprot_t;
71 #define pte_val(x) ((x).pte)
72 #define iopte_val(x) ((x).iopte)
73 #define pmd_val(x) ((x).pmd)
74 #define pgd_val(x) ((x).pgd)
75 #define pgprot_val(x) ((x).pgprot)
77 #define __pte(x) ((pte_t) { (x) } )
78 #define __iopte(x) ((iopte_t) { (x) } )
79 #define __pmd(x) ((pmd_t) { (x) } )
80 #define __pgd(x) ((pgd_t) { (x) } )
81 #define __pgprot(x) ((pgprot_t) { (x) } )
84 /* .. while these make it easier on the compiler */
85 typedef unsigned long pte_t;
86 typedef unsigned long iopte_t;
87 typedef unsigned int pmd_t;
88 typedef unsigned int pgd_t;
89 typedef unsigned long pgprot_t;
91 #define pte_val(x) (x)
92 #define iopte_val(x) (x)
93 #define pmd_val(x) (x)
94 #define pgd_val(x) (x)
95 #define pgprot_val(x) (x)
98 #define __iopte(x) (x)
101 #define __pgprot(x) (x)
103 #endif /* (STRICT_MM_TYPECHECKS) */
105 typedef struct page *pgtable_t;
107 #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
108 (_AC(0x0000000070000000,UL)) : \
109 (_AC(0xfffff80000000000,UL) + (1UL << 32UL)))
111 #include <asm-generic/memory_model.h>
113 #endif /* !(__ASSEMBLY__) */
115 /* to align the pointer to the (next) page boundary */
116 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
118 /* We used to stick this into a hard-coded global register (%g4)
119 * but that does not make sense anymore.
121 #define PAGE_OFFSET _AC(0xFFFFF80000000000,UL)
125 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
126 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
128 #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
130 #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
132 #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
134 #define virt_to_phys __pa
135 #define phys_to_virt __va
137 #endif /* !(__ASSEMBLY__) */
139 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
140 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
142 #include <asm-generic/page.h>
144 #endif /* _SPARC64_PAGE_H */