blob: b6b34a0987e7d7aafb42cd47d0c3b8f888007bd8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _PARISC_MMZONE_H
2#define _PARISC_MMZONE_H
3
John David Anglin872420b2013-02-02 23:42:25 +00004#define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#ifdef CONFIG_DISCONTIGMEM
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008extern int npmem_ranges;
9
10struct node_map_data {
11 pg_data_t pg_data;
12};
13
14extern struct node_map_data node_data[];
15
16#define NODE_DATA(nid) (&node_data[nid].pg_data)
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018/* We have these possible memory map layouts:
19 * Astro: 0-3.75, 67.75-68, 4-64
20 * zx1: 0-1, 257-260, 4-256
21 * Stretch (N-class): 0-2, 4-32, 34-xxx
22 */
23
24/* Since each 1GB can only belong to one region (node), we can create
25 * an index table for pfn to nid lookup; each entry in pfnnid_map
26 * represents 1GB, and contains the node that the memory belongs to. */
27
28#define PFNNID_SHIFT (30 - PAGE_SHIFT)
29#define PFNNID_MAP_MAX 512 /* support 512GB */
Helge Deller91ea8202013-06-05 20:50:01 +000030extern signed char pfnnid_map[PFNNID_MAP_MAX];
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Helge Deller513e7ec2007-01-28 15:09:20 +010032#ifndef CONFIG_64BIT
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
34#else
35/* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
36#define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
37#endif
38
39static inline int pfn_to_nid(unsigned long pfn)
40{
41 unsigned int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43 if (unlikely(pfn_is_io(pfn)))
44 return 0;
45
46 i = pfn >> PFNNID_SHIFT;
Nikitas Angelinas1dda59b2010-09-08 21:11:13 +000047 BUG_ON(i >= ARRAY_SIZE(pfnnid_map));
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Helge Deller91ea8202013-06-05 20:50:01 +000049 return pfnnid_map[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
52static inline int pfn_valid(int pfn)
53{
54 int nid = pfn_to_nid(pfn);
55
56 if (nid >= 0)
57 return (pfn < node_end_pfn(nid));
58 return 0;
59}
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#endif
62#endif /* _PARISC_MMZONE_H */