1 /* include/asm-arm/arch-lh7a40x/memory.h
3 * Copyright (C) 2004 Coastal Environmental Systems
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
11 #ifndef __ASM_ARCH_MEMORY_H
12 #define __ASM_ARCH_MEMORY_H
15 #define BANKS_PER_NODE 1 /* Define as either 1 or 2 */
20 #define TASK_SIZE (0xbf000000UL) /* 0xc0000000? */
21 #define TASK_SIZE_26 (0x04000000UL)
24 * This decides where the kernel will search for a free chunk of vm
25 * space during mmap's.
27 #define TASK_UNMAPPED_BASE (0x40000000)
32 #define PAGE_OFFSET (0xc0000000UL)
35 * Physical DRAM offset.
37 #define PHYS_OFFSET (0xc0000000UL)
40 * physical vs virtual ram conversion
42 #define __virt_to_phys__is_a_macro
43 #define __phys_to_virt__is_a_macro
44 #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
45 #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
48 * Virtual view <-> DMA view memory address translations
49 * virt_to_bus: Used to translate the virtual address to an
50 * address suitable to be passed to set_dma_addr
51 * bus_to_virt: Used to convert an address for DMA operations
52 * to an address that the kernel can use.
54 #define __virt_to_bus__is_a_macro
55 #define __bus_to_virt__is_a_macro
56 #define __virt_to_bus(x) __virt_to_phys(x)
57 #define __bus_to_virt(x) __phys_to_virt(x)
59 #ifdef CONFIG_DISCONTIGMEM
61 * Because of the wide memory address space between physical RAM
62 * banks, it's convenient to use Linux's NUMA support to represent our
63 * memory map. Assuming all memory nodes have equal access
64 * characteristics, we then have a generic discontiguous memory setup.
66 * Of course, all this isn't mandatory for implementations with only
67 * one used memory bank. For those, simply undefine
68 * CONFIG_DISCONTIGMEM. However, keep in mind that a featurefull
69 * system will need more than 4MiB of RAM.
71 * The contiguous memory blocks are small enough that it pays to
72 * aggregate two banks into one node. Setting BANKS_PER_NODE to 2
73 * puts pairs of banks into a node.
75 * A typical layout would start like this:
84 * The proximity of the pairs of blocks makes it feasible to combine them.
89 * Given a kernel address, find the home node of the underlying memory.
93 #define KVADDR_TO_NID(addr) \
94 ( ((((unsigned long) (addr) - PAGE_OFFSET) >> 24) & 1)\
95 | ((((unsigned long) (addr) - PAGE_OFFSET) >> 25) & ~1))
96 #else /* 2 banks per node */
97 #define KVADDR_TO_NID(addr) \
98 ((unsigned long) (addr) - PAGE_OFFSET) >> 26)
102 * Given a page frame number, convert it to a node id.
105 #if BANKS_PER_NODE==1
106 #define PFN_TO_NID(pfn) \
107 (((((pfn) - PHYS_PFN_OFFSET) >> (24 - PAGE_SHIFT)) & 1)\
108 | ((((pfn) - PHYS_PFN_OFFSET) >> (25 - PAGE_SHIFT)) & ~1))
109 #else /* 2 banks per node */
110 #define PFN_TO_NID(addr) \
111 (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT))
115 * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
116 * and return the mem_map of that node.
118 #define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
121 * Given a page frame number, find the owning node of the memory
122 * and return the mem_map of that node.
124 #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn))
127 * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
128 * and returns the index corresponding to the appropriate page in the
132 #if BANKS_PER_NODE==1
133 #define LOCAL_MAP_NR(addr) \
134 (((unsigned long)(addr) & 0x003fffff) >> PAGE_SHIFT)
135 #else /* 2 banks per node */
136 #define LOCAL_MAP_NR(addr) \
137 (((unsigned long)(addr) & 0x01ffffff) >> PAGE_SHIFT)
142 #define PFN_TO_NID(addr) (0)