diff options
Diffstat (limited to 'Board/EM/TCG2/Common/TcgPeiplatform.c')
-rw-r--r-- | Board/EM/TCG2/Common/TcgPeiplatform.c | 240 |
1 files changed, 240 insertions, 0 deletions
diff --git a/Board/EM/TCG2/Common/TcgPeiplatform.c b/Board/EM/TCG2/Common/TcgPeiplatform.c new file mode 100644 index 0000000..6476964 --- /dev/null +++ b/Board/EM/TCG2/Common/TcgPeiplatform.c @@ -0,0 +1,240 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//************************************************************************* +// $Header: /Alaska/SOURCE/Modules/TCG2/Common/TcgPeiplatform/TcgPeiplatform.c 1 4/21/14 2:18p Fredericko $ +// +// $Revision: 1 $ +// +// $Date: 4/21/14 2:18p $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/TCG2/Common/TcgPeiplatform/TcgPeiplatform.c $ +// +// 1 4/21/14 2:18p Fredericko +// +// 1 10/08/13 12:04p Fredericko +// Initial Check-In for Tpm-Next module +// +// 1 7/10/13 5:56p Fredericko +// [TAG] EIP120969 +// [Category] New Feature +// [Description] TCG (TPM20) +// +// 5 4/26/11 1:46p Fredericko +// Function call changes to match changes to function header definition +// for Memoryabsent function. +// +// 4 4/04/11 2:14p Fredericko +// Removed #pragma optimization directives +// +// 3 3/29/11 9:18p Fredericko +// Handle TPM memory present errors +// +// 2 3/29/11 1:19p Fredericko +// [TAG] EIP 54642 +// [Category] Improvement +// [Description] 1. Checkin Files related to TCG function override +// 2. Include TCM and TPM auto detection +// [Files] Affects all TCG files +// +// +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: TcgPeiPlatform.c +// +// Description: Function file for TcgPeiPlatform +// +//<AMI_FHDR_END> +//************************************************************************* +#include <Efi.h> +#include <Pei.h> +#include <TcgCommon.h> +#include <AmiPeiLib.h> +#include <TcgMisc.h> +#include "PPI\TcgService\TcgTcmService.h" +#include "PPI\TcgService\TcgService.h" +#include "PPI\TpmDevice\TpmDevice.h" +#include "PPI\CpuIo.h" +#include "PPI\LoadFile.h" +#include <Ppi\ReadOnlyVariable.h> +#include "AmiTcgPlatformPei.h" + + + +EFI_GUID gAmiTcgPlatformPpiBeforeMem = AMI_TCG_PLATFORM_PPI_BEFORE_MEM_GUID; +EFI_GUID gAmiTcgPlatformPpiAfterMem = AMI_TCG_PLATFORM_PPI_AFTER_MEM_GUID; +EFI_GUID gCacheInstallGuid = EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI; + +EFI_STATUS +EFIAPI OnMemoryDiscovered( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc, + IN VOID *Ppi ); + + +static EFI_PEI_NOTIFY_DESCRIPTOR TcgAmiPlatformInitNotify[] = +{ + { + EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | \ + EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gAmiTcgPlatformPpiAfterMem, + OnMemoryDiscovered + } +}; + +//********************************************************************** +//<AMI_PHDR_START> +// +// Procedure: OnMemoryDiscovered +// +// Description: Call Memory Present initialization on memory Installation +// +// +// Input: IN EFI_PEI_SERVICES **PeiServices, +// IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc, +// IN VOID *Ppi +// +// Output: EFI STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +//<AMI_PHDR_END> +//********************************************************************** +EFI_STATUS +EFIAPI OnMemoryDiscovered( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc, + IN VOID *Ppi ) +{ + EFI_STATUS Status; + AMI_TCG_PLATFORM_PPI_AFTER_MEM *AmiTcgPlatformPPI = NULL; + EFI_BOOT_MODE BootMode; + + + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gAmiTcgPlatformPpiAfterMem , + 0, + NULL, + &AmiTcgPlatformPPI); + + if ( EFI_ERROR( Status )){ + Status = (*PeiServices)->NotifyPpi (PeiServices, \ + TcgAmiPlatformInitNotify); + + return Status; + } + + ASSERT_PEI_ERROR( PeiServices, Status ); + + Status = (*PeiServices)->GetBootMode( PeiServices, &BootMode ); + ASSERT_PEI_ERROR( PeiServices, Status ); + + Status = AmiTcgPlatformPPI->VerifyTcgVariables(PeiServices); + Status = AmiTcgPlatformPPI->MemoryPresentFunctioOverride(PeiServices); + if(EFI_ERROR(Status))return Status; + + if((BootMode == BOOT_ON_S3_RESUME) || (BootMode == BOOT_IN_RECOVERY_MODE)){ + return EFI_SUCCESS; + } + + Status = AmiTcgPlatformPPI->SetPhysicalPresence(PeiServices); + return (Status); +} + + + + +//********************************************************************** +//<AMI_PHDR_START> +// +// Procedure: TcgPeiPlatformEntry +// +// Description: +// +// Input: IN EFI_FFS_FILE_HEADER *FfsHeader +// IN EFI_PEI_SERVICES **PeiServices, +// +// Output: EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +//<AMI_PHDR_END> +//********************************************************************** +EFI_STATUS +EFIAPI TcgPeiplatformEntry( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices ){ + + AMI_TCG_PLATFORM_PPI_BEFORE_MEM *AmiTcgPlatformPPI = NULL; + EFI_STATUS Status; + TCG_PEI_MEMORY_CALLBACK *MemCallback; + + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gAmiTcgPlatformPpiBeforeMem, + 0, + NULL, + &AmiTcgPlatformPPI); + + + if(EFI_ERROR(Status)){ + return EFI_SUCCESS; + } + + AmiTcgPlatformPPI->MemoryAbsentFunctionOverride(PeiServices); + + Status = (**PeiServices).AllocatePool( + PeiServices, + sizeof (TCG_PEI_MEMORY_CALLBACK), + &MemCallback); + + if ( !EFI_ERROR( Status )) + { + MemCallback->NotifyDesc.Flags + = (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK + | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST); + MemCallback->NotifyDesc.Guid = &gCacheInstallGuid; + MemCallback->NotifyDesc.Notify = OnMemoryDiscovered; + MemCallback->FfsHeader = FfsHeader; + + Status = (*PeiServices)->NotifyPpi( PeiServices, + &MemCallback->NotifyDesc ); + } + + return Status; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2010, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** |