summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2024-10-25 14:22:36 -0600
committerTom Rini <[email protected]>2024-10-25 14:22:36 -0600
commitdeafcdc8e014dc83f154cc448cf8cf6a24b29136 (patch)
tree853fc8fe04e1235d55b077f86e22dfc0ba0a41f2 /common
parent3fbc657669591ca893613f14d42e07069b7d56cd (diff)
parent9252b7f867f7638ba3f6af85058fee7b3993222d (diff)
Merge patch series "Allow showing the memory map"
Simon Glass <[email protected]> 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/[email protected]
Diffstat (limited to 'common')
-rw-r--r--common/board_f.c8
-rw-r--r--common/board_r.c3
-rw-r--r--common/bootstage.c16
-rw-r--r--common/dlmalloc.c8
-rw-r--r--common/spl/spl.c4
5 files changed, 20 insertions, 19 deletions
diff --git a/common/board_f.c b/common/board_f.c
index f1bd70fdd6c..98dc2591e1d 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -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);
diff --git a/common/board_r.c b/common/board_r.c
index e5f33f40643..8a19817fa39 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -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;
}
diff --git a/common/bootstage.c b/common/bootstage.c
index dd6aed7c2fd..c7bb204501a 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -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;
}
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 1ac7ce3f43c..cc4d3a0a028 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -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();
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 94657d00591..1ceb63daf31 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -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)) {