123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- /** @file
- Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
- This file includes a memory call back function notified when MRC is done,
- following action is performed in this file,
- 1. ICH initialization after MRC.
- 2. SIO initialization.
- 3. Install ResetSystem and FinvFv PPI.
- 4. Set MTRR for PEI
- 5. Create FV HOB and Flash HOB
- **/
- #include "CommonHeader.h"
- #include "Platform.h"
- #include <Library/BaseCryptLib.h>
- #include <Library/PciLib.h>
- #include "VlvAccess.h"
- EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode[] = {
- { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiPeiBootInRecoveryModePpiGuid,
- NULL
- }
- };
- #if 0
- STATIC
- EFI_STATUS
- GetMemorySize (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- OUT UINT64 *LowMemoryLength,
- OUT UINT64 *HighMemoryLength
- )
- {
- EFI_STATUS Status;
- EFI_PEI_HOB_POINTERS Hob;
- *HighMemoryLength = 0;
- *LowMemoryLength = 0x100000;
- //
- // Get the HOB list for processing
- //
- Status = (*PeiServices)->GetHobList (PeiServices, (void **)&Hob.Raw);
- if (EFI_ERROR(Status)) {
- return Status;
- }
- //
- // Collect memory ranges
- //
- while (!END_OF_HOB_LIST (Hob)) {
- if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
- if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
- //
- // Need memory above 1MB to be collected here
- //
- if (Hob.ResourceDescriptor->PhysicalStart >= 0x100000 &&
- Hob.ResourceDescriptor->PhysicalStart < (EFI_PHYSICAL_ADDRESS) 0x100000000) {
- *LowMemoryLength += (UINT64) (Hob.ResourceDescriptor->ResourceLength);
- } else if (Hob.ResourceDescriptor->PhysicalStart >= (EFI_PHYSICAL_ADDRESS) 0x100000000) {
- *HighMemoryLength += (UINT64) (Hob.ResourceDescriptor->ResourceLength);
- }
- }
- }
- Hob.Raw = GET_NEXT_HOB (Hob);
- }
- return EFI_SUCCESS;
- }
- #endif
- /**
- This function will be called when MRC is done.
- @param PeiServices General purpose services available to every PEIM.
- @param NotifyDescriptor Information about the notify event..
- @param Ppi The notify context.
- @retval EFI_SUCCESS If the function completed successfully.
- **/
- EFI_STATUS
- EFIAPI
- MemoryDiscoveredPpiNotifyCallback (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
- IN VOID *Ppi
- )
- {
- EFI_BOOT_MODE BootMode;
- UINT32 Pages;
- VOID* Memory;
- UINTN Size;
- //
- // Allocate LM memory and configure PDM if enabled by user.
- // ConfigureLM(PeiServices);
- //
- (*PeiServices)->GetBootMode (
- (const EFI_PEI_SERVICES **)PeiServices,
- &BootMode
- );
- if (BootMode != BOOT_ON_S3_RESUME) {
- Size = (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase)) + FixedPcdGet32(PcdFlashFvRecovery2Size);
- Pages= Size/0x1000;
- Memory = AllocatePages ( Pages );
- CopyMem(Memory , (VOID *) FixedPcdGet32(PcdFlashFvMainBase) , Size);
- //
- // We don't verify just load
- //
- PeiServicesInstallFvInfoPpi (
- NULL,
- (VOID *) ((UINTN) Memory + (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase))),
- PcdGet32 (PcdFlashFvRecovery2Size),
- NULL,
- NULL
- );
- PeiServicesInstallFvInfoPpi (
- NULL,
- (VOID *) Memory,
- PcdGet32 (PcdFlashFvMainSize),
- NULL,
- NULL
- );
- }
- if (BootMode == BOOT_ON_S3_RESUME) {
- PeiServicesInstallFvInfoPpi (
- NULL,
- (VOID *) (UINTN) (PcdGet32 (PcdFlashFvRecovery2Base)),
- PcdGet32 (PcdFlashFvRecovery2Size),
- NULL,
- NULL
- );
- }
- return EFI_SUCCESS;
- }
|