From f18c048e6e6194b4f64d440f514dc158e4eb12a7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Oct 2024 10:19:30 +0200 Subject: 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 --- test/cmd/Makefile | 3 ++- test/cmd/meminfo.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/cmd/meminfo.c (limited to 'test') diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 40808350962..4b487c1d2cb 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -19,8 +19,9 @@ obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o obj-$(CONFIG_CMD_HISTORY) += history.o obj-$(CONFIG_CMD_LOADM) += loadm.o -obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o +obj-$(CONFIG_CMD_MEMINFO) += meminfo.o obj-$(CONFIG_CMD_MEMORY) += mem_copy.o +obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o ifdef CONFIG_CMD_PCI obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o endif diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c new file mode 100644 index 00000000000..84981305bf0 --- /dev/null +++ b/test/cmd/meminfo.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for 'meminfo' command + * + * Copyright 2024 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include + +/* Test 'meminfo' command */ +static int cmd_test_meminfo(struct unit_test_state *uts) +{ + ut_assertok(run_command("meminfo", 0)); + ut_assert_nextline("DRAM: 256 MiB"); + ut_assert_nextline_empty(); + + ut_assert_nextline("Region Base Size End Gap"); + ut_assert_nextlinen("-"); + + /* For now we don't worry about checking the values */ + ut_assert_nextlinen("video"); + ut_assert_nextlinen("code"); + ut_assert_nextlinen("malloc"); + ut_assert_nextlinen("board_info"); + ut_assert_nextlinen("global_data"); + ut_assert_nextlinen("devicetree"); + ut_assert_nextlinen("bootstage"); + ut_assert_nextlinen("bloblist"); + ut_assert_nextlinen("stack"); + ut_assert_nextlinen("free"); + ut_assert_console_end(); + + return 0; +} +CMD_TEST(cmd_test_meminfo, UTF_CONSOLE); -- cgit v1.2.3 From 9252b7f867f7638ba3f6af85058fee7b3993222d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Oct 2024 10:19:32 +0200 Subject: meminfo: Show the lmb records Add the lmb records onto the end of the memory map. Signed-off-by: Simon Glass --- test/cmd/meminfo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c index 84981305bf0..53b41e3b49e 100644 --- a/test/cmd/meminfo.c +++ b/test/cmd/meminfo.c @@ -30,7 +30,11 @@ static int cmd_test_meminfo(struct unit_test_state *uts) ut_assert_nextlinen("bootstage"); ut_assert_nextlinen("bloblist"); ut_assert_nextlinen("stack"); - ut_assert_nextlinen("free"); + + /* we expect at least one lmb line, but don't know how many */ + ut_assert_nextlinen("lmb"); + ut_assert_skip_to_linen("free"); + ut_assert_console_end(); return 0; -- cgit v1.2.3