VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / asm-sparc64 / page.h
1 /* $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
6 #include <linux/config.h>
7 #include <asm/const.h>
8
9 #define PAGE_SHIFT   13
10 #define PAGE_SIZE    (_AC(1,UL) << PAGE_SHIFT)
11 #define PAGE_MASK    (~(PAGE_SIZE-1))
12
13 #ifdef __KERNEL__
14
15 #ifndef __ASSEMBLY__
16
17 extern void _clear_page(void *page);
18 #define clear_page(X)   _clear_page((void *)(X))
19 struct page;
20 extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
21 #define copy_page(X,Y)  memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
22 extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
23
24 /* GROSS, defining this makes gcc pass these types as aggregates,
25  * and thus on the stack, turn this crap off... -DaveM
26  */
27
28 /* #define STRICT_MM_TYPECHECKS */
29
30 #ifdef STRICT_MM_TYPECHECKS
31 /* These are used to make use of C type-checking.. */
32 typedef struct { unsigned long pte; } pte_t;
33 typedef struct { unsigned long iopte; } iopte_t;
34 typedef struct { unsigned int pmd; } pmd_t;
35 typedef struct { unsigned int pgd; } pgd_t;
36 typedef struct { unsigned long ctxd; } ctxd_t;
37 typedef struct { unsigned long pgprot; } pgprot_t;
38 typedef struct { unsigned long iopgprot; } iopgprot_t;
39
40 #define pte_val(x)      ((x).pte)
41 #define iopte_val(x)    ((x).iopte)
42 #define pmd_val(x)      ((x).pmd)
43 #define pgd_val(x)      ((x).pgd)
44 #define ctxd_val(x)     ((x).ctxd)
45 #define pgprot_val(x)   ((x).pgprot)
46 #define iopgprot_val(x) ((x).iopgprot)
47
48 #define __pte(x)        ((pte_t) { (x) } )
49 #define __iopte(x)      ((iopte_t) { (x) } )
50 #define __pmd(x)        ((pmd_t) { (x) } )
51 #define __pgd(x)        ((pgd_t) { (x) } )
52 #define __ctxd(x)       ((ctxd_t) { (x) } )
53 #define __pgprot(x)     ((pgprot_t) { (x) } )
54 #define __iopgprot(x)   ((iopgprot_t) { (x) } )
55
56 #else
57 /* .. while these make it easier on the compiler */
58 typedef unsigned long pte_t;
59 typedef unsigned long iopte_t;
60 typedef unsigned int pmd_t;
61 typedef unsigned int pgd_t;
62 typedef unsigned long ctxd_t;
63 typedef unsigned long pgprot_t;
64 typedef unsigned long iopgprot_t;
65
66 #define pte_val(x)      (x)
67 #define iopte_val(x)    (x)
68 #define pmd_val(x)      (x)
69 #define pgd_val(x)      (x)
70 #define ctxd_val(x)     (x)
71 #define pgprot_val(x)   (x)
72 #define iopgprot_val(x) (x)
73
74 #define __pte(x)        (x)
75 #define __iopte(x)      (x)
76 #define __pmd(x)        (x)
77 #define __pgd(x)        (x)
78 #define __ctxd(x)       (x)
79 #define __pgprot(x)     (x)
80 #define __iopgprot(x)   (x)
81
82 #endif /* (STRICT_MM_TYPECHECKS) */
83
84 #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
85 #define HPAGE_SHIFT             22
86 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
87 #define HPAGE_SHIFT             19
88 #elif defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
89 #define HPAGE_SHIFT             16
90 #endif
91
92 #ifdef CONFIG_HUGETLB_PAGE
93 #define HPAGE_SIZE              (_AC(1,UL) << HPAGE_SHIFT)
94 #define HPAGE_MASK              (~(HPAGE_SIZE - 1UL))
95 #define HUGETLB_PAGE_ORDER      (HPAGE_SHIFT - PAGE_SHIFT)
96 #endif
97
98 #define TASK_UNMAPPED_BASE      (test_thread_flag(TIF_32BIT) ? \
99                                  (_AC(0x0000000070000000,UL)) : (PAGE_OFFSET))
100
101 #endif /* !(__ASSEMBLY__) */
102
103 /* to align the pointer to the (next) page boundary */
104 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
105
106 /* We used to stick this into a hard-coded global register (%g4)
107  * but that does not make sense anymore.
108  */
109 #define PAGE_OFFSET             _AC(0xFFFFF80000000000,UL)
110
111 #ifndef __ASSEMBLY__
112
113 #define __pa(x)                 ((unsigned long)(x) - PAGE_OFFSET)
114 #define __va(x)                 ((void *)((unsigned long) (x) + PAGE_OFFSET))
115
116 /* PFNs are real physical page numbers.  However, mem_map only begins to record
117  * per-page information starting at pfn_base.  This is to handle systems where
118  * the first physical page in the machine is at some huge physical address,
119  * such as 4GB.   This is common on a partitioned E10000, for example.
120  */
121 extern struct page *pfn_to_page(unsigned long pfn);
122 extern unsigned long page_to_pfn(struct page *);
123
124 #define virt_to_page(kaddr)     pfn_to_page(__pa(kaddr)>>PAGE_SHIFT)
125
126 #define pfn_valid(pfn)          (((pfn)-(pfn_base)) < max_mapnr)
127 #define virt_addr_valid(kaddr)  pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
128
129 #define virt_to_phys __pa
130 #define phys_to_virt __va
131
132 /* The following structure is used to hold the physical
133  * memory configuration of the machine.  This is filled in
134  * probe_memory() and is later used by mem_init() to set up
135  * mem_map[].  We statically allocate SPARC_PHYS_BANKS of
136  * these structs, this is arbitrary.  The entry after the
137  * last valid one has num_bytes==0.
138  */
139
140 struct sparc_phys_banks {
141         unsigned long base_addr;
142         unsigned long num_bytes;
143 };
144
145 #define SPARC_PHYS_BANKS 32
146
147 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
148
149 /* Pure 2^n version of get_order */
150 static __inline__ int get_order(unsigned long size)
151 {
152         int order;
153
154         size = (size-1) >> (PAGE_SHIFT-1);
155         order = -1;
156         do {
157                 size >>= 1;
158                 order++;
159         } while (size);
160         return order;
161 }
162
163 #endif /* !(__ASSEMBLY__) */
164
165 #define VM_DATA_DEFAULT_FLAGS   (VM_READ | VM_WRITE | VM_EXEC | \
166                                  VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
167
168 #endif /* !(__KERNEL__) */
169
170 #endif /* !(_SPARC64_PAGE_H) */