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