From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 6/7] cmd: efidebug: add memmap command
Date: Tue, 22 Jan 2019 10:42:46 +0900 [thread overview]
Message-ID: <20190122014245.GB20286@linaro.org> (raw)
In-Reply-To: <1946ef25-9ba9-fb3a-45cc-233206f04551@suse.de>
On Mon, Jan 21, 2019 at 02:39:07PM +0100, Alexander Graf wrote:
> On 01/21/2019 08:49 AM, AKASHI Takahiro wrote:
> >"memmap" command prints uefi-specific memory map information.
> >=> efi memmap
> >Type Start End Attributes
> >================ ================ ================ ==========
> >CONVENTIONAL 0000000040000000-000000007de27000 WB
> >RUNTIME DATA 000000007de27000-000000007de28000 WB|RT
> >RESERVED 000000007de28000-000000007de2a000 WB
> >RUNTIME DATA 000000007de2a000-000000007de2b000 WB|RT
> >RESERVED 000000007de2b000-000000007de2c000 WB
> >RUNTIME DATA 000000007de2c000-000000007de2d000 WB|RT
> >LOADER DATA 000000007de2d000-000000007ff37000 WB
> >RUNTIME CODE 000000007ff37000-000000007ff38000 WB|RT
> >LOADER DATA 000000007ff38000-0000000080000000 WB
> >
> >Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> >---
> > cmd/efidebug.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 94 insertions(+), 1 deletion(-)
> >
> >diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> >index 906e6b2d0295..bd6b095562e7 100644
> >--- a/cmd/efidebug.c
> >+++ b/cmd/efidebug.c
> >@@ -592,6 +592,95 @@ static int do_efi_show_images(cmd_tbl_t *cmdtp, int flag,
> > return CMD_RET_SUCCESS;
> > }
> >+static const char * const efi_mem_type_string[] = {
> >+ [EFI_RESERVED_MEMORY_TYPE] = "RESERVED",
> >+ [EFI_LOADER_CODE] = "LOADER CODE",
> >+ [EFI_LOADER_DATA] = "LOADER DATA",
> >+ [EFI_BOOT_SERVICES_CODE] = "BOOT CODE",
> >+ [EFI_BOOT_SERVICES_DATA] = "BOOT DATA",
> >+ [EFI_RUNTIME_SERVICES_CODE] = "RUNTIME CODE",
> >+ [EFI_RUNTIME_SERVICES_DATA] = "RUNTIME DATA",
> >+ [EFI_CONVENTIONAL_MEMORY] = "CONVENTIONAL",
> >+ [EFI_UNUSABLE_MEMORY] = "UNUSABLE MEM",
> >+ [EFI_ACPI_RECLAIM_MEMORY] = "ACPI RECLAIM MEM",
> >+ [EFI_ACPI_MEMORY_NVS] = "ACPI NVS",
> >+ [EFI_MMAP_IO] = "IO",
> >+ [EFI_MMAP_IO_PORT] = "IO PORT",
> >+ [EFI_PAL_CODE] = "PAL",
> >+};
> >+
> >+static const struct efi_mem_attrs {
> >+ const u64 bit;
> >+ const char *text;
> >+} efi_mem_attrs[] = {
> >+ {EFI_MEMORY_UC, "UC"},
> >+ {EFI_MEMORY_UC, "UC"},
> >+ {EFI_MEMORY_WC, "WC"},
> >+ {EFI_MEMORY_WT, "WT"},
> >+ {EFI_MEMORY_WB, "WB"},
> >+ {EFI_MEMORY_UCE, "UCE"},
> >+ {EFI_MEMORY_WP, "WP"},
> >+ {EFI_MEMORY_RP, "RP"},
> >+ {EFI_MEMORY_XP, "WP"},
> >+ {EFI_MEMORY_NV, "NV"},
> >+ {EFI_MEMORY_MORE_RELIABLE, "REL"},
> >+ {EFI_MEMORY_RO, "RO"},
> >+ {EFI_MEMORY_RUNTIME, "RT"},
> >+};
> >+
> >+static void print_memory_attributes(u64 attributes)
> >+{
> >+ int sep, i;
> >+
> >+ for (sep = 0, i = 0; i < ARRAY_SIZE(efi_mem_attrs); i++)
> >+ if (attributes & efi_mem_attrs[i].bit) {
> >+ if (sep) {
> >+ putc('|');
> >+ } else {
> >+ putc(' ');
> >+ sep = 1;
> >+ }
> >+ puts(efi_mem_attrs[i].text);
> >+ }
> >+}
> >+
> >+static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag,
> >+ int argc, char * const argv[])
> >+{
> >+ struct efi_mem_desc *memmap = NULL, *map;
> >+ efi_uintn_t map_size = 0;
> >+ int i;
> >+ efi_status_t ret;
> >+
> >+ ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL);
> >+ if (ret == EFI_BUFFER_TOO_SMALL) {
> >+ memmap = malloc(map_size);
> >+ if (!memmap)
> >+ return CMD_RET_FAILURE;
> >+ ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL);
> >+ }
> >+ if (ret != EFI_SUCCESS) {
> >+ free(memmap);
> >+ return CMD_RET_FAILURE;
> >+ }
> >+
> >+ printf("Type Start End Attributes\n");
> >+ printf("================ ================ ================ ==========\n");
> >+ for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) {
> >+ printf("%-16s %016llx-%016llx",
> >+ efi_mem_type_string[map->type],
>
> Please check that map->type is within bounds (<= PAL; better yet <
> ARRAY_SIZE(efi_mem_type_string)).
OK.
-Takahiro Akashi
>
> Alex
>
next prev parent reply other threads:[~2019-01-22 1:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 7:49 [U-Boot] [PATCH v5 0/7] cmd: add efidebug for efi environment AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 1/7] cmd: add efidebug command AKASHI Takahiro
2019-01-21 13:07 ` Alexander Graf
2019-01-22 1:02 ` AKASHI Takahiro
2019-01-22 9:18 ` Alexander Graf
2019-01-23 4:47 ` AKASHI Takahiro
2019-01-23 9:52 ` Alexander Graf
2019-01-24 1:02 ` AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 2/7] cmd: efidebug: add devices command AKASHI Takahiro
2019-01-21 13:34 ` Alexander Graf
2019-01-22 1:38 ` AKASHI Takahiro
2019-01-22 9:19 ` Alexander Graf
2019-01-23 4:56 ` AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 3/7] cmd: efidebug: add drivers command AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 4/7] cmd: efidebug: add dh command AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 5/7] cmd: efidebug: add images command AKASHI Takahiro
2019-01-21 7:49 ` [U-Boot] [PATCH v5 6/7] cmd: efidebug: add memmap command AKASHI Takahiro
2019-01-21 13:39 ` Alexander Graf
2019-01-22 1:42 ` AKASHI Takahiro [this message]
2019-01-21 7:49 ` [U-Boot] [PATCH v5 7/7] cmd: env: add "-e" option for handling UEFI variables AKASHI Takahiro
2019-01-21 13:41 ` Alexander Graf
2019-01-22 3:06 ` AKASHI Takahiro
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=20190122014245.GB20286@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox