From nobody Fri Oct 08 06:11:03 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 10EA612D3F5C; Fri, 8 Oct 2021 06:11:19 +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 4HQd9f0DW3z3LY2; Fri, 8 Oct 2021 06:11:16 +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 3F50621EE0; Fri, 8 Oct 2021 06:11:03 +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 1986B3i8007542; Fri, 8 Oct 2021 06:11:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1986B3CP007541; Fri, 8 Oct 2021 06:11:03 GMT (envelope-from git) Date: Fri, 8 Oct 2021 06:11:03 GMT Message-Id: <202110080611.1986B3CP007541@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 53fdb802567d - stable/12 - libsa: smbios: Parse the chassis type and export it as smbios.chassis.type List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 53fdb802567df401b333fa0aa898908ccabaca93 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=53fdb802567df401b333fa0aa898908ccabaca93 commit 53fdb802567df401b333fa0aa898908ccabaca93 Author: Emmanuel Vadot AuthorDate: 2020-08-20 12:50:49 +0000 Commit: Kyle Evans CommitDate: 2021-10-08 05:24:27 +0000 libsa: smbios: Parse the chassis type and export it as smbios.chassis.type It can be useful to know what type of machine we are running on for desktop related thing. It also allow us to support all the DMI variable that linux driver can fetch. (cherry picked from commit 9060f2c3920dde41226cf52b925bc949815c7f01) --- stand/libsa/smbios.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/stand/libsa/smbios.c b/stand/libsa/smbios.c index c621114d9107..5582a2f3ce90 100644 --- a/stand/libsa/smbios.c +++ b/stand/libsa/smbios.c @@ -209,6 +209,90 @@ smbios_setuuid(const char *name, const caddr_t addr, const int ver) #endif +static const char * +smbios_parse_chassis_type(caddr_t addr) +{ + int type; + + type = SMBIOS_GET8(addr, 0x5); + switch (type) { + case 0x1: + return ("Other"); + case 0x2: + return ("Unknown"); + case 0x3: + return ("Desktop"); + case 0x4: + return ("Low Profile Desktop"); + case 0x5: + return ("Pizza Box"); + case 0x6: + return ("Mini Tower"); + case 0x7: + return ("Tower"); + case 0x8: + return ("Portable"); + case 0x9: + return ("Laptop"); + case 0xA: + return ("Notebook"); + case 0xB: + return ("Hand Held"); + case 0xC: + return ("Docking Station"); + case 0xD: + return ("All in One"); + case 0xE: + return ("Sub Notebook"); + case 0xF: + return ("Lunch Box"); + case 0x10: + return ("Space-saving"); + case 0x11: + return ("Main Server Chassis"); + case 0x12: + return ("Expansion Chassis"); + case 0x13: + return ("SubChassis"); + case 0x14: + return ("Bus Expansion Chassis"); + case 0x15: + return ("Peripheral Chassis"); + case 0x16: + return ("RAID Chassis"); + case 0x17: + return ("Rack Mount Chassis"); + case 0x18: + return ("Sealed-case PC"); + case 0x19: + return ("Multi-system chassis"); + case 0x1A: + return ("Compact PCI"); + case 0x1B: + return ("Advanced TCA"); + case 0x1C: + return ("Blade"); + case 0x1D: + return ("Blade Enclosure"); + case 0x1E: + return ("Tablet"); + case 0x1F: + return ("Convertible"); + case 0x20: + return ("Detachable"); + case 0x21: + return ("IoT Gateway"); + case 0x22: + return ("Embedded PC"); + case 0x23: + return ("Mini PC"); + case 0x24: + return ("Stick PC"); + } + + return ("Undefined"); +} + static caddr_t smbios_parse_table(const caddr_t addr) { @@ -251,6 +335,7 @@ smbios_parse_table(const caddr_t addr) case 3: /* 3.3.4 System Enclosure or Chassis (Type 3) */ smbios_setenv("smbios.chassis.maker", addr, 0x04); + setenv("smbios.chassis.type", smbios_parse_chassis_type(addr), 1); smbios_setenv("smbios.chassis.version", addr, 0x06); #ifdef SMBIOS_SERIAL_NUMBERS smbios_setenv("smbios.chassis.serial", addr, 0x07);