bootmem.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_boot_start;
  26. unsigned long node_low_pfn;
  27. void *node_bootmem_map;
  28. unsigned long last_offset;
  29. unsigned long last_pos;
  30. unsigned long last_success; /* Previous allocation point. To speed
  31. * up searching */
  32. struct list_head list;
  33. } bootmem_data_t;
  34. extern unsigned long bootmem_bootmap_pages(unsigned long);
  35. extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
  36. extern void free_bootmem(unsigned long addr, unsigned long size);
  37. extern void *__alloc_bootmem(unsigned long size,
  38. unsigned long align,
  39. unsigned long goal);
  40. extern void *__alloc_bootmem_nopanic(unsigned long size,
  41. unsigned long align,
  42. unsigned long goal);
  43. extern void *__alloc_bootmem_low(unsigned long size,
  44. unsigned long align,
  45. unsigned long goal);
  46. extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
  47. unsigned long size,
  48. unsigned long align,
  49. unsigned long goal);
  50. extern void *__alloc_bootmem_core(struct bootmem_data *bdata,
  51. unsigned long size,
  52. unsigned long align,
  53. unsigned long goal,
  54. unsigned long limit);
  55. extern void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size);
  56. #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
  57. extern void reserve_bootmem(unsigned long addr, unsigned long size);
  58. #define alloc_bootmem(x) \
  59. __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
  60. #define alloc_bootmem_low(x) \
  61. __alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
  62. #define alloc_bootmem_pages(x) \
  63. __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  64. #define alloc_bootmem_low_pages(x) \
  65. __alloc_bootmem_low(x, PAGE_SIZE, 0)
  66. #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
  67. extern unsigned long free_all_bootmem(void);
  68. extern unsigned long free_all_bootmem_node(pg_data_t *pgdat);
  69. extern void *__alloc_bootmem_node(pg_data_t *pgdat,
  70. unsigned long size,
  71. unsigned long align,
  72. unsigned long goal);
  73. extern unsigned long init_bootmem_node(pg_data_t *pgdat,
  74. unsigned long freepfn,
  75. unsigned long startpfn,
  76. unsigned long endpfn);
  77. extern void reserve_bootmem_node(pg_data_t *pgdat,
  78. unsigned long physaddr,
  79. unsigned long size);
  80. extern void free_bootmem_node(pg_data_t *pgdat,
  81. unsigned long addr,
  82. unsigned long size);
  83. #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
  84. #define alloc_bootmem_node(pgdat, x) \
  85. __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
  86. #define alloc_bootmem_pages_node(pgdat, x) \
  87. __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
  88. #define alloc_bootmem_low_pages_node(pgdat, x) \
  89. __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
  90. #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
  91. #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
  92. extern void *alloc_remap(int nid, unsigned long size);
  93. #else
  94. static inline void *alloc_remap(int nid, unsigned long size)
  95. {
  96. return NULL;
  97. }
  98. #endif /* CONFIG_HAVE_ARCH_ALLOC_REMAP */
  99. extern unsigned long __meminitdata nr_kernel_pages;
  100. extern unsigned long __meminitdata nr_all_pages;
  101. extern void *alloc_large_system_hash(const char *tablename,
  102. unsigned long bucketsize,
  103. unsigned long numentries,
  104. int scale,
  105. int flags,
  106. unsigned int *_hash_shift,
  107. unsigned int *_hash_mask,
  108. unsigned long limit);
  109. #define HASH_EARLY 0x00000001 /* Allocating during early boot? */
  110. /* Only NUMA needs hash distribution.
  111. * IA64 is known to have sufficient vmalloc space.
  112. */
  113. #if defined(CONFIG_NUMA) && defined(CONFIG_IA64)
  114. #define HASHDIST_DEFAULT 1
  115. #else
  116. #define HASHDIST_DEFAULT 0
  117. #endif
  118. extern int hashdist; /* Distribute hashes across NUMA nodes? */
  119. #endif /* _LINUX_BOOTMEM_H */