bootmem.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Discontiguous memory support, Kanoj Sarcar, SGI, Nov 1999
  3. */
  4. #ifndef _LINUX_BOOTMEM_H
  5. #define _LINUX_BOOTMEM_H
  6. #include <linux/mmzone.h>
  7. #include <asm/dma.h>
  8. /*
  9. * simple boot-time physical memory area allocator.
  10. */
  11. extern unsigned long max_low_pfn;
  12. extern unsigned long min_low_pfn;
  13. /*
  14. * highest page
  15. */
  16. extern unsigned long max_pfn;
  17. #ifndef CONFIG_NO_BOOTMEM
  18. /*
  19. * node_bootmem_map is a map pointer - the bits represent all physical
  20. * memory pages (including holes) on the node.
  21. */
  22. typedef struct bootmem_data {
  23. unsigned long node_min_pfn;
  24. unsigned long node_low_pfn;
  25. void *node_bootmem_map;
  26. unsigned long last_end_off;
  27. unsigned long hint_idx;
  28. struct list_head list;
  29. } bootmem_data_t;
  30. extern bootmem_data_t bootmem_node_data[];
  31. #endif
  32. extern unsigned long bootmem_bootmap_pages(unsigned long);
  33. extern unsigned long init_bootmem_node(pg_data_t *pgdat,
  34. unsigned long freepfn,
  35. unsigned long startpfn,
  36. unsigned long endpfn);
  37. extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
  38. extern unsigned long free_low_memory_core_early(int nodeid);
  39. extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
  40. extern unsigned long free_all_bootmem(void);
  41. extern void free_bootmem_node(pg_data_t *pgdat,
  42. unsigned long addr,
  43. unsigned long size);
  44. extern void free_bootmem(unsigned long physaddr, unsigned long size);
  45. extern void free_bootmem_late(unsigned long physaddr, unsigned long size);
  46. extern void __free_pages_bootmem(struct page *page, unsigned int order);
  47. /*
  48. * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
  49. * the architecture-specific code should honor this).
  50. *
  51. * If flags is 0, then the return value is always 0 (success). If
  52. * flags contains BOOTMEM_EXCLUSIVE, then -EBUSY is returned if the
  53. * memory already was reserved.
  54. */
  55. #define BOOTMEM_DEFAULT 0
  56. #define BOOTMEM_EXCLUSIVE (1<<0)
  57. extern int reserve_bootmem(unsigned long addr,
  58. unsigned long size,
  59. int flags);
  60. extern int reserve_bootmem_node(pg_data_t *pgdat,
  61. unsigned long physaddr,
  62. unsigned long size,
  63. int flags);
  64. extern void *__alloc_bootmem(unsigned long size,
  65. unsigned long align,
  66. unsigned long goal);
  67. extern void *__alloc_bootmem_nopanic(unsigned long size,
  68. unsigned long align,
  69. unsigned long goal);
  70. extern void *__alloc_bootmem_node(pg_data_t *pgdat,
  71. unsigned long size,
  72. unsigned long align,
  73. unsigned long goal);
  74. void *__alloc_bootmem_node_high(pg_data_t *pgdat,
  75. unsigned long size,
  76. unsigned long align,
  77. unsigned long goal);
  78. extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  79. unsigned long size,
  80. unsigned long align,
  81. unsigned long goal);
  82. void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  83. unsigned long size,
  84. unsigned long align,
  85. unsigned long goal,
  86. unsigned long limit);
  87. extern void *__alloc_bootmem_low(unsigned long size,
  88. unsigned long align,
  89. unsigned long goal);
  90. void *__alloc_bootmem_low_nopanic(unsigned long size,
  91. unsigned long align,
  92. unsigned long goal);
  93. extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
  94. unsigned long size,
  95. unsigned long align,
  96. unsigned long goal);
  97. #ifdef CONFIG_NO_BOOTMEM
  98. /* We are using top down, so it is safe to use 0 here */
  99. #define BOOTMEM_LOW_LIMIT 0
  100. #else
  101. #define BOOTMEM_LOW_LIMIT __pa(MAX_DMA_ADDRESS)
  102. #endif
  103. #define alloc_bootmem(x) \
  104. __alloc_bootmem(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
  105. #define alloc_bootmem_align(x, align) \
  106. __alloc_bootmem(x, align, BOOTMEM_LOW_LIMIT)
  107. #define alloc_bootmem_nopanic(x) \
  108. __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
  109. #define alloc_bootmem_pages(x) \
  110. __alloc_bootmem(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
  111. #define alloc_bootmem_pages_nopanic(x) \
  112. __alloc_bootmem_nopanic(x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
  113. #define alloc_bootmem_node(pgdat, x) \
  114. __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
  115. #define alloc_bootmem_node_nopanic(pgdat, x) \
  116. __alloc_bootmem_node_nopanic(pgdat, x, SMP_CACHE_BYTES, BOOTMEM_LOW_LIMIT)
  117. #define alloc_bootmem_pages_node(pgdat, x) \
  118. __alloc_bootmem_node(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
  119. #define alloc_bootmem_pages_node_nopanic(pgdat, x) \
  120. __alloc_bootmem_node_nopanic(pgdat, x, PAGE_SIZE, BOOTMEM_LOW_LIMIT)
  121. #define alloc_bootmem_low(x) \
  122. __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
  123. #define alloc_bootmem_low_pages_nopanic(x) \
  124. __alloc_bootmem_low_nopanic(x, PAGE_SIZE, 0)
  125. #define alloc_bootmem_low_pages(x) \
  126. __alloc_bootmem_low(x, PAGE_SIZE, 0)
  127. #define alloc_bootmem_low_pages_node(pgdat, x) \
  128. __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
  129. #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
  130. extern void *alloc_remap(int nid, unsigned long size);
  131. #else
  132. static inline void *alloc_remap(int nid, unsigned long size)
  133. {
  134. return NULL;
  135. }
  136. #endif /* CONFIG_HAVE_ARCH_ALLOC_REMAP */
  137. extern void *alloc_large_system_hash(const char *tablename,
  138. unsigned long bucketsize,
  139. unsigned long numentries,
  140. int scale,
  141. int flags,
  142. unsigned int *_hash_shift,
  143. unsigned int *_hash_mask,
  144. unsigned long low_limit,
  145. unsigned long high_limit);
  146. #define HASH_EARLY 0x00000001 /* Allocating during early boot? */
  147. #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min
  148. * shift passed via *_hash_shift */
  149. /* Only NUMA needs hash distribution. 64bit NUMA architectures have
  150. * sufficient vmalloc space.
  151. */
  152. #if defined(CONFIG_NUMA) && defined(CONFIG_64BIT)
  153. #define HASHDIST_DEFAULT 1
  154. #else
  155. #define HASHDIST_DEFAULT 0
  156. #endif
  157. extern int hashdist; /* Distribute hashes across NUMA nodes? */
  158. #endif /* _LINUX_BOOTMEM_H */