VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / asm-arm / arch-sa1100 / memory.h
1 /*
2  * linux/include/asm-arm/arch-sa1100/memory.h
3  *
4  * Copyright (C) 1999-2000 Nicolas Pitre <nico@cam.org>
5  */
6
7 #ifndef __ASM_ARCH_MEMORY_H
8 #define __ASM_ARCH_MEMORY_H
9
10 #include <linux/config.h>
11 #include <asm/sizes.h>
12
13 /*
14  * Physical DRAM offset is 0xc0000000 on the SA1100
15  */
16 #define PHYS_OFFSET     (0xc0000000UL)
17
18 #ifndef __ASSEMBLY__
19
20 #ifdef CONFIG_SA1111
21 static inline void
22 __arch_adjust_zones(int node, unsigned long *size, unsigned long *holes)
23 {
24         unsigned int sz = SZ_1M >> PAGE_SHIFT;
25
26         if (node != 0)
27                 sz = 0;
28
29         size[1] = size[0] - sz;
30         size[0] = sz;
31 }
32
33 #define arch_adjust_zones(node, size, holes) \
34         __arch_adjust_zones(node, size, holes)
35
36 #define ISA_DMA_THRESHOLD       (PHYS_OFFSET + SZ_1M - 1)
37
38 #endif
39 #endif
40
41 /*
42  * Virtual view <-> DMA view memory address translations
43  * virt_to_bus: Used to translate the virtual address to an
44  *              address suitable to be passed to set_dma_addr
45  * bus_to_virt: Used to convert an address for DMA operations
46  *              to an address that the kernel can use.
47  *
48  * On the SA1100, bus addresses are equivalent to physical addresses.
49  */
50 #define __virt_to_bus(x)         __virt_to_phys(x)
51 #define __bus_to_virt(x)         __phys_to_virt(x)
52
53 #ifdef CONFIG_DISCONTIGMEM
54 /*
55  * Because of the wide memory address space between physical RAM banks on the 
56  * SA1100, it's much convenient to use Linux's NUMA support to implement our 
57  * memory map representation.  Assuming all memory nodes have equal access 
58  * characteristics, we then have generic discontiguous memory support.
59  *
60  * Of course, all this isn't mandatory for SA1100 implementations with only
61  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
62  *
63  * The nodes are matched with the physical memory bank addresses which are 
64  * incidentally the same as virtual addresses.
65  * 
66  *      node 0:  0xc0000000 - 0xc7ffffff
67  *      node 1:  0xc8000000 - 0xcfffffff
68  *      node 2:  0xd0000000 - 0xd7ffffff
69  *      node 3:  0xd8000000 - 0xdfffffff
70  */
71
72 /*
73  * Given a kernel address, find the home node of the underlying memory.
74  */
75 #define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27)
76
77 /*
78  * Given a page frame number, convert it to a node id.
79  */
80 #define PFN_TO_NID(pfn)         (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT))
81
82 /*
83  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
84  * and return the mem_map of that node.
85  */
86 #define ADDR_TO_MAPBASE(kaddr)  NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
87
88 /*
89  * Given a page frame number, find the owning node of the memory
90  * and return the mem_map of that node.
91  */
92 #define PFN_TO_MAPBASE(pfn)     NODE_MEM_MAP(PFN_TO_NID(pfn))
93
94 /*
95  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
96  * and returns the index corresponding to the appropriate page in the
97  * node's mem_map.
98  */
99 #define LOCAL_MAP_NR(addr) \
100         (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT)
101
102 #else
103
104 #define PFN_TO_NID(addr)        (0)
105
106 #endif
107
108 #endif