Author: kib
Date: Fri Sep 14 14:06:33 2018
New Revision: 338680
URL: https://svnweb.freebsd.org/changeset/base/338680

Log:
  MFC r338522, r338523, r338533:
  Teach sysctl(8) about the Persistent memory type.
  Improve nearby code.

Modified:
  stable/11/sbin/sysctl/sysctl.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/sysctl/sysctl.c
==============================================================================
--- stable/11/sbin/sysctl/sysctl.c      Fri Sep 14 13:41:37 2018        
(r338679)
+++ stable/11/sbin/sysctl/sysctl.c      Fri Sep 14 14:06:33 2018        
(r338680)
@@ -688,21 +688,22 @@ S_efi_map(size_t l2, void *p)
        size_t efisz;
        int ndesc, i;
 
-       static const char *types[] = {
-               "Reserved",
-               "LoaderCode",
-               "LoaderData",
-               "BootServicesCode",
-               "BootServicesData",
-               "RuntimeServicesCode",
-               "RuntimeServicesData",
-               "ConventionalMemory",
-               "UnusableMemory",
-               "ACPIReclaimMemory",
-               "ACPIMemoryNVS",
-               "MemoryMappedIO",
-               "MemoryMappedIOPortSpace",
-               "PalCode"
+       static const char * const types[] = {
+               [EFI_MD_TYPE_NULL] =    "Reserved",
+               [EFI_MD_TYPE_CODE] =    "LoaderCode",
+               [EFI_MD_TYPE_DATA] =    "LoaderData",
+               [EFI_MD_TYPE_BS_CODE] = "BootServicesCode",
+               [EFI_MD_TYPE_BS_DATA] = "BootServicesData",
+               [EFI_MD_TYPE_RT_CODE] = "RuntimeServicesCode",
+               [EFI_MD_TYPE_RT_DATA] = "RuntimeServicesData",
+               [EFI_MD_TYPE_FREE] =    "ConventionalMemory",
+               [EFI_MD_TYPE_BAD] =     "UnusableMemory",
+               [EFI_MD_TYPE_RECLAIM] = "ACPIReclaimMemory",
+               [EFI_MD_TYPE_FIRMWARE] = "ACPIMemoryNVS",
+               [EFI_MD_TYPE_IOMEM] =   "MemoryMappedIO",
+               [EFI_MD_TYPE_IOPORT] =  "MemoryMappedIOPortSpace",
+               [EFI_MD_TYPE_PALCODE] = "PalCode",
+               [EFI_MD_TYPE_PERSISTENT] = "PersistentMemory",
        };
 
        /*
@@ -715,7 +716,7 @@ S_efi_map(size_t l2, void *p)
        }
        efihdr = p;
        efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
-       map = (struct efi_md *)((uint8_t *)efihdr + efisz); 
+       map = (struct efi_md *)((uint8_t *)efihdr + efisz);
 
        if (efihdr->descriptor_size == 0)
                return (0);
@@ -723,7 +724,7 @@ S_efi_map(size_t l2, void *p)
                warnx("S_efi_map length mismatch %zu vs %zu", l2, efisz +
                    efihdr->memory_size);
                return (1);
-       }               
+       }
        ndesc = efihdr->memory_size / efihdr->descriptor_size;
 
        printf("\n%23s %12s %12s %8s %4s",
@@ -731,9 +732,10 @@ S_efi_map(size_t l2, void *p)
 
        for (i = 0; i < ndesc; i++,
            map = efi_next_descriptor(map, efihdr->descriptor_size)) {
-               if (map->md_type <= EFI_MD_TYPE_PALCODE)
+               type = NULL;
+               if (map->md_type < nitems(types))
                        type = types[map->md_type];
-               else
+               if (type == NULL)
                        type = "<INVALID>";
                printf("\n%23s %012lx %12p %08lx ", type, map->md_phys,
                    map->md_virt, map->md_pages);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to