blob: c08c4d942b74519e183d6100b3f0e96f86ef9e39 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kumar Gala6d7bfa82008-02-27 21:51:47 -06002/*
3 * Procedures for maintaining information about logical memory blocks.
4 *
5 * Peter Bergner, IBM Corp. June 2001.
6 * Copyright (C) 2001 Peter Bergner.
Kumar Gala6d7bfa82008-02-27 21:51:47 -06007 */
8
9#include <common.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060010#include <image.h>
Kumar Gala6d7bfa82008-02-27 21:51:47 -060011#include <lmb.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Simon Glass9bc15642020-02-03 07:36:16 -070013#include <malloc.h>
Kumar Gala6d7bfa82008-02-27 21:51:47 -060014
15#define LMB_ALLOC_ANYWHERE 0
16
Tero Kristo97c418b2020-07-20 11:10:45 +030017void lmb_dump_all_force(struct lmb *lmb)
Kumar Gala6d7bfa82008-02-27 21:51:47 -060018{
Kumar Gala6d7bfa82008-02-27 21:51:47 -060019 unsigned long i;
20
Tero Kristo97c418b2020-07-20 11:10:45 +030021 printf("lmb_dump_all:\n");
22 printf(" memory.cnt = 0x%lx\n", lmb->memory.cnt);
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +010023 for (i = 0; i < lmb->memory.cnt; i++) {
Tero Kristo97c418b2020-07-20 11:10:45 +030024 printf(" memory.reg[0x%lx].base = 0x%llx\n", i,
25 (unsigned long long)lmb->memory.region[i].base);
26 printf(" .size = 0x%llx\n",
27 (unsigned long long)lmb->memory.region[i].size);
Kumar Gala6d7bfa82008-02-27 21:51:47 -060028 }
29
Tero Kristo97c418b2020-07-20 11:10:45 +030030 printf("\n reserved.cnt = 0x%lx\n", lmb->reserved.cnt);
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +010031 for (i = 0; i < lmb->reserved.cnt; i++) {
Tero Kristo97c418b2020-07-20 11:10:45 +030032 printf(" reserved.reg[0x%lx].base = 0x%llx\n", i,
33 (unsigned long long)lmb->reserved.region[i].base);
34 printf(" .size = 0x%llx\n",
35 (unsigned long long)lmb->reserved.region[i].size);
Kumar Gala6d7bfa82008-02-27 21:51:47 -060036 }
Tero Kristo97c418b2020-07-20 11:10:45 +030037}
38
39void lmb_dump_all(struct lmb *lmb)
40{
41#ifdef DEBUG
42 lmb_dump_all_force(lmb);
43#endif
Kumar Gala6d7bfa82008-02-27 21:51:47 -060044}
45
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +010046static long lmb_addrs_overlap(phys_addr_t base1, phys_size_t size1,
47 phys_addr_t base2, phys_size_t size2)
Kumar Gala6d7bfa82008-02-27 21:51:47 -060048{
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +010049 const phys_addr_t base1_end = base1 + size1 - 1;
50 const phys_addr_t base2_end = base2 + size2 - 1;
51
52 return ((base1 <= base2_end) && (base2 <= base1_end));
Kumar Gala6d7bfa82008-02-27 21:51:47 -060053}
54
Becky Bruced26d67c2008-06-09 20:37:18 -050055static long lmb_addrs_adjacent(phys_addr_t base1, phys_size_t size1,
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +010056 phys_addr_t base2, phys_size_t size2)
Kumar Gala6d7bfa82008-02-27 21:51:47 -060057{
58 if (base2 == base1 + size1)
59 return 1;
60 else if (base1 == base2 + size2)
61 return -1;
62
63 return 0;
64}
65
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +010066static long lmb_regions_adjacent(struct lmb_region *rgn, unsigned long r1,
67 unsigned long r2)
Kumar Gala6d7bfa82008-02-27 21:51:47 -060068{
Becky Bruced26d67c2008-06-09 20:37:18 -050069 phys_addr_t base1 = rgn->region[r1].base;
70 phys_size_t size1 = rgn->region[r1].size;
71 phys_addr_t base2 = rgn->region[r2].base;
72 phys_size_t size2 = rgn->region[r2].size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -060073
74 return lmb_addrs_adjacent(base1, size1, base2, size2);
75}
76
77static void lmb_remove_region(struct lmb_region *rgn, unsigned long r)
78{
79 unsigned long i;
80
81 for (i = r; i < rgn->cnt - 1; i++) {
82 rgn->region[i].base = rgn->region[i + 1].base;
83 rgn->region[i].size = rgn->region[i + 1].size;
84 }
85 rgn->cnt--;
86}
87
88/* Assumption: base addr of region 1 < base addr of region 2 */
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +010089static void lmb_coalesce_regions(struct lmb_region *rgn, unsigned long r1,
90 unsigned long r2)
Kumar Gala6d7bfa82008-02-27 21:51:47 -060091{
92 rgn->region[r1].size += rgn->region[r2].size;
93 lmb_remove_region(rgn, r2);
94}
95
96void lmb_init(struct lmb *lmb)
97{
Patrick Delaunay71cc9c52021-03-10 10:16:31 +010098#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
Patrick Delaunaycd831af2021-03-10 10:16:28 +010099 lmb->memory.max = CONFIG_LMB_MAX_REGIONS;
100 lmb->reserved.max = CONFIG_LMB_MAX_REGIONS;
Patrick Delaunay71cc9c52021-03-10 10:16:31 +0100101#else
102 lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS;
103 lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS;
104 lmb->memory.region = lmb->memory_regions;
105 lmb->reserved.region = lmb->reserved_regions;
106#endif
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100107 lmb->memory.cnt = 0;
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100108 lmb->reserved.cnt = 0;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600109}
110
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100111static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)
Simon Goldschmidt5b2c6872019-01-14 22:38:19 +0100112{
Simon Goldschmidt5b2c6872019-01-14 22:38:19 +0100113 arch_lmb_reserve(lmb);
114 board_lmb_reserve(lmb);
115
116 if (IMAGE_ENABLE_OF_LIBFDT && fdt_blob)
117 boot_fdt_add_mem_rsv_regions(lmb, fdt_blob);
118}
119
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100120/* Initialize the struct, add memory and call arch/board reserve functions */
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900121void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, void *fdt_blob)
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100122{
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100123 int i;
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100124
125 lmb_init(lmb);
Stefan Roesebbc88462020-08-12 11:55:46 +0200126
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100127 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
128 if (bd->bi_dram[i].size) {
129 lmb_add(lmb, bd->bi_dram[i].start,
130 bd->bi_dram[i].size);
131 }
132 }
Stefan Roesebbc88462020-08-12 11:55:46 +0200133
Simon Goldschmidt8890e7d2019-01-26 22:13:04 +0100134 lmb_reserve_common(lmb, fdt_blob);
135}
136
137/* Initialize the struct, add memory and call arch/board reserve functions */
138void lmb_init_and_reserve_range(struct lmb *lmb, phys_addr_t base,
139 phys_size_t size, void *fdt_blob)
140{
141 lmb_init(lmb);
142 lmb_add(lmb, base, size);
143 lmb_reserve_common(lmb, fdt_blob);
144}
145
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600146/* This routine called with relocation disabled. */
Becky Bruced26d67c2008-06-09 20:37:18 -0500147static long lmb_add_region(struct lmb_region *rgn, phys_addr_t base, phys_size_t size)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600148{
149 unsigned long coalesced = 0;
150 long adjacent, i;
151
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100152 if (rgn->cnt == 0) {
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600153 rgn->region[0].base = base;
154 rgn->region[0].size = size;
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100155 rgn->cnt = 1;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600156 return 0;
157 }
158
159 /* First try and coalesce this LMB with another. */
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100160 for (i = 0; i < rgn->cnt; i++) {
Becky Bruced26d67c2008-06-09 20:37:18 -0500161 phys_addr_t rgnbase = rgn->region[i].base;
162 phys_size_t rgnsize = rgn->region[i].size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600163
164 if ((rgnbase == base) && (rgnsize == size))
165 /* Already have this region, so we're done */
166 return 0;
167
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100168 adjacent = lmb_addrs_adjacent(base, size, rgnbase, rgnsize);
169 if (adjacent > 0) {
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600170 rgn->region[i].base -= size;
171 rgn->region[i].size += size;
172 coalesced++;
173 break;
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100174 } else if (adjacent < 0) {
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600175 rgn->region[i].size += size;
176 coalesced++;
177 break;
Simon Goldschmidtcb57d132019-01-14 22:38:16 +0100178 } else if (lmb_addrs_overlap(base, size, rgnbase, rgnsize)) {
179 /* regions overlap */
180 return -1;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600181 }
182 }
183
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100184 if ((i < rgn->cnt - 1) && lmb_regions_adjacent(rgn, i, i + 1)) {
185 lmb_coalesce_regions(rgn, i, i + 1);
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600186 coalesced++;
187 }
188
189 if (coalesced)
190 return coalesced;
Patrick Delaunay8c69fc22021-03-10 10:16:27 +0100191 if (rgn->cnt >= rgn->max)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600192 return -1;
193
194 /* Couldn't coalesce the LMB, so add it to the sorted table. */
195 for (i = rgn->cnt-1; i >= 0; i--) {
196 if (base < rgn->region[i].base) {
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100197 rgn->region[i + 1].base = rgn->region[i].base;
198 rgn->region[i + 1].size = rgn->region[i].size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600199 } else {
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100200 rgn->region[i + 1].base = base;
201 rgn->region[i + 1].size = size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600202 break;
203 }
204 }
205
206 if (base < rgn->region[0].base) {
207 rgn->region[0].base = base;
208 rgn->region[0].size = size;
209 }
210
211 rgn->cnt++;
212
213 return 0;
214}
215
216/* This routine may be called with relocation disabled. */
Becky Bruced26d67c2008-06-09 20:37:18 -0500217long lmb_add(struct lmb *lmb, phys_addr_t base, phys_size_t size)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600218{
219 struct lmb_region *_rgn = &(lmb->memory);
220
221 return lmb_add_region(_rgn, base, size);
222}
223
Andy Fleming09d2a712008-07-07 14:24:39 -0500224long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size)
Andy Fleming1ae346c2008-06-16 13:58:54 -0500225{
226 struct lmb_region *rgn = &(lmb->reserved);
Andy Fleming09d2a712008-07-07 14:24:39 -0500227 phys_addr_t rgnbegin, rgnend;
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100228 phys_addr_t end = base + size - 1;
Andy Fleming1ae346c2008-06-16 13:58:54 -0500229 int i;
230
231 rgnbegin = rgnend = 0; /* supress gcc warnings */
232
233 /* Find the region where (base, size) belongs to */
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100234 for (i = 0; i < rgn->cnt; i++) {
Andy Fleming1ae346c2008-06-16 13:58:54 -0500235 rgnbegin = rgn->region[i].base;
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100236 rgnend = rgnbegin + rgn->region[i].size - 1;
Andy Fleming1ae346c2008-06-16 13:58:54 -0500237
238 if ((rgnbegin <= base) && (end <= rgnend))
239 break;
240 }
241
242 /* Didn't find the region */
243 if (i == rgn->cnt)
244 return -1;
245
246 /* Check to see if we are removing entire region */
247 if ((rgnbegin == base) && (rgnend == end)) {
248 lmb_remove_region(rgn, i);
249 return 0;
250 }
251
252 /* Check to see if region is matching at the front */
253 if (rgnbegin == base) {
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100254 rgn->region[i].base = end + 1;
Andy Fleming1ae346c2008-06-16 13:58:54 -0500255 rgn->region[i].size -= size;
256 return 0;
257 }
258
259 /* Check to see if the region is matching at the end */
260 if (rgnend == end) {
261 rgn->region[i].size -= size;
262 return 0;
263 }
264
265 /*
266 * We need to split the entry - adjust the current one to the
267 * beginging of the hole and add the region after hole.
268 */
269 rgn->region[i].size = base - rgn->region[i].base;
Simon Goldschmidt6402d9b2019-01-14 22:38:15 +0100270 return lmb_add_region(rgn, end + 1, rgnend - end);
Andy Fleming1ae346c2008-06-16 13:58:54 -0500271}
272
Becky Bruced26d67c2008-06-09 20:37:18 -0500273long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600274{
275 struct lmb_region *_rgn = &(lmb->reserved);
276
277 return lmb_add_region(_rgn, base, size);
278}
279
Jeroen Hofsteea0209722014-10-08 22:57:39 +0200280static long lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
Becky Bruced26d67c2008-06-09 20:37:18 -0500281 phys_size_t size)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600282{
283 unsigned long i;
284
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100285 for (i = 0; i < rgn->cnt; i++) {
Becky Bruced26d67c2008-06-09 20:37:18 -0500286 phys_addr_t rgnbase = rgn->region[i].base;
287 phys_size_t rgnsize = rgn->region[i].size;
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100288 if (lmb_addrs_overlap(base, size, rgnbase, rgnsize))
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600289 break;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600290 }
291
292 return (i < rgn->cnt) ? i : -1;
293}
294
Becky Bruced26d67c2008-06-09 20:37:18 -0500295phys_addr_t lmb_alloc(struct lmb *lmb, phys_size_t size, ulong align)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600296{
297 return lmb_alloc_base(lmb, size, align, LMB_ALLOC_ANYWHERE);
298}
299
Becky Bruced26d67c2008-06-09 20:37:18 -0500300phys_addr_t lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600301{
Becky Bruced26d67c2008-06-09 20:37:18 -0500302 phys_addr_t alloc;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600303
304 alloc = __lmb_alloc_base(lmb, size, align, max_addr);
305
306 if (alloc == 0)
307 printf("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100308 (ulong)size, (ulong)max_addr);
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600309
310 return alloc;
311}
312
Becky Bruced26d67c2008-06-09 20:37:18 -0500313static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600314{
315 return addr & ~(size - 1);
316}
317
Becky Bruced26d67c2008-06-09 20:37:18 -0500318phys_addr_t __lmb_alloc_base(struct lmb *lmb, phys_size_t size, ulong align, phys_addr_t max_addr)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600319{
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100320 long i, rgn;
Becky Bruced26d67c2008-06-09 20:37:18 -0500321 phys_addr_t base = 0;
Andy Fleming78bd5a72008-06-16 13:58:55 -0500322 phys_addr_t res_base;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600323
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100324 for (i = lmb->memory.cnt - 1; i >= 0; i--) {
Becky Bruced26d67c2008-06-09 20:37:18 -0500325 phys_addr_t lmbbase = lmb->memory.region[i].base;
326 phys_size_t lmbsize = lmb->memory.region[i].size;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600327
Andy Fleming78bd5a72008-06-16 13:58:55 -0500328 if (lmbsize < size)
329 continue;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600330 if (max_addr == LMB_ALLOC_ANYWHERE)
331 base = lmb_align_down(lmbbase + lmbsize - size, align);
332 else if (lmbbase < max_addr) {
Stephen Warrenb6a010b2014-07-31 13:40:07 -0600333 base = lmbbase + lmbsize;
334 if (base < lmbbase)
335 base = -1;
336 base = min(base, max_addr);
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600337 base = lmb_align_down(base - size, align);
338 } else
339 continue;
340
Andy Fleming78bd5a72008-06-16 13:58:55 -0500341 while (base && lmbbase <= base) {
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100342 rgn = lmb_overlaps_region(&lmb->reserved, base, size);
343 if (rgn < 0) {
Andy Fleming78bd5a72008-06-16 13:58:55 -0500344 /* This area isn't reserved, take it */
345 if (lmb_add_region(&lmb->reserved, base,
Simon Goldschmidtcb57d132019-01-14 22:38:16 +0100346 size) < 0)
Andy Fleming78bd5a72008-06-16 13:58:55 -0500347 return 0;
348 return base;
349 }
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100350 res_base = lmb->reserved.region[rgn].base;
Andy Fleming78bd5a72008-06-16 13:58:55 -0500351 if (res_base < size)
352 break;
353 base = lmb_align_down(res_base - size, align);
354 }
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600355 }
Andy Fleming78bd5a72008-06-16 13:58:55 -0500356 return 0;
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600357}
358
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100359/*
360 * Try to allocate a specific address range: must be in defined memory but not
361 * reserved
362 */
363phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base, phys_size_t size)
364{
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100365 long rgn;
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100366
367 /* Check if the requested address is in one of the memory regions */
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100368 rgn = lmb_overlaps_region(&lmb->memory, base, size);
369 if (rgn >= 0) {
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100370 /*
371 * Check if the requested end address is in the same memory
372 * region we found.
373 */
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100374 if (lmb_addrs_overlap(lmb->memory.region[rgn].base,
375 lmb->memory.region[rgn].size,
376 base + size - 1, 1)) {
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100377 /* ok, reserve the memory */
378 if (lmb_reserve(lmb, base, size) >= 0)
379 return base;
380 }
381 }
382 return 0;
383}
384
385/* Return number of bytes from a given address that are free */
Simon Goldschmidt7510a562019-01-21 20:29:55 +0100386phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr)
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100387{
388 int i;
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100389 long rgn;
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100390
391 /* check if the requested address is in the memory regions */
Simon Goldschmidtf41f7d62019-01-21 20:29:56 +0100392 rgn = lmb_overlaps_region(&lmb->memory, addr, 1);
393 if (rgn >= 0) {
Simon Goldschmidt7a6ee462019-01-14 22:38:18 +0100394 for (i = 0; i < lmb->reserved.cnt; i++) {
395 if (addr < lmb->reserved.region[i].base) {
396 /* first reserved range > requested address */
397 return lmb->reserved.region[i].base - addr;
398 }
399 if (lmb->reserved.region[i].base +
400 lmb->reserved.region[i].size > addr) {
401 /* requested addr is in this reserved range */
402 return 0;
403 }
404 }
405 /* if we come here: no reserved ranges above requested addr */
406 return lmb->memory.region[lmb->memory.cnt - 1].base +
407 lmb->memory.region[lmb->memory.cnt - 1].size - addr;
408 }
409 return 0;
410}
411
Becky Bruced26d67c2008-06-09 20:37:18 -0500412int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr)
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600413{
414 int i;
415
416 for (i = 0; i < lmb->reserved.cnt; i++) {
Becky Bruced26d67c2008-06-09 20:37:18 -0500417 phys_addr_t upper = lmb->reserved.region[i].base +
Kumar Gala6d7bfa82008-02-27 21:51:47 -0600418 lmb->reserved.region[i].size - 1;
419 if ((addr >= lmb->reserved.region[i].base) && (addr <= upper))
420 return 1;
421 }
422 return 0;
423}
Mike Frysingera0dadf82009-11-03 11:35:59 -0500424
Jeroen Hofstee0461dda2014-06-26 20:04:37 +0200425__weak void board_lmb_reserve(struct lmb *lmb)
Mike Frysingera0dadf82009-11-03 11:35:59 -0500426{
427 /* please define platform specific board_lmb_reserve() */
428}
Mike Frysingera0dadf82009-11-03 11:35:59 -0500429
Jeroen Hofstee0461dda2014-06-26 20:04:37 +0200430__weak void arch_lmb_reserve(struct lmb *lmb)
Mike Frysingera0dadf82009-11-03 11:35:59 -0500431{
432 /* please define platform specific arch_lmb_reserve() */
433}