mmzone.h 1.8 KB

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