]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/AutoScanPei/AutoScanPei.c
MdeModulePkg-DxeCore: rename CoreGetMemoryMapPropertiesTable
[mirror_edk2.git] / EmulatorPkg / AutoScanPei / AutoScanPei.c
CommitLineData
949f388f 1/*++ @file\r
2\r
3Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
4Portions copyright (c) 2011, Apple Inc. All rights reserved.\r
d18d8a1d 5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
949f388f 12\r
13**/\r
14\r
15#include "PiPei.h"\r
16#include <Ppi/EmuThunk.h>\r
17#include <Ppi/MemoryDiscovered.h>\r
18\r
19#include <Library/DebugLib.h>\r
20#include <Library/PeimEntryPoint.h>\r
21#include <Library/BaseLib.h>\r
22#include <Library/BaseMemoryLib.h>\r
23#include <Library/HobLib.h>\r
24#include <Library/PeiServicesLib.h>\r
25#include <Library/PeiServicesTablePointerLib.h>\r
26\r
27EFI_STATUS\r
28EFIAPI\r
29PeimInitializeAutoScanPei (\r
30 IN EFI_PEI_FILE_HANDLE FileHandle,\r
31 IN CONST EFI_PEI_SERVICES **PeiServices\r
32 )\r
33/*++\r
34\r
35Routine Description:\r
36 Perform a call-back into the SEC simulator to get a memory value\r
37\r
38Arguments:\r
39 FfsHeader - General purpose data available to every PEIM\r
40 PeiServices - General purpose services available to every PEIM.\r
d18d8a1d 41\r
949f388f 42Returns:\r
43 None\r
44\r
45**/\r
46{\r
47 EFI_STATUS Status;\r
48 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
49 EMU_THUNK_PPI *Thunk;\r
50 UINT64 MemorySize;\r
51 EFI_PHYSICAL_ADDRESS MemoryBase;\r
52 UINTN Index;\r
53 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
54\r
55\r
56 DEBUG ((EFI_D_ERROR, "Emu Autoscan PEIM Loaded\n"));\r
57\r
58 //\r
59 // Get the PEI UNIX Autoscan PPI\r
60 //\r
61 Status = PeiServicesLocatePpi (\r
62 &gEmuThunkPpiGuid, // GUID\r
63 0, // INSTANCE\r
64 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r
65 (VOID **)&Thunk // PPI\r
66 );\r
67 ASSERT_EFI_ERROR (Status);\r
68\r
69 Index = 0;\r
70 do {\r
71 Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);\r
72 if (!EFI_ERROR (Status)) {\r
73 Attributes =\r
74 (\r
75 EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
76 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
77 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
78 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
79 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
80 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r
81 );\r
82\r
83 if (Index == 0) {\r
84 //\r
85 // Register the memory with the PEI Core\r
86 //\r
87 Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);\r
88 ASSERT_EFI_ERROR (Status);\r
89\r
90 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;\r
91 }\r
d18d8a1d 92\r
949f388f 93 BuildResourceDescriptorHob (\r
94 EFI_RESOURCE_SYSTEM_MEMORY,\r
95 Attributes,\r
96 MemoryBase,\r
97 MemorySize\r
98 );\r
99 }\r
100 Index++;\r
101 } while (!EFI_ERROR (Status));\r
102\r
103 //\r
104 // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
105 //\r
106 BuildCpuHob (36, 16);\r
d18d8a1d 107\r
949f388f 108 return Status;\r
109}\r