From nobody Tue Feb 10 02:49:58 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+88077+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+88077+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1648342751; cv=none; d=zohomail.com; s=zohoarc; b=nd/kDb9XXy4u10za7I8rVJETna9s3c2vyaU2KOEovqVhZ89+1h15p6SVV9JmWKC4ZagotbGcoUZZZyvD22I6adTkj+sjcyeL0zfrjPCtgRlAbsm91niAvpC36UG3bnfqs83GjCOI8V2dnJ8hs3bKjYimuolVQByU91nQmqAZ3Dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648342751; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=LRLFkz53gG6NQppfPXlnU9NthuEnZ/6NC6ZCV/8opKU=; b=ldcLM1J63mQNyOJ+MODtIl/IZHRClHdLfpp6gXFZDy8yLzb67TKpCoTw4vGT6VRTPFaZn//6p+KkP1fBWKeg4PBn+35BLvpdXNwNWaOF8vjTGYoVdwBurcxxe/ae9vqgC493sUa/AwmtL5tSF/JcoM4EKrWNh8QoRfFviUg0lJY= 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+88077+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 1648342751365892.5155910579737; Sat, 26 Mar 2022 17:59:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id QlseYY1788612xEAJivU3WUY; Sat, 26 Mar 2022 17:59:10 -0700 X-Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mx.groups.io with SMTP id smtpd.web08.1303.1648342749804808627 for ; Sat, 26 Mar 2022 17:59:10 -0700 X-Received: by mail-wm1-f41.google.com with SMTP id k124-20020a1ca182000000b0038c9cf6e2a6so6517037wme.0 for ; Sat, 26 Mar 2022 17:59:09 -0700 (PDT) X-Gm-Message-State: LlyMp4YZRbxTX8OpwegmkdT0x1787277AA= X-Google-Smtp-Source: ABdhPJx6muL1/aafap04UeraBEcwoLwRtICOik6Fu64sChJ4No5KUCPBim17f4hKAy2v382mZwibOQ== X-Received: by 2002:a7b:c94e:0:b0:38c:96ac:7e50 with SMTP id i14-20020a7bc94e000000b0038c96ac7e50mr17537494wml.21.1648342748138; Sat, 26 Mar 2022 17:59:08 -0700 (PDT) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id q8-20020a056000136800b00203e740c7desm8722448wrz.71.2022.03.26.17.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 17:59:07 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Isaac Oram , Nate DeSimone , Chasel Chiu Subject: [edk2-devel] [PATCH edk2-platforms 2/2] WhitleyOpenBoardPkg: Replace BaseCrcLib with BaseLib Date: Sun, 27 Mar 2022 00:59:05 +0000 Message-Id: <20220327005905.92480-3-pedro.falcato@gmail.com> In-Reply-To: <20220327005905.92480-1-pedro.falcato@gmail.com> References: <20220327005905.92480-1-pedro.falcato@gmail.com> MIME-Version: 1.0 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,pedro.falcato@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648342750; bh=6L/rurVLNd2CM9b9blHkg8bYDQ4J10q01jRXnaBbCfY=; h=Cc:Date:From:Reply-To:Subject:To; b=WCPTlud81EIBidc2rQg/2m7QpA62AauAKvEWkcs6h5o+ftU/wSnBA9dpCSXvSo+QUrF TTa3JVKGAvbZj08TZe/TdcKi3l8XmDRWMU2PNIUcMa+sH0YS8fXNOl8H9Qb8Ik1Cpnfoe 9B4nN8Tvj0f5UE6d8nGkAVSjfMg5D8WTruI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648343653650100001 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3871 Delete BaseCrcLib and slightly adjust each CalculateCrc16 call for the BaseLib CalculateCrc16() interface, as part of an effort to unify CRC16 implementations. Cc: Isaac Oram Cc: Nate DeSimone Cc: Chasel Chiu Signed-off-by: Pedro Falcato --- .../Include/Library/CrcLib.h | 42 ----------- .../AcpiPlatformLibBdat.c | 46 ++++-------- .../Library/BaseCrcLib/BaseCrcLib.c | 71 ------------------- .../Library/BaseCrcLib/BaseCrcLib.inf | 23 ------ .../Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc | 1 - 5 files changed, 12 insertions(+), 171 deletions(-) delete mode 100644 Platform/Intel/WhitleyOpenBoardPkg/Include/Library/CrcL= ib.h delete mode 100644 Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/B= aseCrcLib.c delete mode 100644 Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/B= aseCrcLib.inf diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Include/Library/CrcLib.h b/= Platform/Intel/WhitleyOpenBoardPkg/Include/Library/CrcLib.h deleted file mode 100644 index 7ca3b7cabb14..000000000000 --- a/Platform/Intel/WhitleyOpenBoardPkg/Include/Library/CrcLib.h +++ /dev/null @@ -1,42 +0,0 @@ -/** @file - Interface header file for the CRC library class. - - @copyright - Copyright 2016 - 2018 Intel Corporation.
- - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#ifndef _CRC_LIB_H_ -#define _CRC_LIB_H_ - -#include - -/** - Calculate a 16-bit CRC. - - The algorithm used is MSB-first form of the ITU-T Recommendation V.41, w= hich - uses an initial value of 0x0000 and a polynomial of 0x1021. It is the sa= me - algorithm used by XMODEM. - - The output CRC location is not updated until the calculation is finished= , so - it is possible to pass a structure as the data, and the CRC field of the= same - structure as the output location for the calculated CRC. The CRC field s= hould - be set to zero before calling this function. Once the CRC field is updat= ed by - this function, running it again over the structure produces a CRC of zer= o. - - @param[in] Data A pointer to the target data. - @param[in] DataSize The target data size. - @param[out] CrcOut A pointer to the return location of the CR= C. - - @retval EFI_SUCCESS The CRC was calculated successfully. - @retval EFI_INVALID_PARAMETER A null pointer was provided. -**/ -EFI_STATUS -CalculateCrc16 ( - IN VOID *Data, - IN UINTN DataSize, - OUT UINT16 *CrcOut - ); - -#endif // _CRC_LIB_H_ diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPlatformTableLi= b/AcpiPlatformLibBdat.c b/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPl= atformTableLib/AcpiPlatformLibBdat.c index 09464b4a11d1..a1780ced39aa 100644 --- a/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/AcpiP= latformLibBdat.c +++ b/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/AcpiP= latformLibBdat.c @@ -11,9 +11,9 @@ // Statements that include other files // #include "AcpiPlatformLibLocal.h" -#include #include #include +#include #include #include #include @@ -287,15 +287,12 @@ CreateBdatHeader ( // CRC16 value of the BDAT_STRUCTURE // (*BdatHeaderStructPtr)->BdatHeader.Crc16 =3D 0; - Status =3D CalculateCrc16 ( + (*BdatHeaderStructPtr)->BdatHeader.Crc16 =3D CalculateCrc16 ( (VOID *)(*BdatHeaderStructPtr), BdatSize, - &(*BdatHeaderStructPtr)->BdatHeader.Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - (*BdatHeaderStructPtr)->BdatHeader.Crc16 =3D 0xFFFF; - } + (*BdatHeaderStructPtr)->BdatSchemas.SchemaListLength =3D NumberOfSchema; (*BdatHeaderStructPtr)->BdatSchemas.Reserved =3D 0; (*BdatHeaderStructPtr)->BdatSchemas.Reserved1 =3D 0; @@ -1088,15 +1085,11 @@ SaveBssaResultsToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // BssaSchemaHeaderPtr->Crc16 =3D 0; - Status =3D CalculateCrc16 ( + BssaSchemaHeaderPtr->Crc16 =3D CalculateCrc16 ( (VOID *) BssaSchemaHeaderPtr, sizeof (BDAT_SCHEMA_HEADER_STRUCTURE), - &BssaSchemaHeaderPtr->Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - BssaSchemaHeaderPtr->Crc16 =3D 0xFFFF; - } =20 if (RemainingHobSizeBssaSchema < CurrentHobSize) { DEBUG ((DEBUG_WARN, "Not enough space to add complete BIOS SSA res= ult\n")); @@ -1217,17 +1210,12 @@ SaveEwlToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // EwlSchemaHeaderPtr->Crc16 =3D 0; - Status =3D CalculateCrc16 ( + EwlSchemaHeaderPtr->Crc16 =3D CalculateCrc16 ( (VOID *)EwlSchemaHeaderPtr, sizeof(BDAT_SCHEMA_HEADER_STRUCTURE), - &EwlSchemaHeaderPtr->Crc16 + 0 ); =20 - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - EwlSchemaHeaderPtr->Crc16 =3D 0xFFFF; - } - GuidHob =3D GetFirstGuidHob (&EWLDataGuid); EwlPrivateData =3D GET_GUID_HOB_DATA (GuidHob); =20 @@ -1334,17 +1322,12 @@ SaveSpdToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // SpdSchemaHeaderPtr->Crc16 =3D 0; - Status =3D CalculateCrc16 ( + SpdSchemaHeaderPtr->Crc16 =3D CalculateCrc16 ( (VOID *)SpdSchemaHeaderPtr, sizeof(BDAT_SCHEMA_HEADER_STRUCTURE), - &SpdSchemaHeaderPtr->Crc16 + 0 ); =20 - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - SpdSchemaHeaderPtr->Crc16 =3D 0xFFFF; - } - Address =3D Address + sizeof(BDAT_SCHEMA_HEADER_STRUCTURE); *SchemaSpaceUsed =3D *SchemaSpaceUsed + sizeof(BDAT_SCHEMA_HEADER_STRUCT= URE); =20 @@ -1483,17 +1466,12 @@ SaveTrainingDataToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // SchemaHeaderPtr->Crc16 =3D 0; - Status =3D CalculateCrc16 ( + SchemaHeaderPtr->Crc16 =3D CalculateCrc16 ( (VOID *)SchemaHeaderPtr, sizeof(BDAT_SCHEMA_HEADER_STRUCTURE), - &SchemaHeaderPtr->Crc16 + 0 ); =20 - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - SchemaHeaderPtr->Crc16 =3D 0xFFFF; - } - GuidHob =3D GetFirstGuidHob (&TrainingDataGuid); =20 ASSERT (GuidHob !=3D NULL); diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcL= ib.c b/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.c deleted file mode 100644 index 3e8fa402add3..000000000000 --- a/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.c +++ /dev/null @@ -1,71 +0,0 @@ -/** @file - Base implementation of the CRC library class. - - @copyright - Copyright 2016 - 2018 Intel Corporation.
- - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#include -#include - -/** - Calculate a 16-bit CRC. - - The algorithm used is MSB-first form of the ITU-T Recommendation V.41, w= hich - uses an initial value of 0x0000 and a polynomial of 0x1021. It is the sa= me - algorithm used by XMODEM. - - The output CRC location is not updated until the calculation is finished= , so - it is possible to pass a structure as the data, and the CRC field of the= same - structure as the output location for the calculated CRC. The CRC field s= hould - be set to zero before calling this function. Once the CRC field is updat= ed by - this function, running it again over the structure produces a CRC of zer= o. - - @param[in] Data A pointer to the target data. - @param[in] DataSize The target data size. - @param[out] CrcOut A pointer to the return location of the CR= C. - - @retval EFI_SUCCESS The CRC was calculated successfully. - @retval EFI_INVALID_PARAMETER A null pointer was provided. -**/ -EFI_STATUS -CalculateCrc16 ( - IN VOID *Data, - IN UINTN DataSize, - OUT UINT16 *CrcOut - ) -{ - UINT32 Crc; - UINTN Index; - UINT8 *Byte; - - if (Data =3D=3D NULL || CrcOut =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - Crc =3D 0x0000; - for (Byte =3D (UINT8 *) Data; Byte < (UINT8 *) Data + DataSize; Byte++) { - // - // XOR the next data byte into the CRC. - // - Crc ^=3D (UINT16) *Byte << 8; - // - // Shift out eight bits, feeding back based on the polynomial whenever= a - // 1 is shifted out of bit 15. - // - for (Index =3D 0; Index < 8; Index++) { - Crc <<=3D 1; - if (Crc & BIT16) { - Crc ^=3D 0x1021; - } - } - } - - // - // Mask and return the 16-bit CRC. - // - *CrcOut =3D (UINT16) (Crc & 0xFFFF); - return EFI_SUCCESS; -} diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcL= ib.inf b/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.i= nf deleted file mode 100644 index 6b404e125959..000000000000 --- a/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.inf +++ /dev/null @@ -1,23 +0,0 @@ -## @file -# Base implementation of the CRC library class. -# -# @copyright -# Copyright 2016 Intel Corporation.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -## - -[Defines] - INF_VERSION =3D 0x00010019 - BASE_NAME =3D BaseCrcLib - FILE_GUID =3D F3BE9A28-78A2-4B02-AB26-D27EE85D9256 - MODULE_TYPE =3D BASE - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D CrcLib - -[Sources] - BaseCrcLib.c - -[Packages] - MdePkg/MdePkg.dec - WhitleyOpenBoardPkg/PlatformPkg.dec diff --git a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc b/Platform/= Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc index 8c4b9cf6ce28..5b9b08feca46 100644 --- a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc +++ b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc @@ -618,7 +618,6 @@ PciSegmentInfoLib|$(PLATFORM_PKG)/Pci/Library/PciSegmentInfoLibSimple/Pc= iSegmentInfoLibSimple.inf PlatformOpromPolicyLib|$(RP_PKG)/Library/PlatformOpromPolicyLibNull/Plat= formOpromPolicyLibNull.inf VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf - CrcLib|WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.inf PlatformSpecificAcpiTableLib|WhitleyOpenBoardPkg/Library/PlatformSpecifi= cAcpiTableLibNull/PlatformSpecificAcpiTableLibNull.inf BuildAcpiTablesLib|WhitleyOpenBoardPkg/Library/BuildAcpiTablesLib/DxeBui= ldAcpiTablesLib.inf AcpiPlatformTableLib|WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/Ac= piPlatformLib.inf --=20 2.35.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 (#88077): https://edk2.groups.io/g/devel/message/88077 Mute This Topic: https://groups.io/mt/90054868/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-