patch-2_6_7-vs1_9_1_12
[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
12 /*
13  * Physical DRAM offset is 0xc0000000 on the SA1100
14  */
15 #define PHYS_OFFSET     (0xc0000000UL)
16
17 /*
18  * Virtual view <-> DMA view memory address translations
19  * virt_to_bus: Used to translate the virtual address to an
20  *              address suitable to be passed to set_dma_addr
21  * bus_to_virt: Used to convert an address for DMA operations
22  *              to an address that the kernel can use.
23  *
24  * On the SA1100, bus addresses are equivalent to physical addresses.
25  */
26 #define __virt_to_bus(x)         __virt_to_phys(x)
27 #define __bus_to_virt(x)         __phys_to_virt(x)
28
29 #ifdef CONFIG_DISCONTIGMEM
30 /*
31  * Because of the wide memory address space between physical RAM banks on the 
32  * SA1100, it's much convenient to use Linux's NUMA support to implement our 
33  * memory map representation.  Assuming all memory nodes have equal access 
34  * characteristics, we then have generic discontiguous memory support.
35  *
36  * Of course, all this isn't mandatory for SA1100 implementations with only
37  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
38  *
39  * The nodes are matched with the physical memory bank addresses which are 
40  * incidentally the same as virtual addresses.
41  * 
42  *      node 0:  0xc0000000 - 0xc7ffffff
43  *      node 1:  0xc8000000 - 0xcfffffff
44  *      node 2:  0xd0000000 - 0xd7ffffff
45  *      node 3:  0xd8000000 - 0xdfffffff
46  */
47
48 /*
49  * Given a kernel address, find the home node of the underlying memory.
50  */
51 #define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27)
52
53 /*
54  * Given a page frame number, convert it to a node id.
55  */
56 #define PFN_TO_NID(pfn)         (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT))
57
58 /*
59  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
60  * and return the mem_map of that node.
61  */
62 #define ADDR_TO_MAPBASE(kaddr)  NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
63
64 /*
65  * Given a page frame number, find the owning node of the memory
66  * and return the mem_map of that node.
67  */
68 #define PFN_TO_MAPBASE(pfn)     NODE_MEM_MAP(PFN_TO_NID(pfn))
69
70 /*
71  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
72  * and returns the index corresponding to the appropriate page in the
73  * node's mem_map.
74  */
75 #define LOCAL_MAP_NR(addr) \
76         (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT)
77
78 #else
79
80 #define PFN_TO_NID(addr)        (0)
81
82 #endif
83
84 #endif