blob: 7af1077451ffb9d9fd80daf9086109a4ee039482 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: page.h,v 1.39 2002/02/09 19:49:31 davem Exp $ */
2
3#ifndef _SPARC64_PAGE_H
4#define _SPARC64_PAGE_H
5
David Woodhouse09087a12006-09-21 08:48:27 +01006#ifdef __KERNEL__
7
Randy Dunlap6df95fd2007-05-08 00:31:11 -07008#include <linux/const.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
11#define PAGE_SHIFT 13
12#elif defined(CONFIG_SPARC64_PAGE_SIZE_64KB)
13#define PAGE_SHIFT 16
14#elif defined(CONFIG_SPARC64_PAGE_SIZE_512KB)
15#define PAGE_SHIFT 19
16#elif defined(CONFIG_SPARC64_PAGE_SIZE_4MB)
17#define PAGE_SHIFT 22
18#else
19#error No page size specified in kernel configuration
20#endif
21
22#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
23#define PAGE_MASK (~(PAGE_SIZE-1))
24
David S. Miller6a9b4902005-09-19 20:11:57 -070025/* Flushing for D-cache alias handling is only needed if
26 * the page size is smaller than 16K.
27 */
28#if PAGE_SHIFT < 14
29#define DCACHE_ALIASING_POSSIBLE
30#endif
31
David S. Millerdcc1e8d2006-03-22 00:49:59 -080032#if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
33#define HPAGE_SHIFT 22
34#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
35#define HPAGE_SHIFT 19
36#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
37#define HPAGE_SHIFT 16
38#endif
39
40#ifdef CONFIG_HUGETLB_PAGE
41#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
42#define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
43#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
44#define ARCH_HAS_SETCLEAR_HUGE_PTE
45#define ARCH_HAS_HUGETLB_PREFAULT_HOOK
46#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
47#endif
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#ifndef __ASSEMBLY__
50
51extern void _clear_page(void *page);
52#define clear_page(X) _clear_page((void *)(X))
53struct page;
54extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
55#define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
56extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
57
58/* Unlike sparc32, sparc64's parameter passing API is more
59 * sane in that structures which as small enough are passed
60 * in registers instead of on the stack. Thus, setting
61 * STRICT_MM_TYPECHECKS does not generate worse code so
62 * let's enable it to get the type checking.
63 */
64
65#define STRICT_MM_TYPECHECKS
66
67#ifdef STRICT_MM_TYPECHECKS
68/* These are used to make use of C type-checking.. */
69typedef struct { unsigned long pte; } pte_t;
70typedef struct { unsigned long iopte; } iopte_t;
71typedef struct { unsigned int pmd; } pmd_t;
72typedef struct { unsigned int pgd; } pgd_t;
73typedef struct { unsigned long pgprot; } pgprot_t;
74
75#define pte_val(x) ((x).pte)
76#define iopte_val(x) ((x).iopte)
77#define pmd_val(x) ((x).pmd)
78#define pgd_val(x) ((x).pgd)
79#define pgprot_val(x) ((x).pgprot)
80
81#define __pte(x) ((pte_t) { (x) } )
82#define __iopte(x) ((iopte_t) { (x) } )
83#define __pmd(x) ((pmd_t) { (x) } )
84#define __pgd(x) ((pgd_t) { (x) } )
85#define __pgprot(x) ((pgprot_t) { (x) } )
86
87#else
88/* .. while these make it easier on the compiler */
89typedef unsigned long pte_t;
90typedef unsigned long iopte_t;
91typedef unsigned int pmd_t;
92typedef unsigned int pgd_t;
93typedef unsigned long pgprot_t;
94
95#define pte_val(x) (x)
96#define iopte_val(x) (x)
97#define pmd_val(x) (x)
98#define pgd_val(x) (x)
99#define pgprot_val(x) (x)
100
101#define __pte(x) (x)
102#define __iopte(x) (x)
103#define __pmd(x) (x)
104#define __pgd(x) (x)
105#define __pgprot(x) (x)
106
107#endif /* (STRICT_MM_TYPECHECKS) */
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
David S. Miller8bcd1742006-03-02 18:12:27 -0800110 (_AC(0x0000000070000000,UL)) : \
111 (_AC(0xfffff80000000000,UL) + (1UL << 32UL)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
KAMEZAWA Hiroyukia117e662006-03-27 01:15:25 -0800113#include <asm-generic/memory_model.h>
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#endif /* !(__ASSEMBLY__) */
116
117/* to align the pointer to the (next) page boundary */
118#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
119
120/* We used to stick this into a hard-coded global register (%g4)
121 * but that does not make sense anymore.
122 */
123#define PAGE_OFFSET _AC(0xFFFFF80000000000,UL)
124
125#ifndef __ASSEMBLY__
126
127#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
128#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
129
David S. Millerd1112012006-03-08 02:16:07 -0800130#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
135
136#define virt_to_phys __pa
137#define phys_to_virt __va
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#endif /* !(__ASSEMBLY__) */
140
141#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
142 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
143
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700144#include <asm-generic/page.h>
145
David Woodhouse09087a12006-09-21 08:48:27 +0100146#endif /* __KERNEL__ */
147#endif /* _SPARC64_PAGE_H */