On Fri, Sep 07, 2018 at 09:00:20AM -0700, John Baldwin wrote:
> On 9/7/18 8:09 AM, Konstantin Belousov wrote:
> > Author: kib
> > Date: Fri Sep 7 15:09:56 2018
> > New Revision: 338523
> > URL: https://svnweb.freebsd.org/changeset/base/338523
> >
> > Log:
> > Teach sysctl(8) about the Persistent memory type.
> >
> > Add PersistentMemory to the list of sysctl's known memory types
> > when decoding an EFI memory map.
> >
> > Submitted by: D Scott Phillips <[email protected]>
> > MFC after: 1 week
> > Approved by: re (rgrimes)
> >
> > Modified:
> > head/sbin/sysctl/sysctl.c
> >
> > Modified: head/sbin/sysctl/sysctl.c
> > ==============================================================================
> > --- head/sbin/sysctl/sysctl.c Fri Sep 7 14:37:44 2018
> > (r338522)
> > +++ head/sbin/sysctl/sysctl.c Fri Sep 7 15:09:56 2018
> > (r338523)
> > @@ -704,7 +704,8 @@ S_efi_map(size_t l2, void *p)
> > "ACPIMemoryNVS",
> > "MemoryMappedIO",
> > "MemoryMappedIOPortSpace",
> > - "PalCode"
> > + "PalCode",
> > + "PersistentMemory"
> > };
> >
> > /*
> > @@ -733,7 +734,7 @@ 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)
> > + if (map->md_type <= EFI_MD_TYPE_PERSISTENT)
>
> Perhaps this should use nitems(types) instead? (And I believe it's my
> fault it didn't originally.)
For me, it was more an issue that the code assumes contiguous values for
the EFI_MD_TYPEs constants.
What about the following:
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index 427f3e2309b..3a7463ef411 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -691,21 +691,21 @@ S_efi_map(size_t l2, void *p)
int ndesc, i;
static const char *types[] = {
- "Reserved",
- "LoaderCode",
- "LoaderData",
- "BootServicesCode",
- "BootServicesData",
- "RuntimeServicesCode",
- "RuntimeServicesData",
- "ConventionalMemory",
- "UnusableMemory",
- "ACPIReclaimMemory",
- "ACPIMemoryNVS",
- "MemoryMappedIO",
- "MemoryMappedIOPortSpace",
- "PalCode",
- "PersistentMemory"
+ [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",
};
/*
@@ -734,9 +734,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_PERSISTENT)
+ type = NULL;
+ if (map->md_type < nitems(types))
type = types[map->md_type];
- else
+ if (type == NULL)
type = "<INVALID>";
printf("\n%23s %012jx %12p %08jx ", type,
(uintmax_t)map->md_phys, map->md_virt,
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"