blob: 115ced33febdbe59de005c23f07abbf01371423a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
13extern 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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
19/*
20 * pfn_valid should be made as fast as possible, and the current definition
21 * is valid for machines that are NUMA, but still contiguous, which is what
22 * is currently supported. A more generalised, but slower definition would
23 * be something like this - mbligh:
24 * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) )
25 */
26#if 1 /* M32R_FIXME */
27#define pfn_valid(pfn) (1)
28#else
29#define pfn_valid(pfn) ((pfn) < num_physpages)
30#endif
31
32/*
33 * generic node memory support, the following assumptions apply:
34 */
35
36static __inline__ int pfn_to_nid(unsigned long pfn)
37{
38 int node;
39
40 for (node = 0 ; node < MAX_NUMNODES ; node++)
KAMEZAWA Hiroyukic6830c22011-06-16 17:28:07 +090041 if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node))
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 break;
43
44 return node;
45}
46
47static __inline__ struct pglist_data *pfn_to_pgdat(unsigned long pfn)
48{
49 return(NODE_DATA(pfn_to_nid(pfn)));
50}
51
52#endif /* CONFIG_DISCONTIGMEM */
53#endif /* _ASM_MMZONE_H_ */