3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 This file includes a memory call back function notified when MRC is done,
16 following action is performed in this file,
17 1. ICH initialization after MRC.
18 2. SIO initialization.
19 3. Install ResetSystem and FinvFv PPI.
21 5. Create FV HOB and Flash HOB
27 #include "CommonHeader.h"
29 #include <Ppi/Cache.h>
30 #include <Library/BaseCryptLib.h>
31 #include <Library/PciLib.h>
32 #include "VlvAccess.h"
35 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode
[] = {
36 { (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
37 &gEfiPeiBootInRecoveryModePpiGuid
,
46 IN CONST EFI_PEI_SERVICES
**PeiServices
,
47 OUT UINT64
*LowMemoryLength
,
48 OUT UINT64
*HighMemoryLength
52 EFI_PEI_HOB_POINTERS Hob
;
54 *HighMemoryLength
= 0;
55 *LowMemoryLength
= 0x100000;
57 // Get the HOB list for processing
59 Status
= (*PeiServices
)->GetHobList (PeiServices
, (void **)&Hob
.Raw
);
60 if (EFI_ERROR(Status
)) {
65 // Collect memory ranges
67 while (!END_OF_HOB_LIST (Hob
)) {
68 if (Hob
.Header
->HobType
== EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
) {
69 if (Hob
.ResourceDescriptor
->ResourceType
== EFI_RESOURCE_SYSTEM_MEMORY
) {
71 // Need memory above 1MB to be collected here
73 if (Hob
.ResourceDescriptor
->PhysicalStart
>= 0x100000 &&
74 Hob
.ResourceDescriptor
->PhysicalStart
< (EFI_PHYSICAL_ADDRESS
) 0x100000000) {
75 *LowMemoryLength
+= (UINT64
) (Hob
.ResourceDescriptor
->ResourceLength
);
76 } else if (Hob
.ResourceDescriptor
->PhysicalStart
>= (EFI_PHYSICAL_ADDRESS
) 0x100000000) {
77 *HighMemoryLength
+= (UINT64
) (Hob
.ResourceDescriptor
->ResourceLength
);
81 Hob
.Raw
= GET_NEXT_HOB (Hob
);
89 This function will be called when MRC is done.
91 @param PeiServices General purpose services available to every PEIM.
92 @param NotifyDescriptor Information about the notify event..
93 @param Ppi The notify context.
95 @retval EFI_SUCCESS If the function completed successfully.
99 MemoryDiscoveredPpiNotifyCallback (
100 IN EFI_PEI_SERVICES
**PeiServices
,
101 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
106 EFI_BOOT_MODE BootMode
;
112 // Allocate LM memory and configure PDM if enabled by user.
113 // ConfigureLM(PeiServices);
115 (*PeiServices
)->GetBootMode (
116 (const EFI_PEI_SERVICES
**)PeiServices
,
120 if (BootMode
!= BOOT_ON_S3_RESUME
) {
121 Size
= (PcdGet32 (PcdFlashFvRecovery2Base
) - PcdGet32 (PcdFlashFvMainBase
)) + FixedPcdGet32(PcdFlashFvRecovery2Size
);
124 Memory
= AllocatePages ( Pages
);
125 CopyMem(Memory
, (VOID
*) FixedPcdGet32(PcdFlashFvMainBase
) , Size
);
128 // We don't verify just load
130 PeiServicesInstallFvInfoPpi (
132 (VOID
*) ((UINTN
) Memory
+ (PcdGet32 (PcdFlashFvRecovery2Base
) - PcdGet32 (PcdFlashFvMainBase
))),
133 PcdGet32 (PcdFlashFvRecovery2Size
),
138 PeiServicesInstallFvInfoPpi (
141 PcdGet32 (PcdFlashFvMainSize
),
148 if (BootMode
== BOOT_ON_S3_RESUME
) {
149 PeiServicesInstallFvInfoPpi (
151 (VOID
*) (UINTN
) (PcdGet32 (PcdFlashFvRecovery2Base
)),
152 PcdGet32 (PcdFlashFvRecovery2Size
),