diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/bootmem.h | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 55d52fb7ac1d..2fae55def608 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #define _LINUX_BOOTMEM_H | 5 | #define _LINUX_BOOTMEM_H |
6 | 6 | ||
7 | #include <linux/mmzone.h> | 7 | #include <linux/mmzone.h> |
8 | #include <linux/mm_types.h> | ||
8 | #include <asm/dma.h> | 9 | #include <asm/dma.h> |
9 | 10 | ||
10 | /* | 11 | /* |
@@ -141,6 +142,157 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat, | |||
141 | #define alloc_bootmem_low_pages_node(pgdat, x) \ | 142 | #define alloc_bootmem_low_pages_node(pgdat, x) \ |
142 | __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) | 143 | __alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0) |
143 | 144 | ||
145 | |||
146 | #if defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) | ||
147 | |||
148 | /* FIXME: use MEMBLOCK_ALLOC_* variants here */ | ||
149 | #define BOOTMEM_ALLOC_ACCESSIBLE 0 | ||
150 | #define BOOTMEM_ALLOC_ANYWHERE (~(phys_addr_t)0) | ||
151 | |||
152 | /* FIXME: Move to memblock.h at a point where we remove nobootmem.c */ | ||
153 | void *memblock_virt_alloc_try_nid_nopanic(phys_addr_t size, | ||
154 | phys_addr_t align, phys_addr_t min_addr, | ||
155 | phys_addr_t max_addr, int nid); | ||
156 | void *memblock_virt_alloc_try_nid(phys_addr_t size, phys_addr_t align, | ||
157 | phys_addr_t min_addr, phys_addr_t max_addr, int nid); | ||
158 | void __memblock_free_early(phys_addr_t base, phys_addr_t size); | ||
159 | void __memblock_free_late(phys_addr_t base, phys_addr_t size); | ||
160 | |||
161 | static inline void * __init memblock_virt_alloc( | ||
162 | phys_addr_t size, phys_addr_t align) | ||
163 | { | ||
164 | return memblock_virt_alloc_try_nid(size, align, BOOTMEM_LOW_LIMIT, | ||
165 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
166 | NUMA_NO_NODE); | ||
167 | } | ||
168 | |||
169 | static inline void * __init memblock_virt_alloc_nopanic( | ||
170 | phys_addr_t size, phys_addr_t align) | ||
171 | { | ||
172 | return memblock_virt_alloc_try_nid_nopanic(size, align, | ||
173 | BOOTMEM_LOW_LIMIT, | ||
174 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
175 | NUMA_NO_NODE); | ||
176 | } | ||
177 | |||
178 | static inline void * __init memblock_virt_alloc_from_nopanic( | ||
179 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | ||
180 | { | ||
181 | return memblock_virt_alloc_try_nid_nopanic(size, align, min_addr, | ||
182 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
183 | NUMA_NO_NODE); | ||
184 | } | ||
185 | |||
186 | static inline void * __init memblock_virt_alloc_node( | ||
187 | phys_addr_t size, int nid) | ||
188 | { | ||
189 | return memblock_virt_alloc_try_nid(size, 0, BOOTMEM_LOW_LIMIT, | ||
190 | BOOTMEM_ALLOC_ACCESSIBLE, nid); | ||
191 | } | ||
192 | |||
193 | static inline void * __init memblock_virt_alloc_node_nopanic( | ||
194 | phys_addr_t size, int nid) | ||
195 | { | ||
196 | return memblock_virt_alloc_try_nid_nopanic(size, 0, BOOTMEM_LOW_LIMIT, | ||
197 | BOOTMEM_ALLOC_ACCESSIBLE, | ||
198 | nid); | ||
199 | } | ||
200 | |||
201 | static inline void __init memblock_free_early( | ||
202 | phys_addr_t base, phys_addr_t size) | ||
203 | { | ||
204 | __memblock_free_early(base, size); | ||
205 | } | ||
206 | |||
207 | static inline void __init memblock_free_early_nid( | ||
208 | phys_addr_t base, phys_addr_t size, int nid) | ||
209 | { | ||
210 | __memblock_free_early(base, size); | ||
211 | } | ||
212 | |||
213 | static inline void __init memblock_free_late( | ||
214 | phys_addr_t base, phys_addr_t size) | ||
215 | { | ||
216 | __memblock_free_late(base, size); | ||
217 | } | ||
218 | |||
219 | #else | ||
220 | |||
221 | #define BOOTMEM_ALLOC_ACCESSIBLE 0 | ||
222 | |||
223 | |||
224 | /* Fall back to all the existing bootmem APIs */ | ||
225 | static inline void * __init memblock_virt_alloc( | ||
226 | phys_addr_t size, phys_addr_t align) | ||
227 | { | ||
228 | if (!align) | ||
229 | align = SMP_CACHE_BYTES; | ||
230 | return __alloc_bootmem(size, align, BOOTMEM_LOW_LIMIT); | ||
231 | } | ||
232 | |||
233 | static inline void * __init memblock_virt_alloc_nopanic( | ||
234 | phys_addr_t size, phys_addr_t align) | ||
235 | { | ||
236 | if (!align) | ||
237 | align = SMP_CACHE_BYTES; | ||
238 | return __alloc_bootmem_nopanic(size, align, BOOTMEM_LOW_LIMIT); | ||
239 | } | ||
240 | |||
241 | static inline void * __init memblock_virt_alloc_from_nopanic( | ||
242 | phys_addr_t size, phys_addr_t align, phys_addr_t min_addr) | ||
243 | { | ||
244 | return __alloc_bootmem_nopanic(size, align, min_addr); | ||
245 | } | ||
246 | |||
247 | static inline void * __init memblock_virt_alloc_node( | ||
248 | phys_addr_t size, int nid) | ||
249 | { | ||
250 | return __alloc_bootmem_node(NODE_DATA(nid), size, SMP_CACHE_BYTES, | ||
251 | BOOTMEM_LOW_LIMIT); | ||
252 | } | ||
253 | |||
254 | static inline void * __init memblock_virt_alloc_node_nopanic( | ||
255 | phys_addr_t size, int nid) | ||
256 | { | ||
257 | return __alloc_bootmem_node_nopanic(NODE_DATA(nid), size, | ||
258 | SMP_CACHE_BYTES, | ||
259 | BOOTMEM_LOW_LIMIT); | ||
260 | } | ||
261 | |||
262 | static inline void * __init memblock_virt_alloc_try_nid(phys_addr_t size, | ||
263 | phys_addr_t align, phys_addr_t min_addr, phys_addr_t max_addr, int nid) | ||
264 | { | ||
265 | return __alloc_bootmem_node_high(NODE_DATA(nid), size, align, | ||
266 | min_addr); | ||
267 | } | ||
268 | |||
269 | static inline void * __init memblock_virt_alloc_try_nid_nopanic( | ||
270 | phys_addr_t size, phys_addr_t align, | ||
271 | phys_addr_t min_addr, phys_addr_t max_addr, int nid) | ||
272 | { | ||
273 | return ___alloc_bootmem_node_nopanic(NODE_DATA(nid), size, align, | ||
274 | min_addr, max_addr); | ||
275 | } | ||
276 | |||
277 | static inline void __init memblock_free_early( | ||
278 | phys_addr_t base, phys_addr_t size) | ||
279 | { | ||
280 | free_bootmem(base, size); | ||
281 | } | ||
282 | |||
283 | static inline void __init memblock_free_early_nid( | ||
284 | phys_addr_t base, phys_addr_t size, int nid) | ||
285 | { | ||
286 | free_bootmem_node(NODE_DATA(nid), base, size); | ||
287 | } | ||
288 | |||
289 | static inline void __init memblock_free_late( | ||
290 | phys_addr_t base, phys_addr_t size) | ||
291 | { | ||
292 | free_bootmem_late(base, size); | ||
293 | } | ||
294 | #endif /* defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) */ | ||
295 | |||
144 | #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP | 296 | #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP |
145 | extern void *alloc_remap(int nid, unsigned long size); | 297 | extern void *alloc_remap(int nid, unsigned long size); |
146 | #else | 298 | #else |