mmzone.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _PARISC_MMZONE_H
  2. #define _PARISC_MMZONE_H
  3. #define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
  4. #ifdef CONFIG_DISCONTIGMEM
  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 signed 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. if (unlikely(pfn_is_io(pfn)))
  32. return 0;
  33. i = pfn >> PFNNID_SHIFT;
  34. BUG_ON(i >= ARRAY_SIZE(pfnnid_map));
  35. return pfnnid_map[i];
  36. }
  37. static inline int pfn_valid(int pfn)
  38. {
  39. int nid = pfn_to_nid(pfn);
  40. if (nid >= 0)
  41. return (pfn < node_end_pfn(nid));
  42. return 0;
  43. }
  44. #endif
  45. #endif /* _PARISC_MMZONE_H */