From nobody Sun Feb 27 16:47:51 2022 X-Original-To: dev-commits-src-all@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 1500F19EA23E; Sun, 27 Feb 2022 16:47:53 +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 4K68Zc5Sbxz4m3H; Sun, 27 Feb 2022 16:47:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645980472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LOzE1SDNXeQ/qCDzeCDziOolmBOMXVrsiBgLURKZ6zE=; b=hL2dBO7dBBFXAO1SLkw+/dLun6JiNDp9aCsS0PIWDuuRBqqM62Uzr79kzfrp3u3vlTnxfz cU227tRfctPRZoAZ/8ZIqMasCyskUPHurnfHGFCbrfmovgmSKpZ9gJNy7bhw/lGn3PKbUK /8+G0uL3e2Ffc/srlcyblqFMmBdRudOlRI9PdIJ1w6jxhl82h221uMLkdpDatz04JeF3jP XiSZVctm4ytLVtM1w8XNqYC8nqQIu8hzR3UP4HUjPeTLmK07mHea8hqm6p3mCNuc4gl+oA PRqvOFipCD9du256S+BQcE5kXxrvLFCKgtvPd5Ze7Pgr+kNiuKIpH/EawSoKzw== 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 033762C9B; Sun, 27 Feb 2022 16:47:51 +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 21RGlpD0037003; Sun, 27 Feb 2022 16:47:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21RGlpjC037002; Sun, 27 Feb 2022 16:47:51 GMT (envelope-from git) Date: Sun, 27 Feb 2022 16:47:51 GMT Message-Id: <202202271647.21RGlpjC037002@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 965f85271c11 - main - libefivar: Handle USBxxx device path when optional para is not specified List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 965f85271c11e6c5901c09984472fa74d2266e1c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645980472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LOzE1SDNXeQ/qCDzeCDziOolmBOMXVrsiBgLURKZ6zE=; b=MUCv5L0fNvtST+SEvZkoaDGop9M9BU6WHSWTZXfK4c0XN7i/UFjpmwL2h2ABzggdyV329k ygvbEACun4YcdLpvJJCQLMiMKBr4vDrx3j4ne9PCAitC/g7/9pg75xRKFfvnDA1gOHDP6g KbNx8F0ngKiDuZ/31UezV9MuyXza+pH74ZupaxnBXSG7rZj8ZONM2brQWnWne5mdaZEhH0 mCmmrEIhXxu6ZiCtanTiE8OS119EUG1slr9YdErYRMoHaFSSwwKcNG4STluI/ZrbaBwIVG WG+cMVLHbXDGO1bMIamoaykSO+QHc7fEYQusnw8tsU78M+LzTElIHyH1QKrSUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645980472; a=rsa-sha256; cv=none; b=Jbs7cK8xRwkV+TJAmZnnroDnUlErl6YJ2M15QkxKzG0tf5WKpKhD77nTka1yz7mo1EC5kO ORajsflDdK17PfCzghh8PcVQ7vYneoF/pvpzZQt/4NOUO0MQbmtWfPiIk2ZJyCe5TCavY1 +AAPRAFHeqDJyWC3YEzr/9tJVW6aZDz4tjr7pPodqkLm0tIjfJp5zoqIW6ESUDpYDX5pOI lsJ7O1K+Uq6AEGZa8s8L9fEp1GiWf1KvvZJFsImBzuR+XHpwNfxkF/BQv/nP66aqz7XQIL AvLmdQ27aTLgJEyw7vJQHrQC6Yxfyp8gJroZ9SCkV4DPQwz+BYf1Vmf+NgJQ3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=965f85271c11e6c5901c09984472fa74d2266e1c commit 965f85271c11e6c5901c09984472fa74d2266e1c Author: Jose Luis Duran AuthorDate: 2022-02-25 17:54:51 +0000 Commit: Warner Losh CommitDate: 2022-02-27 16:13:24 +0000 libefivar: Handle USBxxx device path when optional para is not specified According to UEFI spec, for the Messaging Device Path with USB Class SubType, some paras are optional in the text device path. Take UsbClass(VID,PID,Class,SubClass,Protocol) for example, The VID is an integer between 0 and 65535 and is optional. The default value is 0xFFFF. The PID is an integer between 0 and 65535 and is optional. The default value is 0xFFFF. The Class is an integer between 0 and 255 and is optional. The default value is 0xFF. The SubClass is an integer between 0 and 255 and is optional. The default value is 0xFF. The Protocol is an integer between 0 and 255 and is optional. The default value is 0xFF. So if any the optional para is not specified in the text device, we should set related para in the node structure to default value. This commit is to do the enhancement for USB Class device path when optional para is not specified. Upstream Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=1243 Obtained from: https://github.com/tianocore/edk2/commit/3874108034eb3f1d5d5180df33a5dfdd5fab5d25 Pull Request: https://github.com/freebsd/freebsd-src/pull/581 --- lib/libefivar/efivar-dp-parse.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c index 303fc9676425..a4c7cff57c06 100644 --- a/lib/libefivar/efivar-dp-parse.c +++ b/lib/libefivar/efivar-dp-parse.c @@ -2185,22 +2185,42 @@ ConvertFromTextUsbClass ( PIDStr = GetNextParamStr (&TextDeviceNode); if (UsbClassText->ClassExist) { ClassStr = GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); + if (*ClassStr == '\0') { + UsbClass->DeviceClass = 0xFF; + } else { + UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); + } } else { UsbClass->DeviceClass = UsbClassText->Class; } if (UsbClassText->SubClassExist) { SubClassStr = GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); + if (*SubClassStr == '\0') { + UsbClass->DeviceSubClass = 0xFF; + } else { + UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); + } } else { UsbClass->DeviceSubClass = UsbClassText->SubClass; } ProtocolStr = GetNextParamStr (&TextDeviceNode); - UsbClass->VendorId = (UINT16) Strtoi (VIDStr); - UsbClass->ProductId = (UINT16) Strtoi (PIDStr); - UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); + if (*VIDStr == '\0') { + UsbClass->VendorId = 0xFFFF; + } else { + UsbClass->VendorId = (UINT16) Strtoi (VIDStr); + } + if (*PIDStr == '\0') { + UsbClass->ProductId = 0xFFFF; + } else { + UsbClass->ProductId = (UINT16) Strtoi (PIDStr); + } + if (*ProtocolStr == '\0') { + UsbClass->DeviceProtocol = 0xFF; + } else { + UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); + } return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass; }