Skip to content

Commit 0be0f20

Browse files
sjg20lbmeng
authored andcommitted
bdinfo: Show the malloc base with the bdinfo command
It is useful to see the base of the malloc region. This is visible when debugging but not in normal usage. Add it to the global data so that it can be shown. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Nikhil M Jain <[email protected]> Reviewed-by: Bin Meng <[email protected]> Tested-by: Nikhil M Jain <[email protected]>
1 parent 8f015d3 commit 0be0f20

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

cmd/bdinfo.c

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
176176
if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) {
177177
bdinfo_print_num_ll("stack ptr", (ulong)&bd);
178178
bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top);
179+
bdinfo_print_num_l("malloc base", gd_malloc_start());
179180
}
180181

181182
arch_print_bdinfo();

common/board_r.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int initr_barrier(void)
196196

197197
static int initr_malloc(void)
198198
{
199-
ulong malloc_start;
199+
ulong start;
200200

201201
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
202202
debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
@@ -207,8 +207,9 @@ static int initr_malloc(void)
207207
* This value MUST match the value of gd->start_addr_sp in board_f.c:
208208
* reserve_noncached().
209209
*/
210-
malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
211-
mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
210+
start = gd->relocaddr - TOTAL_MALLOC_LEN;
211+
gd_set_malloc_start(start);
212+
mem_malloc_init((ulong)map_sysmem(start, TOTAL_MALLOC_LEN),
212213
TOTAL_MALLOC_LEN);
213214
return 0;
214215
}

include/asm-generic/global_data.h

+13
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ struct global_data {
301301
* @timebase_l: low 32 bits of timer
302302
*/
303303
unsigned int timebase_l;
304+
/**
305+
* @malloc_start: start of malloc() region
306+
*/
307+
#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
308+
unsigned long malloc_start;
309+
#endif
304310
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
305311
/**
306312
* @malloc_base: base address of early malloc()
@@ -560,6 +566,13 @@ static_assert(sizeof(struct global_data) == GD_SIZE);
560566
#define gd_event_state() NULL
561567
#endif
562568

569+
#if CONFIG_IS_ENABLED(CMD_BDINFO_EXTRA)
570+
#define gd_malloc_start() gd->malloc_start
571+
#define gd_set_malloc_start(_val) gd->malloc_start = (_val)
572+
#else
573+
#define gd_malloc_start() 0
574+
#define gd_set_malloc_start(val)
575+
#endif
563576
/**
564577
* enum gd_flags - global data flags
565578
*

0 commit comments

Comments
 (0)