Re: [edk2-devel] [PATCH 1/1] SecurityPkg/TpmCommLib: Remove TpmCommLib
Reviewed-by: Jian J Wang > -Original Message- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Zhang, Shenglei > Sent: Monday, August 05, 2019 1:55 PM > To: devel@edk2.groups.io > Cc: Zhang, Shenglei ; Yao, Jiewen > ; Wang, Jian J ; Zhang, > Chao B > Subject: [edk2-devel] [PATCH 1/1] SecurityPkg/TpmCommLib: Remove > TpmCommLib > > From: shenglei > > TpmCommonLib is no longer used by TcgPei/TcgDxe/Tcg2ConfigPei > modules. So TpmCommLib can be removed. > > Cc: Jiewen Yao > Cc: Jian Wang > Cc: Chao Zhang > Signed-off-by: Shenglei Zhang > --- > SecurityPkg/Library/TpmCommLib/TisPc.c| 177 --- > SecurityPkg/Library/TpmCommLib/TpmComm.c | 44 --- > SecurityPkg/Include/Library/TpmCommLib.h | 281 -- > SecurityPkg/Library/TpmCommLib/CommonHeader.h | 23 -- > SecurityPkg/Library/TpmCommLib/TpmCommLib.inf | 45 --- > SecurityPkg/Library/TpmCommLib/TpmCommLib.uni | 17 -- > SecurityPkg/SecurityPkg.dec | 4 - > SecurityPkg/SecurityPkg.dsc | 2 - > 8 files changed, 593 deletions(-) > delete mode 100644 SecurityPkg/Library/TpmCommLib/TisPc.c > delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmComm.c > delete mode 100644 SecurityPkg/Include/Library/TpmCommLib.h > delete mode 100644 SecurityPkg/Library/TpmCommLib/CommonHeader.h > delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.inf > delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.uni > > diff --git a/SecurityPkg/Library/TpmCommLib/TisPc.c > b/SecurityPkg/Library/TpmCommLib/TisPc.c > deleted file mode 100644 > index 162e883d2170.. > --- a/SecurityPkg/Library/TpmCommLib/TisPc.c > +++ /dev/null > @@ -1,177 +0,0 @@ > -/** @file > - Basic TIS (TPM Interface Specification) functions. > - > -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. > -SPDX-License-Identifier: BSD-2-Clause-Patent > - > -**/ > - > -#include "CommonHeader.h" > - > -/** > - Check whether TPM chip exist. > - > - @param[in] TisReg Pointer to TIS register. > - > - @retvalTRUETPM chip exists. > - @retvalFALSE TPM chip is not found. > -**/ > -BOOLEAN > -TisPcPresenceCheck ( > - IN TIS_PC_REGISTERS_PTR TisReg > - ) > -{ > - UINT8 RegRead; > - > - RegRead = MmioRead8 ((UINTN)>Access); > - return (BOOLEAN)(RegRead != (UINT8)-1); > -} > - > -/** > - Check whether the value of a TPM chip register satisfies the input BIT > setting. > - > - @param[in] Register Address port of register to be checked. > - @param[in] BitSet Check these data bits are set. > - @param[in] BitClear Check these data bits are clear. > - @param[in] TimeOut The max wait time (unit MicroSecond) when > checking register. > - > - @retval EFI_SUCCESS The register satisfies the check bit. > - @retval EFI_TIMEOUT The register can't run into the expected status in > time. > -**/ > -EFI_STATUS > -EFIAPI > -TisPcWaitRegisterBits ( > - IN UINT8 *Register, > - IN UINT8 BitSet, > - IN UINT8 BitClear, > - IN UINT32TimeOut > - ) > -{ > - UINT8 RegRead; > - UINT32WaitTime; > - > - for (WaitTime = 0; WaitTime < TimeOut; WaitTime += 30){ > -RegRead = MmioRead8 ((UINTN)Register); > -if ((RegRead & BitSet) == BitSet && (RegRead & BitClear) == 0) > - return EFI_SUCCESS; > -MicroSecondDelay (30); > - } > - return EFI_TIMEOUT; > -} > - > -/** > - Get BurstCount by reading the burstCount field of a TIS regiger > - in the time of default TIS_TIMEOUT_D. > - > - @param[in] TisRegPointer to TIS register. > - @param[out] BurstCountPointer to a buffer to store the got > BurstConut. > - > - @retval EFI_SUCCESS Get BurstCount. > - @retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is NULL. > - @retval EFI_TIMEOUT BurstCount can't be got in time. > -**/ > -EFI_STATUS > -EFIAPI > -TisPcReadBurstCount ( > - IN TIS_PC_REGISTERS_PTR TisReg, > - OUT UINT16*BurstCount > - ) > -{ > - UINT32WaitTime; > - UINT8 DataByte0; > - UINT8 DataByte1; > - > - if (BurstCount == NULL || TisReg == NULL) { > -return EFI_INVALID_PARAMETER; > - } > - > - WaitTime = 0; > - do { >
Re: [edk2-devel] [PATCH 1/1] SecurityPkg/TpmCommLib: Remove TpmCommLib
Good. Reviewed-by: jiewen@intel.com > -Original Message- > From: Zhang, Shenglei > Sent: Monday, August 5, 2019 1:55 PM > To: devel@edk2.groups.io > Cc: Zhang, Shenglei ; Yao, Jiewen > ; Wang, Jian J ; Zhang, > Chao B > Subject: [PATCH 1/1] SecurityPkg/TpmCommLib: Remove TpmCommLib > > From: shenglei > > TpmCommonLib is no longer used by TcgPei/TcgDxe/Tcg2ConfigPei > modules. So TpmCommLib can be removed. > > Cc: Jiewen Yao > Cc: Jian Wang > Cc: Chao Zhang > Signed-off-by: Shenglei Zhang > --- > SecurityPkg/Library/TpmCommLib/TisPc.c| 177 --- > SecurityPkg/Library/TpmCommLib/TpmComm.c | 44 --- > SecurityPkg/Include/Library/TpmCommLib.h | 281 -- > SecurityPkg/Library/TpmCommLib/CommonHeader.h | 23 -- > SecurityPkg/Library/TpmCommLib/TpmCommLib.inf | 45 --- > SecurityPkg/Library/TpmCommLib/TpmCommLib.uni | 17 -- > SecurityPkg/SecurityPkg.dec | 4 - > SecurityPkg/SecurityPkg.dsc | 2 - > 8 files changed, 593 deletions(-) > delete mode 100644 SecurityPkg/Library/TpmCommLib/TisPc.c > delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmComm.c > delete mode 100644 SecurityPkg/Include/Library/TpmCommLib.h > delete mode 100644 SecurityPkg/Library/TpmCommLib/CommonHeader.h > delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.inf > delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.uni > > diff --git a/SecurityPkg/Library/TpmCommLib/TisPc.c > b/SecurityPkg/Library/TpmCommLib/TisPc.c > deleted file mode 100644 > index 162e883d2170.. > --- a/SecurityPkg/Library/TpmCommLib/TisPc.c > +++ /dev/null > @@ -1,177 +0,0 @@ > -/** @file > - Basic TIS (TPM Interface Specification) functions. > - > -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. > -SPDX-License-Identifier: BSD-2-Clause-Patent > - > -**/ > - > -#include "CommonHeader.h" > - > -/** > - Check whether TPM chip exist. > - > - @param[in] TisReg Pointer to TIS register. > - > - @retvalTRUETPM chip exists. > - @retvalFALSE TPM chip is not found. > -**/ > -BOOLEAN > -TisPcPresenceCheck ( > - IN TIS_PC_REGISTERS_PTR TisReg > - ) > -{ > - UINT8 RegRead; > - > - RegRead = MmioRead8 ((UINTN)>Access); > - return (BOOLEAN)(RegRead != (UINT8)-1); > -} > - > -/** > - Check whether the value of a TPM chip register satisfies the input BIT > setting. > - > - @param[in] Register Address port of register to be checked. > - @param[in] BitSet Check these data bits are set. > - @param[in] BitClear Check these data bits are clear. > - @param[in] TimeOut The max wait time (unit MicroSecond) > when checking register. > - > - @retval EFI_SUCCESS The register satisfies the check bit. > - @retval EFI_TIMEOUT The register can't run into the expected > status in time. > -**/ > -EFI_STATUS > -EFIAPI > -TisPcWaitRegisterBits ( > - IN UINT8 *Register, > - IN UINT8 BitSet, > - IN UINT8 BitClear, > - IN UINT32TimeOut > - ) > -{ > - UINT8 RegRead; > - UINT32WaitTime; > - > - for (WaitTime = 0; WaitTime < TimeOut; WaitTime += 30){ > -RegRead = MmioRead8 ((UINTN)Register); > -if ((RegRead & BitSet) == BitSet && (RegRead & BitClear) == 0) > - return EFI_SUCCESS; > -MicroSecondDelay (30); > - } > - return EFI_TIMEOUT; > -} > - > -/** > - Get BurstCount by reading the burstCount field of a TIS regiger > - in the time of default TIS_TIMEOUT_D. > - > - @param[in] TisRegPointer to TIS register. > - @param[out] BurstCountPointer to a buffer to store the > got BurstConut. > - > - @retval EFI_SUCCESS Get BurstCount. > - @retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is > NULL. > - @retval EFI_TIMEOUT BurstCount can't be got in time. > -**/ > -EFI_STATUS > -EFIAPI > -TisPcReadBurstCount ( > - IN TIS_PC_REGISTERS_PTR TisReg, > - OUT UINT16*BurstCount > - ) > -{ > - UINT32WaitTime; > - UINT8 DataByte0; > - UINT8 DataByte1; > - > - if (BurstCount == NULL || TisReg == NULL) { > -return EFI_INVALID_PARAMETER; > - } > - > - WaitTime = 0; > - do { > -// > -// TIS_PC_REGISTERS_PTR->burstCount is UINT16, but it is not 2bytes > aligned, > -// so it needs to use MmioRead8 to read two times > -// > -DataByte0 = MmioRead8 ((UINTN)>BurstCount); > -DataByte1 = MmioRead8 ((UINTN)>BurstCount + 1); > -*BurstCount = (UINT16)((DataByte1 << 8) + DataByte0); > -if (*BurstCount != 0) { > - return EFI_SUCCESS; > -} > -MicroSecondDelay (30); > -WaitTime += 30; > - } while (WaitTime < TIS_TIMEOUT_D); > - > - return
[edk2-devel] [PATCH 1/1] SecurityPkg/TpmCommLib: Remove TpmCommLib
From: shenglei TpmCommonLib is no longer used by TcgPei/TcgDxe/Tcg2ConfigPei modules. So TpmCommLib can be removed. Cc: Jiewen Yao Cc: Jian Wang Cc: Chao Zhang Signed-off-by: Shenglei Zhang --- SecurityPkg/Library/TpmCommLib/TisPc.c| 177 --- SecurityPkg/Library/TpmCommLib/TpmComm.c | 44 --- SecurityPkg/Include/Library/TpmCommLib.h | 281 -- SecurityPkg/Library/TpmCommLib/CommonHeader.h | 23 -- SecurityPkg/Library/TpmCommLib/TpmCommLib.inf | 45 --- SecurityPkg/Library/TpmCommLib/TpmCommLib.uni | 17 -- SecurityPkg/SecurityPkg.dec | 4 - SecurityPkg/SecurityPkg.dsc | 2 - 8 files changed, 593 deletions(-) delete mode 100644 SecurityPkg/Library/TpmCommLib/TisPc.c delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmComm.c delete mode 100644 SecurityPkg/Include/Library/TpmCommLib.h delete mode 100644 SecurityPkg/Library/TpmCommLib/CommonHeader.h delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.inf delete mode 100644 SecurityPkg/Library/TpmCommLib/TpmCommLib.uni diff --git a/SecurityPkg/Library/TpmCommLib/TisPc.c b/SecurityPkg/Library/TpmCommLib/TisPc.c deleted file mode 100644 index 162e883d2170.. --- a/SecurityPkg/Library/TpmCommLib/TisPc.c +++ /dev/null @@ -1,177 +0,0 @@ -/** @file - Basic TIS (TPM Interface Specification) functions. - -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. -SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "CommonHeader.h" - -/** - Check whether TPM chip exist. - - @param[in] TisReg Pointer to TIS register. - - @retvalTRUETPM chip exists. - @retvalFALSE TPM chip is not found. -**/ -BOOLEAN -TisPcPresenceCheck ( - IN TIS_PC_REGISTERS_PTR TisReg - ) -{ - UINT8 RegRead; - - RegRead = MmioRead8 ((UINTN)>Access); - return (BOOLEAN)(RegRead != (UINT8)-1); -} - -/** - Check whether the value of a TPM chip register satisfies the input BIT setting. - - @param[in] Register Address port of register to be checked. - @param[in] BitSet Check these data bits are set. - @param[in] BitClear Check these data bits are clear. - @param[in] TimeOut The max wait time (unit MicroSecond) when checking register. - - @retval EFI_SUCCESS The register satisfies the check bit. - @retval EFI_TIMEOUT The register can't run into the expected status in time. -**/ -EFI_STATUS -EFIAPI -TisPcWaitRegisterBits ( - IN UINT8 *Register, - IN UINT8 BitSet, - IN UINT8 BitClear, - IN UINT32TimeOut - ) -{ - UINT8 RegRead; - UINT32WaitTime; - - for (WaitTime = 0; WaitTime < TimeOut; WaitTime += 30){ -RegRead = MmioRead8 ((UINTN)Register); -if ((RegRead & BitSet) == BitSet && (RegRead & BitClear) == 0) - return EFI_SUCCESS; -MicroSecondDelay (30); - } - return EFI_TIMEOUT; -} - -/** - Get BurstCount by reading the burstCount field of a TIS regiger - in the time of default TIS_TIMEOUT_D. - - @param[in] TisRegPointer to TIS register. - @param[out] BurstCountPointer to a buffer to store the got BurstConut. - - @retval EFI_SUCCESS Get BurstCount. - @retval EFI_INVALID_PARAMETER TisReg is NULL or BurstCount is NULL. - @retval EFI_TIMEOUT BurstCount can't be got in time. -**/ -EFI_STATUS -EFIAPI -TisPcReadBurstCount ( - IN TIS_PC_REGISTERS_PTR TisReg, - OUT UINT16*BurstCount - ) -{ - UINT32WaitTime; - UINT8 DataByte0; - UINT8 DataByte1; - - if (BurstCount == NULL || TisReg == NULL) { -return EFI_INVALID_PARAMETER; - } - - WaitTime = 0; - do { -// -// TIS_PC_REGISTERS_PTR->burstCount is UINT16, but it is not 2bytes aligned, -// so it needs to use MmioRead8 to read two times -// -DataByte0 = MmioRead8 ((UINTN)>BurstCount); -DataByte1 = MmioRead8 ((UINTN)>BurstCount + 1); -*BurstCount = (UINT16)((DataByte1 << 8) + DataByte0); -if (*BurstCount != 0) { - return EFI_SUCCESS; -} -MicroSecondDelay (30); -WaitTime += 30; - } while (WaitTime < TIS_TIMEOUT_D); - - return EFI_TIMEOUT; -} - -/** - Set TPM chip to ready state by sending ready command TIS_PC_STS_READY - to Status Register in time. - - @param[in] TisRegPointer to TIS register. - - @retvalEFI_SUCCESS TPM chip enters into ready state. - @retvalEFI_INVALID_PARAMETER TisReg is NULL. - @retvalEFI_TIMEOUT TPM chip can't be set to ready state in time. -**/ -EFI_STATUS -EFIAPI -TisPcPrepareCommand ( - IN TIS_PC_REGISTERS_PTR TisReg - ) -{ - EFI_STATUSStatus; - - if (TisReg == NULL) { -return