]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002 | |
4 | * | |
5 | */ | |
6 | ||
7 | #ifndef _ASM_MMZONE_H_ | |
8 | #define _ASM_MMZONE_H_ | |
9 | ||
10 | #include <asm/smp.h> | |
11 | ||
12 | #ifdef CONFIG_DISCONTIGMEM | |
13 | ||
14 | extern struct pglist_data *node_data[]; | |
15 | #define NODE_DATA(nid) (node_data[nid]) | |
16 | ||
17 | #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn) | |
1da177e4 | 18 | |
1da177e4 LT |
19 | #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT)) |
20 | /* | |
21 | * pfn_valid should be made as fast as possible, and the current definition | |
22 | * is valid for machines that are NUMA, but still contiguous, which is what | |
23 | * is currently supported. A more generalised, but slower definition would | |
24 | * be something like this - mbligh: | |
25 | * ( pfn_to_pgdat(pfn) && ((pfn) < node_end_pfn(pfn_to_nid(pfn))) ) | |
26 | */ | |
27 | #if 1 /* M32R_FIXME */ | |
28 | #define pfn_valid(pfn) (1) | |
29 | #else | |
30 | #define pfn_valid(pfn) ((pfn) < num_physpages) | |
31 | #endif | |
32 | ||
33 | /* | |
34 | * generic node memory support, the following assumptions apply: | |
35 | */ | |
36 | ||
37 | static __inline__ int pfn_to_nid(unsigned long pfn) | |
38 | { | |
39 | int node; | |
40 | ||
41 | for (node = 0 ; node < MAX_NUMNODES ; node++) | |
c6830c22 | 42 | if (pfn >= node_start_pfn(node) && pfn < node_end_pfn(node)) |
1da177e4 LT |
43 | break; |
44 | ||
45 | return node; | |
46 | } | |
47 | ||
48 | static __inline__ struct pglist_data *pfn_to_pgdat(unsigned long pfn) | |
49 | { | |
50 | return(NODE_DATA(pfn_to_nid(pfn))); | |
51 | } | |
52 | ||
53 | #endif /* CONFIG_DISCONTIGMEM */ | |
54 | #endif /* _ASM_MMZONE_H_ */ |