bootmem.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. #ifdef CONFIG_CRASH_DUMP
  18. extern unsigned long saved_max_pfn;
  19. #endif
  20. /*
  21. * node_bootmem_map is a map pointer - the bits represent all physical
  22. * memory pages (including holes) on the node.
  23. */
  24. typedef struct bootmem_data {
  25. unsigned long node_min_pfn;
  26. unsigned long node_low_pfn;
  27. void *node_bootmem_map;
  28. unsigned long last_end_off;
  29. unsigned long hint_idx;
  30. struct list_head list;
  31. } bootmem_data_t;
  32. extern bootmem_data_t bootmem_node_data[];
  33. extern unsigned long bootmem_bootmap_pages(unsigned long);
  34. extern unsigned long init_bootmem_node(pg_data_t *pgdat,
  35. unsigned long freepfn,
  36. unsigned long startpfn,
  37. unsigned long endpfn);
  38. extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
  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 addr, unsigned long size);
  45. /*
  46. * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
  47. * the architecture-specific code should honor this).
  48. *
  49. * If flags is 0, then the return value is always 0 (success). If
  50. * flags contains BOOTMEM_EXCLUSIVE, then -EBUSY is returned if the
  51. * memory already was reserved.
  52. */
  53. #define BOOTMEM_DEFAULT 0
  54. #define BOOTMEM_EXCLUSIVE (1<<0)
  55. extern int reserve_bootmem(unsigned long addr,
  56. unsigned long size,
  57. int flags);
  58. extern int reserve_bootmem_node(pg_data_t *pgdat,
  59. unsigned long physaddr,
  60. unsigned long size,
  61. int flags);
  62. extern void *__alloc_bootmem(unsigned long size,
  63. unsigned long align,
  64. unsigned long goal);
  65. extern void *__alloc_bootmem_nopanic(unsigned long size,
  66. unsigned long align,
  67. unsigned long goal);
  68. extern void *__alloc_bootmem_node(pg_data_t *pgdat,
  69. unsigned long size,
  70. unsigned long align,
  71. unsigned long goal);
  72. extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  73. unsigned long size,
  74. unsigned long align,
  75. unsigned long goal);
  76. extern void *__alloc_bootmem_low(unsigned long size,
  77. unsigned long align,
  78. unsigned long goal);
  79. extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
  80. unsigned long size,
  81. unsigned long align,
  82. unsigned long goal);
  83. #define alloc_bootmem(x) \
  84. __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
  85. #define alloc_bootmem_nopanic(x) \
  86. __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
  87. #define alloc_bootmem_pages(x) \
  88. __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  89. #define alloc_bootmem_pages_nopanic(x) \
  90. __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  91. #define alloc_bootmem_node(pgdat, x) \
  92. __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
  93. #define alloc_bootmem_pages_node(pgdat, x) \
  94. __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  95. #define alloc_bootmem_pages_node_nopanic(pgdat, x) \
  96. __alloc_bootmem_node_nopanic(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  97. #define alloc_bootmem_low(x) \
  98. __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
  99. #define alloc_bootmem_low_pages(x) \
  100. __alloc_bootmem_low(x, PAGE_SIZE, 0)
  101. #define alloc_bootmem_low_pages_node(pgdat, x) \
  102. __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
  103. extern int reserve_bootmem_generic(unsigned long addr, unsigned long size,
  104. int flags);
  105. extern void *alloc_bootmem_section(unsigned long size,
  106. unsigned long section_nr);
  107. #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
  108. extern void *alloc_remap(int nid, unsigned long size);
  109. #else
  110. static inline void *alloc_remap(int nid, unsigned long size)
  111. {
  112. return NULL;
  113. }
  114. #endif /* CONFIG_HAVE_ARCH_ALLOC_REMAP */
  115. extern unsigned long __meminitdata nr_kernel_pages;
  116. extern unsigned long __meminitdata nr_all_pages;
  117. extern void *alloc_large_system_hash(const char *tablename,
  118. unsigned long bucketsize,
  119. unsigned long numentries,
  120. int scale,
  121. int flags,
  122. unsigned int *_hash_shift,
  123. unsigned int *_hash_mask,
  124. unsigned long limit);
  125. #define HASH_EARLY 0x00000001 /* Allocating during early boot? */
  126. /* Only NUMA needs hash distribution.
  127. * IA64 and x86_64 have sufficient vmalloc space.
  128. */
  129. #if defined(CONFIG_NUMA) && (defined(CONFIG_IA64) || defined(CONFIG_X86_64))
  130. #define HASHDIST_DEFAULT 1
  131. #else
  132. #define HASHDIST_DEFAULT 0
  133. #endif
  134. extern int hashdist; /* Distribute hashes across NUMA nodes? */
  135. #endif /* _LINUX_BOOTMEM_H */