blob: f0d09b40103626f7f02d571170935c651f64c470 [file] [log] [blame]
Sam Ravnborgf5e706a2008-07-17 21:55:51 -07001#ifndef _SPARC64_PAGE_H
2#define _SPARC64_PAGE_H
3
4#include <linux/const.h>
5
6#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
7#define PAGE_SHIFT 13
8#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
9#define PAGE_SHIFT 16
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070010#else
11#error No page size specified in kernel configuration
12#endif
13
14#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
15#define PAGE_MASK (~(PAGE_SIZE-1))
16
17/* Flushing for D-cache alias handling is only needed if
18 * the page size is smaller than 16K.
19 */
20#if PAGE_SHIFT < 14
21#define DCACHE_ALIASING_POSSIBLE
22#endif
23
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
30#endif
31
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
37#endif
38
39#ifndef __ASSEMBLY__
40
David S. Millerb0f1e792008-09-11 23:36:32 -070041#define WANT_PAGE_VIRTUAL
42
Sam Ravnborgf5e706a2008-07-17 21:55:51 -070043extern void _clear_page(void *page);
44#define clear_page(X) _clear_page((void *)(X))
45struct page;
46extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
47#define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
48extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
49
50/* Unlike sparc32, sparc64's parameter passing API is more
51 * sane in that structures which as small enough are passed
52 * in registers instead of on the stack. Thus, setting
53 * STRICT_MM_TYPECHECKS does not generate worse code so
54 * let's enable it to get the type checking.
55 */
56
57#define STRICT_MM_TYPECHECKS
58
59#ifdef STRICT_MM_TYPECHECKS
60/* These are used to make use of C type-checking.. */
61typedef struct { unsigned long pte; } pte_t;
62typedef struct { unsigned long iopte; } iopte_t;
63typedef struct { unsigned int pmd; } pmd_t;
64typedef struct { unsigned int pgd; } pgd_t;
65typedef struct { unsigned long pgprot; } pgprot_t;
66
67#define pte_val(x) ((x).pte)
68#define iopte_val(x) ((x).iopte)
69#define pmd_val(x) ((x).pmd)
70#define pgd_val(x) ((x).pgd)
71#define pgprot_val(x) ((x).pgprot)
72
73#define __pte(x) ((pte_t) { (x) } )
74#define __iopte(x) ((iopte_t) { (x) } )
75#define __pmd(x) ((pmd_t) { (x) } )
76#define __pgd(x) ((pgd_t) { (x) } )
77#define __pgprot(x) ((pgprot_t) { (x) } )
78
79#else
80/* .. while these make it easier on the compiler */
81typedef unsigned long pte_t;
82typedef unsigned long iopte_t;
83typedef unsigned int pmd_t;
84typedef unsigned int pgd_t;
85typedef unsigned long pgprot_t;
86
87#define pte_val(x) (x)
88#define iopte_val(x) (x)
89#define pmd_val(x) (x)
90#define pgd_val(x) (x)
91#define pgprot_val(x) (x)
92
93#define __pte(x) (x)
94#define __iopte(x) (x)
95#define __pmd(x) (x)
96#define __pgd(x) (x)
97#define __pgprot(x) (x)
98
99#endif /* (STRICT_MM_TYPECHECKS) */
100
101typedef struct page *pgtable_t;
102
103#define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
104 (_AC(0x0000000070000000,UL)) : \
105 (_AC(0xfffff80000000000,UL) + (1UL << 32UL)))
106
107#include <asm-generic/memory_model.h>
108
109#endif /* !(__ASSEMBLY__) */
110
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700111/* We used to stick this into a hard-coded global register (%g4)
112 * but that does not make sense anymore.
113 */
114#define PAGE_OFFSET _AC(0xFFFFF80000000000,UL)
115
116#ifndef __ASSEMBLY__
117
118#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
119#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
120
121#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
122
123#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
124
125#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
126
127#define virt_to_phys __pa
128#define phys_to_virt __va
129
130#endif /* !(__ASSEMBLY__) */
131
132#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
133 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
134
Arnd Bergmann5b17e1c2009-05-13 22:56:30 +0000135#include <asm-generic/getorder.h>
Sam Ravnborgf5e706a2008-07-17 21:55:51 -0700136
137#endif /* _SPARC64_PAGE_H */