Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/stand/efiboot Add a "mem" command to print the EFI memor...
details: https://anonhg.NetBSD.org/src/rev/14bf4c88eab5
branches: trunk
changeset: 445543:14bf4c88eab5
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Nov 02 01:22:39 2018 +0000
description:
Add a "mem" command to print the EFI memory map.
diffstat:
sys/stand/efiboot/boot.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
sys/stand/efiboot/efifdt.c | 8 +-------
2 files changed, 44 insertions(+), 8 deletions(-)
diffs (101 lines):
diff -r 31f94bda65ce -r 14bf4c88eab5 sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c Thu Nov 01 20:34:49 2018 +0000
+++ b/sys/stand/efiboot/boot.c Fri Nov 02 01:22:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.12 2018/10/29 05:15:21 mrg Exp $ */
+/* $NetBSD: boot.c,v 1.13 2018/11/02 01:22:39 jmcneill Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -51,6 +51,24 @@
#define NUMNAMES __arraycount(names)
+static const char *efi_memory_type[] = {
+ [EfiReservedMemoryType] = "Reserved Memory Type",
+ [EfiLoaderCode] = "Loader Code",
+ [EfiLoaderData] = "Loader Data",
+ [EfiBootServicesCode] = "Boot Services Code",
+ [EfiBootServicesData] = "Boot Services Data",
+ [EfiRuntimeServicesCode] = "Runtime Services Code",
+ [EfiRuntimeServicesData] = "Runtime Services Data",
+ [EfiConventionalMemory] = "Conventional Memory",
+ [EfiUnusableMemory] = "Unusable Memory",
+ [EfiACPIReclaimMemory] = "ACPI Reclaim Memory",
+ [EfiACPIMemoryNVS] = "ACPI Memory NVS",
+ [EfiMemoryMappedIO] = "MMIO",
+ [EfiMemoryMappedIOPortSpace] = "MMIO (Port Space)",
+ [EfiPalCode] = "Pal Code",
+ [EfiPersistentMemory] = "Persistent Memory",
+};
+
static char default_device[32];
static char initrd_path[255];
static char dtb_path[255];
@@ -66,6 +84,7 @@
void command_dtb(char *);
void command_initrd(char *);
void command_ls(char *);
+void command_mem(char *);
void command_printenv(char *);
void command_setenv(char *);
void command_clearenv(char *);
@@ -80,6 +99,7 @@
{ "dtb", command_dtb, "dtb [dev:][filename]" },
{ "initrd", command_initrd, "initrd [dev:][filename]" },
{ "ls", command_ls, "ls [hdNn:/path]" },
+ { "mem", command_mem, "mem" },
{ "printenv", command_printenv, "printenv [key]" },
{ "setenv", command_setenv, "setenv <key> <value>" },
{ "clearenv", command_clearenv, "clearenv <key>" },
@@ -154,6 +174,28 @@
}
void
+command_mem(char *arg)
+{
+ EFI_MEMORY_DESCRIPTOR *md, *memmap;
+ UINTN nentries, mapkey, descsize;
+ UINT32 descver;
+ int n;
+
+ printf("Type Start End Attributes\n");
+ printf("---------------------- ---------------- ---------------- ----------------\n");
+ memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver);
+ for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
+ const char *mem_type = "<unknown>";
+ if (md->Type < __arraycount(efi_memory_type))
+ mem_type = efi_memory_type[md->Type];
+
+ printf("%-22s %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n",
+ mem_type, md->PhysicalStart, md->PhysicalStart + (md->NumberOfPages * EFI_PAGE_SIZE) - 1,
+ md->Attribute);
+ }
+}
+
+void
command_printenv(char *arg)
{
char *val;
diff -r 31f94bda65ce -r 14bf4c88eab5 sys/stand/efiboot/efifdt.c
--- a/sys/stand/efiboot/efifdt.c Thu Nov 01 20:34:49 2018 +0000
+++ b/sys/stand/efiboot/efifdt.c Fri Nov 02 01:22:39 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.12 2018/11/01 00:43:38 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.13 2018/11/02 01:22:39 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -152,12 +152,6 @@
memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver);
for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
-#ifdef EFI_MEMORY_DEBUG
- printf("MEM: %u: Type 0x%x Attr 0x%lx Phys 0x%lx Virt 0x%lx Size 0x%lx\n",
- n, md->Type, md->Attribute,
- md->PhysicalStart, md->VirtualStart,
- (u_long)md->NumberOfPages * EFI_PAGE_SIZE);
-#endif
if ((md->Attribute & EFI_MEMORY_RUNTIME) != 0)
continue;
if ((md->Attribute & EFI_MEMORY_WB) == 0)
Home |
Main Index |
Thread Index |
Old Index