mmzone.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /*
  12. * Given a kernel address, find the home node of the underlying memory.
  13. */
  14. #define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT)
  15. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  16. #define node_end_pfn(nid) \
  17. ({ \
  18. pg_data_t *__pgdat = NODE_DATA(nid); \
  19. __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
  20. })
  21. /* We have these possible memory map layouts:
  22. * Astro: 0-3.75, 67.75-68, 4-64
  23. * zx1: 0-1, 257-260, 4-256
  24. * Stretch (N-class): 0-2, 4-32, 34-xxx
  25. */
  26. /* Since each 1GB can only belong to one region (node), we can create
  27. * an index table for pfn to nid lookup; each entry in pfnnid_map
  28. * represents 1GB, and contains the node that the memory belongs to. */
  29. #define PFNNID_SHIFT (30 - PAGE_SHIFT)
  30. #define PFNNID_MAP_MAX 512 /* support 512GB */
  31. extern unsigned char pfnnid_map[PFNNID_MAP_MAX];
  32. #ifndef __LP64__
  33. #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. static inline int pfn_to_nid(unsigned long pfn)
  39. {
  40. unsigned int i;
  41. unsigned char r;
  42. if (unlikely(pfn_is_io(pfn)))
  43. return 0;
  44. i = pfn >> PFNNID_SHIFT;
  45. BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0]));
  46. r = pfnnid_map[i];
  47. BUG_ON(r == 0xff);
  48. return (int)r;
  49. }
  50. static inline int pfn_valid(int pfn)
  51. {
  52. int nid = pfn_to_nid(pfn);
  53. if (nid >= 0)
  54. return (pfn < node_end_pfn(nid));
  55. return 0;
  56. }
  57. #else /* !CONFIG_DISCONTIGMEM */
  58. #define MAX_PHYSMEM_RANGES 1
  59. #endif
  60. #endif /* _PARISC_MMZONE_H */