Import changeset
[linux-flexiantxendom0-3.2.10.git] / include / asm-arm / arch-sa1100 / mmzone.h
1 /*
2  * linux/include/asm-arm/arch-sa1100/mmzone.h
3  *
4  * (C) 1999-2000, Nicolas Pitre <nico@cam.org>
5  * (inspired by Kanoj Sarcar's code)
6  *
7  * Because of the wide memory address space between physical RAM banks on the 
8  * SA1100, it's much convenient to use Linux's NUMA support to implement our 
9  * memory map representation.  Assuming all memory nodes have equal access 
10  * characteristics, we then have generic discontigous memory support.
11  *
12  * Of course, all this isn't mandatory for SA1100 implementations with only
13  * one used memory bank.  For those, simply undefine CONFIG_DISCONTIGMEM.
14  *
15  * The nodes are matched with the physical memory bank addresses which are 
16  * incidentally the same as virtual addresses.
17  * 
18  *      node 0:  0xc0000000 - 0xc7ffffff
19  *      node 1:  0xc8000000 - 0xcfffffff
20  *      node 2:  0xd0000000 - 0xd7ffffff
21  *      node 3:  0xd8000000 - 0xdfffffff
22  */
23
24
25 /*
26  * Currently defined in arch/arm/mm/mm-sa1100.c
27  */
28 extern pg_data_t sa1100_node_data[];
29
30 /*
31  * Return a pointer to the node data for node n.
32  */
33 #define NODE_DATA(nid)  (&sa1100_node_data[nid])
34
35 /*
36  * NODE_MEM_MAP gives the kaddr for the mem_map of the node.
37  */
38 #define NODE_MEM_MAP(nid)       (NODE_DATA(nid)->node_mem_map)
39
40 /*
41  * Given a kernel address, find the home node of the underlying memory.
42  */
43 #define KVADDR_TO_NID(addr) \
44                 (((unsigned long)(addr) & 0x18000000) >> 27)
45
46 /*
47  * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory
48  * and returns the the mem_map of that node.
49  */
50 #define ADDR_TO_MAPBASE(kaddr) \
51                         NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr)))
52
53 /*
54  * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
55  * and returns the index corresponding to the appropriate page in the
56  * node's mem_map.
57  */
58 #define LOCAL_MAP_NR(kvaddr) \
59         (((unsigned long)(kvaddr) & 0x07ffffff) >> PAGE_SHIFT)
60
61 /*
62  * Given a kaddr, virt_to_page returns a pointer to the corresponding 
63  * mem_map entry.
64  */
65 #define virt_to_page(kaddr) \
66         (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
67
68 /*
69  * Didn't find the best way to validate a page pointer yet...
70  */
71
72 #define VALID_PAGE(page)        (1)