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) */ 7extern int npmem_ranges; 8 9struct node_map_data { 10 pg_data_t pg_data; 11}; 12 13extern struct node_map_data node_data[]; 14 15#define NODE_DATA(nid) (&node_data[nid].pg_data) 16 17#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) 18#define node_end_pfn(nid) \ 19({ \ 20 pg_data_t *__pgdat = NODE_DATA(nid); \ 21 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ 22}) 23 24 25/* Since each 1GB can only belong to one region (node), we can create 26 * an index table for pfn to nid lookup; each entry in pfnnid_map 27 * represents 1GB, and contains the node that the memory belongs to. */ 28 29#define PFNNID_SHIFT (30 - PAGE_SHIFT) 30#define PFNNID_MAP_MAX 512 /* support 512GB */ 31extern unsigned char pfnnid_map[PFNNID_MAP_MAX]; 32 33#ifndef CONFIG_64BIT 34#define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT)) 35#else 36/* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */ 37#define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT)) 38#endif 39 40static inline int pfn_to_nid(unsigned long pfn) 41{ 42 unsigned int i; 43 unsigned char r; 44 45 if (unlikely(pfn_is_io(pfn))) 46 return 0; 47 48 i = pfn >> PFNNID_SHIFT; 49 BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0])); 50 r = pfnnid_map[i]; 51 BUG_ON(r == 0xff); 52 53 return (int)r; 54} 55 56static inline int pfn_valid(int pfn) 57{ 58 int nid = pfn_to_nid(pfn); 59 60 if (nid >= 0) 61 return (pfn < node_end_pfn(nid)); 62 return 0; 63} 64 65#else /* !CONFIG_DISCONTIGMEM */ 66#define MAX_PHYSMEM_RANGES 1 67#endif 68#endif /* _PARISC_MMZONE_H */ 69