aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-m68k/page.h
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2007-05-31 03:40:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-31 10:58:14 -0400
commit12d810c1b8c2b913d48e629e2b5c01d105029839 (patch)
treeb39162d3168f6173af3d0e5790e16eb45a70dfaf /include/asm-m68k/page.h
parent00c541eae7a477e3d1adb1ebf27cccc0bdb5f824 (diff)
m68k: discontinuous memory support
Fix support for discontinuous memory Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-m68k/page.h')
-rw-r--r--include/asm-m68k/page.h52
1 files changed, 41 insertions, 11 deletions
diff --git a/include/asm-m68k/page.h b/include/asm-m68k/page.h
index 7650b99dcae..9e6d0d6debd 100644
--- a/include/asm-m68k/page.h
+++ b/include/asm-m68k/page.h
@@ -121,7 +121,6 @@ extern unsigned long m68k_memoffset;
121#ifndef CONFIG_SUN3 121#ifndef CONFIG_SUN3
122 122
123#define WANT_PAGE_VIRTUAL 123#define WANT_PAGE_VIRTUAL
124#ifdef CONFIG_SINGLE_MEMORY_CHUNK
125 124
126static inline unsigned long ___pa(void *vaddr) 125static inline unsigned long ___pa(void *vaddr)
127{ 126{
@@ -133,7 +132,7 @@ static inline unsigned long ___pa(void *vaddr)
133 : "0" (vaddr), "i" (m68k_fixup_memoffset)); 132 : "0" (vaddr), "i" (m68k_fixup_memoffset));
134 return paddr; 133 return paddr;
135} 134}
136#define __pa(vaddr) ___pa((void *)(vaddr)) 135#define __pa(vaddr) ___pa((void *)(vaddr))
137static inline void *__va(unsigned long paddr) 136static inline void *__va(unsigned long paddr)
138{ 137{
139 void *vaddr; 138 void *vaddr;
@@ -145,11 +144,6 @@ static inline void *__va(unsigned long paddr)
145 return vaddr; 144 return vaddr;
146} 145}
147 146
148#else
149#define __pa(vaddr) virt_to_phys((void *)(vaddr))
150#define __va(paddr) phys_to_virt((unsigned long)(paddr))
151#endif
152
153#else /* !CONFIG_SUN3 */ 147#else /* !CONFIG_SUN3 */
154/* This #define is a horrible hack to suppress lots of warnings. --m */ 148/* This #define is a horrible hack to suppress lots of warnings. --m */
155#define __pa(x) ___pa((unsigned long)(x)) 149#define __pa(x) ___pa((unsigned long)(x))
@@ -184,11 +178,47 @@ static inline void *__va(unsigned long x)
184#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) 178#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
185#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) 179#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
186 180
187#define virt_to_page(kaddr) (mem_map + (((unsigned long)(kaddr)-PAGE_OFFSET) >> PAGE_SHIFT)) 181extern int m68k_virt_to_node_shift;
188#define page_to_virt(page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) 182
183#ifdef CONFIG_SINGLE_MEMORY_CHUNK
184#define __virt_to_node(addr) (&pg_data_map[0])
185#else
186extern struct pglist_data *pg_data_table[];
187
188static inline __attribute_const__ int __virt_to_node_shift(void)
189{
190 int shift;
191
192 asm (
193 "1: moveq #0,%0\n"
194 m68k_fixup(%c1, 1b)
195 : "=d" (shift)
196 : "i" (m68k_fixup_vnode_shift));
197 return shift;
198}
199
200#define __virt_to_node(addr) (pg_data_table[(unsigned long)(addr) >> __virt_to_node_shift()])
201#endif
189 202
190#define pfn_to_page(pfn) virt_to_page(pfn_to_virt(pfn)) 203#define virt_to_page(addr) ({ \
191#define page_to_pfn(page) virt_to_pfn(page_to_virt(page)) 204 pfn_to_page(virt_to_pfn(addr)); \
205})
206#define page_to_virt(page) ({ \
207 pfn_to_virt(page_to_pfn(page)); \
208})
209
210#define pfn_to_page(pfn) ({ \
211 unsigned long __pfn = (pfn); \
212 struct pglist_data *pgdat; \
213 pgdat = __virt_to_node((unsigned long)pfn_to_virt(__pfn)); \
214 pgdat->node_mem_map + (__pfn - pgdat->node_start_pfn); \
215})
216#define page_to_pfn(_page) ({ \
217 struct page *__p = (_page); \
218 struct pglist_data *pgdat; \
219 pgdat = &pg_data_map[page_to_nid(__p)]; \
220 ((__p) - pgdat->node_mem_map) + pgdat->node_start_pfn; \
221})
192 222
193#define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory) 223#define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
194#define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn)) 224#define pfn_valid(pfn) virt_addr_valid(pfn_to_virt(pfn))