File: /usr/src/linux/include/asm-sparc/page.h

1     /* $Id: page.h,v 1.55 2000/10/30 21:01:41 davem Exp $
2      * page.h:  Various defines and such for MMU operations on the Sparc for
3      *          the Linux kernel.
4      *
5      * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6      */
7     
8     #ifndef _SPARC_PAGE_H
9     #define _SPARC_PAGE_H
10     
11     #include <linux/config.h>
12     #ifdef CONFIG_SUN4
13     #define PAGE_SHIFT   13
14     #else
15     #define PAGE_SHIFT   12
16     #endif
17     #ifndef __ASSEMBLY__
18     /* I have my suspicions... -DaveM */
19     #define PAGE_SIZE    (1UL << PAGE_SHIFT)
20     #else
21     #define PAGE_SIZE    (1 << PAGE_SHIFT)
22     #endif
23     #define PAGE_MASK    (~(PAGE_SIZE-1))
24     
25     #ifdef __KERNEL__
26     
27     #include <asm/head.h>       /* for KERNBASE */
28     #include <asm/btfixup.h>
29     
30     /* This is always 2048*sizeof(long), doesn't change with PAGE_SIZE */
31     #define TASK_UNION_SIZE		8192
32     
33     #ifndef __ASSEMBLY__
34     
35     /*
36      * XXX I am hitting compiler bugs with __builtin_trap. This has
37      * hit me before and rusty was blaming his netfilter bugs on
38      * this so lets disable it. - Anton
39      */
40     #if 0
41     /* We need the mb()'s so we don't trigger a compiler bug - Anton */
42     #define BUG() do { \
43     	mb(); \
44     	__builtin_trap(); \
45     	mb(); \
46     } while(0)
47     #else
48     #define BUG() do { \
49     	printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); *(int *)0=0; \
50     } while (0)
51     #endif
52     
53     #define PAGE_BUG(page)	BUG()
54     
55     #define clear_page(page)	 memset((void *)(page), 0, PAGE_SIZE)
56     #define copy_page(to,from) 	memcpy((void *)(to), (void *)(from), PAGE_SIZE)
57     #define clear_user_page(page, vaddr)	clear_page(page)
58     #define copy_user_page(to, from, vaddr)	copy_page(to, from)
59     
60     /* The following structure is used to hold the physical
61      * memory configuration of the machine.  This is filled in
62      * probe_memory() and is later used by mem_init() to set up
63      * mem_map[].  We statically allocate SPARC_PHYS_BANKS of
64      * these structs, this is arbitrary.  The entry after the
65      * last valid one has num_bytes==0.
66      */
67     
68     struct sparc_phys_banks {
69       unsigned long base_addr;
70       unsigned long num_bytes;
71     };
72     
73     #define SPARC_PHYS_BANKS 32
74     
75     extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
76     
77     /* Cache alias structure.  Entry is valid if context != -1. */
78     struct cache_palias {
79     	unsigned long vaddr;
80     	int context;
81     };
82     
83     extern struct cache_palias *sparc_aliases;
84     
85     /* passing structs on the Sparc slow us down tremendously... */
86     
87     /* #define STRICT_MM_TYPECHECKS */
88     
89     #ifdef STRICT_MM_TYPECHECKS
90     /*
91      * These are used to make use of C type-checking..
92      */
93     typedef struct { unsigned long pte; } pte_t;
94     typedef struct { unsigned long iopte; } iopte_t;
95     typedef struct { unsigned long pmd; } pmd_t;
96     typedef struct { unsigned long pgd; } pgd_t;
97     typedef struct { unsigned long ctxd; } ctxd_t;
98     typedef struct { unsigned long pgprot; } pgprot_t;
99     typedef struct { unsigned long iopgprot; } iopgprot_t;
100     
101     #define pte_val(x)	((x).pte)
102     #define iopte_val(x)	((x).iopte)
103     #define pmd_val(x)      ((x).pmd)
104     #define pgd_val(x)	((x).pgd)
105     #define ctxd_val(x)	((x).ctxd)
106     #define pgprot_val(x)	((x).pgprot)
107     #define iopgprot_val(x)	((x).iopgprot)
108     
109     #define __pte(x)	((pte_t) { (x) } )
110     #define __iopte(x)	((iopte_t) { (x) } )
111     #define __pmd(x)        ((pmd_t) { (x) } )
112     #define __pgd(x)	((pgd_t) { (x) } )
113     #define __ctxd(x)	((ctxd_t) { (x) } )
114     #define __pgprot(x)	((pgprot_t) { (x) } )
115     #define __iopgprot(x)	((iopgprot_t) { (x) } )
116     
117     #else
118     /*
119      * .. while these make it easier on the compiler
120      */
121     typedef unsigned long pte_t;
122     typedef unsigned long iopte_t;
123     typedef unsigned long pmd_t;
124     typedef unsigned long pgd_t;
125     typedef unsigned long ctxd_t;
126     typedef unsigned long pgprot_t;
127     typedef unsigned long iopgprot_t;
128     
129     #define pte_val(x)	(x)
130     #define iopte_val(x)	(x)
131     #define pmd_val(x)      (x)
132     #define pgd_val(x)	(x)
133     #define ctxd_val(x)	(x)
134     #define pgprot_val(x)	(x)
135     #define iopgprot_val(x)	(x)
136     
137     #define __pte(x)	(x)
138     #define __iopte(x)	(x)
139     #define __pmd(x)        (x)
140     #define __pgd(x)	(x)
141     #define __ctxd(x)	(x)
142     #define __pgprot(x)	(x)
143     #define __iopgprot(x)	(x)
144     
145     #endif
146     
147     extern unsigned long sparc_unmapped_base;
148     
149     BTFIXUPDEF_SETHI(sparc_unmapped_base)
150     
151     #define TASK_UNMAPPED_BASE	BTFIXUP_SETHI(sparc_unmapped_base)
152     
153     /* Pure 2^n version of get_order */
154     extern __inline__ int get_order(unsigned long size)
155     {
156     	int order;
157     
158     	size = (size-1) >> (PAGE_SHIFT-1);
159     	order = -1;
160     	do {
161     		size >>= 1;
162     		order++;
163     	} while (size);
164     	return order;
165     }
166     
167     #else /* !(__ASSEMBLY__) */
168     
169     #define __pgprot(x)	(x)
170     
171     #endif /* !(__ASSEMBLY__) */
172     
173     /* to align the pointer to the (next) page boundary */
174     #define PAGE_ALIGN(addr)  (((addr)+PAGE_SIZE-1)&PAGE_MASK)
175     
176     #define PAGE_OFFSET	0xf0000000
177     #define __pa(x)                 ((unsigned long)(x) - PAGE_OFFSET)
178     #define __va(x)                 ((void *)((unsigned long) (x) + PAGE_OFFSET))
179     #define virt_to_page(kaddr)	(mem_map + (__pa(kaddr) >> PAGE_SHIFT))
180     #define VALID_PAGE(page)	((page - mem_map) < max_mapnr)
181     
182     #endif /* __KERNEL__ */
183     
184     #endif /* _SPARC_PAGE_H */
185