Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mmzone.h
Go to the documentation of this file.
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 /* We have these possible memory map layouts:
18  * Astro: 0-3.75, 67.75-68, 4-64
19  * zx1: 0-1, 257-260, 4-256
20  * Stretch (N-class): 0-2, 4-32, 34-xxx
21  */
22 
23 /* Since each 1GB can only belong to one region (node), we can create
24  * an index table for pfn to nid lookup; each entry in pfnnid_map
25  * represents 1GB, and contains the node that the memory belongs to. */
26 
27 #define PFNNID_SHIFT (30 - PAGE_SHIFT)
28 #define PFNNID_MAP_MAX 512 /* support 512GB */
29 extern unsigned char pfnnid_map[PFNNID_MAP_MAX];
30 
31 #ifndef CONFIG_64BIT
32 #define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
33 #else
34 /* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
35 #define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
36 #endif
37 
38 static inline int pfn_to_nid(unsigned long pfn)
39 {
40  unsigned int i;
41  unsigned char r;
42 
43  if (unlikely(pfn_is_io(pfn)))
44  return 0;
45 
46  i = pfn >> PFNNID_SHIFT;
47  BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0]));
48  r = pfnnid_map[i];
49  BUG_ON(r == 0xff);
50 
51  return (int)r;
52 }
53 
54 static inline int pfn_valid(int pfn)
55 {
56  int nid = pfn_to_nid(pfn);
57 
58  if (nid >= 0)
59  return (pfn < node_end_pfn(nid));
60  return 0;
61 }
62 
63 #else /* !CONFIG_DISCONTIGMEM */
64 #define MAX_PHYSMEM_RANGES 1
65 #endif
66 #endif /* _PARISC_MMZONE_H */