Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / include / asm-parisc / mmzone.h
1 #ifndef _PARISC_MMZONE_H
2 #define _PARISC_MMZONE_H
3
4 #ifdef CONFIG_DISCONTIGMEM
5
6 #define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
7 extern int npmem_ranges;
8
9 struct node_map_data {
10     pg_data_t pg_data;
11 };
12
13 extern struct node_map_data node_data[];
14
15 #define NODE_DATA(nid)          (&node_data[nid].pg_data)
16
17 /*
18  * Given a kernel address, find the home node of the underlying memory.
19  */
20 #define kvaddr_to_nid(kaddr)    pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
21
22 #define node_start_pfn(nid)     (NODE_DATA(nid)->node_start_pfn)
23 #define node_end_pfn(nid)                                               \
24 ({                                                                      \
25         pg_data_t *__pgdat = NODE_DATA(nid);                            \
26         __pgdat->node_start_pfn + __pgdat->node_spanned_pages;          \
27 })
28
29 /* We have these possible memory map layouts:
30  * Astro: 0-3.75, 67.75-68, 4-64
31  * zx1: 0-1, 257-260, 4-256
32  * Stretch (N-class): 0-2, 4-32, 34-xxx
33  */
34
35 /* Since each 1GB can only belong to one region (node), we can create
36  * an index table for pfn to nid lookup; each entry in pfnnid_map 
37  * represents 1GB, and contains the node that the memory belongs to. */
38
39 #define PFNNID_SHIFT (30 - PAGE_SHIFT)
40 #define PFNNID_MAP_MAX  512     /* support 512GB */
41 extern unsigned char pfnnid_map[PFNNID_MAP_MAX];
42
43 #ifndef __LP64__
44 #define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
45 #else
46 /* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
47 #define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
48 #endif
49
50 static inline int pfn_to_nid(unsigned long pfn)
51 {
52         unsigned int i;
53         unsigned char r;
54
55         if (unlikely(pfn_is_io(pfn)))
56                 return 0;
57
58         i = pfn >> PFNNID_SHIFT;
59         BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0]));
60         r = pfnnid_map[i];
61         BUG_ON(r == 0xff);
62
63         return (int)r;
64 }
65
66 static inline int pfn_valid(int pfn)
67 {
68         int nid = pfn_to_nid(pfn);
69
70         if (nid >= 0)
71                 return (pfn < node_end_pfn(nid));
72         return 0;
73 }
74
75 #else /* !CONFIG_DISCONTIGMEM */
76 #define MAX_PHYSMEM_RANGES      1 
77 #endif
78 #endif /* _PARISC_MMZONE_H */