From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Tom Rini <trini@konsulko.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>
Subject: [PATCH 06/15] sandbox: Add a way to show the sandbox memory-mapping
Date: Mon, 28 Oct 2024 13:47:57 +0100 [thread overview]
Message-ID: <20241028124815.47262-7-sjg@chromium.org> (raw)
In-Reply-To: <20241028124815.47262-1-sjg@chromium.org>
This is mostly hidden in the background, but it is sometimes useful to
look at it. Add a function to allow this.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
arch/sandbox/cpu/cpu.c | 13 +++++++++++++
arch/sandbox/include/asm/cpu.h | 3 +++
cmd/sb.c | 11 +++++++++++
doc/usage/cmd/sb.rst | 25 +++++++++++++++++++++++++
4 files changed, 52 insertions(+)
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 06f8c13fab9..d1c4dcf0764 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -253,6 +253,19 @@ phys_addr_t map_to_sysmem(const void *ptr)
return mentry->tag;
}
+void sandbox_map_list(void)
+{
+ struct sandbox_mapmem_entry *mentry;
+ struct sandbox_state *state = state_get_current();
+
+ printf("Sandbox memory-mapping\n");
+ printf("%8s %16s %6s\n", "Addr", "Mapping", "Refcnt");
+ list_for_each_entry(mentry, &state->mapmem_head, sibling_node) {
+ printf("%8lx %p %6d\n", mentry->tag, mentry->ptr,
+ mentry->refcnt);
+ }
+}
+
unsigned long sandbox_read(const void *addr, enum sandboxio_size_t size)
{
struct sandbox_state *state = state_get_current();
diff --git a/arch/sandbox/include/asm/cpu.h b/arch/sandbox/include/asm/cpu.h
index c97ac7ba95b..682bb3376d1 100644
--- a/arch/sandbox/include/asm/cpu.h
+++ b/arch/sandbox/include/asm/cpu.h
@@ -8,4 +8,7 @@
void cpu_sandbox_set_current(const char *name);
+/* show the mapping of sandbox addresses to pointers */
+void sandbox_map_list(void);
+
#endif /* __SANDBOX_CPU_H */
diff --git a/cmd/sb.c b/cmd/sb.c
index 9dbb53275b3..9245052492e 100644
--- a/cmd/sb.c
+++ b/cmd/sb.c
@@ -7,6 +7,7 @@
#include <command.h>
#include <dm.h>
#include <spl.h>
+#include <asm/cpu.h>
#include <asm/global_data.h>
#include <asm/state.h>
@@ -29,6 +30,14 @@ static int do_sb_handoff(struct cmd_tbl *cmdtp, int flag, int argc,
#endif
}
+static int do_sb_map(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ sandbox_map_list();
+
+ return 0;
+}
+
static int do_sb_state(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -42,8 +51,10 @@ static int do_sb_state(struct cmd_tbl *cmdtp, int flag, int argc,
U_BOOT_LONGHELP(sb,
"handoff - Show handoff data received from SPL\n"
+ "sb map - Show mapped memory\n"
"sb state - Show sandbox state");
U_BOOT_CMD_WITH_SUBCMDS(sb, "Sandbox status commands", sb_help_text,
U_BOOT_SUBCMD_MKENT(handoff, 1, 1, do_sb_handoff),
+ U_BOOT_SUBCMD_MKENT(map, 1, 1, do_sb_map),
U_BOOT_SUBCMD_MKENT(state, 1, 1, do_sb_state));
diff --git a/doc/usage/cmd/sb.rst b/doc/usage/cmd/sb.rst
index 6f54f9d9eb7..37431aff7c8 100644
--- a/doc/usage/cmd/sb.rst
+++ b/doc/usage/cmd/sb.rst
@@ -12,6 +12,7 @@ Synopsis
::
sb handoff
+ sb map
sb state
Description
@@ -26,6 +27,24 @@ sb handoff
This shows information about any handoff information received from SPL. If
U-Boot is started from an SPL build, it shows a valid magic number.
+sb map
+~~~~~~
+
+This shows any mappings between sandbox's emulated RAM and the underlying host
+address-space.
+
+Fields shown are:
+
+Addr
+ Address in emulated RAM
+
+Mapping
+ Equivalent address in the host address-space. While sandbox requests address
+ ``0x10000000`` from the OS, this is not always available.
+
+Refcnt
+ Shows the number of references to this mapping.
+
sb state
~~~~~~~~
@@ -42,6 +61,12 @@ as ``sandbox_spl``::
=> sb handoff
SPL handoff magic 14f93c7b
+This shows output from the *sb map* subcommand, with a single mapping::
+
+ Sandbox memory-mapping
+ Addr Mapping Refcnt
+ ff000000 000056185b46d6d0 2
+
This shows output from the *sb state* subcommand::
=> sb state
--
2.43.0
next prev parent reply other threads:[~2024-10-28 12:49 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 12:47 [PATCH 00/15] efi_loader: Add support for logging to a buffer Simon Glass
2024-10-28 12:47 ` [PATCH 01/15] log: Add a new category for tests Simon Glass
2024-10-28 12:47 ` [PATCH 02/15] test: Allow saving and restoring the bloblist Simon Glass
2024-10-28 12:47 ` [PATCH 03/15] bloblist: test: Mark tests with UTF_BLOBLIST Simon Glass
2024-10-28 12:47 ` [PATCH 04/15] sandbox: Convert sb command to use new macro Simon Glass
2024-10-28 12:47 ` [PATCH 05/15] doc: sandbox: Add docs for the sb command Simon Glass
2024-11-03 23:24 ` Heinrich Schuchardt
2024-10-28 12:47 ` Simon Glass [this message]
2024-10-29 9:59 ` [PATCH 06/15] sandbox: Add a way to show the sandbox memory-mapping Ilias Apalodimas
2024-10-29 15:46 ` Simon Glass
2024-10-28 12:47 ` [PATCH 07/15] sandbox: Fix comment for nomap_sysmem() function Simon Glass
2024-10-28 12:47 ` [PATCH 08/15] lmb: Drop extra 16KB of stack space Simon Glass
2024-10-28 12:48 ` [PATCH 09/15] efi_loader: Fix free in ..._media_device_boot_option() Simon Glass
2024-10-29 10:01 ` Ilias Apalodimas
2024-10-29 15:45 ` Simon Glass
2024-10-29 22:13 ` Heinrich Schuchardt
2024-10-31 17:51 ` Simon Glass
2024-10-28 12:48 ` [PATCH 10/15] efi_loader: Add support for logging EFI calls Simon Glass
2024-10-29 11:44 ` Heinrich Schuchardt
2024-10-29 22:19 ` Heinrich Schuchardt
2024-10-31 18:01 ` Simon Glass
2024-10-31 22:30 ` Heinrich Schuchardt
2024-10-31 22:37 ` Tom Rini
2024-11-20 15:37 ` Simon Glass
2024-10-28 12:48 ` [PATCH 11/15] efi_loader: Create the log on startup Simon Glass
2024-10-28 12:48 ` [PATCH 12/15] efi_loader: Add a command to show the EFI log Simon Glass
2024-10-28 12:48 ` [PATCH 13/15] test: efi_loader: Add a simple test for " Simon Glass
2024-10-28 12:48 ` [PATCH 14/15] efi_loader: Use the log with memory-related functions Simon Glass
2024-10-28 12:48 ` [PATCH 15/15] efi_loader: Add documentation for the EFI log Simon Glass
2024-10-29 9:58 ` [PATCH 00/15] efi_loader: Add support for logging to a buffer Ilias Apalodimas
2024-10-29 15:45 ` Simon Glass
2024-10-29 18:31 ` Ilias Apalodimas
2024-10-31 18:01 ` Simon Glass
2024-11-01 11:31 ` Ilias Apalodimas
2024-11-20 15:37 ` Simon Glass
2024-11-20 15:55 ` Ilias Apalodimas
2024-11-20 18:06 ` Tom Rini
2024-11-20 20:05 ` Heinrich Schuchardt
2024-11-21 2:19 ` Simon Glass
2024-12-02 0:12 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241028124815.47262-7-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=ilias.apalodimas@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.