* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / include / asm-sparc / page.h
bloba3754dfe2105c01c6e4b067132a1a37a2b84e442
1 /* $Id: page.h,v 1.45 1999/07/03 08:58:05 davem Exp $
2 * page.h: Various defines and such for MMU operations on the Sparc for
3 * the Linux kernel.
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
8 #ifndef _SPARC_PAGE_H
9 #define _SPARC_PAGE_H
11 #include <linux/config.h>
12 #ifdef CONFIG_SUN4
13 #define PAGE_SHIFT 13
14 #else
15 #define PAGE_SHIFT 12
16 #endif
17 #define PAGE_SIZE (1 << PAGE_SHIFT)
18 #define PAGE_MASK (~(PAGE_SIZE-1))
20 #ifdef __KERNEL__
22 #include <asm/head.h> /* for KERNBASE */
23 #include <asm/btfixup.h>
25 /* This is always 2048*sizeof(long), doesn't change with PAGE_SIZE */
26 #define TASK_UNION_SIZE 8192
28 #ifndef __ASSEMBLY__
30 #define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; } while (0)
31 #define PAGE_BUG(page) do { \
32 BUG(); } while (0)
34 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
35 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
37 extern unsigned long page_offset;
39 BTFIXUPDEF_SETHI_INIT(page_offset,0xf0000000)
41 #ifdef MODULE
42 #define PAGE_OFFSET (page_offset)
43 #else
44 #define PAGE_OFFSET BTFIXUP_SETHI(page_offset)
45 #endif
47 /* translate between physical and virtual addresses */
48 BTFIXUPDEF_CALL_CONST(unsigned long, mmu_v2p, unsigned long)
49 BTFIXUPDEF_CALL_CONST(unsigned long, mmu_p2v, unsigned long)
51 #define mmu_v2p(vaddr) BTFIXUP_CALL(mmu_v2p)(vaddr)
52 #define mmu_p2v(paddr) BTFIXUP_CALL(mmu_p2v)(paddr)
54 #define __pa(x) (mmu_v2p((unsigned long)(x)))
55 #define __va(x) ((void *)(mmu_p2v((unsigned long)(x))))
57 /* The following structure is used to hold the physical
58 * memory configuration of the machine. This is filled in
59 * probe_memory() and is later used by mem_init() to set up
60 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
61 * these structs, this is arbitrary. The entry after the
62 * last valid one has num_bytes==0.
65 struct sparc_phys_banks {
66 unsigned long base_addr;
67 unsigned long num_bytes;
70 #define SPARC_PHYS_BANKS 32
72 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
74 /* Cache alias structure. Entry is valid if context != -1. */
75 struct cache_palias {
76 unsigned long vaddr;
77 int context;
80 extern struct cache_palias *sparc_aliases;
82 /* passing structs on the Sparc slow us down tremendously... */
84 /* #define STRICT_MM_TYPECHECKS */
86 #ifdef STRICT_MM_TYPECHECKS
88 * These are used to make use of C type-checking..
90 typedef struct { unsigned long pte; } pte_t;
91 typedef struct { unsigned long iopte; } iopte_t;
92 typedef struct { unsigned long pmd; } pmd_t;
93 typedef struct { unsigned long pgd; } pgd_t;
94 typedef struct { unsigned long ctxd; } ctxd_t;
95 typedef struct { unsigned long pgprot; } pgprot_t;
96 typedef struct { unsigned long iopgprot; } iopgprot_t;
98 #define pte_val(x) ((x).pte)
99 #define iopte_val(x) ((x).iopte)
100 #define pmd_val(x) ((x).pmd)
101 #define pgd_val(x) ((x).pgd)
102 #define ctxd_val(x) ((x).ctxd)
103 #define pgprot_val(x) ((x).pgprot)
104 #define iopgprot_val(x) ((x).iopgprot)
106 #define __pte(x) ((pte_t) { (x) } )
107 #define __iopte(x) ((iopte_t) { (x) } )
108 #define __pmd(x) ((pmd_t) { (x) } )
109 #define __pgd(x) ((pgd_t) { (x) } )
110 #define __ctxd(x) ((ctxd_t) { (x) } )
111 #define __pgprot(x) ((pgprot_t) { (x) } )
112 #define __iopgprot(x) ((iopgprot_t) { (x) } )
114 #elif CONFIG_AP1000_DEBUG
116 typedef struct { unsigned long pte; } pte_t;
117 typedef struct { unsigned long iopte; } iopte_t;
118 typedef struct { unsigned long pmd; } pmd_t;
119 typedef struct { unsigned long pgd; } pgd_t;
120 typedef struct { unsigned long ctxd; } ctxd_t;
121 typedef struct { unsigned long pgprot; } pgprot_t;
122 typedef struct { unsigned long iopgprot; } iopgprot_t;
124 static inline unsigned long __get_val(unsigned long x)
126 if ((x & 0xF0000000) == (8<<28))
127 return x & 0x0FFFFFFF;
128 return x;
131 static inline unsigned long __set_val(unsigned long x)
133 if ((x & 0xF0000000) == (0<<28))
134 return x | 0x80000000;
135 return x;
138 #define __pte_val(x) ((x).pte)
139 #define __iopte_val(x) ((x).iopte)
140 #define __pmd_val(x) ((x).pmd)
141 #define __pgd_val(x) ((x).pgd)
142 #define __ctxd_val(x) ((x).ctxd)
143 #define __pgprot_val(x) ((x).pgprot)
144 #define __iopgprot_val(x) ((x).iopgprot)
146 #define ___pte(x) ((pte_t) { (x) } )
147 #define ___iopte(x) ((iopte_t) { (x) } )
148 #define ___pmd(x) ((pmd_t) { (x) } )
149 #define ___pgd(x) ((pgd_t) { (x) } )
150 #define ___ctxd(x) ((ctxd_t) { (x) } )
151 #define ___pgprot(x) ((pgprot_t) { (x) } )
152 #define ___iopgprot(x) ((iopgprot_t) { (x) } )
155 #define pte_val(x) __get_val(__pte_val(x))
156 #define iopte_val(x) __get_val(__iopte_val(x))
157 #define pmd_val(x) __get_val(__pmd_val(x))
158 #define pgd_val(x) __get_val(__pgd_val(x))
159 #define ctxd_val(x) __get_val(__ctxd_val(x))
160 #define pgprot_val(x) __get_val(__pgprot_val(x))
161 #define iopgprot_val(x) __get_val(__iopgprot_val(x))
163 #define __pte(x) ___pte(__set_val(x))
164 #define __iopte(x) ___iopte(__set_val(x))
165 #define __pmd(x) ___pmd(__set_val(x))
166 #define __pgd(x) ___pgd(__set_val(x))
167 #define __ctxd(x) ___ctxd(__set_val(x))
168 #define __pgprot(x) ___pgprot(x)
169 #define __iopgprot(x) ___iopgprot(__set_val(x))
171 #elif CONFIG_AP1000
173 typedef unsigned long pte_t;
174 typedef unsigned long iopte_t;
175 typedef unsigned long pmd_t;
176 typedef unsigned long pgd_t;
177 typedef unsigned long ctxd_t;
178 typedef unsigned long pgprot_t;
179 typedef unsigned long iopgprot_t;
181 static inline unsigned long __get_val(unsigned long x)
183 #if 0
184 extern void ap_panic(char *fmt,...);
185 if (x && (x & 0xF0000000) == 0) {
186 ap_panic("get_val got 0x%x\n",x);
188 #endif
189 if ((x & 0xF0000000) == (8<<28))
190 return x & 0x0FFFFFFF;
191 return x;
194 static inline unsigned long __set_val(unsigned long x)
196 #if 0
197 extern void ap_panic(char *fmt,...);
198 if ((x & 0xF0000000) == (8<<28)) {
199 ap_panic("set_val got 0x%x\n",x);
201 #endif
202 if ((x & 0xF0000000) == (0<<28))
203 return x | 0x80000000;
204 return x;
207 #define __pte_val(x) (x)
208 #define __iopte_val(x) (x)
209 #define __pmd_val(x) (x)
210 #define __pgd_val(x) (x)
211 #define __ctxd_val(x) (x)
212 #define __pgprot_val(x) (x)
213 #define __iopgprot_val(x) (x)
215 #define ___pte(x) ((pte_t) { (x) } )
216 #define ___iopte(x) ((iopte_t) { (x) } )
217 #define ___pmd(x) ((pmd_t) { (x) } )
218 #define ___pgd(x) ((pgd_t) { (x) } )
219 #define ___ctxd(x) ((ctxd_t) { (x) } )
220 #define ___pgprot(x) ((pgprot_t) { (x) } )
221 #define ___iopgprot(x) ((iopgprot_t) { (x) } )
224 #define pte_val(x) __get_val(__pte_val(x))
225 #define iopte_val(x) __get_val(__iopte_val(x))
226 #define pmd_val(x) __get_val(__pmd_val(x))
227 #define pgd_val(x) __get_val(__pgd_val(x))
228 #define ctxd_val(x) __get_val(__ctxd_val(x))
229 #define pgprot_val(x) __get_val(__pgprot_val(x))
230 #define iopgprot_val(x) __get_val(__iopgprot_val(x))
232 #define __pte(x) ___pte(__set_val(x))
233 #define __iopte(x) ___iopte(__set_val(x))
234 #define __pmd(x) ___pmd(__set_val(x))
235 #define __pgd(x) ___pgd(__set_val(x))
236 #define __ctxd(x) ___ctxd(__set_val(x))
237 #define __pgprot(x) ___pgprot(x)
238 #define __iopgprot(x) ___iopgprot(__set_val(x))
240 #else
242 * .. while these make it easier on the compiler
244 typedef unsigned long pte_t;
245 typedef unsigned long iopte_t;
246 typedef unsigned long pmd_t;
247 typedef unsigned long pgd_t;
248 typedef unsigned long ctxd_t;
249 typedef unsigned long pgprot_t;
250 typedef unsigned long iopgprot_t;
252 #define pte_val(x) (x)
253 #define iopte_val(x) (x)
254 #define pmd_val(x) (x)
255 #define pgd_val(x) (x)
256 #define ctxd_val(x) (x)
257 #define pgprot_val(x) (x)
258 #define iopgprot_val(x) (x)
260 #define __pte(x) (x)
261 #define __iopte(x) (x)
262 #define __pmd(x) (x)
263 #define __pgd(x) (x)
264 #define __ctxd(x) (x)
265 #define __pgprot(x) (x)
266 #define __iopgprot(x) (x)
268 #endif
270 extern unsigned long sparc_unmapped_base;
272 BTFIXUPDEF_SETHI(sparc_unmapped_base)
274 #define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base)
276 /* to align the pointer to the (next) page boundary */
277 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
279 /* Now, to allow for very large physical memory configurations we
280 * place the page pool both above the kernel and below the kernel.
282 #define MAP_NR(addr) ((((unsigned long) (addr)) - PAGE_OFFSET) >> PAGE_SHIFT)
284 #else /* !(__ASSEMBLY__) */
286 #define __pgprot(x) (x)
288 #endif /* !(__ASSEMBLY__) */
290 #endif /* __KERNEL__ */
292 #endif /* _SPARC_PAGE_H */