diff options
| author | Simon Glass <[email protected]> | 2024-10-21 10:19:30 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-10-25 14:22:24 -0600 |
| commit | f18c048e6e6194b4f64d440f514dc158e4eb12a7 (patch) | |
| tree | 65b1ae26b38f5b829157304ea941fc47252d6460 /cmd/meminfo.c | |
| parent | 8306c3b035bebce2d4060620d85192a401128bd7 (diff) | |
cmd: Update the meminfo command to show the memory map
U-Boot has a fairly rigid memory map which is normally not visible
unless debugging is enabled in board_f.c
Update the 'meminfo' command to show it. This command does not cover
arch-specific pieces but gives a good overview of where things are.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'cmd/meminfo.c')
| -rw-r--r-- | cmd/meminfo.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/cmd/meminfo.c b/cmd/meminfo.c index bb9bcec2e3f..0e6d2f9cc2c 100644 --- a/cmd/meminfo.c +++ b/cmd/meminfo.c @@ -4,18 +4,67 @@ * Written by Simon Glass <[email protected]> */ +#include <bloblist.h> +#include <bootstage.h> #include <command.h> #include <display_options.h> +#include <malloc.h> +#include <mapmem.h> #include <asm/global_data.h> DECLARE_GLOBAL_DATA_PTR; +static void print_region(const char *name, ulong base, ulong size, ulong *uptop) +{ + ulong end = base + size; + + printf("%-12s %8lx %8lx %8lx", name, base, size, end); + if (*uptop) + printf(" %8lx", *uptop - end); + putc('\n'); + *uptop = base; +} + static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) + char *const argv[]) { + ulong upto, stk_bot; + puts("DRAM: "); print_size(gd->ram_size, "\n"); + if (!IS_ENABLED(CONFIG_CMD_MEMINFO_MAP)) + return 0; + + printf("\n%-12s %8s %8s %8s %8s\n", "Region", "Base", "Size", "End", + "Gap"); + printf("------------------------------------------------\n"); + upto = 0; + if (IS_ENABLED(CONFIG_VIDEO)) + print_region("video", gd_video_bottom(), + gd_video_size(), &upto); + if (IS_ENABLED(CONFIG_TRACE)) + print_region("trace", map_to_sysmem(gd_trace_buff()), + gd_trace_size(), &upto); + print_region("code", gd->relocaddr, gd->mon_len, &upto); + print_region("malloc", map_to_sysmem((void *)mem_malloc_start), + mem_malloc_end - mem_malloc_start, &upto); + print_region("board_info", map_to_sysmem(gd->bd), + sizeof(struct bd_info), &upto); + print_region("global_data", map_to_sysmem((void *)gd), + sizeof(struct global_data), &upto); + print_region("devicetree", map_to_sysmem(gd->fdt_blob), + fdt_totalsize(gd->fdt_blob), &upto); + if (IS_ENABLED(CONFIG_BOOTSTAGE)) + print_region("bootstage", map_to_sysmem(gd_bootstage()), + bootstage_get_size(false), &upto); + if (IS_ENABLED(CONFIG_BLOBLIST)) + print_region("bloblist", map_to_sysmem(gd_bloblist()), + bloblist_get_total_size(), &upto); + stk_bot = gd->start_addr_sp - CONFIG_STACK_SIZE; + print_region("stack", stk_bot, CONFIG_STACK_SIZE, &upto); + print_region("free", gd->ram_base, stk_bot, &upto); + return 0; } |
