1 /** @file 2 3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 4 5 6 This program and the accompanying materials are licensed and made available under 7 8 the terms and conditions of the BSD License that accompanies this distribution. 9 10 The full text of the license may be found at 11 12 http://opensource.org/licenses/bsd-license.php. 13 14 15 16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 17 18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 19 20 21 22 23 24 This file includes a memory call back function notified when MRC is done, 25 following action is performed in this file, 26 1. ICH initialization after MRC. 27 2. SIO initialization. 28 3. Install ResetSystem and FinvFv PPI. 29 4. Set MTRR for PEI 30 5. Create FV HOB and Flash HOB 31 32 33 **/ 34 35 36 #include "CommonHeader.h" 37 #include "Platform.h" 38 #include <Ppi/Cache.h> 39 #include <Library/BaseCryptLib.h> 40 #include <Library/PciLib.h> 41 #include "VlvAccess.h" 42 43 44 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode[] = { 45 { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), 46 &gEfiPeiBootInRecoveryModePpiGuid, 47 NULL 48 } 49 }; 50 51 #if 0 52 STATIC 53 EFI_STATUS 54 GetMemorySize ( 55 IN CONST EFI_PEI_SERVICES **PeiServices, 56 OUT UINT64 *LowMemoryLength, 57 OUT UINT64 *HighMemoryLength 58 ) 59 { 60 EFI_STATUS Status; 61 EFI_PEI_HOB_POINTERS Hob; 62 63 *HighMemoryLength = 0; 64 *LowMemoryLength = 0x100000; 65 // 66 // Get the HOB list for processing 67 // 68 Status = (*PeiServices)->GetHobList (PeiServices, (void **)&Hob.Raw); 69 if (EFI_ERROR(Status)) { 70 return Status; 71 } 72 73 // 74 // Collect memory ranges 75 // 76 while (!END_OF_HOB_LIST (Hob)) { 77 if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { 78 if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) { 79 // 80 // Need memory above 1MB to be collected here 81 // 82 if (Hob.ResourceDescriptor->PhysicalStart >= 0x100000 && 83 Hob.ResourceDescriptor->PhysicalStart < (EFI_PHYSICAL_ADDRESS) 0x100000000) { 84 *LowMemoryLength += (UINT64) (Hob.ResourceDescriptor->ResourceLength); 85 } else if (Hob.ResourceDescriptor->PhysicalStart >= (EFI_PHYSICAL_ADDRESS) 0x100000000) { 86 *HighMemoryLength += (UINT64) (Hob.ResourceDescriptor->ResourceLength); 87 } 88 } 89 } 90 Hob.Raw = GET_NEXT_HOB (Hob); 91 } 92 93 return EFI_SUCCESS; 94 } 95 96 #endif 97 /** 98 This function will be called when MRC is done. MemoryDiscoveredPpiNotifyCallback(IN EFI_PEI_SERVICES ** PeiServices,IN EFI_PEI_NOTIFY_DESCRIPTOR * NotifyDescriptor,IN VOID * Ppi)99 100 @param PeiServices General purpose services available to every PEIM. 101 @param NotifyDescriptor Information about the notify event.. 102 @param Ppi The notify context. 103 104 @retval EFI_SUCCESS If the function completed successfully. 105 **/ 106 EFI_STATUS 107 EFIAPI 108 MemoryDiscoveredPpiNotifyCallback ( 109 IN EFI_PEI_SERVICES **PeiServices, 110 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, 111 IN VOID *Ppi 112 ) 113 { 114 115 EFI_BOOT_MODE BootMode; 116 UINT32 Pages; 117 VOID* Memory; 118 UINTN Size; 119 120 // 121 // Allocate LM memory and configure PDM if enabled by user. 122 // ConfigureLM(PeiServices); 123 // 124 (*PeiServices)->GetBootMode ( 125 (const EFI_PEI_SERVICES **)PeiServices, 126 &BootMode 127 ); 128 129 if (BootMode != BOOT_ON_S3_RESUME) { 130 Size = (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase)) + FixedPcdGet32(PcdFlashFvRecovery2Size); 131 Pages= Size/0x1000; 132 133 Memory = AllocatePages ( Pages ); 134 CopyMem(Memory , (VOID *) FixedPcdGet32(PcdFlashFvMainBase) , Size); 135 136 // 137 // We don't verify just load 138 // 139 PeiServicesInstallFvInfoPpi ( 140 NULL, 141 (VOID *) ((UINTN) Memory + (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase))), 142 PcdGet32 (PcdFlashFvRecovery2Size), 143 NULL, 144 NULL 145 ); 146 147 PeiServicesInstallFvInfoPpi ( 148 NULL, 149 (VOID *) Memory, 150 PcdGet32 (PcdFlashFvMainSize), 151 NULL, 152 NULL 153 ); 154 155 } 156 157 if (BootMode == BOOT_ON_S3_RESUME) { 158 PeiServicesInstallFvInfoPpi ( 159 NULL, 160 (VOID *) (UINTN) (PcdGet32 (PcdFlashFvRecovery2Base)), 161 PcdGet32 (PcdFlashFvRecovery2Size), 162 NULL, 163 NULL 164 ); 165 } 166 167 return EFI_SUCCESS; 168 } 169