From owner-svn-src-stable@freebsd.org Fri Sep 14 14:06:34 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3689F10896AA; Fri, 14 Sep 2018 14:06:34 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E0836832C6; Fri, 14 Sep 2018 14:06:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C1D9025677; Fri, 14 Sep 2018 14:06:33 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w8EE6XH2082865; Fri, 14 Sep 2018 14:06:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8EE6XPF082864; Fri, 14 Sep 2018 14:06:33 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809141406.w8EE6XPF082864@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 14 Sep 2018 14:06:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r338680 - stable/11/sbin/sysctl X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sbin/sysctl X-SVN-Commit-Revision: 338680 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Sep 2018 14:06:34 -0000 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 = ""; printf("\n%23s %012lx %12p %08lx ", type, map->md_phys, map->md_virt, map->md_pages);