[PATCH v3 13/38] cmd: Add a command to display the address map

Priyanka Jain (OSS) priyanka.jain at oss.nxp.com
Fri Feb 26 10:34:24 CET 2021



>-----Original Message-----
>From: U-Boot <u-boot-bounces at lists.denx.de> On Behalf Of Bin Meng
>Sent: Thursday, February 25, 2021 2:53 PM
>To: Simon Glass <sjg at chromium.org>; Alexander Graf <agraf at csgraf.de>;
>Priyanka Jain <priyanka.jain at nxp.com>
>Cc: U-Boot Mailing List <u-boot at lists.denx.de>; Tom Rini
><trini at konsulko.com>; Marek Szyprowski <m.szyprowski at samsung.com>;
>Matthias Brugger <mbrugger at suse.com>
>Subject: [PATCH v3 13/38] cmd: Add a command to display the address map
>
>This adds a new command 'addrmap' to display the address map for non-
>identity virtual-physical memory mappings.
>
>Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
>Reviewed-by: Simon Glass <sjg at chromium.org>
>Reviewed-by: Priyanka Jain <priyanka.jain at nxp.com>
>
>---
>
>(no changes since v2)
>
>Changes in v2:
>- add doc/usage/addrmap.rst
>
> cmd/Kconfig           |  7 +++++++
> cmd/Makefile          |  1 +
> cmd/addrmap.c         | 35 +++++++++++++++++++++++++++++++++++
> doc/usage/addrmap.rst | 41
>+++++++++++++++++++++++++++++++++++++++++
> doc/usage/index.rst   |  1 +
> 5 files changed, 85 insertions(+)
> create mode 100644 cmd/addrmap.c
> create mode 100644 doc/usage/addrmap.rst
>
>diff --git a/cmd/Kconfig b/cmd/Kconfig
>index 928a2a0..2021939 100644
>--- a/cmd/Kconfig
>+++ b/cmd/Kconfig
>@@ -97,6 +97,13 @@ config CMD_ACPI
> 	  between the firmware and OS, and is particularly useful when you
> 	  want to make hardware changes without the OS needing to be
>adjusted.
>
>+config CMD_ADDRMAP
>+	bool "addrmap"
>+	depends on ADDR_MAP
>+	default y
>+	help
>+	  List non-identity virtual-physical memory mappings for 32-bit CPUs.
>+
> config CMD_BDI
> 	bool "bdinfo"
> 	default y
>diff --git a/cmd/Makefile b/cmd/Makefile index 176bf92..567e2b7 100644
>--- a/cmd/Makefile
>+++ b/cmd/Makefile
>@@ -13,6 +13,7 @@ obj-y += version.o
>
> # command
> obj-$(CONFIG_CMD_ACPI) += acpi.o
>+obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
> obj-$(CONFIG_CMD_AES) += aes.o
> obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o
> obj-$(CONFIG_CMD_ADC) += adc.o
>diff --git a/cmd/addrmap.c b/cmd/addrmap.c new file mode 100644 index
>0000000..bd23549
>--- /dev/null
>+++ b/cmd/addrmap.c
>@@ -0,0 +1,35 @@
>+// SPDX-License-Identifier: GPL-2.0+
>+/*
>+ * Copyright (C) 2021, Bin Meng <bmeng.cn at gmail.com>  */
>+
>+#include <common.h>
>+#include <command.h>
>+#include <addr_map.h>
>+
>+static int do_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
>+		      char *const argv[])
>+{
>+	int i;
>+
>+	printf("           vaddr            paddr             size\n");
>+	printf("================ ================
>================\n");
>+
>+	for (i = 0; i < CONFIG_SYS_NUM_ADDR_MAP; i++) {
>+		if (address_map[i].size == 0)
>+			continue;
>+
>+		printf("%16.8lx %16.8llx %16.8llx\n",
>+		       address_map[i].vaddr,
>+		       (unsigned long long)address_map[i].paddr,
>+		       (unsigned long long)address_map[i].size);
>+	}
>+
>+	return 0;
>+}
>+
>+U_BOOT_CMD(
>+	addrmap,	1,	1,	do_addrmap,
>+	"List non-identity virtual-physical memory mappings for 32-bit CPUs",
>+	""
>+);
>diff --git a/doc/usage/addrmap.rst b/doc/usage/addrmap.rst new file mode
>100644 index 0000000..472fd54
>--- /dev/null
>+++ b/doc/usage/addrmap.rst
>@@ -0,0 +1,41 @@
>+.. SPDX-License-Identifier: GPL-2.0+
>+
>+addrmap command
>+===============
>+
>+Synopsis
>+--------
>+
>+::
>+
>+    addrmap
>+
>+Description
>+-----------
>+
>+The addrmap command is used to display non-identity virtual-physical
>+memory mappings for 32-bit CPUs.
>+
>+The output may look like:
>+
>+::
>+
>+    => addrmap
>+               vaddr            paddr             size
>+    ================ ================ ================
>+            e0000000        fe0000000         00100000
>+            00000000         00000000         04000000
>+            04000000         04000000         04000000
>+            80000000        c00000000         10000000
>+            90000000        c10000000         10000000
>+            a0000000        fe1000000         00010000
>+
>+The first column indicates the virtual address.
>+The second column indicates the physical address.
>+The third column indicates the mapped size.
>+
>+Configuration
>+-------------
>+
>+To use the addrmap command you must specify
>CONFIG_CMD_ADDRMAP=y.
>+It is automatically turned on when CONFIG_ADDR_MAP is set.
>diff --git a/doc/usage/index.rst b/doc/usage/index.rst index a8842bf..f962246
>100644
>--- a/doc/usage/index.rst
>+++ b/doc/usage/index.rst
>@@ -13,6 +13,7 @@ Shell commands
> .. toctree::
>    :maxdepth: 1
>
>+   addrmap
>    base
>    bootefi
>    booti
>--
>2.7.4

Kindly fix below checkpatch warnings

ARNING: please write a paragraph that describes the config symbol fully
#30: FILE: cmd/Kconfig:100:
+config CMD_ADDRMAP

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#53: 
new file mode 100644

WARNING: Possible new command - make sure you add a test
#67: FILE: cmd/addrmap.c:10:
+static int do_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,

CHECK: Lines should not end with a '('
#88: FILE: cmd/addrmap.c:31:
+U_BOOT_CMD(

total: 0 errors, 3 warnings, 1 checks, 103 lines checked


Regards
Priyanka



More information about the U-Boot mailing list