ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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  * Task size: 3GB
14  */
15 #define TASK_SIZE       (0xbf000000UL)
16 #define TASK_SIZE_26    (0x04000000UL)
17
18 /*
19  * This decides where the kernel will search for a free chunk of vm
20  * space during mmap's.
21  */
22 #define TASK_UNMAPPED_BASE (0x40000000)
23
24 /*
25  * Page offset: 3GB
26  */
27 #define PAGE_OFFSET     (0xc0000000UL)
28
29 /*
30  * Physical DRAM offset is 0xc0000000 on the SA1100
31  */
32 #define PHYS_OFFSET     (0xc0000000UL)
33
34 /*
35  * We take advantage of the fact that physical and virtual address can be the
36  * same.  The NUMA code is handling the large holes that might exist between
37  * all memory banks.
38  */
39 #define __virt_to_phys__is_a_macro
40 #define __phys_to_virt__is_a_macro
41 #define __virt_to_phys(x)       (x)
42 #define __phys_to_virt(x)       (x)
43
44 /*
45  * Virtual view <-> DMA view memory address translations
46  * virt_to_bus: Used to translate the virtual address to an
47  *              address suitable to be passed to set_dma_addr
48  * bus_to_virt: Used to convert an address for DMA operations
49  *              to an address that the kernel can use.
50  *
51  * On the SA1100, bus addresses are equivalent to physical addresses.
52  */
53 #define __virt_to_bus__is_a_macro
54 #define __bus_to_virt__is_a_macro
55 #define __virt_to_bus(x)         __virt_to_phys(x)
56 #define __bus_to_virt(x)         __phys_to_virt(x)
57
58 #ifdef CONFIG_DISCONTIGMEM
59 /*
60  * Because of the wide memory address space between physical RAM banks on the 
61  * SA1100, it's much convenient to use Linux's NUMA support to implement our 
62  * memory map representation.  Assuming all memory nodes have equal access 
63  * characteristics, we then have generic discontiguous memory support.
64  *
65  * Of course, all this isn't mandatory for SA1100 implementations with only
66  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
67  *
68  * The nodes are matched with the physical memory bank addresses which are 
69  * incidentally the same as virtual addresses.
70  * 
71  *      node 0:  0xc0000000 - 0xc7ffffff
72  *      node 1:  0xc8000000 - 0xcfffffff
73  *      node 2:  0xd0000000 - 0xd7ffffff
74  *      node 3:  0xd8000000 - 0xdfffffff
75  */
76
77 /*
78  * Given a kernel address, find the home node of the underlying memory.
79  */
80 #define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27)
81
82 /*
83  * Given a page frame number, convert it to a node id.
84  */
85 #define PFN_TO_NID(pfn)         (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT))
86
87 /*
88  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
89  * and return the mem_map of that node.
90  */
91 #define ADDR_TO_MAPBASE(kaddr)  NODE_MEM_MAP(KVADDR_TO_NID(kaddr))
92
93 /*
94  * Given a page frame number, find the owning node of the memory
95  * and return the mem_map of that node.
96  */
97 #define PFN_TO_MAPBASE(pfn)     NODE_MEM_MAP(PFN_TO_NID(pfn))
98
99 /*
100  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
101  * and returns the index corresponding to the appropriate page in the
102  * node's mem_map.
103  */
104 #define LOCAL_MAP_NR(addr) \
105         (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT)
106
107 #else
108
109 #define PFN_TO_NID(addr)        (0)
110
111 #endif
112
113 #endif