svn commit: r342993 - in stable/12/stand/efi: include libefi loader
Toomas Soome
tsoome at FreeBSD.org
Sun Jan 13 07:19:22 UTC 2019
Author: tsoome
Date: Sun Jan 13 07:19:20 2019
New Revision: 342993
URL: https://svnweb.freebsd.org/changeset/base/342993
Log:
loader.efi: update memmap command to recognize new attributes
Also move memory type to string translation to libefi for later use.
Modified:
stable/12/stand/efi/include/efidef.h
stable/12/stand/efi/include/efilib.h
stable/12/stand/efi/libefi/env.c
stable/12/stand/efi/loader/main.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/stand/efi/include/efidef.h
==============================================================================
--- stable/12/stand/efi/include/efidef.h Sun Jan 13 07:12:50 2019 (r342992)
+++ stable/12/stand/efi/include/efidef.h Sun Jan 13 07:19:20 2019 (r342993)
@@ -157,23 +157,27 @@ typedef enum {
EfiMemoryMappedIO,
EfiMemoryMappedIOPortSpace,
EfiPalCode,
+ EfiPersistentMemory,
EfiMaxMemoryType
} EFI_MEMORY_TYPE;
// possible caching types for the memory range
-#define EFI_MEMORY_UC 0x0000000000000001
-#define EFI_MEMORY_WC 0x0000000000000002
-#define EFI_MEMORY_WT 0x0000000000000004
-#define EFI_MEMORY_WB 0x0000000000000008
-#define EFI_MEMORY_UCE 0x0000000000000010
+#define EFI_MEMORY_UC 0x0000000000000001
+#define EFI_MEMORY_WC 0x0000000000000002
+#define EFI_MEMORY_WT 0x0000000000000004
+#define EFI_MEMORY_WB 0x0000000000000008
+#define EFI_MEMORY_UCE 0x0000000000000010
// physical memory protection on range
-#define EFI_MEMORY_WP 0x0000000000001000
-#define EFI_MEMORY_RP 0x0000000000002000
-#define EFI_MEMORY_XP 0x0000000000004000
+#define EFI_MEMORY_WP 0x0000000000001000
+#define EFI_MEMORY_RP 0x0000000000002000
+#define EFI_MEMORY_XP 0x0000000000004000
+#define EFI_MEMORY_NV 0x0000000000008000
+#define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000
+#define EFI_MEMORY_RO 0x0000000000020000
// range requires a runtime mapping
-#define EFI_MEMORY_RUNTIME 0x8000000000000000
+#define EFI_MEMORY_RUNTIME 0x8000000000000000
#define EFI_MEMORY_DESCRIPTOR_VERSION 1
typedef struct {
Modified: stable/12/stand/efi/include/efilib.h
==============================================================================
--- stable/12/stand/efi/include/efilib.h Sun Jan 13 07:12:50 2019 (r342992)
+++ stable/12/stand/efi/include/efilib.h Sun Jan 13 07:19:20 2019 (r342993)
@@ -108,6 +108,9 @@ void delay(int usecs);
/* EFI environment initialization. */
void efi_init_environment(void);
+/* EFI Memory type strings. */
+const char *efi_memory_type(EFI_MEMORY_TYPE);
+
/* CHAR16 utility functions. */
int wcscmp(CHAR16 *, CHAR16 *);
void cpy8to16(const char *, CHAR16 *, size_t);
Modified: stable/12/stand/efi/libefi/env.c
==============================================================================
--- stable/12/stand/efi/libefi/env.c Sun Jan 13 07:12:50 2019 (r342992)
+++ stable/12/stand/efi/libefi/env.c Sun Jan 13 07:19:20 2019 (r342993)
@@ -47,6 +47,49 @@ efi_init_environment(void)
COMMAND_SET(efishow, "efi-show", "print some or all EFI variables", command_efi_show);
+const char *
+efi_memory_type(EFI_MEMORY_TYPE type)
+{
+ const char *types[] = {
+ "Reserved",
+ "LoaderCode",
+ "LoaderData",
+ "BootServicesCode",
+ "BootServicesData",
+ "RuntimeServicesCode",
+ "RuntimeServicesData",
+ "ConventionalMemory",
+ "UnusableMemory",
+ "ACPIReclaimMemory",
+ "ACPIMemoryNVS",
+ "MemoryMappedIO",
+ "MemoryMappedIOPortSpace",
+ "PalCode",
+ "PersistentMemory"
+ };
+
+ switch (type) {
+ case EfiReservedMemoryType:
+ case EfiLoaderCode:
+ case EfiLoaderData:
+ case EfiBootServicesCode:
+ case EfiBootServicesData:
+ case EfiRuntimeServicesCode:
+ case EfiRuntimeServicesData:
+ case EfiConventionalMemory:
+ case EfiUnusableMemory:
+ case EfiACPIReclaimMemory:
+ case EfiACPIMemoryNVS:
+ case EfiMemoryMappedIO:
+ case EfiMemoryMappedIOPortSpace:
+ case EfiPalCode:
+ case EfiPersistentMemory:
+ return (types[type]);
+ default:
+ return ("Unknown");
+ }
+}
+
static int
efi_print_var(CHAR16 *varnamearg, EFI_GUID *matchguid, int lflag)
{
Modified: stable/12/stand/efi/loader/main.c
==============================================================================
--- stable/12/stand/efi/loader/main.c Sun Jan 13 07:12:50 2019 (r342992)
+++ stable/12/stand/efi/loader/main.c Sun Jan 13 07:19:20 2019 (r342993)
@@ -1041,7 +1041,7 @@ command_quit(int argc, char *argv[])
COMMAND_SET(memmap, "memmap", "print memory map", command_memmap);
static int
-command_memmap(int argc, char *argv[])
+command_memmap(int argc __unused, char *argv[] __unused)
{
UINTN sz;
EFI_MEMORY_DESCRIPTOR *map, *p;
@@ -1050,22 +1050,6 @@ command_memmap(int argc, char *argv[])
EFI_STATUS status;
int i, ndesc;
char line[80];
- static char *types[] = {
- "Reserved",
- "LoaderCode",
- "LoaderData",
- "BootServicesCode",
- "BootServicesData",
- "RuntimeServicesCode",
- "RuntimeServicesData",
- "ConventionalMemory",
- "UnusableMemory",
- "ACPIReclaimMemory",
- "ACPIMemoryNVS",
- "MemoryMappedIO",
- "MemoryMappedIOPortSpace",
- "PalCode"
- };
sz = 0;
status = BS->GetMemoryMap(&sz, 0, &key, &dsz, &dver);
@@ -1091,9 +1075,12 @@ command_memmap(int argc, char *argv[])
for (i = 0, p = map; i < ndesc;
i++, p = NextMemoryDescriptor(p, dsz)) {
- printf("%23s %012jx %012jx %08jx ", types[p->Type],
- (uintmax_t)p->PhysicalStart, (uintmax_t)p->VirtualStart,
- (uintmax_t)p->NumberOfPages);
+ snprintf(line, sizeof(line), "%23s %012jx %012jx %08jx ",
+ efi_memory_type(p->Type), (uintmax_t)p->PhysicalStart,
+ (uintmax_t)p->VirtualStart, (uintmax_t)p->NumberOfPages);
+ if (pager_output(line))
+ break;
+
if (p->Attribute & EFI_MEMORY_UC)
printf("UC ");
if (p->Attribute & EFI_MEMORY_WC)
@@ -1110,6 +1097,12 @@ command_memmap(int argc, char *argv[])
printf("RP ");
if (p->Attribute & EFI_MEMORY_XP)
printf("XP ");
+ if (p->Attribute & EFI_MEMORY_NV)
+ printf("NV ");
+ if (p->Attribute & EFI_MEMORY_MORE_RELIABLE)
+ printf("MR ");
+ if (p->Attribute & EFI_MEMORY_RO)
+ printf("RO ");
if (pager_output("\n"))
break;
}
More information about the svn-src-stable
mailing list