diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/Pfat/PfatRecovery | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Board/EM/Pfat/PfatRecovery')
-rw-r--r-- | Board/EM/Pfat/PfatRecovery/PfatRecovery.c | 287 | ||||
-rw-r--r-- | Board/EM/Pfat/PfatRecovery/PfatRecovery.cif | 12 | ||||
-rw-r--r-- | Board/EM/Pfat/PfatRecovery/PfatRecovery.dxs | 58 | ||||
-rw-r--r-- | Board/EM/Pfat/PfatRecovery/PfatRecovery.mak | 113 | ||||
-rw-r--r-- | Board/EM/Pfat/PfatRecovery/PfatRecovery.sdl | 169 | ||||
-rw-r--r-- | Board/EM/Pfat/PfatRecovery/PfatRecoveryHook.c | 187 |
6 files changed, 826 insertions, 0 deletions
diff --git a/Board/EM/Pfat/PfatRecovery/PfatRecovery.c b/Board/EM/Pfat/PfatRecovery/PfatRecovery.c new file mode 100644 index 0000000..590b70d --- /dev/null +++ b/Board/EM/Pfat/PfatRecovery/PfatRecovery.c @@ -0,0 +1,287 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (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/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.c 1 4/05/13 5:36p Fredericko $ +// +// $Revision: 1 $ +// +// $Date: 4/05/13 5:36p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.c $ +// +// 1 4/05/13 5:36p Fredericko +// [TAG] EIP119706 +// [Category] Improvement +// [Description] Support Recovery in pfat module +// [Files] PfatRecovery.cif +// PfatRecovery.sdl +// PfatRecovery.mak +// PfatRecovery.dxs +// PfatRecovery.c +// PfatRecoveryHook.c +// +// +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: +// +// Description: +// +//<AMI_FHDR_END> +//********************************************************************** +//---------------------------------------------------------------------------- +// Includes +// Statements that include other files +#include <PEI.h> +#include <AmiPeiLib.h> +#include <token.h> +#include <PPI\stall.h> +#include <PPI\DeviceRecoveryModule.h> +#include <HOB.h> +#include <AmiHobs.h> +#include <PfatDefinitions.h> + +#define PFAT_PACKAGE_CERT 524 +//---------------------------------------------------------------------------- +// Function Externs + +//---------------------------------------------------------------------------- +// Local prototypes +typedef struct +{ + EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *pDRM_Ppi; + EFI_PEI_DEVICE_LOAD_RECOVERY_CAPSULE SavedLoadCapsule; + +} DEVICE_RECOVERY_MODULE_INFO; + +//---------------------------------------------------------------------------- +// Local Variables +DEVICE_RECOVERY_MODULE_INFO gDeviceRecoveryModuleInfo[MAX_DEVICE_RECOVERY_MODULE]; + + +//---------------------------------------------------------------------------- +// Function Definitions +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: FindAvailableMemory +// +// Description: +// +// Input: +// IN EFI_PEI_SERVICES **PeiServices, +// +// Output: +// EFI_PHYSICAL_ADDRESS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_PHYSICAL_ADDRESS +FindAvailableMemory ( + IN EFI_PEI_SERVICES **PeiServices +) +{ + VOID *p; + UINT8 i; + EFI_PHYSICAL_ADDRESS TopOfMemory = 0xffffffff; + + for ((*PeiServices)->GetHobList(PeiServices, &p), i = 0; \ + !(FindNextHobByType(EFI_HOB_TYPE_MEMORY_ALLOCATION, &p)); i++) { + if (TopOfMemory > ((EFI_HOB_MEMORY_ALLOCATION*)p)->AllocDescriptor.MemoryBaseAddress) + TopOfMemory = ((EFI_HOB_MEMORY_ALLOCATION*)p)->AllocDescriptor.MemoryBaseAddress; + } + return (TopOfMemory - (PFAT_RECOVERY_IMAGE_SIZE & 0xFFF00000)); +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PfatRecoveryFileLoaded +// +// Description: Call this function at end of Pei. This currently +// check recovery file. +// +// Input: +// IN EFI_PEI_SERVICES **PeiServices, +// IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, +// IN VOID *Ppi +// +// +// Output: +// EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS PfatRecoveryFileLoaded ( + IN EFI_PEI_SERVICES **PeiServices, + IN RECOVERY_IMAGE_HOB *RecoveryHob +) +{ + UINT8 *p; + UINT32 i = 0, j = 0; + PUP_HEADER *PupHdr; + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Buffer = NULL; + EFI_BOOT_MODE BootMode; + UINT8 pAmiPfatSign[] = "_AMIPFAT"; + EFI_GUID PfatHobGuid = PFAT_HOB_GUID; + PFAT_HOB *PfatHob; + + Status = (*PeiServices)->GetBootMode(PeiServices, &BootMode); + if ((EFI_ERROR(Status)) || (BootMode != BOOT_IN_RECOVERY_MODE)) + return EFI_SUCCESS; + + // To avoid out of memory resource with AllocatePages in PEI phase, find + // out the top of available memory to re-collate rom image w/o PAT headers. + Buffer = FindAvailableMemory(PeiServices); + + p = (UINT8*)RecoveryHob->Address; + + // Verify AMIPFAT Header. + if (MemCmp (p + 8, pAmiPfatSign, 8)) return Status; + + i = *(UINT32*)p; + PupHdr = (PUP_HEADER*)(p + i); + do { + // skip ScriptSection and PUP Header + i += (PupHdr->ScriptSectionSize + sizeof(PUP_HEADER)); + // collect DataSection only to buffer. + (*PeiServices)->CopyMem ((UINT8*)Buffer + j, \ + (UINT8*)p + i, PupHdr->DataSectionSize); + // pointer to next PUP block. + i += (PupHdr->DataSectionSize + PFAT_PACKAGE_CERT); + j += PupHdr->DataSectionSize; + PupHdr = (PUP_HEADER*)(p + i); + + } while (i < PFAT_RECOVERY_IMAGE_SIZE); + + // Skip ME Region if needed (j = Original image size). + (*PeiServices)->CopyMem ((UINT8*)RecoveryHob->Address, \ + (UINT8*)Buffer + (j - FLASH_SIZE), \ + FLASH_SIZE ); + + // Invalidate PfatHob for disabling PFAT during DXE. + (*PeiServices)->GetHobList(PeiServices, &PfatHob); + Status = FindNextHobByGuid(&PfatHobGuid, &PfatHob); + if(!EFI_ERROR(Status)) { + PfatHob->EfiHobGuidType.Header.HobType = EFI_HOB_TYPE_UNUSED; + } + return EFI_SUCCESS; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: LoadRecoveryCapsuleHook +// +// Description: +// +// Input: IN EFI_PEI_SERVICES **PeiServices, +// IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +LoadRecoveryCapsuleHook ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *This, + IN UINTN CapsuleInstance, + OUT VOID *Buffer ) +{ + UINT8 i = 0; + RECOVERY_IMAGE_HOB RecoveryHob; + EFI_STATUS Status; + + // All the LoadRecoveryCapsule calls come here + for (i = 0; gDeviceRecoveryModuleInfo[i].pDRM_Ppi != NULL; i++) { + // Check "This" for identfiy the LoadRecoveryCapsule call. + if (This != gDeviceRecoveryModuleInfo[i].pDRM_Ppi) continue; + + // Invoke the Original LoadRecoveryCapsule procedure + Status = gDeviceRecoveryModuleInfo[i].SavedLoadCapsule ( \ + PeiServices, This, CapsuleInstance, Buffer ); + if (EFI_ERROR(Status)) return Status; + + // Recovery image loaded, check if PFAT image then reconstruct the + // BIOS image. + RecoveryHob.Address = (EFI_PHYSICAL_ADDRESS)Buffer; + Status = PfatRecoveryFileLoaded (PeiServices, &RecoveryHob); + break; + } + return EFI_SUCCESS; +} +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// +// Procedure: PfatRecoveryEntry +// +// Description: +// +// Input: EFI_HANDLE - ImageHandle +// EFI_SYSTEM_TABLE* - SystemTable +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +PfatRecoveryEntry ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices +) +{ + UINTN i = 0; + EFI_STATUS Status; + EFI_PEI_DEVICE_RECOVERY_MODULE_PPI *pRecoveryDevice; + EFI_GUID guidRecoveryDevice = EFI_PEI_DEVICE_RECOVERY_MODULE_PPI_GUID; + EFI_PEI_PPI_DESCRIPTOR *pDummy; + + // Initialize gDeviceRecoveryModuleInfo structure + for(i = 0; i < MAX_DEVICE_RECOVERY_MODULE; i++) { + gDeviceRecoveryModuleInfo[i].pDRM_Ppi = NULL; + gDeviceRecoveryModuleInfo[i].SavedLoadCapsule = NULL; + } + i = 0; + do { + // Discover the Device Recovery Module PPIs for hooking the + // LoadRecoveryCapule procedure. + Status = (*PeiServices)->LocatePpi(PeiServices, \ + &guidRecoveryDevice, i, &pDummy, &pRecoveryDevice); + if (!EFI_ERROR(Status)) { + // Save Ppi pointer and LoadRecoveryCapsule procedure for Hook used. + gDeviceRecoveryModuleInfo[i].pDRM_Ppi = pRecoveryDevice; + gDeviceRecoveryModuleInfo[i++].SavedLoadCapsule = pRecoveryDevice->LoadRecoveryCapsule; + // Hook the LaodRecoveryCapsule procedure. + pRecoveryDevice->LoadRecoveryCapsule = LoadRecoveryCapsuleHook; + } + } while(!EFI_ERROR(Status)); + return EFI_SUCCESS; +} +//************************************************************************* +//************************************************************************* +//** ** +//** (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/Pfat/PfatRecovery/PfatRecovery.cif b/Board/EM/Pfat/PfatRecovery/PfatRecovery.cif new file mode 100644 index 0000000..263e558 --- /dev/null +++ b/Board/EM/Pfat/PfatRecovery/PfatRecovery.cif @@ -0,0 +1,12 @@ +<component> + name = "PfatRecovery" + category = ModulePart + LocalRoot = "Board\EM\Pfat\PfatRecovery" + RefName = "PfatRecovery" +[files] +"PfatRecovery.sdl" +"PfatRecovery.mak" +"PfatRecovery.dxs" +"PfatRecovery.c" +"PfatRecoveryHook.c" +<endComponent> diff --git a/Board/EM/Pfat/PfatRecovery/PfatRecovery.dxs b/Board/EM/Pfat/PfatRecovery/PfatRecovery.dxs new file mode 100644 index 0000000..3c9e8b5 --- /dev/null +++ b/Board/EM/Pfat/PfatRecovery/PfatRecovery.dxs @@ -0,0 +1,58 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (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/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.dxs 1 4/05/13 5:36p Fredericko $ +// +// $Revision: 1 $ +// +// $Date: 4/05/13 5:36p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.dxs $ +// +// 1 4/05/13 5:36p Fredericko +// [TAG] EIP119706 +// [Category] Improvement +// [Description] Support Recovery in pfat module +// [Files] PfatRecovery.cif +// PfatRecovery.sdl +// PfatRecovery.mak +// PfatRecovery.dxs +// PfatRecovery.c +// PfatRecoveryHook.c +// +// +//********************************************************************** +#include <PEI.h> +#include <PPI\RecoveryModule.h> + +DEPENDENCY_START + EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI AND + EFI_PEI_RECOVERY_MODULE_PPI_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/Pfat/PfatRecovery/PfatRecovery.mak b/Board/EM/Pfat/PfatRecovery/PfatRecovery.mak new file mode 100644 index 0000000..ebded82 --- /dev/null +++ b/Board/EM/Pfat/PfatRecovery/PfatRecovery.mak @@ -0,0 +1,113 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.mak 1 4/05/13 5:36p Fredericko $ +# +# $Revision: 1 $ +# +# $Date: 4/05/13 5:36p $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.mak $ +# +# 1 4/05/13 5:36p Fredericko +# [TAG] EIP119706 +# [Category] Improvement +# [Description] Support Recovery in pfat module +# [Files] PfatRecovery.cif +# PfatRecovery.sdl +# PfatRecovery.mak +# PfatRecovery.dxs +# PfatRecovery.c +# PfatRecoveryHook.c +# +# +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: PfatRecovery.mak +# +# Description: Make file for PfatRecovery module part +# +#<AMI_FHDR_END> +#********************************************************************** +all : PfatRecovery + +PFAT_RECOVERY_BUILD_DIR = $(BUILD_DIR)\$(PFAT_RECOVERY_PATH) +#--------------------------------------------------------------------------- +# Create Fault Tolerant BootBlock Update dependencies +#--------------------------------------------------------------------------- +$(BUILD_DIR)\PfatRecovery.mak : $(PFAT_RECOVERY_PATH)\$(@B).cif $(PFAT_RECOVERY_PATH)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(PFAT_RECOVERY_PATH)\$(@B).cif $(CIF2MAK_DEFAULTS) +#--------------------------------------------------------------------------- +# Create Fault Tolerant BootBlock Update DXE Component +#--------------------------------------------------------------------------- +PfatRecovery: $(BUILD_DIR)\PfatRecovery.mak PfatRecoveryBin + +PfatRecoveryIncludes =\ +/I$(PROJECT_CPU_ROOT)\Include + +PfatRecoveryObjs = \ +$(PFAT_RECOVERY_BUILD_DIR)\PfatRecovery.obj + +PfatRecoveryBin : $(AMIPEILIB) + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\PfatRecovery.mak all\ + OBJECTS="$(PfatRecoveryObjs)" \ + NAME=PfatRecovery\ + MAKEFILE=$(BUILD_DIR)\PfatRecovery.mak \ + "CFLAGS=$(CFLAGS) $(PfatRecoveryIncludes)"\ + GUID=c2bcc635-779e-46f0-9e1b-b83db1ca4690 \ + ENTRY_POINT=PfatRecoveryEntry \ + TYPE=PEIM \ + DEPEX1=$(PFAT_RECOVERY_PATH)\PfatRecovery.DXS \ + DEPEX1_TYPE=EFI_SECTION_PEI_DEPEX \ + COMPRESS=1 + +#--------------------------------------------------------------------------- +# Create Launch SCLEAN Pei Component +#--------------------------------------------------------------------------- +PfatRecoveryHook : $(BUILD_DIR)\PfatRecovery.mak PfatRecoveryHookBin + +PfatRecoveryHookObjs = \ +$(PFAT_RECOVERY_BUILD_DIR)\PfatRecoveryHook.obj + +PfatRecoveryHookBin : + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\PfatRecovery.mak all\ + OBJECTS="$(PfatRecoveryHookObjs)" \ + NAME=PfatRecovery \ + TYPE=PEI_LIBRARY LIBRARY_NAME=$(PfatRecoveryPeiLib) + +$(PfatRecoveryPeiLib) : PfatRecoveryHook + +RecoveryBin : $(PfatRecoveryPeiLib) +FwCapsuleRecoveryPPIBin : $(PfatRecoveryPeiLib) + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/Pfat/PfatRecovery/PfatRecovery.sdl b/Board/EM/Pfat/PfatRecovery/PfatRecovery.sdl new file mode 100644 index 0000000..a12b5e2 --- /dev/null +++ b/Board/EM/Pfat/PfatRecovery/PfatRecovery.sdl @@ -0,0 +1,169 @@ +#********************************************************************** +#********************************************************************** +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#********************************************************************** +#********************************************************************** + +#********************************************************************** +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.sdl 3 7/15/13 8:17p Fredericko $ +# +# $Revision: 3 $ +# +# $Date: 7/15/13 8:17p $ +#********************************************************************** +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecovery.sdl $ +# +# 3 7/15/13 8:17p Fredericko +# EIP 124189: Secure Flash failure with Pfat +# +# 2 5/29/13 5:44p Fredericko +# [TAG] EIP124189 +# [Description] [PFAT] Secure Flash is fail using +# 4.6.5.1_INTEL_PFAT_2_6 or 2_7 +# [Files] PfatPubKeysAndBuildPsl.sdl +# Pfatrecovery.sdl +# PfatRecoveryHook.c +# Recovery.mak +# +# 1 4/05/13 5:36p Fredericko +# [TAG] EIP119706 +# [Category] Improvement +# [Description] Support Recovery in pfat module +# [Files] PfatRecovery.cif +# PfatRecovery.sdl +# PfatRecovery.mak +# PfatRecovery.dxs +# PfatRecovery.c +# PfatRecoveryHook.c +# +# +#********************************************************************** +#<AMI_FHDR_START> +# +# Name: PfatSetup.sdl +# +# Description: SDL file for PfatSetup +# +# +#<AMI_FHDR_END> +#********************************************************************** + +TOKEN + Name = "PFAT_RECOVERY_SUPPORT" + Value = "1" + Help = "" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes + Master = Yes + Token = "PfatServices_SUPPORT" "=" "1" +End + +PATH + Name = "PFAT_RECOVERY_PATH" +End + +MODULE + Help = "Includes PfatRecovery.mak to Project" + File = "PfatRecovery.mak" +End + +TOKEN + Name = "MAX_DEVICE_RECOVERY_MODULE" + Value = "8" + TokenType = Integer + TargetH = Yes +End + +TOKEN + Name = "PFAT_RECOVERY_FILE" + Value = "AMIPFAT.BIN" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes +End + +TOKEN + Name = "PFAT_RECOVERY_IMAGE_SIZE" + Value = "0xFF4CE0" + TokenType = Integer + TargetH = Yes +End + +TOKEN + Name = "PFAT_RECOVERY_IMAGE_SIZE" + Value = "0x10050c5" + TokenType = Integer + TargetH = Yes + Token = "OEM_ACTIVATION_TABLE_LOCATION" "=" "1" +End + +TOKEN + Name = "PfatRecoveryPeiLib" + Value = "$(BUILD_DIR)\PfatRecoveryPeiLib.lib" + TokenType = Expression + TargetMAK = Yes +End + +#-ELINK +#- Name = "$(BUILD_DIR)\PfatRecoveryPeiLib.lib" +#- Parent = "AMIPEILIB" +#- InvokeOrder = AfterParent +#-End + +ELINK + Name = "$(BUILD_DIR)\PfatRecovery.ffs" + Parent = "FV_BB" + InvokeOrder = AfterParent +End + +TOKEN + Name = "FwCapsuleInfo_enable" + Value = "0" + TokenType = Boolean +End + +TOKEN + Name = "FwCapsuleInfo_enable" + Value = "1" + TokenType = Boolean + Token = "SecureMod_SUPPORT" "=" "1" +End + +ELINK + Name = "PfatRecoveryFileInfo" + Parent = "AmiGetRecoveryFileInfo" + InvokeOrder = ReplaceParent + Token = "FwCapsuleInfo_enable" "=" "0" +End + +ELINK + Name = "PfatImageInfo" + Parent = "FwCapsuleInfo" + InvokeOrder = ReplaceParent + Token = "FwCapsuleInfo_enable" "=" "1" +End + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/Pfat/PfatRecovery/PfatRecoveryHook.c b/Board/EM/Pfat/PfatRecovery/PfatRecoveryHook.c new file mode 100644 index 0000000..e0a0bbe --- /dev/null +++ b/Board/EM/Pfat/PfatRecovery/PfatRecoveryHook.c @@ -0,0 +1,187 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecoveryHook.c 2 5/29/13 5:45p Fredericko $ +// +// $Revision: 2 $ +// +// $Date: 5/29/13 5:45p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelPfat/PfatRecovery/PfatRecoveryHook.c $ +// +// 2 5/29/13 5:45p Fredericko +// [TAG] EIP124189 +// [Description] [PFAT] Secure Flash is fail using +// 4.6.5.1_INTEL_PFAT_2_6 or 2_7 +// [Files] PfatPubKeysAndBuildPsl.sdl +// Pfatrecovery.sdl +// PfatRecoveryHook.c +// Recovery.mak +// +// 1 4/05/13 5:37p Fredericko +// [TAG] EIP119706 +// [Category] Improvement +// [Description] Support Recovery in pfat module +// [Files] PfatRecovery.cif +// PfatRecovery.sdl +// PfatRecovery.mak +// PfatRecovery.dxs +// PfatRecovery.c +// PfatRecoveryHook.c +// +// +//********************************************************************** +//<AMI_FHDR_START> +//---------------------------------------------------------------------- +// +// Name: +// +// Description: +// +//---------------------------------------------------------------------- +//<AMI_FHDR_END> + +//---------------------------------------------------------------------------- +// Includes +#include <AmiPeiLib.h> +#include <token.h> +#include <Setup.h> +#include <ppi\ReadOnlyVariable.h> + +// Statements that include other files + +//---------------------------------------------------------------------------- +// Function Externs + +//---------------------------------------------------------------------------- +// Local prototypes +#if defined(SecFlashUpd_SUPPORT) && SecFlashUpd_SUPPORT == 1 +EFI_STATUS +FwCapsuleInfo ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT VOID **pCapsuleName, + IN OUT UINTN *pCapsuleSize, + OUT BOOLEAN *ExtendedVerification +); +#else +AmiGetRecoveryFileInfo ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT VOID **pCapsuleName, + IN OUT UINTN *pCapsuleSize, + OUT BOOLEAN *ExtendedVerification +); +#endif + +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +// Local Variables +const char *RecoveryPfatFileName = CONVERT_TO_STRING(PFAT_RECOVERY_FILE); +const UINTN RecoveryPfatImageSize = PFAT_RECOVERY_IMAGE_SIZE; // 8k should be enough to cover Sec Capsule Hdr overhead + +//---------------------------------------------------------------------------- +// Function Definitions + +//---------------------------------------------------------------------------- +// Local Variables + +//---------------------------------------------------------------------------- +// Function Definitions +//<AMI_PHDR_START> +//---------------------------------------------------------------------- +// +// Procedure: PfatImageInfo +// +// Description: +// +// Input: EFI_PEI_SERVICES** PeiServices +// VOID** pPfatImageName +// UINTN* pPfatImageSize +// BOOLEAN* ExtendedVerification +// +// Output: EFI_STATUS +// +//---------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +PfatImageInfo ( + IN EFI_PEI_SERVICES **PeiServices, + IN OUT VOID **pPfatImageName, + IN OUT UINTN *pPfatImageSize, + OUT BOOLEAN *ExtendedVerification +){ + EFI_GUID gEfiPeiReadOnlyVariablePpiGuid = EFI_PEI_READ_ONLY_VARIABLE_PPI_GUID; + EFI_PEI_READ_ONLY_VARIABLE_PPI *ReadOnlyVar = NULL; + EFI_GUID SetupGuid = SETUP_GUID; + UINTN VariableSize= sizeof (SETUP_DATA); + SETUP_DATA SetupData; + EFI_STATUS Status; + + Status = (*PeiServices)->LocatePpi ( PeiServices, \ + &gEfiPeiReadOnlyVariablePpiGuid, \ + 0, \ + NULL, \ + &ReadOnlyVar ); + if ( !EFI_ERROR(Status) ) { + Status = ReadOnlyVar->GetVariable ( + PeiServices, + L"Setup", + &SetupGuid, + NULL, + &VariableSize, + &SetupData + ); + if ( EFI_ERROR( Status ) ) { + return Status; + } + } else { + return Status; + } + + if ( SetupData.Pfatstate == 0 ) { +#if defined(SecFlashUpd_SUPPORT) && SecFlashUpd_SUPPORT == 1 + Status = FwCapsuleInfo(PeiServices, pPfatImageName, pPfatImageSize, ExtendedVerification); +#else + Status = AmiGetRecoveryFileInfo(PeiServices, pPfatImageName, pPfatImageSize, ExtendedVerification); +#endif + return Status; + } else { + if(!pPfatImageName && !pPfatImageSize && !ExtendedVerification ) + return EFI_UNSUPPORTED; + + if(ExtendedVerification != NULL) + *ExtendedVerification = FALSE; + + *pPfatImageSize = RecoveryPfatImageSize; + *pPfatImageName = (VOID*)RecoveryPfatFileName; + } + return EFI_SUCCESS; +} + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2011, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* |