From nobody Tue Feb 10 14:33:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76934+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76934+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446354; cv=none; d=zohomail.com; s=zohoarc; b=BOESIypcT69Db7kSYgpyKrZDorwiuFjVCDMlXk7P6my+VDVt0jPRK6S/eet4wxmOjPS3eoeUczAs1Lp4YO4kRMawguWqSGS5a1DsbTj0VK7Y7x5mE67NI3Md6NabnfMdkSXJuTq5Wptwg6gGAcufdHGtMIXViXAl7SxUpGb7XTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446354; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=QV5jiJiPVfoyrwKI3rruxYAFuotx1hibfTacCfxSpIw=; b=ZH2wl8cTTAPnEhGP0feGSIJl65wSjosd7DKH3/B3hoKOexLYHucnW/nqA8V9aesS0f4Zmzenyw6O4TVqaUPX+pmD0MedMI0nSz2dycX+5qtoZdasJGd6XMy+WPQ0cptr6WyotmCzMh8ZvD2zmPsn5zvo6FByK76bzljE2yErkWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76934+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446354627441.77587329362586; Wed, 23 Jun 2021 04:05:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SXCwYY1788612xY5GarLv4xz; Wed, 23 Jun 2021 04:05:54 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5935.1624446348595156657 for ; Wed, 23 Jun 2021 04:05:48 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4243931B; Wed, 23 Jun 2021 04:05:48 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 376C03F719; Wed, 23 Jun 2021 04:05:47 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 05/10] DynamicTablesPkg: Add AmlGetEisaIdFromString() to AcpiHelperLib Date: Wed, 23 Jun 2021 12:05:19 +0100 Message-Id: <20210623110525.6171-6-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 8ruurpFOCytT6xYmDhhpdyMPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446354; bh=4iDJkbIlR9fe8faots9NCsKiqK7E71d6GRaRKdssvpg=; h=Date:From:Reply-To:Subject:To; b=GN+tgHxDWJNw3BOT3lw6AER/HHI7Eal6Z8tVKglnlhNNF67A84XVhut3cFNVjPl1aAE YAr4iasywgdqC1px4k5P5v676MlpdupoorygqKvkxCdCPU6kUG4rJa40u2FhdnUdKCGqZ rUPVdGFYPC/Dq+P0zOeEprfqU7VXqvViFu0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a function converting a 7 characters string to its UINT32 EISAID. The algorithm used to create the EISAID is described in the ACPI 6.4 specification, s19.3.4 "ASL Macros". Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Include/Library/AcpiHelperLib.h | 17 +++++ .../Library/Common/AcpiHelperLib/AcpiHelper.c | 69 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h index eec0cf75e084..e7962a2b931a 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -71,4 +71,21 @@ IsValidAcpiId ( IN CONST CHAR8 * Hid ); =20 +/** Convert a EisaId string to its compressed UINT32 equivalent. + + Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid" + + @param [in] EisaIdStr Input EisaId string. + @param [out] EisaIdInt Output EisaId UINT32 (compressed). + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlGetEisaIdFromString ( + IN CONST CHAR8 * EisaIdStr, + OUT UINT32 * EisaIdInt + ); + #endif // ACPI_HELPER_LIB_H_ diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c b/D= ynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c index c7097c8ff432..4b6756054c0c 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -137,3 +137,72 @@ IsValidAcpiId ( =20 return TRUE; } + +/** Convert a EisaId string to its compressed UINT32 equivalent. + + Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid" + + @param [in] EisaIdStr Input EisaId string. + @param [out] EisaIdInt Output EisaId UINT32 (compressed). + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlGetEisaIdFromString ( + IN CONST CHAR8 * EisaIdStr, + OUT UINT32 * EisaIdInt + ) +{ + if ((EisaIdStr =3D=3D NULL) || + (!IsValidPnpId (EisaIdStr)) || + (EisaIdInt =3D=3D NULL)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + /* Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid" + + Converts and compresses the 7-character text argument into its correspon= ding + 4-byte numeric EISA ID encoding (Integer). This can be used when declari= ng + IDs for devices that are EISA IDs. + + The algorithm used to convert the TextID is as shown in the following + example: + Starting with a seven character input string "PNP0303", we want to cre= ate + a DWordConst. This string contains a three character manufacturer code + "PNP", a three character hex product identifier "030", and a one chara= cter + revision identifier "3". + The compressed manufacturer code is created as follows: + 1) Find hex ASCII value for each letter + 2) Subtract 40h from each ASCII value + 3) Retain 5 least significant bits for each letter and discard remai= ning + 0's: + + Byte 0: + Bit 7: reserved (0) + Bit 6-2: 1st character of compressed mfg code "P" + Bit 1-0: Upper 2 bits of 2nd character of mfg code "N" + Byte 1: + Bit 7-5: Lower 3 bits of 2nd character of mfg code "N" + Bit 4-0: 3rd character of mfg code "P" + Byte 2: + Bit 7-4: 1st hex digit of product number "0" + Bit 3-0: 2nd hex digit of product number "3" + Byte 3: + Bit 7-4: 3rd hex digit of product number "0" + Bit 3-0: 4th hex digit of product number "3" + */ + *EisaIdInt =3D SwapBytes32 ( + ((EisaIdStr[0] - 0x40) << 26) | + ((EisaIdStr[1] - 0x40) << 21) | + ((EisaIdStr[2] - 0x40) << 16) | + (HexFromAscii (EisaIdStr[3]) << 12) | + (HexFromAscii (EisaIdStr[4]) << 8) | + (HexFromAscii (EisaIdStr[5]) << 4) | + (HexFromAscii (EisaIdStr[6])) + ); + + return EFI_SUCCESS; +} --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76934): https://edk2.groups.io/g/devel/message/76934 Mute This Topic: https://groups.io/mt/83735188/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-