From b7c51c9cf4864df6aabb99a1ae843becd577237c Mon Sep 17 00:00:00 2001 From: raywu Date: Fri, 15 Jun 2018 00:00:50 +0800 Subject: init. 1AQQW051 --- Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.DXS | 85 +++++ Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.c | 373 ++++++++++++++++++++++ Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.cif | 15 + Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.h | 141 +++++++++ Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.mak | 191 +++++++++++ Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.sdl | 72 +++++ Board/EM/TCG2/Common/Tpm20Acpi/TpmCrb.asl | 387 +++++++++++++++++++++++ Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2.asl | 256 +++++++++++++++ Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2_Ex.asl | 301 ++++++++++++++++++ 9 files changed, 1821 insertions(+) create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.DXS create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.c create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.cif create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.h create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.mak create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.sdl create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/TpmCrb.asl create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2.asl create mode 100644 Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2_Ex.asl (limited to 'Board/EM/TCG2/Common/Tpm20Acpi') diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.DXS b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.DXS new file mode 100644 index 0000000..ec6fb4e --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.DXS @@ -0,0 +1,85 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* +//************************************************************************* +//************************************************************************* +// $Header: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.DXS 1 4/21/14 2:19p Fredericko $ +// +// $Revision: 1 $ +// +// $Date: 4/21/14 2:19p $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.DXS $ +// +// 1 4/21/14 2:19p Fredericko +// +// 2 3/14/14 3:50p Fredericko +// +// 1 10/08/13 12:06p Fredericko +// Initial Check-In for Tpm-Next module +// +// 2 8/30/13 11:05p Fredericko +// +// 1 7/10/13 5:58p Fredericko +// [TAG] EIP120969 +// [Category] New Feature +// [Description] TCG (TPM20) +// +// 3 7/25/11 3:21a Fredericko +// [TAG] EIP65177 +// [Category] Spec Update +// [Severity] Minor +// [Description] TCG Ppi Sec ver 1.2 update +// +// 2 5/20/10 8:54a Fredericko +// +// Included File Header +// Included File Revision History +// EIP 37653 +// +//************************************************************************* +// +// +// Name: TCGSmm.dxs +// +// Description: +// Dependency for TcgSmm +// +// +//************************************************************************* +#include "Tpm20Acpi.h" +#include +#include +#include +#include + +DEPENDENCY_START + EFI_ACPI_TABLE_PROTOCOL_GUID AND + EFI_TREE_PROTOCOL_GUID +DEPENDENCY_END + +//************************************************************************* +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.c b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.c new file mode 100644 index 0000000..6d12019 --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.c @@ -0,0 +1,373 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* +//************************************************************************* +// $Header: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.c 2 4/21/14 3:18p Fredericko $ +// +// $Revision: 2 $ +// +// $Date: 4/21/14 3:18p $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.c $ +// +// 2 4/21/14 3:18p Fredericko +// +// 1 4/21/14 2:19p Fredericko +// +// 1 10/08/13 12:06p Fredericko +// Initial Check-In for Tpm-Next module +// +// 2 10/03/13 3:01p Fredericko +// +// 1 7/10/13 5:58p Fredericko +// [TAG] EIP120969 +// [Category] New Feature +// [Description] TCG (TPM20) +//************************************************************************* +// +// +// Name: +// +// Description: +// +// +//************************************************************************* + +#include "Tpm20Acpi.h" +#include +#include +#include "Tpm20CRBLib.h" + + +EFI_TPM2_ACPI_TABLE mTpm2AcpiTemplate = { + { + EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE, + sizeof (mTpm2AcpiTemplate), + EFI_TPM2_ACPI_TABLE_REVISION, + // + // initialize to 0 + // + // + }, + 0, // Flags + (EFI_PHYSICAL_ADDRESS)(UINTN)0xFFFFFFFF, // Control Area + EFI_TPM2_ACPI_TABLE_START_METHOD_ACPI, +}; + + + + +//********************************************************************** +// +// +// Procedure: GetHob +// +// Description: Find instance of a HOB type in a HOB list +// +// Input: +// Type The HOB type to return. +// HobStart The first HOB in the HOB list. +// +// Output: +// Pointer to the Hob matching the type or NULL +// +// Modified: +// +// Referrals: +// +// Notes: +// +//********************************************************************** +VOID* GetHob( + IN UINT16 Type, + IN VOID *HobStart ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = HobStart; + + // + // Return input if not found + // + if ( HobStart == NULL ) + { + return HobStart; + } + + // + // Parse the HOB list, stop if end of list or matching type found. + // + while ( !END_OF_HOB_LIST( Hob )) + { + if ( Hob.Header->HobType == Type ) + { + break; + } + + Hob.Raw = GET_NEXT_HOB( Hob ); + } + + // + // Return input if not found + // + if ( END_OF_HOB_LIST( Hob )) + { + return HobStart; + } + + return (VOID*)(Hob.Raw); +} + +//********************************************************************** +// +// +// Procedure: CompareGuid +// +// Description: Compares two input GUIDs +// +// Input: Comparision status +// +// Output: None +// +// Modified: +// +// Referrals: +// +// Notes: +// +//********************************************************************** +BOOLEAN CompareGuid( + EFI_GUID *G1, + EFI_GUID *G2 ) +{ + UINT32 *p1 = (UINT32*)G1, *p2 = (UINT32*)G2; + UINTN i; + + for ( i = 0; i < 4; ++i ) + { + if ( p1[i] != p2[i] ) + { + return FALSE; + } + } + return TRUE; + ; +} + +//********************************************************************** +// +// +// Procedure: GetNextGuidHob +// +// Description: Find GUID HOB +// +// Input: HobStart A pointer to the start hob. +// Guid A pointer to a guid. +// Output: +// Buffer A pointer to the buffer. +// BufferSize Buffer size. +// +// Modified: +// +// Referrals: +// +// Notes: +// +//********************************************************************** +EFI_STATUS GetNextGuidHob( + IN OUT VOID **HobStart, + IN EFI_GUID * Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL ) +{ + EFI_STATUS Status; + EFI_PEI_HOB_POINTERS GuidHob; + + if ( Buffer == NULL ) + { + return EFI_INVALID_PARAMETER; + } + + for ( Status = EFI_NOT_FOUND; EFI_ERROR( Status );) + { + GuidHob.Raw = *HobStart; + + if ( END_OF_HOB_LIST( GuidHob )) + { + return EFI_NOT_FOUND; + } + + GuidHob.Raw = GetHob( EFI_HOB_TYPE_GUID_EXTENSION, *HobStart ); + + if ( GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION ) + { + if ( CompareGuid( Guid, &GuidHob.Guid->Name )) + { + Status = EFI_SUCCESS; + *Buffer = (VOID*)((UINT8*)(&GuidHob.Guid->Name) + + sizeof (EFI_GUID)); + + if ( BufferSize != NULL ) + { + *BufferSize = GuidHob.Header->HobLength + - sizeof (EFI_HOB_GUID_TYPE); + } + } + } + + *HobStart = GET_NEXT_HOB( GuidHob ); + } + + return Status; +} + + + +VOID* FindHob( + IN UINTN NoTableEntries, + IN EFI_CONFIGURATION_TABLE *ConfigTable, + IN EFI_GUID *HOB_guid ) +{ + VOID *HobStart; + VOID *PtrHob; + EFI_GUID Hoblistguid = HOB_LIST_GUID; + + while ( NoTableEntries > 0 ) + { + NoTableEntries--; + + if ((!MemCmp( + &ConfigTable[NoTableEntries].VendorGuid, + &Hoblistguid, sizeof(EFI_GUID) + ))) + { + HobStart = ConfigTable[NoTableEntries].VendorTable; + + if ( !EFI_ERROR( + GetNextGuidHob( &HobStart, HOB_guid, &PtrHob, NULL ) + )) + { + TRACE ((TRACE_ALWAYS, "Hob found = %x \n", PtrHob)); + return PtrHob; + } + } + } + return NULL; +} + + + +EFI_STATUS +Tpm20PublishAcpiTable ( + VOID + ) +{ + EFI_STATUS Status; + UINTN TableKey = 0; + EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + EFI_TPM2_ACPI_CONTROL_AREA *CtrlAreaMap = NULL; + EFI_GUID Meguid = ME_DATA_HOB_GUID; + INTEL_PTT_HOB_DATA *StolenAddress = NULL; + + mTpm2AcpiTemplate.Header.OemRevision = TPM20TABLEOEMREVISION; + mTpm2AcpiTemplate.Header.CreatorId = CREATOR_ID_AMI; + mTpm2AcpiTemplate.Header.OemTableId = EFI_SIGNATURE_64 ('T', 'p', 'm', '2', 'T', 'a', 'b', 'l'); + + // + // Publish the TPM ACPI table + // + Status = pBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTable); + if(EFI_ERROR(Status))return Status; + + if(!isTpm20CrbPresent()) + { + mTpm2AcpiTemplate.AddressOfControlArea = 0; + mTpm2AcpiTemplate.StartMethod = 6; + }else{ + + StolenAddress = (INTEL_PTT_HOB_DATA *)FindHob ( pST->NumberOfTableEntries, + pST->ConfigurationTable, + &Meguid); + + if(StolenAddress != 0){ + if(((UINTN)((UINT64 *)StolenAddress->BufferAddress)) != 0){ + mTpm2AcpiTemplate.AddressOfControlArea = StolenAddress->BufferAddress; + }else{ + mTpm2AcpiTemplate.AddressOfControlArea = TPM20_CRBBASE; + } + }else{ + mTpm2AcpiTemplate.AddressOfControlArea = TPM20_CRBBASE; + } + + mTpm2AcpiTemplate.StartMethod = 2; + CtrlAreaMap = (EFI_TPM2_ACPI_CONTROL_AREA *)(UINTN) mTpm2AcpiTemplate.AddressOfControlArea; + MemSet (CtrlAreaMap, sizeof(EFI_TPM2_ACPI_CONTROL_AREA), 0); + CtrlAreaMap->CommandSize = 0xF80; + CtrlAreaMap->ResponseSize = 0xF80; + CtrlAreaMap->Command = (UINTN)mTpm2AcpiTemplate.AddressOfControlArea + 0x80; + CtrlAreaMap->Response = (UINTN)mTpm2AcpiTemplate.AddressOfControlArea + 0x80; + + TRACE ((TRACE_ALWAYS, "Ftpm Windows Buffer Control Area Address = %x\n", mTpm2AcpiTemplate.AddressOfControlArea)); + TRACE ((TRACE_ALWAYS, "Ftpm Windows Command/Response Buffer Address = %x\n", CtrlAreaMap->Command)); + } + + TRACE ((TRACE_ALWAYS, " Before Installation of ACPI table \n")); + Status = AcpiTable->InstallAcpiTable (AcpiTable, + &mTpm2AcpiTemplate, + sizeof(EFI_TPM2_ACPI_TABLE), + &TableKey); + + if(EFI_ERROR(Status))return Status; + + return Status; +} + + +EFI_STATUS +EFIAPI +Tpm20AcpiInitEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +) +{ + EFI_STATUS Status; + + InitAmiLib( ImageHandle, SystemTable ); + + Status = Tpm20PublishAcpiTable (); + + return Status; +} + + + + + + + + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.cif b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.cif new file mode 100644 index 0000000..2d62ae1 --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.cif @@ -0,0 +1,15 @@ + + name = "Tpm20Acpi" + category = ModulePart + LocalRoot = "Board\EM\TCG2\Common\Tpm20Acpi" + RefName = "Tpm20Acpi" +[files] +"Tpm20Acpi.sdl" +"Tpm20Acpi.mak" +"Tpm20Acpi.h" +"Tpm20Acpi.c" +"Tpm20Acpi.DXS" +"TpmCrb.asl" +"tcg_ppi1_2_Ex.asl" +"tcg_ppi1_2.asl" + diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.h b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.h new file mode 100644 index 0000000..d07ee42 --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.h @@ -0,0 +1,141 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* +//************************************************************************* +// $Header: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.h 1 4/21/14 2:19p Fredericko $ +// +// $Revision: 1 $ +// +// $Date: 4/21/14 2:19p $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.h $ +// +// 1 4/21/14 2:19p Fredericko +// +// 1 10/08/13 12:06p Fredericko +// Initial Check-In for Tpm-Next module +// +// 1 7/10/13 5:58p Fredericko +// [TAG] EIP120969 +// [Category] New Feature +// [Description] TCG (TPM20) +// +// +//************************************************************************* +// +// +// Name: +// +// Description: +// +// +//************************************************************************* +#ifndef _TPM20ACPI_H_ +#define _TPM20ACPI_H_ + +#include +#include +#include + +#define ME_DATA_HOB_GUID \ + { 0x1e94f097, 0x5acd, 0x4089, 0xb2, 0xe3, 0xb9, 0xa5, 0xc8, 0x79, 0xa7, 0x0c } + +#define INTERNAL_NVS_AREA_PROTOCOL_GUID \ + { \ + 0x74e1e48, 0x8132, 0x47a1, 0x8c, 0x2c, 0x3f, 0x14, 0xad, 0x9a, 0x66, 0xdc \ + } + +#define EFI_SIGNATURE_16(A, B) ((A) | (B << 8)) +#define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16)) + +#ifndef EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE +#define EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE EFI_SIGNATURE_32('T', 'P', 'M', '2') + +#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \ + (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32)) + +#endif + +#define TPM20TABLEOEMREVISION 1 +#define CREATOR_ID_AMI 0x20494D41 //" IMA""AMI "(AMI) +#define EFI_TPM2_ACPI_TABLE_START_METHOD_ACPI 2 +#define EFI_TPM2_ACPI_TABLE_REVISION 3 + +#pragma pack (1) + + +typedef struct { + UINT32 Signature; + UINT32 Length; + UINT8 Revision; + UINT8 Checksum; + UINT8 OemId[6]; + UINT64 OemTableId; + UINT32 OemRevision; + UINT32 CreatorId; + UINT32 CreatorRevision; +} EFI_ACPI_DESCRIPTION_HEADER; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Flags; + UINT64 AddressOfControlArea; + UINT32 StartMethod; +} EFI_TPM2_ACPI_TABLE; + +typedef struct { + UINT32 Reserved; + UINT32 Error; + UINT32 Cancel; + UINT32 Start; + UINT64 InterruptControl; + UINT32 CommandSize; + UINT64 Command; + UINT32 ResponseSize; + UINT64 Response; +} EFI_TPM2_ACPI_CONTROL_AREA; + +typedef struct { + UINT64 BufferAddress; +}INTEL_PTT_HOB_DATA; + +#pragma pack () + +#define GET_HOB_TYPE( Hob ) ((Hob).Header->HobType) +#define GET_HOB_LENGTH( Hob ) ((Hob).Header->HobLength) +#define GET_NEXT_HOB( Hob ) ((Hob).Raw + GET_HOB_LENGTH( Hob )) +#define END_OF_HOB_LIST( Hob ) (GET_HOB_TYPE( Hob ) ==\ + EFI_HOB_TYPE_END_OF_HOB_LIST) + +EFI_STATUS GetNextGuidHob( + IN OUT VOID **HobStart, + IN EFI_GUID * Guid, + OUT VOID **Buffer, + OUT UINTN *BufferSize OPTIONAL ); + +#endif +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2005, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 6145-F Northbelt Pkwy, Norcross, GA 30071 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.mak b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.mak new file mode 100644 index 0000000..40a658f --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.mak @@ -0,0 +1,191 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2010, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* +#************************************************************************* +# $Header: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.mak 3 4/30/14 11:55a Fredericko $ +# +# $Revision: 3 $ +# +# $Date: 4/30/14 11:55a $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/TCG2/Common/Tpm20PlatformDxe/Tpm20Acpi/Tpm20Acpi.mak $ +# +# 3 4/30/14 11:55a Fredericko +# +# 2 4/25/14 4:46p Fredericko +# Use Fixed memory descriptor to prevent O.S. from reassigning TPM +# resources +# +# 1 4/21/14 2:19p Fredericko +# +# 3 3/14/14 3:51p Fredericko +# +# 2 3/11/14 6:51p Fredericko +# [TAG] EIP151925 +# [Category] New Feature +# [Description] Changes for TcgGeneric Regression Testing +# +# 1 10/08/13 12:06p Fredericko +# Initial Check-In for Tpm-Next module +# +# 2 7/11/13 6:18p Fredericko +# +# 1 7/10/13 5:58p Fredericko +# [TAG] EIP120969 +# [Category] New Feature +# [Description] TCG (TPM20) +# +# 4 12/07/11 4:30p Fredericko +# [TAG] EIP59683 +# [Category] Improvement +# [Description] Allow selection between writing to SMI port as a word +# or as a Byte. +# Some platforms might require word writes to the SMI Status port. +# [Files] Tcg.cif, Tcg.sdl, Tcg_ppi1_2_Ex.asl, TcgSmm.mak, TcgSmm.c +# +# 3 8/09/10 2:32p Fredericko +# +# 2 5/20/10 8:50a Fredericko +# Included File Header +# Included File Revision History +# EIP 37653 +# +#************************************************************************* +# +# +# Name: TCGSmm.mak +# +# Description: +# Make file for TCG SMM module +# +# +#************************************************************************* +all : Tpm20Acpi + +Tpm20Acpi : $(BUILD_DIR)\Tpm20Acpi.mak Tpm20AcpiBin + +$(BUILD_DIR)\Tpm20Acpi.mak : $(TPM20ACPI_DIR)\Tpm20Acpi.cif $(TPM20ACPI_DIR)\Tpm20Acpi.mak $(BUILD_RULES) + $(CIF2MAK) $(TPM20ACPI_DIR)\Tpm20Acpi.cif $(CIF2MAK_DEFAULTS) + +Tpm20PlatformFlags=$(CFLAGS) \ + /I$(TCG_DIR)\ + /I$(TCG_DIR)\Common\ + /I$(PROJECT_DIR)\Include\Protocol\ + /I$(TCG_DIR)\Protocol\ + /I$(TPM20_CRBLIB)\ + +Tpm20AcpiBin : $(AMICSPLib) $(AMIDXELIB) $(BUILD_DIR)\Tpm20CRBLib.lib + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\Tpm20Acpi.mak all\ + "CFLAGS=$(Tpm20PlatformFlags) "\ + "CPFLAGS=$(Tpm20PlatformFlags) "\ + GUID=4C8BDF60-2085-4577-8A46-96CB180967BC\ + ENTRY_POINT=Tpm20AcpiInitEntry\ + TYPE=BS_DRIVER \ + COMPRESS=1\ + + +$(BUILD_DIR)\tpm.asl: $(TPM20ACPI_DIR)\Tpm20Acpi.mak + copy << $@ +//tpm.asl +Device(\_SB.PCI0.TPM) + { + Method(_HID, 0){ //PnP Device ID + If(TCMF) + { + Return(EISAID("ZIT0101")) + } + Else + { + If(LEqual(TTDP, 0)){ + Return(EISAID("PNP0C31")) + }else{ + Return("MSFT0101") + } + } + } + + + Method(_STR,0) + { + If(LEqual(TTDP, 0)){ + Return (Unicode ("TPM 1.2 Device")) + }else { + Return (Unicode ("TPM 2.0 Device")) + } + } + + Name(_UID,0x01) + Name(CRST,ResourceTemplate() + { + Memory32Fixed (ReadOnly, 0xFED40000, 0x5000,PCRS) + }) + + OperationRegion(TMMB, SystemMemory, 0x0FED40000, 0x5000) + Field(TMMB, ByteAcc, Lock, Preserve) + { + Offset(0x0000), + ACCS, 8, // Access + Offset(0x0018), + TSTA, 8, // Status + TBCA, 8, // Burst Count + Offset(0x0F00), + TVID, 16, // TPM Chip VID + TDID, 16 // TPM Chip DID + } + + Method(_STA, 0){ + If(LEqual(TTDP, 0)){ + If(TPMF){ + Return(0x0F) // TPM Support + } + Return(0x00) // No TPM Support + }ElseIF(LEqual(TTDP, 1)){ + if(TTPF){ + Return(0x0F) // TPM Support + } + } + Return(0x00) // No TPM Support + } + + Method(_CRS, 0, Serialized) + { + If(LEqual(TTPF, 1)) + { + CreateDWordField(CRST, ^PCRS._BAS, MTFD) // Min + CreateDWordField(CRST, ^PCRS._LEN, LTFD) // Length + + Store(0x0FED40000, MTFD) + Store(0x00005000, LTFD) + } + + Return (CRST) + } + + } +<< +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2010, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* \ No newline at end of file diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.sdl b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.sdl new file mode 100644 index 0000000..850243a --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/Tpm20Acpi.sdl @@ -0,0 +1,72 @@ +TOKEN + Name = "TPM20ACPI_SUPPORT" + Value = "1" + Help = "Main switch to enable TCGSMM support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + Master = Yes + Token = "TPM20Enabled" "!=" "0" +End + +PATH + Name = "TPM20ACPI_DIR" +End + +MODULE + Help = "Includes Tpm20Acpi.mak to Project" + File = "Tpm20Acpi.mak" +End + +ELINK + Name = "$(BUILD_DIR)\Tpm20Acpi.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\tpm.asl" + Parent = "GENERIC_ASL" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(TPM20ACPI_DIR)\TpmCrb.asl" + Parent = "GENERIC_ASL" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(TPM20ACPI_DIR)\tcg_ppi1_2.asl" + Parent = "GENERIC_ASL" + InvokeOrder = AfterParent + Token = "OVERRIDE_TCG_ASL" "=" "0" + Token = "TCGPPISPEC_1_2_SUPPORT" "=" "1" + Token = "WORD_ACCESS_SMI_PORT" "=" "0" +End + +ELINK + Name = "$(TPM20ACPI_DIR)\tcg_ppi1_2_Ex.asl" + Parent = "GENERIC_ASL" + InvokeOrder = AfterParent + Token = "OVERRIDE_TCG_ASL" "=" "0" + Token = "TCGPPISPEC_1_2_SUPPORT" "=" "1" + Token = "WORD_ACCESS_SMI_PORT" "=" "1" +End + +TOKEN + Name = "TPMF" + Value = "0" + Help = "TPM ASL update Variable" + TokenType = Integer + TargetASL = Yes + TargetH = Yes +End + +ELINK + Name = "/D PTT_FLAG" + Help = "Intel platforms only" + Parent = "GLOBAL_DEFINES" + InvokeOrder = AfterParent +End + diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/TpmCrb.asl b/Board/EM/TCG2/Common/Tpm20Acpi/TpmCrb.asl new file mode 100644 index 0000000..43dc77e --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/TpmCrb.asl @@ -0,0 +1,387 @@ +Scope (\_SB.PCI0) +{ + Device (FTPM) + { + // + // Define _HID, "PNP0C31" is defined in + // + Name (_HID, "MSFT0101") + + // + // Readable name of this device, don't know if this way is correct yet + // + Name (_STR, Unicode ("TPM 2.0 Device")) + + // + // Return the resource consumed by TPM device + // + Name(_CRS,ResourceTemplate() + { + Memory32Fixed (ReadOnly, 0xFED70000, 0x1000,PCRS) + }) + + OperationRegion (TPMR, SystemMemory, 0xFED70000, 0x1000) + Field (TPMR, AnyAcc, NoLock, Preserve) + { + Offset(0x04), + FERR, 32, + Offset(0x0c), + BEGN, 32, + } + + OperationRegion (CRBD, SystemMemory, 0xFED70000, 0x1000) + Field (CRBD, AnyAcc, NoLock, Preserve) + { + Offset(0x04), + HERR, 32, + Offset (0x40), + HCMD, 32, + Offset(0x44), + HSTS, 32, + } + + OperationRegion (ASMI, SystemIO, SMIA , 0x1) + Field (ASMI, ByteAcc, NoLock, Preserve) + { + INQ,8 + } + + OperationRegion (BSMI, SystemIO, SMIB , 0x1) + Field (BSMI, ByteAcc, NoLock, Preserve) + { + DAT,8 + } + + Method (_STA, 0) + { + If(LEqual(TTDP, 1)){ + If(LEqual(TTPF, 0)){ + Return (0x0f) + } + } + Return (0x0) + } + + + Method (STRT, 3, Serialized, 0, IntObj, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj + { + // + // Switch by function index + // + Switch (ToInteger (Arg1)) + { + Case (0) + { + // + // Standard query, supports function 1-1 + // + Return (Buffer () {0x03}) + } + Case (1) + { + If(LEqual(Or(And(HSTS,0x00000002),And(HSTS,0x00000001)),0x00000003)) + { + // + // Trigger the FTPM_CMD interrupt + // + Store (0x00000001, HCMD) + } + Else + { + //Set Error Bit + Store(0x00000001,FERR) + //Clear Start Bit + Store(0x00000000,BEGN) + } + Return (0) + } + } + + Return (0) + } + + Method (CRYF, 3, Serialized, 0, {BuffObj, PkgObj}, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj + { + // + // Switch by function index + // + Switch (ToInteger(Arg1)) + { + Case (0) + { + // + // Standard query + // + Return (Buffer () {0x03}) + } + Case (1) + { + // + // Return failure if no TPM present + // + Name(TPMV, Package () {0x01, Package () {0x1, 0x20}}) + Return (TPMV) + } + } + Return (Buffer () {0}) + } + + Method (PPIR, 3, Serialized, 0, {BuffObj, PkgObj, IntObj, StrObj}, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj + { + // + // Switch by function index + // + Switch (ToInteger(Arg1)) + { + Case (0) + { + // + // Standard query, supports function 1-8 + // + return (Buffer() {0xff,0x01}) //support functions 0-6 + } + Case (1) + { + // + // a) Get Physical Presence Interface Version + // + Return ("1.2") + } + + // + // Function 2: Submit TPM Operation request + // Arg3[0]: Integer - Operation Value + case(2) + { + ToInteger(DeRefOf(Index(Arg2,0)), TMF2) //save request in temp flag + Store(0x12, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + Store(TMF2,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + if(Lequal(DAT,0xF1)){ + return(0x1) + } + + return (Zero) //Success + } + + // + // Function 3: Get pending TPM operation + case(3) + { + Name(PPI1, Package(){0,0}) + Store(0x11,DAT) //read rqst operation + Store(OFST,INQ) //should cause SMI + + if(Lequal(DAT,0xFF)){ + return(0x1) + } + + Store(DAT, Index(PPI1,1)) + return(PPI1) + } + + // + // Function 4: Get platform-specific action to transition + // ot Pre-OS + // Returns: + // 0: None + // 1: Shutdown + // 2: Reboot + // 3: OS Vendor Specific + case(4) + { + return (TRST) //Shutdown + } + + // + // Function 5: Return TPM responce + // + case(5) + { + Name(PPI2, Package(){0,0,0}) + Store(0x21,DAT) + Store(OFST,INQ) + Store(DAT, Index(PPI2,1)) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + Store(0x31,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + IF (Lequal(DAT, 0xF0)) + { + Store(0x51,DAT) + Store(OFST,INQ) + if(Lequal(DAT,0xFF)){ + Store(0xFFFFFFF0, Index(PPI2,2)) + return(PPI2) + } + } + ElseIF (Lequal(DAT, 0xF1)) + { + Store(0x51,DAT) + Store(OFST,INQ) + if(Lequal(DAT,0xFF)){ + Store(0xFFFFFFF1, Index(PPI2,2)) + return(PPI2) + } + } + Else + {Store(DAT, Index(PPI2,2))} + + return(PPI2) + } + + + // + // Function 6: Submit preferred user language + // Ppi Spec 1.2 section 2.1.6 + // Arg3[0]: String - preferred language code + case(6) + { + return ( 0x03 ) //Success + } + + + // + // Function 7: Submit TPM Operation Request to Pre-OS Environment 2 + // Ppi Spec 1.2 section 2.1.7 + // Arg3[0]: String - preferred language code + case(7) + { + ToInteger(DeRefOf(Index(Arg2,0)), TMF2) //save request in temp flag + Store(0x12, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + Store(TMF2,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + if(Lequal(DAT,0xF1)){ + return(0x1) + } + + return (Zero) //Success + } + + case(8) + { + ToInteger(DeRefOf(Index(Arg2,0)), TMF2) //save request in temp flag + Store(0x43, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + Store(TMF2,DAT) + Store(OFST,INQ) + return (DAT) + } + + default { } + } + } + + Method (MORI, 3, Serialized, 0, IntObj, {UnknownObj, UnknownObj, UnknownObj}) // IntObj, IntObj, PkgObj + { + // + // Switch by function index + // + Switch (ToInteger (Arg1)) + { + // + // Function 0: Return supported funcitons + // + case(0) + { + return (Buffer() {0x3}) //support functions 0 and 1 + } + + // + // Function 1: Set MOR Bit State + // + case(1) + { + Store(0x22, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + ToInteger(DeRefOf(Index(Arg2,0)), TMF1) //save request in temp flag + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + return (Zero) + } + default { } + } + return (Buffer() {0}) + } + + Method (_DSM, 4, Serialized, 0, UnknownObj, {BuffObj, IntObj, IntObj, PkgObj}) + { + + // + // TCG Physical Presence Interface + // + If(LEqual(Arg0, ToUUID ("3dddfaa6-361b-4eb4-a424-8d10089d1653"))) + { + Return (PPIR (Arg1, Arg2, Arg3)) + } + + // + // TCG Memory Clear Interface + // + If(LEqual(Arg0, ToUUID ("376054ed-cc13-4675-901c-4756d7f2d45d"))) + { + Return (MORI (Arg1, Arg2, Arg3)) + } + + // + // TPM2 ACPI Start Method + // + If(LEqual(Arg0, ToUUID ("cf8e16a5-c1e8-4e25-b712-4f54a96702c8"))) + { + Return (CRYF (Arg1, Arg2, Arg3)) + } + + If(LEqual(Arg0, ToUUID ("6bbf6cab-5463-4714-b7cd-f0203c0368d4"))) + { + Return (STRT (Arg1, Arg2, Arg3)) + } + + Return (Buffer () {0}) + } + + } +} \ No newline at end of file diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2.asl b/Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2.asl new file mode 100644 index 0000000..3406155 --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2.asl @@ -0,0 +1,256 @@ +//********************************************************************** +// +// +// Procedure: _DSM PPI Method for TPM device +// +// Description: Implement Phisical Presence Interface +// +// Input: \_SB.PCI0.LPCB.TP +// +// Output: PPI result +// +// Modified: +// +// Referrals: +// +// Notes: +// +//********************************************************************** +Scope(\_SB.PCI0.TPM) +{ + OperationRegion (ASMI, SystemIO, SMIA , 0x1) + Field (ASMI, ByteAcc, NoLock, Preserve) + { + INQ,8 + } + + OperationRegion (BSMI, SystemIO, SMIB , 0x1) + Field (BSMI, ByteAcc, NoLock, Preserve) + { + DAT,8 + } + + + Method( _DSM , 4) + { + if( LEqual(Arg0,ToUUID("3DDDFAA6-361B-4EB4-A424-8D10089D1653"))) + { + switch(ToInteger(Arg2)) + { + // + // Function 0: Return supported funcitons + // + case(0) + { + return (Buffer() {0xff,0x01}) //support functions 0-6 + } + + // + // Function 1: Ge PPI Version + // + case(1) + { + return ("1.2") + } + + // + // Function 2: Submit TPM Operation request + // Arg3[0]: Integer - Operation Value + case(2) + { + ToInteger(DeRefOf(Index(Arg3,0)), TMF2) //save request in temp flag + Store(0x12, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + Store(TMF2,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + if(Lequal(DAT,0xF1)){ + return(0x1) + } + + + return (Zero) //Success + } + + // + // Function 3: Get pending TPM operation + case(3) + { + Name(PPI1, Package(){0,0}) + Store(0x11,DAT) //read rqst operation + Store(OFST,INQ) //should cause SMI + + if(Lequal(DAT,0xFF)){ + return(0x1) + } + + Store(DAT, Index(PPI1,1)) + return(PPI1) + } + + // + // Function 4: Get platform-specific action to transition + // ot Pre-OS + // Returns: + // 0: None + // 1: Shutdown + // 2: Reboot + // 3: OS Vendor Specific + case(4) + { + return (TRST) //Shutdown + } + + // + // Function 5: Return TPM responce + // + case(5) + { + Name(PPI2, Package(){0,0,0}) + Store(0x21,DAT) + Store(OFST,INQ) + Store(DAT, Index(PPI2,1)) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + Store(0x31,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + IF (Lequal(DAT, 0xF0)) + { + Store(0x51,DAT) + Store(OFST,INQ) + if(Lequal(DAT,0xFF)){ + Store(0xFFFFFFF0, Index(PPI2,2)) + return(PPI2) + } + } + ElseIF (Lequal(DAT, 0xF1)) + { + Store(0x51,DAT) + Store(OFST,INQ) + if(Lequal(DAT,0xFF)){ + Store(0xFFFFFFF1, Index(PPI2,2)) + return(PPI2) + } + } + Else + {Store(DAT, Index(PPI2,2))} + return(PPI2) + } + + + // + // Function 6: Submit preferred user language + // Ppi Spec 1.2 section 2.1.6 + // Arg3[0]: String - preferred language code + case(6) + { + return ( 0x03 ) //Success + } + + + // + // Function 7: Submit TPM Operation Request to Pre-OS Environment 2 + // Ppi Spec 1.2 section 2.1.7 + // Arg3[0]: String - preferred language code + case(7) + { + ToInteger(DeRefOf(Index(Arg3,0)), TMF2) //save request in temp flag + Store(0x12, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + Store(TMF2,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + if(Lequal(DAT,0xF1)){ + return(0x1) + } + + return (Zero) //Success + } + + case(8) + { + + ToInteger(DeRefOf(Index(Arg3,0)), TMF2) //save request in temp flag + Store(0x43, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + Store(TMF2,DAT) + Store(OFST,INQ) + return (DAT) + } + + default { } + } + } else {if(LEqual(Arg0, + ToUUID("376054ED-CC13-4675-901C-4756D7F2D45D"))){ + // + // Reset Atack Mitigation + // + switch(ToInteger(Arg2)) + { + // + // Function 0: Return supported funcitons + // + case(0) + { + return (Buffer() {0x3}) //support functions 0 and 1 + } + + // + // Function 1: Set MOR Bit State + // + case(1) + { + Store(0x22, TMF1) + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + ToInteger(DeRefOf(Index(Arg3,0)), TMF1) //save request in temp flag + Store(TMF1,DAT) + Store(OFST,INQ) + + if(Lequal(DAT,0xFF)){ + return(0x2) + } + + return (Zero) + } + default { } + } + + }} + return (Buffer() {0}) + } +} diff --git a/Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2_Ex.asl b/Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2_Ex.asl new file mode 100644 index 0000000..6d74b1e --- /dev/null +++ b/Board/EM/TCG2/Common/Tpm20Acpi/tcg_ppi1_2_Ex.asl @@ -0,0 +1,301 @@ +//********************************************************************** +// +// +// Procedure: _DSM PPI Method for TPM device +// +// Description: Implement Phisical Presence Interface using WordAcc +// +// Input: \_SB.PCI0.LPCB.TP +// +// Output: PPI result +// +// Modified: +// +// Referrals: +// +// Notes: +// +//********************************************************************** +Scope(\_SB.TPM) +{ + OperationRegion (TSMI, SystemIO, SMIA , 0x2) + Field (TSMI, WordAcc, NoLock, Preserve) + { + SMI,16, + } + + Method( _DSM , 4) + { + if( LEqual(Arg0,ToUUID("3DDDFAA6-361B-4EB4-A424-8D10089D1653"))) + { + switch(ToInteger(Arg2)) + { + // + // Function 0: Return supported funcitons + // + case(0) + { + return (Buffer() {0xff,0x01}) //support functions 0-6 + } + + // + // Function 1: Ge PPI Version + // + case(1) + { + return ("1.2") + } + + // + // Function 2: Submit TPM Operation request + // Arg3[0]: Integer - Operation Value + case(2) + { + ToInteger(DeRefOf(Index(Arg3,0)), TMF2) //save request in temp flag + Store(OFST, TMF1) + Or(0x1200, TMF1, TMF1) + + Store(0xFA,P80D) + Store(TMF1,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + ShiftLeft(TMF2, 0x8, TMF2) + Or(OFST, TMF2, TMF2) + + Store(TMF2,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + if(Lequal(TMF1,0xFF)){ + return(0x1) + } + + return (Zero) //Success + } + + // + // Function 3: Get pending TPM operation + case(3) + { + Store(0xFB,P80D) + Name(PPI1, Package(){0,0}) + Store(OFST,TMF1) + Or(0x1100, TMF1, TMF1) + + Store(TMF1, SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x1) + } + + Store(TMF1, Index(PPI1,1)) + return(PPI1) + } + + // + // Function 4: Get platform-specific action to transition + // ot Pre-OS + // Returns: + // 0: None + // 1: Shutdown + // 2: Reboot + // 3: OS Vendor Specific + case(4) + { + Store(0xFC,P80D) + return (TRST) //Shutdown + } + + // + // Function 5: Return TPM responce + // + case(5) + { + Name(PPI2, Package(){0,0,0}) + Store(0xFD,P80D) + Store(OFST,TMF1) + Or(0x2100, TMF1, TMF1) + Store(TMF1,SMI) + + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + Store(TMF1, Index(PPI2,1)) + + Store(OFST,TMF1) + Or(0x3100, TMF1, TMF1) + + Store(TMF1,SMI) + + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + IF (Lequal(TMF1, 0xF0)) + { + Store(OFST,TMF1) + Or(0x5100, TMF1, TMF1) + Store(TMF1,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + Store(0xFFFFFFF0, Index(PPI2,2)) + return(PPI2) + } + + } + ElseIF (Lequal(TMF1, 0xF1)) + { + Store(OFST,TMF1) + Or(0x5100, TMF1, TMF1) + Store(TMF1,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + Store(0xFFFFFFF1, Index(PPI2,2)) + return(PPI2) + } + } + Else + {Store(TMF1, Index(PPI2,2))} + return(PPI2) + } + + + // + // Function 6: Submit preferred user language + // Ppi Spec 1.2 section 2.1.6 + // Arg3[0]: String - preferred language code + case(6) + { + return ( 0x03 ) //Success + } + + + // + // Function 7: Submit TPM Operation Request to Pre-OS Environment 2 + // Ppi Spec 1.2 section 2.1.7 + // Arg3[0]: String - preferred language code + case(7) + { + ToInteger(DeRefOf(Index(Arg3,0)), TMF2) //save request in temp flag + Store(0xFE,P80D) + Store(OFST,TMF1) + Or(0x1200, TMF1, TMF1) + Store(TMF1,SMI) + + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + ShiftLeft(TMF2, 0x8, TMF2) + Or(OFST, TMF2, TMF2) + + Store(TMF2,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + if(Lequal(TMF1,0xF1)){ + return(0x1) + } + + return (Zero) //Success + } + + case(8) + { + Store(0xFF,P80D) + ToInteger(DeRefOf(Index(Arg3,0)), TMF2) //save request in temp flag + Store(OFST,TMF1) + Or(0x4300, TMF1, TMF1) + Store(TMF1,SMI) + Store(SMI,TMF1) + ShiftLeft(TMF2, 0x8, TMF2) + Or(OFST, TMF2, TMF2) + Store(TMF2,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + return (TMF1) + } + + default { } + } + } else {if(LEqual(Arg0, + ToUUID("376054ED-CC13-4675-901C-4756D7F2D45D"))){ + // + // Reset Atack Mitigation + // + switch(ToInteger(Arg2)) + { + // + // Function 0: Return supported funcitons + // + case(0) + { + return (Buffer() {0x3}) //support functions 0 and 1 + } + + // + // Function 1: Set MOR Bit State + // + case(1) + { + Store(0xF1,P80D) + Or(0x2200, TMF1, TMF1) + Store(TMF1,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + ToInteger(DeRefOf(Index(Arg3,0)), TMF1) //save request in temp flag + ShiftLeft(TMF1, 0x8, TMF1) + Or(OFST, TMF1, TMF1) + Store(TMF1,SMI) + Store(SMI,TMF1) + ShiftRight(TMF1, 0x8, TMF1) + + if(Lequal(TMF1,0xFF)){ + return(0x2) + } + + return (Zero) + } + default { } + } + + }} + return (Buffer() {0}) + } +} -- cgit v1.2.3