mmzone.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /* We have these possible memory map layouts:
  12. * Astro: 0-3.75, 67.75-68, 4-64
  13. * zx1: 0-1, 257-260, 4-256
  14. * Stretch (N-class): 0-2, 4-32, 34-xxx
  15. */
  16. /* Since each 1GB can only belong to one region (node), we can create
  17. * an index table for pfn to nid lookup; each entry in pfnnid_map
  18. * represents 1GB, and contains the node that the memory belongs to. */
  19. #define PFNNID_SHIFT (30 - PAGE_SHIFT)
  20. #define PFNNID_MAP_MAX 512 /* support 512GB */
  21. extern unsigned char pfnnid_map[PFNNID_MAP_MAX];
  22. #ifndef CONFIG_64BIT
  23. #define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
  24. #else
  25. /* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
  26. #define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
  27. #endif
  28. static inline int pfn_to_nid(unsigned long pfn)
  29. {
  30. unsigned int i;
  31. unsigned char r;
  32. if (unlikely(pfn_is_io(pfn)))
  33. return 0;
  34. i = pfn >> PFNNID_SHIFT;
  35. BUG_ON(i >= sizeof(pfnnid_map) / sizeof(pfnnid_map[0]));
  36. r = pfnnid_map[i];
  37. BUG_ON(r == 0xff);
  38. return (int)r;
  39. }
  40. static inline int pfn_valid(int pfn)
  41. {
  42. int nid = pfn_to_nid(pfn);
  43. if (nid >= 0)
  44. return (pfn < node_end_pfn(nid));
  45. return 0;
  46. }
  47. #else /* !CONFIG_DISCONTIGMEM */
  48. #define MAX_PHYSMEM_RANGES 1
  49. #endif
  50. #endif /* _PARISC_MMZONE_H */