From owner-dev-commits-src-main@freebsd.org Wed Apr 7 20:08:46 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1F5DC5C3482; Wed, 7 Apr 2021 20:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFwSt0N8Nz4jLW; Wed, 7 Apr 2021 20:08:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E922825436; Wed, 7 Apr 2021 20:08:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 137K8jDD083307; Wed, 7 Apr 2021 20:08:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137K8jD7083306; Wed, 7 Apr 2021 20:08:45 GMT (envelope-from git) Date: Wed, 7 Apr 2021 20:08:45 GMT Message-Id: <202104072008.137K8jD7083306@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: f689cb23b278 - main - ipmi, smbios: move smbios_walk_table to smbios.h MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f689cb23b2782d0d0f586bcfabbad68f728ed1df Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 20:08:46 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=f689cb23b2782d0d0f586bcfabbad68f728ed1df commit f689cb23b2782d0d0f586bcfabbad68f728ed1df Author: Greg V AuthorDate: 2021-04-07 20:05:49 +0000 Commit: Eric van Gyzen CommitDate: 2021-04-07 20:05:49 +0000 ipmi,smbios: move smbios_walk_table to smbios.h This function will be used for exposing DMI info as sysctls in the smbios module (in an upcoming review). While here, add __packed to the structs. Reviewed by: dab MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29270 --- sys/dev/ipmi/ipmi_smbios.c | 29 ----------------------------- sys/dev/smbios/smbios.h | 31 +++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/sys/dev/ipmi/ipmi_smbios.c b/sys/dev/ipmi/ipmi_smbios.c index 308a3b076ef7..a1b953365d7c 100644 --- a/sys/dev/ipmi/ipmi_smbios.c +++ b/sys/dev/ipmi/ipmi_smbios.c @@ -79,8 +79,6 @@ struct ipmi_entry { #define SPACING_32 0x1 #define SPACING_16 0x2 -typedef void (*smbios_callback_t)(struct smbios_structure_header *, void *); - static struct ipmi_get_info ipmi_info; static int ipmi_probed; static struct mtx ipmi_info_mtx; @@ -88,8 +86,6 @@ MTX_SYSINIT(ipmi_info, &ipmi_info_mtx, "ipmi info", MTX_DEF); static void ipmi_smbios_probe(struct ipmi_get_info *); static int smbios_cksum(struct smbios_eps *); -static void smbios_walk_table(uint8_t *, int, smbios_callback_t, - void *); static void smbios_ipmi_info(struct smbios_structure_header *, void *); static void @@ -146,31 +142,6 @@ smbios_ipmi_info(struct smbios_structure_header *h, void *arg) info->iface_type = s->interface_type; } -static void -smbios_walk_table(uint8_t *p, int entries, smbios_callback_t cb, void *arg) -{ - struct smbios_structure_header *s; - - while (entries--) { - s = (struct smbios_structure_header *)p; - cb(s, arg); - - /* - * Look for a double-nul after the end of the - * formatted area of this structure. - */ - p += s->length; - while (!(p[0] == 0 && p[1] == 0)) - p++; - - /* - * Skip over the double-nul to the start of the next - * structure. - */ - p += 2; - } -} - /* * Walk the SMBIOS table looking for an IPMI (type 38) entry. If we find * one, return the parsed data in the passed in ipmi_get_info structure and diff --git a/sys/dev/smbios/smbios.h b/sys/dev/smbios/smbios.h index 6503cdb73c4c..ec216b676f2b 100644 --- a/sys/dev/smbios/smbios.h +++ b/sys/dev/smbios/smbios.h @@ -56,12 +56,39 @@ struct smbios_eps { uint32_t structure_table_address; uint16_t number_structures; uint8_t BCD_revision; -}; +} __packed; struct smbios_structure_header { uint8_t type; uint8_t length; uint16_t handle; -}; +} __packed; + +typedef void (*smbios_callback_t)(struct smbios_structure_header *, void *); + +static inline void +smbios_walk_table(uint8_t *p, int entries, smbios_callback_t cb, void *arg) +{ + struct smbios_structure_header *s; + + while (entries--) { + s = (struct smbios_structure_header *)p; + cb(s, arg); + + /* + * Look for a double-nul after the end of the + * formatted area of this structure. + */ + p += s->length; + while (!(p[0] == 0 && p[1] == 0)) + p++; + + /* + * Skip over the double-nul to the start of the next + * structure. + */ + p += 2; + } +} #endif /* _SMBIOS_H_ */