]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/PlatformPei/MemoryCallback.c
MdeModulePkg/CapsuleApp: Center bitmap at bottom of screen
[mirror_edk2.git] / Vlv2TbltDevicePkg / PlatformPei / MemoryCallback.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
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.
9
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.
12
13
14
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.
20 4. Set MTRR for PEI
21 5. Create FV HOB and Flash HOB
22
23
24 **/
25
26
27 #include "CommonHeader.h"
28 #include "Platform.h"
29 #include <Ppi/Cache.h>
30 #include <Library/BaseCryptLib.h>
31 #include <Library/PciLib.h>
32 #include "VlvAccess.h"
33
34
35 EFI_PEI_PPI_DESCRIPTOR mPpiListRecoveryBootMode[] = {
36 { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
37 &gEfiPeiBootInRecoveryModePpiGuid,
38 NULL
39 }
40 };
41
42 #if 0
43 STATIC
44 EFI_STATUS
45 GetMemorySize (
46 IN CONST EFI_PEI_SERVICES **PeiServices,
47 OUT UINT64 *LowMemoryLength,
48 OUT UINT64 *HighMemoryLength
49 )
50 {
51 EFI_STATUS Status;
52 EFI_PEI_HOB_POINTERS Hob;
53
54 *HighMemoryLength = 0;
55 *LowMemoryLength = 0x100000;
56 //
57 // Get the HOB list for processing
58 //
59 Status = (*PeiServices)->GetHobList (PeiServices, (void **)&Hob.Raw);
60 if (EFI_ERROR(Status)) {
61 return Status;
62 }
63
64 //
65 // Collect memory ranges
66 //
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) {
70 //
71 // Need memory above 1MB to be collected here
72 //
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);
78 }
79 }
80 }
81 Hob.Raw = GET_NEXT_HOB (Hob);
82 }
83
84 return EFI_SUCCESS;
85 }
86
87 #endif
88 /**
89 This function will be called when MRC is done.
90
91 @param PeiServices General purpose services available to every PEIM.
92 @param NotifyDescriptor Information about the notify event..
93 @param Ppi The notify context.
94
95 @retval EFI_SUCCESS If the function completed successfully.
96 **/
97 EFI_STATUS
98 EFIAPI
99 MemoryDiscoveredPpiNotifyCallback (
100 IN EFI_PEI_SERVICES **PeiServices,
101 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
102 IN VOID *Ppi
103 )
104 {
105
106 EFI_BOOT_MODE BootMode;
107 UINT32 Pages;
108 VOID* Memory;
109 UINTN Size;
110
111 //
112 // Allocate LM memory and configure PDM if enabled by user.
113 // ConfigureLM(PeiServices);
114 //
115 (*PeiServices)->GetBootMode (
116 (const EFI_PEI_SERVICES **)PeiServices,
117 &BootMode
118 );
119
120 if (BootMode != BOOT_ON_S3_RESUME) {
121 Size = (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase)) + FixedPcdGet32(PcdFlashFvRecovery2Size);
122 Pages= Size/0x1000;
123
124 Memory = AllocatePages ( Pages );
125 CopyMem(Memory , (VOID *) FixedPcdGet32(PcdFlashFvMainBase) , Size);
126
127 //
128 // We don't verify just load
129 //
130 PeiServicesInstallFvInfoPpi (
131 NULL,
132 (VOID *) ((UINTN) Memory + (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase))),
133 PcdGet32 (PcdFlashFvRecovery2Size),
134 NULL,
135 NULL
136 );
137
138 PeiServicesInstallFvInfoPpi (
139 NULL,
140 (VOID *) Memory,
141 PcdGet32 (PcdFlashFvMainSize),
142 NULL,
143 NULL
144 );
145
146 }
147
148 if (BootMode == BOOT_ON_S3_RESUME) {
149 PeiServicesInstallFvInfoPpi (
150 NULL,
151 (VOID *) (UINTN) (PcdGet32 (PcdFlashFvRecovery2Base)),
152 PcdGet32 (PcdFlashFvRecovery2Size),
153 NULL,
154 NULL
155 );
156 }
157
158 return EFI_SUCCESS;
159 }