]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/PlatformPei/MemoryCallback.c
Pkg-Module: CorebootModulePkg
[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
106 EFI_STATUS Status;\r
107 EFI_BOOT_MODE BootMode;\r
108 UINT32 Pages;\r
109 VOID* Memory;\r
110 UINTN Size;\r
111\r
112 //\r
113 // Allocate LM memory and configure PDM if enabled by user.\r
114 // ConfigureLM(PeiServices);\r
115 //\r
116 Status = (*PeiServices)->GetBootMode (\r
117 (const EFI_PEI_SERVICES **)PeiServices,\r
118 &BootMode\r
119 );\r
120\r
121 if (BootMode != BOOT_ON_S3_RESUME) {\r
122 Size = (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase)) + FixedPcdGet32(PcdFlashFvRecovery2Size);\r
123 Pages= Size/0x1000;\r
124\r
125 Memory = AllocatePages ( Pages );\r
126 CopyMem(Memory , (VOID *) FixedPcdGet32(PcdFlashFvMainBase) , Size);\r
127\r
128 //\r
129 // We don't verify just load\r
130 //\r
131 PeiServicesInstallFvInfoPpi (\r
132 NULL,\r
133 (VOID *) ((UINTN) Memory + (PcdGet32 (PcdFlashFvRecovery2Base) - PcdGet32 (PcdFlashFvMainBase))),\r
134 PcdGet32 (PcdFlashFvRecovery2Size),\r
135 NULL,\r
136 NULL\r
137 );\r
138\r
139 PeiServicesInstallFvInfoPpi (\r
140 NULL,\r
141 (VOID *) Memory,\r
142 PcdGet32 (PcdFlashFvMainSize),\r
143 NULL,\r
144 NULL\r
145 );\r
146\r
147 }\r
148\r
149 if (BootMode == BOOT_ON_S3_RESUME) {\r
150 PeiServicesInstallFvInfoPpi (\r
151 NULL,\r
152 (VOID *) (UINTN) (PcdGet32 (PcdFlashFvRecovery2Base)),\r
153 PcdGet32 (PcdFlashFvRecovery2Size),\r
154 NULL,\r
155 NULL\r
156 );\r
157 }\r
158\r
159 return EFI_SUCCESS;\r
160}\r