diff options
Diffstat (limited to 'IntelFspWrapperPkg/FspInitPei')
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/FspInitPei.c | 168 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/FspInitPei.h | 14 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/FspInitPei.inf | 16 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/FspInitPeiV1.c | 181 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/FspInitPeiV2.c | 331 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/FspNotifyS3.c | 24 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/SecFspInitDone.c | 57 | ||||
-rw-r--r-- | IntelFspWrapperPkg/FspInitPei/SecMain.c | 43 |
8 files changed, 609 insertions, 225 deletions
diff --git a/IntelFspWrapperPkg/FspInitPei/FspInitPei.c b/IntelFspWrapperPkg/FspInitPei/FspInitPei.c index 823f1bbef8..17a646836a 100644 --- a/IntelFspWrapperPkg/FspInitPei/FspInitPei.c +++ b/IntelFspWrapperPkg/FspInitPei/FspInitPei.c @@ -1,9 +1,7 @@ /** @file
- This PEIM will be invoked twice by pei core. In 1st entry, it will call FspInit API.
- In 2nd entry, it will parse the hoblist from fsp and report them into pei core.
- This file contains the main entrypoint of the PEIM.
+ This PEIM initialize FSP.
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -18,111 +16,6 @@ #include "FspInitPei.h"
/**
- FSP Init continuation function.
- Control will be returned to this callback function after FspInit API call.
-
- @param[in] Status Status of the FSP INIT API
- @param[in] HobListPtr Pointer to the HOB data structure defined in the PI specification.
-
-**/
-VOID
-ContinuationFunc (
- IN FSP_STATUS Status,
- IN VOID *HobListPtr
- )
-{
- EFI_BOOT_MODE BootMode;
- UINT64 StackSize;
- EFI_PHYSICAL_ADDRESS StackBase;
-
- DEBUG ((DEBUG_INFO, "ContinuationFunc - %r\n", Status));
- DEBUG ((DEBUG_INFO, "HobListPtr - 0x%x\n", HobListPtr));
-
- if (Status != FSP_SUCCESS) {
- CpuDeadLoop ();
- }
-
- //
- // Can not call any PeiServices
- //
- BootMode = GetBootMode ();
-
- GetStackInfo (BootMode, TRUE, &StackBase, &StackSize);
- DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));
- DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));
- CallPeiCoreEntryPoint (
- HobListPtr,
- (VOID *)(UINTN)StackBase,
- (VOID *)(UINTN)(StackBase + StackSize)
- );
-}
-
-/**
- Call FspInit API.
-
- @param[in] FspHeader FSP header pointer.
-**/
-VOID
-SecFspInit (
- IN FSP_INFO_HEADER *FspHeader
- )
-{
- FSP_INIT_PARAMS FspInitParams;
- FSP_INIT_RT_COMMON_BUFFER FspRtBuffer;
- UINT8 FspUpdRgn[FixedPcdGet32 (PcdMaxUpdRegionSize)];
- UINT32 UpdRegionSize;
- EFI_BOOT_MODE BootMode;
- UINT64 StackSize;
- EFI_PHYSICAL_ADDRESS StackBase;
- FSP_STATUS FspStatus;
-
- DEBUG ((DEBUG_INFO, "SecFspInit enter\n"));
-
- PeiServicesGetBootMode (&BootMode);
- DEBUG ((DEBUG_INFO, "BootMode - 0x%x\n", BootMode));
-
- GetStackInfo (BootMode, FALSE, &StackBase, &StackSize);
- DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));
- DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));
-
- ZeroMem (&FspRtBuffer, sizeof(FspRtBuffer));
- FspRtBuffer.StackTop = (UINT32 *)(UINTN)(StackBase + StackSize);
-
- FspRtBuffer.BootMode = BootMode;
-
- /* Platform override any UPD configs */
- UpdRegionSize = GetUpdRegionSize();
- DEBUG ((DEBUG_INFO, "UpdRegionSize - 0x%x\n", UpdRegionSize));
- DEBUG ((DEBUG_INFO, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn)));
- ASSERT(sizeof(FspUpdRgn) >= UpdRegionSize);
- ZeroMem (FspUpdRgn, UpdRegionSize);
- FspRtBuffer.UpdDataRgnPtr = UpdateFspUpdConfigs (FspUpdRgn);
-
- ZeroMem (&FspInitParams, sizeof(FspInitParams));
- FspInitParams.NvsBufferPtr = GetNvsBuffer ();
- DEBUG ((DEBUG_INFO, "NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));
- FspInitParams.RtBufferPtr = (VOID *)&FspRtBuffer;
- FspInitParams.ContinuationFunc = (CONTINUATION_PROC)ContinuationFunc;
-
- SaveSecContext (GetPeiServicesTablePointer ());
-
- DEBUG ((DEBUG_INFO, "FspInitParams - 0x%x\n", &FspInitParams));
- DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));
- DEBUG ((DEBUG_INFO, " RtBufferPtr - 0x%x\n", FspInitParams.RtBufferPtr));
- DEBUG ((DEBUG_INFO, " StackTop - 0x%x\n", FspRtBuffer.StackTop));
- DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspRtBuffer.BootMode));
- DEBUG ((DEBUG_INFO, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer.UpdDataRgnPtr));
- DEBUG ((DEBUG_INFO, " ContinuationFunc - 0x%x\n", FspInitParams.ContinuationFunc));
-
- FspStatus = CallFspInit (FspHeader, &FspInitParams);
- //
- // Should never return
- //
- DEBUG((DEBUG_ERROR, "FSP Init failed, status: 0x%x\n", FspStatus));
- CpuDeadLoop ();
-}
-
-/**
This is the entrypoint of PEIM
@param[in] FileHandle Handle of the file being invoked.
@@ -138,50 +31,31 @@ FspPeiEntryPoint ( )
{
FSP_INFO_HEADER *FspHeader;
- EFI_STATUS Status;
- FSP_INIT_DONE_PPI *FspInitDone;
- VOID *FspHobList;
- EFI_BOOT_MODE BootMode;
+ UINT8 PcdFspApiVersion;
DEBUG ((DEBUG_INFO, "FspPeiEntryPoint\n"));
+ PcdFspApiVersion = 1;
- Status = PeiServicesLocatePpi (
- &gFspInitDonePpiGuid,
- 0,
- NULL,
- (VOID **) &FspInitDone
- );
- if (EFI_ERROR (Status)) {
- //
- // 1st entry
- //
- DEBUG ((DEBUG_INFO, "1st entry\n"));
- FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));
- DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", FspHeader));
- if (FspHeader == NULL) {
- return EFI_DEVICE_ERROR;
- }
+ FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));
+ DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", FspHeader));
+ if (FspHeader == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
- SecFspInit (FspHeader);
+ if ((PcdGet8 (PcdFspApiVersion) >= 2) &&
+ (FspHeader->HeaderRevision >= FSP_HEADER_REVISION_2) &&
+ (FspHeader->ApiEntryNum >= 6) &&
+ (FspHeader->FspMemoryInitEntryOffset != 0) &&
+ (FspHeader->TempRamExitEntryOffset != 0) &&
+ (FspHeader->FspSiliconInitEntryOffset != 0) ) {
+ PcdFspApiVersion = FSP_HEADER_REVISION_2;
+ }
+ DEBUG ((DEBUG_INFO, "PcdFspApiVersion - 0x%x\n", PcdFspApiVersion));
- //
- // Never return here
- //
- CpuDeadLoop ();
+ if (PcdFspApiVersion == FSP_HEADER_REVISION_1) {
+ PeiFspInitV1 (FspHeader);
} else {
- //
- // 2nd entry
- //
- DEBUG ((DEBUG_INFO, "2nd entry\n"));
- Status = FspInitDone->GetFspHobList (PeiServices, FspInitDone, &FspHobList);
- DEBUG ((DEBUG_INFO, "FspHobList - 0x%x\n", FspHobList));
- FspHobProcess (FspHobList);
-
- PeiServicesGetBootMode (&BootMode);
- if (BootMode == BOOT_ON_S3_RESUME) {
- Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);
- ASSERT_EFI_ERROR (Status);
- }
+ PeiFspInitV2 (FspHeader);
}
return EFI_SUCCESS;
diff --git a/IntelFspWrapperPkg/FspInitPei/FspInitPei.h b/IntelFspWrapperPkg/FspInitPei/FspInitPei.h index 5118cd04e3..fd4b707684 100644 --- a/IntelFspWrapperPkg/FspInitPei/FspInitPei.h +++ b/IntelFspWrapperPkg/FspInitPei/FspInitPei.h @@ -1,7 +1,7 @@ /** @file
This is PEIM header file.
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -32,7 +32,19 @@ #include <Ppi/FspInitDone.h>
#include <Ppi/EndOfPeiPhase.h>
+#include <Ppi/MemoryDiscovered.h>
+#include <Ppi/TemporaryRamDone.h>
extern EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc;
+EFI_STATUS
+PeiFspInitV1 (
+ IN FSP_INFO_HEADER *FspHeader
+ );
+
+EFI_STATUS
+PeiFspInitV2 (
+ IN FSP_INFO_HEADER *FspHeader
+ );
+
#endif
diff --git a/IntelFspWrapperPkg/FspInitPei/FspInitPei.inf b/IntelFspWrapperPkg/FspInitPei/FspInitPei.inf index 500c9fd238..97e88138bd 100644 --- a/IntelFspWrapperPkg/FspInitPei/FspInitPei.inf +++ b/IntelFspWrapperPkg/FspInitPei/FspInitPei.inf @@ -1,9 +1,13 @@ ## @file
# FSP PEI Module
#
-# This PEIM will be invoked twice by pei core. In 1st entry, it will call FspInit API.
-# In 2nd entry, it will parse the hoblist from fsp and report them into pei core.
-# including install the memory as required.
+# This PEIM initialize FSP.
+# In FSP API V1 mode, it will be invoked twice by pei core. In 1st entry, it will
+# call FspInit API. In 2nd entry, it will parse the hoblist from fsp and report
+# them into pei core.
+# In FSP API V2 mode, it will be invoked only once. It will call FspMemoryInit API,
+# register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
+# notify to call FspSiliconInit API.
#
# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
#
@@ -33,11 +37,12 @@ [Sources]
FspInitPei.c
FspInitPei.h
+ FspInitPeiV1.c
+ FspInitPeiV2.c
FspNotifyS3.c
SecMain.c
SecMain.h
FindPeiCore.c
- SecFspInitDone.c
[Packages]
MdePkg/MdePkg.dec
@@ -67,6 +72,8 @@ gTopOfTemporaryRamPpiGuid ## PRODUCES
gFspInitDonePpiGuid ## PRODUCES
gEfiEndOfPeiSignalPpiGuid ## PRODUCES
+ gEfiTemporaryRamDonePpiGuid ## PRODUCES
+ gEfiPeiMemoryDiscoveredPpiGuid ## PRODUCES
[FixedPcd]
gFspWrapperTokenSpaceGuid.PcdSecCoreMaxPpiSupported ## CONSUMES
@@ -76,6 +83,7 @@ gFspWrapperTokenSpaceGuid.PcdFlashFvFspBase ## CONSUMES
gFspWrapperTokenSpaceGuid.PcdFlashFvFspSize ## CONSUMES
gFspWrapperTokenSpaceGuid.PcdMaxUpdRegionSize ## CONSUMES
+ gFspWrapperTokenSpaceGuid.PcdFspApiVersion ## CONSUMES
[Depex]
gEfiPeiMasterBootModePpiGuid
diff --git a/IntelFspWrapperPkg/FspInitPei/FspInitPeiV1.c b/IntelFspWrapperPkg/FspInitPei/FspInitPeiV1.c new file mode 100644 index 0000000000..f6ffecb2ca --- /dev/null +++ b/IntelFspWrapperPkg/FspInitPei/FspInitPeiV1.c @@ -0,0 +1,181 @@ +/** @file
+ In FSP API V1 mode, it will be invoked twice by pei core. In 1st entry, it will
+ call FspInit API. In 2nd entry, it will parse the hoblist from fsp and report
+ them into pei core.
+
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include "FspInitPei.h"
+
+/**
+ FSP Init continuation function.
+ Control will be returned to this callback function after FspInit API call.
+
+ @param[in] Status Status of the FSP INIT API
+ @param[in] HobListPtr Pointer to the HOB data structure defined in the PI specification.
+
+**/
+VOID
+ContinuationFunc (
+ IN EFI_STATUS Status,
+ IN VOID *HobListPtr
+ )
+{
+ EFI_BOOT_MODE BootMode;
+ UINT64 StackSize;
+ EFI_PHYSICAL_ADDRESS StackBase;
+
+ DEBUG ((DEBUG_INFO, "ContinuationFunc - %r\n", Status));
+ DEBUG ((DEBUG_INFO, "HobListPtr - 0x%x\n", HobListPtr));
+
+ if (Status != EFI_SUCCESS) {
+ CpuDeadLoop ();
+ }
+
+ //
+ // Can not call any PeiServices
+ //
+ BootMode = GetBootMode ();
+
+ GetStackInfo (BootMode, TRUE, &StackBase, &StackSize);
+ DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));
+ DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));
+ CallPeiCoreEntryPoint (
+ HobListPtr,
+ (VOID *)(UINTN)StackBase,
+ (VOID *)(UINTN)(StackBase + StackSize)
+ );
+}
+
+/**
+ Call FspInit API.
+
+ @param[in] FspHeader FSP header pointer.
+**/
+VOID
+PeiFspInit (
+ IN FSP_INFO_HEADER *FspHeader
+ )
+{
+ FSP_INIT_PARAMS FspInitParams;
+ FSP_INIT_RT_COMMON_BUFFER FspRtBuffer;
+ UINT8 FspUpdRgn[FixedPcdGet32 (PcdMaxUpdRegionSize)];
+ UINT32 UpdRegionSize;
+ EFI_BOOT_MODE BootMode;
+ UINT64 StackSize;
+ EFI_PHYSICAL_ADDRESS StackBase;
+ EFI_STATUS Status;
+
+ DEBUG ((DEBUG_INFO, "PeiFspInit enter\n"));
+
+ PeiServicesGetBootMode (&BootMode);
+ DEBUG ((DEBUG_INFO, "BootMode - 0x%x\n", BootMode));
+
+ GetStackInfo (BootMode, FALSE, &StackBase, &StackSize);
+ DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));
+ DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));
+
+ ZeroMem (&FspRtBuffer, sizeof(FspRtBuffer));
+ FspRtBuffer.StackTop = (UINT32 *)(UINTN)(StackBase + StackSize);
+
+ FspRtBuffer.BootMode = BootMode;
+
+ /* Platform override any UPD configs */
+ UpdRegionSize = GetUpdRegionSize();
+ DEBUG ((DEBUG_INFO, "UpdRegionSize - 0x%x\n", UpdRegionSize));
+ DEBUG ((DEBUG_INFO, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn)));
+ ASSERT(sizeof(FspUpdRgn) >= UpdRegionSize);
+ ZeroMem (FspUpdRgn, UpdRegionSize);
+ FspRtBuffer.UpdDataRgnPtr = UpdateFspUpdConfigs (FspUpdRgn);
+
+ ZeroMem (&FspInitParams, sizeof(FspInitParams));
+ FspInitParams.NvsBufferPtr = GetNvsBuffer ();
+ DEBUG ((DEBUG_INFO, "NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));
+ FspInitParams.RtBufferPtr = (VOID *)&FspRtBuffer;
+ FspInitParams.ContinuationFunc = (CONTINUATION_PROC)ContinuationFunc;
+
+ SaveSecContext (GetPeiServicesTablePointer ());
+
+ DEBUG ((DEBUG_INFO, "FspInitParams - 0x%x\n", &FspInitParams));
+ DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));
+ DEBUG ((DEBUG_INFO, " RtBufferPtr - 0x%x\n", FspInitParams.RtBufferPtr));
+ DEBUG ((DEBUG_INFO, " StackTop - 0x%x\n", FspRtBuffer.StackTop));
+ DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspRtBuffer.BootMode));
+ DEBUG ((DEBUG_INFO, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer.UpdDataRgnPtr));
+ DEBUG ((DEBUG_INFO, " ContinuationFunc - 0x%x\n", FspInitParams.ContinuationFunc));
+
+ Status = CallFspInit (FspHeader, &FspInitParams);
+ //
+ // Should never return
+ //
+ DEBUG((DEBUG_ERROR, "FSP Init failed, status: 0x%x\n", Status));
+ CpuDeadLoop ();
+}
+
+/**
+ Do FSP initialization based on FspApi version 1.
+
+ @param[in] FspHeader FSP header pointer.
+
+ @return FSP initialization status.
+**/
+EFI_STATUS
+PeiFspInitV1 (
+ IN FSP_INFO_HEADER *FspHeader
+ )
+{
+ EFI_STATUS Status;
+ FSP_INIT_DONE_PPI *FspInitDone;
+ VOID *FspHobList;
+ EFI_BOOT_MODE BootMode;
+
+ Status = PeiServicesLocatePpi (
+ &gFspInitDonePpiGuid,
+ 0,
+ NULL,
+ (VOID **) &FspInitDone
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // 1st entry
+ //
+ DEBUG ((DEBUG_INFO, "1st entry\n"));
+
+ PeiFspInit (FspHeader);
+ //
+ // Never return here, for FspApi version 1.
+ //
+ CpuDeadLoop ();
+ } else {
+ //
+ // 2nd entry for FspApi version 1 only.
+ //
+ DEBUG ((DEBUG_INFO, "2nd entry\n"));
+
+ Status = FspInitDone->GetFspHobList (GetPeiServicesTablePointer (), FspInitDone, &FspHobList);
+ ASSERT_EFI_ERROR (Status);
+ DEBUG ((DEBUG_INFO, "FspHobList - 0x%x\n", FspHobList));
+ FspHobProcess (FspHobList);
+
+ //
+ // Register EndOfPei Notify for S3 to run FspNotifyPhase
+ //
+ PeiServicesGetBootMode (&BootMode);
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ return EFI_SUCCESS;
+}
\ No newline at end of file diff --git a/IntelFspWrapperPkg/FspInitPei/FspInitPeiV2.c b/IntelFspWrapperPkg/FspInitPei/FspInitPeiV2.c new file mode 100644 index 0000000000..6ddbf7f1b3 --- /dev/null +++ b/IntelFspWrapperPkg/FspInitPei/FspInitPeiV2.c @@ -0,0 +1,331 @@ +/** @file
+ In FSP API V2 mode, it will be invoked only once. It will call FspMemoryInit API,
+ register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi
+ notify to call FspSiliconInit API.
+
+ Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include "FspInitPei.h"
+
+/**
+ Return Hob list produced by FSP.
+
+ @param[in] PeiServices The pointer to the PEI Services Table.
+ @param[in] This The pointer to this instance of this PPI.
+ @param[out] FspHobList The pointer to Hob list produced by FSP.
+
+ @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
+**/
+EFI_STATUS
+EFIAPI
+FspInitDoneGetFspHobListV2 (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN FSP_INIT_DONE_PPI *This,
+ OUT VOID **FspHobList
+ );
+
+FSP_INIT_DONE_PPI mFspInitDonePpiV2 = {
+ FspInitDoneGetFspHobListV2
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPeiFspInitDonePpiV2 = {
+ EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gFspInitDonePpiGuid,
+ &mFspInitDonePpiV2
+};
+
+/**
+ This function is called after PEI core discover memory and finish migration.
+
+ @param[in] PeiServices Pointer to PEI Services Table.
+ @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
+ caused this function to execute.
+ @param[in] Ppi Pointer to the PPI data associated with this function.
+
+ @retval EFI_STATUS Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+PeiMemoryDiscoveredNotify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ );
+
+EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiMemoryDiscoveredPpiGuid,
+ PeiMemoryDiscoveredNotify
+};
+
+/**
+ TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
+ by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
+
+ @retval EFI_SUCCESS Use of Temporary RAM was disabled.
+ @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiTemporaryRamDone (
+ VOID
+ );
+
+EFI_PEI_TEMPORARY_RAM_DONE_PPI mPeiTemporaryRamDonePpi = {
+ PeiTemporaryRamDone
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPeiTemporaryRamDoneDesc = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiTemporaryRamDonePpiGuid,
+ &mPeiTemporaryRamDonePpi
+};
+
+/**
+ Return Hob list produced by FSP.
+
+ @param[in] PeiServices The pointer to the PEI Services Table.
+ @param[in] This The pointer to this instance of this PPI.
+ @param[out] FspHobList The pointer to Hob list produced by FSP.
+
+ @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
+**/
+EFI_STATUS
+EFIAPI
+FspInitDoneGetFspHobListV2 (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN FSP_INIT_DONE_PPI *This,
+ OUT VOID **FspHobList
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gFspInitDonePpiGuid);
+ if (GuidHob != NULL) {
+ *FspHobList = *(VOID **)GET_GUID_HOB_DATA (GuidHob);
+ return EFI_SUCCESS;
+ } else {
+ return EFI_NOT_FOUND;
+ }
+}
+
+/**
+ Call FspMemoryInit API.
+
+ @param[in] FspHeader FSP header pointer.
+
+ @return Status returned by FspMemoryInit API.
+**/
+EFI_STATUS
+PeiFspMemoryInit (
+ IN FSP_INFO_HEADER *FspHeader
+ )
+{
+ FSP_MEMORY_INIT_PARAMS FspMemoryInitParams;
+ FSP_INIT_RT_COMMON_BUFFER FspRtBuffer;
+ UINT8 FspUpdRgn[FixedPcdGet32 (PcdMaxUpdRegionSize)];
+ UINT32 UpdRegionSize;
+ EFI_BOOT_MODE BootMode;
+ UINT64 StackSize;
+ EFI_PHYSICAL_ADDRESS StackBase;
+ EFI_STATUS Status;
+ VOID *FspHobList;
+ VOID *HobData;
+
+ DEBUG ((DEBUG_INFO, "PeiFspMemoryInit enter\n"));
+
+ PeiServicesGetBootMode (&BootMode);
+ DEBUG ((DEBUG_INFO, "BootMode - 0x%x\n", BootMode));
+
+ GetStackInfo (BootMode, FALSE, &StackBase, &StackSize);
+ DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));
+ DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));
+
+ ZeroMem (&FspRtBuffer, sizeof(FspRtBuffer));
+ FspRtBuffer.StackTop = (UINT32 *)(UINTN)(StackBase + StackSize);
+
+ FspRtBuffer.BootMode = BootMode;
+
+ /* Platform override any UPD configs */
+ UpdRegionSize = GetUpdRegionSize();
+ DEBUG ((DEBUG_INFO, "UpdRegionSize - 0x%x\n", UpdRegionSize));
+ DEBUG ((DEBUG_INFO, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn)));
+ ASSERT(sizeof(FspUpdRgn) >= UpdRegionSize);
+ ZeroMem (FspUpdRgn, UpdRegionSize);
+ FspRtBuffer.UpdDataRgnPtr = UpdateFspUpdConfigs (FspUpdRgn);
+
+ ZeroMem (&FspMemoryInitParams, sizeof(FspMemoryInitParams));
+ FspMemoryInitParams.NvsBufferPtr = GetNvsBuffer ();
+ DEBUG ((DEBUG_INFO, "NvsBufferPtr - 0x%x\n", FspMemoryInitParams.NvsBufferPtr));
+ FspMemoryInitParams.RtBufferPtr = (VOID *)&FspRtBuffer;
+ FspMemoryInitParams.HobListPtr = &FspHobList;
+
+ DEBUG ((DEBUG_INFO, "FspMemoryInitParams - 0x%x\n", &FspMemoryInitParams));
+ DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspMemoryInitParams.NvsBufferPtr));
+ DEBUG ((DEBUG_INFO, " RtBufferPtr - 0x%x\n", FspMemoryInitParams.RtBufferPtr));
+ DEBUG ((DEBUG_INFO, " StackTop - 0x%x\n", FspRtBuffer.StackTop));
+ DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspRtBuffer.BootMode));
+ DEBUG ((DEBUG_INFO, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer.UpdDataRgnPtr));
+ DEBUG ((DEBUG_INFO, " HobListPtr - 0x%x\n", FspMemoryInitParams.HobListPtr));
+
+ Status = CallFspMemoryInit (FspHeader, &FspMemoryInitParams);
+ DEBUG((DEBUG_INFO, "FspMemoryInit status: 0x%x\n", Status));
+ ASSERT_EFI_ERROR (Status);
+
+ DEBUG ((DEBUG_INFO, " HobListPtr (returned) - 0x%x\n", FspHobList));
+
+ FspHobProcessForMemoryResource (FspHobList);
+
+ //
+ // FspHobList is not complete at this moment.
+ // Save FspHobList pointer to hob, so that it can be got later
+ //
+ HobData = BuildGuidHob (
+ &gFspInitDonePpiGuid,
+ sizeof (VOID *)
+ );
+ ASSERT (HobData != NULL);
+ CopyMem (HobData, &FspHobList, sizeof (FspHobList));
+
+ return Status;
+}
+
+/**
+ TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
+ by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
+
+ @retval EFI_SUCCESS Use of Temporary RAM was disabled.
+ @retval EFI_INVALID_PARAMETER Temporary RAM could not be disabled.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiTemporaryRamDone (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *TempRamExitParam;
+ FSP_INFO_HEADER *FspHeader;
+
+ FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));
+ if (FspHeader == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ DEBUG ((DEBUG_INFO, "PeiTemporaryRamDone enter\n"));
+
+ TempRamExitParam = GetTempRamExitParam ();
+ Status = CallTempRamExit (FspHeader, TempRamExitParam);
+ DEBUG((DEBUG_INFO, "TempRamExit status: 0x%x\n", Status));
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function is called after PEI core discover memory and finish migration.
+
+ @param[in] PeiServices Pointer to PEI Services Table.
+ @param[in] NotifyDesc Pointer to the descriptor for the Notification event that
+ caused this function to execute.
+ @param[in] Ppi Pointer to the PPI data associated with this function.
+
+ @retval EFI_STATUS Always return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+PeiMemoryDiscoveredNotify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+ IN VOID *Ppi
+ )
+{
+ EFI_STATUS Status;
+ VOID *FspSiliconInitParam;
+ FSP_INFO_HEADER *FspHeader;
+ VOID *FspHobList;
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));
+ if (FspHeader == NULL) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ DEBUG ((DEBUG_INFO, "PeiMemoryDiscoveredNotify enter\n"));
+
+ FspSiliconInitParam = GetFspSiliconInitParam ();
+ Status = CallFspSiliconInit (FspHeader, FspSiliconInitParam);
+ DEBUG((DEBUG_ERROR, "FspSiliconInit status: 0x%x\n", Status));
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Now FspHobList complete, process it
+ //
+ GuidHob = GetFirstGuidHob (&gFspInitDonePpiGuid);
+ ASSERT (GuidHob != NULL);
+ FspHobList = *(VOID **)GET_GUID_HOB_DATA (GuidHob);
+ DEBUG ((DEBUG_INFO, "FspHobList - 0x%x\n", FspHobList));
+ FspHobProcessForOtherData (FspHobList);
+
+ //
+ // Install FspInitDonePpi so that any other driver can consume this info.
+ //
+ Status = PeiServicesInstallPpi (&mPeiFspInitDonePpiV2);
+ ASSERT_EFI_ERROR(Status);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Do FSP initialization based on FspApi version 2.
+
+ @param[in] FspHeader FSP header pointer.
+
+ @return FSP initialization status.
+**/
+EFI_STATUS
+PeiFspInitV2 (
+ IN FSP_INFO_HEADER *FspHeader
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
+
+ Status = PeiFspMemoryInit (FspHeader);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Install TempramDonePpi to run TempRamExit
+ //
+ Status = PeiServicesInstallPpi (&mPeiTemporaryRamDoneDesc);
+ ASSERT_EFI_ERROR(Status);
+
+ //
+ // Register MemoryDiscovered Nofity to run FspSiliconInit
+ //
+ Status = PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register EndOfPei Notify for S3 to run FspNotifyPhase
+ //
+ PeiServicesGetBootMode (&BootMode);
+ if (BootMode == BOOT_ON_S3_RESUME) {
+ Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ return EFI_SUCCESS;
+}
\ No newline at end of file diff --git a/IntelFspWrapperPkg/FspInitPei/FspNotifyS3.c b/IntelFspWrapperPkg/FspInitPei/FspNotifyS3.c index 6fd2b77588..f784b014a6 100644 --- a/IntelFspWrapperPkg/FspInitPei/FspNotifyS3.c +++ b/IntelFspWrapperPkg/FspInitPei/FspNotifyS3.c @@ -1,7 +1,7 @@ /** @file
In EndOfPei notify, it will call FspNotifyPhase API.
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -58,29 +58,23 @@ S3EndOfPeiNotify ( )
{
NOTIFY_PHASE_PARAMS NotifyPhaseParams;
- FSP_STATUS FspStatus;
+ EFI_STATUS Status;
FSP_INFO_HEADER *FspHeader;
FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));
if (FspHeader == NULL) {
return EFI_DEVICE_ERROR;
}
-
+
+ DEBUG ((DEBUG_INFO, "S3EndOfPeiNotify enter\n"));
+
NotifyPhaseParams.Phase = EnumInitPhaseAfterPciEnumeration;
- FspStatus = CallFspNotifyPhase (FspHeader, &NotifyPhaseParams);
- if (FspStatus != FSP_SUCCESS) {
- DEBUG((DEBUG_ERROR, "FSP S3NotifyPhase AfterPciEnumeration failed, status: 0x%x\n", FspStatus));
- } else {
- DEBUG((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration Success.\n"));
- }
+ Status = CallFspNotifyPhase (FspHeader, &NotifyPhaseParams);
+ DEBUG((DEBUG_INFO, "FSP S3NotifyPhase AfterPciEnumeration status: 0x%x\n", Status));
NotifyPhaseParams.Phase = EnumInitPhaseReadyToBoot;
- FspStatus = CallFspNotifyPhase (FspHeader, &NotifyPhaseParams);
- if (FspStatus != FSP_SUCCESS) {
- DEBUG((DEBUG_ERROR, "FSP S3NotifyPhase ReadyToBoot failed, status: 0x%x\n", FspStatus));
- } else {
- DEBUG((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot Success.\n"));
- }
+ Status = CallFspNotifyPhase (FspHeader, &NotifyPhaseParams);
+ DEBUG((DEBUG_INFO, "FSP S3NotifyPhase ReadyToBoot status: 0x%x\n", Status));
return EFI_SUCCESS;
}
diff --git a/IntelFspWrapperPkg/FspInitPei/SecFspInitDone.c b/IntelFspWrapperPkg/FspInitPei/SecFspInitDone.c deleted file mode 100644 index e109694062..0000000000 --- a/IntelFspWrapperPkg/FspInitPei/SecFspInitDone.c +++ /dev/null @@ -1,57 +0,0 @@ -/** @file
- Install FspInitDone PPI and GetFspHobList API.
-
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-
-#include "SecMain.h"
-
-FSP_INIT_DONE_PPI gFspInitDonePpi = {
- FspInitDoneGetFspHobList
-};
-
-/**
- Return Hob list produced by FSP.
-
- @param[in] PeiServices The pointer to the PEI Services Table.
- @param[in] This The pointer to this instance of this PPI.
- @param[out] FspHobList The pointer to Hob list produced by FSP.
-
- @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
-**/
-EFI_STATUS
-EFIAPI
-FspInitDoneGetFspHobList (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN FSP_INIT_DONE_PPI *This,
- OUT VOID **FspHobList
- )
-{
- VOID *TopOfTemporaryRamPpi;
- EFI_STATUS Status;
-
- Status = (*PeiServices)->LocatePpi (
- PeiServices,
- &gTopOfTemporaryRamPpiGuid,
- 0,
- NULL,
- (VOID **) &TopOfTemporaryRamPpi
- );
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
- }
-
- *FspHobList = (VOID *)(UINTN)(*(UINT32 *)((UINTN)TopOfTemporaryRamPpi - sizeof(UINT32)));
-
- return EFI_SUCCESS;
-}
-
diff --git a/IntelFspWrapperPkg/FspInitPei/SecMain.c b/IntelFspWrapperPkg/FspInitPei/SecMain.c index 10550e74de..4d0878a9df 100644 --- a/IntelFspWrapperPkg/FspInitPei/SecMain.c +++ b/IntelFspWrapperPkg/FspInitPei/SecMain.c @@ -1,7 +1,7 @@ /** @file
C functions in SEC
- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -28,6 +28,10 @@ EFI_PEI_PPI_DESCRIPTOR mPeiSecMainPpi[] = { },
};
+FSP_INIT_DONE_PPI gFspInitDonePpi = {
+ FspInitDoneGetFspHobList
+};
+
//
// These are IDT entries pointing to 10:FFFFFFE4h.
//
@@ -267,3 +271,40 @@ SecStartupPhase2( //
return ;
}
+
+/**
+ Return Hob list produced by FSP.
+
+ @param[in] PeiServices The pointer to the PEI Services Table.
+ @param[in] This The pointer to this instance of this PPI.
+ @param[out] FspHobList The pointer to Hob list produced by FSP.
+
+ @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.
+**/
+EFI_STATUS
+EFIAPI
+FspInitDoneGetFspHobList (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN FSP_INIT_DONE_PPI *This,
+ OUT VOID **FspHobList
+ )
+{
+ VOID *TopOfTemporaryRamPpi;
+ EFI_STATUS Status;
+
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gTopOfTemporaryRamPpiGuid,
+ 0,
+ NULL,
+ (VOID **) &TopOfTemporaryRamPpi
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ *FspHobList = (VOID *)(UINTN)(*(UINT32 *)((UINTN)TopOfTemporaryRamPpi - sizeof(UINT32)));
+
+ return EFI_SUCCESS;
+}
+
|