[PATCH] aic7xxx_osm build fix
[cris-mirror.git] / include / asm-sparc / page.h
blob383060e90d947793eefb85af52c442e3b3025410
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.
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 #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))
25 #ifdef __KERNEL__
27 #include <asm/btfixup.h>
29 #ifndef __ASSEMBLY__
31 #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
32 #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
33 #define clear_user_page(addr, vaddr, page) \
34 do { clear_page(addr); \
35 sparc_flush_page_to_ram(page); \
36 } while (0)
37 #define copy_user_page(to, from, vaddr, page) \
38 do { copy_page(to, from); \
39 sparc_flush_page_to_ram(page); \
40 } while (0)
42 /* The following structure is used to hold the physical
43 * memory configuration of the machine. This is filled in
44 * probe_memory() and is later used by mem_init() to set up
45 * mem_map[]. We statically allocate SPARC_PHYS_BANKS of
46 * these structs, this is arbitrary. The entry after the
47 * last valid one has num_bytes==0.
50 struct sparc_phys_banks {
51 unsigned long base_addr;
52 unsigned long num_bytes;
55 #define SPARC_PHYS_BANKS 32
57 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS+1];
59 /* Cache alias structure. Entry is valid if context != -1. */
60 struct cache_palias {
61 unsigned long vaddr;
62 int context;
65 extern struct cache_palias *sparc_aliases;
67 /* passing structs on the Sparc slow us down tremendously... */
69 /* #define STRICT_MM_TYPECHECKS */
71 #ifdef STRICT_MM_TYPECHECKS
73 * These are used to make use of C type-checking..
75 typedef struct { unsigned long pte; } pte_t;
76 typedef struct { unsigned long iopte; } iopte_t;
77 typedef struct { unsigned long pmdv[16]; } pmd_t;
78 typedef struct { unsigned long pgd; } pgd_t;
79 typedef struct { unsigned long ctxd; } ctxd_t;
80 typedef struct { unsigned long pgprot; } pgprot_t;
81 typedef struct { unsigned long iopgprot; } iopgprot_t;
83 #define pte_val(x) ((x).pte)
84 #define iopte_val(x) ((x).iopte)
85 #define pmd_val(x) ((x).pmdv[0])
86 #define pgd_val(x) ((x).pgd)
87 #define ctxd_val(x) ((x).ctxd)
88 #define pgprot_val(x) ((x).pgprot)
89 #define iopgprot_val(x) ((x).iopgprot)
91 #define __pte(x) ((pte_t) { (x) } )
92 #define __iopte(x) ((iopte_t) { (x) } )
93 /* #define __pmd(x) ((pmd_t) { (x) } ) */ /* XXX procedure with loop */
94 #define __pgd(x) ((pgd_t) { (x) } )
95 #define __ctxd(x) ((ctxd_t) { (x) } )
96 #define __pgprot(x) ((pgprot_t) { (x) } )
97 #define __iopgprot(x) ((iopgprot_t) { (x) } )
99 #else
101 * .. while these make it easier on the compiler
103 typedef unsigned long pte_t;
104 typedef unsigned long iopte_t;
105 typedef struct { unsigned long pmdv[16]; } pmd_t;
106 typedef unsigned long pgd_t;
107 typedef unsigned long ctxd_t;
108 typedef unsigned long pgprot_t;
109 typedef unsigned long iopgprot_t;
111 #define pte_val(x) (x)
112 #define iopte_val(x) (x)
113 #define pmd_val(x) ((x).pmdv[0])
114 #define pgd_val(x) (x)
115 #define ctxd_val(x) (x)
116 #define pgprot_val(x) (x)
117 #define iopgprot_val(x) (x)
119 #define __pte(x) (x)
120 #define __iopte(x) (x)
121 /* #define __pmd(x) (x) */ /* XXX later */
122 #define __pgd(x) (x)
123 #define __ctxd(x) (x)
124 #define __pgprot(x) (x)
125 #define __iopgprot(x) (x)
127 #endif
129 extern unsigned long sparc_unmapped_base;
131 BTFIXUPDEF_SETHI(sparc_unmapped_base)
133 #define TASK_UNMAPPED_BASE BTFIXUP_SETHI(sparc_unmapped_base)
135 /* Pure 2^n version of get_order */
136 extern __inline__ int get_order(unsigned long size)
138 int order;
140 size = (size-1) >> (PAGE_SHIFT-1);
141 order = -1;
142 do {
143 size >>= 1;
144 order++;
145 } while (size);
146 return order;
149 #else /* !(__ASSEMBLY__) */
151 #define __pgprot(x) (x)
153 #endif /* !(__ASSEMBLY__) */
155 /* to align the pointer to the (next) page boundary */
156 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
158 #define PAGE_OFFSET 0xf0000000
159 #ifndef __ASSEMBLY__
160 extern unsigned long phys_base;
161 extern unsigned long pfn_base;
162 #endif
163 #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET + phys_base)
164 #define __va(x) ((void *)((unsigned long) (x) - phys_base + PAGE_OFFSET))
166 #define virt_to_phys __pa
167 #define phys_to_virt __va
169 #define pfn_to_page(pfn) (mem_map + ((pfn)-(pfn_base)))
170 #define page_to_pfn(page) ((unsigned long)(((page) - mem_map) + pfn_base))
171 #define virt_to_page(kaddr) (mem_map + ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT)))
173 #define pfn_valid(pfn) (((pfn) >= (pfn_base)) && (((pfn)-(pfn_base)) < max_mapnr))
174 #define virt_addr_valid(kaddr) ((((unsigned long)(kaddr)-PAGE_OFFSET)>>PAGE_SHIFT) < max_mapnr)
176 #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
177 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
179 #endif /* __KERNEL__ */
181 #endif /* _SPARC_PAGE_H */