mmzone_32.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
  3. *
  4. */
  5. #ifndef _ASM_MMZONE_H_
  6. #define _ASM_MMZONE_H_
  7. #include <asm/smp.h>
  8. #ifdef CONFIG_NUMA
  9. extern struct pglist_data *node_data[];
  10. #define NODE_DATA(nid) (node_data[nid])
  11. #ifdef CONFIG_X86_NUMAQ
  12. #include <asm/numaq.h>
  13. #elif defined(CONFIG_ACPI_SRAT)/* summit or generic arch */
  14. #include <asm/srat.h>
  15. #endif
  16. extern int get_memcfg_numa_flat(void );
  17. /*
  18. * This allows any one NUMA architecture to be compiled
  19. * for, and still fall back to the flat function if it
  20. * fails.
  21. */
  22. static inline void get_memcfg_numa(void)
  23. {
  24. #ifdef CONFIG_X86_NUMAQ
  25. if (get_memcfg_numaq())
  26. return;
  27. #elif defined(CONFIG_ACPI_SRAT)
  28. if (get_memcfg_from_srat())
  29. return;
  30. #endif
  31. get_memcfg_numa_flat();
  32. }
  33. extern int early_pfn_to_nid(unsigned long pfn);
  34. extern void numa_kva_reserve(void);
  35. #else /* !CONFIG_NUMA */
  36. #define get_memcfg_numa get_memcfg_numa_flat
  37. #define get_zholes_size(n) (0)
  38. static inline void numa_kva_reserve(void)
  39. {
  40. }
  41. #endif /* CONFIG_NUMA */
  42. #ifdef CONFIG_DISCONTIGMEM
  43. /*
  44. * generic node memory support, the following assumptions apply:
  45. *
  46. * 1) memory comes in 256Mb contigious chunks which are either present or not
  47. * 2) we will not have more than 64Gb in total
  48. *
  49. * for now assume that 64Gb is max amount of RAM for whole system
  50. * 64Gb / 4096bytes/page = 16777216 pages
  51. */
  52. #define MAX_NR_PAGES 16777216
  53. #define MAX_ELEMENTS 256
  54. #define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS)
  55. extern s8 physnode_map[];
  56. static inline int pfn_to_nid(unsigned long pfn)
  57. {
  58. #ifdef CONFIG_NUMA
  59. return((int) physnode_map[(pfn) / PAGES_PER_ELEMENT]);
  60. #else
  61. return 0;
  62. #endif
  63. }
  64. /*
  65. * Following are macros that each numa implmentation must define.
  66. */
  67. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  68. #define node_end_pfn(nid) \
  69. ({ \
  70. pg_data_t *__pgdat = NODE_DATA(nid); \
  71. __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
  72. })
  73. /* XXX: FIXME -- wli */
  74. #define kern_addr_valid(kaddr) (0)
  75. #ifdef CONFIG_X86_NUMAQ /* we have contiguous memory on NUMA-Q */
  76. #define pfn_valid(pfn) ((pfn) < num_physpages)
  77. #else
  78. static inline int pfn_valid(int pfn)
  79. {
  80. int nid = pfn_to_nid(pfn);
  81. if (nid >= 0)
  82. return (pfn < node_end_pfn(nid));
  83. return 0;
  84. }
  85. #endif /* CONFIG_X86_NUMAQ */
  86. #endif /* CONFIG_DISCONTIGMEM */
  87. #ifdef CONFIG_NEED_MULTIPLE_NODES
  88. /*
  89. * Following are macros that are specific to this numa platform.
  90. */
  91. #define reserve_bootmem(addr, size) \
  92. reserve_bootmem_node(NODE_DATA(0), (addr), (size))
  93. #define alloc_bootmem(x) \
  94. __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
  95. #define alloc_bootmem_low(x) \
  96. __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
  97. #define alloc_bootmem_pages(x) \
  98. __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  99. #define alloc_bootmem_low_pages(x) \
  100. __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
  101. #define alloc_bootmem_node(pgdat, x) \
  102. ({ \
  103. struct pglist_data __maybe_unused \
  104. *__alloc_bootmem_node__pgdat = (pgdat); \
  105. __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
  106. __pa(MAX_DMA_ADDRESS)); \
  107. })
  108. #define alloc_bootmem_pages_node(pgdat, x) \
  109. ({ \
  110. struct pglist_data __maybe_unused \
  111. *__alloc_bootmem_node__pgdat = (pgdat); \
  112. __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \
  113. __pa(MAX_DMA_ADDRESS)) \
  114. })
  115. #define alloc_bootmem_low_pages_node(pgdat, x) \
  116. ({ \
  117. struct pglist_data __maybe_unused \
  118. *__alloc_bootmem_node__pgdat = (pgdat); \
  119. __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0); \
  120. })
  121. #endif /* CONFIG_NEED_MULTIPLE_NODES */
  122. #endif /* _ASM_MMZONE_H_ */