From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 08/14] cmd: efishell: add memmap command
Date: Mon, 3 Dec 2018 16:10:37 +0900 [thread overview]
Message-ID: <20181203071036.GE28995@linaro.org> (raw)
In-Reply-To: <af1500dc-3a3b-cd5b-d04e-f66bce02bb35@suse.de>
On Mon, Dec 03, 2018 at 12:48:28AM +0100, Alexander Graf wrote:
>
>
> On 05.11.18 10:06, 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/efishell.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 77 insertions(+), 1 deletion(-)
> >
> > diff --git a/cmd/efishell.c b/cmd/efishell.c
> > index b5050d63fa22..3e1118a407ff 100644
> > --- a/cmd/efishell.c
> > +++ b/cmd/efishell.c
> > @@ -442,6 +442,78 @@ static int do_efi_show_images(int argc, char * const argv[])
> > 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",
> > +};
> > +
> > +#define EFI_MEM_ATTR(attribute, bit, string) \
> > + if ((attribute) & (bit)) { \
> > + if (sep) \
> > + putc('|'); \
> > + sep = 1; \
> > + printf(string); \
> > + }
> > +
> > +static int do_efi_show_memmap(int argc, char * const argv[])
> > +{
> > + struct efi_mem_desc *map = NULL;
> > + efi_uintn_t map_size = 0;
> > + int i, sep;
> > + efi_status_t ret;
> > +
> > + ret = efi_get_memory_map(&map_size, map, NULL, NULL, NULL);
> > + if (ret == EFI_BUFFER_TOO_SMALL) {
> > + map = malloc(map_size);
>
> Where is the free() to this malloc()?
OK, fix it.
Thanks,
-Takahiro Akashi
>
> Alex
>
> > + if (!map)
> > + return CMD_RET_FAILURE;
> > + ret = efi_get_memory_map(&map_size, map, NULL, NULL, NULL);
> > + }
> > + if (ret != EFI_SUCCESS)
> > + return CMD_RET_FAILURE;
> > +
> > + ret = efi_get_memory_map(&map_size, map, NULL, NULL, NULL);
> > + if (ret != EFI_SUCCESS)
> > + return CMD_RET_FAILURE;
> > +
> > + printf("Type Start End Attributes\n");
> > + printf("================ ================ ================ ==========\n");
> > + for (i = 0; i < map_size / sizeof(*map); map++, i++) {
> > + sep = 0;
> > + printf("%-16s %016llx-%016llx ",
> > + efi_mem_type_string[map->type],
> > + map->physical_start,
> > + map->physical_start + map->num_pages * EFI_PAGE_SIZE);
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_UC, "UC");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_WC, "WC");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_WT, "WT");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_WB, "WB");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_UCE, "UCE");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_WP, "WP");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_RP, "RP");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_XP, "WP");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_NV, "NV");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_MORE_RELIABLE, "REL");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_RO, "RO");
> > + EFI_MEM_ATTR(map->attribute, EFI_MEMORY_RUNTIME, "RT");
> > + putc('\n');
> > + }
> > +
> > + return CMD_RET_SUCCESS;
> > +}
> > +
> > static int do_efi_boot_add(int argc, char * const argv[])
> > {
> > int id;
> > @@ -826,6 +898,8 @@ static int do_efishell(cmd_tbl_t *cmdtp, int flag,
> > return do_efi_show_drivers(argc, argv);
> > else if (!strcmp(command, "images"))
> > return do_efi_show_images(argc, argv);
> > + else if (!strcmp(command, "memmap"))
> > + return do_efi_show_memmap(argc, argv);
> > else
> > return CMD_RET_USAGE;
> > }
> > @@ -853,7 +927,9 @@ static char efishell_help_text[] =
> > "efishell drivers\n"
> > " - show uefi drivers\n"
> > "efishell images\n"
> > - " - show loaded images\n";
> > + " - show loaded images\n"
> > + "efishell memmap\n"
> > + " - show uefi memory map\n";
> > #endif
> >
> > U_BOOT_CMD(
> >
next prev parent reply other threads:[~2018-12-03 7:10 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 9:06 [U-Boot] [PATCH v2 00/14] efi: make efi and bootmgr more usable AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 01/14] efi_loader: allow device == NULL in efi_dp_from_name() AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 02/14] efi_loader: bootmgr: add load option helper functions AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 03/14] efi_loader: bootmgr: allow for running a given load option AKASHI Takahiro
2018-12-02 23:22 ` Alexander Graf
2018-12-03 3:20 ` AKASHI Takahiro
2018-12-03 13:54 ` Alexander Graf
2018-11-05 9:06 ` [U-Boot] [PATCH v2 04/14] cmd: add efishell command AKASHI Takahiro
2018-12-02 23:42 ` Alexander Graf
2018-12-03 6:42 ` AKASHI Takahiro
2018-12-03 14:01 ` Alexander Graf
2018-11-05 9:06 ` [U-Boot] [PATCH v2 05/14] cmd: efishell: add devices command AKASHI Takahiro
2018-12-02 23:46 ` Alexander Graf
2018-12-03 7:02 ` AKASHI Takahiro
2018-12-23 3:11 ` Alexander Graf
2018-12-25 12:00 ` AKASHI Takahiro
2018-12-26 8:00 ` Alexander Graf
2019-01-07 8:22 ` AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 06/14] cmd: efishell: add drivers command AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 07/14] cmd: efishell: add images command AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 08/14] cmd: efishell: add memmap command AKASHI Takahiro
2018-12-02 23:48 ` Alexander Graf
2018-12-03 7:10 ` AKASHI Takahiro [this message]
2018-11-05 9:06 ` [U-Boot] [PATCH v2 09/14] cmd: efishell: add dh command AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 10/14] cmd: bootefi: carve out fdt parameter handling AKASHI Takahiro
2018-12-02 23:50 ` Alexander Graf
2018-12-03 7:33 ` AKASHI Takahiro
2018-12-23 3:11 ` Alexander Graf
2018-12-25 12:05 ` AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 11/14] cmd: bootefi: run an EFI application of a specific load option AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 12/14] cmd: run: add "-e" option to run an EFI application AKASHI Takahiro
2018-12-02 23:53 ` Alexander Graf
2018-12-03 7:57 ` AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 13/14] cmd: efishell: export uefi variable helper functions AKASHI Takahiro
2018-12-02 23:54 ` Alexander Graf
2018-12-03 8:08 ` AKASHI Takahiro
2018-12-23 3:13 ` Alexander Graf
2018-12-25 12:14 ` AKASHI Takahiro
2018-11-05 9:06 ` [U-Boot] [PATCH v2 14/14] cmd: env: add "-e" option for handling UEFI variables 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=20181203071036.GE28995@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