xref: /openbmc/linux/arch/parisc/include/asm/mmzone.h (revision 872420b3)
1deae26bfSKyle McMartin #ifndef _PARISC_MMZONE_H
2deae26bfSKyle McMartin #define _PARISC_MMZONE_H
3deae26bfSKyle McMartin 
4872420b3SJohn David Anglin #define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
5872420b3SJohn David Anglin 
6deae26bfSKyle McMartin #ifdef CONFIG_DISCONTIGMEM
7deae26bfSKyle McMartin 
8deae26bfSKyle McMartin extern int npmem_ranges;
9deae26bfSKyle McMartin 
10deae26bfSKyle McMartin struct node_map_data {
11deae26bfSKyle McMartin     pg_data_t pg_data;
12deae26bfSKyle McMartin };
13deae26bfSKyle McMartin 
14deae26bfSKyle McMartin extern struct node_map_data node_data[];
15deae26bfSKyle McMartin 
16deae26bfSKyle McMartin #define NODE_DATA(nid)          (&node_data[nid].pg_data)
17deae26bfSKyle McMartin 
18deae26bfSKyle McMartin /* We have these possible memory map layouts:
19deae26bfSKyle McMartin  * Astro: 0-3.75, 67.75-68, 4-64
20deae26bfSKyle McMartin  * zx1: 0-1, 257-260, 4-256
21deae26bfSKyle McMartin  * Stretch (N-class): 0-2, 4-32, 34-xxx
22deae26bfSKyle McMartin  */
23deae26bfSKyle McMartin 
24deae26bfSKyle McMartin /* Since each 1GB can only belong to one region (node), we can create
25deae26bfSKyle McMartin  * an index table for pfn to nid lookup; each entry in pfnnid_map
26deae26bfSKyle McMartin  * represents 1GB, and contains the node that the memory belongs to. */
27deae26bfSKyle McMartin 
28deae26bfSKyle McMartin #define PFNNID_SHIFT (30 - PAGE_SHIFT)
29deae26bfSKyle McMartin #define PFNNID_MAP_MAX  512     /* support 512GB */
30deae26bfSKyle McMartin extern unsigned char pfnnid_map[PFNNID_MAP_MAX];
31deae26bfSKyle McMartin 
32deae26bfSKyle McMartin #ifndef CONFIG_64BIT
33deae26bfSKyle McMartin #define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
34deae26bfSKyle McMartin #else
35deae26bfSKyle McMartin /* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
36deae26bfSKyle McMartin #define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
37deae26bfSKyle McMartin #endif
38deae26bfSKyle McMartin 
39deae26bfSKyle McMartin static inline int pfn_to_nid(unsigned long pfn)
40deae26bfSKyle McMartin {
41deae26bfSKyle McMartin 	unsigned int i;
42deae26bfSKyle McMartin 	unsigned char r;
43deae26bfSKyle McMartin 
44deae26bfSKyle McMartin 	if (unlikely(pfn_is_io(pfn)))
45deae26bfSKyle McMartin 		return 0;
46deae26bfSKyle McMartin 
47deae26bfSKyle McMartin 	i = pfn >> PFNNID_SHIFT;
48deae26bfSKyle McMartin 	BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0]));
49deae26bfSKyle McMartin 	r = pfnnid_map[i];
50deae26bfSKyle McMartin 	BUG_ON(r == 0xff);
51deae26bfSKyle McMartin 
52deae26bfSKyle McMartin 	return (int)r;
53deae26bfSKyle McMartin }
54deae26bfSKyle McMartin 
55deae26bfSKyle McMartin static inline int pfn_valid(int pfn)
56deae26bfSKyle McMartin {
57deae26bfSKyle McMartin 	int nid = pfn_to_nid(pfn);
58deae26bfSKyle McMartin 
59deae26bfSKyle McMartin 	if (nid >= 0)
60deae26bfSKyle McMartin 		return (pfn < node_end_pfn(nid));
61deae26bfSKyle McMartin 	return 0;
62deae26bfSKyle McMartin }
63deae26bfSKyle McMartin 
64deae26bfSKyle McMartin #endif
65deae26bfSKyle McMartin #endif /* _PARISC_MMZONE_H */
66