]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/asm-m32r/mmzone.h
Merge branch 'master'
[linux-2.6-omap-h63xx.git] / include / asm-m32r / mmzone.h
1 /*
2  * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
3  *
4  */
5
6 #ifndef _ASM_MMZONE_H_
7 #define _ASM_MMZONE_H_
8
9 #include <asm/smp.h>
10
11 #ifdef CONFIG_DISCONTIGMEM
12
13 extern struct pglist_data *node_data[];
14 #define NODE_DATA(nid)          (node_data[nid])
15
16 #define node_localnr(pfn, nid)  ((pfn) - NODE_DATA(nid)->node_start_pfn)
17 #define node_start_pfn(nid)     (NODE_DATA(nid)->node_start_pfn)
18 #define node_end_pfn(nid)                                               \
19 ({                                                                      \
20         pg_data_t *__pgdat = NODE_DATA(nid);                            \
21         __pgdat->node_start_pfn + __pgdat->node_spanned_pages - 1;      \
22 })
23
24 #define pfn_to_page(pfn)                                                \
25 ({                                                                      \
26         unsigned long __pfn = pfn;                                      \
27         int __node  = pfn_to_nid(__pfn);                                \
28         &NODE_DATA(__node)->node_mem_map[node_localnr(__pfn,__node)];   \
29 })
30
31 #define page_to_pfn(pg)                                                 \
32 ({                                                                      \
33         struct page *__page = pg;                                       \
34         struct zone *__zone = page_zone(__page);                        \
35         (unsigned long)(__page - __zone->zone_mem_map)                  \
36                 + __zone->zone_start_pfn;                               \
37 })
38 #define pmd_page(pmd)           (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
39 /*
40  * pfn_valid should be made as fast as possible, and the current definition
41  * is valid for machines that are NUMA, but still contiguous, which is what
42  * is currently supported. A more generalised, but slower definition would
43  * be something like this - mbligh:
44  * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) )
45  */
46 #if 1   /* M32R_FIXME */
47 #define pfn_valid(pfn)  (1)
48 #else
49 #define pfn_valid(pfn)  ((pfn) < num_physpages)
50 #endif
51
52 /*
53  * generic node memory support, the following assumptions apply:
54  */
55
56 static __inline__ int pfn_to_nid(unsigned long pfn)
57 {
58         int node;
59
60         for (node = 0 ; node < MAX_NUMNODES ; node++)
61                 if (pfn >= node_start_pfn(node) && pfn <= node_end_pfn(node))
62                         break;
63
64         return node;
65 }
66
67 static __inline__ struct pglist_data *pfn_to_pgdat(unsigned long pfn)
68 {
69         return(NODE_DATA(pfn_to_nid(pfn)));
70 }
71
72 #endif /* CONFIG_DISCONTIGMEM */
73 #endif /* _ASM_MMZONE_H_ */