Merge patch series "Allow showing the memory map"

Simon Glass <sjg@chromium.org> says:

This little series adds a new 'memmap' command, intended to show the
layout of memory within U-Boot and how much memory is available for
loading images.

Link: https://lore.kernel.org/r/20241021081934.289473-1-sjg@chromium.org
This commit is contained in:
Tom Rini
2024-10-25 14:22:36 -06:00
17 changed files with 347 additions and 42 deletions
+4 -4
View File
@@ -501,9 +501,9 @@ static unsigned long reserve_stack_aligned(size_t size)
static int reserve_noncached(void)
{
/*
* The value of gd->start_addr_sp must match the value of malloc_start
* calculated in board_r.c:initr_malloc(), which is passed to
* dlmalloc.c:mem_malloc_init() and then used by
* The value of gd->start_addr_sp must match the value of
* mem_malloc_start calculated in board_r.c:initr_malloc(), which is
* passed to dlmalloc.c:mem_malloc_init() and then used by
* cache.c:noncached_init()
*
* These calculations must match the code in cache.c:noncached_init()
@@ -582,7 +582,7 @@ static int reserve_fdt(void)
static int reserve_bootstage(void)
{
#ifdef CONFIG_BOOTSTAGE
int size = bootstage_get_size();
int size = bootstage_get_size(true);
gd->start_addr_sp = reserve_stack_aligned(size);
gd->boardf->new_bootstage = map_sysmem(gd->start_addr_sp, size);
+1 -2
View File
@@ -204,8 +204,7 @@ static int initr_malloc(void)
*/
start = gd->relocaddr - TOTAL_MALLOC_LEN;
gd_set_malloc_start(start);
mem_malloc_init((ulong)map_sysmem(start, TOTAL_MALLOC_LEN),
TOTAL_MALLOC_LEN);
mem_malloc_init(start, TOTAL_MALLOC_LEN);
return 0;
}
+9 -7
View File
@@ -520,17 +520,19 @@ int _bootstage_unstash_default(void)
}
#endif
int bootstage_get_size(void)
int bootstage_get_size(bool add_strings)
{
struct bootstage_data *data = gd->bootstage;
struct bootstage_record *rec;
int size;
int i;
size = sizeof(struct bootstage_data);
for (rec = data->record, i = 0; i < data->rec_count;
i++, rec++)
size += strlen(rec->name) + 1;
if (add_strings) {
struct bootstage_data *data = gd->bootstage;
struct bootstage_record *rec;
int i;
for (rec = data->record, i = 0; i < data->rec_count; i++, rec++)
size += strlen(rec->name) + 1;
}
return size;
}
+5 -3
View File
@@ -16,6 +16,8 @@
#include <asm/global_data.h>
#include <malloc.h>
#include <mapmem.h>
#include <string.h>
#include <asm/io.h>
#include <valgrind/memcheck.h>
@@ -598,9 +600,9 @@ void *sbrk(ptrdiff_t increment)
void mem_malloc_init(ulong start, ulong size)
{
mem_malloc_start = start;
mem_malloc_end = start + size;
mem_malloc_brk = start;
mem_malloc_start = (ulong)map_sysmem(start, size);
mem_malloc_end = mem_malloc_start + size;
mem_malloc_brk = mem_malloc_start;
#ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
malloc_init();
+1 -3
View File
@@ -678,9 +678,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
spl_set_bd();
if (IS_ENABLED(CONFIG_SPL_SYS_MALLOC)) {
mem_malloc_init((ulong)map_sysmem(SPL_SYS_MALLOC_START,
SPL_SYS_MALLOC_SIZE),
SPL_SYS_MALLOC_SIZE);
mem_malloc_init(SPL_SYS_MALLOC_START, SPL_SYS_MALLOC_SIZE);
gd->flags |= GD_FLG_FULL_MALLOC_INIT;
}
if (!(gd->flags & GD_FLG_SPL_INIT)) {