ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-arm / arch-lh7a40x / memory.h
1 /* include/asm-arm/arch-lh7a40x/memory.h
2  *
3  *  Copyright (C) 2004 Coastal Environmental Systems
4  *
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.
8  *
9  */
10
11 #ifndef __ASM_ARCH_MEMORY_H
12 #define __ASM_ARCH_MEMORY_H
13
14
15 #define BANKS_PER_NODE 1        /* Define as either 1 or 2 */
16
17 /*
18  * Task size: 3GB
19  */
20 #define TASK_SIZE       (0xbf000000UL) /* 0xc0000000? */
21 #define TASK_SIZE_26    (0x04000000UL)
22
23 /*
24  * This decides where the kernel will search for a free chunk of vm
25  * space during mmap's.
26  */
27 #define TASK_UNMAPPED_BASE (0x40000000)
28
29 /*
30  * Page offset: 3GB
31  */
32 #define PAGE_OFFSET     (0xc0000000UL)
33
34 /*
35  * Physical DRAM offset.
36  */
37 #define PHYS_OFFSET     (0xc0000000UL)
38
39 /*
40  * physical vs virtual ram conversion
41  */
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)
46
47 /*
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.
53  */
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)
58
59 #ifdef CONFIG_DISCONTIGMEM
60 /*
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.
65  *
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.
70  *
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.
74  *
75  * A typical layout would start like this:
76  *
77  *  node 0: 0xc0000000
78  *          0xc1000000
79  *  node 1: 0xc4000000
80  *          0xc5000000
81  *  node 2: 0xc8000000
82  *          0xc9000000
83  *
84  * The proximity of the pairs of blocks makes it feasible to combine them.
85  *
86  */
87
88 /*
89  * Given a kernel address, find the home node of the underlying memory.
90  */
91
92 #if BANKS_PER_NODE==1
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)
99 #endif
100
101 /*
102  * Given a page frame number, convert it to a node id.
103  */
104
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))
112 #endif
113
114 /*
115  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
116  * and return the mem_map of that node.
117  */
118 #define ADDR_TO_MAPBASE(kaddr)  NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
119
120 /*
121  * Given a page frame number, find the owning node of the memory
122  * and return the mem_map of that node.
123  */
124 #define PFN_TO_MAPBASE(pfn)     NODE_MEM_MAP(PFN_TO_NID(pfn))
125
126 /*
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
129  * node's mem_map.
130  */
131
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)
138 #endif
139
140 #else
141
142 #define PFN_TO_NID(addr)        (0)
143
144 #endif
145
146 #endif