mirror of
https://xff.cz/git/u-boot/
synced 2025-09-19 09:32:07 +02:00
malloc_simple: Add debug() information
It's useful to get a a trace of memory allocations in early init. Add a debug() call to provide that. It can be enabled by adding '#define DEBUG' to the top of the file. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
@@ -19,10 +19,13 @@ void *malloc_simple(size_t bytes)
|
|||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
new_ptr = gd->malloc_ptr + bytes;
|
new_ptr = gd->malloc_ptr + bytes;
|
||||||
|
debug("%s: size=%zx, ptr=%lx, limit=%lx\n", __func__, bytes, new_ptr,
|
||||||
|
gd->malloc_limit);
|
||||||
if (new_ptr > gd->malloc_limit)
|
if (new_ptr > gd->malloc_limit)
|
||||||
return NULL;
|
return NULL;
|
||||||
ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
|
ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
|
||||||
gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
|
gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +40,7 @@ void *memalign_simple(size_t align, size_t bytes)
|
|||||||
return NULL;
|
return NULL;
|
||||||
ptr = map_sysmem(addr, bytes);
|
ptr = map_sysmem(addr, bytes);
|
||||||
gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
|
gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user