mmzone.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PARISC_MMZONE_H
  3. #define _PARISC_MMZONE_H
  4. #define MAX_PHYSMEM_RANGES 8 /* Fix the size for now (current known max is 3) */
  5. #ifdef CONFIG_DISCONTIGMEM
  6. extern int npmem_ranges;
  7. struct node_map_data {
  8. pg_data_t pg_data;
  9. };
  10. extern struct node_map_data node_data[];
  11. #define NODE_DATA(nid) (&node_data[nid].pg_data)
  12. /* We have these possible memory map layouts:
  13. * Astro: 0-3.75, 67.75-68, 4-64
  14. * zx1: 0-1, 257-260, 4-256
  15. * Stretch (N-class): 0-2, 4-32, 34-xxx
  16. */
  17. /* Since each 1GB can only belong to one region (node), we can create
  18. * an index table for pfn to nid lookup; each entry in pfnnid_map
  19. * represents 1GB, and contains the node that the memory belongs to. */
  20. #define PFNNID_SHIFT (30 - PAGE_SHIFT)
  21. #define PFNNID_MAP_MAX 512 /* support 512GB */
  22. extern signed char pfnnid_map[PFNNID_MAP_MAX];
  23. #ifndef CONFIG_64BIT
  24. #define pfn_is_io(pfn) ((pfn & (0xf0000000UL >> PAGE_SHIFT)) == (0xf0000000UL >> PAGE_SHIFT))
  25. #else
  26. /* io can be 0xf0f0f0f0f0xxxxxx or 0xfffffffff0000000 */
  27. #define pfn_is_io(pfn) ((pfn & (0xf000000000000000UL >> PAGE_SHIFT)) == (0xf000000000000000UL >> PAGE_SHIFT))
  28. #endif
  29. static inline int pfn_to_nid(unsigned long pfn)
  30. {
  31. unsigned int i;
  32. if (unlikely(pfn_is_io(pfn)))
  33. return 0;
  34. i = pfn >> PFNNID_SHIFT;
  35. BUG_ON(i >= ARRAY_SIZE(pfnnid_map));
  36. return pfnnid_map[i];
  37. }
  38. static inline int pfn_valid(int pfn)
  39. {
  40. int nid = pfn_to_nid(pfn);
  41. if (nid >= 0)
  42. return (pfn < node_end_pfn(nid));
  43. return 0;
  44. }
  45. #endif
  46. #endif /* _PARISC_MMZONE_H */