1 #ifndef _LINUX_MEMBLOCK_H
2 #define _LINUX_MEMBLOCK_H
5 #ifdef CONFIG_HAVE_MEMBLOCK
20 #define INIT_MEMBLOCK_REGIONS 128
22 struct memblock_region {
25 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
30 struct memblock_type {
34 struct memblock_region *regions;
39 struct memblock_type
memory;
43 extern struct memblock memblock;
44 extern int memblock_debug;
46 #define memblock_dbg(fmt, ...) \
47 if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
62 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
63 void __next_mem_pfn_range(
int *
idx,
int nid,
unsigned long *out_start_pfn,
64 unsigned long *out_end_pfn,
int *out_nid);
76 #define for_each_mem_pfn_range(i, nid, p_start, p_end, p_nid) \
77 for (i = -1, __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid); \
78 i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid))
95 #define for_each_free_mem_range(i, nid, p_start, p_end, p_nid) \
97 __next_free_mem_range(&i, nid, p_start, p_end, p_nid); \
98 i != (u64)ULLONG_MAX; \
99 __next_free_mem_range(&i, nid, p_start, p_end, p_nid))
115 #define for_each_free_mem_range_reverse(i, nid, p_start, p_end, p_nid) \
116 for (i = (u64)ULLONG_MAX, \
117 __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid); \
118 i != (u64)ULLONG_MAX; \
119 __next_free_mem_range_rev(&i, nid, p_start, p_end, p_nid))
121 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
124 static inline void memblock_set_region_node(
struct memblock_region *
r,
int nid)
129 static inline int memblock_get_region_node(
const struct memblock_region *
r)
134 static inline void memblock_set_region_node(
struct memblock_region *
r,
int nid)
138 static inline int memblock_get_region_node(
const struct memblock_region *
r)
150 #define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0)
151 #define MEMBLOCK_ALLOC_ACCESSIBLE 0
168 static inline void memblock_dump_all(
void)
195 static inline unsigned long memblock_region_memory_base_pfn(
const struct memblock_region *
reg)
204 static inline unsigned long memblock_region_memory_end_pfn(
const struct memblock_region *
reg)
206 return PFN_DOWN(reg->base + reg->size);
213 static inline unsigned long memblock_region_reserved_base_pfn(
const struct memblock_region *
reg)
222 static inline unsigned long memblock_region_reserved_end_pfn(
const struct memblock_region *
reg)
224 return PFN_UP(reg->base + reg->size);
227 #define for_each_memblock(memblock_type, region) \
228 for (region = memblock.memblock_type.regions; \
229 region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
233 #ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
234 #define __init_memblock __meminit
235 #define __initdata_memblock __meminitdata
237 #define __init_memblock
238 #define __initdata_memblock