Skip to content

Commit 56d0635

Browse files
lbmengp-priyanka-jain
authored andcommittedMar 5, 2021
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 <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Priyanka Jain <[email protected]>
1 parent b561563 commit 56d0635

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed
 

‎cmd/Kconfig

+7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ config CMD_ACPI
9797
between the firmware and OS, and is particularly useful when you
9898
want to make hardware changes without the OS needing to be adjusted.
9999

100+
config CMD_ADDRMAP
101+
bool "addrmap"
102+
depends on ADDR_MAP
103+
default y
104+
help
105+
List non-identity virtual-physical memory mappings for 32-bit CPUs.
106+
100107
config CMD_BDI
101108
bool "bdinfo"
102109
default y

‎cmd/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-y += version.o
1313

1414
# command
1515
obj-$(CONFIG_CMD_ACPI) += acpi.o
16+
obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
1617
obj-$(CONFIG_CMD_AES) += aes.o
1718
obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o
1819
obj-$(CONFIG_CMD_ADC) += adc.o

‎cmd/addrmap.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
4+
*/
5+
6+
#include <common.h>
7+
#include <command.h>
8+
#include <addr_map.h>
9+
10+
static int do_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
11+
char *const argv[])
12+
{
13+
int i;
14+
15+
printf(" vaddr paddr size\n");
16+
printf("================ ================ ================\n");
17+
18+
for (i = 0; i < CONFIG_SYS_NUM_ADDR_MAP; i++) {
19+
if (address_map[i].size == 0)
20+
continue;
21+
22+
printf("%16.8lx %16.8llx %16.8llx\n",
23+
address_map[i].vaddr,
24+
(unsigned long long)address_map[i].paddr,
25+
(unsigned long long)address_map[i].size);
26+
}
27+
28+
return 0;
29+
}
30+
31+
U_BOOT_CMD(
32+
addrmap, 1, 1, do_addrmap,
33+
"List non-identity virtual-physical memory mappings for 32-bit CPUs",
34+
""
35+
);

‎doc/usage/addrmap.rst

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. SPDX-License-Identifier: GPL-2.0+
2+
3+
addrmap command
4+
===============
5+
6+
Synopsis
7+
--------
8+
9+
::
10+
11+
addrmap
12+
13+
Description
14+
-----------
15+
16+
The addrmap command is used to display non-identity virtual-physical memory
17+
mappings for 32-bit CPUs.
18+
19+
The output may look like:
20+
21+
::
22+
23+
=> addrmap
24+
vaddr paddr size
25+
================ ================ ================
26+
e0000000 fe0000000 00100000
27+
00000000 00000000 04000000
28+
04000000 04000000 04000000
29+
80000000 c00000000 10000000
30+
90000000 c10000000 10000000
31+
a0000000 fe1000000 00010000
32+
33+
The first column indicates the virtual address.
34+
The second column indicates the physical address.
35+
The third column indicates the mapped size.
36+
37+
Configuration
38+
-------------
39+
40+
To use the addrmap command you must specify CONFIG_CMD_ADDRMAP=y.
41+
It is automatically turned on when CONFIG_ADDR_MAP is set.

‎doc/usage/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Shell commands
1414
.. toctree::
1515
:maxdepth: 1
1616

17+
addrmap
1718
base
1819
bootefi
1920
booti

0 commit comments

Comments
 (0)
Please sign in to comment.