Import 2.3.47pre1
[davej-history.git] / include / asm-sparc / page.h
blob3c61eb6362de40a3c5165b73aba99f3738af6d23
1 /* $Id: page.h,v 1.48 2000/02/16 07:34:51 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)
32 #define PAGE_BUG(page) do { \
33 BUG(); \
34 } while (0)
36 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
37 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
39 /* The following structure is used to hold the physical
40 * memory configuration of the machine. This is filled in
41 * probe_memory() and is later used by mem_init() to set up
42 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
43 * these structs, this is arbitrary. The entry after the
44 * last valid one has num_bytes==0.
47 struct sparc_phys_banks {
48 unsigned long base_addr;
49 unsigned long num_bytes;
52 #define SPARC_PHYS_BANKS 32
54 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
56 /* Cache alias structure. Entry is valid if context != -1. */
57 struct cache_palias {
58 unsigned long vaddr;
59 int context;
62 extern struct cache_palias *sparc_aliases;
64 /* passing structs on the Sparc slow us down tremendously... */
66 /* #define STRICT_MM_TYPECHECKS */
68 #ifdef STRICT_MM_TYPECHECKS
70 * These are used to make use of C type-checking..
72 typedef struct { unsigned long pte; } pte_t;
73 typedef struct { unsigned long iopte; } iopte_t;
74 typedef struct { unsigned long pmd; } pmd_t;
75 typedef struct { unsigned long pgd; } pgd_t;
76 typedef struct { unsigned long ctxd; } ctxd_t;
77 typedef struct { unsigned long pgprot; } pgprot_t;
78 typedef struct { unsigned long iopgprot; } iopgprot_t;
80 #define pte_val(x) ((x).pte)
81 #define iopte_val(x) ((x).iopte)
82 #define pmd_val(x) ((x).pmd)
83 #define pgd_val(x) ((x).pgd)
84 #define ctxd_val(x) ((x).ctxd)
85 #define pgprot_val(x) ((x).pgprot)
86 #define iopgprot_val(x) ((x).iopgprot)
88 #define __pte(x) ((pte_t) { (x) } )
89 #define __iopte(x) ((iopte_t) { (x) } )
90 #define __pmd(x) ((pmd_t) { (x) } )
91 #define __pgd(x) ((pgd_t) { (x) } )
92 #define __ctxd(x) ((ctxd_t) { (x) } )
93 #define __pgprot(x) ((pgprot_t) { (x) } )
94 #define __iopgprot(x) ((iopgprot_t) { (x) } )
96 #else
98 * .. while these make it easier on the compiler
100 typedef unsigned long pte_t;
101 typedef unsigned long iopte_t;
102 typedef unsigned long pmd_t;
103 typedef unsigned long pgd_t;
104 typedef unsigned long ctxd_t;
105 typedef unsigned long pgprot_t;
106 typedef unsigned long iopgprot_t;
108 #define pte_val(x) (x)
109 #define iopte_val(x) (x)
110 #define pmd_val(x) (x)
111 #define pgd_val(x) (x)
112 #define ctxd_val(x) (x)
113 #define pgprot_val(x) (x)
114 #define iopgprot_val(x) (x)
116 #define __pte(x) (x)
117 #define __iopte(x) (x)
118 #define __pmd(x) (x)
119 #define __pgd(x) (x)
120 #define __ctxd(x) (x)
121 #define __pgprot(x) (x)
122 #define __iopgprot(x) (x)
124 #endif
126 extern unsigned long sparc_unmapped_base;
128 BTFIXUPDEF_SETHI(sparc_unmapped_base)
130 #define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base)
132 /* Pure 2^n version of get_order */
133 extern __inline__ int get_order(unsigned long size)
135 int order;
137 size = (size-1) >> (PAGE_SHIFT-1);
138 order = -1;
139 do {
140 size >>= 1;
141 order++;
142 } while (size);
143 return order;
146 #else /* !(__ASSEMBLY__) */
148 #define __pgprot(x) (x)
150 #endif /* !(__ASSEMBLY__) */
152 /* to align the pointer to the (next) page boundary */
153 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
155 #define PAGE_OFFSET 0xf0000000
156 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
157 #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET))
158 #define MAP_NR(addr) (__pa(addr) >> PAGE_SHIFT)
160 #endif /* __KERNEL__ */
162 #endif /* _SPARC_PAGE_H */