aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-arm/memory.h
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2006-11-30 15:39:18 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-11-30 17:52:28 -0500
commitb7dc96d75309346c1213875be68fdbbec92da5e7 (patch)
treeb6f85da5e99cb3f20fef42504ce7b82b4a69c6fc /include/asm-arm/memory.h
parent0215ffb08ce99e2bb59eca114a99499a4d06e704 (diff)
[ARM] Clean up discontigmem support
Most architectures have fairly simple discontiguous memory - a simple set of successive regions each containing some memory. These can be described simply as a log2 of their maximum size, along with the base address of the first region and the number of regions. The base address is already described by PHYS_PFN_OFFSET, and the number of regions via the MAX_NUMNODES and the number of online nodes. If we then supply the log2 of their maximum size, all the other discontigmem macros can move into generic code. There is one exception: lh7a40x seems to have a more complicated setup; this is left alone. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'include/asm-arm/memory.h')
-rw-r--r--include/asm-arm/memory.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h
index 91d536c215d7..d9bfb39adabf 100644
--- a/include/asm-arm/memory.h
+++ b/include/asm-arm/memory.h
@@ -215,6 +215,7 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
215 * virt_addr_valid(k) indicates whether a virtual address is valid 215 * virt_addr_valid(k) indicates whether a virtual address is valid
216 */ 216 */
217#ifndef CONFIG_DISCONTIGMEM 217#ifndef CONFIG_DISCONTIGMEM
218
218#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 219#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
219#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) 220#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
220 221
@@ -230,6 +231,7 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
230 * around in memory. 231 * around in memory.
231 */ 232 */
232#include <linux/numa.h> 233#include <linux/numa.h>
234
233#define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) 235#define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn)
234#define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) 236#define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT)
235 237
@@ -256,6 +258,43 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
256 */ 258 */
257#define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) 259#define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT)
258 260
261/*
262 * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
263 * and returns the mem_map of that node.
264 */
265#define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
266
267/*
268 * Given a page frame number, find the owning node of the memory
269 * and returns the mem_map of that node.
270 */
271#define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn))
272
273#ifdef NODE_MEM_SIZE_BITS
274#define NODE_MEM_SIZE_MASK ((1 << NODE_MEM_SIZE_BITS) - 1)
275
276/*
277 * Given a kernel address, find the home node of the underlying memory.
278 */
279#define KVADDR_TO_NID(addr) \
280 (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MEM_SIZE_BITS)
281
282/*
283 * Given a page frame number, convert it to a node id.
284 */
285#define PFN_TO_NID(pfn) \
286 (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MEM_SIZE_BITS - PAGE_SHIFT))
287
288/*
289 * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
290 * and returns the index corresponding to the appropriate page in the
291 * node's mem_map.
292 */
293#define LOCAL_MAP_NR(addr) \
294 (((unsigned long)(addr) & NODE_MEM_SIZE_MASK) >> PAGE_SHIFT)
295
296#endif /* NODE_MEM_SIZE_BITS */
297
259#endif /* !CONFIG_DISCONTIGMEM */ 298#endif /* !CONFIG_DISCONTIGMEM */
260 299
261/* 300/*