3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 This file includes a memory call back function notified when MRC is done,
11 following action is performed in this file,
12 1. ICH initialization after MRC.
13 2. SIO initialization.
14 3. Install ResetSystem and FinvFv PPI.
16 5. Create FV HOB and Flash HOB
22 #include "CommonHeader.h"
24 #include <Ppi/Cache.h>
25 #include <Library/BaseCryptLib.h>
26 #include <Library/PciLib.h>
27 #include "VlvAccess.h"
30 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode
[] = {
31 { (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
32 &gEfiPeiBootInRecoveryModePpiGuid
,
41 IN CONST EFI_PEI_SERVICES
**PeiServices
,
42 OUT UINT64
*LowMemoryLength
,
43 OUT UINT64
*HighMemoryLength
47 EFI_PEI_HOB_POINTERS Hob
;
49 *HighMemoryLength
= 0;
50 *LowMemoryLength
= 0x100000;
52 // Get the HOB list for processing
54 Status
= (*PeiServices
)->GetHobList (PeiServices
, (void **)&Hob
.Raw
);
55 if (EFI_ERROR(Status
)) {
60 // Collect memory ranges
62 while (!END_OF_HOB_LIST (Hob
)) {
63 if (Hob
.Header
->HobType
== EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
) {
64 if (Hob
.ResourceDescriptor
->ResourceType
== EFI_RESOURCE_SYSTEM_MEMORY
) {
66 // Need memory above 1MB to be collected here
68 if (Hob
.ResourceDescriptor
->PhysicalStart
>= 0x100000 &&
69 Hob
.ResourceDescriptor
->PhysicalStart
< (EFI_PHYSICAL_ADDRESS
) 0x100000000) {
70 *LowMemoryLength
+= (UINT64
) (Hob
.ResourceDescriptor
->ResourceLength
);
71 } else if (Hob
.ResourceDescriptor
->PhysicalStart
>= (EFI_PHYSICAL_ADDRESS
) 0x100000000) {
72 *HighMemoryLength
+= (UINT64
) (Hob
.ResourceDescriptor
->ResourceLength
);
76 Hob
.Raw
= GET_NEXT_HOB (Hob
);
84 This function will be called when MRC is done.
86 @param PeiServices General purpose services available to every PEIM.
87 @param NotifyDescriptor Information about the notify event..
88 @param Ppi The notify context.
90 @retval EFI_SUCCESS If the function completed successfully.
94 MemoryDiscoveredPpiNotifyCallback (
95 IN EFI_PEI_SERVICES
**PeiServices
,
96 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
101 EFI_BOOT_MODE BootMode
;
107 // Allocate LM memory and configure PDM if enabled by user.
108 // ConfigureLM(PeiServices);
110 (*PeiServices
)->GetBootMode (
111 (const EFI_PEI_SERVICES
**)PeiServices
,
115 if (BootMode
!= BOOT_ON_S3_RESUME
) {
116 Size
= (PcdGet32 (PcdFlashFvRecovery2Base
) - PcdGet32 (PcdFlashFvMainBase
)) + FixedPcdGet32(PcdFlashFvRecovery2Size
);
119 Memory
= AllocatePages ( Pages
);
120 CopyMem(Memory
, (VOID
*) FixedPcdGet32(PcdFlashFvMainBase
) , Size
);
123 // We don't verify just load
125 PeiServicesInstallFvInfoPpi (
127 (VOID
*) ((UINTN
) Memory
+ (PcdGet32 (PcdFlashFvRecovery2Base
) - PcdGet32 (PcdFlashFvMainBase
))),
128 PcdGet32 (PcdFlashFvRecovery2Size
),
133 PeiServicesInstallFvInfoPpi (
136 PcdGet32 (PcdFlashFvMainSize
),
143 if (BootMode
== BOOT_ON_S3_RESUME
) {
144 PeiServicesInstallFvInfoPpi (
146 (VOID
*) (UINTN
) (PcdGet32 (PcdFlashFvRecovery2Base
)),
147 PcdGet32 (PcdFlashFvRecovery2Size
),