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