From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LGut9xFa; spf=pass (domain: gmail.com, ip: 209.85.128.41, mailfrom: pedro.falcato@gmail.com) Received: by mail-wm1-f41.google.com with SMTP id k124-20020a1ca182000000b0038c9cf6e2a6so6517037wme.0 for ; Sat, 26 Mar 2022 17:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sOdty/zi/UcQ34LwfUx19YoKRkiqWQTNc7V3h6kiWc0=; b=LGut9xFamcJUXXV0naVahdfufEKeXl1eoygRys4S6M/yh8N6SwXddZhcZ7j2no4xCo lAR1KbhGRfXZg0qysFKajCDa7cQgKio6lN7BdEoC7GtDDf0F8JzS3clMGTFoqzK8Nm86 ww9iGWrxh7OB3KNXvT8B6FeLYHRsm62Aodz8S27OQxigDI3F6/WDZDa19ryYR2r0RjhO ayXYf6GPV9DoFJ+7x806E8qH1zdv5V7UYmjOtP/sQ+TQWaC4ItaRPAm0utl34UfSMAHs Ubs2dhzmON2hekomwJtXqDm2RPJPhvyIfK/04M7XxrXA1wUiQQlwL6+vqNmR24BTHsCl Waaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sOdty/zi/UcQ34LwfUx19YoKRkiqWQTNc7V3h6kiWc0=; b=XRHIjCkt+GGBtg8UnpGxwvG10zrjXvo56e3eXpMZ0X1ERI/XAmo7LYzhQerwpXOIMT +wNm9HH/FSU810ytq0WhHy0Fcbhs36tNFLb1jqHCGZAbzSIH3vd3jUrfxvgAbPpMav4b aGvTtiBM55naRxdJjYe0RqEpTzOUOqRfyesL6p+mYysMbx3KtzK04WJKBceUjpyBJyI5 rNK+Sl35YyTbs5eA+lFjI2H/njnkwavFJqyVOL6zeKnPBx/EPAMABFIVvt3e9rG2JkXX Z9qPGB0aLaGHqkUKfR31ZEZGgpFYeGMvc+x4yXM8G/BLItG0wFE2rhifoWHWEUgfEdEK HAoQ== X-Gm-Message-State: AOAM53132HV0tgrWCBXMh3j1CLUV2Osa9uJGicQ/tnrPX0BIS+nDR8v/ nXrYXmYyrfvMsgWwZ6z+BUjL/PQTUazcx2vM 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220327005905.92480-1-pedro.falcato@gmail.com> References: <20220327005905.92480-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3871 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/CrcLib.h delete mode 100644 Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.c delete mode 100644 Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.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, which - uses an initial value of 0x0000 and a polynomial of 0x1021. It is the same - 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 should - be set to zero before calling this function. Once the CRC field is updated by - this function, running it again over the structure produces a CRC of zero. - - @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 CRC. - - @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/AcpiPlatformTableLib/AcpiPlatformLibBdat.c b/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/AcpiPlatformLibBdat.c index 09464b4a11d1..a1780ced39aa 100644 --- a/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/AcpiPlatformLibBdat.c +++ b/Platform/Intel/WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/AcpiPlatformLibBdat.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 = 0; - Status = CalculateCrc16 ( + (*BdatHeaderStructPtr)->BdatHeader.Crc16 = CalculateCrc16 ( (VOID *)(*BdatHeaderStructPtr), BdatSize, - &(*BdatHeaderStructPtr)->BdatHeader.Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - (*BdatHeaderStructPtr)->BdatHeader.Crc16 = 0xFFFF; - } + (*BdatHeaderStructPtr)->BdatSchemas.SchemaListLength = NumberOfSchema; (*BdatHeaderStructPtr)->BdatSchemas.Reserved = 0; (*BdatHeaderStructPtr)->BdatSchemas.Reserved1 = 0; @@ -1088,15 +1085,11 @@ SaveBssaResultsToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // BssaSchemaHeaderPtr->Crc16 = 0; - Status = CalculateCrc16 ( + BssaSchemaHeaderPtr->Crc16 = CalculateCrc16 ( (VOID *) BssaSchemaHeaderPtr, sizeof (BDAT_SCHEMA_HEADER_STRUCTURE), - &BssaSchemaHeaderPtr->Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - BssaSchemaHeaderPtr->Crc16 = 0xFFFF; - } if (RemainingHobSizeBssaSchema < CurrentHobSize) { DEBUG ((DEBUG_WARN, "Not enough space to add complete BIOS SSA result\n")); @@ -1217,17 +1210,12 @@ SaveEwlToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // EwlSchemaHeaderPtr->Crc16 = 0; - Status = CalculateCrc16 ( + EwlSchemaHeaderPtr->Crc16 = CalculateCrc16 ( (VOID *)EwlSchemaHeaderPtr, sizeof(BDAT_SCHEMA_HEADER_STRUCTURE), - &EwlSchemaHeaderPtr->Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - EwlSchemaHeaderPtr->Crc16 = 0xFFFF; - } - GuidHob = GetFirstGuidHob (&EWLDataGuid); EwlPrivateData = GET_GUID_HOB_DATA (GuidHob); @@ -1334,17 +1322,12 @@ SaveSpdToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // SpdSchemaHeaderPtr->Crc16 = 0; - Status = CalculateCrc16 ( + SpdSchemaHeaderPtr->Crc16 = CalculateCrc16 ( (VOID *)SpdSchemaHeaderPtr, sizeof(BDAT_SCHEMA_HEADER_STRUCTURE), - &SpdSchemaHeaderPtr->Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - SpdSchemaHeaderPtr->Crc16 = 0xFFFF; - } - Address = Address + sizeof(BDAT_SCHEMA_HEADER_STRUCTURE); *SchemaSpaceUsed = *SchemaSpaceUsed + sizeof(BDAT_SCHEMA_HEADER_STRUCTURE); @@ -1483,17 +1466,12 @@ SaveTrainingDataToBdat ( // CRC16 value of the BDAT_SCHEMA_HEADER_STRUCTURE // SchemaHeaderPtr->Crc16 = 0; - Status = CalculateCrc16 ( + SchemaHeaderPtr->Crc16 = CalculateCrc16 ( (VOID *)SchemaHeaderPtr, sizeof(BDAT_SCHEMA_HEADER_STRUCTURE), - &SchemaHeaderPtr->Crc16 + 0 ); - ASSERT_EFI_ERROR (Status); - if (EFI_ERROR (Status)) { - SchemaHeaderPtr->Crc16 = 0xFFFF; - } - GuidHob = GetFirstGuidHob (&TrainingDataGuid); ASSERT (GuidHob != NULL); diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.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, which - uses an initial value of 0x0000 and a polynomial of 0x1021. It is the same - 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 should - be set to zero before calling this function. Once the CRC field is updated by - this function, running it again over the structure produces a CRC of zero. - - @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 CRC. - - @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 == NULL || CrcOut == NULL) { - return EFI_INVALID_PARAMETER; - } - - Crc = 0x0000; - for (Byte = (UINT8 *) Data; Byte < (UINT8 *) Data + DataSize; Byte++) { - // - // XOR the next data byte into the CRC. - // - Crc ^= (UINT16) *Byte << 8; - // - // Shift out eight bits, feeding back based on the polynomial whenever a - // 1 is shifted out of bit 15. - // - for (Index = 0; Index < 8; Index++) { - Crc <<= 1; - if (Crc & BIT16) { - Crc ^= 0x1021; - } - } - } - - // - // Mask and return the 16-bit CRC. - // - *CrcOut = (UINT16) (Crc & 0xFFFF); - return EFI_SUCCESS; -} diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.inf b/Platform/Intel/WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.inf 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 = 0x00010019 - BASE_NAME = BaseCrcLib - FILE_GUID = F3BE9A28-78A2-4B02-AB26-D27EE85D9256 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = 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/PciSegmentInfoLibSimple.inf PlatformOpromPolicyLib|$(RP_PKG)/Library/PlatformOpromPolicyLibNull/PlatformOpromPolicyLibNull.inf VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf - CrcLib|WhitleyOpenBoardPkg/Library/BaseCrcLib/BaseCrcLib.inf PlatformSpecificAcpiTableLib|WhitleyOpenBoardPkg/Library/PlatformSpecificAcpiTableLibNull/PlatformSpecificAcpiTableLibNull.inf BuildAcpiTablesLib|WhitleyOpenBoardPkg/Library/BuildAcpiTablesLib/DxeBuildAcpiTablesLib.inf AcpiPlatformTableLib|WhitleyOpenBoardPkg/Library/AcpiPlatformTableLib/AcpiPlatformLib.inf -- 2.35.1