blob: 7aeec0cb4c27f89841f9508414d9295bbfc7f1a2 [file] [log] [blame]
Yinghai Lu95f72d12010-07-12 14:36:09 +10001#ifndef _LINUX_MEMBLOCK_H
2#define _LINUX_MEMBLOCK_H
3#ifdef __KERNEL__
4
Yinghai Luf0b37fad2010-07-28 15:28:21 +10005#ifdef CONFIG_HAVE_MEMBLOCK
Yinghai Lu95f72d12010-07-12 14:36:09 +10006/*
7 * Logical memory blocks.
8 *
9 * Copyright (C) 2001 Peter Bergner, IBM Corp.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16
17#include <linux/init.h>
18#include <linux/mm.h>
19
Yinghai Lu37d8d4b2010-07-28 15:20:58 +100020#define INIT_MEMBLOCK_REGIONS 128
Philipp Hachtmann70210ed2014-01-29 18:16:01 +010021#define INIT_PHYSMEM_REGIONS 4
Yinghai Lu95f72d12010-07-12 14:36:09 +100022
Tang Chen66b16ed2014-01-21 15:49:23 -080023/* Definition of memblock flags. */
Tony Luckfc6daaf2015-06-24 16:58:09 -070024enum {
25 MEMBLOCK_NONE = 0x0, /* No special request */
26 MEMBLOCK_HOTPLUG = 0x1, /* hotpluggable region */
27};
Tang Chen66b16ed2014-01-21 15:49:23 -080028
Benjamin Herrenschmidte3239ff2010-08-04 14:06:41 +100029struct memblock_region {
Benjamin Herrenschmidt2898cc42010-08-04 13:34:42 +100030 phys_addr_t base;
31 phys_addr_t size;
Tang Chen66a20752014-01-21 15:49:20 -080032 unsigned long flags;
Tejun Heo7c0caeb2011-07-14 11:43:42 +020033#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
34 int nid;
35#endif
Yinghai Lu95f72d12010-07-12 14:36:09 +100036};
37
Benjamin Herrenschmidte3239ff2010-08-04 14:06:41 +100038struct memblock_type {
Benjamin Herrenschmidtbf23c512010-07-06 15:39:06 -070039 unsigned long cnt; /* number of regions */
40 unsigned long max; /* size of the allocated array */
Tejun Heo1440c4e2011-12-08 10:22:08 -080041 phys_addr_t total_size; /* size of all regions */
Benjamin Herrenschmidtbf23c512010-07-06 15:39:06 -070042 struct memblock_region *regions;
Yinghai Lu95f72d12010-07-12 14:36:09 +100043};
44
45struct memblock {
Tang Chen79442ed2013-11-12 15:07:59 -080046 bool bottom_up; /* is bottom up direction? */
Benjamin Herrenschmidt2898cc42010-08-04 13:34:42 +100047 phys_addr_t current_limit;
Benjamin Herrenschmidte3239ff2010-08-04 14:06:41 +100048 struct memblock_type memory;
49 struct memblock_type reserved;
Philipp Hachtmann70210ed2014-01-29 18:16:01 +010050#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
51 struct memblock_type physmem;
52#endif
Yinghai Lu95f72d12010-07-12 14:36:09 +100053};
54
55extern struct memblock memblock;
Yinghai Lu5e63cf42010-07-28 15:07:21 +100056extern int memblock_debug;
Tang Chen55ac5902014-01-21 15:49:35 -080057#ifdef CONFIG_MOVABLE_NODE
58/* If movable_node boot option specified */
59extern bool movable_node_enabled;
60#endif /* CONFIG_MOVABLE_NODE */
Yinghai Lu5e63cf42010-07-28 15:07:21 +100061
62#define memblock_dbg(fmt, ...) \
63 if (memblock_debug) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
Yinghai Lu95f72d12010-07-12 14:36:09 +100064
Grygorii Strashko87029ee2014-01-21 15:50:14 -080065phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
66 phys_addr_t start, phys_addr_t end,
Tony Luckfc6daaf2015-06-24 16:58:09 -070067 int nid, ulong flags);
Tejun Heofc769a82011-07-12 09:58:10 +020068phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
69 phys_addr_t size, phys_addr_t align);
Yinghai Lu29f67382012-07-11 14:02:56 -070070phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
Philipp Hachtmann5e270e22014-01-23 15:53:11 -080071phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
Tejun Heo1aadc052011-12-08 10:22:08 -080072void memblock_allow_resize(void);
Tejun Heo7fb0bc32011-12-08 10:22:08 -080073int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
Tejun Heo581adcb2011-12-08 10:22:06 -080074int memblock_add(phys_addr_t base, phys_addr_t size);
75int memblock_remove(phys_addr_t base, phys_addr_t size);
76int memblock_free(phys_addr_t base, phys_addr_t size);
77int memblock_reserve(phys_addr_t base, phys_addr_t size);
Yinghai Lu6ede1fd2012-10-22 16:35:18 -070078void memblock_trim_memory(phys_addr_t align);
Tang Chen66b16ed2014-01-21 15:49:23 -080079int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size);
80int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size);
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +010081
82/* Low level functions */
83int memblock_add_range(struct memblock_type *type,
84 phys_addr_t base, phys_addr_t size,
85 int nid, unsigned long flags);
86
87int memblock_remove_range(struct memblock_type *type,
88 phys_addr_t base,
89 phys_addr_t size);
90
Tony Luckfc6daaf2015-06-24 16:58:09 -070091void __next_mem_range(u64 *idx, int nid, ulong flags,
92 struct memblock_type *type_a,
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +010093 struct memblock_type *type_b, phys_addr_t *out_start,
94 phys_addr_t *out_end, int *out_nid);
95
Tony Luckfc6daaf2015-06-24 16:58:09 -070096void __next_mem_range_rev(u64 *idx, int nid, ulong flags,
97 struct memblock_type *type_a,
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +010098 struct memblock_type *type_b, phys_addr_t *out_start,
99 phys_addr_t *out_end, int *out_nid);
100
101/**
102 * for_each_mem_range - iterate through memblock areas from type_a and not
103 * included in type_b. Or just type_a if type_b is NULL.
104 * @i: u64 used as loop variable
105 * @type_a: ptr to memblock_type to iterate
106 * @type_b: ptr to memblock_type which excludes from the iteration
107 * @nid: node selector, %NUMA_NO_NODE for all nodes
Tony Luckfc6daaf2015-06-24 16:58:09 -0700108 * @flags: pick from blocks based on memory attributes
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100109 * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
110 * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
111 * @p_nid: ptr to int for nid of the range, can be %NULL
112 */
Tony Luckfc6daaf2015-06-24 16:58:09 -0700113#define for_each_mem_range(i, type_a, type_b, nid, flags, \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100114 p_start, p_end, p_nid) \
Tony Luckfc6daaf2015-06-24 16:58:09 -0700115 for (i = 0, __next_mem_range(&i, nid, flags, type_a, type_b, \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100116 p_start, p_end, p_nid); \
117 i != (u64)ULLONG_MAX; \
Tony Luckfc6daaf2015-06-24 16:58:09 -0700118 __next_mem_range(&i, nid, flags, type_a, type_b, \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100119 p_start, p_end, p_nid))
120
121/**
122 * for_each_mem_range_rev - reverse iterate through memblock areas from
123 * type_a and not included in type_b. Or just type_a if type_b is NULL.
124 * @i: u64 used as loop variable
125 * @type_a: ptr to memblock_type to iterate
126 * @type_b: ptr to memblock_type which excludes from the iteration
127 * @nid: node selector, %NUMA_NO_NODE for all nodes
Tony Luckfc6daaf2015-06-24 16:58:09 -0700128 * @flags: pick from blocks based on memory attributes
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100129 * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
130 * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
131 * @p_nid: ptr to int for nid of the range, can be %NULL
132 */
Tony Luckfc6daaf2015-06-24 16:58:09 -0700133#define for_each_mem_range_rev(i, type_a, type_b, nid, flags, \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100134 p_start, p_end, p_nid) \
135 for (i = (u64)ULLONG_MAX, \
Tony Luckfc6daaf2015-06-24 16:58:09 -0700136 __next_mem_range_rev(&i, nid, flags, type_a, type_b,\
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100137 p_start, p_end, p_nid); \
138 i != (u64)ULLONG_MAX; \
Tony Luckfc6daaf2015-06-24 16:58:09 -0700139 __next_mem_range_rev(&i, nid, flags, type_a, type_b, \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100140 p_start, p_end, p_nid))
141
Tang Chen55ac5902014-01-21 15:49:35 -0800142#ifdef CONFIG_MOVABLE_NODE
143static inline bool memblock_is_hotpluggable(struct memblock_region *m)
144{
145 return m->flags & MEMBLOCK_HOTPLUG;
146}
147
148static inline bool movable_node_is_enabled(void)
149{
150 return movable_node_enabled;
151}
152#else
153static inline bool memblock_is_hotpluggable(struct memblock_region *m)
154{
155 return false;
156}
157static inline bool movable_node_is_enabled(void)
158{
159 return false;
160}
161#endif
Benjamin Herrenschmidte63075a2010-07-06 15:39:01 -0700162
Tejun Heo0ee332c2011-12-08 10:22:09 -0800163#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
Yinghai Lue76b63f2013-09-11 14:22:17 -0700164int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn,
165 unsigned long *end_pfn);
Tejun Heo0ee332c2011-12-08 10:22:09 -0800166void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
167 unsigned long *out_end_pfn, int *out_nid);
168
169/**
170 * for_each_mem_pfn_range - early memory pfn range iterator
171 * @i: an integer used as loop variable
172 * @nid: node selector, %MAX_NUMNODES for all nodes
173 * @p_start: ptr to ulong for start pfn of the range, can be %NULL
174 * @p_end: ptr to ulong for end pfn of the range, can be %NULL
175 * @p_nid: ptr to int for nid of the range, can be %NULL
176 *
Wanpeng Lif2d52fe2012-10-08 16:32:24 -0700177 * Walks over configured memory ranges.
Tejun Heo0ee332c2011-12-08 10:22:09 -0800178 */
179#define for_each_mem_pfn_range(i, nid, p_start, p_end, p_nid) \
180 for (i = -1, __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid); \
181 i >= 0; __next_mem_pfn_range(&i, nid, p_start, p_end, p_nid))
182#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
183
Tejun Heo35fd0802011-07-12 11:15:59 +0200184/**
185 * for_each_free_mem_range - iterate through free memblock areas
186 * @i: u64 used as loop variable
Grygorii Strashkob1154232014-01-21 15:50:16 -0800187 * @nid: node selector, %NUMA_NO_NODE for all nodes
Tejun Heo35fd0802011-07-12 11:15:59 +0200188 * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
189 * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
190 * @p_nid: ptr to int for nid of the range, can be %NULL
Tony Luckfc6daaf2015-06-24 16:58:09 -0700191 * @flags: pick from blocks based on memory attributes
Tejun Heo35fd0802011-07-12 11:15:59 +0200192 *
193 * Walks over free (memory && !reserved) areas of memblock. Available as
194 * soon as memblock is initialized.
195 */
Tony Luckfc6daaf2015-06-24 16:58:09 -0700196#define for_each_free_mem_range(i, nid, flags, p_start, p_end, p_nid) \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100197 for_each_mem_range(i, &memblock.memory, &memblock.reserved, \
Tony Luckfc6daaf2015-06-24 16:58:09 -0700198 nid, flags, p_start, p_end, p_nid)
Tejun Heo7bd0b0f2011-12-08 10:22:09 -0800199
200/**
201 * for_each_free_mem_range_reverse - rev-iterate through free memblock areas
202 * @i: u64 used as loop variable
Grygorii Strashkob1154232014-01-21 15:50:16 -0800203 * @nid: node selector, %NUMA_NO_NODE for all nodes
Tejun Heo7bd0b0f2011-12-08 10:22:09 -0800204 * @p_start: ptr to phys_addr_t for start address of the range, can be %NULL
205 * @p_end: ptr to phys_addr_t for end address of the range, can be %NULL
206 * @p_nid: ptr to int for nid of the range, can be %NULL
Tony Luckfc6daaf2015-06-24 16:58:09 -0700207 * @flags: pick from blocks based on memory attributes
Tejun Heo7bd0b0f2011-12-08 10:22:09 -0800208 *
209 * Walks over free (memory && !reserved) areas of memblock in reverse
210 * order. Available as soon as memblock is initialized.
211 */
Tony Luckfc6daaf2015-06-24 16:58:09 -0700212#define for_each_free_mem_range_reverse(i, nid, flags, p_start, p_end, \
213 p_nid) \
Philipp Hachtmannf1af9d32014-01-29 18:16:01 +0100214 for_each_mem_range_rev(i, &memblock.memory, &memblock.reserved, \
Tony Luckfc6daaf2015-06-24 16:58:09 -0700215 nid, flags, p_start, p_end, p_nid)
Tejun Heo7bd0b0f2011-12-08 10:22:09 -0800216
Tang Chen66b16ed2014-01-21 15:49:23 -0800217static inline void memblock_set_region_flags(struct memblock_region *r,
218 unsigned long flags)
219{
220 r->flags |= flags;
221}
222
223static inline void memblock_clear_region_flags(struct memblock_region *r,
224 unsigned long flags)
225{
226 r->flags &= ~flags;
227}
228
Tejun Heo7c0caeb2011-07-14 11:43:42 +0200229#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
Tang Chene7e8de52014-01-21 15:49:26 -0800230int memblock_set_node(phys_addr_t base, phys_addr_t size,
231 struct memblock_type *type, int nid);
Tejun Heo7c0caeb2011-07-14 11:43:42 +0200232
233static inline void memblock_set_region_node(struct memblock_region *r, int nid)
234{
235 r->nid = nid;
236}
237
238static inline int memblock_get_region_node(const struct memblock_region *r)
239{
240 return r->nid;
241}
242#else
243static inline void memblock_set_region_node(struct memblock_region *r, int nid)
244{
245}
246
247static inline int memblock_get_region_node(const struct memblock_region *r)
248{
249 return 0;
250}
251#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
252
Tejun Heo581adcb2011-12-08 10:22:06 -0800253phys_addr_t memblock_alloc_nid(phys_addr_t size, phys_addr_t align, int nid);
254phys_addr_t memblock_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid);
Benjamin Herrenschmidt9d1e2492010-07-06 15:39:17 -0700255
Tejun Heo581adcb2011-12-08 10:22:06 -0800256phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align);
Benjamin Herrenschmidte63075a2010-07-06 15:39:01 -0700257
Tang Chen79442ed2013-11-12 15:07:59 -0800258#ifdef CONFIG_MOVABLE_NODE
259/*
260 * Set the allocation direction to bottom-up or top-down.
261 */
Fabian Frederick2cfb3662014-08-06 16:05:03 -0700262static inline void __init memblock_set_bottom_up(bool enable)
Tang Chen79442ed2013-11-12 15:07:59 -0800263{
264 memblock.bottom_up = enable;
265}
266
267/*
268 * Check if the allocation direction is bottom-up or not.
269 * if this is true, that said, memblock will allocate memory
270 * in bottom-up direction.
271 */
272static inline bool memblock_bottom_up(void)
273{
274 return memblock.bottom_up;
275}
276#else
Fabian Frederick2cfb3662014-08-06 16:05:03 -0700277static inline void __init memblock_set_bottom_up(bool enable) {}
Tang Chen79442ed2013-11-12 15:07:59 -0800278static inline bool memblock_bottom_up(void) { return false; }
279#endif
280
Benjamin Herrenschmidte63075a2010-07-06 15:39:01 -0700281/* Flags for memblock_alloc_base() amd __memblock_alloc_base() */
Benjamin Herrenschmidt2898cc42010-08-04 13:34:42 +1000282#define MEMBLOCK_ALLOC_ANYWHERE (~(phys_addr_t)0)
Benjamin Herrenschmidte63075a2010-07-06 15:39:01 -0700283#define MEMBLOCK_ALLOC_ACCESSIBLE 0
284
Akinobu Mita2bfc2862014-06-04 16:06:53 -0700285phys_addr_t __init memblock_alloc_range(phys_addr_t size, phys_addr_t align,
Tony Luckfc6daaf2015-06-24 16:58:09 -0700286 phys_addr_t start, phys_addr_t end,
287 ulong flags);
Tejun Heo581adcb2011-12-08 10:22:06 -0800288phys_addr_t memblock_alloc_base(phys_addr_t size, phys_addr_t align,
289 phys_addr_t max_addr);
290phys_addr_t __memblock_alloc_base(phys_addr_t size, phys_addr_t align,
291 phys_addr_t max_addr);
292phys_addr_t memblock_phys_mem_size(void);
Yinghai Lu595ad9a2013-01-24 12:20:09 -0800293phys_addr_t memblock_mem_size(unsigned long limit_pfn);
Tejun Heo581adcb2011-12-08 10:22:06 -0800294phys_addr_t memblock_start_of_DRAM(void);
295phys_addr_t memblock_end_of_DRAM(void);
296void memblock_enforce_memory_limit(phys_addr_t memory_limit);
297int memblock_is_memory(phys_addr_t addr);
298int memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
299int memblock_is_reserved(phys_addr_t addr);
300int memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
Yinghai Lu95f72d12010-07-12 14:36:09 +1000301
Tejun Heo4ff7b822011-12-08 10:22:06 -0800302extern void __memblock_dump_all(void);
303
304static inline void memblock_dump_all(void)
305{
306 if (memblock_debug)
307 __memblock_dump_all();
308}
Yinghai Lu95f72d12010-07-12 14:36:09 +1000309
Benjamin Herrenschmidte63075a2010-07-06 15:39:01 -0700310/**
311 * memblock_set_current_limit - Set the current allocation limit to allow
312 * limiting allocations to what is currently
313 * accessible during boot
314 * @limit: New limit value (physical address)
315 */
Tejun Heo581adcb2011-12-08 10:22:06 -0800316void memblock_set_current_limit(phys_addr_t limit);
Benjamin Herrenschmidte63075a2010-07-06 15:39:01 -0700317
Benjamin Herrenschmidt35a1f0b2010-07-06 15:38:58 -0700318
Laura Abbottfec51012014-02-27 01:23:43 +0100319phys_addr_t memblock_get_current_limit(void);
320
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000321/*
322 * pfn conversion functions
323 *
324 * While the memory MEMBLOCKs should always be page aligned, the reserved
325 * MEMBLOCKs may not be. This accessor attempt to provide a very clear
326 * idea of what they return for such non aligned MEMBLOCKs.
327 */
328
329/**
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700330 * memblock_region_memory_base_pfn - Return the lowest pfn intersecting with the memory region
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000331 * @reg: memblock_region structure
332 */
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700333static inline unsigned long memblock_region_memory_base_pfn(const struct memblock_region *reg)
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000334{
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700335 return PFN_UP(reg->base);
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000336}
337
338/**
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700339 * memblock_region_memory_end_pfn - Return the end_pfn this region
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000340 * @reg: memblock_region structure
341 */
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700342static inline unsigned long memblock_region_memory_end_pfn(const struct memblock_region *reg)
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000343{
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700344 return PFN_DOWN(reg->base + reg->size);
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000345}
346
347/**
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700348 * memblock_region_reserved_base_pfn - Return the lowest pfn intersecting with the reserved region
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000349 * @reg: memblock_region structure
350 */
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700351static inline unsigned long memblock_region_reserved_base_pfn(const struct memblock_region *reg)
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000352{
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700353 return PFN_DOWN(reg->base);
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000354}
355
356/**
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700357 * memblock_region_reserved_end_pfn - Return the end_pfn this region
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000358 * @reg: memblock_region structure
359 */
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700360static inline unsigned long memblock_region_reserved_end_pfn(const struct memblock_region *reg)
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000361{
Yinghai Luc7fc2de2010-10-12 14:07:09 -0700362 return PFN_UP(reg->base + reg->size);
Benjamin Herrenschmidt5b385f22010-08-04 13:40:38 +1000363}
364
365#define for_each_memblock(memblock_type, region) \
366 for (region = memblock.memblock_type.regions; \
367 region < (memblock.memblock_type.regions + memblock.memblock_type.cnt); \
368 region++)
369
370
Tejun Heoc378ddd2011-07-14 11:46:03 +0200371#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
Tejun Heo67e24bc2011-07-14 11:42:03 +0200372#define __init_memblock __meminit
373#define __initdata_memblock __meminitdata
Yinghai Lu10d06432010-07-28 15:43:02 +1000374#else
375#define __init_memblock
376#define __initdata_memblock
377#endif
378
Vladimir Murzin4a207992015-04-14 15:48:27 -0700379#ifdef CONFIG_MEMTEST
Vladimir Murzin7f70bae2015-04-14 15:48:30 -0700380extern void early_memtest(phys_addr_t start, phys_addr_t end);
Vladimir Murzin4a207992015-04-14 15:48:27 -0700381#else
Vladimir Murzin7f70bae2015-04-14 15:48:30 -0700382static inline void early_memtest(phys_addr_t start, phys_addr_t end)
Vladimir Murzin4a207992015-04-14 15:48:27 -0700383{
384}
385#endif
386
Yinghai Lu95dde502011-05-24 17:13:19 -0700387#else
388static inline phys_addr_t memblock_alloc(phys_addr_t size, phys_addr_t align)
389{
Tejun Heo1f5026a2011-07-12 09:58:09 +0200390 return 0;
Yinghai Lu95dde502011-05-24 17:13:19 -0700391}
392
Yinghai Luf0b37fad2010-07-28 15:28:21 +1000393#endif /* CONFIG_HAVE_MEMBLOCK */
394
Yinghai Lu95f72d12010-07-12 14:36:09 +1000395#endif /* __KERNEL__ */
396
397#endif /* _LINUX_MEMBLOCK_H */